This page can used as playground or run by webdriver.io
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /playgrounds/next-playground/public/demos/faulty-load.js: -------------------------------------------------------------------------------- 1 | const faultyLoad = { 2 | name: 'Fails to load', 3 | type: 'destination', 4 | version: '1.0', 5 | 6 | load: () => { 7 | return new Promise((_res, rej) => { 8 | setTimeout(() => { 9 | rej(new Error('aaay')) 10 | }, 2000) 11 | }) 12 | }, 13 | 14 | isLoaded: () => false, 15 | } 16 | 17 | window.analytics.register(faultyLoad) 18 | -------------------------------------------------------------------------------- /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-wrapper-onetrust/src/test-helpers/onetrust-globals.d.ts: -------------------------------------------------------------------------------- 1 | import { OneTrustGlobal } from '../lib/onetrust-api' 2 | /** 3 | * ALERT: It's OK to declare ambient globals in test code, but __not__ in library code 4 | * This file should not be included in the final package 5 | */ 6 | export declare global { 7 | interface Window { 8 | OneTrust: OneTrustGlobal 9 | OnetrustActiveGroups: string 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /playgrounds/next-playground/public/demos/faulty-middleware.js: -------------------------------------------------------------------------------- 1 | const faultyMiddleware = { 2 | name: 'Fails to run before', 3 | type: 'before', 4 | version: '1.0', 5 | 6 | load: async () => {}, 7 | isLoaded: () => true, 8 | 9 | track(ctx) { 10 | if (ctx.event.context?.attempts < 4) { 11 | throw new Error('aaay') 12 | } 13 | 14 | return ctx 15 | }, 16 | } 17 | 18 | window.analytics.register(faultyMiddleware) 19 | -------------------------------------------------------------------------------- /packages/browser/src/lib/get-global.ts: -------------------------------------------------------------------------------- 1 | // This an imperfect polyfill for globalThis 2 | export const getGlobal = () => { 3 | if (typeof globalThis !== 'undefined') { 4 | return globalThis 5 | } 6 | if (typeof self !== 'undefined') { 7 | return self 8 | } 9 | if (typeof window !== 'undefined') { 10 | return window 11 | } 12 | if (typeof global !== 'undefined') { 13 | return global 14 | } 15 | return null 16 | } 17 | -------------------------------------------------------------------------------- /packages/node-integration-tests/src/server/fixtures.ts: -------------------------------------------------------------------------------- 1 | import crypto from 'crypto' 2 | 3 | export const trackEventSmall = { 4 | userId: '019mr8mf4r', 5 | event: 'Order Completed', 6 | properties: { userId: 'foo', event: 'click' }, 7 | } 8 | 9 | export const trackEventLarge = { 10 | ...trackEventSmall, 11 | properties: { 12 | ...trackEventSmall.properties, 13 | data: crypto.randomBytes(1024 * 6).toString(), 14 | }, 15 | } 16 | -------------------------------------------------------------------------------- /playgrounds/with-vite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |