@walkeros/web-destination-segment 4.7.2 → 4.8.0-next-1791441510508
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/CHANGELOG.md +13 -0
- package/README.md +6 -2
- package/dist/dev.d.mts +20 -15
- package/dist/dev.d.ts +20 -15
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +20 -15
- package/dist/examples/index.d.ts +20 -15
- package/dist/examples/index.js +15 -6
- package/dist/examples/index.mjs +15 -6
- package/dist/index.d.mts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +78 -24
- package/package.json +4 -4
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 apiKey: z\n .string()\n .min(1)\n .describe(\n 'Your Segment source write key. Find it in your Segment workspace under Connections, Sources, Settings, API Keys. Maps to `writeKey` in the Analytics.js `load()` call (like a1B2c3D4e5F6a1B2c3D4e5F6a1B2c3D4).',\n ),\n cdnURL: z\n .string()\n .describe(\n 'Override the CDN URL used for settings fetch. Default: https://cdn.segment.com. Useful for self-hosted Segment proxies.',\n )\n .optional(),\n initialPageview: z\n .boolean()\n .describe(\n 'When true, the SDK fires an automatic initial page() call on load. Default: false — walkerOS sources handle page tracking, so this is disabled to avoid duplicate page views.',\n )\n .optional(),\n disableClientPersistence: z\n .boolean()\n .describe(\n 'When true, prevents any cookie or localStorage writes. Useful for privacy-conscious setups. Default: false.',\n )\n .optional(),\n disableAutoISOConversion: z\n .boolean()\n .describe('Disable automatic ISO string → Date conversion. Default: false.')\n .optional(),\n retryQueue: z\n .boolean()\n .describe('Retry failed events. Default: true.')\n .optional(),\n obfuscate: z\n .boolean()\n .describe('Obfuscate event payloads. Default: false.')\n .optional(),\n integrations: z\n .record(z.string(), z.unknown())\n .describe(\n 'Enable/disable downstream Segment destinations. Example: { \"All\": true, \"Mixpanel\": false }.',\n )\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to an object with any of: userId, traits, anonymousId. Fires on the first push and re-fires when the resolved value changes.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Destination-level group mapping. Resolves to an object with: groupId, traits. Fires on the first push and re-fires on change.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.string())\n .describe(\n 'Mapping from walkerOS consent keys → Segment `categoryPreferences` keys. Example: { \"marketing\": \"Advertising\", \"analytics\": \"Analytics\" }. When omitted, walkerOS keys are forwarded 1:1 to Segment.',\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 an object with any of: userId, traits, anonymousId. 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 configuration. Resolves to { category?, name?, properties? } for analytics.page(), or `true` for an empty analytics.page() that relies on SDK auto-collection. Use with rule-level `silent: true` on page view events.',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → analytics.reset() (clears userId, anonymousId, traits). Typically used with silent: true on a user logout rule.',\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, SegmentAnalytics, SegmentSDK } from '../types';\n\nconst noop = () => {};\n\n/**\n * Pre-init env — load() returns an instance whose methods are all no-ops.\n * The test runner clones this and replaces instance methods with jest spies\n * to capture calls.\n */\nfunction createMockInstance(): SegmentAnalytics {\n return {\n track: noop,\n identify: noop,\n group: noop,\n page: noop,\n alias: noop,\n reset: noop,\n setAnonymousId: noop,\n };\n}\n\nfunction createMockSDK(): SegmentSDK {\n return {\n load: () => createMockInstance(),\n };\n}\n\nexport const init: Env | undefined = {\n analytics: createMockSDK(),\n};\n\nexport const push: Env = {\n analytics: createMockSDK(),\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:analytics.load',\n 'call:analytics.load.track',\n 'call:analytics.load.identify',\n 'call:analytics.load.group',\n 'call:analytics.load.page',\n 'call:analytics.load.alias',\n 'call:analytics.load.reset',\n 'call:analytics.load.setAnonymousId',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Examples may optionally carry destination-level settings.\n * The test runner merges this on top of a base { apiKey: 'test-project' }.\n */\nexport type SegmentStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Destination bootstrap.\n * Given the canonical apiKey setting, init calls analytics.load() with the\n * Segment writeKey and the walkerOS defaults (initialPageview: false).\n * Reproduce by passing the same settings as the destination config.\n */\nexport const init: Flow.StepExample = {\n title: 'Initialization',\n description:\n 'Destination bootstrap calls analytics.load with the Segment writeKey and walker default options.',\n in: {\n settings: {\n apiKey: 'test-project',\n },\n },\n out: [\n [\n 'analytics.load',\n { writeKey: 'test-project' },\n { initialPageview: false },\n ],\n ],\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * analytics.track(event.name, properties). With no mapping and no\n * destination-level include, properties is `{}`.\n */\nexport const defaultEventForwarding: SegmentStepExample = {\n title: 'Default track',\n description:\n 'A walker event becomes a Segment analytics.track call with the event name and empty properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [['analytics.track', 'product view', {}]],\n};\n\n/**\n * Wildcard ignore - walkerOS's standard way to drop events. The rule\n * matches but does nothing. The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: SegmentStepExample = {\n public: false,\n in: getEvent('debug noise', { timestamp: 1700000101 }),\n mapping: { ignore: true },\n out: [],\n};\n\n/**\n * Destination-level settings.include flattens the walkerOS `data` section\n * into prefixed properties on every push.\n */\nexport const destinationLevelInclude: SegmentStepExample = {\n title: 'Include data',\n description:\n 'Destination-level include flattens the event data section into prefixed Segment track properties.',\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\n 'analytics.track',\n 'product view',\n {\n data_id: 'ers',\n data_name: 'Everyday Ruck Snack',\n data_color: 'black',\n data_size: 'l',\n data_price: 420,\n },\n ],\n ],\n};\n\n/**\n * Per-rule settings.include REPLACES destination-level include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: SegmentStepExample = {\n title: 'Rule include overrides',\n description:\n 'A per-rule include replaces the destination-level include so this event forwards only globals.',\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'analytics.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push. The\n * destination resolves the mapping, calls analytics.identify(userId),\n * and records the value in runtime state. Subsequent pushes with the\n * same userId do NOT re-fire identify().\n */\nexport const destinationLevelIdentify: SegmentStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify calls analytics.identify with the resolved userId before firing the default track.',\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n userId: 'user.id',\n },\n },\n },\n out: [\n ['analytics.identify', 'us3r', {}],\n ['analytics.track', 'page view', {}],\n ],\n};\n\n/**\n * Per-event identify with traits - the canonical \"user login\" pattern.\n * silent: true suppresses the default analytics.track() call because we're\n * running identity side effects only. Matches Segment Spec reserved traits\n * (email, name, plan, company) so downstream destinations recognize them.\n */\nexport const userLoginIdentify: SegmentStepExample = {\n title: 'User login identify',\n description:\n 'A user login fires Segment analytics.identify with userId and reserved traits such as email, name, and plan.',\n in: getEvent('user login', {\n timestamp: 1700000105,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n company_name: 'Acme',\n company_id: 'comp-456',\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 company: {\n map: {\n name: 'data.company_name',\n id: 'data.company_id',\n },\n },\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n 'new-user-123',\n {\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n company: { name: 'Acme', id: 'comp-456' },\n },\n ],\n ],\n};\n\n/**\n * Profile update - omit userId. Segment's SDK uses the currently stored\n * userId and merges the traits into the existing trait set.\n */\nexport const profileUpdateTraitsOnly: SegmentStepExample = {\n title: 'Profile update',\n description:\n 'A profile update calls Segment analytics.identify with traits and no userId to merge traits into the current profile.',\n in: getEvent('profile update', {\n timestamp: 1700000106,\n data: {\n name: 'Jane Q. Doe',\n avatar_url: 'https://example.com/avatar.png',\n phone: '+1234567890',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n traits: {\n map: {\n name: 'data.name',\n avatar: 'data.avatar_url',\n phone: 'data.phone',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n undefined,\n {\n name: 'Jane Q. Doe',\n avatar: 'https://example.com/avatar.png',\n phone: '+1234567890',\n },\n ],\n ],\n};\n\n/**\n * User logout - reset: true fires analytics.reset(), which clears userId,\n * anonymousId, traits, and generates a new anonymous ID.\n * silent: true because we're only running the reset side effect.\n */\nexport const userLogoutReset: SegmentStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls analytics.reset to clear userId, anonymousId, and traits then generate a new anonymous id.',\n in: getEvent('user logout', { timestamp: 1700000107 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['analytics.reset']],\n};\n\n/**\n * Per-event group assignment - company update event attaches the user\n * to a company and sets the company's traits in one call.\n */\nexport const companyUpdateGroup: SegmentStepExample = {\n title: 'Group company',\n description:\n 'A company update fires Segment analytics.group with a groupId and traits for account-level tracking.',\n in: getEvent('company update', {\n timestamp: 1700000108,\n data: {\n company_id: 'comp-456',\n company_name: 'Acme',\n industry: 'tech',\n employees: 50,\n plan: 'enterprise',\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 plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.group',\n 'comp-456',\n {\n name: 'Acme',\n industry: 'tech',\n employees: 50,\n plan: 'enterprise',\n },\n ],\n ],\n};\n\n/**\n * Explicit page() call - the canonical Segment pattern for page views.\n * silent: true suppresses the default track() call; settings.page fires\n * analytics.page(category, name, properties) instead.\n */\nexport const pageViewAsPage: SegmentStepExample = {\n title: 'Page view',\n description:\n 'A page view fires Segment analytics.page with category, name, and properties instead of a generic track.',\n in: getEvent('page view', {\n timestamp: 1700000109,\n data: {\n category: 'docs',\n title: 'Getting Started',\n section: 'tutorials',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n page: {\n map: {\n category: 'data.category',\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 'docs',\n 'Getting Started',\n {\n section: 'tutorials',\n },\n ],\n ],\n};\n\n/**\n * Minimal page() call - settings.page: true produces an empty\n * analytics.page() relying entirely on SDK auto-collection.\n */\nexport const pageViewMinimal: SegmentStepExample = {\n title: 'Page view minimal',\n description:\n 'A mapping with page: true fires an empty analytics.page call relying on Segments auto-collection.',\n in: getEvent('page view', { timestamp: 1700000110 }),\n mapping: {\n silent: true,\n settings: {\n page: true,\n },\n },\n out: [['analytics.page']],\n};\n\n/**\n * Segment ecommerce spec - Order Completed event. One track() call with\n * a products array. Uses mapping.name to produce the Segment Spec name\n * and mapping.data to build the properties object including the nested\n * products loop. The loop filters via condition to products with prices.\n */\nexport const orderCompletedEcommerce: SegmentStepExample = {\n title: 'Order completed',\n description:\n 'A completed order is mapped to the Segment Spec Order Completed event with a nested products array.',\n in: getEvent('order complete', { timestamp: 1700000111 }),\n mapping: {\n name: 'Order Completed',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n shipping: 'data.shipping',\n tax: 'data.taxes',\n total: 'data.total',\n products: {\n loop: [\n 'nested',\n {\n condition: (value: unknown) => {\n const v = value as { data?: { price?: unknown } };\n return typeof v?.data?.price === 'number';\n },\n map: {\n product_id: 'data.id',\n name: 'data.name',\n price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'analytics.track',\n 'Order Completed',\n {\n order_id: '0rd3r1d',\n currency: 'EUR',\n shipping: 5.22,\n tax: 73.76,\n total: 555,\n products: [\n {\n product_id: 'ers',\n name: 'Everyday Ruck Snack',\n price: 420,\n quantity: 1,\n currency: 'EUR',\n },\n {\n product_id: 'cc',\n name: 'Cool Cap',\n price: 42,\n quantity: 1,\n currency: 'EUR',\n },\n ],\n },\n ],\n ],\n};\n\n/**\n * Consent context forwarding - when the event has consent state,\n * the destination automatically stamps every track/identify/group/page\n * call with context.consent.categoryPreferences. settings.consent\n * remaps walkerOS keys to Segment category names.\n */\nexport const consentContextForwarded: SegmentStepExample = {\n title: 'Consent context',\n description:\n 'Walker consent is stamped on every Segment call via context.consent.categoryPreferences for downstream filtering.',\n in: getEvent('product view', {\n timestamp: 1700000112,\n consent: { analytics: true, marketing: true },\n }),\n settings: {\n consent: {\n analytics: 'Analytics',\n marketing: 'Advertising',\n },\n },\n out: [\n [\n 'analytics.track',\n 'product view',\n {},\n {\n context: {\n consent: {\n categoryPreferences: {\n Analytics: true,\n Advertising: true,\n },\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Consent granted → deferred load fires for the first time. The\n * destination was initialized with consent requirement; on the walker\n * consent command it calls analytics.load(writeKey, initOptions).\n *\n * Uses the canonical StepExample.command='consent' pattern. The full\n * call shape includes both the settings arg and the initOptions arg.\n */\nexport const consentGrantDeferredLoad: SegmentStepExample = {\n title: 'Consent deferred load',\n description:\n 'A walker consent grant triggers the deferred Segment analytics.load with the configured writeKey.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n out: [\n [\n 'analytics.load',\n { writeKey: 'test-project' },\n { initialPageview: false },\n ],\n ],\n};\n\n/**\n * Consent revoked → no SDK call. The walkerOS consent gate handles\n * blocking subsequent events. The destination's on('consent') handler\n * is a no-op on revocation (Segment has no opt-out method).\n */\nexport const consentRevokeNoOp: SegmentStepExample = {\n public: false,\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n out: [],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,EACL,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,EACd,QAAQ,EACR;AAAA,IACC;A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N,OAAO;AAAA,YACP,UAAU;AAAA,YACV,UAAU;AAAA,UACZ;AAAA,UACA;AAAA,YACE,YAAY;AAAA,YACZ,MAAM;AAAA,YACN,OAAO;AAAA,YACP,UAAU;AAAA,YACV,UAAU;AAAA,UACZ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAQO,IAAM,0BAA8C;AAAA,EACzD,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,gBAAgB;AAAA,IAC3B,WAAW;AAAA,IACX,SAAS,EAAE,WAAW,MAAM,WAAW,KAAK;AAAA,EAC9C,CAAC;AAAA,EACD,UAAU;AAAA,IACR,SAAS;AAAA,MACP,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC;AAAA,MACD;AAAA,QACE,SAAS;AAAA,UACP,SAAS;AAAA,YACP,qBAAqB;AAAA,cACnB,WAAW;AAAA,cACX,aAAa;AAAA,YACf;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAUO,IAAM,2BAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA,EAAE,UAAU,eAAe;AAAA,MAC3B,EAAE,iBAAiB,MAAM;AAAA,IAC3B;AAAA,EACF;AACF;AAOO,IAAM,oBAAwC;AAAA,EACnD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,KAAK,CAAC;AACR;","names":["z","init"]}
|
|
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 apiKey: z\n .string()\n .min(1)\n .describe(\n 'Your Segment source write key. Find it in your Segment workspace under Connections, Sources, Settings, API Keys. Maps to `writeKey` in the Analytics.js `load()` call (like a1B2c3D4e5F6a1B2c3D4e5F6a1B2c3D4).',\n ),\n cdnURL: z\n .string()\n .describe(\n 'Not applied: the destination passes it in the load() options, where Analytics.js does not read it, so settings are always fetched from https://cdn.segment.com.',\n )\n .optional(),\n initialPageview: z\n .boolean()\n .describe(\n 'When true, the SDK fires an automatic initial page() call on load. Default: false (walkerOS sources handle page tracking, so this is disabled to avoid duplicate page views).',\n )\n .optional(),\n disableClientPersistence: z\n .boolean()\n .describe(\n 'When true, prevents any cookie or localStorage writes. Useful for privacy-conscious setups. Default: false.',\n )\n .optional(),\n disableAutoISOConversion: z\n .boolean()\n .describe('Disable automatic ISO string → Date conversion. Default: false.')\n .optional(),\n retryQueue: z\n .boolean()\n .describe('Retry failed events. Default: true.')\n .optional(),\n obfuscate: z\n .boolean()\n .describe('Obfuscate event payloads. Default: false.')\n .optional(),\n integrations: z\n .record(z.string(), z.unknown())\n .describe(\n 'Enable/disable downstream Segment destinations. Example: { \"All\": true, \"Mixpanel\": false }.',\n )\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to an object with any of: userId, traits, anonymousId. Resolved on every push: analytics.identify fires on the first push and when userId or traits change, and on every push while anonymousId is set.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Destination-level group mapping. Resolves to an object with: groupId, traits. Fires on the first push and re-fires on change.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.string())\n .describe(\n 'Mapping from walkerOS consent keys → Segment `categoryPreferences` keys. Example: { \"marketing\": \"Advertising\", \"analytics\": \"Analytics\" }. Only mapped keys are forwarded; when omitted, no consent context is sent.',\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 an object with any of: userId, traits, anonymousId. 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 configuration. Resolves to { category?, name?, properties? } for analytics.page(), or `true` for an empty analytics.page() that relies on SDK auto-collection. Use with rule-level `silent: true` on page view events.',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → analytics.reset() (clears userId, anonymousId, traits). Typically used with silent: true on a user logout rule.',\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, SegmentAnalytics, SegmentSDK } from '../types';\n\nconst noop = () => {};\n\n/**\n * Pre-init env — load() returns an instance whose methods are all no-ops.\n * The test runner clones this and replaces instance methods with jest spies\n * to capture calls.\n */\nfunction createMockInstance(): SegmentAnalytics {\n return {\n track: noop,\n identify: noop,\n group: noop,\n page: noop,\n alias: noop,\n reset: noop,\n setAnonymousId: noop,\n };\n}\n\nfunction createMockSDK(): SegmentSDK {\n return {\n load: () => createMockInstance(),\n };\n}\n\nexport const init: Env | undefined = {\n analytics: createMockSDK(),\n};\n\nexport const push: Env = {\n analytics: createMockSDK(),\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:analytics.load',\n 'call:analytics.load.track',\n 'call:analytics.load.identify',\n 'call:analytics.load.group',\n 'call:analytics.load.page',\n 'call:analytics.load.alias',\n 'call:analytics.load.reset',\n 'call:analytics.load.setAnonymousId',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Examples may optionally carry destination-level settings.\n * The test runner merges this on top of a base { apiKey: 'test-project' }.\n */\nexport type SegmentStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Destination bootstrap.\n * Given the canonical apiKey setting, init calls analytics.load() with the\n * Segment writeKey and the walkerOS defaults (initialPageview: false).\n * Reproduce by passing the same settings as the destination config.\n */\nexport const init: Flow.StepExample = {\n title: 'Initialization',\n description:\n 'Destination bootstrap calls analytics.load with the Segment writeKey and walker default options.',\n in: {\n settings: {\n apiKey: 'test-project',\n },\n },\n out: [\n [\n 'analytics.load',\n { writeKey: 'test-project' },\n { initialPageview: false },\n ],\n ],\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * analytics.track(event.name, properties). With no mapping and no\n * destination-level include, properties is `{}`.\n */\nexport const defaultEventForwarding: SegmentStepExample = {\n title: 'Default track',\n description:\n 'A walker event becomes a Segment analytics.track call with the event name and empty properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [['analytics.track', 'product view', {}]],\n};\n\n/**\n * Wildcard ignore - walkerOS's standard way to drop events. The rule\n * matches but does nothing. The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: SegmentStepExample = {\n public: false,\n in: getEvent('debug noise', { timestamp: 1700000101 }),\n mapping: { ignore: true },\n out: [],\n};\n\n/**\n * Destination-level include (config.include) flattens the walkerOS `data`\n * section into prefixed properties on every push.\n */\nexport const destinationLevelInclude: SegmentStepExample = {\n title: 'Include data',\n description:\n \"With include: ['data'] in the destination config, the event data section is flattened into prefixed Segment track properties.\",\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\n 'analytics.track',\n 'product view',\n {\n data_id: 'ers',\n data_name: 'Everyday Ruck Snack',\n data_color: 'black',\n data_size: 'l',\n data_price: 420,\n },\n ],\n ],\n};\n\n/**\n * Per-rule include REPLACES the destination-level config.include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: SegmentStepExample = {\n title: 'Rule include overrides',\n description:\n \"With include: ['data'] in the destination config, the rule's include: ['globals'] replaces it, so this event forwards only globals.\",\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'analytics.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push. The\n * destination resolves the mapping, calls analytics.identify(userId),\n * and records the value in runtime state. Subsequent pushes with the\n * same userId do NOT re-fire identify().\n */\nexport const destinationLevelIdentify: SegmentStepExample = {\n title: 'Destination identify',\n description:\n \"With settings.identify mapping userId to 'user.id', the destination calls analytics.identify before the default track.\",\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n userId: 'user.id',\n },\n },\n },\n out: [\n ['analytics.identify', 'us3r', {}],\n ['analytics.track', 'page view', {}],\n ],\n};\n\n/**\n * Per-event identify with traits - the canonical \"user login\" pattern.\n * silent: true suppresses the default analytics.track() call because we're\n * running identity side effects only. Matches Segment Spec reserved traits\n * (email, name, plan, company) so downstream destinations recognize them.\n */\nexport const userLoginIdentify: SegmentStepExample = {\n title: 'User login identify',\n description:\n 'A user login fires Segment analytics.identify with userId and reserved traits such as email, name, and plan.',\n in: getEvent('user login', {\n timestamp: 1700000105,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n company_name: 'Acme',\n company_id: 'comp-456',\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 company: {\n map: {\n name: 'data.company_name',\n id: 'data.company_id',\n },\n },\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n 'new-user-123',\n {\n email: 'user@acme.com',\n name: 'Jane Doe',\n plan: 'premium',\n company: { name: 'Acme', id: 'comp-456' },\n },\n ],\n ],\n};\n\n/**\n * Profile update - omit userId. Segment's SDK uses the currently stored\n * userId and merges the traits into the existing trait set.\n */\nexport const profileUpdateTraitsOnly: SegmentStepExample = {\n title: 'Profile update',\n description:\n 'A profile update calls Segment analytics.identify with traits and no userId to merge traits into the current profile.',\n in: getEvent('profile update', {\n timestamp: 1700000106,\n data: {\n name: 'Jane Q. Doe',\n avatar_url: 'https://example.com/avatar.png',\n phone: '+1234567890',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n traits: {\n map: {\n name: 'data.name',\n avatar: 'data.avatar_url',\n phone: 'data.phone',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.identify',\n undefined,\n {\n name: 'Jane Q. Doe',\n avatar: 'https://example.com/avatar.png',\n phone: '+1234567890',\n },\n ],\n ],\n};\n\n/**\n * User logout - reset: true fires analytics.reset(), which clears userId,\n * anonymousId, traits, and generates a new anonymous ID.\n * silent: true because we're only running the reset side effect.\n */\nexport const userLogoutReset: SegmentStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls analytics.reset to clear userId, anonymousId, and traits then generate a new anonymous id.',\n in: getEvent('user logout', { timestamp: 1700000107 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['analytics.reset']],\n};\n\n/**\n * Per-event group assignment - company update event attaches the user\n * to a company and sets the company's traits in one call.\n */\nexport const companyUpdateGroup: SegmentStepExample = {\n title: 'Group company',\n description:\n 'A company update fires Segment analytics.group with a groupId and traits for account-level tracking.',\n in: getEvent('company update', {\n timestamp: 1700000108,\n data: {\n company_id: 'comp-456',\n company_name: 'Acme',\n industry: 'tech',\n employees: 50,\n plan: 'enterprise',\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 plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'analytics.group',\n 'comp-456',\n {\n name: 'Acme',\n industry: 'tech',\n employees: 50,\n plan: 'enterprise',\n },\n ],\n ],\n};\n\n/**\n * Explicit page() call - the canonical Segment pattern for page views.\n * silent: true suppresses the default track() call; settings.page fires\n * analytics.page(category, name, properties) instead.\n */\nexport const pageViewAsPage: SegmentStepExample = {\n title: 'Page view',\n description:\n 'A page view fires Segment analytics.page with category, name, and properties instead of a generic track.',\n in: getEvent('page view', {\n timestamp: 1700000109,\n data: {\n category: 'docs',\n title: 'Getting Started',\n section: 'tutorials',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n page: {\n map: {\n category: 'data.category',\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 'docs',\n 'Getting Started',\n {\n section: 'tutorials',\n },\n ],\n ],\n};\n\n/**\n * Minimal page() call - settings.page: true produces an empty\n * analytics.page() relying entirely on SDK auto-collection.\n */\nexport const pageViewMinimal: SegmentStepExample = {\n title: 'Page view minimal',\n description:\n \"A mapping with page: true fires an empty analytics.page call relying on Segment's auto-collection.\",\n in: getEvent('page view', { timestamp: 1700000110 }),\n mapping: {\n silent: true,\n settings: {\n page: true,\n },\n },\n out: [['analytics.page']],\n};\n\n/**\n * Segment ecommerce spec - Order Completed event. One track() call with\n * a products array. Uses mapping.name to produce the Segment Spec name\n * and mapping.data to build the properties object including the nested\n * products loop. The loop filters via condition to products with prices.\n */\nexport const orderCompletedEcommerce: SegmentStepExample = {\n title: 'Order completed',\n description:\n 'A completed order is mapped to the Segment Spec Order Completed event with a nested products array.',\n in: getEvent('order complete', { timestamp: 1700000111 }),\n mapping: {\n name: 'Order Completed',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n shipping: 'data.shipping',\n tax: 'data.taxes',\n total: 'data.total',\n products: {\n loop: [\n 'nested',\n {\n condition: (value: unknown) => {\n const v = value as { data?: { price?: unknown } };\n return typeof v?.data?.price === 'number';\n },\n map: {\n product_id: 'data.id',\n name: 'data.name',\n price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'analytics.track',\n 'Order Completed',\n {\n order_id: '0rd3r1d',\n currency: 'EUR',\n shipping: 5.22,\n tax: 73.76,\n total: 555,\n products: [\n {\n product_id: 'ers',\n name: 'Everyday Ruck Snack',\n price: 420,\n quantity: 1,\n currency: 'EUR',\n },\n {\n product_id: 'cc',\n name: 'Cool Cap',\n price: 42,\n quantity: 1,\n currency: 'EUR',\n },\n ],\n },\n ],\n ],\n};\n\n/**\n * Consent context forwarding - when the event has consent state,\n * the destination automatically stamps every track/identify/group/page\n * call with context.consent.categoryPreferences. settings.consent\n * remaps walkerOS keys to Segment category names.\n */\nexport const consentContextForwarded: SegmentStepExample = {\n title: 'Consent context',\n description:\n 'With settings.consent mapping analytics to Analytics and marketing to Advertising, the event consent is stamped on every Segment call via context.consent.categoryPreferences for downstream filtering.',\n in: getEvent('product view', {\n timestamp: 1700000112,\n consent: { analytics: true, marketing: true },\n }),\n settings: {\n consent: {\n analytics: 'Analytics',\n marketing: 'Advertising',\n },\n },\n out: [\n [\n 'analytics.track',\n 'product view',\n {},\n {\n context: {\n consent: {\n categoryPreferences: {\n Analytics: true,\n Advertising: true,\n },\n },\n },\n },\n ],\n ],\n};\n\n/**\n * No settings.consent: the event's consent state is not forwarded, so the\n * track call carries no options (consent stamping is opt-in).\n */\nexport const consentContextOmitted: SegmentStepExample = {\n public: false,\n in: getEvent('product view', {\n timestamp: 1700000113000,\n consent: { analytics: true, marketing: false },\n }),\n out: [['analytics.track', 'product view', {}]],\n};\n\n/**\n * Consent granted → deferred load fires for the first time. The\n * destination was initialized with consent requirement; on the walker\n * consent command it calls analytics.load(writeKey, initOptions).\n *\n * Uses the canonical StepExample.command='consent' pattern. The full\n * call shape includes both the settings arg and the initOptions arg.\n */\nexport const consentGrantDeferredLoad: SegmentStepExample = {\n title: 'Consent deferred load',\n description:\n 'With consent: { analytics: true } in the destination config, a walker consent grant triggers the deferred Segment analytics.load with the configured writeKey.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n out: [\n [\n 'analytics.load',\n { writeKey: 'test-project' },\n { initialPageview: false },\n ],\n ],\n};\n\n/**\n * Consent revoked → no SDK call. The walkerOS consent gate handles\n * blocking subsequent events. The destination's on('consent') handler\n * is a no-op on revocation (Segment has no opt-out method).\n */\nexport const consentRevokeNoOp: SegmentStepExample = {\n public: false,\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n out: [],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,EACL,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,EACd,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,0BAA0B,EACvB,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,0BAA0B,EACvB,QAAQ,EACR,SAAS,sEAAiE,EAC1E,SAAS;AAAA,EACZ,YAAY,EACT,QAAQ,EACR,SAAS,qCAAqC,EAC9C,SAAS;AAAA,EACZ,WAAW,EACR,QAAQ,EACR,SAAS,2CAA2C,EACpD,SAAS;AAAA,EACZ,cAAc,EACX,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAC9B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,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AAU;AAAA,IACR,SAAS;AAAA,MACP,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC;AAAA,MACD;AAAA,QACE,SAAS;AAAA,UACP,SAAS;AAAA,YACP,qBAAqB;AAAA,cACnB,WAAW;AAAA,cACX,aAAa;AAAA,YACf;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,wBAA4C;AAAA,EACvD,QAAQ;AAAA,EACR,IAAI,SAAS,gBAAgB;AAAA,IAC3B,WAAW;AAAA,IACX,SAAS,EAAE,WAAW,MAAM,WAAW,MAAM;AAAA,EAC/C,CAAC;AAAA,EACD,KAAK,CAAC,CAAC,mBAAmB,gBAAgB,CAAC,CAAC,CAAC;AAC/C;AAUO,IAAM,2BAA+C;AAAA,EAC1D,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA,EAAE,UAAU,eAAe;AAAA,MAC3B,EAAE,iBAAiB,MAAM;AAAA,IAC3B;AAAA,EACF;AACF;AAOO,IAAM,oBAAwC;AAAA,EACnD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,KAAK,CAAC;AACR;","names":["z","init"]}
|
|
@@ -9,12 +9,11 @@ import { AnalyticsBrowserSettings, InitOptions } from '@segment/analytics-next';
|
|
|
9
9
|
* walkerOS's own `group` mapping) so every passthrough option (cookie,
|
|
10
10
|
* storage, integrations, plan, etc.) keeps IntelliSense intact. walkerOS
|
|
11
11
|
* adds:
|
|
12
|
-
* - `apiKey` (required)
|
|
13
|
-
* - `identify
|
|
14
|
-
* - `group
|
|
15
|
-
* - `
|
|
16
|
-
* - `
|
|
17
|
-
* - `_state` — runtime state (not user-facing, mutated by init/push)
|
|
12
|
+
* - `apiKey` (required): maps to `writeKey` in `AnalyticsBrowser.load()`
|
|
13
|
+
* - `identify`: destination-level identity mapping (Segment `identify()`)
|
|
14
|
+
* - `group`: destination-level group mapping (Segment `group()`)
|
|
15
|
+
* - `consent`: walkerOS consent key → Segment category name mapping
|
|
16
|
+
* - `_state`: runtime state (not user-facing, mutated by init/push)
|
|
18
17
|
*/
|
|
19
18
|
interface Settings extends Omit<InitOptions, 'group'> {
|
|
20
19
|
/** Segment write key. Maps to `writeKey` in the load() settings arg. */
|
|
@@ -26,10 +25,10 @@ interface Settings extends Omit<InitOptions, 'group'> {
|
|
|
26
25
|
/**
|
|
27
26
|
* Mapping from walkerOS consent keys → Segment `categoryPreferences` keys.
|
|
28
27
|
* Example: { marketing: "Advertising", analytics: "Analytics" }
|
|
29
|
-
* If omitted,
|
|
28
|
+
* Only mapped keys are forwarded. If omitted, no consent context is sent.
|
|
30
29
|
*/
|
|
31
30
|
consent?: Record<string, string>;
|
|
32
|
-
/** Runtime state
|
|
31
|
+
/** Runtime state: populated by init() and mutated by push(). Not user-facing. */
|
|
33
32
|
_state?: RuntimeState;
|
|
34
33
|
}
|
|
35
34
|
interface RuntimeState {
|
|
@@ -50,7 +49,7 @@ interface RuntimeState {
|
|
|
50
49
|
loaded?: boolean;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
|
-
* Segment SDK surface
|
|
52
|
+
* Segment SDK surface: the subset of @segment/analytics-next the
|
|
54
53
|
* destination actually uses. Mirrors the AnalyticsBrowser instance shape
|
|
55
54
|
* so tests can mock each method individually via env.analytics.
|
|
56
55
|
*/
|
|
@@ -64,7 +63,7 @@ interface SegmentAnalytics {
|
|
|
64
63
|
setAnonymousId: (id: string) => Promise<unknown> | void;
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
|
-
* Segment event options
|
|
66
|
+
* Segment event options: the fourth argument to track/identify/group/page
|
|
68
67
|
* that carries context and integration overrides. The destination uses
|
|
69
68
|
* this to stamp consent context on every event.
|
|
70
69
|
*/
|
|
@@ -90,7 +89,7 @@ interface SegmentSDK {
|
|
|
90
89
|
load: (settings: AnalyticsBrowserSettings, options?: InitOptions) => SegmentAnalytics;
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
93
|
-
* Env
|
|
92
|
+
* Env: optional SDK override. Production leaves this undefined and the
|
|
94
93
|
* destination falls back to the real @segment/analytics-next module.
|
|
95
94
|
* Tests provide a mock via env.analytics = { ... }.
|
|
96
95
|
*/
|
|
@@ -136,12 +135,12 @@ declare const defaultEventForwarding: SegmentStepExample;
|
|
|
136
135
|
*/
|
|
137
136
|
declare const wildcardIgnored: SegmentStepExample;
|
|
138
137
|
/**
|
|
139
|
-
* Destination-level
|
|
140
|
-
* into prefixed properties on every push.
|
|
138
|
+
* Destination-level include (config.include) flattens the walkerOS `data`
|
|
139
|
+
* section into prefixed properties on every push.
|
|
141
140
|
*/
|
|
142
141
|
declare const destinationLevelInclude: SegmentStepExample;
|
|
143
142
|
/**
|
|
144
|
-
* Per-rule
|
|
143
|
+
* Per-rule include REPLACES the destination-level config.include for the
|
|
145
144
|
* matched rule. Here destination-level sends `data`, but the rule
|
|
146
145
|
* overrides it with `globals` only.
|
|
147
146
|
*/
|
|
@@ -201,6 +200,11 @@ declare const orderCompletedEcommerce: SegmentStepExample;
|
|
|
201
200
|
* remaps walkerOS keys to Segment category names.
|
|
202
201
|
*/
|
|
203
202
|
declare const consentContextForwarded: SegmentStepExample;
|
|
203
|
+
/**
|
|
204
|
+
* No settings.consent: the event's consent state is not forwarded, so the
|
|
205
|
+
* track call carries no options (consent stamping is opt-in).
|
|
206
|
+
*/
|
|
207
|
+
declare const consentContextOmitted: SegmentStepExample;
|
|
204
208
|
/**
|
|
205
209
|
* Consent granted → deferred load fires for the first time. The
|
|
206
210
|
* destination was initialized with consent requirement; on the walker
|
|
@@ -220,6 +224,7 @@ declare const consentRevokeNoOp: SegmentStepExample;
|
|
|
220
224
|
type step_SegmentStepExample = SegmentStepExample;
|
|
221
225
|
declare const step_companyUpdateGroup: typeof companyUpdateGroup;
|
|
222
226
|
declare const step_consentContextForwarded: typeof consentContextForwarded;
|
|
227
|
+
declare const step_consentContextOmitted: typeof consentContextOmitted;
|
|
223
228
|
declare const step_consentGrantDeferredLoad: typeof consentGrantDeferredLoad;
|
|
224
229
|
declare const step_consentRevokeNoOp: typeof consentRevokeNoOp;
|
|
225
230
|
declare const step_defaultEventForwarding: typeof defaultEventForwarding;
|
|
@@ -235,7 +240,7 @@ declare const step_userLoginIdentify: typeof userLoginIdentify;
|
|
|
235
240
|
declare const step_userLogoutReset: typeof userLogoutReset;
|
|
236
241
|
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
237
242
|
declare namespace step {
|
|
238
|
-
export { type step_SegmentStepExample as SegmentStepExample, step_companyUpdateGroup as companyUpdateGroup, step_consentContextForwarded as consentContextForwarded, step_consentGrantDeferredLoad as consentGrantDeferredLoad, step_consentRevokeNoOp as consentRevokeNoOp, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_init as init, step_orderCompletedEcommerce as orderCompletedEcommerce, step_pageViewAsPage as pageViewAsPage, step_pageViewMinimal as pageViewMinimal, step_profileUpdateTraitsOnly as profileUpdateTraitsOnly, step_ruleIncludeReplaces as ruleIncludeReplaces, step_userLoginIdentify as userLoginIdentify, step_userLogoutReset as userLogoutReset, step_wildcardIgnored as wildcardIgnored };
|
|
243
|
+
export { type step_SegmentStepExample as SegmentStepExample, step_companyUpdateGroup as companyUpdateGroup, step_consentContextForwarded as consentContextForwarded, step_consentContextOmitted as consentContextOmitted, step_consentGrantDeferredLoad as consentGrantDeferredLoad, step_consentRevokeNoOp as consentRevokeNoOp, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_init as init, step_orderCompletedEcommerce as orderCompletedEcommerce, step_pageViewAsPage as pageViewAsPage, step_pageViewMinimal as pageViewMinimal, step_profileUpdateTraitsOnly as profileUpdateTraitsOnly, step_ruleIncludeReplaces as ruleIncludeReplaces, step_userLoginIdentify as userLoginIdentify, step_userLogoutReset as userLogoutReset, step_wildcardIgnored as wildcardIgnored };
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
export { env, step };
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -9,12 +9,11 @@ import { AnalyticsBrowserSettings, InitOptions } from '@segment/analytics-next';
|
|
|
9
9
|
* walkerOS's own `group` mapping) so every passthrough option (cookie,
|
|
10
10
|
* storage, integrations, plan, etc.) keeps IntelliSense intact. walkerOS
|
|
11
11
|
* adds:
|
|
12
|
-
* - `apiKey` (required)
|
|
13
|
-
* - `identify
|
|
14
|
-
* - `group
|
|
15
|
-
* - `
|
|
16
|
-
* - `
|
|
17
|
-
* - `_state` — runtime state (not user-facing, mutated by init/push)
|
|
12
|
+
* - `apiKey` (required): maps to `writeKey` in `AnalyticsBrowser.load()`
|
|
13
|
+
* - `identify`: destination-level identity mapping (Segment `identify()`)
|
|
14
|
+
* - `group`: destination-level group mapping (Segment `group()`)
|
|
15
|
+
* - `consent`: walkerOS consent key → Segment category name mapping
|
|
16
|
+
* - `_state`: runtime state (not user-facing, mutated by init/push)
|
|
18
17
|
*/
|
|
19
18
|
interface Settings extends Omit<InitOptions, 'group'> {
|
|
20
19
|
/** Segment write key. Maps to `writeKey` in the load() settings arg. */
|
|
@@ -26,10 +25,10 @@ interface Settings extends Omit<InitOptions, 'group'> {
|
|
|
26
25
|
/**
|
|
27
26
|
* Mapping from walkerOS consent keys → Segment `categoryPreferences` keys.
|
|
28
27
|
* Example: { marketing: "Advertising", analytics: "Analytics" }
|
|
29
|
-
* If omitted,
|
|
28
|
+
* Only mapped keys are forwarded. If omitted, no consent context is sent.
|
|
30
29
|
*/
|
|
31
30
|
consent?: Record<string, string>;
|
|
32
|
-
/** Runtime state
|
|
31
|
+
/** Runtime state: populated by init() and mutated by push(). Not user-facing. */
|
|
33
32
|
_state?: RuntimeState;
|
|
34
33
|
}
|
|
35
34
|
interface RuntimeState {
|
|
@@ -50,7 +49,7 @@ interface RuntimeState {
|
|
|
50
49
|
loaded?: boolean;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
|
-
* Segment SDK surface
|
|
52
|
+
* Segment SDK surface: the subset of @segment/analytics-next the
|
|
54
53
|
* destination actually uses. Mirrors the AnalyticsBrowser instance shape
|
|
55
54
|
* so tests can mock each method individually via env.analytics.
|
|
56
55
|
*/
|
|
@@ -64,7 +63,7 @@ interface SegmentAnalytics {
|
|
|
64
63
|
setAnonymousId: (id: string) => Promise<unknown> | void;
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
|
-
* Segment event options
|
|
66
|
+
* Segment event options: the fourth argument to track/identify/group/page
|
|
68
67
|
* that carries context and integration overrides. The destination uses
|
|
69
68
|
* this to stamp consent context on every event.
|
|
70
69
|
*/
|
|
@@ -90,7 +89,7 @@ interface SegmentSDK {
|
|
|
90
89
|
load: (settings: AnalyticsBrowserSettings, options?: InitOptions) => SegmentAnalytics;
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
93
|
-
* Env
|
|
92
|
+
* Env: optional SDK override. Production leaves this undefined and the
|
|
94
93
|
* destination falls back to the real @segment/analytics-next module.
|
|
95
94
|
* Tests provide a mock via env.analytics = { ... }.
|
|
96
95
|
*/
|
|
@@ -136,12 +135,12 @@ declare const defaultEventForwarding: SegmentStepExample;
|
|
|
136
135
|
*/
|
|
137
136
|
declare const wildcardIgnored: SegmentStepExample;
|
|
138
137
|
/**
|
|
139
|
-
* Destination-level
|
|
140
|
-
* into prefixed properties on every push.
|
|
138
|
+
* Destination-level include (config.include) flattens the walkerOS `data`
|
|
139
|
+
* section into prefixed properties on every push.
|
|
141
140
|
*/
|
|
142
141
|
declare const destinationLevelInclude: SegmentStepExample;
|
|
143
142
|
/**
|
|
144
|
-
* Per-rule
|
|
143
|
+
* Per-rule include REPLACES the destination-level config.include for the
|
|
145
144
|
* matched rule. Here destination-level sends `data`, but the rule
|
|
146
145
|
* overrides it with `globals` only.
|
|
147
146
|
*/
|
|
@@ -201,6 +200,11 @@ declare const orderCompletedEcommerce: SegmentStepExample;
|
|
|
201
200
|
* remaps walkerOS keys to Segment category names.
|
|
202
201
|
*/
|
|
203
202
|
declare const consentContextForwarded: SegmentStepExample;
|
|
203
|
+
/**
|
|
204
|
+
* No settings.consent: the event's consent state is not forwarded, so the
|
|
205
|
+
* track call carries no options (consent stamping is opt-in).
|
|
206
|
+
*/
|
|
207
|
+
declare const consentContextOmitted: SegmentStepExample;
|
|
204
208
|
/**
|
|
205
209
|
* Consent granted → deferred load fires for the first time. The
|
|
206
210
|
* destination was initialized with consent requirement; on the walker
|
|
@@ -220,6 +224,7 @@ declare const consentRevokeNoOp: SegmentStepExample;
|
|
|
220
224
|
type step_SegmentStepExample = SegmentStepExample;
|
|
221
225
|
declare const step_companyUpdateGroup: typeof companyUpdateGroup;
|
|
222
226
|
declare const step_consentContextForwarded: typeof consentContextForwarded;
|
|
227
|
+
declare const step_consentContextOmitted: typeof consentContextOmitted;
|
|
223
228
|
declare const step_consentGrantDeferredLoad: typeof consentGrantDeferredLoad;
|
|
224
229
|
declare const step_consentRevokeNoOp: typeof consentRevokeNoOp;
|
|
225
230
|
declare const step_defaultEventForwarding: typeof defaultEventForwarding;
|
|
@@ -235,7 +240,7 @@ declare const step_userLoginIdentify: typeof userLoginIdentify;
|
|
|
235
240
|
declare const step_userLogoutReset: typeof userLogoutReset;
|
|
236
241
|
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
237
242
|
declare namespace step {
|
|
238
|
-
export { type step_SegmentStepExample as SegmentStepExample, step_companyUpdateGroup as companyUpdateGroup, step_consentContextForwarded as consentContextForwarded, step_consentGrantDeferredLoad as consentGrantDeferredLoad, step_consentRevokeNoOp as consentRevokeNoOp, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_init as init, step_orderCompletedEcommerce as orderCompletedEcommerce, step_pageViewAsPage as pageViewAsPage, step_pageViewMinimal as pageViewMinimal, step_profileUpdateTraitsOnly as profileUpdateTraitsOnly, step_ruleIncludeReplaces as ruleIncludeReplaces, step_userLoginIdentify as userLoginIdentify, step_userLogoutReset as userLogoutReset, step_wildcardIgnored as wildcardIgnored };
|
|
243
|
+
export { type step_SegmentStepExample as SegmentStepExample, step_companyUpdateGroup as companyUpdateGroup, step_consentContextForwarded as consentContextForwarded, step_consentContextOmitted as consentContextOmitted, step_consentGrantDeferredLoad as consentGrantDeferredLoad, step_consentRevokeNoOp as consentRevokeNoOp, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_init as init, step_orderCompletedEcommerce as orderCompletedEcommerce, step_pageViewAsPage as pageViewAsPage, step_pageViewMinimal as pageViewMinimal, step_profileUpdateTraitsOnly as profileUpdateTraitsOnly, step_ruleIncludeReplaces as ruleIncludeReplaces, step_userLoginIdentify as userLoginIdentify, step_userLogoutReset as userLogoutReset, step_wildcardIgnored as wildcardIgnored };
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
export { env, step };
|
package/dist/examples/index.js
CHANGED
|
@@ -72,6 +72,7 @@ var step_exports = {};
|
|
|
72
72
|
__export(step_exports, {
|
|
73
73
|
companyUpdateGroup: () => companyUpdateGroup,
|
|
74
74
|
consentContextForwarded: () => consentContextForwarded,
|
|
75
|
+
consentContextOmitted: () => consentContextOmitted,
|
|
75
76
|
consentGrantDeferredLoad: () => consentGrantDeferredLoad,
|
|
76
77
|
consentRevokeNoOp: () => consentRevokeNoOp,
|
|
77
78
|
defaultEventForwarding: () => defaultEventForwarding,
|
|
@@ -118,7 +119,7 @@ var wildcardIgnored = {
|
|
|
118
119
|
};
|
|
119
120
|
var destinationLevelInclude = {
|
|
120
121
|
title: "Include data",
|
|
121
|
-
description: "
|
|
122
|
+
description: "With include: ['data'] in the destination config, the event data section is flattened into prefixed Segment track properties.",
|
|
122
123
|
in: (0, import_core.getEvent)("product view", { timestamp: 1700000102 }),
|
|
123
124
|
configInclude: ["data"],
|
|
124
125
|
out: [
|
|
@@ -137,7 +138,7 @@ var destinationLevelInclude = {
|
|
|
137
138
|
};
|
|
138
139
|
var ruleIncludeReplaces = {
|
|
139
140
|
title: "Rule include overrides",
|
|
140
|
-
description: "
|
|
141
|
+
description: "With include: ['data'] in the destination config, the rule's include: ['globals'] replaces it, so this event forwards only globals.",
|
|
141
142
|
in: (0, import_core.getEvent)("order complete", { timestamp: 1700000103 }),
|
|
142
143
|
configInclude: ["data"],
|
|
143
144
|
mapping: {
|
|
@@ -155,7 +156,7 @@ var ruleIncludeReplaces = {
|
|
|
155
156
|
};
|
|
156
157
|
var destinationLevelIdentify = {
|
|
157
158
|
title: "Destination identify",
|
|
158
|
-
description: "
|
|
159
|
+
description: "With settings.identify mapping userId to 'user.id', the destination calls analytics.identify before the default track.",
|
|
159
160
|
in: (0, import_core.getEvent)("page view", { timestamp: 1700000104 }),
|
|
160
161
|
settings: {
|
|
161
162
|
identify: {
|
|
@@ -354,7 +355,7 @@ var pageViewAsPage = {
|
|
|
354
355
|
};
|
|
355
356
|
var pageViewMinimal = {
|
|
356
357
|
title: "Page view minimal",
|
|
357
|
-
description: "A mapping with page: true fires an empty analytics.page call relying on
|
|
358
|
+
description: "A mapping with page: true fires an empty analytics.page call relying on Segment's auto-collection.",
|
|
358
359
|
in: (0, import_core.getEvent)("page view", { timestamp: 1700000110 }),
|
|
359
360
|
mapping: {
|
|
360
361
|
silent: true,
|
|
@@ -431,7 +432,7 @@ var orderCompletedEcommerce = {
|
|
|
431
432
|
};
|
|
432
433
|
var consentContextForwarded = {
|
|
433
434
|
title: "Consent context",
|
|
434
|
-
description: "
|
|
435
|
+
description: "With settings.consent mapping analytics to Analytics and marketing to Advertising, the event consent is stamped on every Segment call via context.consent.categoryPreferences for downstream filtering.",
|
|
435
436
|
in: (0, import_core.getEvent)("product view", {
|
|
436
437
|
timestamp: 1700000112,
|
|
437
438
|
consent: { analytics: true, marketing: true }
|
|
@@ -460,9 +461,17 @@ var consentContextForwarded = {
|
|
|
460
461
|
]
|
|
461
462
|
]
|
|
462
463
|
};
|
|
464
|
+
var consentContextOmitted = {
|
|
465
|
+
public: false,
|
|
466
|
+
in: (0, import_core.getEvent)("product view", {
|
|
467
|
+
timestamp: 1700000113e3,
|
|
468
|
+
consent: { analytics: true, marketing: false }
|
|
469
|
+
}),
|
|
470
|
+
out: [["analytics.track", "product view", {}]]
|
|
471
|
+
};
|
|
463
472
|
var consentGrantDeferredLoad = {
|
|
464
473
|
title: "Consent deferred load",
|
|
465
|
-
description: "
|
|
474
|
+
description: "With consent: { analytics: true } in the destination config, a walker consent grant triggers the deferred Segment analytics.load with the configured writeKey.",
|
|
466
475
|
command: "consent",
|
|
467
476
|
in: { analytics: true },
|
|
468
477
|
out: [
|
package/dist/examples/index.mjs
CHANGED
|
@@ -51,6 +51,7 @@ var step_exports = {};
|
|
|
51
51
|
__export(step_exports, {
|
|
52
52
|
companyUpdateGroup: () => companyUpdateGroup,
|
|
53
53
|
consentContextForwarded: () => consentContextForwarded,
|
|
54
|
+
consentContextOmitted: () => consentContextOmitted,
|
|
54
55
|
consentGrantDeferredLoad: () => consentGrantDeferredLoad,
|
|
55
56
|
consentRevokeNoOp: () => consentRevokeNoOp,
|
|
56
57
|
defaultEventForwarding: () => defaultEventForwarding,
|
|
@@ -97,7 +98,7 @@ var wildcardIgnored = {
|
|
|
97
98
|
};
|
|
98
99
|
var destinationLevelInclude = {
|
|
99
100
|
title: "Include data",
|
|
100
|
-
description: "
|
|
101
|
+
description: "With include: ['data'] in the destination config, the event data section is flattened into prefixed Segment track properties.",
|
|
101
102
|
in: getEvent("product view", { timestamp: 1700000102 }),
|
|
102
103
|
configInclude: ["data"],
|
|
103
104
|
out: [
|
|
@@ -116,7 +117,7 @@ var destinationLevelInclude = {
|
|
|
116
117
|
};
|
|
117
118
|
var ruleIncludeReplaces = {
|
|
118
119
|
title: "Rule include overrides",
|
|
119
|
-
description: "
|
|
120
|
+
description: "With include: ['data'] in the destination config, the rule's include: ['globals'] replaces it, so this event forwards only globals.",
|
|
120
121
|
in: getEvent("order complete", { timestamp: 1700000103 }),
|
|
121
122
|
configInclude: ["data"],
|
|
122
123
|
mapping: {
|
|
@@ -134,7 +135,7 @@ var ruleIncludeReplaces = {
|
|
|
134
135
|
};
|
|
135
136
|
var destinationLevelIdentify = {
|
|
136
137
|
title: "Destination identify",
|
|
137
|
-
description: "
|
|
138
|
+
description: "With settings.identify mapping userId to 'user.id', the destination calls analytics.identify before the default track.",
|
|
138
139
|
in: getEvent("page view", { timestamp: 1700000104 }),
|
|
139
140
|
settings: {
|
|
140
141
|
identify: {
|
|
@@ -333,7 +334,7 @@ var pageViewAsPage = {
|
|
|
333
334
|
};
|
|
334
335
|
var pageViewMinimal = {
|
|
335
336
|
title: "Page view minimal",
|
|
336
|
-
description: "A mapping with page: true fires an empty analytics.page call relying on
|
|
337
|
+
description: "A mapping with page: true fires an empty analytics.page call relying on Segment's auto-collection.",
|
|
337
338
|
in: getEvent("page view", { timestamp: 1700000110 }),
|
|
338
339
|
mapping: {
|
|
339
340
|
silent: true,
|
|
@@ -410,7 +411,7 @@ var orderCompletedEcommerce = {
|
|
|
410
411
|
};
|
|
411
412
|
var consentContextForwarded = {
|
|
412
413
|
title: "Consent context",
|
|
413
|
-
description: "
|
|
414
|
+
description: "With settings.consent mapping analytics to Analytics and marketing to Advertising, the event consent is stamped on every Segment call via context.consent.categoryPreferences for downstream filtering.",
|
|
414
415
|
in: getEvent("product view", {
|
|
415
416
|
timestamp: 1700000112,
|
|
416
417
|
consent: { analytics: true, marketing: true }
|
|
@@ -439,9 +440,17 @@ var consentContextForwarded = {
|
|
|
439
440
|
]
|
|
440
441
|
]
|
|
441
442
|
};
|
|
443
|
+
var consentContextOmitted = {
|
|
444
|
+
public: false,
|
|
445
|
+
in: getEvent("product view", {
|
|
446
|
+
timestamp: 1700000113e3,
|
|
447
|
+
consent: { analytics: true, marketing: false }
|
|
448
|
+
}),
|
|
449
|
+
out: [["analytics.track", "product view", {}]]
|
|
450
|
+
};
|
|
442
451
|
var consentGrantDeferredLoad = {
|
|
443
452
|
title: "Consent deferred load",
|
|
444
|
-
description: "
|
|
453
|
+
description: "With consent: { analytics: true } in the destination config, a walker consent grant triggers the deferred Segment analytics.load with the configured writeKey.",
|
|
445
454
|
command: "consent",
|
|
446
455
|
in: { analytics: true },
|
|
447
456
|
out: [
|
package/dist/index.d.mts
CHANGED
|
@@ -9,12 +9,11 @@ import { InitOptions, AnalyticsBrowserSettings } from '@segment/analytics-next';
|
|
|
9
9
|
* walkerOS's own `group` mapping) so every passthrough option (cookie,
|
|
10
10
|
* storage, integrations, plan, etc.) keeps IntelliSense intact. walkerOS
|
|
11
11
|
* adds:
|
|
12
|
-
* - `apiKey` (required)
|
|
13
|
-
* - `identify
|
|
14
|
-
* - `group
|
|
15
|
-
* - `
|
|
16
|
-
* - `
|
|
17
|
-
* - `_state` — runtime state (not user-facing, mutated by init/push)
|
|
12
|
+
* - `apiKey` (required): maps to `writeKey` in `AnalyticsBrowser.load()`
|
|
13
|
+
* - `identify`: destination-level identity mapping (Segment `identify()`)
|
|
14
|
+
* - `group`: destination-level group mapping (Segment `group()`)
|
|
15
|
+
* - `consent`: walkerOS consent key → Segment category name mapping
|
|
16
|
+
* - `_state`: runtime state (not user-facing, mutated by init/push)
|
|
18
17
|
*/
|
|
19
18
|
interface Settings extends Omit<InitOptions, 'group'> {
|
|
20
19
|
/** Segment write key. Maps to `writeKey` in the load() settings arg. */
|
|
@@ -26,10 +25,10 @@ interface Settings extends Omit<InitOptions, 'group'> {
|
|
|
26
25
|
/**
|
|
27
26
|
* Mapping from walkerOS consent keys → Segment `categoryPreferences` keys.
|
|
28
27
|
* Example: { marketing: "Advertising", analytics: "Analytics" }
|
|
29
|
-
* If omitted,
|
|
28
|
+
* Only mapped keys are forwarded. If omitted, no consent context is sent.
|
|
30
29
|
*/
|
|
31
30
|
consent?: Record<string, string>;
|
|
32
|
-
/** Runtime state
|
|
31
|
+
/** Runtime state: populated by init() and mutated by push(). Not user-facing. */
|
|
33
32
|
_state?: RuntimeState;
|
|
34
33
|
}
|
|
35
34
|
interface RuntimeState {
|
|
@@ -62,7 +61,7 @@ interface Mapping {
|
|
|
62
61
|
reset?: Mapping$1.Value | boolean;
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
|
-
* Segment SDK surface
|
|
64
|
+
* Segment SDK surface: the subset of @segment/analytics-next the
|
|
66
65
|
* destination actually uses. Mirrors the AnalyticsBrowser instance shape
|
|
67
66
|
* so tests can mock each method individually via env.analytics.
|
|
68
67
|
*/
|
|
@@ -76,7 +75,7 @@ interface SegmentAnalytics {
|
|
|
76
75
|
setAnonymousId: (id: string) => Promise<unknown> | void;
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
|
-
* Segment event options
|
|
78
|
+
* Segment event options: the fourth argument to track/identify/group/page
|
|
80
79
|
* that carries context and integration overrides. The destination uses
|
|
81
80
|
* this to stamp consent context on every event.
|
|
82
81
|
*/
|
|
@@ -102,7 +101,7 @@ interface SegmentSDK {
|
|
|
102
101
|
load: (settings: AnalyticsBrowserSettings, options?: InitOptions) => SegmentAnalytics;
|
|
103
102
|
}
|
|
104
103
|
/**
|
|
105
|
-
* Env
|
|
104
|
+
* Env: optional SDK override. Production leaves this undefined and the
|
|
106
105
|
* destination falls back to the real @segment/analytics-next module.
|
|
107
106
|
* Tests provide a mock via env.analytics = { ... }.
|
|
108
107
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -9,12 +9,11 @@ import { InitOptions, AnalyticsBrowserSettings } from '@segment/analytics-next';
|
|
|
9
9
|
* walkerOS's own `group` mapping) so every passthrough option (cookie,
|
|
10
10
|
* storage, integrations, plan, etc.) keeps IntelliSense intact. walkerOS
|
|
11
11
|
* adds:
|
|
12
|
-
* - `apiKey` (required)
|
|
13
|
-
* - `identify
|
|
14
|
-
* - `group
|
|
15
|
-
* - `
|
|
16
|
-
* - `
|
|
17
|
-
* - `_state` — runtime state (not user-facing, mutated by init/push)
|
|
12
|
+
* - `apiKey` (required): maps to `writeKey` in `AnalyticsBrowser.load()`
|
|
13
|
+
* - `identify`: destination-level identity mapping (Segment `identify()`)
|
|
14
|
+
* - `group`: destination-level group mapping (Segment `group()`)
|
|
15
|
+
* - `consent`: walkerOS consent key → Segment category name mapping
|
|
16
|
+
* - `_state`: runtime state (not user-facing, mutated by init/push)
|
|
18
17
|
*/
|
|
19
18
|
interface Settings extends Omit<InitOptions, 'group'> {
|
|
20
19
|
/** Segment write key. Maps to `writeKey` in the load() settings arg. */
|
|
@@ -26,10 +25,10 @@ interface Settings extends Omit<InitOptions, 'group'> {
|
|
|
26
25
|
/**
|
|
27
26
|
* Mapping from walkerOS consent keys → Segment `categoryPreferences` keys.
|
|
28
27
|
* Example: { marketing: "Advertising", analytics: "Analytics" }
|
|
29
|
-
* If omitted,
|
|
28
|
+
* Only mapped keys are forwarded. If omitted, no consent context is sent.
|
|
30
29
|
*/
|
|
31
30
|
consent?: Record<string, string>;
|
|
32
|
-
/** Runtime state
|
|
31
|
+
/** Runtime state: populated by init() and mutated by push(). Not user-facing. */
|
|
33
32
|
_state?: RuntimeState;
|
|
34
33
|
}
|
|
35
34
|
interface RuntimeState {
|
|
@@ -62,7 +61,7 @@ interface Mapping {
|
|
|
62
61
|
reset?: Mapping$1.Value | boolean;
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
|
-
* Segment SDK surface
|
|
64
|
+
* Segment SDK surface: the subset of @segment/analytics-next the
|
|
66
65
|
* destination actually uses. Mirrors the AnalyticsBrowser instance shape
|
|
67
66
|
* so tests can mock each method individually via env.analytics.
|
|
68
67
|
*/
|
|
@@ -76,7 +75,7 @@ interface SegmentAnalytics {
|
|
|
76
75
|
setAnonymousId: (id: string) => Promise<unknown> | void;
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
|
-
* Segment event options
|
|
78
|
+
* Segment event options: the fourth argument to track/identify/group/page
|
|
80
79
|
* that carries context and integration overrides. The destination uses
|
|
81
80
|
* this to stamp consent context on every event.
|
|
82
81
|
*/
|
|
@@ -102,7 +101,7 @@ interface SegmentSDK {
|
|
|
102
101
|
load: (settings: AnalyticsBrowserSettings, options?: InitOptions) => SegmentAnalytics;
|
|
103
102
|
}
|
|
104
103
|
/**
|
|
105
|
-
* Env
|
|
104
|
+
* Env: optional SDK override. Production leaves this undefined and the
|
|
106
105
|
* destination falls back to the real @segment/analytics-next module.
|
|
107
106
|
* Tests provide a mock via env.analytics = { ... }.
|
|
108
107
|
*/
|