This page can used as playground or run by Playwright
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/core/src/utils/p-while.ts: -------------------------------------------------------------------------------- 1 | export const pWhile = asyncThis page can used as playground or run by Playwright
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/node/src/lib/get-message-id.ts: -------------------------------------------------------------------------------- 1 | import { uuid } from './uuid' 2 | 3 | /** 4 | * get a unique messageId with a very low chance of collisions 5 | * using @lukeed/uuid/secure uses the node crypto module, which is the fastest 6 | * @example "node-next-1668208232027-743be593-7789-4b74-8078-cbcc8894c586" 7 | */ 8 | export const createMessageId = (): string => { 9 | return `node-next-${Date.now()}-${uuid()}` 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/next-playground/public/demos/faulty-track.js: -------------------------------------------------------------------------------- 1 | const faultyTrack = { 2 | name: 'Fails to send', 3 | type: 'destination', 4 | version: '1.0', 5 | 6 | load: async () => {}, 7 | isLoaded: () => true, 8 | 9 | track(ctx) { 10 | if (ctx.event.context?.attempts < 2) { 11 | throw new Error('aaay') 12 | } 13 | 14 | return ctx 15 | }, 16 | } 17 | 18 | window.analytics.register(faultyTrack) 19 | -------------------------------------------------------------------------------- /packages/consent/consent-tools-integration-tests/src/page-bundles/onetrust/index.ts: -------------------------------------------------------------------------------- 1 | import { AnalyticsBrowser } from '@segment/analytics-next' 2 | import { withOneTrust } from '@segment/analytics-consent-wrapper-onetrust' 3 | 4 | const analytics = new AnalyticsBrowser() 5 | 6 | withOneTrust(analytics).load( 7 | { 8 | writeKey: 'foo', 9 | }, 10 | { initialPageview: true } 11 | ) 12 | ;(window as any).analytics = analytics 13 | -------------------------------------------------------------------------------- /packages/browser/src/test-helpers/helpers.ts: -------------------------------------------------------------------------------- 1 | import { sleep } from '@segment/analytics-core' 2 | 3 | export const waitForCondition = async ( 4 | condition: () => boolean, 5 | timeout = 1000 6 | ): Promise