@shware/analytics 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-outbound-click-analytics.cjs +2 -2
- package/dist/hooks/use-outbound-click-analytics.cjs.map +1 -1
- package/dist/hooks/use-outbound-click-analytics.mjs +2 -2
- package/dist/hooks/use-outbound-click-analytics.mjs.map +1 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/native/fingerprint.cjs +3 -3
- package/dist/native/fingerprint.cjs.map +1 -1
- package/dist/native/fingerprint.mjs +3 -3
- package/dist/native/fingerprint.mjs.map +1 -1
- package/dist/native/firebase.cjs.map +1 -1
- package/dist/native/firebase.mjs.map +1 -1
- package/dist/native/index.cjs +1 -1
- package/dist/native/index.mjs +1 -1
- package/dist/native/setup.cjs +3 -5
- package/dist/native/setup.cjs.map +1 -1
- package/dist/native/setup.mjs +3 -5
- package/dist/native/setup.mjs.map +1 -1
- package/dist/react-router/index.cjs +1 -1
- package/dist/react-router/index.mjs +1 -1
- package/dist/schema/index.cjs +0 -14
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +1 -150
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +1 -150
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +2 -15
- package/dist/schema/index.mjs.map +1 -1
- package/dist/server/linkedin-conversions-api.cjs +1 -1
- package/dist/server/linkedin-conversions-api.cjs.map +1 -1
- package/dist/server/linkedin-conversions-api.mjs +1 -1
- package/dist/server/linkedin-conversions-api.mjs.map +1 -1
- package/dist/server/meta-conversions-api.cjs +4 -4
- package/dist/server/meta-conversions-api.cjs.map +1 -1
- package/dist/server/meta-conversions-api.d.cts.map +1 -1
- package/dist/server/meta-conversions-api.d.mts.map +1 -1
- package/dist/server/meta-conversions-api.mjs +4 -4
- package/dist/server/meta-conversions-api.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +1 -1
- package/dist/server/openai-conversions-api.cjs.map +1 -1
- package/dist/server/openai-conversions-api.mjs +1 -1
- package/dist/server/openai-conversions-api.mjs.map +1 -1
- package/dist/server/reddit-conversions-api.cjs +3 -3
- package/dist/server/reddit-conversions-api.cjs.map +1 -1
- package/dist/server/reddit-conversions-api.mjs +3 -3
- package/dist/server/reddit-conversions-api.mjs.map +1 -1
- package/dist/setup/session.cjs.map +1 -1
- package/dist/setup/session.mjs.map +1 -1
- package/dist/tanstack/analytics.cjs +1 -1
- package/dist/tanstack/analytics.mjs +1 -1
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +4 -1
- package/dist/third-parties/google-analytics.d.cts.map +1 -1
- package/dist/third-parties/google-analytics.d.mts +4 -1
- package/dist/third-parties/google-analytics.d.mts.map +1 -1
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +4 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +4 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +4 -1
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts +4 -1
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +2 -1
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +4 -1
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts +4 -1
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.mjs +2 -1
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +4 -1
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +4 -1
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/track/index.cjs +1 -1
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.d.cts.map +1 -1
- package/dist/track/index.d.mts.map +1 -1
- package/dist/track/index.mjs +1 -1
- package/dist/track/index.mjs.map +1 -1
- package/dist/track/oaiq.cjs.map +1 -1
- package/dist/track/oaiq.d.cts +1 -1
- package/dist/track/oaiq.d.cts.map +1 -1
- package/dist/track/oaiq.d.mts +1 -1
- package/dist/track/oaiq.d.mts.map +1 -1
- package/dist/track/oaiq.mjs.map +1 -1
- package/dist/track/rdt.cjs +3 -4
- package/dist/track/rdt.cjs.map +1 -1
- package/dist/track/rdt.mjs +3 -4
- package/dist/track/rdt.mjs.map +1 -1
- package/dist/track/types.d.cts +0 -4
- package/dist/track/types.d.cts.map +1 -1
- package/dist/track/types.d.mts +0 -4
- package/dist/track/types.d.mts.map +1 -1
- package/dist/web/index.cjs +1 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts.map +1 -1
- package/dist/web/index.d.mts.map +1 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/index.mjs.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oaiq.d.mts","names":[],"sources":["../../src/track/oaiq.ts"],"mappings":";;;cAGa;;;;;KAiBD;EACV;EACA;EACA;EACA;;EAEA;EACA;;KAGU;EACV;;EAEA;EACA;EACA,WAAW;;KAGD;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA,WAAW;;KAGD;EACV;EACA;EACA;EACA,WAAW;;KAGD,YAAY,eAAe,qBAAqB,qBAAqB;;;;;KAMrE;EACV,uBAAuB;EACvB,kBAAkB;EAClB,iBAAiB;EACjB,aAAa;EACb,cAAc;EACd,eAAe;EACf,aAAa;EACb,wBAAwB;EACxB,sBAAsB;EACtB,eAAe;;KAGL,sBAAsB;;;;;;KAOtB;EACV;EACA;;EAEA;;EAEA;;EAEA;;KAGU;EACV;;EAEA;EACA,OAAO;;;;;;KAOG;;EAEV;;EAEA;;EAEA;;UAGe;EACf,KAAK,iBAAiB,QAAQ;EAC9B,KAAK,UAAU,eACb,oBACA,OAAO,GACP,MAAM,eAAe,IACrB,UAAU;EAEZ,KACE,oBACA,iBACA,MAAM,iBACN,SAAS;IAAmB;;;;iBAgChB,aAAa,
|
|
1
|
+
{"version":3,"file":"oaiq.d.mts","names":[],"sources":["../../src/track/oaiq.ts"],"mappings":";;;cAGa;;;;;KAiBD;EACV;EACA;EACA;EACA;;EAEA;EACA;;KAGU;EACV;;EAEA;EACA;EACA,WAAW;;KAGD;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA,WAAW;;KAGD;EACV;EACA;EACA;EACA,WAAW;;KAGD,YAAY,eAAe,qBAAqB,qBAAqB;;;;;KAMrE;EACV,uBAAuB;EACvB,kBAAkB;EAClB,iBAAiB;EACjB,aAAa;EACb,cAAc;EACd,eAAe;EACf,aAAa;EACb,wBAAwB;EACxB,sBAAsB;EACtB,eAAe;;KAGL,sBAAsB;;;;;;KAOtB;EACV;EACA;;EAEA;;EAEA;;EAEA;;KAGU;EACV;;EAEA;EACA,OAAO;;;;;;KAOG;;EAEV;;EAEA;;EAEA;;UAGe;EACf,KAAK,iBAAiB,QAAQ;EAC9B,KAAK,UAAU,eACb,oBACA,OAAO,GACP,MAAM,eAAe,IACrB,UAAU;EAEZ,KACE,oBACA,iBACA,MAAM,iBACN,SAAS;IAAmB;;;;iBAgChB,aAAa,uBAAuB;iBAYpC,YAAY,QAAQ,QAAQ,oBAAoB;KAkEpD;EACV,MAAM;EACN,MAAM;;;iBAIQ,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,KAC5B"}
|
package/dist/track/oaiq.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oaiq.mjs","names":[],"sources":["../../src/track/oaiq.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\nexport const NON_AD_EVENTS = [\n // metrics\n 'CLS',\n 'FCP',\n 'FID',\n 'INP',\n 'LCP',\n 'TTFB',\n // promotions\n 'view_promotion',\n 'select_promotion',\n];\n\n/**\n * Content item shared by `contents` and `plan_enrollment` events.\n * https://developers.openai.com/ads/supported-events\n */\nexport type ContentItem = {\n id?: string;\n name?: string;\n content_type?: string;\n quantity?: number;\n /** Per-item monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */\n amount?: number;\n currency?: string;\n};\n\nexport type ContentsData = {\n type: 'contents';\n /** Monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type CustomerActionData = {\n type: 'customer_action';\n amount?: number;\n currency?: string;\n};\n\nexport type PlanEnrollmentData = {\n type: 'plan_enrollment';\n plan_id?: string;\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type CustomEventData = {\n type: 'custom';\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type EventData = ContentsData | CustomerActionData | PlanEnrollmentData | CustomEventData;\n\n/**\n * Standard event names and the `data` shape each one expects.\n * https://developers.openai.com/ads/supported-events\n */\nexport type StandardEvents = {\n appointment_scheduled: CustomerActionData;\n checkout_started: ContentsData;\n contents_viewed: ContentsData;\n items_added: ContentsData;\n lead_created: CustomerActionData;\n order_created: ContentsData;\n page_viewed: ContentsData;\n registration_completed: CustomerActionData;\n subscription_created: PlanEnrollmentData;\n trial_started: PlanEnrollmentData;\n};\n\nexport type StandardEvent = keyof StandardEvents;\n\n/**\n * Identity fields passed to `oaiq(\"init\", ...)` for conversion matching. Email and external id\n * must be pre-hashed as lowercase 64-char SHA-256 hex strings; the rest are sent as raw values.\n * https://developers.openai.com/ads/measurement-pixel\n */\nexport type OAIQUser = {\n email_sha256?: string;\n external_id_sha256?: string;\n /** Two-letter ISO 3166-1 country code (e.g. \"US\"). */\n country?: string;\n /** Lowercased, max 128 characters. */\n city?: string;\n /** Max 32 characters. */\n zip_code?: string;\n};\n\nexport type InitConfig = {\n pixelId: string;\n /** Log SDK activity to the browser console. */\n debug?: boolean;\n user?: OAIQUser;\n};\n\n/**\n * Fourth argument of `oaiq(\"measure\", ...)`. Required for custom events (carries\n * `custom_event_name`); optional for standard events.\n */\nexport type MeasureOptions = {\n /** Shared with the Conversions API to deduplicate the same conversion across browser and server. */\n event_id?: string;\n /** Required for custom events; 1-64 chars of letters, numbers, underscores, or dashes. */\n custom_event_name?: string;\n /** When true, opts the event out of user-level personalization. */\n opt_out?: boolean;\n};\n\nexport interface OAIQ {\n oaiq(command: 'init', config: InitConfig): void;\n oaiq<T extends StandardEvent>(\n command: 'measure',\n event: T,\n data: StandardEvents[T],\n options?: MeasureOptions\n ): void;\n oaiq(\n command: 'measure',\n event: 'custom',\n data: CustomEventData,\n options: MeasureOptions & { custom_event_name: string }\n ): void;\n}\n\n/**\n * Currencies whose minor unit has 0 or 3 decimal places; everything else uses 2.\n * Follows Stripe's zero-decimal convention (e.g., MGA is treated as 0, ISK is included),\n * which can differ from strict ISO 4217 exponents.\n * https://docs.stripe.com/currencies#zero-decimal\n */\nconst ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'ISK',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst THREE_DECIMAL_CURRENCIES = new Set(['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND']);\n\n/** Convert a major-unit amount (e.g., 129.99) into ISO 4217 minor units (e.g., 12,999). */\nexport function toMinorUnits(value?: number, currency?: string): number | undefined {\n if (value === undefined || value === null || Number.isNaN(value)) return undefined;\n const code = currency?.toUpperCase();\n const exponent =\n code && ZERO_DECIMAL_CURRENCIES.has(code)\n ? 0\n : code && THREE_DECIMAL_CURRENCIES.has(code)\n ? 3\n : 2;\n return Math.round(value * 10 ** exponent);\n}\n\nexport function mapContents(items?: Item[], currency?: string): ContentItem[] | undefined {\n if (!items || items.length === 0) return undefined;\n const code = currency?.toUpperCase();\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n content_type: item.item_category,\n quantity: item.quantity,\n amount: toMinorUnits(item.price, currency),\n currency: item.price !== undefined ? code : undefined,\n }));\n}\n\n/** Safely read a property off loosely typed track properties without widening to `any`. */\nfunction prop(properties: unknown, key: string): unknown {\n return typeof properties === 'object' && properties !== null\n ? (properties as Record<string, unknown>)[key]\n : undefined;\n}\n\nfunction readValue(properties: unknown): number | undefined {\n const value = prop(properties, 'value');\n return typeof value === 'number' ? value : undefined;\n}\n\nfunction readCurrency(properties: unknown): string | undefined {\n const currency = prop(properties, 'currency');\n return typeof currency === 'string' ? currency : undefined;\n}\n\nfunction readItems(properties: unknown): Item[] | undefined {\n const items = prop(properties, 'items');\n return Array.isArray(items) ? (items as Item[]) : undefined;\n}\n\nfunction contentsData(properties: unknown): ContentsData {\n const currency = readCurrency(properties);\n return {\n type: 'contents',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(readItems(properties), currency),\n };\n}\n\nfunction customerActionData(properties: unknown): CustomerActionData {\n const currency = readCurrency(properties);\n return {\n type: 'customer_action',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n };\n}\n\nfunction planEnrollmentData(properties: unknown): PlanEnrollmentData {\n const currency = readCurrency(properties);\n const items = readItems(properties);\n return {\n type: 'plan_enrollment',\n plan_id: items?.[0]?.item_id,\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(items, currency),\n };\n}\n\nexport type MappedOAIEvent = {\n type: StandardEvent | 'custom';\n data: EventData;\n};\n\n/** Map an internal track event onto an OpenAI standard (or custom) conversion event. */\nexport function mapOAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n): MappedOAIEvent {\n switch (name) {\n case 'page_view':\n return { type: 'page_viewed', data: contentsData(properties) };\n case 'view_item':\n case 'view_item_list':\n return { type: 'contents_viewed', data: contentsData(properties) };\n case 'begin_checkout':\n return { type: 'checkout_started', data: contentsData(properties) };\n case 'add_to_cart':\n return { type: 'items_added', data: contentsData(properties) };\n case 'purchase':\n return { type: 'order_created', data: contentsData(properties) };\n case 'generate_lead':\n case 'qualify_lead':\n return { type: 'lead_created', data: customerActionData(properties) };\n case 'sign_up':\n case 'login':\n return { type: 'registration_completed', data: customerActionData(properties) };\n case 'schedule':\n return { type: 'appointment_scheduled', data: customerActionData(properties) };\n case 'subscribe':\n return { type: 'subscription_created', data: planEnrollmentData(properties) };\n case 'trial_begin':\n return { type: 'trial_started', data: planEnrollmentData(properties) };\n default: {\n const currency = readCurrency(properties);\n return {\n type: 'custom',\n data: {\n type: 'custom',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(readItems(properties), currency),\n },\n };\n }\n }\n}\n"],"mappings":";AAGA,MAAa,gBAAgB;CAE3B;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;AACF;;;;;;;AA4HA,MAAM,0CAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,2CAA2B,IAAI,IAAI;CAAC;CAAO;CAAO;CAAO;CAA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,SAAS;GACP,MAAM,WAAW,aAAa,UAAU;GACxC,OAAO;IACL,MAAM;IACN,MAAM;KACJ,MAAM;KACN,QAAQ,aAAa,UAAU,UAAU,GAAG,QAAQ;KACpD,UAAU,UAAU,YAAY;KAChC,UAAU,YAAY,UAAU,UAAU,GAAG,QAAQ;IACvD;GACF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"oaiq.mjs","names":[],"sources":["../../src/track/oaiq.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\nexport const NON_AD_EVENTS = [\n // metrics\n 'CLS',\n 'FCP',\n 'FID',\n 'INP',\n 'LCP',\n 'TTFB',\n // promotions\n 'view_promotion',\n 'select_promotion',\n];\n\n/**\n * Content item shared by `contents` and `plan_enrollment` events.\n * https://developers.openai.com/ads/supported-events\n */\nexport type ContentItem = {\n id?: string;\n name?: string;\n content_type?: string;\n quantity?: number;\n /** Per-item monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */\n amount?: number;\n currency?: string;\n};\n\nexport type ContentsData = {\n type: 'contents';\n /** Monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type CustomerActionData = {\n type: 'customer_action';\n amount?: number;\n currency?: string;\n};\n\nexport type PlanEnrollmentData = {\n type: 'plan_enrollment';\n plan_id?: string;\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type CustomEventData = {\n type: 'custom';\n amount?: number;\n currency?: string;\n contents?: ContentItem[];\n};\n\nexport type EventData = ContentsData | CustomerActionData | PlanEnrollmentData | CustomEventData;\n\n/**\n * Standard event names and the `data` shape each one expects.\n * https://developers.openai.com/ads/supported-events\n */\nexport type StandardEvents = {\n appointment_scheduled: CustomerActionData;\n checkout_started: ContentsData;\n contents_viewed: ContentsData;\n items_added: ContentsData;\n lead_created: CustomerActionData;\n order_created: ContentsData;\n page_viewed: ContentsData;\n registration_completed: CustomerActionData;\n subscription_created: PlanEnrollmentData;\n trial_started: PlanEnrollmentData;\n};\n\nexport type StandardEvent = keyof StandardEvents;\n\n/**\n * Identity fields passed to `oaiq(\"init\", ...)` for conversion matching. Email and external id\n * must be pre-hashed as lowercase 64-char SHA-256 hex strings; the rest are sent as raw values.\n * https://developers.openai.com/ads/measurement-pixel\n */\nexport type OAIQUser = {\n email_sha256?: string;\n external_id_sha256?: string;\n /** Two-letter ISO 3166-1 country code (e.g. \"US\"). */\n country?: string;\n /** Lowercased, max 128 characters. */\n city?: string;\n /** Max 32 characters. */\n zip_code?: string;\n};\n\nexport type InitConfig = {\n pixelId: string;\n /** Log SDK activity to the browser console. */\n debug?: boolean;\n user?: OAIQUser;\n};\n\n/**\n * Fourth argument of `oaiq(\"measure\", ...)`. Required for custom events (carries\n * `custom_event_name`); optional for standard events.\n */\nexport type MeasureOptions = {\n /** Shared with the Conversions API to deduplicate the same conversion across browser and server. */\n event_id?: string;\n /** Required for custom events; 1-64 chars of letters, numbers, underscores, or dashes. */\n custom_event_name?: string;\n /** When true, opts the event out of user-level personalization. */\n opt_out?: boolean;\n};\n\nexport interface OAIQ {\n oaiq(command: 'init', config: InitConfig): void;\n oaiq<T extends StandardEvent>(\n command: 'measure',\n event: T,\n data: StandardEvents[T],\n options?: MeasureOptions\n ): void;\n oaiq(\n command: 'measure',\n event: 'custom',\n data: CustomEventData,\n options: MeasureOptions & { custom_event_name: string }\n ): void;\n}\n\n/**\n * Currencies whose minor unit has 0 or 3 decimal places; everything else uses 2.\n * Follows Stripe's zero-decimal convention (e.g., MGA is treated as 0, ISK is included),\n * which can differ from strict ISO 4217 exponents.\n * https://docs.stripe.com/currencies#zero-decimal\n */\nconst ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'ISK',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst THREE_DECIMAL_CURRENCIES = new Set(['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND']);\n\n/** Convert a major-unit amount (e.g., 129.99) into ISO 4217 minor units (e.g., 12,999). */\nexport function toMinorUnits(value?: number | null, currency?: string): number | undefined {\n if (value === undefined || value === null || Number.isNaN(value)) return undefined;\n const code = currency?.toUpperCase();\n const exponent =\n code && ZERO_DECIMAL_CURRENCIES.has(code)\n ? 0\n : code && THREE_DECIMAL_CURRENCIES.has(code)\n ? 3\n : 2;\n return Math.round(value * 10 ** exponent);\n}\n\nexport function mapContents(items?: Item[], currency?: string): ContentItem[] | undefined {\n if (!items || items.length === 0) return undefined;\n const code = currency?.toUpperCase();\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n content_type: item.item_category,\n quantity: item.quantity,\n amount: toMinorUnits(item.price, currency),\n currency: item.price !== undefined ? code : undefined,\n }));\n}\n\n/** Safely read a property off loosely typed track properties without widening to `any`. */\nfunction prop(properties: unknown, key: string): unknown {\n return typeof properties === 'object' && properties !== null\n ? (properties as Record<string, unknown>)[key]\n : undefined;\n}\n\nfunction readValue(properties: unknown): number | undefined {\n const value = prop(properties, 'value');\n return typeof value === 'number' ? value : undefined;\n}\n\nfunction readCurrency(properties: unknown): string | undefined {\n const currency = prop(properties, 'currency');\n return typeof currency === 'string' ? currency : undefined;\n}\n\nfunction readItems(properties: unknown): Item[] | undefined {\n const items = prop(properties, 'items');\n return Array.isArray(items) ? (items as Item[]) : undefined;\n}\n\nfunction contentsData(properties: unknown): ContentsData {\n const currency = readCurrency(properties);\n return {\n type: 'contents',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(readItems(properties), currency),\n };\n}\n\nfunction customerActionData(properties: unknown): CustomerActionData {\n const currency = readCurrency(properties);\n return {\n type: 'customer_action',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n };\n}\n\nfunction planEnrollmentData(properties: unknown): PlanEnrollmentData {\n const currency = readCurrency(properties);\n const items = readItems(properties);\n return {\n type: 'plan_enrollment',\n plan_id: items?.[0]?.item_id,\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(items, currency),\n };\n}\n\nexport type MappedOAIEvent = {\n type: StandardEvent | 'custom';\n data: EventData;\n};\n\n/** Map an internal track event onto an OpenAI standard (or custom) conversion event. */\nexport function mapOAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n): MappedOAIEvent {\n switch (name) {\n case 'page_view':\n return { type: 'page_viewed', data: contentsData(properties) };\n case 'view_item':\n case 'view_item_list':\n return { type: 'contents_viewed', data: contentsData(properties) };\n case 'begin_checkout':\n return { type: 'checkout_started', data: contentsData(properties) };\n case 'add_to_cart':\n return { type: 'items_added', data: contentsData(properties) };\n case 'purchase':\n return { type: 'order_created', data: contentsData(properties) };\n case 'generate_lead':\n case 'qualify_lead':\n return { type: 'lead_created', data: customerActionData(properties) };\n case 'sign_up':\n case 'login':\n return { type: 'registration_completed', data: customerActionData(properties) };\n case 'schedule':\n return { type: 'appointment_scheduled', data: customerActionData(properties) };\n case 'subscribe':\n return { type: 'subscription_created', data: planEnrollmentData(properties) };\n case 'trial_begin':\n return { type: 'trial_started', data: planEnrollmentData(properties) };\n default: {\n const currency = readCurrency(properties);\n return {\n type: 'custom',\n data: {\n type: 'custom',\n amount: toMinorUnits(readValue(properties), currency),\n currency: currency?.toUpperCase(),\n contents: mapContents(readItems(properties), currency),\n },\n };\n }\n }\n}\n"],"mappings":";AAGA,MAAa,gBAAgB;CAE3B;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;AACF;;;;;;;AA4HA,MAAM,0CAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,2CAA2B,IAAI,I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,MAAM,mBAAmB,UAAU;EAAE;EACvE,SAAS;GACP,MAAM,WAAW,aAAa,UAAU;GACxC,OAAO;IACL,MAAM;IACN,MAAM;KACJ,MAAM;KACN,QAAQ,aAAa,UAAU,UAAU,GAAG,QAAQ;KACpD,UAAU,UAAU,YAAY;KAChC,UAAU,YAAY,UAAU,UAAU,GAAG,QAAQ;IACvD;GACF;EACF;CACF;AACF"}
|
package/dist/track/rdt.cjs
CHANGED
|
@@ -18,7 +18,7 @@ function mapRDTEvent(name, properties, eventId) {
|
|
|
18
18
|
conversionId: eventId,
|
|
19
19
|
value: p?.value,
|
|
20
20
|
currency: p?.currency.toUpperCase(),
|
|
21
|
-
itemCount: p?.items
|
|
21
|
+
itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),
|
|
22
22
|
products: mapItems(p?.items)
|
|
23
23
|
}];
|
|
24
24
|
} else if (name === "add_to_wishlist") {
|
|
@@ -27,7 +27,7 @@ function mapRDTEvent(name, properties, eventId) {
|
|
|
27
27
|
conversionId: eventId,
|
|
28
28
|
value: p?.value,
|
|
29
29
|
currency: p?.currency.toUpperCase(),
|
|
30
|
-
itemCount: p?.items
|
|
30
|
+
itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),
|
|
31
31
|
products: mapItems(p?.items)
|
|
32
32
|
}];
|
|
33
33
|
} else if (name === "purchase") {
|
|
@@ -62,8 +62,7 @@ function mapServerStandardEvent(name) {
|
|
|
62
62
|
if (name === "AddToWishlist") return "ADD_TO_WISHLIST";
|
|
63
63
|
if (name === "Purchase") return "PURCHASE";
|
|
64
64
|
if (name === "Lead") return "LEAD";
|
|
65
|
-
|
|
66
|
-
throw new Error(`Unsupported standard event: ${String(name)}`);
|
|
65
|
+
return "SIGN_UP";
|
|
67
66
|
}
|
|
68
67
|
//#endregion
|
|
69
68
|
exports.mapItems = mapItems;
|
package/dist/track/rdt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdt.cjs","names":[],"sources":["../../src/track/rdt.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\n/** https://business.reddithelp.com/s/article/about-event-metadata */\nexport type Product = {\n /**\n * (Required) Product ID: Either the SKU or GTIN, which represents the variant ID, not the\n * parent ID. If there are no variants, pass the assigned ID for that item.\n */\n id: string;\n\n /** (Optional) Product Category: The group the product belongs to. */\n name?: string;\n\n /** (Optional) Product Name: The title of the product. */\n category?: string;\n};\n\n/**\n * https://business.reddithelp.com/s/article/supported-conversion-events#supported-conversion-events\n * https://business.reddithelp.com/s/article/about-event-metadata\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport type StandardEvents = {\n PageVisit: {\n conversionId?: string;\n products?: Product[];\n };\n ViewContent: {\n conversionId?: string;\n products?: Product[];\n };\n Search: {\n conversionId?: string;\n products?: Product[];\n };\n AddToCart: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n AddToWishlist: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Purchase: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Lead: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n SignUp: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n};\n\nexport type PixelId = `a2_${string}`;\n\nexport type MatchKeys = {\n email?: string;\n phoneNumber?: string;\n externalId?: string;\n idfa?: string;\n aaid?: string;\n};\n\nexport type CustomEventParams<T extends string = string> = {\n customEventName: T;\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n};\n\nexport interface RDT {\n rdt(event: 'init', pixelId: PixelId, matchKeys?: MatchKeys): void;\n\n rdt<T extends keyof StandardEvents>(event: 'track', type: T, params?: StandardEvents[T]): void;\n\n rdt(event: 'track', type: 'Custom', params: CustomEventParams): void;\n}\n\ntype Mapped<F extends keyof StandardEvents> = [F, StandardEvents[F]];\ntype Missed<F extends string> = ['Custom', CustomEventParams<F>];\n\nexport function mapItems(items?: Item[]): undefined | Product[] {\n if (!items || items.length === 0) return undefined;\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n category: item.item_category,\n }));\n}\n\nexport function mapRDTEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n): Mapped<keyof StandardEvents> | Missed<TrackName<T>> {\n // standard events\n if (name === 'page_view') {\n return ['PageVisit', { conversionId: eventId }];\n } else if (name === 'view_item') {\n return ['ViewContent', { conversionId: eventId }];\n } else if (name === 'search') {\n return ['Search', { conversionId: eventId }];\n } else if (name === 'add_to_cart') {\n const p = properties as TrackProperties<'add_to_cart'> | undefined;\n return [\n 'AddToCart',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items
|
|
1
|
+
{"version":3,"file":"rdt.cjs","names":[],"sources":["../../src/track/rdt.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\n/** https://business.reddithelp.com/s/article/about-event-metadata */\nexport type Product = {\n /**\n * (Required) Product ID: Either the SKU or GTIN, which represents the variant ID, not the\n * parent ID. If there are no variants, pass the assigned ID for that item.\n */\n id: string;\n\n /** (Optional) Product Category: The group the product belongs to. */\n name?: string;\n\n /** (Optional) Product Name: The title of the product. */\n category?: string;\n};\n\n/**\n * https://business.reddithelp.com/s/article/supported-conversion-events#supported-conversion-events\n * https://business.reddithelp.com/s/article/about-event-metadata\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport type StandardEvents = {\n PageVisit: {\n conversionId?: string;\n products?: Product[];\n };\n ViewContent: {\n conversionId?: string;\n products?: Product[];\n };\n Search: {\n conversionId?: string;\n products?: Product[];\n };\n AddToCart: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n AddToWishlist: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Purchase: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Lead: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n SignUp: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n};\n\nexport type PixelId = `a2_${string}`;\n\nexport type MatchKeys = {\n email?: string;\n phoneNumber?: string;\n externalId?: string;\n idfa?: string;\n aaid?: string;\n};\n\nexport type CustomEventParams<T extends string = string> = {\n customEventName: T;\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n};\n\nexport interface RDT {\n rdt(event: 'init', pixelId: PixelId, matchKeys?: MatchKeys): void;\n\n rdt<T extends keyof StandardEvents>(event: 'track', type: T, params?: StandardEvents[T]): void;\n\n rdt(event: 'track', type: 'Custom', params: CustomEventParams): void;\n}\n\ntype Mapped<F extends keyof StandardEvents> = [F, StandardEvents[F]];\ntype Missed<F extends string> = ['Custom', CustomEventParams<F>];\n\nexport function mapItems(items?: Item[]): undefined | Product[] {\n if (!items || items.length === 0) return undefined;\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n category: item.item_category,\n }));\n}\n\nexport function mapRDTEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n): Mapped<keyof StandardEvents> | Missed<TrackName<T>> {\n // standard events\n if (name === 'page_view') {\n return ['PageVisit', { conversionId: eventId }];\n } else if (name === 'view_item') {\n return ['ViewContent', { conversionId: eventId }];\n } else if (name === 'search') {\n return ['Search', { conversionId: eventId }];\n } else if (name === 'add_to_cart') {\n const p = properties as TrackProperties<'add_to_cart'> | undefined;\n return [\n 'AddToCart',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'add_to_wishlist') {\n const p = properties as TrackProperties<'add_to_wishlist'> | undefined;\n return [\n 'AddToWishlist',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'purchase') {\n const p = properties as TrackProperties<'purchase'> | undefined;\n return [\n 'Purchase',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items?.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'generate_lead') {\n const p = properties as TrackProperties<'generate_lead'> | undefined;\n return [\n 'Lead',\n { conversionId: eventId, value: p?.value, currency: p?.currency.toUpperCase() },\n ];\n } else if (name === 'sign_up' || name === 'login') {\n return ['SignUp', { conversionId: eventId }];\n } else {\n // custom event\n return [\n 'Custom',\n {\n customEventName: name,\n conversionId: eventId,\n value:\n properties && 'value' in properties && typeof properties.value === 'number'\n ? properties.value\n : undefined,\n currency:\n properties && 'currency' in properties && typeof properties.currency === 'string'\n ? properties.currency.toUpperCase()\n : undefined,\n },\n ];\n }\n}\n\nexport type ServerStandardEvent =\n | 'PAGE_VISIT'\n | 'VIEW_CONTENT'\n | 'SEARCH'\n | 'ADD_TO_CART'\n | 'ADD_TO_WISHLIST'\n | 'PURCHASE'\n | 'LEAD'\n | 'SIGN_UP';\n\nexport function mapServerStandardEvent(name: keyof StandardEvents): ServerStandardEvent {\n if (name === 'PageVisit') return 'PAGE_VISIT';\n if (name === 'ViewContent') return 'VIEW_CONTENT';\n if (name === 'Search') return 'SEARCH';\n if (name === 'AddToCart') return 'ADD_TO_CART';\n if (name === 'AddToWishlist') return 'ADD_TO_WISHLIST';\n if (name === 'Purchase') return 'PURCHASE';\n if (name === 'Lead') return 'LEAD';\n // `name` is narrowed to 'SignUp' here, so the mapping is exhaustive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ACL,QACA;GAAE,cAAc;GAAS,OAAO,GAAG;GAAO,UAAU,GAAG,SAAS,YAAY;EAAE,CAChF;CACF,OAAO,IAAI,SAAS,aAAa,SAAS,SACxC,OAAO,CAAC,UAAU,EAAE,cAAc,QAAQ,CAAC;MAG3C,OAAO,CACL,UACA;EACE,iBAAiB;EACjB,cAAc;EACd,OACE,cAAc,WAAW,cAAc,OAAO,WAAW,UAAU,WAC/D,WAAW,QACX,KAAA;EACN,UACE,cAAc,cAAc,cAAc,OAAO,WAAW,aAAa,WACrE,WAAW,SAAS,YAAY,IAChC,KAAA;CACR,CACF;AAEJ;AAYA,SAAgB,uBAAuB,MAAiD;CACtF,IAAI,SAAS,aAAa,OAAO;CACjC,IAAI,SAAS,eAAe,OAAO;CACnC,IAAI,SAAS,UAAU,OAAO;CAC9B,IAAI,SAAS,aAAa,OAAO;CACjC,IAAI,SAAS,iBAAiB,OAAO;CACrC,IAAI,SAAS,YAAY,OAAO;CAChC,IAAI,SAAS,QAAQ,OAAO;CAE5B,OAAO;AACT"}
|
package/dist/track/rdt.mjs
CHANGED
|
@@ -17,7 +17,7 @@ function mapRDTEvent(name, properties, eventId) {
|
|
|
17
17
|
conversionId: eventId,
|
|
18
18
|
value: p?.value,
|
|
19
19
|
currency: p?.currency.toUpperCase(),
|
|
20
|
-
itemCount: p?.items
|
|
20
|
+
itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),
|
|
21
21
|
products: mapItems(p?.items)
|
|
22
22
|
}];
|
|
23
23
|
} else if (name === "add_to_wishlist") {
|
|
@@ -26,7 +26,7 @@ function mapRDTEvent(name, properties, eventId) {
|
|
|
26
26
|
conversionId: eventId,
|
|
27
27
|
value: p?.value,
|
|
28
28
|
currency: p?.currency.toUpperCase(),
|
|
29
|
-
itemCount: p?.items
|
|
29
|
+
itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),
|
|
30
30
|
products: mapItems(p?.items)
|
|
31
31
|
}];
|
|
32
32
|
} else if (name === "purchase") {
|
|
@@ -61,8 +61,7 @@ function mapServerStandardEvent(name) {
|
|
|
61
61
|
if (name === "AddToWishlist") return "ADD_TO_WISHLIST";
|
|
62
62
|
if (name === "Purchase") return "PURCHASE";
|
|
63
63
|
if (name === "Lead") return "LEAD";
|
|
64
|
-
|
|
65
|
-
throw new Error(`Unsupported standard event: ${String(name)}`);
|
|
64
|
+
return "SIGN_UP";
|
|
66
65
|
}
|
|
67
66
|
//#endregion
|
|
68
67
|
export { mapItems, mapRDTEvent, mapServerStandardEvent };
|
package/dist/track/rdt.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdt.mjs","names":[],"sources":["../../src/track/rdt.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\n/** https://business.reddithelp.com/s/article/about-event-metadata */\nexport type Product = {\n /**\n * (Required) Product ID: Either the SKU or GTIN, which represents the variant ID, not the\n * parent ID. If there are no variants, pass the assigned ID for that item.\n */\n id: string;\n\n /** (Optional) Product Category: The group the product belongs to. */\n name?: string;\n\n /** (Optional) Product Name: The title of the product. */\n category?: string;\n};\n\n/**\n * https://business.reddithelp.com/s/article/supported-conversion-events#supported-conversion-events\n * https://business.reddithelp.com/s/article/about-event-metadata\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport type StandardEvents = {\n PageVisit: {\n conversionId?: string;\n products?: Product[];\n };\n ViewContent: {\n conversionId?: string;\n products?: Product[];\n };\n Search: {\n conversionId?: string;\n products?: Product[];\n };\n AddToCart: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n AddToWishlist: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Purchase: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Lead: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n SignUp: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n};\n\nexport type PixelId = `a2_${string}`;\n\nexport type MatchKeys = {\n email?: string;\n phoneNumber?: string;\n externalId?: string;\n idfa?: string;\n aaid?: string;\n};\n\nexport type CustomEventParams<T extends string = string> = {\n customEventName: T;\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n};\n\nexport interface RDT {\n rdt(event: 'init', pixelId: PixelId, matchKeys?: MatchKeys): void;\n\n rdt<T extends keyof StandardEvents>(event: 'track', type: T, params?: StandardEvents[T]): void;\n\n rdt(event: 'track', type: 'Custom', params: CustomEventParams): void;\n}\n\ntype Mapped<F extends keyof StandardEvents> = [F, StandardEvents[F]];\ntype Missed<F extends string> = ['Custom', CustomEventParams<F>];\n\nexport function mapItems(items?: Item[]): undefined | Product[] {\n if (!items || items.length === 0) return undefined;\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n category: item.item_category,\n }));\n}\n\nexport function mapRDTEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n): Mapped<keyof StandardEvents> | Missed<TrackName<T>> {\n // standard events\n if (name === 'page_view') {\n return ['PageVisit', { conversionId: eventId }];\n } else if (name === 'view_item') {\n return ['ViewContent', { conversionId: eventId }];\n } else if (name === 'search') {\n return ['Search', { conversionId: eventId }];\n } else if (name === 'add_to_cart') {\n const p = properties as TrackProperties<'add_to_cart'> | undefined;\n return [\n 'AddToCart',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items
|
|
1
|
+
{"version":3,"file":"rdt.mjs","names":[],"sources":["../../src/track/rdt.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\n/** https://business.reddithelp.com/s/article/about-event-metadata */\nexport type Product = {\n /**\n * (Required) Product ID: Either the SKU or GTIN, which represents the variant ID, not the\n * parent ID. If there are no variants, pass the assigned ID for that item.\n */\n id: string;\n\n /** (Optional) Product Category: The group the product belongs to. */\n name?: string;\n\n /** (Optional) Product Name: The title of the product. */\n category?: string;\n};\n\n/**\n * https://business.reddithelp.com/s/article/supported-conversion-events#supported-conversion-events\n * https://business.reddithelp.com/s/article/about-event-metadata\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport type StandardEvents = {\n PageVisit: {\n conversionId?: string;\n products?: Product[];\n };\n ViewContent: {\n conversionId?: string;\n products?: Product[];\n };\n Search: {\n conversionId?: string;\n products?: Product[];\n };\n AddToCart: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n AddToWishlist: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Purchase: {\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n };\n Lead: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n SignUp: {\n value?: number;\n currency?: string;\n conversionId?: string;\n products?: Product[];\n };\n};\n\nexport type PixelId = `a2_${string}`;\n\nexport type MatchKeys = {\n email?: string;\n phoneNumber?: string;\n externalId?: string;\n idfa?: string;\n aaid?: string;\n};\n\nexport type CustomEventParams<T extends string = string> = {\n customEventName: T;\n value?: number;\n currency?: string;\n itemCount?: number;\n conversionId?: string;\n products?: Product[];\n};\n\nexport interface RDT {\n rdt(event: 'init', pixelId: PixelId, matchKeys?: MatchKeys): void;\n\n rdt<T extends keyof StandardEvents>(event: 'track', type: T, params?: StandardEvents[T]): void;\n\n rdt(event: 'track', type: 'Custom', params: CustomEventParams): void;\n}\n\ntype Mapped<F extends keyof StandardEvents> = [F, StandardEvents[F]];\ntype Missed<F extends string> = ['Custom', CustomEventParams<F>];\n\nexport function mapItems(items?: Item[]): undefined | Product[] {\n if (!items || items.length === 0) return undefined;\n return items.map((item) => ({\n id: item.item_id,\n name: item.item_name,\n category: item.item_category,\n }));\n}\n\nexport function mapRDTEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n): Mapped<keyof StandardEvents> | Missed<TrackName<T>> {\n // standard events\n if (name === 'page_view') {\n return ['PageVisit', { conversionId: eventId }];\n } else if (name === 'view_item') {\n return ['ViewContent', { conversionId: eventId }];\n } else if (name === 'search') {\n return ['Search', { conversionId: eventId }];\n } else if (name === 'add_to_cart') {\n const p = properties as TrackProperties<'add_to_cart'> | undefined;\n return [\n 'AddToCart',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'add_to_wishlist') {\n const p = properties as TrackProperties<'add_to_wishlist'> | undefined;\n return [\n 'AddToWishlist',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'purchase') {\n const p = properties as TrackProperties<'purchase'> | undefined;\n return [\n 'Purchase',\n {\n conversionId: eventId,\n value: p?.value,\n currency: p?.currency.toUpperCase(),\n itemCount: p?.items?.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n products: mapItems(p?.items),\n },\n ];\n } else if (name === 'generate_lead') {\n const p = properties as TrackProperties<'generate_lead'> | undefined;\n return [\n 'Lead',\n { conversionId: eventId, value: p?.value, currency: p?.currency.toUpperCase() },\n ];\n } else if (name === 'sign_up' || name === 'login') {\n return ['SignUp', { conversionId: eventId }];\n } else {\n // custom event\n return [\n 'Custom',\n {\n customEventName: name,\n conversionId: eventId,\n value:\n properties && 'value' in properties && typeof properties.value === 'number'\n ? properties.value\n : undefined,\n currency:\n properties && 'currency' in properties && typeof properties.currency === 'string'\n ? properties.currency.toUpperCase()\n : undefined,\n },\n ];\n }\n}\n\nexport type ServerStandardEvent =\n | 'PAGE_VISIT'\n | 'VIEW_CONTENT'\n | 'SEARCH'\n | 'ADD_TO_CART'\n | 'ADD_TO_WISHLIST'\n | 'PURCHASE'\n | 'LEAD'\n | 'SIGN_UP';\n\nexport function mapServerStandardEvent(name: keyof StandardEvents): ServerStandardEvent {\n if (name === 'PageVisit') return 'PAGE_VISIT';\n if (name === 'ViewContent') return 'VIEW_CONTENT';\n if (name === 'Search') return 'SEARCH';\n if (name === 'AddToCart') return 'ADD_TO_CART';\n if (name === 'AddToWishlist') return 'ADD_TO_WISHLIST';\n if (name === 'Purchase') return 'PURCHASE';\n if (name === 'Lead') return 'LEAD';\n // `name` is narrowed to 'SignUp' here, so the mapping is exhaustive\n return 'SIGN_UP';\n}\n"],"mappings":";AAqGA,SAAgB,SAAS,OAAuC;CAC9D,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,OAAO,KAAA;CACzC,OAAO,MAAM,KAAK,UAAU;EAC1B,IAAI,KAAK;EACT,MAAM,KAAK;EACX,UAAU,KAAK;CACjB,EAAE;AACJ;AAEA,SAAgB,YACd,MACA,YACA,SACqD;CAErD,IAAI,SAAS,aACX,OAAO,CAAC,aAAa,EAAE,cAAc,QAAQ,CAAC;MACzC,IAAI,SAAS,aAClB,OAAO,CAAC,eAAe,EAAE,cAAc,QAAQ,CAAC;MAC3C,IAAI,SAAS,UAClB,OAAO,CAAC,UAAU,EAAE,cAAc,QAAQ,CAAC;MACtC,IAAI,SAAS,eAAe;EACjC,MAAM,IAAI;EACV,OAAO,CACL,aACA;GACE,cAAc;GACd,OAAO,GAAG;GACV,UAAU,GAAG,SAAS,YAAY;GAClC,WAAW,GAAG,MAAM,QAAQ,KAAK,MAAM,OAAO,EAAE,YAAY,IAAI,CAAC;GACjE,UAAU,SAAS,GAAG,KAAK;EAC7B,CACF;CACF,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,IAAI;EACV,OAAO,CACL,iBACA;GACE,cAAc;GACd,OAAO,GAAG;GACV,UAAU,GAAG,SAAS,YAAY;GAClC,WAAW,GAAG,MAAM,QAAQ,KAAK,MAAM,OAAO,EAAE,YAAY,IAAI,CAAC;GACjE,UAAU,SAAS,GAAG,KAAK;EAC7B,CACF;CACF,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,IAAI;EACV,OAAO,CACL,YACA;GACE,cAAc;GACd,OAAO,GAAG;GACV,UAAU,GAAG,SAAS,YAAY;GAClC,WAAW,GAAG,OAAO,QAAQ,KAAK,MAAM,OAAO,EAAE,YAAY,IAAI,CAAC;GAClE,UAAU,SAAS,GAAG,KAAK;EAC7B,CACF;CACF,OAAO,IAAI,SAAS,iBAAiB;EACnC,MAAM,IAAI;EACV,OAAO,CACL,QACA;GAAE,cAAc;GAAS,OAAO,GAAG;GAAO,UAAU,GAAG,SAAS,YAAY;EAAE,CAChF;CACF,OAAO,IAAI,SAAS,aAAa,SAAS,SACxC,OAAO,CAAC,UAAU,EAAE,cAAc,QAAQ,CAAC;MAG3C,OAAO,CACL,UACA;EACE,iBAAiB;EACjB,cAAc;EACd,OACE,cAAc,WAAW,cAAc,OAAO,WAAW,UAAU,WAC/D,WAAW,QACX,KAAA;EACN,UACE,cAAc,cAAc,cAAc,OAAO,WAAW,aAAa,WACrE,WAAW,SAAS,YAAY,IAChC,KAAA;CACR,CACF;AAEJ;AAYA,SAAgB,uBAAuB,MAAiD;CACtF,IAAI,SAAS,aAAa,OAAO;CACjC,IAAI,SAAS,eAAe,OAAO;CACnC,IAAI,SAAS,UAAU,OAAO;CAC9B,IAAI,SAAS,aAAa,OAAO;CACjC,IAAI,SAAS,iBAAiB,OAAO;CACrC,IAAI,SAAS,YAAY,OAAO;CAChC,IAAI,SAAS,QAAQ,OAAO;CAE5B,OAAO;AACT"}
|
package/dist/track/types.d.cts
CHANGED
|
@@ -40,8 +40,6 @@ interface PlatformInfo {
|
|
|
40
40
|
browser?: string;
|
|
41
41
|
browser_name?: string;
|
|
42
42
|
browser_version?: string;
|
|
43
|
-
/** @deprecated */
|
|
44
|
-
platform: Platform;
|
|
45
43
|
}
|
|
46
44
|
interface DeviceInfo {
|
|
47
45
|
device?: string;
|
|
@@ -63,8 +61,6 @@ interface EnvironmentInfo {
|
|
|
63
61
|
release?: string;
|
|
64
62
|
language?: string;
|
|
65
63
|
time_zone?: string;
|
|
66
|
-
/** @deprecated */
|
|
67
|
-
environment: Environment;
|
|
68
64
|
}
|
|
69
65
|
interface SourceInfo {
|
|
70
66
|
source_url?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/track/types.ts"],"mappings":";;KAEY;KACA,YAAY;KAEZ,UAAU,UAAU,YAAY,aAAa,gBAAgB,iBACrE,IACA;KACQ,gBAAgB,UAAU,YAAY,aAAa,gBAAgB,iBAC3E,eAAe,KACf,OAAO,mBAAmB;KAElB;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,yBAAyB;EACxC;EACA;EACA;EACA;EACA;IAAa;IAAc;IAAe;;EAE1C;EACA;;KAGU,qBAAqB,UAAU,WACzC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/track/types.ts"],"mappings":";;KAEY;KACA,YAAY;KAEZ,UAAU,UAAU,YAAY,aAAa,gBAAgB,iBACrE,IACA;KACQ,gBAAgB,UAAU,YAAY,aAAa,gBAAgB,iBAC3E,eAAe,KACf,OAAO,mBAAmB;KAElB;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,yBAAyB;EACxC;EACA;EACA;EACA;EACA;IAAa;IAAc;IAAe;;EAE1C;EACA;;KAGU,qBAAqB,UAAU,WACzC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;;;;;;;EAOf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;;EAEA;EACA;;EAEA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;UAQe;;EAEf;;;;;;;;;;;;EAqCA;;;;;;EAuDA;;EAMA;;EAEA;;EAEA;;EAEA;;EAUA;;EAEA;;UAGe,kBAEb,cACA,YACA,SACA,iBACA,YACA,iBACA;EACF;GACC;;UAGc,WAAW,UAAU,YAAY;EAChD;EACA,MAAM,UAAU;EAChB,MAAM;EACN;EACA;EACA,UAAU;EACV,aAAa;EACb,aAAa,gBAAgB;EAC7B;;KAGU;;EAEV"}
|
package/dist/track/types.d.mts
CHANGED
|
@@ -40,8 +40,6 @@ interface PlatformInfo {
|
|
|
40
40
|
browser?: string;
|
|
41
41
|
browser_name?: string;
|
|
42
42
|
browser_version?: string;
|
|
43
|
-
/** @deprecated */
|
|
44
|
-
platform: Platform;
|
|
45
43
|
}
|
|
46
44
|
interface DeviceInfo {
|
|
47
45
|
device?: string;
|
|
@@ -63,8 +61,6 @@ interface EnvironmentInfo {
|
|
|
63
61
|
release?: string;
|
|
64
62
|
language?: string;
|
|
65
63
|
time_zone?: string;
|
|
66
|
-
/** @deprecated */
|
|
67
|
-
environment: Environment;
|
|
68
64
|
}
|
|
69
65
|
interface SourceInfo {
|
|
70
66
|
source_url?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/track/types.ts"],"mappings":";;KAEY;KACA,YAAY;KAEZ,UAAU,UAAU,YAAY,aAAa,gBAAgB,iBACrE,IACA;KACQ,gBAAgB,UAAU,YAAY,aAAa,gBAAgB,iBAC3E,eAAe,KACf,OAAO,mBAAmB;KAElB;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,yBAAyB;EACxC;EACA;EACA;EACA;EACA;IAAa;IAAc;IAAe;;EAE1C;EACA;;KAGU,qBAAqB,UAAU,WACzC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/track/types.ts"],"mappings":";;KAEY;KACA,YAAY;KAEZ,UAAU,UAAU,YAAY,aAAa,gBAAgB,iBACrE,IACA;KACQ,gBAAgB,UAAU,YAAY,aAAa,gBAAgB,iBAC3E,eAAe,KACf,OAAO,mBAAmB;KAElB;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,yBAAyB;EACxC;EACA;EACA;EACA;EACA;IAAa;IAAc;IAAe;;EAE1C;EACA;;KAGU,qBAAqB,UAAU,WACzC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;;;;;;;EAOf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;;EAEA;EACA;;EAEA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;UAQe;;EAEf;;;;;;;;;;;;EAqCA;;;;;;EAuDA;;EAMA;;EAEA;;EAEA;;EAEA;;EAUA;;EAEA;;UAGe,kBAEb,cACA,YACA,SACA,iBACA,YACA,iBACA;EACF;GACC;;UAGc,WAAW,UAAU,YAAY;EAChD;EACA,MAAM,UAAU;EAChB,MAAM;EACN;EACA;EACA,UAAU;EACV,aAAa;EACb,aAAa,gBAAgB;EAC7B;;KAGU;;EAEV"}
|
package/dist/web/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ var import_es5 = /* @__PURE__ */ require_runtime.__toESM(require_es5$1.default,
|
|
|
11
11
|
function getDeviceId() {
|
|
12
12
|
const cached = localStorage.getItem(require_constants_storage.keys.device_id);
|
|
13
13
|
if (cached) return cached;
|
|
14
|
-
const id = crypto
|
|
14
|
+
const id = crypto.randomUUID ? crypto.randomUUID() : (0, uuid.v4)();
|
|
15
15
|
localStorage.setItem(require_constants_storage.keys.device_id, id);
|
|
16
16
|
return id;
|
|
17
17
|
}
|
package/dist/web/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["keys","Bowser","getLink","config"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem(keys.device_id);\n if (cached) return cached;\n const id = crypto
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["keys","Bowser","getLink","config"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem(keys.device_id);\n if (cached) return cached;\n // lib.dom types `crypto.randomUUID` as always present, but it is missing in\n // insecure contexts and older browsers, so probe it before use.\n const id = (crypto as Partial<Crypto>).randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem(keys.device_id, id);\n return id;\n}\n\nexport async function getTags() {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = parseCookie(document.cookie);\n\n const linkId = params.get('s');\n const link = linkId ? await getLink(linkId) : null;\n\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n // oxlint-disable-next-line typescript/no-deprecated -- required TrackTags field kept for transition compat\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: window.devicePixelRatio,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release: config.release,\n language: navigator.language,\n time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n // oxlint-disable-next-line typescript/no-deprecated -- required TrackTags field kept for transition compat\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.href,\n page_referrer: document.referrer || undefined,\n // Meta Ads — _fbc is set server-side (see @shware/analytics/server resolveClickIdCookies)\n fbc: parsed._fbc ?? undefined,\n fbp: parsed._fbp,\n fbclid: params.get('fbclid') ?? undefined,\n ad_id: params.get('ad_id') ?? undefined,\n ad_name: params.get('ad_name') ?? undefined,\n adset_id: params.get('adset_id') ?? undefined,\n adset_name: params.get('adset_name') ?? undefined,\n campaign_id: params.get('campaign_id') ?? undefined,\n campaign_name: params.get('campaign_name') ?? undefined,\n placement: params.get('placement') ?? undefined,\n site_source_name: params.get('site_source_name') ?? undefined,\n // Google Ads\n gclid: params.get('gclid') ?? undefined,\n gclsrc: params.get('gclsrc') ?? undefined,\n gad_source: params.get('gad_source') ?? undefined,\n gad_campaignid: params.get('gad_campaignid') ?? undefined,\n // Reddit Ads — _rdt_cid is set server-side (see @shware/analytics/server resolveClickIdCookies)\n rdt_cid: params.get('rdt_cid') ?? parsed._rdt_cid ?? undefined,\n rdt_uuid: parsed._rdt_uuid,\n // LinkedIn Ads: get click id from url params or first-party cookie\n li_fat_id: params.get('li_fat_id') ?? parsed.li_fat_id ?? undefined,\n // click ids\n dclid: params.get('dclid') ?? undefined,\n ko_click_id: params.get('ko_click_id') ?? undefined,\n msclkid: params.get('msclkid') ?? undefined,\n sccid: params.get('sccid') ?? undefined,\n ttclid: params.get('ttclid') ?? undefined,\n twclid: params.get('twclid') ?? undefined,\n wbraid: params.get('wbraid') ?? undefined,\n yclid: params.get('yclid') ?? undefined,\n // utm params\n utm_source: link?.utm_source ?? params.get('utm_source') ?? undefined,\n utm_medium: link?.utm_medium ?? params.get('utm_medium') ?? undefined,\n utm_campaign: link?.utm_campaign ?? params.get('utm_campaign') ?? undefined,\n utm_term: link?.utm_term ?? params.get('utm_term') ?? undefined,\n utm_content: link?.utm_content ?? params.get('utm_content') ?? undefined,\n utm_id: link?.utm_id ?? params.get('utm_id') ?? undefined,\n utm_source_platform:\n link?.utm_source_platform ?? params.get('utm_source_platform') ?? undefined,\n utm_creative_format:\n link?.utm_creative_format ?? params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic:\n link?.utm_marketing_tactic ?? params.get('utm_marketing_tactic') ?? undefined,\n };\n\n cache.tags = tags;\n return tags;\n}\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,cAAc;CAC5B,MAAM,SAAS,aAAa,QAAQA,0BAAAA,KAAK,SAAS;CAClD,IAAI,QAAQ,OAAO;CAGnB,MAAM,KAAM,OAA2B,aAAa,OAAO,WAAW,KAAA,GAAA,KAAA,GAAA,CAAW;CACjF,aAAa,QAAQA,0BAAAA,KAAK,WAAW,EAAE;CACvC,OAAO;AACT;AAEA,eAAsB,UAAU;CAC9B,MAAM,SAASC,WAAAA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IAAI,qBAAqB,KAAK,KAAA;EACpE,sBACE,MAAM,wBAAwB,OAAO,IAAI,sBAAsB,KAAK,KAAA;CACxE;CAEA,oBAAA,MAAM,OAAO;CACb,OAAO;AACT;AAEA,MAAM,sBAAM,IAAI,IAAoB;AAEpC,MAAa,UAAmB;CAC9B,UAAU,QAAQ;EAChB,IAAI;GACF,OAAO,aAAa,QAAQ,GAAG;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,UAAU,KAAK,UAAU;EACvB,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF"}
|
package/dist/web/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/web/index.ts"],"mappings":";;;iBAQgB;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/web/index.ts"],"mappings":";;;iBAQgB;iBAUM,WAAO,QAAA;cAwFhB,SAAS"}
|
package/dist/web/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/web/index.ts"],"mappings":";;;iBAQgB;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/web/index.ts"],"mappings":";;;iBAQgB;iBAUM,WAAO,QAAA;cAwFhB,SAAS"}
|
package/dist/web/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var import_es5 = /* @__PURE__ */ __toESM(require_es5(), 1);
|
|
|
10
10
|
function getDeviceId() {
|
|
11
11
|
const cached = localStorage.getItem(keys.device_id);
|
|
12
12
|
if (cached) return cached;
|
|
13
|
-
const id = crypto
|
|
13
|
+
const id = crypto.randomUUID ? crypto.randomUUID() : v4();
|
|
14
14
|
localStorage.setItem(keys.device_id, id);
|
|
15
15
|
return id;
|
|
16
16
|
}
|
package/dist/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["uuidv4","Bowser"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem(keys.device_id);\n if (cached) return cached;\n const id = crypto
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["uuidv4","Bowser"],"sources":["../../src/web/index.ts"],"sourcesContent":["import Bowser from 'bowser';\nimport { parseCookie } from 'cookie';\nimport { v4 as uuidv4 } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { getLink } from '../link/index';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nexport function getDeviceId() {\n const cached = localStorage.getItem(keys.device_id);\n if (cached) return cached;\n // lib.dom types `crypto.randomUUID` as always present, but it is missing in\n // insecure contexts and older browsers, so probe it before use.\n const id = (crypto as Partial<Crypto>).randomUUID ? crypto.randomUUID() : uuidv4();\n localStorage.setItem(keys.device_id, id);\n return id;\n}\n\nexport async function getTags() {\n const parser = Bowser.getParser(window.navigator.userAgent);\n const params = new URLSearchParams(window.location.search);\n const os = parser.getOS();\n const browser = parser.getBrowser();\n const platform = parser.getPlatform();\n const parsed = parseCookie(document.cookie);\n\n const linkId = params.get('s');\n const link = linkId ? await getLink(linkId) : null;\n\n const tags: TrackTags = {\n os: `${os.name} ${os.version}`,\n os_name: os.name,\n os_version: os.version,\n browser: `${browser.name} ${browser.version}`,\n browser_name: browser.name,\n browser_version: browser.version,\n // oxlint-disable-next-line typescript/no-deprecated -- required TrackTags field kept for transition compat\n platform: 'web',\n device: platform.model,\n device_id: getDeviceId(),\n device_type: platform.type,\n device_vendor: platform.vendor,\n device_pixel_ratio: window.devicePixelRatio,\n screen_width: window.screen.width,\n screen_height: window.screen.height,\n screen_resolution: `${window.screen.width}x${window.screen.height}`,\n release: config.release,\n language: navigator.language,\n time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n // oxlint-disable-next-line typescript/no-deprecated -- required TrackTags field kept for transition compat\n environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',\n source: 'web',\n source_url: window.location.href,\n page_referrer: document.referrer || undefined,\n // Meta Ads — _fbc is set server-side (see @shware/analytics/server resolveClickIdCookies)\n fbc: parsed._fbc ?? undefined,\n fbp: parsed._fbp,\n fbclid: params.get('fbclid') ?? undefined,\n ad_id: params.get('ad_id') ?? undefined,\n ad_name: params.get('ad_name') ?? undefined,\n adset_id: params.get('adset_id') ?? undefined,\n adset_name: params.get('adset_name') ?? undefined,\n campaign_id: params.get('campaign_id') ?? undefined,\n campaign_name: params.get('campaign_name') ?? undefined,\n placement: params.get('placement') ?? undefined,\n site_source_name: params.get('site_source_name') ?? undefined,\n // Google Ads\n gclid: params.get('gclid') ?? undefined,\n gclsrc: params.get('gclsrc') ?? undefined,\n gad_source: params.get('gad_source') ?? undefined,\n gad_campaignid: params.get('gad_campaignid') ?? undefined,\n // Reddit Ads — _rdt_cid is set server-side (see @shware/analytics/server resolveClickIdCookies)\n rdt_cid: params.get('rdt_cid') ?? parsed._rdt_cid ?? undefined,\n rdt_uuid: parsed._rdt_uuid,\n // LinkedIn Ads: get click id from url params or first-party cookie\n li_fat_id: params.get('li_fat_id') ?? parsed.li_fat_id ?? undefined,\n // click ids\n dclid: params.get('dclid') ?? undefined,\n ko_click_id: params.get('ko_click_id') ?? undefined,\n msclkid: params.get('msclkid') ?? undefined,\n sccid: params.get('sccid') ?? undefined,\n ttclid: params.get('ttclid') ?? undefined,\n twclid: params.get('twclid') ?? undefined,\n wbraid: params.get('wbraid') ?? undefined,\n yclid: params.get('yclid') ?? undefined,\n // utm params\n utm_source: link?.utm_source ?? params.get('utm_source') ?? undefined,\n utm_medium: link?.utm_medium ?? params.get('utm_medium') ?? undefined,\n utm_campaign: link?.utm_campaign ?? params.get('utm_campaign') ?? undefined,\n utm_term: link?.utm_term ?? params.get('utm_term') ?? undefined,\n utm_content: link?.utm_content ?? params.get('utm_content') ?? undefined,\n utm_id: link?.utm_id ?? params.get('utm_id') ?? undefined,\n utm_source_platform:\n link?.utm_source_platform ?? params.get('utm_source_platform') ?? undefined,\n utm_creative_format:\n link?.utm_creative_format ?? params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic:\n link?.utm_marketing_tactic ?? params.get('utm_marketing_tactic') ?? undefined,\n };\n\n cache.tags = tags;\n return tags;\n}\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n"],"mappings":";;;;;;;;;AAQA,SAAgB,cAAc;CAC5B,MAAM,SAAS,aAAa,QAAQ,KAAK,SAAS;CAClD,IAAI,QAAQ,OAAO;CAGnB,MAAM,KAAM,OAA2B,aAAa,OAAO,WAAW,IAAIA,GAAO;CACjF,aAAa,QAAQ,KAAK,WAAW,EAAE;CACvC,OAAO;AACT;AAEA,eAAsB,UAAU;CAC9B,MAAM,SAASC,WAAAA,QAAO,UAAU,OAAO,UAAU,SAAS;CAC1D,MAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;CACzD,MAAM,KAAK,OAAO,MAAM;CACxB,MAAM,UAAU,OAAO,WAAW;CAClC,MAAM,WAAW,OAAO,YAAY;CACpC,MAAM,SAAS,YAAY,SAAS,MAAM;CAE1C,MAAM,SAAS,OAAO,IAAI,GAAG;CAC7B,MAAM,OAAO,SAAS,MAAM,QAAQ,MAAM,IAAI;CAE9C,MAAM,OAAkB;E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,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/analytics",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"uuid": "^14.0.1",
|
|
131
131
|
"web-vitals": "^5.3.0",
|
|
132
132
|
"zod": "^4.4.3",
|
|
133
|
-
"@shware/utils": "^1.5.
|
|
133
|
+
"@shware/utils": "^1.5.2"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
136
|
"@types/facebook-nodejs-business-sdk": "^24.0.0",
|
|
@@ -143,22 +143,22 @@
|
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"@react-native-firebase/analytics": "^25.1.0",
|
|
146
|
-
"@tanstack/react-router": "^1.170.
|
|
147
|
-
"@tanstack/react-start": "^1.168.
|
|
148
|
-
"expo-application": "^57.0.
|
|
149
|
-
"expo-clipboard": "^57.0.
|
|
150
|
-
"expo-crypto": "^57.0.
|
|
151
|
-
"expo-device": "^57.0.
|
|
152
|
-
"expo-localization": "^57.0.
|
|
153
|
-
"expo-sqlite": "^57.0.
|
|
154
|
-
"expo-tracking-transparency": "^57.0.
|
|
146
|
+
"@tanstack/react-router": "^1.170.18",
|
|
147
|
+
"@tanstack/react-start": "^1.168.32",
|
|
148
|
+
"expo-application": "^57.0.2",
|
|
149
|
+
"expo-clipboard": "^57.0.1",
|
|
150
|
+
"expo-crypto": "^57.0.1",
|
|
151
|
+
"expo-device": "^57.0.1",
|
|
152
|
+
"expo-localization": "^57.0.1",
|
|
153
|
+
"expo-sqlite": "^57.0.1",
|
|
154
|
+
"expo-tracking-transparency": "^57.0.1",
|
|
155
155
|
"facebook-nodejs-business-sdk": "^24.0.1",
|
|
156
|
-
"next": "^16.2.
|
|
157
|
-
"posthog-js": "^1.
|
|
158
|
-
"react": "^19.2.
|
|
156
|
+
"next": "^16.2.11",
|
|
157
|
+
"posthog-js": "^1.406.2",
|
|
158
|
+
"react": "^19.2.8",
|
|
159
159
|
"react-native": "^0.86.0",
|
|
160
160
|
"react-native-fbsdk-next": "^13.4.3",
|
|
161
|
-
"react-native-url-polyfill": "^
|
|
161
|
+
"react-native-url-polyfill": "^4.0.0",
|
|
162
162
|
"react-router": "^8.2.0"
|
|
163
163
|
},
|
|
164
164
|
"peerDependenciesMeta": {
|