@od-oneapp/analytics 2026.2.1501-canary.1 → 2026.2.1701

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.
Files changed (65) hide show
  1. package/{ai-Co8hBoEj.mjs → ai-YMnynb-t.mjs} +2 -2
  2. package/{ai-Co8hBoEj.mjs.map → ai-YMnynb-t.mjs.map} +1 -1
  3. package/{client-C_4MPbIp.mjs → client-CcFTauAh.mjs} +1 -1
  4. package/{client-C_4MPbIp.mjs.map → client-CcFTauAh.mjs.map} +1 -1
  5. package/{client-BOIcr_5V.mjs → client-CeOLjbac.mjs} +1 -1
  6. package/{client-BOIcr_5V.mjs.map → client-CeOLjbac.mjs.map} +1 -1
  7. package/{client-BiJJm6CH.mjs → client-D339NFJS.mjs} +1 -1
  8. package/{client-BiJJm6CH.mjs.map → client-D339NFJS.mjs.map} +1 -1
  9. package/client-next.d.mts +7 -7
  10. package/client-next.mjs +10 -10
  11. package/client.d.mts +9 -9
  12. package/client.mjs +115 -7
  13. package/client.mjs.map +1 -1
  14. package/{config-BUMHyePt.d.mts → config-DPS6bSYo.d.mts} +2 -2
  15. package/{config-BUMHyePt.d.mts.map → config-DPS6bSYo.d.mts.map} +1 -1
  16. package/{config-6Mwe7b2O.mjs → config-P6P5adJg.mjs} +1 -1
  17. package/{config-6Mwe7b2O.mjs.map → config-P6P5adJg.mjs.map} +1 -1
  18. package/{ecommerce-DGG1FbiH.mjs → ecommerce-Cgu4wlux.mjs} +2 -2
  19. package/{ecommerce-DGG1FbiH.mjs.map → ecommerce-Cgu4wlux.mjs.map} +1 -1
  20. package/{emitters-BvEelkxS.mjs → emitters-6-nKo8i-.mjs} +1 -1
  21. package/{emitters-BvEelkxS.mjs.map → emitters-6-nKo8i-.mjs.map} +1 -1
  22. package/{emitters-BAXagFjt.d.mts → emitters-DldkVSPp.d.mts} +2 -2
  23. package/{emitters-BAXagFjt.d.mts.map → emitters-DldkVSPp.d.mts.map} +1 -1
  24. package/index-BfNWgfa5.d.mts +1494 -0
  25. package/index-BfNWgfa5.d.mts.map +1 -0
  26. package/{index-Cnz0VecZ.d.mts → index-BkIWe--N.d.mts} +2 -2
  27. package/{index-Cnz0VecZ.d.mts.map → index-BkIWe--N.d.mts.map} +1 -1
  28. package/{index-qlFPt3-1.d.mts → index-jPzXRn52.d.mts} +3 -3
  29. package/{index-qlFPt3-1.d.mts.map → index-jPzXRn52.d.mts.map} +1 -1
  30. package/{manager-B6kowr9x.d.mts → manager-DvRRjza6.d.mts} +9 -3
  31. package/{manager-B6kowr9x.d.mts.map → manager-DvRRjza6.d.mts.map} +1 -1
  32. package/package.json +7 -2
  33. package/{posthog-bootstrap-DDToYA4X.mjs → posthog-bootstrap-CYfIy_WS.mjs} +7 -6
  34. package/posthog-bootstrap-CYfIy_WS.mjs.map +1 -0
  35. package/{posthog-bootstrap-CRl1Pk_E.d.mts → posthog-bootstrap-DWxFrxlt.d.mts} +3 -3
  36. package/{posthog-bootstrap-CRl1Pk_E.d.mts.map → posthog-bootstrap-DWxFrxlt.d.mts.map} +1 -1
  37. package/providers-http-client.d.mts +1 -1
  38. package/providers-http-client.mjs +1 -1
  39. package/providers-http-server.d.mts +1 -1
  40. package/providers-http-server.mjs +1 -1
  41. package/server-edge.d.mts +3 -3
  42. package/server-edge.mjs +2 -2
  43. package/server-next.d.mts +11 -10
  44. package/server-next.d.mts.map +1 -1
  45. package/server-next.mjs +6 -6
  46. package/server.d.mts +10 -10
  47. package/server.mjs +6 -6
  48. package/service-Duqnlppl.mjs +1049 -0
  49. package/service-Duqnlppl.mjs.map +1 -0
  50. package/shared.d.mts +4 -4
  51. package/shared.mjs +3 -3
  52. package/{types-DnfdguWa.d.mts → types-BxBnNQ0V.d.mts} +1 -1
  53. package/{types-DnfdguWa.d.mts.map → types-BxBnNQ0V.d.mts.map} +1 -1
  54. package/{types-Brm88i6e.d.mts → types-CBvxUEaF.d.mts} +1 -1
  55. package/{types-Brm88i6e.d.mts.map → types-CBvxUEaF.d.mts.map} +1 -1
  56. package/types.d.mts +3 -3
  57. package/{vercel-types-Crq8m8c1.d.mts → vercel-types-lwakUfoI.d.mts} +1 -1
  58. package/{vercel-types-Crq8m8c1.d.mts.map → vercel-types-lwakUfoI.d.mts.map} +1 -1
  59. package/logs-B4zFs5kX.mjs +0 -108
  60. package/logs-B4zFs5kX.mjs.map +0 -1
  61. package/posthog-bootstrap-DDToYA4X.mjs.map +0 -1
  62. package/validation-DZc_nvoN.d.mts +0 -24
  63. package/validation-DZc_nvoN.d.mts.map +0 -1
  64. package/validation-Dll9R6h6.mjs +0 -315
  65. package/validation-Dll9R6h6.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config-6Mwe7b2O.mjs","names":[],"sources":["../src/shared/utils/emitter-adapter.ts","../src/shared/utils/config.ts"],"sourcesContent":["/**\n * @fileoverview Adapter functions to convert emitter payloads to analytics method calls\n * Adapter functions to convert emitter payloads to analytics method calls\n * This bridges the gap between the Segment.io spec emitters and the analytics manager\n */\n\nimport type {\n EmitterAliasPayload,\n EmitterGroupPayload,\n EmitterIdentifyPayload,\n EmitterPagePayload,\n EmitterPayload,\n EmitterScreenPayload,\n EmitterTrackPayload,\n} from '../emitters/emitter-types';\nimport type { AnalyticsManager } from '../types/types';\n\n/**\n * Routes any emitter payload to the matching analytics manager method.\n *\n * This function is deliberately small so that Codex/OpenAI powered tooling can\n * inspect a single switch statement and understand how each analytics verb maps\n * to the strongly typed helper below.\n *\n * @deprecated Use `analytics.emit(payload)` instead for simpler API usage.\n * This function remains available for compatibility and advanced use cases.\n *\n * @example Preferred approach:\n * ```typescript\n * await analytics.emit(track('Button Clicked', { color: 'blue' }));\n * ```\n *\n * @param analytics - The analytics manager implementation (client or server)\n * @param payload - Any emitter payload created by the Segment-style helpers\n * @throws Error when the payload type is unknown, protecting against silent drops\n */\nexport async function processEmitterPayload(\n analytics: AnalyticsManager,\n payload: EmitterPayload,\n): Promise<void> {\n switch (payload.type) {\n case 'identify':\n return processIdentifyPayload(analytics, payload);\n case 'track':\n return processTrackPayload(analytics, payload);\n case 'page':\n return processPagePayload(analytics, payload);\n case 'screen':\n return processScreenPayload(analytics, payload);\n case 'group':\n return processGroupPayload(analytics, payload);\n case 'alias':\n return processAliasPayload(analytics, payload);\n default: {\n // Runtime safety for unknown payload types (e.g., from untyped JavaScript code)\n const unknownPayload = payload as { type: string };\n throw new Error(`Unknown emitter payload type: ${unknownPayload.type}`);\n }\n }\n}\n\n/**\n * Pipes an identify payload into `analytics.identify`, preserving context.\n *\n * @param analytics - Active analytics manager\n * @param payload - Identify payload produced by the emitter factory\n */\nexport async function processIdentifyPayload(\n analytics: AnalyticsManager,\n payload: EmitterIdentifyPayload,\n): Promise<void> {\n const { traits, userId, ...options } = payload;\n\n // Convert emitter options to tracking options\n const trackingOptions = {\n context: options.context,\n // Add other options as needed\n };\n\n await analytics.identify(userId, traits, trackingOptions);\n}\n\n/**\n * Pipes a track payload into `analytics.track`, preserving context metadata.\n *\n * @param analytics - Active analytics manager\n * @param payload - Track payload produced by the emitter factory\n */\nexport async function processTrackPayload(\n analytics: AnalyticsManager,\n payload: EmitterTrackPayload,\n): Promise<void> {\n const { event, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.track(event, properties, trackingOptions);\n}\n\n/**\n * Pipes a page payload into `analytics.page`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Page payload produced by the emitter factory\n */\nexport async function processPagePayload(\n analytics: AnalyticsManager,\n payload: EmitterPagePayload,\n): Promise<void> {\n const { name, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.page(name, properties, trackingOptions);\n}\n\n/**\n * Pipes a screen payload into `analytics.screen` (mobile equivalent of page).\n *\n * @param analytics - Active analytics manager\n * @param payload - Screen payload produced by the emitter factory\n */\nexport async function processScreenPayload(\n analytics: AnalyticsManager,\n payload: EmitterScreenPayload,\n): Promise<void> {\n const { name, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.screen?.(name, properties, trackingOptions);\n}\n\n/**\n * Pipes a group payload into `analytics.group`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Group payload produced by the emitter factory\n */\nexport async function processGroupPayload(\n analytics: AnalyticsManager,\n payload: EmitterGroupPayload,\n): Promise<void> {\n const { groupId, traits, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.group(groupId, traits, trackingOptions);\n}\n\n/**\n * Pipes an alias payload into `analytics.alias`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Alias payload produced by the emitter factory\n */\nexport async function processAliasPayload(\n analytics: AnalyticsManager,\n payload: EmitterAliasPayload,\n): Promise<void> {\n const { previousId, userId, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.alias(userId, previousId ?? '', trackingOptions);\n}\n\n/**\n * Creates a pre-bound emitter processor for repeated usage.\n *\n * @example\n * ```ts\n * const processor = createEmitterProcessor(analytics);\n * queue.forEach(processor);\n * ```\n *\n * @param analytics - Active analytics manager\n * @returns Function that accepts any emitter payload and routes it correctly\n */\nexport function createEmitterProcessor(analytics: AnalyticsManager) {\n return (payload: EmitterPayload) => processEmitterPayload(analytics, payload);\n}\n\n/**\n * Minimal helper for wiring ecommerce event specs into analytics.track.\n *\n * @deprecated Use `analytics.emit(ecommerce.EVENT_NAME(...))` instead.\n *\n * @example Preferred approach:\n * ```typescript\n * await analytics.emit(ecommerce.productViewed({ product_id: '123' }));\n * ```\n *\n * @param analytics - Active analytics manager\n * @param eventSpec - Object that contains the `name` and `properties` fields\n */\nexport async function trackEcommerceEvent(\n analytics: AnalyticsManager,\n eventSpec: { name: string; properties: Record<string, any> },\n): Promise<void> {\n await analytics.track(eventSpec.name, eventSpec.properties);\n}\n","/**\n * @fileoverview Configuration utilities for the analytics system\n *\n * This module provides configuration utilities that work in both client and server\n * environments. It includes:\n *\n * - **Provider Requirements**: Required fields for each provider type\n * - **Configuration Validation**: Validates provider configurations\n * - **Config Builder**: Fluent API for building configurations\n * - **Config Factory**: Environment-aware configuration factory\n *\n * **Usage**: Use `createConfigBuilder()` for programmatic config creation or\n * `getAnalyticsConfig()` for environment-aware configuration.\n *\n * @module @od-oneapp/analytics/shared/utils/config\n */\n\nimport type { AnalyticsConfig, ProviderConfig } from '../types/types';\n\n/**\n * Type for provider requirements mapping.\n *\n * Maps provider names to arrays of required configuration field names.\n */\nexport type ConfigRequirements = Record<string, string[]>;\n\n/**\n * Provider requirements map - defines required fields for each provider.\n *\n * Used during configuration validation to ensure all required fields are present.\n * Providers not listed here have no required fields.\n */\nexport const PROVIDER_REQUIREMENTS: ConfigRequirements = {\n console: [], // No required fields\n mixpanel: [], // Server-only provider\n posthog: ['apiKey'],\n segment: ['writeKey'],\n vercel: [], // No required fields\n};\n\n/**\n * Validates analytics configuration.\n *\n * Accepts `unknown` for runtime validation of potentially malformed configs.\n * Throws descriptive errors if configuration is invalid.\n *\n * @param {unknown} config - Configuration object to validate\n * @throws {Error} If configuration is invalid or missing required fields\n *\n * @example\n * ```typescript\n * try {\n * validateConfig(config);\n * } catch (error) {\n * console.error('Invalid config:', error.message);\n * }\n * ```\n */\nexport function validateConfig(config: unknown): void {\n if (!config || typeof config !== 'object') {\n throw new Error('Analytics config must be an object');\n }\n\n const typedConfig = config as AnalyticsConfig;\n\n if (!typedConfig.providers || typeof typedConfig.providers !== 'object') {\n throw new Error('Analytics config must have a providers object');\n }\n\n for (const [providerName, providerConfig] of Object.entries(typedConfig.providers)) {\n validateProviderConfig(providerName, providerConfig);\n }\n}\n\n/**\n * Validates a single provider configuration.\n *\n * Checks that all required fields for the provider are present in the configuration.\n *\n * @param {string} providerName - Name of the provider to validate\n * @param {ProviderConfig} config - Provider configuration to validate\n * @throws {Error} If required fields are missing\n *\n * @internal\n */\nfunction validateProviderConfig(providerName: string, config: ProviderConfig): void {\n const requiredFields = PROVIDER_REQUIREMENTS[providerName] ?? [];\n\n for (const field of requiredFields) {\n if (!config[field as keyof ProviderConfig]) {\n throw new Error(\n `Provider '${providerName}' missing required field '${field}'. ` +\n `Remove the provider from config or provide the required field.`,\n );\n }\n }\n}\n\n/**\n * Configuration builder interface.\n *\n * Provides a fluent API for building analytics configurations programmatically.\n * Methods return `this` to enable method chaining.\n */\nexport interface ConfigBuilder {\n addConsole(options?: Record<string, unknown>): ConfigBuilder;\n addPostHog(apiKey: string, options?: Record<string, unknown>): ConfigBuilder;\n addProvider(name: string, config: ProviderConfig): ConfigBuilder;\n addSegment(writeKey: string, options?: Record<string, unknown>): ConfigBuilder;\n addVercel(options?: Record<string, unknown>): ConfigBuilder;\n build(): AnalyticsConfig;\n providers: Record<string, ProviderConfig>;\n}\n\n/**\n * Creates a fluent configuration builder.\n *\n * Returns a builder instance that allows chaining provider configuration methods.\n * Call `build()` at the end to get the final configuration object.\n *\n * @returns {ConfigBuilder} Configuration builder instance\n *\n * @example\n * ```typescript\n * const config = createConfigBuilder()\n * .addPostHog('phc_xxx')\n * .addSegment('xxx')\n * .addConsole({ pretty: true })\n * .build();\n * ```\n */\nexport function createConfigBuilder(): ConfigBuilder {\n const builder: ConfigBuilder = {\n providers: {},\n\n addProvider(name: string, config: ProviderConfig): ConfigBuilder {\n this.providers[name] = config;\n return this;\n },\n\n addSegment(writeKey: string, options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('segment', { options, writeKey });\n },\n\n addPostHog(apiKey: string, options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('posthog', { apiKey, options });\n },\n\n addVercel(options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('vercel', { options });\n },\n\n addConsole(options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('console', { options });\n },\n\n build(): AnalyticsConfig {\n const config = { providers: { ...this.providers } };\n validateConfig(config);\n return config;\n },\n };\n\n return builder;\n}\n\n/**\n * Options for client-side configuration.\n *\n * Allows explicit configuration values to be passed instead of reading from\n * environment variables. Useful for client-side code where environment variables\n * may not be available.\n */\nexport interface AnalyticsConfigOptions {\n isDevelopment?: boolean;\n isStaging?: boolean;\n segmentWriteKey?: string;\n posthogApiKey?: string;\n}\n\n/**\n * Get analytics configuration\n *\n * When called with options (client-safe), uses the provided values.\n * When called without options (server), reads from process.env.\n *\n * @param options - Optional configuration options for client-side usage\n * @returns Analytics configuration object\n *\n * @example Server usage (reads from process.env):\n * ```typescript\n * const config = getAnalyticsConfig();\n * ```\n *\n * @example Client usage (explicit options):\n * ```typescript\n * const config = getAnalyticsConfig({\n * isDevelopment: process.env.NODE_ENV === 'development',\n * posthogApiKey: process.env.NEXT_PUBLIC_POSTHOG_KEY,\n * });\n * ```\n */\nexport function getAnalyticsConfig(options?: AnalyticsConfigOptions): AnalyticsConfig {\n const builder = createConfigBuilder();\n\n // Determine environment from options or process.env\n const isDevelopment = options?.isDevelopment ?? process.env.NODE_ENV === 'development';\n const isStaging = options?.isStaging ?? process.env.APP_ENV === 'staging';\n\n // Get API keys from options or process.env\n const posthogApiKey = options?.posthogApiKey ?? process.env.POSTHOG_API_KEY;\n const segmentWriteKey = options?.segmentWriteKey ?? process.env.SEGMENT_WRITE_KEY;\n\n // Development - minimal providers\n if (isDevelopment) {\n builder.addConsole({\n prefix: '[Dev Analytics]',\n pretty: true,\n });\n return builder.build();\n }\n\n // Staging - selective providers\n if (isStaging) {\n if (posthogApiKey) {\n builder.addPostHog(posthogApiKey);\n }\n\n builder.addConsole({\n prefix: '[Staging Analytics]',\n pretty: true,\n });\n\n return builder.build();\n }\n\n // Production - multiple providers\n if (segmentWriteKey) {\n builder.addSegment(segmentWriteKey);\n }\n\n if (posthogApiKey) {\n builder.addPostHog(posthogApiKey);\n }\n\n // Add Vercel Analytics in production\n builder.addVercel();\n\n return builder.build();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,eAAsB,sBACpB,WACA,SACe;AACf,SAAQ,QAAQ,MAAhB;EACE,KAAK,WACH,QAAO,uBAAuB,WAAW,QAAQ;EACnD,KAAK,QACH,QAAO,oBAAo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zD,UAAU,SAAkD;AAC1D,UAAO,KAAK,YAAY,UAAU,EAAE,SAAS,CAAC;;EAGhD,WAAW,SAAkD;AAC3D,UAAO,KAAK,YAAY,WAAW,EAAE,SAAS,CAAC;;EAGjD,QAAyB;GACvB,MAAM,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,WAAW,EAAE;AACnD,kBAAe,OAAO;AACtB,UAAO;;EAEV;;;;;;;;;;;;;;;;;;;;;;;;AAyCH,SAAgB,mBAAmB,SAAmD;CACpF,MAAM,UAAU,qBAAqB;CAGrC,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,YAAY,SAAS,aAAa,QAAQ,IAAI,YAAY;CAGhE,MAAM,gBAAgB,SAAS,iBAAiB,QAAQ,IAAI;CAC5D,MAAM,kBAAkB,SAAS,mBAAmB,QAAQ,IAAI;AAGhE,KAAI,eAAe;AACjB,UAAQ,WAAW;GACjB,QAAQ;GACR,QAAQ;GACT,CAAC;AACF,SAAO,QAAQ,OAAO;;AAIxB,KAAI,WAAW;AACb,MAAI,cACF,SAAQ,WAAW,cAAc;AAGnC,UAAQ,WAAW;GACjB,QAAQ;GACR,QAAQ;GACT,CAAC;AAEF,SAAO,QAAQ,OAAO;;AAIxB,KAAI,gBACF,SAAQ,WAAW,gBAAgB;AAGrC,KAAI,cACF,SAAQ,WAAW,cAAc;AAInC,SAAQ,WAAW;AAEnB,QAAO,QAAQ,OAAO"}
1
+ {"version":3,"file":"config-P6P5adJg.mjs","names":[],"sources":["../src/shared/utils/emitter-adapter.ts","../src/shared/utils/config.ts"],"sourcesContent":["/**\n * @fileoverview Adapter functions to convert emitter payloads to analytics method calls\n * Adapter functions to convert emitter payloads to analytics method calls\n * This bridges the gap between the Segment.io spec emitters and the analytics manager\n */\n\nimport type {\n EmitterAliasPayload,\n EmitterGroupPayload,\n EmitterIdentifyPayload,\n EmitterPagePayload,\n EmitterPayload,\n EmitterScreenPayload,\n EmitterTrackPayload,\n} from '../emitters/emitter-types';\nimport type { AnalyticsManager } from '../types/types';\n\n/**\n * Routes any emitter payload to the matching analytics manager method.\n *\n * This function is deliberately small so that Codex/OpenAI powered tooling can\n * inspect a single switch statement and understand how each analytics verb maps\n * to the strongly typed helper below.\n *\n * @deprecated Use `analytics.emit(payload)` instead for simpler API usage.\n * This function remains available for compatibility and advanced use cases.\n *\n * @example Preferred approach:\n * ```typescript\n * await analytics.emit(track('Button Clicked', { color: 'blue' }));\n * ```\n *\n * @param analytics - The analytics manager implementation (client or server)\n * @param payload - Any emitter payload created by the Segment-style helpers\n * @throws Error when the payload type is unknown, protecting against silent drops\n */\nexport async function processEmitterPayload(\n analytics: AnalyticsManager,\n payload: EmitterPayload,\n): Promise<void> {\n switch (payload.type) {\n case 'identify':\n return processIdentifyPayload(analytics, payload);\n case 'track':\n return processTrackPayload(analytics, payload);\n case 'page':\n return processPagePayload(analytics, payload);\n case 'screen':\n return processScreenPayload(analytics, payload);\n case 'group':\n return processGroupPayload(analytics, payload);\n case 'alias':\n return processAliasPayload(analytics, payload);\n default: {\n // Runtime safety for unknown payload types (e.g., from untyped JavaScript code)\n const unknownPayload = payload as { type: string };\n throw new Error(`Unknown emitter payload type: ${unknownPayload.type}`);\n }\n }\n}\n\n/**\n * Pipes an identify payload into `analytics.identify`, preserving context.\n *\n * @param analytics - Active analytics manager\n * @param payload - Identify payload produced by the emitter factory\n */\nexport async function processIdentifyPayload(\n analytics: AnalyticsManager,\n payload: EmitterIdentifyPayload,\n): Promise<void> {\n const { traits, userId, ...options } = payload;\n\n // Convert emitter options to tracking options\n const trackingOptions = {\n context: options.context,\n // Add other options as needed\n };\n\n await analytics.identify(userId, traits, trackingOptions);\n}\n\n/**\n * Pipes a track payload into `analytics.track`, preserving context metadata.\n *\n * @param analytics - Active analytics manager\n * @param payload - Track payload produced by the emitter factory\n */\nexport async function processTrackPayload(\n analytics: AnalyticsManager,\n payload: EmitterTrackPayload,\n): Promise<void> {\n const { event, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.track(event, properties, trackingOptions);\n}\n\n/**\n * Pipes a page payload into `analytics.page`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Page payload produced by the emitter factory\n */\nexport async function processPagePayload(\n analytics: AnalyticsManager,\n payload: EmitterPagePayload,\n): Promise<void> {\n const { name, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.page(name, properties, trackingOptions);\n}\n\n/**\n * Pipes a screen payload into `analytics.screen` (mobile equivalent of page).\n *\n * @param analytics - Active analytics manager\n * @param payload - Screen payload produced by the emitter factory\n */\nexport async function processScreenPayload(\n analytics: AnalyticsManager,\n payload: EmitterScreenPayload,\n): Promise<void> {\n const { name, properties, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.screen?.(name, properties, trackingOptions);\n}\n\n/**\n * Pipes a group payload into `analytics.group`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Group payload produced by the emitter factory\n */\nexport async function processGroupPayload(\n analytics: AnalyticsManager,\n payload: EmitterGroupPayload,\n): Promise<void> {\n const { groupId, traits, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.group(groupId, traits, trackingOptions);\n}\n\n/**\n * Pipes an alias payload into `analytics.alias`.\n *\n * @param analytics - Active analytics manager\n * @param payload - Alias payload produced by the emitter factory\n */\nexport async function processAliasPayload(\n analytics: AnalyticsManager,\n payload: EmitterAliasPayload,\n): Promise<void> {\n const { previousId, userId, ...options } = payload;\n\n const trackingOptions = {\n context: options.context,\n };\n\n await analytics.alias(userId, previousId ?? '', trackingOptions);\n}\n\n/**\n * Creates a pre-bound emitter processor for repeated usage.\n *\n * @example\n * ```ts\n * const processor = createEmitterProcessor(analytics);\n * queue.forEach(processor);\n * ```\n *\n * @param analytics - Active analytics manager\n * @returns Function that accepts any emitter payload and routes it correctly\n */\nexport function createEmitterProcessor(analytics: AnalyticsManager) {\n return (payload: EmitterPayload) => processEmitterPayload(analytics, payload);\n}\n\n/**\n * Minimal helper for wiring ecommerce event specs into analytics.track.\n *\n * @deprecated Use `analytics.emit(ecommerce.EVENT_NAME(...))` instead.\n *\n * @example Preferred approach:\n * ```typescript\n * await analytics.emit(ecommerce.productViewed({ product_id: '123' }));\n * ```\n *\n * @param analytics - Active analytics manager\n * @param eventSpec - Object that contains the `name` and `properties` fields\n */\nexport async function trackEcommerceEvent(\n analytics: AnalyticsManager,\n eventSpec: { name: string; properties: Record<string, any> },\n): Promise<void> {\n await analytics.track(eventSpec.name, eventSpec.properties);\n}\n","/**\n * @fileoverview Configuration utilities for the analytics system\n *\n * This module provides configuration utilities that work in both client and server\n * environments. It includes:\n *\n * - **Provider Requirements**: Required fields for each provider type\n * - **Configuration Validation**: Validates provider configurations\n * - **Config Builder**: Fluent API for building configurations\n * - **Config Factory**: Environment-aware configuration factory\n *\n * **Usage**: Use `createConfigBuilder()` for programmatic config creation or\n * `getAnalyticsConfig()` for environment-aware configuration.\n *\n * @module @od-oneapp/analytics/shared/utils/config\n */\n\nimport type { AnalyticsConfig, ProviderConfig } from '../types/types';\n\n/**\n * Type for provider requirements mapping.\n *\n * Maps provider names to arrays of required configuration field names.\n */\nexport type ConfigRequirements = Record<string, string[]>;\n\n/**\n * Provider requirements map - defines required fields for each provider.\n *\n * Used during configuration validation to ensure all required fields are present.\n * Providers not listed here have no required fields.\n */\nexport const PROVIDER_REQUIREMENTS: ConfigRequirements = {\n console: [], // No required fields\n mixpanel: [], // Server-only provider\n posthog: ['apiKey'],\n segment: ['writeKey'],\n vercel: [], // No required fields\n};\n\n/**\n * Validates analytics configuration.\n *\n * Accepts `unknown` for runtime validation of potentially malformed configs.\n * Throws descriptive errors if configuration is invalid.\n *\n * @param {unknown} config - Configuration object to validate\n * @throws {Error} If configuration is invalid or missing required fields\n *\n * @example\n * ```typescript\n * try {\n * validateConfig(config);\n * } catch (error) {\n * console.error('Invalid config:', error.message);\n * }\n * ```\n */\nexport function validateConfig(config: unknown): void {\n if (!config || typeof config !== 'object') {\n throw new Error('Analytics config must be an object');\n }\n\n const typedConfig = config as AnalyticsConfig;\n\n if (!typedConfig.providers || typeof typedConfig.providers !== 'object') {\n throw new Error('Analytics config must have a providers object');\n }\n\n for (const [providerName, providerConfig] of Object.entries(typedConfig.providers)) {\n validateProviderConfig(providerName, providerConfig);\n }\n}\n\n/**\n * Validates a single provider configuration.\n *\n * Checks that all required fields for the provider are present in the configuration.\n *\n * @param {string} providerName - Name of the provider to validate\n * @param {ProviderConfig} config - Provider configuration to validate\n * @throws {Error} If required fields are missing\n *\n * @internal\n */\nfunction validateProviderConfig(providerName: string, config: ProviderConfig): void {\n const requiredFields = PROVIDER_REQUIREMENTS[providerName] ?? [];\n\n for (const field of requiredFields) {\n if (!config[field as keyof ProviderConfig]) {\n throw new Error(\n `Provider '${providerName}' missing required field '${field}'. ` +\n `Remove the provider from config or provide the required field.`,\n );\n }\n }\n}\n\n/**\n * Configuration builder interface.\n *\n * Provides a fluent API for building analytics configurations programmatically.\n * Methods return `this` to enable method chaining.\n */\nexport interface ConfigBuilder {\n addConsole(options?: Record<string, unknown>): ConfigBuilder;\n addPostHog(apiKey: string, options?: Record<string, unknown>): ConfigBuilder;\n addProvider(name: string, config: ProviderConfig): ConfigBuilder;\n addSegment(writeKey: string, options?: Record<string, unknown>): ConfigBuilder;\n addVercel(options?: Record<string, unknown>): ConfigBuilder;\n build(): AnalyticsConfig;\n providers: Record<string, ProviderConfig>;\n}\n\n/**\n * Creates a fluent configuration builder.\n *\n * Returns a builder instance that allows chaining provider configuration methods.\n * Call `build()` at the end to get the final configuration object.\n *\n * @returns {ConfigBuilder} Configuration builder instance\n *\n * @example\n * ```typescript\n * const config = createConfigBuilder()\n * .addPostHog('phc_xxx')\n * .addSegment('xxx')\n * .addConsole({ pretty: true })\n * .build();\n * ```\n */\nexport function createConfigBuilder(): ConfigBuilder {\n const builder: ConfigBuilder = {\n providers: {},\n\n addProvider(name: string, config: ProviderConfig): ConfigBuilder {\n this.providers[name] = config;\n return this;\n },\n\n addSegment(writeKey: string, options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('segment', { options, writeKey });\n },\n\n addPostHog(apiKey: string, options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('posthog', { apiKey, options });\n },\n\n addVercel(options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('vercel', { options });\n },\n\n addConsole(options?: Record<string, unknown>): ConfigBuilder {\n return this.addProvider('console', { options });\n },\n\n build(): AnalyticsConfig {\n const config = { providers: { ...this.providers } };\n validateConfig(config);\n return config;\n },\n };\n\n return builder;\n}\n\n/**\n * Options for client-side configuration.\n *\n * Allows explicit configuration values to be passed instead of reading from\n * environment variables. Useful for client-side code where environment variables\n * may not be available.\n */\nexport interface AnalyticsConfigOptions {\n isDevelopment?: boolean;\n isStaging?: boolean;\n segmentWriteKey?: string;\n posthogApiKey?: string;\n}\n\n/**\n * Get analytics configuration\n *\n * When called with options (client-safe), uses the provided values.\n * When called without options (server), reads from process.env.\n *\n * @param options - Optional configuration options for client-side usage\n * @returns Analytics configuration object\n *\n * @example Server usage (reads from process.env):\n * ```typescript\n * const config = getAnalyticsConfig();\n * ```\n *\n * @example Client usage (explicit options):\n * ```typescript\n * const config = getAnalyticsConfig({\n * isDevelopment: process.env.NODE_ENV === 'development',\n * posthogApiKey: process.env.NEXT_PUBLIC_POSTHOG_KEY,\n * });\n * ```\n */\nexport function getAnalyticsConfig(options?: AnalyticsConfigOptions): AnalyticsConfig {\n const builder = createConfigBuilder();\n\n // Determine environment from options or process.env\n const isDevelopment = options?.isDevelopment ?? process.env.NODE_ENV === 'development';\n const isStaging = options?.isStaging ?? process.env.APP_ENV === 'staging';\n\n // Get API keys from options or process.env\n const posthogApiKey = options?.posthogApiKey ?? process.env.POSTHOG_API_KEY;\n const segmentWriteKey = options?.segmentWriteKey ?? process.env.SEGMENT_WRITE_KEY;\n\n // Development - minimal providers\n if (isDevelopment) {\n builder.addConsole({\n prefix: '[Dev Analytics]',\n pretty: true,\n });\n return builder.build();\n }\n\n // Staging - selective providers\n if (isStaging) {\n if (posthogApiKey) {\n builder.addPostHog(posthogApiKey);\n }\n\n builder.addConsole({\n prefix: '[Staging Analytics]',\n pretty: true,\n });\n\n return builder.build();\n }\n\n // Production - multiple providers\n if (segmentWriteKey) {\n builder.addSegment(segmentWriteKey);\n }\n\n if (posthogApiKey) {\n builder.addPostHog(posthogApiKey);\n }\n\n // Add Vercel Analytics in production\n builder.addVercel();\n\n return builder.build();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,eAAsB,sBACpB,WACA,SACe;AACf,SAAQ,QAAQ,MAAhB;EACE,KAAK,WACH,QAAO,uBAAuB,WAAW,QAAQ;EACnD,KAAK,QACH,QAAO,oBAAoB,WAAW,QAAQ;EAChD,KAAK,OACH,QAAO,mBAAmB,WAAW,QAAQ;EAC/C,KAAK,SACH,QAAO,qBAAqB,WAAW,QAAQ;EACjD,KAAK,QACH,QAAO,oBAAoB,WAAW,QAAQ;EAChD,KAAK,QACH,QAAO,oBAAoB,WAAW,QAAQ;EAChD,SAAS;GAEP,MAAM,iBAAiB;AACvB,SAAM,IAAI,MAAM,iCAAiC,eAAe,OAAO;;;;;;;;;;AAW7E,eAAsB,uBACpB,WACA,SACe;CACf,MAAM,EAAE,QAAQ,QAAQ,GAAG,YAAY;CAGvC,MAAM,kBAAkB,EACtB,SAAS,QAAQ,SAElB;AAED,OAAM,UAAU,SAAS,QAAQ,QAAQ,gBAAgB;;;;;;;;AAS3D,eAAsB,oBACpB,WACA,SACe;CACf,MAAM,EAAE,OAAO,YAAY,GAAG,YAAY;CAE1C,MAAM,kBAAkB,EACtB,SAAS,QAAQ,SAClB;AAED,OAAM,UAAU,MAAM,OAAO,YAAY,gBAAgB;;;;;;;;AAS3D,eAAsB,mBACpB,WACA,SACe;CACf,MAAM,EAAE,MAAM,YAAY,GAAG,YAAY;CAEzC,MAAM,kBAAkB,EACtB,SAAS,QAAQ,SAClB;AAED,OAAM,UAAU,KAAK,M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ACF,SAAQ,WAAW,gBAAgB;AAGrC,KAAI,cACF,SAAQ,WAAW,cAAc;AAInC,SAAQ,WAAW;AAEnB,QAAO,QAAQ,OAAO"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
2
- import { o as track } from "./emitters-BvEelkxS.mjs";
2
+ import { o as track } from "./emitters-6-nKo8i-.mjs";
3
3
 
4
4
  //#region src/shared/emitters/ecommerce/types.ts
5
5
  const ECOMMERCE_EVENTS = {
@@ -990,4 +990,4 @@ var ecommerce_exports = /* @__PURE__ */ __exportAll({
990
990
 
991
991
  //#endregion
992
992
  export { ecommerce_exports as t };
993
- //# sourceMappingURL=ecommerce-DGG1FbiH.mjs.map
993
+ //# sourceMappingURL=ecommerce-Cgu4wlux.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ecommerce-DGG1FbiH.mjs","names":[],"sources":["../src/shared/emitters/ecommerce/types.ts","../src/shared/emitters/ecommerce/utils.ts","../src/shared/emitters/ecommerce/track-ecommerce.ts","../src/shared/emitters/ecommerce/events/cart-checkout.ts","../src/shared/emitters/ecommerce/events/coupon.ts","../src/shared/emitters/ecommerce/events/engagement.ts","../src/shared/emitters/ecommerce/events/marketplace.ts","../src/shared/emitters/ecommerce/events/order.ts","../src/shared/emitters/ecommerce/events/product.ts","../src/shared/emitters/ecommerce/events/registry.ts","../src/shared/emitters/ecommerce/events/wishlist-sharing.ts","../src/shared/emitters/ecommerce/index.ts"],"sourcesContent":["/**\n * @fileoverview Platform-standard ecommerce event types\n * Platform-standard ecommerce event types\n * Based on industry best practices for ecommerce tracking\n */\n\n// Base product properties shared across events\nexport interface BaseProductProperties {\n affiliate_link?: string | undefined;\n affiliate_network?: string | undefined;\n availability?: 'in_stock' | 'out_of_stock' | 'preorder' | 'discontinued' | undefined;\n brand?: string | undefined;\n category?: string | undefined;\n commission_amount?: number | undefined;\n commission_rate?: number | undefined;\n condition?: 'new' | 'used' | 'refurbished' | undefined;\n coupon?: string | undefined;\n gtin?: string | undefined;\n image_url?: string | undefined;\n // Marketplace/affiliate properties (optional for any product)\n merchant_id?: string | undefined;\n merchant_name?: string | undefined;\n merchant_url?: string | undefined;\n mpn?: string | undefined;\n name?: string | undefined;\n original_price?: number | undefined;\n position?: number | undefined;\n price?: number | undefined;\n product_id: string;\n quantity?: number | undefined;\n sale_price?: number | undefined;\n url?: string | undefined;\n variant?: string | undefined;\n}\n\n// Extended product properties for detailed tracking\nexport interface ExtendedProductProperties extends BaseProductProperties {\n currency?: string | undefined;\n value?: number | undefined;\n}\n\n// Registry-specific properties\nexport interface RegistryProperties {\n co_registrant_id?: string | undefined;\n co_registrant_name?: string | undefined;\n event_date?: string | undefined;\n privacy_setting?: 'public' | 'private' | 'unlisted' | undefined;\n registry_id: string;\n registry_name?: string | undefined;\n registry_type?: 'wedding' | 'baby' | 'birthday' | 'universal' | 'custom' | undefined;\n registry_url?: string | undefined;\n}\n\n// Registry item properties\nexport interface RegistryItemProperties extends BaseProductProperties {\n merchant_id?: string | undefined;\n merchant_name?: string | undefined;\n notes?: string | undefined;\n priority?: 'high' | 'medium' | 'low' | undefined;\n purchased_quantity?: number | undefined;\n registry_id: string;\n requested_quantity?: number | undefined;\n}\n\n// Properties for product list events\nexport interface ProductListProperties {\n category?: string | undefined;\n list_id?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n}\n\n// Properties for cart events\nexport interface CartProperties {\n cart_id?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n}\n\n// Properties for checkout events\nexport interface CheckoutProperties {\n checkout_id?: string | undefined;\n payment_method?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n shipping_method?: string | undefined;\n step?: number | undefined;\n}\n\n// Properties for order events\nexport interface OrderProperties {\n affiliation?: string | undefined;\n coupon?: string | undefined;\n currency?: string | undefined;\n discount?: number | undefined;\n order_id: string;\n products?: BaseProductProperties[] | undefined;\n revenue?: number | undefined;\n shipping?: number | undefined;\n tax?: number | undefined;\n total?: number | undefined;\n}\n\n// Properties for coupon events\nexport interface CouponProperties {\n cart_id?: string | undefined;\n coupon_id?: string | undefined;\n coupon_name?: string | undefined;\n discount?: number | undefined;\n order_id?: string | undefined;\n reason?: string | undefined;\n}\n\n// Properties for wishlist events\nexport interface WishlistProperties extends BaseProductProperties {\n wishlist_id?: string | undefined;\n wishlist_name?: string | undefined;\n}\n\n// Properties for sharing events\nexport interface SharingProperties {\n recipient?: string | undefined;\n share_message?: string | undefined;\n share_via?: string | undefined;\n}\n\n// Properties for review events\nexport interface ReviewProperties {\n product_id: string;\n rating?: string | undefined;\n review_body?: string | undefined;\n review_id?: string | undefined;\n}\n\n// Properties for search results\nexport interface SearchResultsProperties {\n filters_applied?: Record<string, any>;\n products?: BaseProductProperties[];\n query: string;\n results_count: number;\n sort_order?: string;\n}\n\n// Properties for cart updates\nexport interface CartUpdateProperties {\n action: 'added' | 'removed' | 'updated';\n cart_id?: string;\n cart_total?: number;\n product: BaseProductProperties;\n quantity_change?: number;\n}\n\n// Properties for cart abandonment\nexport interface CartAbandonmentProperties {\n abandonment_reason?: 'timeout' | 'navigation' | 'closed';\n cart_id: string;\n cart_value: number;\n products: BaseProductProperties[];\n time_in_cart?: number;\n}\n\n// Properties for checkout progression\nexport interface CheckoutProgressProperties {\n action: 'viewed' | 'completed' | 'abandoned' | 'error';\n checkout_id?: string;\n error_message?: string;\n payment_method?: string;\n products?: BaseProductProperties[];\n shipping_method?: string;\n step: number;\n step_name: string;\n}\n\n// Properties for order status updates\nexport interface OrderStatusProperties {\n carrier?: string;\n estimated_delivery?: string;\n order_id: string;\n previous_status?: string;\n status:\n | 'confirmed'\n | 'processing'\n | 'shipped'\n | 'out_for_delivery'\n | 'delivered'\n | 'returned'\n | 'failed';\n tracking_number?: string;\n}\n\n// Properties for product comparison\nexport interface ProductComparisonProperties {\n action: 'added' | 'removed' | 'viewed';\n comparison_list?: BaseProductProperties[];\n product: BaseProductProperties;\n}\n\n// Properties for recommendations\nexport interface RecommendationProperties {\n algorithm?: string;\n products: BaseProductProperties[];\n recommendation_type:\n | 'similar'\n | 'frequently_bought'\n | 'trending'\n | 'personalized'\n | 'upsell'\n | 'cross_sell';\n source: string; // e.g., 'product_page', 'cart', 'checkout'\n}\n\n// Properties for engagement events\nexport interface EngagementProperties {\n action_type: 'price_alert' | 'back_in_stock' | 'favorite';\n notification_method?: 'email' | 'sms' | 'push';\n product_id: string;\n threshold_price?: number;\n}\n\n// Properties for returns\nexport interface ReturnProperties {\n order_id: string;\n products: BaseProductProperties[];\n reason: string;\n refund_amount?: number;\n return_id?: string;\n return_method?: 'mail' | 'store' | 'pickup';\n}\n\n// Standard ecommerce event names\nexport const ECOMMERCE_EVENTS = {\n PRODUCT_CLICKED: 'Product Clicked',\n PRODUCT_COMPARED: 'Product Compared',\n PRODUCT_LIST_FILTERED: 'Product List Filtered',\n PRODUCT_LIST_VIEWED: 'Product List Viewed',\n PRODUCT_RECOMMENDATION_CLICKED: 'Product Recommendation Clicked',\n PRODUCT_RECOMMENDATION_VIEWED: 'Product Recommendation Viewed',\n // Search & Discovery events\n PRODUCT_SEARCHED: 'Product Searched',\n PRODUCT_VIEWED: 'Product Viewed',\n SEARCH_RESULTS_VIEWED: 'Search Results Viewed',\n\n CART_ABANDONED: 'Cart Abandoned',\n // Cart events\n CART_UPDATED: 'Cart Updated',\n CART_VIEWED: 'Cart Viewed',\n\n // Checkout events\n CHECKOUT_PROGRESSED: 'Checkout Progressed',\n\n ORDER_CANCELLED: 'Order Cancelled',\n // Order events\n ORDER_COMPLETED: 'Order Completed',\n ORDER_FAILED: 'Order Failed',\n ORDER_REFUNDED: 'Order Refunded',\n ORDER_STATUS_UPDATED: 'Order Status Updated',\n\n // Coupon events\n COUPON_APPLIED: 'Coupon Applied',\n COUPON_REMOVED: 'Coupon Removed',\n\n // Wishlist events\n PRODUCT_ADDED_TO_WISHLIST: 'Product Added to Wishlist',\n PRODUCT_REMOVED_FROM_WISHLIST: 'Product Removed from Wishlist',\n WISHLIST_PRODUCT_ADDED_TO_CART: 'Wishlist Product Added to Cart',\n\n CART_SHARED: 'Cart Shared',\n // Sharing events\n PRODUCT_SHARED: 'Product Shared',\n\n // Review events\n PRODUCT_REVIEWED: 'Product Reviewed',\n\n AFFILIATE_CONVERSION_TRACKED: 'Affiliate Conversion Tracked',\n AFFILIATE_LINK_CLICKED: 'Affiliate Link Clicked',\n // Marketplace-specific events\n MERCHANT_SELECTED: 'Merchant Selected',\n PRICE_COMPARISON_VIEWED: 'Price Comparison Viewed',\n\n REGISTRY_ITEM_MANAGED: 'Registry Item Managed',\n // Registry events\n REGISTRY_MANAGED: 'Registry Managed',\n REGISTRY_SHARED: 'Registry Shared',\n REGISTRY_VIEWED: 'Registry Viewed',\n\n RETURN_COMPLETED: 'Return Completed',\n // Post-purchase events\n RETURN_REQUESTED: 'Return Requested',\n\n BACK_IN_STOCK_REQUESTED: 'Back In Stock Requested',\n // Engagement events\n PRICE_ALERT_SET: 'Price Alert Set',\n} as const;\n\nexport type EcommerceEventName = (typeof ECOMMERCE_EVENTS)[keyof typeof ECOMMERCE_EVENTS];\n\n// Event specification interface\nexport interface EcommerceEventSpec<T = any> {\n category: 'ecommerce';\n name: EcommerceEventName;\n properties: T;\n requiredProperties: (keyof T)[];\n}\n\n// Union type for all ecommerce event properties\nexport type EcommerceEventProperties =\n | BaseProductProperties\n | ExtendedProductProperties\n | ProductListProperties\n | CartProperties\n | CheckoutProperties\n | OrderProperties\n | CouponProperties\n | WishlistProperties\n | (BaseProductProperties & SharingProperties)\n | (CartProperties & SharingProperties)\n | ReviewProperties;\n","/**\n * @fileoverview Utilities for normalizing and validating ecommerce event properties\n * Utilities for normalizing and validating ecommerce event properties\n */\n\nimport type { BaseProductProperties, EcommerceEventProperties } from './types';\n\n/**\n * Input product type for normalization functions\n * Accepts various property naming conventions\n */\ninterface ProductInput {\n // ID variations\n product_id?: string;\n productId?: string;\n id?: string;\n // Name variations\n name?: string;\n title?: string;\n productName?: string;\n // Image URL variations\n image_url?: string;\n imageUrl?: string;\n image?: string;\n // URL variations\n url?: string;\n link?: string;\n product_url?: string;\n // Other properties\n brand?: string;\n manufacturer?: string;\n category?: string;\n coupon?: string;\n couponCode?: string;\n coupon_code?: string;\n position?: number | string;\n price?: number | string;\n quantity?: number | string;\n variant?: string;\n variation?: string;\n [key: string]: unknown;\n}\n\n/**\n * Normalizes product properties to ensure consistent naming\n * Handles common variations like productId vs product_id\n */\nexport function normalizeProductProperties(\n product?: ProductInput | unknown,\n): BaseProductProperties {\n if (!product || typeof product !== 'object') {\n throw new Error('Product properties are required');\n }\n\n const p = product as ProductInput;\n\n // Normalize product ID (required) - using ES2022 nullish coalescing\n const product_id = p.product_id ?? p.productId ?? p.id;\n if (!product_id) {\n throw new Error('Product must have an id (product_id, productId, or id)');\n }\n\n const normalized = {\n product_id,\n name: p.name ?? p.title ?? p.productName,\n image_url: p.image_url ?? p.imageUrl ?? p.image,\n url: p.url ?? p.link ?? p.product_url,\n brand: p.brand ?? p.manufacturer,\n category: p.category,\n coupon: p.coupon ?? p.couponCode ?? p.coupon_code,\n position: normalizePosition(p.position),\n price: normalizePrice(p.price),\n quantity: normalizeQuantity(p.quantity),\n variant: p.variant ?? p.variation,\n };\n\n // Remove undefined and null values - using ES2022 Object.hasOwn\n const result: BaseProductProperties = { product_id };\n Object.entries(normalized).forEach(([key, value]) => {\n if (\n value !== undefined &&\n value !== null &&\n Object.hasOwn(normalized, key) &&\n key !== 'product_id'\n ) {\n // Cast to any to allow dynamic property assignment\n (result as any)[key] = value;\n }\n });\n\n return result;\n}\n\n/**\n * Normalizes an array of products\n */\nexport function normalizeProducts(products: unknown[]): BaseProductProperties[] {\n if (!Array.isArray(products)) {\n return [];\n }\n return products.map(product => normalizeProductProperties(product as ProductInput));\n}\n\n/**\n * ES2022 enhanced product validation with Error.cause\n */\nexport function validateProductWithContext(product: unknown, context?: string): void {\n try {\n normalizeProductProperties(product as ProductInput);\n } catch (error) {\n throw new Error(`Product validation failed${context ? ` in ${context}` : ''}`, {\n cause: error,\n });\n }\n}\n\n/**\n * Normalizes price to a number\n */\nfunction normalizePrice(price: unknown): number | undefined {\n if (price === undefined || price === null) {\n return undefined;\n }\n const normalized = typeof price === 'string' ? Number.parseFloat(price) : Number(price);\n return Number.isNaN(normalized) ? undefined : normalized;\n}\n\n/**\n * Normalizes quantity to a positive integer\n */\nfunction normalizeQuantity(quantity: unknown): number | undefined {\n if (quantity === undefined || quantity === null) {\n return undefined;\n }\n const normalized = Number.parseInt(String(quantity), 10);\n return Number.isNaN(normalized) || normalized < 0 ? undefined : normalized;\n}\n\n/**\n * Normalizes position to a positive integer\n */\nfunction normalizePosition(position: unknown): number | undefined {\n if (position === undefined || position === null) {\n return undefined;\n }\n const normalized = Number.parseInt(String(position), 10);\n return Number.isNaN(normalized) || normalized < 0 ? undefined : normalized;\n}\n\n/**\n * Validates required properties for an event\n */\nexport function validateRequiredProperties<T extends Record<string, any>>(\n properties: T,\n required: (keyof T)[],\n): void {\n const missing = required.filter(prop => {\n const value = properties[prop];\n return value === undefined || value === null || value === '';\n });\n if (missing.length > 0) {\n throw new Error(`Missing required properties: ${missing.join(', ')}`);\n }\n}\n\n/**\n * Removes undefined values from an object\n */\nexport function cleanProperties<T extends Record<string, any>>(obj: T): Partial<T> {\n const cleaned: Partial<T> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n cleaned[key as keyof T] = value;\n }\n }\n return cleaned;\n}\n\n/**\n * Merges common fields with event-specific properties\n */\nexport function mergeEventProperties(\n specific: EcommerceEventProperties,\n common?: Record<string, any>,\n): EcommerceEventProperties {\n return {\n ...common,\n ...specific,\n };\n}\n\n/**\n * Validates currency code (ISO 4217)\n */\nexport function validateCurrency(currency?: string): string | undefined {\n if (!currency || typeof currency !== 'string') return undefined;\n\n // Basic validation - should be 3 uppercase letters\n const normalized = currency.toUpperCase();\n if (!/^[A-Z]{3}$/.test(normalized)) {\n // Invalid currency code - return undefined\n return undefined;\n }\n\n return normalized;\n}\n\n/**\n * Creates a consistent context object for ecommerce events\n */\nexport function createEcommerceContext(additionalContext?: Record<string, any>) {\n return {\n ...additionalContext,\n category: 'ecommerce',\n };\n}\n","/**\n * @fileoverview Ecommerce tracking wrapper that integrates with the core emitter system\n * Ecommerce tracking wrapper that integrates with the core emitter system\n */\n\nimport { track } from '../emitters';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../emitter-types';\nimport type { EcommerceEventSpec } from './types';\n\n/**\n * Convert an ecommerce event specification to a track payload\n *\n * @param eventSpec - The ecommerce event specification\n * @param options - Optional emitter options\n * @returns Track payload ready to be sent to analytics providers\n */\nexport function trackEcommerce(\n eventSpec: EcommerceEventSpec,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n // Add ecommerce context to options\n const enrichedOptions: EmitterOptions = {\n ...options,\n context: {\n ...options?.context,\n // Add ecommerce-specific context if needed\n ...(eventSpec.category && {\n // Store category as a custom field since EmitterContext doesn't have category\n traits: {\n ...options?.context?.traits,\n event_category: eventSpec.category,\n },\n }),\n },\n };\n\n // Return the track payload with the event name and properties\n return track(eventSpec.name, eventSpec.properties, enrichedOptions);\n}\n\n/**\n * Helper to create a tracking function for a specific ecommerce event\n * This allows for cleaner usage in applications\n */\nexport function createEcommerceTracker<T extends Record<string, any>>(\n eventFactory: (properties: T) => EcommerceEventSpec,\n) {\n return (properties: T, options?: EmitterOptions): EmitterTrackPayload => {\n const eventSpec = eventFactory(properties);\n return trackEcommerce(eventSpec, options);\n };\n}\n","/**\n * @fileoverview Cart and checkout-related ecommerce events\n * Cart and checkout-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n type CartAbandonmentProperties,\n type CartProperties,\n type CartUpdateProperties,\n type CheckoutProgressProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track cart updates (add, remove, update) with a single event\n */\nexport function cartUpdated(\n properties: CartUpdateProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const { cart_id, action, cart_total, product, quantity_change } = properties;\n const normalizedProduct = normalizeProductProperties(product);\n\n validateRequiredProperties(properties, ['action']);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.CART_UPDATED,\n category: 'ecommerce',\n properties: cleanProperties({\n action,\n ...normalizedProduct,\n cart_id,\n cart_total,\n quantity_change,\n }),\n requiredProperties: ['action', 'product_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when a user views their shopping cart\n */\nexport function cartViewed(properties: CartProperties): EcommerceEventSpec<CartProperties> {\n const normalizedProps: CartProperties = {\n cart_id: properties.cart_id,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.CART_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a cart is abandoned\n */\nexport function cartAbandoned(properties: CartAbandonmentProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['cart_id', 'cart_value']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.CART_ABANDONED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['cart_id', 'cart_value'],\n };\n}\n\n/**\n * Track checkout progression with a single event\n */\nexport function checkoutProgressed(properties: CheckoutProgressProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['step', 'step_name', 'action']);\n\n const normalizedProps = {\n ...properties,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.CHECKOUT_PROGRESSED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['step', 'step_name', 'action'],\n };\n}\n","/**\n * @fileoverview Coupon-related ecommerce events\n * Coupon-related ecommerce events\n */\n\nimport { type CouponProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties } from '../utils';\n\n/**\n * Track when a coupon is successfully applied\n */\nexport function couponApplied(properties: CouponProperties): EcommerceEventSpec<CouponProperties> {\n const normalizedProps: CouponProperties = {\n cart_id: properties.cart_id,\n coupon_id: properties.coupon_id,\n order_id: properties.order_id,\n coupon_name: properties.coupon_name,\n discount: properties.discount,\n reason: properties.reason,\n };\n\n return {\n name: ECOMMERCE_EVENTS.COUPON_APPLIED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a coupon is removed\n */\nexport function couponRemoved(properties: CouponProperties): EcommerceEventSpec<CouponProperties> {\n const normalizedProps: CouponProperties = {\n cart_id: properties.cart_id,\n coupon_id: properties.coupon_id,\n order_id: properties.order_id,\n coupon_name: properties.coupon_name,\n discount: properties.discount,\n reason: properties.reason,\n };\n\n return {\n name: ECOMMERCE_EVENTS.COUPON_REMOVED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n","/**\n * @fileoverview Customer engagement events for ecommerce\n * Customer engagement events for ecommerce\n * Track user interactions that indicate interest but aren't direct purchases\n */\n\nimport { type BaseProductProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track when a user sets a price alert for a product\n */\nexport function priceAlertSet(\n properties: BaseProductProperties & {\n threshold_price: number;\n notification_method?: 'email' | 'sms' | 'push';\n currency?: string;\n },\n): EcommerceEventSpec {\n const { currency, notification_method, threshold_price, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n validateRequiredProperties({ threshold_price }, ['threshold_price']);\n\n return {\n name: ECOMMERCE_EVENTS.PRICE_ALERT_SET,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n action_type: 'price_alert',\n currency,\n notification_method,\n threshold_price,\n }),\n requiredProperties: ['product_id', 'threshold_price'],\n };\n}\n\n/**\n * Track when a user requests notification for out-of-stock items\n */\nexport function backInStockRequested(\n properties: BaseProductProperties & {\n notification_method?: 'email' | 'sms' | 'push';\n },\n): EcommerceEventSpec {\n const { notification_method, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.BACK_IN_STOCK_REQUESTED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n action_type: 'back_in_stock',\n notification_method,\n }),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Marketplace and affiliate-specific ecommerce events\n * Marketplace and affiliate-specific ecommerce events\n * These events track user interactions unique to marketplace/affiliate models\n */\n\nimport { type BaseProductProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track when a user views price comparisons across multiple merchants\n */\nexport function priceComparisonViewed(properties: {\n product_id: string;\n merchants: {\n merchant_id: string;\n merchant_name: string;\n price: number;\n shipping?: number;\n total_price?: number;\n availability?: string;\n rating?: number;\n }[];\n lowest_price?: number;\n highest_price?: number;\n average_price?: number;\n}): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id', 'merchants']);\n\n return {\n name: ECOMMERCE_EVENTS.PRICE_COMPARISON_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id', 'merchants'],\n };\n}\n\n/**\n * Track when a user selects a specific merchant from multiple options\n */\nexport function merchantSelected(\n properties: BaseProductProperties & {\n selected_merchant_id: string;\n selected_merchant_name: string;\n selection_reason?: 'lowest_price' | 'fastest_shipping' | 'best_rating' | 'in_stock' | 'other';\n compared_merchants?: string[];\n },\n): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(properties, ['product_id', 'selected_merchant_id']);\n\n return {\n name: ECOMMERCE_EVENTS.MERCHANT_SELECTED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProps,\n selected_merchant_id: properties.selected_merchant_id,\n selected_merchant_name: properties.selected_merchant_name,\n compared_merchants: properties.compared_merchants,\n selection_reason: properties.selection_reason,\n }),\n requiredProperties: ['product_id', 'selected_merchant_id'],\n };\n}\n\n/**\n * Track when a user clicks an affiliate link to visit merchant site\n */\nexport function affiliateLinkClicked(\n properties: BaseProductProperties & {\n destination_url: string;\n affiliate_network?: string;\n commission_rate?: number;\n tracking_code?: string;\n deep_link?: boolean;\n },\n): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(properties, ['product_id', 'destination_url']);\n\n return {\n name: ECOMMERCE_EVENTS.AFFILIATE_LINK_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProps,\n destination_url: properties.destination_url,\n deep_link: properties.deep_link,\n tracking_code: properties.tracking_code,\n }),\n requiredProperties: ['product_id', 'destination_url'],\n };\n}\n\n/**\n * Track when an affiliate conversion is confirmed\n * This is typically fired via webhook or after confirmation from affiliate network\n */\nexport function affiliateConversionTracked(properties: {\n product_id: string;\n order_id: string;\n merchant_id: string;\n merchant_name?: string;\n affiliate_network?: string;\n commission_amount?: number;\n commission_rate?: number;\n conversion_value?: number;\n currency?: string;\n conversion_type?: 'sale' | 'lead' | 'click' | 'other';\n tracking_code?: string;\n}): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id', 'order_id', 'merchant_id']);\n\n return {\n name: ECOMMERCE_EVENTS.AFFILIATE_CONVERSION_TRACKED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id', 'order_id', 'merchant_id'],\n };\n}\n","/**\n * @fileoverview Order-related ecommerce events\n * Order-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type OrderProperties,\n type OrderStatusProperties,\n type ReturnProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProducts,\n validateCurrency,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track when a user completes an order\n */\nexport function orderCompleted(\n properties: OrderProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.ORDER_COMPLETED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when an order fails (payment declined, validation error, etc.)\n */\nexport function orderFailed(\n properties: OrderProperties & {\n failure_reason?: string;\n error_code?: string;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const { error_code, failure_reason, ...orderProps } = properties;\n const normalizedProps = {\n order_id: orderProps.order_id,\n affiliation: orderProps.affiliation,\n coupon: orderProps.coupon,\n currency: validateCurrency(orderProps.currency),\n discount: orderProps.discount,\n error_code,\n failure_reason,\n products: orderProps.products ? normalizeProducts(orderProps.products) : undefined,\n revenue: orderProps.revenue,\n shipping: orderProps.shipping,\n tax: orderProps.tax,\n total: orderProps.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_FAILED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track when an order is refunded\n */\nexport function orderRefunded(properties: OrderProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_REFUNDED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track when an order is cancelled\n */\nexport function orderCancelled(properties: OrderProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_CANCELLED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track order status changes (shipping, delivery, etc.)\n */\nexport function orderStatusUpdated(properties: OrderStatusProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'status']);\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_STATUS_UPDATED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['order_id', 'status'],\n };\n}\n\n/**\n * Track when a return is requested\n */\nexport function returnRequested(properties: ReturnProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'reason']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.RETURN_REQUESTED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id', 'reason'],\n };\n}\n\n/**\n * Track when a return is completed\n */\nexport function returnCompleted(\n properties: ReturnProperties & {\n completion_date?: string;\n refund_status?: 'pending' | 'completed' | 'failed';\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'return_id']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.RETURN_COMPLETED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id', 'return_id'],\n };\n}\n","/**\n * @fileoverview Product-related ecommerce events\n * Product-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n type BaseProductProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type ProductComparisonProperties,\n type ProductListProperties,\n type RecommendationProperties,\n type SearchResultsProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track when a user searches for products\n */\nexport function productSearched(\n properties: { query: string },\n options?: EmitterOptions,\n): EmitterTrackPayload {\n validateRequiredProperties(properties, ['query']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.PRODUCT_SEARCHED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['query'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when search results are displayed\n */\nexport function searchResultsViewed(properties: SearchResultsProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['query', 'results_count']);\n\n const normalizedProps = {\n ...properties,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.SEARCH_RESULTS_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['query', 'results_count'],\n };\n}\n\n/**\n * Track when a user views a product list or category\n */\nexport function productListViewed(\n properties: ProductListProperties,\n): EcommerceEventSpec<ProductListProperties> {\n const normalizedProps: ProductListProperties = {\n list_id: properties.list_id,\n category: properties.category,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_LIST_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a user filters a product list\n */\nexport function productListFiltered(\n properties: ProductListProperties & { filters?: Record<string, any> },\n): EcommerceEventSpec {\n const normalizedProps = {\n list_id: properties.list_id,\n category: properties.category,\n filters: properties.filters,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_LIST_FILTERED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a user clicks on a product\n */\nexport function productClicked(properties: BaseProductProperties): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(normalizedProps, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a user views a product detail page\n */\nexport function productViewed(\n properties: BaseProductProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(normalizedProps, ['product_id']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.PRODUCT_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['product_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when a user compares products\n */\nexport function productCompared(properties: ProductComparisonProperties): EcommerceEventSpec {\n const { action, comparison_list, product } = properties;\n const normalizedProduct = normalizeProductProperties(product);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_COMPARED,\n category: 'ecommerce',\n properties: cleanProperties({\n action,\n ...normalizedProduct,\n comparison_list: comparison_list ? normalizeProducts(comparison_list) : undefined,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when product recommendations are viewed\n */\nexport function productRecommendationViewed(\n properties: RecommendationProperties,\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['recommendation_type', 'source']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['recommendation_type', 'source'],\n };\n}\n\n/**\n * Track when a recommended product is clicked\n */\nexport function productRecommendationClicked(\n properties: BaseProductProperties & {\n recommendation_type: string;\n source: string;\n position?: number;\n },\n): EcommerceEventSpec {\n const { recommendation_type, position, source, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n recommendation_type,\n position,\n source,\n }),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Universal registry events for gift registries, wishlists, and similar features\n * Universal registry events for gift registries, wishlists, and similar features\n * Uses action-based patterns for efficient tracking\n */\n\nimport {\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type RegistryItemProperties,\n type RegistryProperties,\n} from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track registry management actions (create, update, delete)\n */\nexport function registryManaged(\n properties: RegistryProperties & {\n action: 'created' | 'updated' | 'deleted';\n updated_fields?: string[];\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id', 'action']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_MANAGED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id', 'action'],\n };\n}\n\n/**\n * Track when someone views a registry\n */\nexport function registryViewed(\n properties: RegistryProperties & {\n viewer_id?: string;\n viewer_relationship?: 'owner' | 'co_owner' | 'friend' | 'family' | 'other';\n items_count?: number;\n items_fulfilled?: number;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id'],\n };\n}\n\n/**\n * Track when a registry is shared\n */\nexport function registryShared(\n properties: RegistryProperties & {\n share_method: 'email' | 'social' | 'link' | 'qr_code' | 'other';\n recipients_count?: number;\n message?: string;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id', 'share_method']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_SHARED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id', 'share_method'],\n };\n}\n\n/**\n * Track registry item management (add, remove, update, purchase)\n */\nexport function registryItemManaged(\n properties: RegistryItemProperties & {\n action: 'added' | 'removed' | 'updated' | 'purchased';\n purchaser_id?: string;\n purchaser_name?: string;\n purchase_quantity?: number;\n purchase_message?: string;\n gift_wrap?: boolean;\n anonymous_gift?: boolean;\n updated_fields?: string[];\n },\n): EcommerceEventSpec {\n const {\n purchaser_id,\n registry_id,\n purchaser_name,\n action,\n anonymous_gift,\n gift_wrap,\n purchase_message,\n purchase_quantity,\n updated_fields,\n ...productProps\n } = properties;\n\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(properties, ['registry_id', 'product_id', 'action']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_ITEM_MANAGED,\n category: 'ecommerce',\n properties: cleanProperties({\n purchaser_id,\n registry_id,\n purchaser_name,\n action,\n anonymous_gift,\n gift_wrap,\n purchase_message,\n purchase_quantity,\n updated_fields,\n ...normalizedProduct,\n }),\n requiredProperties: ['registry_id', 'product_id', 'action'],\n };\n}\n","/**\n * @fileoverview Wishlist, sharing, and review-related ecommerce events\n * Wishlist, sharing, and review-related ecommerce events\n */\n\nimport {\n type BaseProductProperties,\n type CartProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type ReviewProperties,\n type SharingProperties,\n type WishlistProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\n/**\n * Track when a product is added to wishlist\n */\nexport function productAddedToWishlist(properties: WishlistProperties): EcommerceEventSpec {\n const { wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_ADDED_TO_WISHLIST,\n category: 'ecommerce',\n properties: cleanProperties({\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a product is removed from wishlist\n */\nexport function productRemovedFromWishlist(properties: WishlistProperties): EcommerceEventSpec {\n const { wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_REMOVED_FROM_WISHLIST,\n category: 'ecommerce',\n properties: cleanProperties({\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a wishlist product is added to cart\n */\nexport function wishlistProductAddedToCart(\n properties: WishlistProperties & { cart_id?: string },\n): EcommerceEventSpec {\n const { cart_id, wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.WISHLIST_PRODUCT_ADDED_TO_CART,\n category: 'ecommerce',\n properties: cleanProperties({\n cart_id,\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a product is shared\n */\nexport function productShared(\n properties: BaseProductProperties & SharingProperties,\n): EcommerceEventSpec {\n const { recipient, share_message, share_via, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_SHARED,\n category: 'ecommerce',\n properties: cleanProperties({\n recipient,\n share_message,\n share_via,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a cart is shared\n */\nexport function cartShared(properties: CartProperties & SharingProperties): EcommerceEventSpec {\n const { cart_id, products, recipient, share_message, share_via } = properties;\n\n return {\n name: ECOMMERCE_EVENTS.CART_SHARED,\n category: 'ecommerce',\n properties: cleanProperties({\n cart_id,\n products: products ? normalizeProducts(products) : undefined,\n recipient,\n share_message,\n share_via,\n }),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a product is reviewed\n */\nexport function productReviewed(properties: ReviewProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_REVIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Platform-standard ecommerce events\n *\n * This module provides comprehensive ecommerce event tracking following industry\n * best practices (Segment.io ecommerce spec, Google Analytics Enhanced Ecommerce).\n *\n * **Event Categories**:\n * - **Cart & Checkout**: Add to cart, remove from cart, checkout started, checkout completed\n * - **Orders**: Order placed, order updated, order refunded, order cancelled\n * - **Products**: Product viewed, product added, product removed, product shared\n * - **Coupons**: Coupon applied, coupon removed, coupon viewed\n * - **Engagement**: Product list viewed, product list filtered, product searched\n * - **Marketplace**: Seller viewed, seller contacted, review submitted\n * - **Registry**: Registry created, registry item added, registry shared\n * - **Wishlist**: Wishlist item added, wishlist item removed, wishlist shared\n *\n * **Usage**: Import event functions and use with `analytics.emit()`:\n * ```typescript\n * import { ecommerce } from '@od-oneapp/analytics/shared';\n * await analytics.emit(ecommerce.productViewed({ productId: 'prod-123' }));\n * ```\n *\n * @module @od-oneapp/analytics/shared/emitters/ecommerce\n */\n\n// Export all types\nexport * from './types';\n\n// Export utilities\nexport * from './utils';\n\n// Export all event functions\nexport * from './events/cart-checkout';\nexport * from './events/coupon';\nexport * from './events/engagement';\nexport * from './events/marketplace';\nexport * from './events/order';\nexport * from './events/product';\nexport * from './events/registry';\nexport * from './events/wishlist-sharing';\n\n// Export tracking functionality\nexport * from './track-ecommerce';\n\n// Re-export commonly used constants for convenience\nexport { ECOMMERCE_EVENTS } from './types';\n"],"mappings":";;;;AAmOA,MAAa,mBAAmB;CAC9B,iBAAiB;CACjB,kBAAkB;CAClB,uBAAuB;CACvB,qBAAqB;CACrB,gCAAgC;CAChC,+BAA+B;CAE/B,kBAAkB;CAClB,gBAAgB;CAChB,uBAAuB;CAEvB,gBAAgB;CAEhB,cAAc;CACd,aAAa;CAGb,qBAAqB;CAErB,iBAAiB;CAEjB,iBAAiB;CACjB,cAAc;CACd,gBAAgB;CAChB,sBAAsB;CAGtB,gBAAgB;CAChB,gBAAgB;CAGhB,2BAA2B;CAC3B,+BAA+B;CAC/B,gCAAgC;CAEhC,aAAa;CAEb,gBAAgB;CAGhB,kBAAkB;CAElB,8BAA8B;CAC9B,wBAAwB;CAExB,mBAAmB;CACnB,yBAAyB;CAEzB,uBAAuB;CAEvB,kBAAkB;CAClB,iBAAiB;CACjB,iBAAiB;CAEjB,kBAAkB;CAElB,kBAAkB;CAElB,yBAAyB;CAEzB,iBAAiB;CAClB;;;;;;;;AClPD,SAAgB,2BACd,SACuB;AACvB,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,kCAAkC;CAGpD,MAAM,IAAI;CAGV,MAAM,aAAa,EAAE,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;EACnC;;;;;AAMH,SAAgB,2BACd,YACoB;CACpB,MAAM,EAAE,SAAS,aAAa,eAAe,GAAG,iBAAiB;CACjE,MAAM,oBAAoB,2BAA2B,aAAa;AAClE,4BAA2B,mBAAmB,CAAC,aAAa,CAAC;AAE7D,QAAO;EACL,MAAM,iBAAiB;EACvB,UAAU;EACV,YAAY,gBAAgB;GAC1B;GACA;GACA;GACA,GAAG;GACJ,CAAC;EACF,oBAAoB,CAAC,aAAa;EACnC;;;;;AAMH,SAAgB,cACd,YACoB;CACpB,MAAM,EAAE,WAAW,eAAe,WAAW,GAAG,iBAAiB;CACjE,MAAM,oBAAoB,2BAA2B,aAAa;AAClE,4BAA2B,mBAAmB,CAAC,aAAa,CAAC;AAE7D,QAAO;EACL,MAAM,iBAAiB;EACvB,UAAU;EACV,YAAY,gBAAgB;GAC1B;GACA;GACA;GACA,GAAG;GACJ,CAAC;EACF,oBAAoB,CAAC,aAAa;EACnC;;;;;AAMH,SAAgB,WAAW,YAAoE;CAC7F,MAAM,EAAE,SAAS,UAAU,WAAW,eAAe,cAAc;AAEnE,QAAO;EACL,MAAM,iBAAiB;EACvB,UAAU;EACV,YAAY,gBAAgB;GAC1B;GACA,UAAU,WAAW,kBAAkB,SAAS,GAAG;GACnD;GACA;GACA;GACD,CAAC;EACF,oBAAoB,EAAE;EACvB;;;;;AAMH,SAAgB,gBAAgB,YAAkD;AAChF,4BAA2B,YAAY,CAAC,aAAa,CAAC;AAEtD,QAAO;EACL,MAAM,iBAAiB;EACvB,UAAU;EACV,YAAY,gBAAgB,WAAW;EACvC,oBAAoB,CAAC,aAAa;EACnC"}
1
+ {"version":3,"file":"ecommerce-Cgu4wlux.mjs","names":[],"sources":["../src/shared/emitters/ecommerce/types.ts","../src/shared/emitters/ecommerce/utils.ts","../src/shared/emitters/ecommerce/track-ecommerce.ts","../src/shared/emitters/ecommerce/events/cart-checkout.ts","../src/shared/emitters/ecommerce/events/coupon.ts","../src/shared/emitters/ecommerce/events/engagement.ts","../src/shared/emitters/ecommerce/events/marketplace.ts","../src/shared/emitters/ecommerce/events/order.ts","../src/shared/emitters/ecommerce/events/product.ts","../src/shared/emitters/ecommerce/events/registry.ts","../src/shared/emitters/ecommerce/events/wishlist-sharing.ts","../src/shared/emitters/ecommerce/index.ts"],"sourcesContent":["/**\n * @fileoverview Platform-standard ecommerce event types\n * Platform-standard ecommerce event types\n * Based on industry best practices for ecommerce tracking\n */\n\n// Base product properties shared across events\nexport interface BaseProductProperties {\n affiliate_link?: string | undefined;\n affiliate_network?: string | undefined;\n availability?: 'in_stock' | 'out_of_stock' | 'preorder' | 'discontinued' | undefined;\n brand?: string | undefined;\n category?: string | undefined;\n commission_amount?: number | undefined;\n commission_rate?: number | undefined;\n condition?: 'new' | 'used' | 'refurbished' | undefined;\n coupon?: string | undefined;\n gtin?: string | undefined;\n image_url?: string | undefined;\n // Marketplace/affiliate properties (optional for any product)\n merchant_id?: string | undefined;\n merchant_name?: string | undefined;\n merchant_url?: string | undefined;\n mpn?: string | undefined;\n name?: string | undefined;\n original_price?: number | undefined;\n position?: number | undefined;\n price?: number | undefined;\n product_id: string;\n quantity?: number | undefined;\n sale_price?: number | undefined;\n url?: string | undefined;\n variant?: string | undefined;\n}\n\n// Extended product properties for detailed tracking\nexport interface ExtendedProductProperties extends BaseProductProperties {\n currency?: string | undefined;\n value?: number | undefined;\n}\n\n// Registry-specific properties\nexport interface RegistryProperties {\n co_registrant_id?: string | undefined;\n co_registrant_name?: string | undefined;\n event_date?: string | undefined;\n privacy_setting?: 'public' | 'private' | 'unlisted' | undefined;\n registry_id: string;\n registry_name?: string | undefined;\n registry_type?: 'wedding' | 'baby' | 'birthday' | 'universal' | 'custom' | undefined;\n registry_url?: string | undefined;\n}\n\n// Registry item properties\nexport interface RegistryItemProperties extends BaseProductProperties {\n merchant_id?: string | undefined;\n merchant_name?: string | undefined;\n notes?: string | undefined;\n priority?: 'high' | 'medium' | 'low' | undefined;\n purchased_quantity?: number | undefined;\n registry_id: string;\n requested_quantity?: number | undefined;\n}\n\n// Properties for product list events\nexport interface ProductListProperties {\n category?: string | undefined;\n list_id?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n}\n\n// Properties for cart events\nexport interface CartProperties {\n cart_id?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n}\n\n// Properties for checkout events\nexport interface CheckoutProperties {\n checkout_id?: string | undefined;\n payment_method?: string | undefined;\n products?: BaseProductProperties[] | undefined;\n shipping_method?: string | undefined;\n step?: number | undefined;\n}\n\n// Properties for order events\nexport interface OrderProperties {\n affiliation?: string | undefined;\n coupon?: string | undefined;\n currency?: string | undefined;\n discount?: number | undefined;\n order_id: string;\n products?: BaseProductProperties[] | undefined;\n revenue?: number | undefined;\n shipping?: number | undefined;\n tax?: number | undefined;\n total?: number | undefined;\n}\n\n// Properties for coupon events\nexport interface CouponProperties {\n cart_id?: string | undefined;\n coupon_id?: string | undefined;\n coupon_name?: string | undefined;\n discount?: number | undefined;\n order_id?: string | undefined;\n reason?: string | undefined;\n}\n\n// Properties for wishlist events\nexport interface WishlistProperties extends BaseProductProperties {\n wishlist_id?: string | undefined;\n wishlist_name?: string | undefined;\n}\n\n// Properties for sharing events\nexport interface SharingProperties {\n recipient?: string | undefined;\n share_message?: string | undefined;\n share_via?: string | undefined;\n}\n\n// Properties for review events\nexport interface ReviewProperties {\n product_id: string;\n rating?: string | undefined;\n review_body?: string | undefined;\n review_id?: string | undefined;\n}\n\n// Properties for search results\nexport interface SearchResultsProperties {\n filters_applied?: Record<string, any>;\n products?: BaseProductProperties[];\n query: string;\n results_count: number;\n sort_order?: string;\n}\n\n// Properties for cart updates\nexport interface CartUpdateProperties {\n action: 'added' | 'removed' | 'updated';\n cart_id?: string;\n cart_total?: number;\n product: BaseProductProperties;\n quantity_change?: number;\n}\n\n// Properties for cart abandonment\nexport interface CartAbandonmentProperties {\n abandonment_reason?: 'timeout' | 'navigation' | 'closed';\n cart_id: string;\n cart_value: number;\n products: BaseProductProperties[];\n time_in_cart?: number;\n}\n\n// Properties for checkout progression\nexport interface CheckoutProgressProperties {\n action: 'viewed' | 'completed' | 'abandoned' | 'error';\n checkout_id?: string;\n error_message?: string;\n payment_method?: string;\n products?: BaseProductProperties[];\n shipping_method?: string;\n step: number;\n step_name: string;\n}\n\n// Properties for order status updates\nexport interface OrderStatusProperties {\n carrier?: string;\n estimated_delivery?: string;\n order_id: string;\n previous_status?: string;\n status:\n | 'confirmed'\n | 'processing'\n | 'shipped'\n | 'out_for_delivery'\n | 'delivered'\n | 'returned'\n | 'failed';\n tracking_number?: string;\n}\n\n// Properties for product comparison\nexport interface ProductComparisonProperties {\n action: 'added' | 'removed' | 'viewed';\n comparison_list?: BaseProductProperties[];\n product: BaseProductProperties;\n}\n\n// Properties for recommendations\nexport interface RecommendationProperties {\n algorithm?: string;\n products: BaseProductProperties[];\n recommendation_type:\n | 'similar'\n | 'frequently_bought'\n | 'trending'\n | 'personalized'\n | 'upsell'\n | 'cross_sell';\n source: string; // e.g., 'product_page', 'cart', 'checkout'\n}\n\n// Properties for engagement events\nexport interface EngagementProperties {\n action_type: 'price_alert' | 'back_in_stock' | 'favorite';\n notification_method?: 'email' | 'sms' | 'push';\n product_id: string;\n threshold_price?: number;\n}\n\n// Properties for returns\nexport interface ReturnProperties {\n order_id: string;\n products: BaseProductProperties[];\n reason: string;\n refund_amount?: number;\n return_id?: string;\n return_method?: 'mail' | 'store' | 'pickup';\n}\n\n// Standard ecommerce event names\nexport const ECOMMERCE_EVENTS = {\n PRODUCT_CLICKED: 'Product Clicked',\n PRODUCT_COMPARED: 'Product Compared',\n PRODUCT_LIST_FILTERED: 'Product List Filtered',\n PRODUCT_LIST_VIEWED: 'Product List Viewed',\n PRODUCT_RECOMMENDATION_CLICKED: 'Product Recommendation Clicked',\n PRODUCT_RECOMMENDATION_VIEWED: 'Product Recommendation Viewed',\n // Search & Discovery events\n PRODUCT_SEARCHED: 'Product Searched',\n PRODUCT_VIEWED: 'Product Viewed',\n SEARCH_RESULTS_VIEWED: 'Search Results Viewed',\n\n CART_ABANDONED: 'Cart Abandoned',\n // Cart events\n CART_UPDATED: 'Cart Updated',\n CART_VIEWED: 'Cart Viewed',\n\n // Checkout events\n CHECKOUT_PROGRESSED: 'Checkout Progressed',\n\n ORDER_CANCELLED: 'Order Cancelled',\n // Order events\n ORDER_COMPLETED: 'Order Completed',\n ORDER_FAILED: 'Order Failed',\n ORDER_REFUNDED: 'Order Refunded',\n ORDER_STATUS_UPDATED: 'Order Status Updated',\n\n // Coupon events\n COUPON_APPLIED: 'Coupon Applied',\n COUPON_REMOVED: 'Coupon Removed',\n\n // Wishlist events\n PRODUCT_ADDED_TO_WISHLIST: 'Product Added to Wishlist',\n PRODUCT_REMOVED_FROM_WISHLIST: 'Product Removed from Wishlist',\n WISHLIST_PRODUCT_ADDED_TO_CART: 'Wishlist Product Added to Cart',\n\n CART_SHARED: 'Cart Shared',\n // Sharing events\n PRODUCT_SHARED: 'Product Shared',\n\n // Review events\n PRODUCT_REVIEWED: 'Product Reviewed',\n\n AFFILIATE_CONVERSION_TRACKED: 'Affiliate Conversion Tracked',\n AFFILIATE_LINK_CLICKED: 'Affiliate Link Clicked',\n // Marketplace-specific events\n MERCHANT_SELECTED: 'Merchant Selected',\n PRICE_COMPARISON_VIEWED: 'Price Comparison Viewed',\n\n REGISTRY_ITEM_MANAGED: 'Registry Item Managed',\n // Registry events\n REGISTRY_MANAGED: 'Registry Managed',\n REGISTRY_SHARED: 'Registry Shared',\n REGISTRY_VIEWED: 'Registry Viewed',\n\n RETURN_COMPLETED: 'Return Completed',\n // Post-purchase events\n RETURN_REQUESTED: 'Return Requested',\n\n BACK_IN_STOCK_REQUESTED: 'Back In Stock Requested',\n // Engagement events\n PRICE_ALERT_SET: 'Price Alert Set',\n} as const;\n\nexport type EcommerceEventName = (typeof ECOMMERCE_EVENTS)[keyof typeof ECOMMERCE_EVENTS];\n\n// Event specification interface\nexport interface EcommerceEventSpec<T = any> {\n category: 'ecommerce';\n name: EcommerceEventName;\n properties: T;\n requiredProperties: (keyof T)[];\n}\n\n// Union type for all ecommerce event properties\nexport type EcommerceEventProperties =\n | BaseProductProperties\n | ExtendedProductProperties\n | ProductListProperties\n | CartProperties\n | CheckoutProperties\n | OrderProperties\n | CouponProperties\n | WishlistProperties\n | (BaseProductProperties & SharingProperties)\n | (CartProperties & SharingProperties)\n | ReviewProperties;\n","/**\n * @fileoverview Utilities for normalizing and validating ecommerce event properties\n * Utilities for normalizing and validating ecommerce event properties\n */\n\nimport type { BaseProductProperties, EcommerceEventProperties } from './types';\n\n/**\n * Input product type for normalization functions\n * Accepts various property naming conventions\n */\ninterface ProductInput {\n // ID variations\n product_id?: string;\n productId?: string;\n id?: string;\n // Name variations\n name?: string;\n title?: string;\n productName?: string;\n // Image URL variations\n image_url?: string;\n imageUrl?: string;\n image?: string;\n // URL variations\n url?: string;\n link?: string;\n product_url?: string;\n // Other properties\n brand?: string;\n manufacturer?: string;\n category?: string;\n coupon?: string;\n couponCode?: string;\n coupon_code?: string;\n position?: number | string;\n price?: number | string;\n quantity?: number | string;\n variant?: string;\n variation?: string;\n [key: string]: unknown;\n}\n\n/**\n * Normalizes product properties to ensure consistent naming\n * Handles common variations like productId vs product_id\n */\nexport function normalizeProductProperties(\n product?: ProductInput | unknown,\n): BaseProductProperties {\n if (!product || typeof product !== 'object') {\n throw new Error('Product properties are required');\n }\n\n const p = product as ProductInput;\n\n // Normalize product ID (required) - using ES2022 nullish coalescing\n const product_id = p.product_id ?? p.productId ?? p.id;\n if (!product_id) {\n throw new Error('Product must have an id (product_id, productId, or id)');\n }\n\n const normalized = {\n product_id,\n name: p.name ?? p.title ?? p.productName,\n image_url: p.image_url ?? p.imageUrl ?? p.image,\n url: p.url ?? p.link ?? p.product_url,\n brand: p.brand ?? p.manufacturer,\n category: p.category,\n coupon: p.coupon ?? p.couponCode ?? p.coupon_code,\n position: normalizePosition(p.position),\n price: normalizePrice(p.price),\n quantity: normalizeQuantity(p.quantity),\n variant: p.variant ?? p.variation,\n };\n\n // Remove undefined and null values - using ES2022 Object.hasOwn\n const result: BaseProductProperties = { product_id };\n Object.entries(normalized).forEach(([key, value]) => {\n if (\n value !== undefined &&\n value !== null &&\n Object.hasOwn(normalized, key) &&\n key !== 'product_id'\n ) {\n // Cast to any to allow dynamic property assignment\n (result as any)[key] = value;\n }\n });\n\n return result;\n}\n\n/**\n * Normalizes an array of products\n */\nexport function normalizeProducts(products: unknown[]): BaseProductProperties[] {\n if (!Array.isArray(products)) {\n return [];\n }\n return products.map(product => normalizeProductProperties(product as ProductInput));\n}\n\n/**\n * ES2022 enhanced product validation with Error.cause\n */\nexport function validateProductWithContext(product: unknown, context?: string): void {\n try {\n normalizeProductProperties(product as ProductInput);\n } catch (error) {\n throw new Error(`Product validation failed${context ? ` in ${context}` : ''}`, {\n cause: error,\n });\n }\n}\n\n/**\n * Normalizes price to a number\n */\nfunction normalizePrice(price: unknown): number | undefined {\n if (price === undefined || price === null) {\n return undefined;\n }\n const normalized = typeof price === 'string' ? Number.parseFloat(price) : Number(price);\n return Number.isNaN(normalized) ? undefined : normalized;\n}\n\n/**\n * Normalizes quantity to a positive integer\n */\nfunction normalizeQuantity(quantity: unknown): number | undefined {\n if (quantity === undefined || quantity === null) {\n return undefined;\n }\n const normalized = Number.parseInt(String(quantity), 10);\n return Number.isNaN(normalized) || normalized < 0 ? undefined : normalized;\n}\n\n/**\n * Normalizes position to a positive integer\n */\nfunction normalizePosition(position: unknown): number | undefined {\n if (position === undefined || position === null) {\n return undefined;\n }\n const normalized = Number.parseInt(String(position), 10);\n return Number.isNaN(normalized) || normalized < 0 ? undefined : normalized;\n}\n\n/**\n * Validates required properties for an event\n */\nexport function validateRequiredProperties<T extends Record<string, any>>(\n properties: T,\n required: (keyof T)[],\n): void {\n const missing = required.filter(prop => {\n const value = properties[prop];\n return value === undefined || value === null || value === '';\n });\n if (missing.length > 0) {\n throw new Error(`Missing required properties: ${missing.join(', ')}`);\n }\n}\n\n/**\n * Removes undefined values from an object\n */\nexport function cleanProperties<T extends Record<string, any>>(obj: T): Partial<T> {\n const cleaned: Partial<T> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n cleaned[key as keyof T] = value;\n }\n }\n return cleaned;\n}\n\n/**\n * Merges common fields with event-specific properties\n */\nexport function mergeEventProperties(\n specific: EcommerceEventProperties,\n common?: Record<string, any>,\n): EcommerceEventProperties {\n return {\n ...common,\n ...specific,\n };\n}\n\n/**\n * Validates currency code (ISO 4217)\n */\nexport function validateCurrency(currency?: string): string | undefined {\n if (!currency || typeof currency !== 'string') return undefined;\n\n // Basic validation - should be 3 uppercase letters\n const normalized = currency.toUpperCase();\n if (!/^[A-Z]{3}$/.test(normalized)) {\n // Invalid currency code - return undefined\n return undefined;\n }\n\n return normalized;\n}\n\n/**\n * Creates a consistent context object for ecommerce events\n */\nexport function createEcommerceContext(additionalContext?: Record<string, any>) {\n return {\n ...additionalContext,\n category: 'ecommerce',\n };\n}\n","/**\n * @fileoverview Ecommerce tracking wrapper that integrates with the core emitter system\n * Ecommerce tracking wrapper that integrates with the core emitter system\n */\n\nimport { track } from '../emitters';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../emitter-types';\nimport type { EcommerceEventSpec } from './types';\n\n/**\n * Convert an ecommerce event specification to a track payload\n *\n * @param eventSpec - The ecommerce event specification\n * @param options - Optional emitter options\n * @returns Track payload ready to be sent to analytics providers\n */\nexport function trackEcommerce(\n eventSpec: EcommerceEventSpec,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n // Add ecommerce context to options\n const enrichedOptions: EmitterOptions = {\n ...options,\n context: {\n ...options?.context,\n // Add ecommerce-specific context if needed\n ...(eventSpec.category && {\n // Store category as a custom field since EmitterContext doesn't have category\n traits: {\n ...options?.context?.traits,\n event_category: eventSpec.category,\n },\n }),\n },\n };\n\n // Return the track payload with the event name and properties\n return track(eventSpec.name, eventSpec.properties, enrichedOptions);\n}\n\n/**\n * Helper to create a tracking function for a specific ecommerce event\n * This allows for cleaner usage in applications\n */\nexport function createEcommerceTracker<T extends Record<string, any>>(\n eventFactory: (properties: T) => EcommerceEventSpec,\n) {\n return (properties: T, options?: EmitterOptions): EmitterTrackPayload => {\n const eventSpec = eventFactory(properties);\n return trackEcommerce(eventSpec, options);\n };\n}\n","/**\n * @fileoverview Cart and checkout-related ecommerce events\n * Cart and checkout-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n type CartAbandonmentProperties,\n type CartProperties,\n type CartUpdateProperties,\n type CheckoutProgressProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track cart updates (add, remove, update) with a single event\n */\nexport function cartUpdated(\n properties: CartUpdateProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const { cart_id, action, cart_total, product, quantity_change } = properties;\n const normalizedProduct = normalizeProductProperties(product);\n\n validateRequiredProperties(properties, ['action']);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.CART_UPDATED,\n category: 'ecommerce',\n properties: cleanProperties({\n action,\n ...normalizedProduct,\n cart_id,\n cart_total,\n quantity_change,\n }),\n requiredProperties: ['action', 'product_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when a user views their shopping cart\n */\nexport function cartViewed(properties: CartProperties): EcommerceEventSpec<CartProperties> {\n const normalizedProps: CartProperties = {\n cart_id: properties.cart_id,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.CART_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a cart is abandoned\n */\nexport function cartAbandoned(properties: CartAbandonmentProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['cart_id', 'cart_value']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.CART_ABANDONED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['cart_id', 'cart_value'],\n };\n}\n\n/**\n * Track checkout progression with a single event\n */\nexport function checkoutProgressed(properties: CheckoutProgressProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['step', 'step_name', 'action']);\n\n const normalizedProps = {\n ...properties,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.CHECKOUT_PROGRESSED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['step', 'step_name', 'action'],\n };\n}\n","/**\n * @fileoverview Coupon-related ecommerce events\n * Coupon-related ecommerce events\n */\n\nimport { type CouponProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties } from '../utils';\n\n/**\n * Track when a coupon is successfully applied\n */\nexport function couponApplied(properties: CouponProperties): EcommerceEventSpec<CouponProperties> {\n const normalizedProps: CouponProperties = {\n cart_id: properties.cart_id,\n coupon_id: properties.coupon_id,\n order_id: properties.order_id,\n coupon_name: properties.coupon_name,\n discount: properties.discount,\n reason: properties.reason,\n };\n\n return {\n name: ECOMMERCE_EVENTS.COUPON_APPLIED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a coupon is removed\n */\nexport function couponRemoved(properties: CouponProperties): EcommerceEventSpec<CouponProperties> {\n const normalizedProps: CouponProperties = {\n cart_id: properties.cart_id,\n coupon_id: properties.coupon_id,\n order_id: properties.order_id,\n coupon_name: properties.coupon_name,\n discount: properties.discount,\n reason: properties.reason,\n };\n\n return {\n name: ECOMMERCE_EVENTS.COUPON_REMOVED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n","/**\n * @fileoverview Customer engagement events for ecommerce\n * Customer engagement events for ecommerce\n * Track user interactions that indicate interest but aren't direct purchases\n */\n\nimport { type BaseProductProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track when a user sets a price alert for a product\n */\nexport function priceAlertSet(\n properties: BaseProductProperties & {\n threshold_price: number;\n notification_method?: 'email' | 'sms' | 'push';\n currency?: string;\n },\n): EcommerceEventSpec {\n const { currency, notification_method, threshold_price, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n validateRequiredProperties({ threshold_price }, ['threshold_price']);\n\n return {\n name: ECOMMERCE_EVENTS.PRICE_ALERT_SET,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n action_type: 'price_alert',\n currency,\n notification_method,\n threshold_price,\n }),\n requiredProperties: ['product_id', 'threshold_price'],\n };\n}\n\n/**\n * Track when a user requests notification for out-of-stock items\n */\nexport function backInStockRequested(\n properties: BaseProductProperties & {\n notification_method?: 'email' | 'sms' | 'push';\n },\n): EcommerceEventSpec {\n const { notification_method, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.BACK_IN_STOCK_REQUESTED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n action_type: 'back_in_stock',\n notification_method,\n }),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Marketplace and affiliate-specific ecommerce events\n * Marketplace and affiliate-specific ecommerce events\n * These events track user interactions unique to marketplace/affiliate models\n */\n\nimport { type BaseProductProperties, ECOMMERCE_EVENTS, type EcommerceEventSpec } from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track when a user views price comparisons across multiple merchants\n */\nexport function priceComparisonViewed(properties: {\n product_id: string;\n merchants: {\n merchant_id: string;\n merchant_name: string;\n price: number;\n shipping?: number;\n total_price?: number;\n availability?: string;\n rating?: number;\n }[];\n lowest_price?: number;\n highest_price?: number;\n average_price?: number;\n}): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id', 'merchants']);\n\n return {\n name: ECOMMERCE_EVENTS.PRICE_COMPARISON_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id', 'merchants'],\n };\n}\n\n/**\n * Track when a user selects a specific merchant from multiple options\n */\nexport function merchantSelected(\n properties: BaseProductProperties & {\n selected_merchant_id: string;\n selected_merchant_name: string;\n selection_reason?: 'lowest_price' | 'fastest_shipping' | 'best_rating' | 'in_stock' | 'other';\n compared_merchants?: string[];\n },\n): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(properties, ['product_id', 'selected_merchant_id']);\n\n return {\n name: ECOMMERCE_EVENTS.MERCHANT_SELECTED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProps,\n selected_merchant_id: properties.selected_merchant_id,\n selected_merchant_name: properties.selected_merchant_name,\n compared_merchants: properties.compared_merchants,\n selection_reason: properties.selection_reason,\n }),\n requiredProperties: ['product_id', 'selected_merchant_id'],\n };\n}\n\n/**\n * Track when a user clicks an affiliate link to visit merchant site\n */\nexport function affiliateLinkClicked(\n properties: BaseProductProperties & {\n destination_url: string;\n affiliate_network?: string;\n commission_rate?: number;\n tracking_code?: string;\n deep_link?: boolean;\n },\n): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(properties, ['product_id', 'destination_url']);\n\n return {\n name: ECOMMERCE_EVENTS.AFFILIATE_LINK_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProps,\n destination_url: properties.destination_url,\n deep_link: properties.deep_link,\n tracking_code: properties.tracking_code,\n }),\n requiredProperties: ['product_id', 'destination_url'],\n };\n}\n\n/**\n * Track when an affiliate conversion is confirmed\n * This is typically fired via webhook or after confirmation from affiliate network\n */\nexport function affiliateConversionTracked(properties: {\n product_id: string;\n order_id: string;\n merchant_id: string;\n merchant_name?: string;\n affiliate_network?: string;\n commission_amount?: number;\n commission_rate?: number;\n conversion_value?: number;\n currency?: string;\n conversion_type?: 'sale' | 'lead' | 'click' | 'other';\n tracking_code?: string;\n}): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id', 'order_id', 'merchant_id']);\n\n return {\n name: ECOMMERCE_EVENTS.AFFILIATE_CONVERSION_TRACKED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id', 'order_id', 'merchant_id'],\n };\n}\n","/**\n * @fileoverview Order-related ecommerce events\n * Order-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type OrderProperties,\n type OrderStatusProperties,\n type ReturnProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProducts,\n validateCurrency,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track when a user completes an order\n */\nexport function orderCompleted(\n properties: OrderProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.ORDER_COMPLETED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when an order fails (payment declined, validation error, etc.)\n */\nexport function orderFailed(\n properties: OrderProperties & {\n failure_reason?: string;\n error_code?: string;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const { error_code, failure_reason, ...orderProps } = properties;\n const normalizedProps = {\n order_id: orderProps.order_id,\n affiliation: orderProps.affiliation,\n coupon: orderProps.coupon,\n currency: validateCurrency(orderProps.currency),\n discount: orderProps.discount,\n error_code,\n failure_reason,\n products: orderProps.products ? normalizeProducts(orderProps.products) : undefined,\n revenue: orderProps.revenue,\n shipping: orderProps.shipping,\n tax: orderProps.tax,\n total: orderProps.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_FAILED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track when an order is refunded\n */\nexport function orderRefunded(properties: OrderProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_REFUNDED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track when an order is cancelled\n */\nexport function orderCancelled(properties: OrderProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id']);\n\n const normalizedProps: OrderProperties = {\n order_id: properties.order_id,\n affiliation: properties.affiliation,\n coupon: properties.coupon,\n currency: validateCurrency(properties.currency),\n discount: properties.discount,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n revenue: properties.revenue,\n shipping: properties.shipping,\n tax: properties.tax,\n total: properties.total,\n };\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_CANCELLED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id'],\n };\n}\n\n/**\n * Track order status changes (shipping, delivery, etc.)\n */\nexport function orderStatusUpdated(properties: OrderStatusProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'status']);\n\n return {\n name: ECOMMERCE_EVENTS.ORDER_STATUS_UPDATED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['order_id', 'status'],\n };\n}\n\n/**\n * Track when a return is requested\n */\nexport function returnRequested(properties: ReturnProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'reason']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.RETURN_REQUESTED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id', 'reason'],\n };\n}\n\n/**\n * Track when a return is completed\n */\nexport function returnCompleted(\n properties: ReturnProperties & {\n completion_date?: string;\n refund_status?: 'pending' | 'completed' | 'failed';\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['order_id', 'return_id']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.RETURN_COMPLETED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['order_id', 'return_id'],\n };\n}\n","/**\n * @fileoverview Product-related ecommerce events\n * Product-related ecommerce events\n */\n\nimport { trackEcommerce } from '../track-ecommerce';\nimport {\n type BaseProductProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type ProductComparisonProperties,\n type ProductListProperties,\n type RecommendationProperties,\n type SearchResultsProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\nimport type { EmitterOptions, EmitterTrackPayload } from '../../emitter-types';\n\n/**\n * Track when a user searches for products\n */\nexport function productSearched(\n properties: { query: string },\n options?: EmitterOptions,\n): EmitterTrackPayload {\n validateRequiredProperties(properties, ['query']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.PRODUCT_SEARCHED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['query'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when search results are displayed\n */\nexport function searchResultsViewed(properties: SearchResultsProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['query', 'results_count']);\n\n const normalizedProps = {\n ...properties,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.SEARCH_RESULTS_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['query', 'results_count'],\n };\n}\n\n/**\n * Track when a user views a product list or category\n */\nexport function productListViewed(\n properties: ProductListProperties,\n): EcommerceEventSpec<ProductListProperties> {\n const normalizedProps: ProductListProperties = {\n list_id: properties.list_id,\n category: properties.category,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_LIST_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a user filters a product list\n */\nexport function productListFiltered(\n properties: ProductListProperties & { filters?: Record<string, any> },\n): EcommerceEventSpec {\n const normalizedProps = {\n list_id: properties.list_id,\n category: properties.category,\n filters: properties.filters,\n products: properties.products ? normalizeProducts(properties.products) : undefined,\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_LIST_FILTERED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a user clicks on a product\n */\nexport function productClicked(properties: BaseProductProperties): EcommerceEventSpec {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(normalizedProps, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a user views a product detail page\n */\nexport function productViewed(\n properties: BaseProductProperties,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const normalizedProps = normalizeProductProperties(properties);\n validateRequiredProperties(normalizedProps, ['product_id']);\n\n const eventSpec: EcommerceEventSpec = {\n name: ECOMMERCE_EVENTS.PRODUCT_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['product_id'],\n };\n\n return trackEcommerce(eventSpec, options);\n}\n\n/**\n * Track when a user compares products\n */\nexport function productCompared(properties: ProductComparisonProperties): EcommerceEventSpec {\n const { action, comparison_list, product } = properties;\n const normalizedProduct = normalizeProductProperties(product);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_COMPARED,\n category: 'ecommerce',\n properties: cleanProperties({\n action,\n ...normalizedProduct,\n comparison_list: comparison_list ? normalizeProducts(comparison_list) : undefined,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when product recommendations are viewed\n */\nexport function productRecommendationViewed(\n properties: RecommendationProperties,\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['recommendation_type', 'source']);\n\n const normalizedProps = {\n ...properties,\n products: normalizeProducts(properties.products),\n };\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(normalizedProps),\n requiredProperties: ['recommendation_type', 'source'],\n };\n}\n\n/**\n * Track when a recommended product is clicked\n */\nexport function productRecommendationClicked(\n properties: BaseProductProperties & {\n recommendation_type: string;\n source: string;\n position?: number;\n },\n): EcommerceEventSpec {\n const { recommendation_type, position, source, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_CLICKED,\n category: 'ecommerce',\n properties: cleanProperties({\n ...normalizedProduct,\n recommendation_type,\n position,\n source,\n }),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Universal registry events for gift registries, wishlists, and similar features\n * Universal registry events for gift registries, wishlists, and similar features\n * Uses action-based patterns for efficient tracking\n */\n\nimport {\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type RegistryItemProperties,\n type RegistryProperties,\n} from '../types';\nimport { cleanProperties, normalizeProductProperties, validateRequiredProperties } from '../utils';\n\n/**\n * Track registry management actions (create, update, delete)\n */\nexport function registryManaged(\n properties: RegistryProperties & {\n action: 'created' | 'updated' | 'deleted';\n updated_fields?: string[];\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id', 'action']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_MANAGED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id', 'action'],\n };\n}\n\n/**\n * Track when someone views a registry\n */\nexport function registryViewed(\n properties: RegistryProperties & {\n viewer_id?: string;\n viewer_relationship?: 'owner' | 'co_owner' | 'friend' | 'family' | 'other';\n items_count?: number;\n items_fulfilled?: number;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_VIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id'],\n };\n}\n\n/**\n * Track when a registry is shared\n */\nexport function registryShared(\n properties: RegistryProperties & {\n share_method: 'email' | 'social' | 'link' | 'qr_code' | 'other';\n recipients_count?: number;\n message?: string;\n },\n): EcommerceEventSpec {\n validateRequiredProperties(properties, ['registry_id', 'share_method']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_SHARED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['registry_id', 'share_method'],\n };\n}\n\n/**\n * Track registry item management (add, remove, update, purchase)\n */\nexport function registryItemManaged(\n properties: RegistryItemProperties & {\n action: 'added' | 'removed' | 'updated' | 'purchased';\n purchaser_id?: string;\n purchaser_name?: string;\n purchase_quantity?: number;\n purchase_message?: string;\n gift_wrap?: boolean;\n anonymous_gift?: boolean;\n updated_fields?: string[];\n },\n): EcommerceEventSpec {\n const {\n purchaser_id,\n registry_id,\n purchaser_name,\n action,\n anonymous_gift,\n gift_wrap,\n purchase_message,\n purchase_quantity,\n updated_fields,\n ...productProps\n } = properties;\n\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(properties, ['registry_id', 'product_id', 'action']);\n\n return {\n name: ECOMMERCE_EVENTS.REGISTRY_ITEM_MANAGED,\n category: 'ecommerce',\n properties: cleanProperties({\n purchaser_id,\n registry_id,\n purchaser_name,\n action,\n anonymous_gift,\n gift_wrap,\n purchase_message,\n purchase_quantity,\n updated_fields,\n ...normalizedProduct,\n }),\n requiredProperties: ['registry_id', 'product_id', 'action'],\n };\n}\n","/**\n * @fileoverview Wishlist, sharing, and review-related ecommerce events\n * Wishlist, sharing, and review-related ecommerce events\n */\n\nimport {\n type BaseProductProperties,\n type CartProperties,\n ECOMMERCE_EVENTS,\n type EcommerceEventSpec,\n type ReviewProperties,\n type SharingProperties,\n type WishlistProperties,\n} from '../types';\nimport {\n cleanProperties,\n normalizeProductProperties,\n normalizeProducts,\n validateRequiredProperties,\n} from '../utils';\n\n/**\n * Track when a product is added to wishlist\n */\nexport function productAddedToWishlist(properties: WishlistProperties): EcommerceEventSpec {\n const { wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_ADDED_TO_WISHLIST,\n category: 'ecommerce',\n properties: cleanProperties({\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a product is removed from wishlist\n */\nexport function productRemovedFromWishlist(properties: WishlistProperties): EcommerceEventSpec {\n const { wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_REMOVED_FROM_WISHLIST,\n category: 'ecommerce',\n properties: cleanProperties({\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a wishlist product is added to cart\n */\nexport function wishlistProductAddedToCart(\n properties: WishlistProperties & { cart_id?: string },\n): EcommerceEventSpec {\n const { cart_id, wishlist_id, wishlist_name, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.WISHLIST_PRODUCT_ADDED_TO_CART,\n category: 'ecommerce',\n properties: cleanProperties({\n cart_id,\n wishlist_id,\n wishlist_name,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a product is shared\n */\nexport function productShared(\n properties: BaseProductProperties & SharingProperties,\n): EcommerceEventSpec {\n const { recipient, share_message, share_via, ...productProps } = properties;\n const normalizedProduct = normalizeProductProperties(productProps);\n validateRequiredProperties(normalizedProduct, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_SHARED,\n category: 'ecommerce',\n properties: cleanProperties({\n recipient,\n share_message,\n share_via,\n ...normalizedProduct,\n }),\n requiredProperties: ['product_id'],\n };\n}\n\n/**\n * Track when a cart is shared\n */\nexport function cartShared(properties: CartProperties & SharingProperties): EcommerceEventSpec {\n const { cart_id, products, recipient, share_message, share_via } = properties;\n\n return {\n name: ECOMMERCE_EVENTS.CART_SHARED,\n category: 'ecommerce',\n properties: cleanProperties({\n cart_id,\n products: products ? normalizeProducts(products) : undefined,\n recipient,\n share_message,\n share_via,\n }),\n requiredProperties: [],\n };\n}\n\n/**\n * Track when a product is reviewed\n */\nexport function productReviewed(properties: ReviewProperties): EcommerceEventSpec {\n validateRequiredProperties(properties, ['product_id']);\n\n return {\n name: ECOMMERCE_EVENTS.PRODUCT_REVIEWED,\n category: 'ecommerce',\n properties: cleanProperties(properties),\n requiredProperties: ['product_id'],\n };\n}\n","/**\n * @fileoverview Platform-standard ecommerce events\n *\n * This module provides comprehensive ecommerce event tracking following industry\n * best practices (Segment.io ecommerce spec, Google Analytics Enhanced Ecommerce).\n *\n * **Event Categories**:\n * - **Cart & Checkout**: Add to cart, remove from cart, checkout started, checkout completed\n * - **Orders**: Order placed, order updated, order refunded, order cancelled\n * - **Products**: Product viewed, product added, product removed, product shared\n * - **Coupons**: Coupon applied, coupon removed, coupon viewed\n * - **Engagement**: Product list viewed, product list filtered, product searched\n * - **Marketplace**: Seller viewed, seller contacted, review submitted\n * - **Registry**: Registry created, registry item added, registry shared\n * - **Wishlist**: Wishlist item added, wishlist item removed, wishlist shared\n *\n * **Usage**: Import event functions and use with `analytics.emit()`:\n * ```typescript\n * import { ecommerce } from '@od-oneapp/analytics/shared';\n * await analytics.emit(ecommerce.productViewed({ productId: 'prod-123' }));\n * ```\n *\n * @module @od-oneapp/analytics/shared/emitters/ecommerce\n */\n\n// Export all types\nexport * from './types';\n\n// Export utilities\nexport * from './utils';\n\n// Export all event functions\nexport * from './events/cart-checkout';\nexport * from './events/coupon';\nexport * from './events/engagement';\nexport * from './events/marketplace';\nexport * from './events/order';\nexport * from './events/product';\nexport * from './events/registry';\nexport * from './events/wishlist-sharing';\n\n// Export tracking functionality\nexport * from './track-ecommerce';\n\n// Re-export commonly used constants for convenience\nexport { ECOMMERCE_EVENTS } from './types';\n"],"mappings":";;;;AAmOA,MAAa,mBAAmB;CAC9B,iBAAiB;CACjB,kBAAkB;CAClB,uBAAuB;CACvB,qBAAqB;CACrB,gCAAgC;CAChC,+BAA+B;CAE/B,kBAAkB;CAClB,gBAAgB;CAChB,uBAAuB;CAEvB,gBAAgB;CAEhB,cAAc;CACd,aAAa;CAGb,qBAAqB;CAErB,iBAAiB;CAEjB,iB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C1B;GACA,UAAU,WAAW,kBAAkB,SAAS,GAAG;GACnD;GACA;GACA;GACD,CAAC;EACF,oBAAoB,EAAE;EACvB;;;;;AAMH,SAAgB,gBAAgB,YAAkD;AAChF,4BAA2B,YAAY,CAAC,aAAa,CAAC;AAEtD,QAAO;EACL,MAAM,iBAAiB;EACvB,UAAU;EACV,YAAY,gBAAgB,WAAW;EACvC,oBAAoB,CAAC,aAAa;EACnC"}
@@ -205,4 +205,4 @@ function alias(userId, previousId, options) {
205
205
 
206
206
  //#endregion
207
207
  export { screen as a, page as i, group as n, track as o, identify as r, alias as t };
208
- //# sourceMappingURL=emitters-BvEelkxS.mjs.map
208
+ //# sourceMappingURL=emitters-6-nKo8i-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"emitters-BvEelkxS.mjs","names":[],"sources":["../src/shared/emitters/emitters.ts"],"sourcesContent":["/**\n * @fileoverview Core analytics emitter functions following Segment.io specification\n *\n * This module provides type-safe emitter functions that return event payloads following\n * the Segment.io specification. These payloads can be passed to `analytics.emit()` or\n * `analytics.track()` for tracking.\n *\n * **Emitter Functions**:\n * - `identify()`: Identify users with traits\n * - `track()`: Track custom events\n * - `page()`: Track page views\n * - `screen()`: Track screen views (mobile)\n * - `group()`: Associate users with groups\n * - `alias()`: Alias user IDs\n *\n * **Benefits**:\n * - Type-safe event tracking\n * - Consistent with Segment.io spec\n * - Can be composed and batched\n * - Works with all analytics providers\n *\n * **Reference**: https://segment.com/docs/connections/spec/\n *\n * @module @od-oneapp/analytics/shared/emitters\n */\n\nimport type {\n EmitterAliasPayload,\n EmitterGroupPayload,\n EmitterIdentifyPayload,\n EmitterOptions,\n EmitterPagePayload,\n EmitterScreenPayload,\n EmitterTrackPayload,\n} from './emitter-types';\nimport type { GroupTraits, PageProperties, PropertyObject, UserTraits } from '../types/types';\n\n/**\n * Identify - who is the customer?\n *\n * Ties a user to their actions and records traits about them. This is the core\n * method for identifying users in your analytics system.\n *\n * **When to call**:\n * - After a user first registers\n * - After a user logs in\n * - When a user updates their info\n *\n * **Reference**: https://segment.com/docs/connections/spec/identify/\n *\n * @param {string} userId - Unique identifier for the user in your database (required unless anonymousId is set)\n * @param {UserTraits} [traits] - Free-form dictionary of traits about the user, like email or name\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterIdentifyPayload} Identify payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(identify('user-123', {\n * email: 'user@example.com',\n * name: 'John Doe'\n * }));\n * ```\n */\nexport function identify(\n userId: string,\n traits?: UserTraits,\n options?: EmitterOptions,\n): EmitterIdentifyPayload {\n const payload: EmitterIdentifyPayload = {\n type: 'identify',\n userId,\n ...(traits && { traits }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n return payload;\n}\n\n/**\n * Track - what are they doing?\n *\n * Records any actions your users perform, along with properties that describe the action.\n * This is the most common method for tracking user behavior.\n *\n * **Reference**: https://segment.com/docs/connections/spec/track/\n *\n * @param {string} event - Name of the action that a user has performed (required)\n * @param {PropertyObject} [properties] - Free-form dictionary of properties of the event, like revenue\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterTrackPayload} Track payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(track('Button Clicked', {\n * buttonName: 'Sign Up',\n * location: 'header'\n * }));\n * ```\n */\nexport function track(\n event: string,\n properties?: PropertyObject,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const payload: EmitterTrackPayload = {\n type: 'track',\n event,\n ...(properties && { properties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Page - what web page are they on?\n *\n * Records page views on your website, along with optional properties about the page.\n * Automatically merges category into properties if provided.\n *\n * **Reference**: https://segment.com/docs/connections/spec/page/\n *\n * @param {string} [category] - Category of the page (optional)\n * @param {string} [name] - Name of the page (optional)\n * @param {PageProperties} [properties] - Free-form dictionary of properties of the page, like url and referrer\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterPagePayload} Page payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(page('Home', 'Landing', {\n * url: 'https://example.com',\n * referrer: 'https://google.com'\n * }));\n * ```\n */\nexport function page(\n category?: string,\n name?: string,\n properties?: PageProperties,\n options?: EmitterOptions,\n): EmitterPagePayload {\n // Merge category into properties if provided\n const mergedProperties = {\n ...(properties ?? {}),\n ...(category && { category }),\n };\n\n const payload: EmitterPagePayload = {\n type: 'page',\n ...(name && { name }),\n ...(Object.keys(mergedProperties).length > 0 && { properties: mergedProperties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Screen - what app screen are they on?\n *\n * The mobile equivalent of page, records screen views in your mobile app.\n * Use this for React Native, iOS, and Android applications.\n *\n * **Reference**: https://segment.com/docs/connections/spec/screen/\n *\n * @param {string} [name] - Name of the screen (optional)\n * @param {PropertyObject} [properties] - Free-form dictionary of properties of the screen\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterScreenPayload} Screen payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(screen('Home Screen', {\n * screenType: 'main',\n * userId: 'user-123'\n * }));\n * ```\n */\nexport function screen(\n name?: string,\n properties?: PropertyObject,\n options?: EmitterOptions,\n): EmitterScreenPayload {\n const payload: EmitterScreenPayload = {\n type: 'screen',\n ...(name && { name }),\n ...(properties && { properties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Group - what account or organization are they part of?\n *\n * Associates an individual user with a group—a company, organization, account, project, or team.\n * Useful for B2B applications where users belong to organizations.\n *\n * **Reference**: https://segment.com/docs/connections/spec/group/\n *\n * @param {string} groupId - Unique identifier for the group in your database (required)\n * @param {GroupTraits} [traits] - Free-form dictionary of traits of the group, like name or industry\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterGroupPayload} Group payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(group('org-456', {\n * name: 'Acme Corp',\n * industry: 'Technology',\n * plan: 'enterprise'\n * }));\n * ```\n */\nexport function group(\n groupId: string,\n traits?: GroupTraits,\n options?: EmitterOptions,\n): EmitterGroupPayload {\n const payload: EmitterGroupPayload = {\n type: 'group',\n groupId,\n ...(traits && { traits }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Alias - what was their past identity?\n *\n * Merges two user identities, effectively connecting two sets of user data in one profile.\n * This is an advanced method that should only be used when required for downstream\n * destination compatibility (e.g., when a user signs up after browsing anonymously).\n *\n * **Reference**: https://segment.com/docs/connections/spec/alias/\n *\n * @param {string} userId - The user's new identity, or an existing identity to merge with previousId (required)\n * @param {string} previousId - The existing ID you've referred to the user by (required)\n * @param {EmitterOptions} [options] - Optional fields like timestamp, context, integrations\n * @returns {EmitterAliasPayload} Alias payload ready to emit\n *\n * @example\n * ```typescript\n * // When anonymous user signs up\n * await analytics.emit(alias('user-123', 'anonymous-456'));\n * ```\n */\nexport function alias(\n userId: string,\n previousId: string,\n options?: EmitterOptions,\n): EmitterAliasPayload {\n const payload: EmitterAliasPayload = {\n type: 'alias',\n previousId,\n userId,\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n return payload;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAgB,SACd,QACA,QACA,SACwB;AAWxB,QAVwC;EACtC,MAAM;EACN;EACA,GAAI,UAAU,EAAE,QAAQ;EACxB,GAAI,SAAS,aAAa,EAAE,WAAW,QAAQ,WAAW;EAC1D,GAAI,SAAS,WAAW,EAAE,SAAS,QAAQ,SAAS;EACpD,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EAChE,GAAI,SAAS,gBAAgB,EAAE,cAAc,QAAQ,cAAc;EACpE;;;;;;;;;;;;;;;;;;;;;;;AA0BH,SAAgB,MACd,OACA,YACA,SACqB;AAcrB,QAbqC;EACnC,MAAM;EACN;EACA,GAAI,cAAc,EAAE,YAAY;EAChC,GAAI,SAAS,aAAa,EAAE,WAAW,QAAQ,WAAW;EAC1D,GAAI,SAAS,WAAW,EAAE,SAAS,QAAQ,SAAS;EACpD,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EAChE,GAAI,SAAS,gBAAgB,EAAE,cAAc,QAAQ,cAAc;EACnE,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EACjE;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,SAAgB,KACd,UACA,MACA,YACA,SACoB;CAEpB,MAAM,mBAAmB;EACvB,GAAI,cAAc,EAAE;EACpB,GAAI,YAAY,EAAE,UAAU;EAC7B;AAcD,QAZoC;EAClC,MAAM;EACN,GAAI,QAAQ,EAAE,MAAM;EACpB,GAAI,OAAO,KAAK,iBAAiB,CAAC,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{"version":3,"file":"emitters-6-nKo8i-.mjs","names":[],"sources":["../src/shared/emitters/emitters.ts"],"sourcesContent":["/**\n * @fileoverview Core analytics emitter functions following Segment.io specification\n *\n * This module provides type-safe emitter functions that return event payloads following\n * the Segment.io specification. These payloads can be passed to `analytics.emit()` or\n * `analytics.track()` for tracking.\n *\n * **Emitter Functions**:\n * - `identify()`: Identify users with traits\n * - `track()`: Track custom events\n * - `page()`: Track page views\n * - `screen()`: Track screen views (mobile)\n * - `group()`: Associate users with groups\n * - `alias()`: Alias user IDs\n *\n * **Benefits**:\n * - Type-safe event tracking\n * - Consistent with Segment.io spec\n * - Can be composed and batched\n * - Works with all analytics providers\n *\n * **Reference**: https://segment.com/docs/connections/spec/\n *\n * @module @od-oneapp/analytics/shared/emitters\n */\n\nimport type {\n EmitterAliasPayload,\n EmitterGroupPayload,\n EmitterIdentifyPayload,\n EmitterOptions,\n EmitterPagePayload,\n EmitterScreenPayload,\n EmitterTrackPayload,\n} from './emitter-types';\nimport type { GroupTraits, PageProperties, PropertyObject, UserTraits } from '../types/types';\n\n/**\n * Identify - who is the customer?\n *\n * Ties a user to their actions and records traits about them. This is the core\n * method for identifying users in your analytics system.\n *\n * **When to call**:\n * - After a user first registers\n * - After a user logs in\n * - When a user updates their info\n *\n * **Reference**: https://segment.com/docs/connections/spec/identify/\n *\n * @param {string} userId - Unique identifier for the user in your database (required unless anonymousId is set)\n * @param {UserTraits} [traits] - Free-form dictionary of traits about the user, like email or name\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterIdentifyPayload} Identify payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(identify('user-123', {\n * email: 'user@example.com',\n * name: 'John Doe'\n * }));\n * ```\n */\nexport function identify(\n userId: string,\n traits?: UserTraits,\n options?: EmitterOptions,\n): EmitterIdentifyPayload {\n const payload: EmitterIdentifyPayload = {\n type: 'identify',\n userId,\n ...(traits && { traits }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n return payload;\n}\n\n/**\n * Track - what are they doing?\n *\n * Records any actions your users perform, along with properties that describe the action.\n * This is the most common method for tracking user behavior.\n *\n * **Reference**: https://segment.com/docs/connections/spec/track/\n *\n * @param {string} event - Name of the action that a user has performed (required)\n * @param {PropertyObject} [properties] - Free-form dictionary of properties of the event, like revenue\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterTrackPayload} Track payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(track('Button Clicked', {\n * buttonName: 'Sign Up',\n * location: 'header'\n * }));\n * ```\n */\nexport function track(\n event: string,\n properties?: PropertyObject,\n options?: EmitterOptions,\n): EmitterTrackPayload {\n const payload: EmitterTrackPayload = {\n type: 'track',\n event,\n ...(properties && { properties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Page - what web page are they on?\n *\n * Records page views on your website, along with optional properties about the page.\n * Automatically merges category into properties if provided.\n *\n * **Reference**: https://segment.com/docs/connections/spec/page/\n *\n * @param {string} [category] - Category of the page (optional)\n * @param {string} [name] - Name of the page (optional)\n * @param {PageProperties} [properties] - Free-form dictionary of properties of the page, like url and referrer\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterPagePayload} Page payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(page('Home', 'Landing', {\n * url: 'https://example.com',\n * referrer: 'https://google.com'\n * }));\n * ```\n */\nexport function page(\n category?: string,\n name?: string,\n properties?: PageProperties,\n options?: EmitterOptions,\n): EmitterPagePayload {\n // Merge category into properties if provided\n const mergedProperties = {\n ...(properties ?? {}),\n ...(category && { category }),\n };\n\n const payload: EmitterPagePayload = {\n type: 'page',\n ...(name && { name }),\n ...(Object.keys(mergedProperties).length > 0 && { properties: mergedProperties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Screen - what app screen are they on?\n *\n * The mobile equivalent of page, records screen views in your mobile app.\n * Use this for React Native, iOS, and Android applications.\n *\n * **Reference**: https://segment.com/docs/connections/spec/screen/\n *\n * @param {string} [name] - Name of the screen (optional)\n * @param {PropertyObject} [properties] - Free-form dictionary of properties of the screen\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterScreenPayload} Screen payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(screen('Home Screen', {\n * screenType: 'main',\n * userId: 'user-123'\n * }));\n * ```\n */\nexport function screen(\n name?: string,\n properties?: PropertyObject,\n options?: EmitterOptions,\n): EmitterScreenPayload {\n const payload: EmitterScreenPayload = {\n type: 'screen',\n ...(name && { name }),\n ...(properties && { properties }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Group - what account or organization are they part of?\n *\n * Associates an individual user with a group—a company, organization, account, project, or team.\n * Useful for B2B applications where users belong to organizations.\n *\n * **Reference**: https://segment.com/docs/connections/spec/group/\n *\n * @param {string} groupId - Unique identifier for the group in your database (required)\n * @param {GroupTraits} [traits] - Free-form dictionary of traits of the group, like name or industry\n * @param {EmitterOptions} [options] - Optional fields like timestamp, anonymousId, context, integrations\n * @returns {EmitterGroupPayload} Group payload ready to emit\n *\n * @example\n * ```typescript\n * await analytics.emit(group('org-456', {\n * name: 'Acme Corp',\n * industry: 'Technology',\n * plan: 'enterprise'\n * }));\n * ```\n */\nexport function group(\n groupId: string,\n traits?: GroupTraits,\n options?: EmitterOptions,\n): EmitterGroupPayload {\n const payload: EmitterGroupPayload = {\n type: 'group',\n groupId,\n ...(traits && { traits }),\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n // userId should be passed through the main function params or via options\n\n return payload;\n}\n\n/**\n * Alias - what was their past identity?\n *\n * Merges two user identities, effectively connecting two sets of user data in one profile.\n * This is an advanced method that should only be used when required for downstream\n * destination compatibility (e.g., when a user signs up after browsing anonymously).\n *\n * **Reference**: https://segment.com/docs/connections/spec/alias/\n *\n * @param {string} userId - The user's new identity, or an existing identity to merge with previousId (required)\n * @param {string} previousId - The existing ID you've referred to the user by (required)\n * @param {EmitterOptions} [options] - Optional fields like timestamp, context, integrations\n * @returns {EmitterAliasPayload} Alias payload ready to emit\n *\n * @example\n * ```typescript\n * // When anonymous user signs up\n * await analytics.emit(alias('user-123', 'anonymous-456'));\n * ```\n */\nexport function alias(\n userId: string,\n previousId: string,\n options?: EmitterOptions,\n): EmitterAliasPayload {\n const payload: EmitterAliasPayload = {\n type: 'alias',\n previousId,\n userId,\n ...(options?.timestamp && { timestamp: options.timestamp }),\n ...(options?.context && { context: options.context }),\n ...(options?.anonymousId && { anonymousId: options.anonymousId }),\n ...(options?.integrations && { integrations: options.integrations }),\n };\n\n return payload;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAgB,SACd,QACA,QACA,SACwB;AAWxB,QAVwC;EACtC,MAAM;EACN;EACA,GAAI,UAAU,EAAE,QAAQ;EACxB,GAAI,SAAS,aAAa,EAAE,WAAW,QAAQ,WAAW;EAC1D,GAAI,S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SAAS,QAAQ,SAAS;EACpD,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EAChE,GAAI,SAAS,gBAAgB,EAAE,cAAc,QAAQ,cAAc;EACpE;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,SAAgB,MACd,SACA,QACA,SACqB;AAarB,QAZqC;EACnC,MAAM;EACN;EACA,GAAI,UAAU,EAAE,QAAQ;EACxB,GAAI,SAAS,aAAa,EAAE,WAAW,QAAQ,WAAW;EAC1D,GAAI,SAAS,WAAW,EAAE,SAAS,QAAQ,SAAS;EACpD,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EAChE,GAAI,SAAS,gBAAgB,EAAE,cAAc,QAAQ,cAAc;EACpE;;;;;;;;;;;;;;;;;;;;;;AA2BH,SAAgB,MACd,QACA,YACA,SACqB;AAWrB,QAVqC;EACnC,MAAM;EACN;EACA;EACA,GAAI,SAAS,aAAa,EAAE,WAAW,QAAQ,WAAW;EAC1D,GAAI,SAAS,WAAW,EAAE,SAAS,QAAQ,SAAS;EACpD,GAAI,SAAS,eAAe,EAAE,aAAa,QAAQ,aAAa;EAChE,GAAI,SAAS,gBAAgB,EAAE,cAAc,QAAQ,cAAc;EACpE"}
@@ -1,4 +1,4 @@
1
- import { A as GroupTraits, C as EmitterPagePayload, D as EmitterTrackPayload, E as EmitterScreenPayload, F as UserTraits, N as PropertyObject, S as EmitterOptions, b as EmitterIdentifyPayload, j as PageProperties, p as EmitterAliasPayload, v as EmitterGroupPayload } from "./types-DnfdguWa.mjs";
1
+ import { A as GroupTraits, C as EmitterPagePayload, D as EmitterTrackPayload, E as EmitterScreenPayload, F as UserTraits, N as PropertyObject, S as EmitterOptions, b as EmitterIdentifyPayload, j as PageProperties, p as EmitterAliasPayload, v as EmitterGroupPayload } from "./types-BxBnNQ0V.mjs";
2
2
 
3
3
  //#region src/shared/emitters/emitters.d.ts
4
4
  declare function identify(userId: string, traits?: UserTraits, options?: EmitterOptions): EmitterIdentifyPayload;
@@ -9,4 +9,4 @@ declare function group(groupId: string, traits?: GroupTraits, options?: EmitterO
9
9
  declare function alias(userId: string, previousId: string, options?: EmitterOptions): EmitterAliasPayload;
10
10
  //#endregion
11
11
  export { screen as a, page as i, group as n, track as o, identify as r, alias as t };
12
- //# sourceMappingURL=emitters-BAXagFjt.d.mts.map
12
+ //# sourceMappingURL=emitters-DldkVSPp.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emitters-BAXagFjt.d.mts","names":[],"sources":["../src/shared/emitters/emitters.ts"],"mappings":";;;iBA+DgB,QAAA,CACd,MAAA,UACA,MAAA,GAAS,UAAA,EACT,OAAA,GAAU,cAAA,GACT,sBAAA;AAAA,iBAmCa,KAAA,CACd,KAAA,UACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,mBAAA;AAAA,iBAuCa,IAAA,CACd,QAAA,WACA,IAAA,WACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,kBAAA;AAAA,iBA2Ca,MAAA,CACd,IAAA,WACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,oBAAA;AAAA,iBAsCa,KAAA,CACd,OAAA,UACA,MAAA,GAAS,WAAA,EACT,OAAA,GAAU,cAAA,GACT,mBAAA;AAAA,iBAoCa,KAAA,CACd,MAAA,UACA,UAAA,UACA,OAAA,GAAU,cAAA,GACT,mBAAA"}
1
+ {"version":3,"file":"emitters-DldkVSPp.d.mts","names":[],"sources":["../src/shared/emitters/emitters.ts"],"mappings":";;;iBA+DgB,QAAA,CACd,MAAA,UACA,MAAA,GAAS,UAAA,EACT,OAAA,GAAU,cAAA,GACT,sBAAA;AAAA,iBAmCa,KAAA,CACd,KAAA,UACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,mBAAA;AAAA,iBAuCa,IAAA,CACd,QAAA,WACA,IAAA,WACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,kBAAA;AAAA,iBA2Ca,MAAA,CACd,IAAA,WACA,UAAA,GAAa,cAAA,EACb,OAAA,GAAU,cAAA,GACT,oBAAA;AAAA,iBAsCa,KAAA,CACd,OAAA,UACA,MAAA,GAAS,WAAA,EACT,OAAA,GAAU,cAAA,GACT,mBAAA;AAAA,iBAoCa,KAAA,CACd,MAAA,UACA,UAAA,UACA,OAAA,GAAU,cAAA,GACT,mBAAA"}