@walkeros/server-destination-rudderstack 4.8.1-next-1792019907609 → 4.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n writeKey: z\n .string()\n .min(1)\n .describe(\n 'RudderStack source write key. Find it in the RudderStack dashboard under Sources > Setup.',\n ),\n dataPlaneUrl: z\n .string()\n .url()\n .describe(\n 'RudderStack data plane URL. Required. Example: https://your-data-plane.rudderstack.com',\n ),\n userId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve userId from each event (like user.id).',\n )\n .optional(),\n anonymousId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve anonymousId from each event (like user.session).',\n )\n .optional(),\n path: z.string().describe('API path route (like /v1/batch).').optional(),\n flushAt: z\n .number()\n .int()\n .positive()\n .describe('Events to enqueue before flushing a batch. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .int()\n .positive()\n .describe('Max milliseconds before auto-flush. Default: 10000.')\n .optional(),\n maxQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Maximum batch payload size in bytes. Default: 460800 (~500KB).')\n .optional(),\n maxInternalQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Maximum in-memory queue length. Default: 20000.')\n .optional(),\n logLevel: z\n .string()\n .describe(\n \"SDK log level: 'info', 'debug', 'error', or 'silly'. Default: 'info'.\",\n )\n .optional(),\n retryCount: z\n .number()\n .int()\n .min(0)\n .describe('Retry attempts for failed batches. Default: 3.')\n .optional(),\n enable: z\n .boolean()\n .describe('Set to false to no-op all SDK calls. Default: true.')\n .optional(),\n gzip: z\n .boolean()\n .describe('Enable gzip compression for requests. Default: true.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to { traits } object. Fires identify() on the first push and re-fires when values change.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Destination-level group mapping. Resolves to { groupId, traits }. Fires group() on the first push and re-fires on change.',\n )\n .optional(),\n integrations: z\n .record(z.string(), z.unknown())\n .describe(\n 'Enable/disable downstream RudderStack destinations. Example: { \"All\": true, \"Mixpanel\": false }.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { userId?, traits? }. Use with rule-level silent: true on login/identify events.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Per-event group assignment. Resolves to { groupId, traits? }. Use with rule-level silent: true on company/team events.',\n )\n .optional(),\n page: z\n .unknown()\n .describe(\n 'Per-event page call. Resolves to { name, properties? } or true for minimal page(). RudderStack requires name (falls back to empty string). Use with silent: true.',\n )\n .optional(),\n screen: z\n .unknown()\n .describe(\n 'Per-event screen call (mobile backends). Resolves to { name, properties? } or true for minimal screen(). RudderStack requires name (falls back to empty string). Use with silent: true.',\n )\n .optional(),\n alias: z\n .unknown()\n .describe(\n 'Per-event alias call. Resolves to { previousId }. Links anonymous user to identified user. Use with rule-level silent: true.',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env, RudderStackAnalyticsMock } from '../types';\n\ntype SdkCall = (_params: Record<string, unknown>) => void;\ntype SdkFlush = (\n _callback?: (err?: Error, data?: unknown) => void,\n) => Promise<void>;\n\nconst noop: SdkCall = () => {};\nconst asyncNoop: SdkFlush = () => Promise.resolve();\n\nfunction createMockAnalytics(): RudderStackAnalyticsMock {\n return {\n track: noop,\n identify: noop,\n group: noop,\n page: noop,\n screen: noop,\n alias: noop,\n flush: asyncNoop,\n };\n}\n\nexport const push: Env = {\n analytics: createMockAnalytics(),\n};\n\nexport const simulation = [\n 'call:analytics.track',\n 'call:analytics.identify',\n 'call:analytics.group',\n 'call:analytics.page',\n 'call:analytics.screen',\n 'call:analytics.alias',\n];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type RudderStackStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * RudderStack server destination invokes the injected `env.analytics` SDK\n * methods (`track`, `identify`, `group`, `page`, `screen`, `alias`) - not a\n * raw HTTP endpoint. Each `out` entry is therefore\n * `[callable, params]` where `callable` is the dotted method name\n * (e.g. `'analytics.track'`) and `params` is the object passed to the SDK.\n *\n * Examples may emit multiple calls in order (e.g. identify + track), so\n * every `out` is wrapped as `[[callable, params], ...]`.\n */\n\n/**\n * Default event forwarding -- analytics.track() with event name and empty\n * properties. userId resolved from default settings.userId = 'user.id'.\n */\nexport const defaultTrack: RudderStackStepExample = {\n title: 'Default track',\n description:\n 'A walker event becomes a RudderStack analytics.track call with userId and anonymousId resolved from the event.',\n in: getEvent('product view', {\n timestamp: 1700000100,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n out: [\n [\n 'analytics.track',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'product view',\n properties: {},\n timestamp: new Date(1700000100),\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- mapping.name renames the event for RudderStack.\n */\nexport const mappedEventName: RudderStackStepExample = {\n title: 'Renamed event',\n description:\n 'A mapping renames the event so the RudderStack track call uses a canonical name such as Order Completed.',\n in: getEvent('order complete', {\n timestamp: 1700000101,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n mapping: {\n name: 'Order Completed',\n },\n out: [\n [\n 'analytics.track',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'Order Completed',\n properties: {},\n timestamp: new Date(1700000101),\n },\n ],\n ],\n};\n\n/**\n * Destination-level identify -- fires analytics.identify() on first push\n * when settings.identify mapping resolves. Then fires analytics.track().\n */\nexport const destinationIdentify: RudderStackStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify fires analytics.identify with traits on the first push only, then the track call follows.',\n in: getEvent('page view', {\n timestamp: 1700000102,\n user: { id: 'us3r', session: 's3ss10n', email: 'user@example.com' },\n }),\n settings: {\n identify: {\n map: {\n traits: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n traits: { email: 'user@example.com' },\n timestamp: new Date(1700000102),\n },\n ],\n [\n 'analytics.track',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'page view',\n properties: {},\n timestamp: new Date(1700000102),\n },\n ],\n ],\n};\n\n/**\n * Per-event identify with silent -- user login fires identify() only.\n */\nexport const userLoginIdentify: RudderStackStepExample = {\n title: 'User login identify',\n description:\n 'A user login fires only an analytics.identify call with the resolved userId and traits, skipping the track.',\n in: getEvent('user login', {\n timestamp: 1700000103,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n userId: 'data.user_id',\n traits: {\n map: {\n email: 'data.email',\n name: 'data.name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n {\n userId: 'new-user-123',\n anonymousId: 's3ss10n',\n traits: { email: 'user@acme.com', name: 'Jane Doe', plan: 'premium' },\n timestamp: new Date(1700000103),\n },\n ],\n ],\n};\n\n/**\n * Per-event group with silent -- company update fires group() only.\n */\nexport const companyGroup: RudderStackStepExample = {\n title: 'Group company',\n description:\n 'A company update fires analytics.group with the groupId and group traits for B2B account tracking.',\n in: getEvent('company update', {\n timestamp: 1700000104,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n company_id: 'comp-456',\n company_name: 'Acme',\n industry: 'tech',\n employees: 50,\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n groupId: 'data.company_id',\n traits: {\n map: {\n name: 'data.company_name',\n industry: 'data.industry',\n employees: 'data.employees',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.group',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n groupId: 'comp-456',\n traits: { name: 'Acme', industry: 'tech', employees: 50 },\n timestamp: new Date(1700000104),\n },\n ],\n ],\n};\n\n/**\n * Explicit page() call with properties. RudderStack requires name -- resolved\n * from mapping. silent: true suppresses track().\n */\nexport const pageView: RudderStackStepExample = {\n title: 'Page view',\n description:\n 'A page view fires analytics.page with a resolved page name and properties instead of a generic track.',\n in: getEvent('page view', {\n timestamp: 1700000105,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n title: 'Getting Started',\n section: 'tutorials',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n page: {\n map: {\n name: 'data.title',\n properties: {\n map: {\n section: 'data.section',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.page',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n name: 'Getting Started',\n properties: { section: 'tutorials' },\n timestamp: new Date(1700000105),\n },\n ],\n ],\n};\n\n/**\n * Screen call -- server-only method for mobile app backends.\n * RudderStack requires name -- resolved from mapping.\n */\nexport const screenView: RudderStackStepExample = {\n title: 'Screen view',\n description:\n 'A screen view from a mobile app backend fires analytics.screen with a screen name and properties.',\n in: getEvent('screen view', {\n timestamp: 1700000106,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n screen_name: 'Welcome',\n section: 'onboarding',\n build: '1.2.3',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n screen: {\n map: {\n name: 'data.screen_name',\n properties: {\n map: {\n build: 'data.build',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.screen',\n {\n userId: 'us3r',\n anonymousId: 's3ss10n',\n name: 'Welcome',\n properties: { build: '1.2.3' },\n timestamp: new Date(1700000106),\n },\n ],\n ],\n};\n\n/**\n * Alias call -- links anonymous user identity to registered user.\n * silent: true suppresses track(). Requires previousId from mapping.\n */\nexport const aliasUser: RudderStackStepExample = {\n title: 'Alias user',\n description:\n 'An identity merge fires analytics.alias to link a previous anonymous id to the newly registered user id.',\n in: getEvent('identity merge', {\n timestamp: 1700000107,\n user: { id: 'registered-456', session: 's3ss10n' },\n data: {\n anonymous_id: 'anonymous-123',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n alias: {\n map: {\n previousId: 'data.anonymous_id',\n },\n },\n },\n },\n out: [\n [\n 'analytics.alias',\n {\n userId: 'registered-456',\n previousId: 'anonymous-123',\n timestamp: new Date(1700000107),\n },\n ],\n ],\n};\n\n/**\n * AnonymousId only -- no userId resolved. RudderStack accepts anonymousId alone.\n */\nexport const anonymousOnly: RudderStackStepExample = {\n title: 'Anonymous only',\n description:\n 'When no userId is resolved RudderStack accepts the track call keyed solely by anonymousId.',\n in: getEvent('product view', {\n timestamp: 1700000108,\n user: { session: 's3ss10n' },\n }),\n settings: {\n userId: undefined,\n },\n out: [\n [\n 'analytics.track',\n {\n anonymousId: 's3ss10n',\n event: 'product view',\n properties: {},\n timestamp: new Date(1700000108),\n },\n ],\n ],\n};\n\n/**\n * Wildcard ignore -- the event matches a mapping rule with ignore: true.\n * The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: RudderStackStepExample = {\n public: false,\n in: getEvent('debug noise', {\n timestamp: 1700000109,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n mapping: { ignore: true },\n out: [],\n};\n"],"mappings":";;;;;;;AA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;AAAA,EACV;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,aAAa;AAAA,QACb,OAAO;AAAA,QACP,YAAY,CAAC;AAAA,QACb,WAAW,oBAAI,KAAK,UAAU;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,kBAA0C;AAAA,EACrD,QAAQ;AAAA,EACR,IAAI,SAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,QAAQ,SAAS,UAAU;AAAA,EACzC,CAAC;AAAA,EACD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","names":["z"]}
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z\n .object({\n writeKey: z\n .string()\n .min(1)\n .describe(\n 'RudderStack source write key. Find it in the RudderStack dashboard under Sources > Setup.',\n ),\n dataPlaneUrl: z\n .string()\n .url()\n .describe(\n 'RudderStack data plane URL. Required. Example: https://your-data-plane.rudderstack.com',\n ),\n userId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve userId from each event (like user.id).',\n )\n .optional(),\n anonymousId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve anonymousId from each event (like user.session).',\n )\n .optional(),\n path: z.string().describe('API path route (like /v1/batch).').optional(),\n flushAt: z\n .number()\n .int()\n .positive()\n .describe(\n 'Events the SDK sends in one request. Each push and each config.batch batch flushes the SDK and waits until its calls are sent. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .int()\n .positive()\n .describe('Max milliseconds before auto-flush. Default: 10000.')\n .optional(),\n maxQueueSize: z\n .number()\n .int()\n .positive()\n .describe(\n 'Maximum batch payload size in bytes. Default: 460800 (~500KB).',\n )\n .optional(),\n maxInternalQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Maximum in-memory queue length. Default: 20000.')\n .optional(),\n logLevel: z\n .string()\n .describe(\n \"SDK log level: 'info', 'debug', 'error', or 'silly'. Default: 'info'.\",\n )\n .optional(),\n retryCount: z\n .number()\n .int()\n .min(0)\n .describe(\n 'Retries the SDK makes for a failed request, a tenth of config.timeout apart. Default: 2, which ends within config.timeout. A value set here wins.',\n )\n .optional(),\n timeout: z\n .number()\n .int()\n .positive()\n .describe(\n 'Time one request may take, in milliseconds. Default: a quarter of config.timeout (2500 at the 10 s default). A value set here wins.',\n )\n .optional(),\n enable: z\n .boolean()\n .describe('Set to false to no-op all SDK calls. Default: true.')\n .optional(),\n gzip: z\n .boolean()\n .describe('Enable gzip compression for requests. Default: true.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to { traits } object. Fires identify() on the first push and re-fires when values change.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Destination-level group mapping. Resolves to { groupId, traits }. Fires group() on the first push and re-fires on change.',\n )\n .optional(),\n integrations: z\n .record(z.string(), z.unknown())\n .describe(\n 'Enable/disable downstream RudderStack destinations. Example: { \"All\": true, \"Mixpanel\": false }.',\n )\n .optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { userId?, traits? }. Use with rule-level silent: true on login/identify events.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Per-event group assignment. Resolves to { groupId, traits? }. Use with rule-level silent: true on company/team events.',\n )\n .optional(),\n page: z\n .unknown()\n .describe(\n 'Per-event page call. Resolves to { name, properties? } or true for minimal page(). RudderStack requires name (falls back to empty string). Use with silent: true.',\n )\n .optional(),\n screen: z\n .unknown()\n .describe(\n 'Per-event screen call (mobile backends). Resolves to { name, properties? } or true for minimal screen(). RudderStack requires name (falls back to empty string). Use with silent: true.',\n )\n .optional(),\n alias: z\n .unknown()\n .describe(\n 'Per-event alias call. Resolves to { previousId }. Links anonymous user to identified user. Use with rule-level silent: true.',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n RudderStackAnalyticsMock,\n RudderStackCallback,\n} from '../types';\n\n/** Every call is sent: its callback answers without an error. */\nconst sent = (_params: unknown, callback?: RudderStackCallback) => callback?.();\nconst asyncNoop = () => Promise.resolve();\n\nfunction createMockAnalytics(): RudderStackAnalyticsMock {\n return {\n track: sent,\n identify: sent,\n group: sent,\n page: sent,\n screen: sent,\n alias: sent,\n flush: asyncNoop,\n };\n}\n\nexport const push: Env = {\n analytics: createMockAnalytics(),\n};\n\nexport const simulation = [\n 'call:analytics.track',\n 'call:analytics.identify',\n 'call:analytics.group',\n 'call:analytics.page',\n 'call:analytics.screen',\n 'call:analytics.alias',\n];\n","import type { Flow } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type RudderStackStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * RudderStack server destination invokes the injected `env.analytics` SDK\n * methods (`track`, `identify`, `group`, `page`, `screen`, `alias`) - not a\n * raw HTTP endpoint. Each `out` entry is therefore\n * `[callable, params]` where `callable` is the dotted method name\n * (e.g. `'analytics.track'`) and `params` is the object passed to the SDK.\n *\n * Examples may emit multiple calls in order (e.g. identify + track), so\n * every `out` is wrapped as `[[callable, params], ...]`.\n */\n\n/**\n * Default event forwarding -- analytics.track() with event name and empty\n * properties. userId resolved from default settings.userId = 'user.id'.\n */\nexport const defaultTrack: RudderStackStepExample = {\n title: 'Default track',\n description:\n 'A walker event becomes a RudderStack analytics.track call with userId and anonymousId resolved from the event.',\n in: getEvent('product view', {\n id: 'ev1700000100',\n timestamp: 1700000100,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n out: [\n [\n 'analytics.track',\n {\n messageId: 'ev1700000100',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'product view',\n properties: {},\n timestamp: new Date(1700000100),\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- mapping.name renames the event for RudderStack.\n */\nexport const mappedEventName: RudderStackStepExample = {\n title: 'Renamed event',\n description:\n 'A mapping renames the event so the RudderStack track call uses a canonical name such as Order Completed.',\n in: getEvent('order complete', {\n id: 'ev1700000101',\n timestamp: 1700000101,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n mapping: {\n name: 'Order Completed',\n },\n out: [\n [\n 'analytics.track',\n {\n messageId: 'ev1700000101',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'Order Completed',\n properties: {},\n timestamp: new Date(1700000101),\n },\n ],\n ],\n};\n\n/**\n * Destination-level identify -- fires analytics.identify() on first push\n * when settings.identify mapping resolves. Then fires analytics.track().\n */\nexport const destinationIdentify: RudderStackStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify fires analytics.identify with traits on the first push only, then the track call follows.',\n in: getEvent('page view', {\n id: 'ev1700000102',\n timestamp: 1700000102,\n user: { id: 'us3r', session: 's3ss10n', email: 'user@example.com' },\n }),\n settings: {\n identify: {\n map: {\n traits: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n {\n messageId: 'ev1700000102-identify',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n traits: { email: 'user@example.com' },\n timestamp: new Date(1700000102),\n },\n ],\n [\n 'analytics.track',\n {\n messageId: 'ev1700000102',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n event: 'page view',\n properties: {},\n timestamp: new Date(1700000102),\n },\n ],\n ],\n};\n\n/**\n * Per-event identify with silent -- user login fires identify() only.\n */\nexport const userLoginIdentify: RudderStackStepExample = {\n title: 'User login identify',\n description:\n 'A user login fires only an analytics.identify call with the resolved userId and traits, skipping the track.',\n in: createEvent({\n name: 'user login',\n id: 'ev1700000103',\n timestamp: 1700000103,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n userId: 'data.user_id',\n traits: {\n map: {\n email: 'data.email',\n name: 'data.name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n {\n messageId: 'ev1700000103-identify',\n userId: 'new-user-123',\n anonymousId: 's3ss10n',\n traits: { email: 'user@acme.com', name: 'Jane Doe', plan: 'premium' },\n timestamp: new Date(1700000103),\n },\n ],\n ],\n};\n\n/**\n * Per-event group with silent -- company update fires group() only.\n */\nexport const companyGroup: RudderStackStepExample = {\n title: 'Group company',\n description:\n 'A company update fires analytics.group with the groupId and group traits for B2B account tracking.',\n in: createEvent({\n name: 'company update',\n id: 'ev1700000104',\n timestamp: 1700000104,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n company_id: 'comp-456',\n company_name: 'Acme',\n industry: 'tech',\n employees: 50,\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n groupId: 'data.company_id',\n traits: {\n map: {\n name: 'data.company_name',\n industry: 'data.industry',\n employees: 'data.employees',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.group',\n {\n messageId: 'ev1700000104-group',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n groupId: 'comp-456',\n traits: { name: 'Acme', industry: 'tech', employees: 50 },\n timestamp: new Date(1700000104),\n },\n ],\n ],\n};\n\n/**\n * Explicit page() call with properties. RudderStack requires name -- resolved\n * from mapping. silent: true suppresses track().\n */\nexport const pageView: RudderStackStepExample = {\n title: 'Page view',\n description:\n 'A page view fires analytics.page with a resolved page name and properties instead of a generic track.',\n in: getEvent('page view', {\n id: 'ev1700000105',\n timestamp: 1700000105,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n title: 'Getting Started',\n section: 'tutorials',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n page: {\n map: {\n name: 'data.title',\n properties: {\n map: {\n section: 'data.section',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.page',\n {\n messageId: 'ev1700000105-page',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n name: 'Getting Started',\n properties: { section: 'tutorials' },\n timestamp: new Date(1700000105),\n },\n ],\n ],\n};\n\n/**\n * Screen call -- server-only method for mobile app backends.\n * RudderStack requires name -- resolved from mapping.\n */\nexport const screenView: RudderStackStepExample = {\n title: 'Screen view',\n description:\n 'A screen view from a mobile app backend fires analytics.screen with a screen name and properties.',\n in: createEvent({\n name: 'screen view',\n id: 'ev1700000106',\n timestamp: 1700000106,\n user: { id: 'us3r', session: 's3ss10n' },\n data: {\n screen_name: 'Welcome',\n section: 'onboarding',\n build: '1.2.3',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n screen: {\n map: {\n name: 'data.screen_name',\n properties: {\n map: {\n build: 'data.build',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.screen',\n {\n messageId: 'ev1700000106-screen',\n userId: 'us3r',\n anonymousId: 's3ss10n',\n name: 'Welcome',\n properties: { build: '1.2.3' },\n timestamp: new Date(1700000106),\n },\n ],\n ],\n};\n\n/**\n * Alias call -- links anonymous user identity to registered user.\n * silent: true suppresses track(). Requires previousId from mapping.\n */\nexport const aliasUser: RudderStackStepExample = {\n title: 'Alias user',\n description:\n 'An identity merge fires analytics.alias to link a previous anonymous id to the newly registered user id.',\n in: createEvent({\n name: 'identity merge',\n id: 'ev1700000107',\n timestamp: 1700000107,\n user: { id: 'registered-456', session: 's3ss10n' },\n data: {\n anonymous_id: 'anonymous-123',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n alias: {\n map: {\n previousId: 'data.anonymous_id',\n },\n },\n },\n },\n out: [\n [\n 'analytics.alias',\n {\n messageId: 'ev1700000107-alias',\n userId: 'registered-456',\n previousId: 'anonymous-123',\n timestamp: new Date(1700000107),\n },\n ],\n ],\n};\n\n/**\n * AnonymousId only -- no userId resolved. RudderStack accepts anonymousId alone.\n */\nexport const anonymousOnly: RudderStackStepExample = {\n title: 'Anonymous only',\n description:\n 'When no userId is resolved RudderStack accepts the track call keyed solely by anonymousId.',\n in: getEvent('product view', {\n id: 'ev1700000108',\n timestamp: 1700000108,\n user: { session: 's3ss10n' },\n }),\n settings: {\n userId: undefined,\n },\n out: [\n [\n 'analytics.track',\n {\n messageId: 'ev1700000108',\n anonymousId: 's3ss10n',\n event: 'product view',\n properties: {},\n timestamp: new Date(1700000108),\n },\n ],\n ],\n};\n\n/**\n * No identity -- neither userId nor anonymousId resolves from the event, so\n * RudderStack cannot take it: the push fails with missing-input instead of\n * counting as delivered. One per event name above, so every example's event\n * without identity has its declared outcome.\n */\nfunction withoutIdentity(\n name: string,\n timestamp: number,\n): RudderStackStepExample {\n const [entity, action] = name.split(' ');\n return {\n public: false,\n description: `A ${name} event without userId or anonymousId cannot be sent to RudderStack: the push fails with missing-input instead of counting as delivered.`,\n in: { name, entity, action, timestamp },\n out: [],\n outcome: { status: 'failed', code: 'missing-input', retryable: false },\n };\n}\n\nexport const noIdentityProduct = withoutIdentity('product view', 1700000110);\nexport const noIdentityOrder = withoutIdentity('order complete', 1700000111);\nexport const noIdentityPage = withoutIdentity('page view', 1700000112);\nexport const noIdentityLogin = withoutIdentity('user login', 1700000113);\nexport const noIdentityCompany = withoutIdentity('company update', 1700000114);\nexport const noIdentityScreen = withoutIdentity('screen view', 1700000115);\nexport const noIdentityMerge = withoutIdentity('identity merge', 1700000116);\n\n/** A silent rule without identify, group, page, screen or alias calls nothing. */\nexport const silentRule: RudderStackStepExample = {\n public: false,\n description:\n 'A rule with silent: true and no identify, group, page, screen or alias mapping sends nothing to RudderStack.',\n in: getEvent('page view', {\n timestamp: 1700000117,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * Wildcard ignore -- the event matches a mapping rule with ignore: true.\n * The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: RudderStackStepExample = {\n public: false,\n in: createEvent({\n name: 'debug noise',\n timestamp: 1700000109,\n user: { id: 'us3r', session: 's3ss10n' },\n }),\n mapping: { ignore: true },\n out: [],\n};\n\n/**\n * The silent group rule of companyGroup on an event without company data: no\n * groupId resolves and the rule suppresses the track, so nothing is sent.\n */\nexport const companyGroupWithoutData: RudderStackStepExample = {\n public: false,\n description:\n 'A silent group rule whose groupId finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.',\n in: {\n name: 'company update',\n entity: 'company',\n action: 'update',\n timestamp: 1700000120,\n user: { id: 'us3r', session: 's3ss10n' },\n },\n mapping: companyGroup.mapping,\n out: [],\n};\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,UAAU,EACP,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,cAAc,EACX,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,EACL,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,aAAa,EACV,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,MAAM,EAAE,OAAO,EAAE,SAAS,kCAAkC,EAAE,SAAS;AAAA,EACvE,SAAS,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,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A,EACxB,KAAK,CAAC;AACR;AAMO,IAAM,0BAAkD;AAAA,EAC7D,QAAQ;AAAA,EACR,aACE;AAAA,EACF,IAAI;AAAA,IACF,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,QAAQ,SAAS,UAAU;AAAA,EACzC;AAAA,EACA,SAAS,aAAa;AAAA,EACtB,KAAK,CAAC;AACR;","names":["z"]}
@@ -28,15 +28,19 @@ interface Settings {
28
28
  maxInternalQueueSize?: number;
29
29
  /** Log level. Default: 'info'. */
30
30
  logLevel?: string;
31
- /** Retry attempts for failed batches. Default: 3. */
31
+ /** Retries for a failed request. Default: 2, within config.timeout. */
32
32
  retryCount?: number;
33
+ /** Time one request may take (ms). Default: a quarter of config.timeout. */
34
+ timeout?: number;
33
35
  /** Completely disable the SDK. Default: false. */
34
36
  enable?: boolean;
35
37
  /** Enable gzip compression. Default: true. */
36
38
  gzip?: boolean;
37
39
  /** Runtime state -- not user-facing. Mutated by init/push. */
38
- _analytics?: unknown;
40
+ _analytics?: RudderStackAnalyticsMock;
39
41
  _state?: RuntimeState;
42
+ /** The running flush; the next one waits for it. Runtime only. */
43
+ _flushing?: Promise<void>;
40
44
  }
41
45
  interface RuntimeState {
42
46
  lastIdentity?: {
@@ -62,14 +66,16 @@ interface Env extends DestinationServer.Env {
62
66
  * destination actually calls. Tests can provide this via env.analytics
63
67
  * instead of the real SDK.
64
68
  */
69
+ /** Called once the SDK sent the call, with the error if it failed. */
70
+ type RudderStackCallback = (error?: Error, data?: unknown) => void;
65
71
  interface RudderStackAnalyticsMock {
66
- track: (params: Record<string, unknown>) => void;
67
- identify: (params: Record<string, unknown>) => void;
68
- group: (params: Record<string, unknown>) => void;
69
- page: (params: Record<string, unknown>) => void;
70
- screen: (params: Record<string, unknown>) => void;
71
- alias: (params: Record<string, unknown>) => void;
72
- flush: (callback?: (err?: Error, data?: unknown) => void) => Promise<void>;
72
+ track: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
73
+ identify: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
74
+ group: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
75
+ page: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
76
+ screen: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
77
+ alias: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
78
+ flush: (callback?: RudderStackCallback) => Promise<void>;
73
79
  }
74
80
 
75
81
  declare const push: Env;
@@ -138,25 +144,48 @@ declare const aliasUser: RudderStackStepExample;
138
144
  * AnonymousId only -- no userId resolved. RudderStack accepts anonymousId alone.
139
145
  */
140
146
  declare const anonymousOnly: RudderStackStepExample;
147
+ declare const noIdentityProduct: RudderStackStepExample;
148
+ declare const noIdentityOrder: RudderStackStepExample;
149
+ declare const noIdentityPage: RudderStackStepExample;
150
+ declare const noIdentityLogin: RudderStackStepExample;
151
+ declare const noIdentityCompany: RudderStackStepExample;
152
+ declare const noIdentityScreen: RudderStackStepExample;
153
+ declare const noIdentityMerge: RudderStackStepExample;
154
+ /** A silent rule without identify, group, page, screen or alias calls nothing. */
155
+ declare const silentRule: RudderStackStepExample;
141
156
  /**
142
157
  * Wildcard ignore -- the event matches a mapping rule with ignore: true.
143
158
  * The destination fires zero SDK calls.
144
159
  */
145
160
  declare const wildcardIgnored: RudderStackStepExample;
161
+ /**
162
+ * The silent group rule of companyGroup on an event without company data: no
163
+ * groupId resolves and the rule suppresses the track, so nothing is sent.
164
+ */
165
+ declare const companyGroupWithoutData: RudderStackStepExample;
146
166
 
147
167
  type step_RudderStackStepExample = RudderStackStepExample;
148
168
  declare const step_aliasUser: typeof aliasUser;
149
169
  declare const step_anonymousOnly: typeof anonymousOnly;
150
170
  declare const step_companyGroup: typeof companyGroup;
171
+ declare const step_companyGroupWithoutData: typeof companyGroupWithoutData;
151
172
  declare const step_defaultTrack: typeof defaultTrack;
152
173
  declare const step_destinationIdentify: typeof destinationIdentify;
153
174
  declare const step_mappedEventName: typeof mappedEventName;
175
+ declare const step_noIdentityCompany: typeof noIdentityCompany;
176
+ declare const step_noIdentityLogin: typeof noIdentityLogin;
177
+ declare const step_noIdentityMerge: typeof noIdentityMerge;
178
+ declare const step_noIdentityOrder: typeof noIdentityOrder;
179
+ declare const step_noIdentityPage: typeof noIdentityPage;
180
+ declare const step_noIdentityProduct: typeof noIdentityProduct;
181
+ declare const step_noIdentityScreen: typeof noIdentityScreen;
154
182
  declare const step_pageView: typeof pageView;
155
183
  declare const step_screenView: typeof screenView;
184
+ declare const step_silentRule: typeof silentRule;
156
185
  declare const step_userLoginIdentify: typeof userLoginIdentify;
157
186
  declare const step_wildcardIgnored: typeof wildcardIgnored;
158
187
  declare namespace step {
159
- export { type step_RudderStackStepExample as RudderStackStepExample, step_aliasUser as aliasUser, step_anonymousOnly as anonymousOnly, step_companyGroup as companyGroup, step_defaultTrack as defaultTrack, step_destinationIdentify as destinationIdentify, step_mappedEventName as mappedEventName, step_pageView as pageView, step_screenView as screenView, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
188
+ export { type step_RudderStackStepExample as RudderStackStepExample, step_aliasUser as aliasUser, step_anonymousOnly as anonymousOnly, step_companyGroup as companyGroup, step_companyGroupWithoutData as companyGroupWithoutData, step_defaultTrack as defaultTrack, step_destinationIdentify as destinationIdentify, step_mappedEventName as mappedEventName, step_noIdentityCompany as noIdentityCompany, step_noIdentityLogin as noIdentityLogin, step_noIdentityMerge as noIdentityMerge, step_noIdentityOrder as noIdentityOrder, step_noIdentityPage as noIdentityPage, step_noIdentityProduct as noIdentityProduct, step_noIdentityScreen as noIdentityScreen, step_pageView as pageView, step_screenView as screenView, step_silentRule as silentRule, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
160
189
  }
161
190
 
162
191
  export { env, step };
@@ -28,15 +28,19 @@ interface Settings {
28
28
  maxInternalQueueSize?: number;
29
29
  /** Log level. Default: 'info'. */
30
30
  logLevel?: string;
31
- /** Retry attempts for failed batches. Default: 3. */
31
+ /** Retries for a failed request. Default: 2, within config.timeout. */
32
32
  retryCount?: number;
33
+ /** Time one request may take (ms). Default: a quarter of config.timeout. */
34
+ timeout?: number;
33
35
  /** Completely disable the SDK. Default: false. */
34
36
  enable?: boolean;
35
37
  /** Enable gzip compression. Default: true. */
36
38
  gzip?: boolean;
37
39
  /** Runtime state -- not user-facing. Mutated by init/push. */
38
- _analytics?: unknown;
40
+ _analytics?: RudderStackAnalyticsMock;
39
41
  _state?: RuntimeState;
42
+ /** The running flush; the next one waits for it. Runtime only. */
43
+ _flushing?: Promise<void>;
40
44
  }
41
45
  interface RuntimeState {
42
46
  lastIdentity?: {
@@ -62,14 +66,16 @@ interface Env extends DestinationServer.Env {
62
66
  * destination actually calls. Tests can provide this via env.analytics
63
67
  * instead of the real SDK.
64
68
  */
69
+ /** Called once the SDK sent the call, with the error if it failed. */
70
+ type RudderStackCallback = (error?: Error, data?: unknown) => void;
65
71
  interface RudderStackAnalyticsMock {
66
- track: (params: Record<string, unknown>) => void;
67
- identify: (params: Record<string, unknown>) => void;
68
- group: (params: Record<string, unknown>) => void;
69
- page: (params: Record<string, unknown>) => void;
70
- screen: (params: Record<string, unknown>) => void;
71
- alias: (params: Record<string, unknown>) => void;
72
- flush: (callback?: (err?: Error, data?: unknown) => void) => Promise<void>;
72
+ track: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
73
+ identify: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
74
+ group: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
75
+ page: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
76
+ screen: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
77
+ alias: (params: Record<string, unknown>, callback?: RudderStackCallback) => unknown;
78
+ flush: (callback?: RudderStackCallback) => Promise<void>;
73
79
  }
74
80
 
75
81
  declare const push: Env;
@@ -138,25 +144,48 @@ declare const aliasUser: RudderStackStepExample;
138
144
  * AnonymousId only -- no userId resolved. RudderStack accepts anonymousId alone.
139
145
  */
140
146
  declare const anonymousOnly: RudderStackStepExample;
147
+ declare const noIdentityProduct: RudderStackStepExample;
148
+ declare const noIdentityOrder: RudderStackStepExample;
149
+ declare const noIdentityPage: RudderStackStepExample;
150
+ declare const noIdentityLogin: RudderStackStepExample;
151
+ declare const noIdentityCompany: RudderStackStepExample;
152
+ declare const noIdentityScreen: RudderStackStepExample;
153
+ declare const noIdentityMerge: RudderStackStepExample;
154
+ /** A silent rule without identify, group, page, screen or alias calls nothing. */
155
+ declare const silentRule: RudderStackStepExample;
141
156
  /**
142
157
  * Wildcard ignore -- the event matches a mapping rule with ignore: true.
143
158
  * The destination fires zero SDK calls.
144
159
  */
145
160
  declare const wildcardIgnored: RudderStackStepExample;
161
+ /**
162
+ * The silent group rule of companyGroup on an event without company data: no
163
+ * groupId resolves and the rule suppresses the track, so nothing is sent.
164
+ */
165
+ declare const companyGroupWithoutData: RudderStackStepExample;
146
166
 
147
167
  type step_RudderStackStepExample = RudderStackStepExample;
148
168
  declare const step_aliasUser: typeof aliasUser;
149
169
  declare const step_anonymousOnly: typeof anonymousOnly;
150
170
  declare const step_companyGroup: typeof companyGroup;
171
+ declare const step_companyGroupWithoutData: typeof companyGroupWithoutData;
151
172
  declare const step_defaultTrack: typeof defaultTrack;
152
173
  declare const step_destinationIdentify: typeof destinationIdentify;
153
174
  declare const step_mappedEventName: typeof mappedEventName;
175
+ declare const step_noIdentityCompany: typeof noIdentityCompany;
176
+ declare const step_noIdentityLogin: typeof noIdentityLogin;
177
+ declare const step_noIdentityMerge: typeof noIdentityMerge;
178
+ declare const step_noIdentityOrder: typeof noIdentityOrder;
179
+ declare const step_noIdentityPage: typeof noIdentityPage;
180
+ declare const step_noIdentityProduct: typeof noIdentityProduct;
181
+ declare const step_noIdentityScreen: typeof noIdentityScreen;
154
182
  declare const step_pageView: typeof pageView;
155
183
  declare const step_screenView: typeof screenView;
184
+ declare const step_silentRule: typeof silentRule;
156
185
  declare const step_userLoginIdentify: typeof userLoginIdentify;
157
186
  declare const step_wildcardIgnored: typeof wildcardIgnored;
158
187
  declare namespace step {
159
- export { type step_RudderStackStepExample as RudderStackStepExample, step_aliasUser as aliasUser, step_anonymousOnly as anonymousOnly, step_companyGroup as companyGroup, step_defaultTrack as defaultTrack, step_destinationIdentify as destinationIdentify, step_mappedEventName as mappedEventName, step_pageView as pageView, step_screenView as screenView, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
188
+ export { type step_RudderStackStepExample as RudderStackStepExample, step_aliasUser as aliasUser, step_anonymousOnly as anonymousOnly, step_companyGroup as companyGroup, step_companyGroupWithoutData as companyGroupWithoutData, step_defaultTrack as defaultTrack, step_destinationIdentify as destinationIdentify, step_mappedEventName as mappedEventName, step_noIdentityCompany as noIdentityCompany, step_noIdentityLogin as noIdentityLogin, step_noIdentityMerge as noIdentityMerge, step_noIdentityOrder as noIdentityOrder, step_noIdentityPage as noIdentityPage, step_noIdentityProduct as noIdentityProduct, step_noIdentityScreen as noIdentityScreen, step_pageView as pageView, step_screenView as screenView, step_silentRule as silentRule, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
160
189
  }
161
190
 
162
191
  export { env, step };
@@ -31,17 +31,16 @@ __export(env_exports, {
31
31
  push: () => push,
32
32
  simulation: () => simulation
33
33
  });
34
- var noop = () => {
35
- };
34
+ var sent = (_params, callback) => callback?.();
36
35
  var asyncNoop = () => Promise.resolve();
37
36
  function createMockAnalytics() {
38
37
  return {
39
- track: noop,
40
- identify: noop,
41
- group: noop,
42
- page: noop,
43
- screen: noop,
44
- alias: noop,
38
+ track: sent,
39
+ identify: sent,
40
+ group: sent,
41
+ page: sent,
42
+ screen: sent,
43
+ alias: sent,
45
44
  flush: asyncNoop
46
45
  };
47
46
  }
@@ -63,11 +62,20 @@ __export(step_exports, {
63
62
  aliasUser: () => aliasUser,
64
63
  anonymousOnly: () => anonymousOnly,
65
64
  companyGroup: () => companyGroup,
65
+ companyGroupWithoutData: () => companyGroupWithoutData,
66
66
  defaultTrack: () => defaultTrack,
67
67
  destinationIdentify: () => destinationIdentify,
68
68
  mappedEventName: () => mappedEventName,
69
+ noIdentityCompany: () => noIdentityCompany,
70
+ noIdentityLogin: () => noIdentityLogin,
71
+ noIdentityMerge: () => noIdentityMerge,
72
+ noIdentityOrder: () => noIdentityOrder,
73
+ noIdentityPage: () => noIdentityPage,
74
+ noIdentityProduct: () => noIdentityProduct,
75
+ noIdentityScreen: () => noIdentityScreen,
69
76
  pageView: () => pageView,
70
77
  screenView: () => screenView,
78
+ silentRule: () => silentRule,
71
79
  userLoginIdentify: () => userLoginIdentify,
72
80
  wildcardIgnored: () => wildcardIgnored
73
81
  });
@@ -76,6 +84,7 @@ var defaultTrack = {
76
84
  title: "Default track",
77
85
  description: "A walker event becomes a RudderStack analytics.track call with userId and anonymousId resolved from the event.",
78
86
  in: (0, import_core.getEvent)("product view", {
87
+ id: "ev1700000100",
79
88
  timestamp: 1700000100,
80
89
  user: { id: "us3r", session: "s3ss10n" }
81
90
  }),
@@ -83,6 +92,7 @@ var defaultTrack = {
83
92
  [
84
93
  "analytics.track",
85
94
  {
95
+ messageId: "ev1700000100",
86
96
  userId: "us3r",
87
97
  anonymousId: "s3ss10n",
88
98
  event: "product view",
@@ -96,6 +106,7 @@ var mappedEventName = {
96
106
  title: "Renamed event",
97
107
  description: "A mapping renames the event so the RudderStack track call uses a canonical name such as Order Completed.",
98
108
  in: (0, import_core.getEvent)("order complete", {
109
+ id: "ev1700000101",
99
110
  timestamp: 1700000101,
100
111
  user: { id: "us3r", session: "s3ss10n" }
101
112
  }),
@@ -106,6 +117,7 @@ var mappedEventName = {
106
117
  [
107
118
  "analytics.track",
108
119
  {
120
+ messageId: "ev1700000101",
109
121
  userId: "us3r",
110
122
  anonymousId: "s3ss10n",
111
123
  event: "Order Completed",
@@ -119,6 +131,7 @@ var destinationIdentify = {
119
131
  title: "Destination identify",
120
132
  description: "Destination-level identify fires analytics.identify with traits on the first push only, then the track call follows.",
121
133
  in: (0, import_core.getEvent)("page view", {
134
+ id: "ev1700000102",
122
135
  timestamp: 1700000102,
123
136
  user: { id: "us3r", session: "s3ss10n", email: "user@example.com" }
124
137
  }),
@@ -137,6 +150,7 @@ var destinationIdentify = {
137
150
  [
138
151
  "analytics.identify",
139
152
  {
153
+ messageId: "ev1700000102-identify",
140
154
  userId: "us3r",
141
155
  anonymousId: "s3ss10n",
142
156
  traits: { email: "user@example.com" },
@@ -146,6 +160,7 @@ var destinationIdentify = {
146
160
  [
147
161
  "analytics.track",
148
162
  {
163
+ messageId: "ev1700000102",
149
164
  userId: "us3r",
150
165
  anonymousId: "s3ss10n",
151
166
  event: "page view",
@@ -158,7 +173,9 @@ var destinationIdentify = {
158
173
  var userLoginIdentify = {
159
174
  title: "User login identify",
160
175
  description: "A user login fires only an analytics.identify call with the resolved userId and traits, skipping the track.",
161
- in: (0, import_core.getEvent)("user login", {
176
+ in: (0, import_core.createEvent)({
177
+ name: "user login",
178
+ id: "ev1700000103",
162
179
  timestamp: 1700000103,
163
180
  user: { id: "us3r", session: "s3ss10n" },
164
181
  data: {
@@ -189,6 +206,7 @@ var userLoginIdentify = {
189
206
  [
190
207
  "analytics.identify",
191
208
  {
209
+ messageId: "ev1700000103-identify",
192
210
  userId: "new-user-123",
193
211
  anonymousId: "s3ss10n",
194
212
  traits: { email: "user@acme.com", name: "Jane Doe", plan: "premium" },
@@ -200,7 +218,9 @@ var userLoginIdentify = {
200
218
  var companyGroup = {
201
219
  title: "Group company",
202
220
  description: "A company update fires analytics.group with the groupId and group traits for B2B account tracking.",
203
- in: (0, import_core.getEvent)("company update", {
221
+ in: (0, import_core.createEvent)({
222
+ name: "company update",
223
+ id: "ev1700000104",
204
224
  timestamp: 1700000104,
205
225
  user: { id: "us3r", session: "s3ss10n" },
206
226
  data: {
@@ -231,6 +251,7 @@ var companyGroup = {
231
251
  [
232
252
  "analytics.group",
233
253
  {
254
+ messageId: "ev1700000104-group",
234
255
  userId: "us3r",
235
256
  anonymousId: "s3ss10n",
236
257
  groupId: "comp-456",
@@ -244,6 +265,7 @@ var pageView = {
244
265
  title: "Page view",
245
266
  description: "A page view fires analytics.page with a resolved page name and properties instead of a generic track.",
246
267
  in: (0, import_core.getEvent)("page view", {
268
+ id: "ev1700000105",
247
269
  timestamp: 1700000105,
248
270
  user: { id: "us3r", session: "s3ss10n" },
249
271
  data: {
@@ -270,6 +292,7 @@ var pageView = {
270
292
  [
271
293
  "analytics.page",
272
294
  {
295
+ messageId: "ev1700000105-page",
273
296
  userId: "us3r",
274
297
  anonymousId: "s3ss10n",
275
298
  name: "Getting Started",
@@ -282,7 +305,9 @@ var pageView = {
282
305
  var screenView = {
283
306
  title: "Screen view",
284
307
  description: "A screen view from a mobile app backend fires analytics.screen with a screen name and properties.",
285
- in: (0, import_core.getEvent)("screen view", {
308
+ in: (0, import_core.createEvent)({
309
+ name: "screen view",
310
+ id: "ev1700000106",
286
311
  timestamp: 1700000106,
287
312
  user: { id: "us3r", session: "s3ss10n" },
288
313
  data: {
@@ -310,6 +335,7 @@ var screenView = {
310
335
  [
311
336
  "analytics.screen",
312
337
  {
338
+ messageId: "ev1700000106-screen",
313
339
  userId: "us3r",
314
340
  anonymousId: "s3ss10n",
315
341
  name: "Welcome",
@@ -322,7 +348,9 @@ var screenView = {
322
348
  var aliasUser = {
323
349
  title: "Alias user",
324
350
  description: "An identity merge fires analytics.alias to link a previous anonymous id to the newly registered user id.",
325
- in: (0, import_core.getEvent)("identity merge", {
351
+ in: (0, import_core.createEvent)({
352
+ name: "identity merge",
353
+ id: "ev1700000107",
326
354
  timestamp: 1700000107,
327
355
  user: { id: "registered-456", session: "s3ss10n" },
328
356
  data: {
@@ -343,6 +371,7 @@ var aliasUser = {
343
371
  [
344
372
  "analytics.alias",
345
373
  {
374
+ messageId: "ev1700000107-alias",
346
375
  userId: "registered-456",
347
376
  previousId: "anonymous-123",
348
377
  timestamp: /* @__PURE__ */ new Date(1700000107)
@@ -354,6 +383,7 @@ var anonymousOnly = {
354
383
  title: "Anonymous only",
355
384
  description: "When no userId is resolved RudderStack accepts the track call keyed solely by anonymousId.",
356
385
  in: (0, import_core.getEvent)("product view", {
386
+ id: "ev1700000108",
357
387
  timestamp: 1700000108,
358
388
  user: { session: "s3ss10n" }
359
389
  }),
@@ -364,6 +394,7 @@ var anonymousOnly = {
364
394
  [
365
395
  "analytics.track",
366
396
  {
397
+ messageId: "ev1700000108",
367
398
  anonymousId: "s3ss10n",
368
399
  event: "product view",
369
400
  properties: {},
@@ -372,15 +403,56 @@ var anonymousOnly = {
372
403
  ]
373
404
  ]
374
405
  };
406
+ function withoutIdentity(name, timestamp) {
407
+ const [entity, action] = name.split(" ");
408
+ return {
409
+ public: false,
410
+ description: `A ${name} event without userId or anonymousId cannot be sent to RudderStack: the push fails with missing-input instead of counting as delivered.`,
411
+ in: { name, entity, action, timestamp },
412
+ out: [],
413
+ outcome: { status: "failed", code: "missing-input", retryable: false }
414
+ };
415
+ }
416
+ var noIdentityProduct = withoutIdentity("product view", 1700000110);
417
+ var noIdentityOrder = withoutIdentity("order complete", 1700000111);
418
+ var noIdentityPage = withoutIdentity("page view", 1700000112);
419
+ var noIdentityLogin = withoutIdentity("user login", 1700000113);
420
+ var noIdentityCompany = withoutIdentity("company update", 1700000114);
421
+ var noIdentityScreen = withoutIdentity("screen view", 1700000115);
422
+ var noIdentityMerge = withoutIdentity("identity merge", 1700000116);
423
+ var silentRule = {
424
+ public: false,
425
+ description: "A rule with silent: true and no identify, group, page, screen or alias mapping sends nothing to RudderStack.",
426
+ in: (0, import_core.getEvent)("page view", {
427
+ timestamp: 1700000117,
428
+ user: { id: "us3r", session: "s3ss10n" }
429
+ }),
430
+ mapping: { silent: true },
431
+ out: []
432
+ };
375
433
  var wildcardIgnored = {
376
434
  public: false,
377
- in: (0, import_core.getEvent)("debug noise", {
435
+ in: (0, import_core.createEvent)({
436
+ name: "debug noise",
378
437
  timestamp: 1700000109,
379
438
  user: { id: "us3r", session: "s3ss10n" }
380
439
  }),
381
440
  mapping: { ignore: true },
382
441
  out: []
383
442
  };
443
+ var companyGroupWithoutData = {
444
+ public: false,
445
+ description: "A silent group rule whose groupId finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.",
446
+ in: {
447
+ name: "company update",
448
+ entity: "company",
449
+ action: "update",
450
+ timestamp: 1700000120,
451
+ user: { id: "us3r", session: "s3ss10n" }
452
+ },
453
+ mapping: companyGroup.mapping,
454
+ out: []
455
+ };
384
456
  // Annotate the CommonJS export names for ESM import in node:
385
457
  0 && (module.exports = {
386
458
  env,