@shware/analytics 3.5.2 → 3.6.1
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/server/index.cjs +3 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.mjs +2 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/linkedin-conversions-api.cjs.map +1 -1
- package/dist/server/linkedin-conversions-api.mjs.map +1 -1
- package/dist/server/meta-conversions-api.cjs.map +1 -1
- package/dist/server/meta-conversions-api.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +107 -0
- package/dist/server/openai-conversions-api.cjs.map +1 -0
- package/dist/server/openai-conversions-api.d.cts +47 -0
- package/dist/server/openai-conversions-api.d.ts +47 -0
- package/dist/server/openai-conversions-api.mjs +81 -0
- package/dist/server/openai-conversions-api.mjs.map +1 -0
- package/dist/server/reddit-conversions-api.cjs.map +1 -1
- package/dist/server/reddit-conversions-api.mjs.map +1 -1
- package/dist/tanstack/index.cjs +28 -0
- package/dist/tanstack/index.cjs.map +1 -1
- package/dist/tanstack/index.d.cts +2 -1
- package/dist/tanstack/index.d.ts +2 -1
- package/dist/tanstack/index.mjs +28 -0
- package/dist/tanstack/index.mjs.map +1 -1
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/index.cjs +5 -0
- package/dist/third-parties/index.cjs.map +1 -1
- package/dist/third-parties/index.d.cts +2 -0
- package/dist/third-parties/index.d.ts +2 -0
- package/dist/third-parties/index.mjs +3 -0
- package/dist/third-parties/index.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs.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.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +77 -0
- package/dist/third-parties/openai-pixel.cjs.map +1 -0
- package/dist/third-parties/openai-pixel.d.cts +23 -0
- package/dist/third-parties/openai-pixel.d.ts +23 -0
- package/dist/third-parties/openai-pixel.mjs +51 -0
- package/dist/third-parties/openai-pixel.mjs.map +1 -0
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/track/gtag.cjs.map +1 -1
- package/dist/track/gtag.d.cts +45 -12
- package/dist/track/gtag.d.ts +45 -12
- package/dist/track/gtag.mjs.map +1 -1
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.mjs.map +1 -1
- package/dist/track/oaiq.cjs +169 -0
- package/dist/track/oaiq.cjs.map +1 -0
- package/dist/track/oaiq.d.cts +111 -0
- package/dist/track/oaiq.d.ts +111 -0
- package/dist/track/oaiq.mjs +141 -0
- package/dist/track/oaiq.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/server/openai-conversions-api.ts"],"sourcesContent":["/**\n * OpenAI Conversions API\n * https://developers.openai.com/ads/conversions-api\n * https://developers.openai.com/ads/supported-events\n */\nimport { createHash } from 'crypto';\nimport { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport { type EventData, NON_AD_EVENTS, mapOAIEvent } from '../track/oaiq';\nimport type { TrackEvent, TrackTags, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\n\nconst ENDPOINT = 'https://bzr.openai.com/v1/events';\n\ntype ActionSource =\n | 'web'\n | 'mobile_app'\n | 'offline'\n | 'physical_store'\n | 'phone_call'\n | 'email'\n | 'other';\n\n/**\n * User/identity fields. Email and external id must be sent as lowercase 64-char SHA-256 hex\n * strings; geographic, IP, and user-agent fields are sent as raw values.\n */\nexport interface OpenAIUser {\n email_sha256?: string;\n external_id_sha256?: string;\n /** Two-letter ISO 3166-1 country code (e.g. \"US\"). */\n country?: string;\n city?: string;\n zip_code?: string;\n ip_address?: string;\n user_agent?: string;\n}\n\nexport interface OpenAIEvent {\n /** Unique event id; combined with `type` for deduplication against pixel events. */\n id: string;\n /** Standard event name or `custom`. */\n type: string;\n /** Required when `type` is `custom`. */\n custom_event_name?: string;\n /** Event timestamp in ms; must be within 7 days and no more than 10 minutes in the future. */\n timestamp_ms: number;\n /** Required for `action_source: \"web\"`. */\n source_url?: string;\n action_source?: ActionSource;\n /** OpenAI-provided privacy-preserving identifier. */\n oppref?: string;\n /** When true, opts the event out of personalization. */\n opt_out?: boolean;\n user?: OpenAIUser;\n data: EventData;\n}\n\nexport interface CreateOpenAIEventsDTO {\n /** When true, validates the events without persisting them. */\n validate_only?: boolean;\n events: OpenAIEvent[];\n}\n\nfunction sha256(value: string): string {\n return createHash('sha256').update(value).digest('hex');\n}\n\nfunction mapActionSource(source: TrackTags['source']): ActionSource | undefined {\n switch (source) {\n case 'web':\n return 'web';\n case 'app':\n return 'mobile_app';\n case 'offline':\n return 'offline';\n default:\n return undefined;\n }\n}\n\nfunction getUser(data: UserProvidedData): OpenAIUser | undefined {\n const email = getFirst(data.email)?.trim().toLowerCase();\n const address = getFirst(data.address);\n\n const user: OpenAIUser = {\n email_sha256: email ? sha256(email) : undefined,\n external_id_sha256: data.user_id ? sha256(data.user_id) : undefined,\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n ip_address: data.ip_address,\n user_agent: data.user_agent,\n };\n\n return Object.values(user).some((value) => value !== undefined) ? user : undefined;\n}\n\nexport function getServerEvent(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n event: TrackEvent<any>,\n data: UserProvidedData\n): OpenAIEvent {\n const { type, data: eventData } = mapOAIEvent(event.name, event.properties);\n\n return {\n id: event.tags.idempotency_key ?? event.id.toString(),\n type,\n // For custom events the original track name is the OpenAI custom_event_name; this matches\n // the browser pixel so the two deduplicate. Standard events omit it.\n custom_event_name: type === 'custom' ? event.name : undefined,\n timestamp_ms: Date.now(),\n source_url: event.tags.source_url,\n action_source: mapActionSource(event.tags.source),\n user: getUser(data),\n data: eventData,\n };\n}\n\nexport async function sendEvents(\n apiKey: string,\n pixelId: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {},\n validateOnly = false\n) {\n const dto: CreateOpenAIEventsDTO = {\n validate_only: validateOnly,\n events: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .filter((event) => !NON_AD_EVENTS.includes(event.name))\n .map((event) => getServerEvent(event, data)),\n };\n\n if (dto.events.length === 0) return;\n\n try {\n const response = await fetch(`${ENDPOINT}?pid=${pixelId}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(dto),\n });\n\n if (response.ok) return;\n const { status } = response;\n const message = await response.text();\n console.error(`Failed to send OpenAI conversion, status: ${status}, body: ${message}`);\n } catch (error) {\n console.error('Failed to send OpenAI conversion, network error:', error);\n }\n}\n"],"mappings":";AAKA,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAAyB,eAAe,mBAAmB;AAE3D,SAAS,gBAAgB;AAEzB,IAAM,WAAW;AAoDjB,SAAS,OAAO,OAAuB;AACrC,SAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK;AACxD;AAEA,SAAS,gBAAgB,QAAuD;AAC9E,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,MAAgD;AAjFjE;AAkFE,QAAM,SAAQ,cAAS,KAAK,KAAK,MAAnB,mBAAsB,OAAO;AAC3C,QAAM,UAAU,SAAS,KAAK,OAAO;AAErC,QAAM,OAAm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AAgB;AAAA,QAChB,QAAQ;AAAA,QACR,eAAe,UAAU,MAAM;AAAA,MACjC;AAAA,MACA,MAAM,KAAK,UAAU,GAAG;AAAA,IAC1B,CAAC;AAED,QAAI,SAAS,GAAI;AACjB,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,UAAU,MAAM,SAAS,KAAK;AACpC,YAAQ,MAAM,6CAA6C,MAAM,WAAW,OAAO,EAAE;AAAA,EACvF,SAAS,OAAO;AACd,YAAQ,MAAM,oDAAoD,KAAK;AAAA,EACzE;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/reddit-conversions-api.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport { type ServerStandardEvent, mapRDTEvent, mapServerStandardEvent } from '../track/rdt';\nimport type { TrackEvent, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * https://ads-api.reddit.com/docs/v3/operations/Post%20Conversion%20Events\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport interface RedditEvent {\n /** Match keys: Share user identifiers to match conversions to a Reddit ad engagement. */\n click_id?: string;\n\n /** Unix epoch timestamp in milliseconds, event_at can't be older than seven days. */\n event_at: number;\n\n action_source: 'WEBSITE' | 'APP' | string;\n\n type: {\n tracking_type: ServerStandardEvent | 'CUSTOM';\n custom_event_name?: string;\n };\n\n /**\n * Event metadata\n * Share as much additional information about your conversion event as you'd like. If you're\n * using the Conversions API with the pixel, conversion_id is required for deduplication.\n */\n metadata?: {\n conversion_id?: string;\n currency?: string; // ISO 4217 3-letter currency code\n item_count?: number;\n value?: number;\n products?: { id: string; name?: string; category?: string }[];\n };\n\n user?: {\n email?: string;\n external_id?: string;\n ip_address?: string;\n phone_number?: string;\n user_agent?: string;\n\n /** The Identifier for Advertisers (IDFA) of the user's Apple device. */\n idfa?: string;\n\n /** The Android Advertising ID (AAID) of the user's Android device. */\n aaid?: string;\n /**\n * The value from the first-party Pixel _rdt_uuid cookie on your domain. Note that it is in\n * the {timestamp}.{uuid} format. You may use the full value or just the UUID portion.\n * Example: 1684189007728.7c73f2ae-a433-4d7b-9838-f467da98f48e\n */\n uuid?: string;\n\n screen_dimensions?: { width: number; height: number };\n\n /**\n * A structure of data processing options to specify the processing type for the event\n * https://business.reddithelp.com/s/article/Limited-Data-Use\n */\n data_processing_options?: {\n country: string;\n region: string;\n modes: string[] | ['LDU'];\n };\n };\n}\n\nexport interface CreateRedditEventDTO {\n data: { test_id?: string; events: RedditEvent[] };\n}\n\nexport function getServerEvent(\n //
|
|
1
|
+
{"version":3,"sources":["../../src/server/reddit-conversions-api.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport { type ServerStandardEvent, mapRDTEvent, mapServerStandardEvent } from '../track/rdt';\nimport type { TrackEvent, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * https://ads-api.reddit.com/docs/v3/operations/Post%20Conversion%20Events\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport interface RedditEvent {\n /** Match keys: Share user identifiers to match conversions to a Reddit ad engagement. */\n click_id?: string;\n\n /** Unix epoch timestamp in milliseconds, event_at can't be older than seven days. */\n event_at: number;\n\n action_source: 'WEBSITE' | 'APP' | string;\n\n type: {\n tracking_type: ServerStandardEvent | 'CUSTOM';\n custom_event_name?: string;\n };\n\n /**\n * Event metadata\n * Share as much additional information about your conversion event as you'd like. If you're\n * using the Conversions API with the pixel, conversion_id is required for deduplication.\n */\n metadata?: {\n conversion_id?: string;\n currency?: string; // ISO 4217 3-letter currency code\n item_count?: number;\n value?: number;\n products?: { id: string; name?: string; category?: string }[];\n };\n\n user?: {\n email?: string;\n external_id?: string;\n ip_address?: string;\n phone_number?: string;\n user_agent?: string;\n\n /** The Identifier for Advertisers (IDFA) of the user's Apple device. */\n idfa?: string;\n\n /** The Android Advertising ID (AAID) of the user's Android device. */\n aaid?: string;\n /**\n * The value from the first-party Pixel _rdt_uuid cookie on your domain. Note that it is in\n * the {timestamp}.{uuid} format. You may use the full value or just the UUID portion.\n * Example: 1684189007728.7c73f2ae-a433-4d7b-9838-f467da98f48e\n */\n uuid?: string;\n\n screen_dimensions?: { width: number; height: number };\n\n /**\n * A structure of data processing options to specify the processing type for the event\n * https://business.reddithelp.com/s/article/Limited-Data-Use\n */\n data_processing_options?: {\n country: string;\n region: string;\n modes: string[] | ['LDU'];\n };\n };\n}\n\nexport interface CreateRedditEventDTO {\n data: { test_id?: string; events: RedditEvent[] };\n}\n\nexport function getServerEvent(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n event: TrackEvent<any>,\n data: UserProvidedData\n): RedditEvent {\n const { id, name, properties, tags } = event;\n const [type, params] = mapRDTEvent(name, properties, id);\n\n return {\n click_id: tags.rdt_cid,\n event_at: Date.now(),\n action_source: tags.source === 'web' ? 'WEBSITE' : tags.source === 'app' ? 'APP' : 'UNKNOWN',\n type: {\n tracking_type: type === 'Custom' ? 'CUSTOM' : mapServerStandardEvent(type),\n custom_event_name: type === 'Custom' ? params.customEventName : undefined,\n },\n metadata: {\n conversion_id: id,\n currency:\n 'currency' in params && typeof params.currency === 'string'\n ? params.currency.toUpperCase()\n : undefined,\n item_count:\n 'itemCount' in params && typeof params.itemCount === 'number'\n ? params.itemCount\n : undefined,\n value: 'value' in params && typeof params.value === 'number' ? params.value : undefined,\n products:\n 'products' in params && Array.isArray(params.products) && params.products.length > 0\n ? params.products\n : undefined,\n },\n user: {\n email: getFirst(data.email),\n external_id: data.user_id,\n ip_address: data.ip_address,\n phone_number: getFirst(data.phone_number),\n user_agent: data.user_agent,\n idfa: tags.platform === 'ios' ? tags.advertising_id : undefined,\n aaid: tags.platform === 'android' ? tags.advertising_id : undefined,\n uuid: tags.rdt_uuid,\n screen_dimensions:\n tags.screen_width && tags.screen_height\n ? { width: tags.screen_width, height: tags.screen_height }\n : undefined,\n },\n };\n}\n\nexport async function sendEvents(\n accessToken: string,\n pixelId: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {},\n testId?: string\n) {\n const dto: CreateRedditEventDTO = {\n data: {\n test_id: testId,\n events: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .map((event) => getServerEvent(event, data)),\n },\n };\n\n if (dto.data.events.length === 0) return;\n\n try {\n const response = await fetch(\n `https://ads-api.reddit.com/api/v3/pixels/${pixelId}/conversion_events`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(dto),\n }\n );\n if (response.ok) return;\n const { status } = response;\n const message = await response.text();\n console.error(`Failed to send Reddit conversion, status: ${status}, body: ${message}`);\n } catch (error) {\n console.error('Failed to send Reddit conversion, network error:', error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,4BAA+B;AAC/B,iBAA8E;AAE9E,mBAAyB;AAsElB,SAAS,eAEd,OACA,MACa;AACb,QAAM,EAAE,IAAI,MAAM,YAAY,KAAK,IAAI;AACvC,QAAM,CAAC,MAAM,MAAM,QAAI,wBAAY,MAAM,YAAY,EAAE;AAEvD,SAAO;AAAA,IACL,UAAU,KAAK;AAAA,IACf,UAAU,KAAK,IAAI;AAAA,IACnB,eAAe,KAAK,WAAW,QAAQ,YAAY,KAAK,WAAW,QAAQ,QAAQ;AAAA,IACnF,MAAM;AAAA,MACJ,eAAe,SAAS,WAAW,eAAW,mCAAuB,IAAI;AAAA,MACzE,mBAAmB,SAAS,WAAW,OAAO,kBAAkB;AAAA,IAClE;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,MACf,UACE,cAAc,UAAU,OAAO,OAAO,aAAa,WAC/C,OAAO,SAAS,YAAY,IAC5B;AAAA,M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,EAAE,OAAO,IAAI;AACnB,UAAM,UAAU,MAAM,SAAS,KAAK;AACpC,YAAQ,MAAM,6CAA6C,MAAM,WAAW,OAAO,EAAE;AAAA,EACvF,SAAS,OAAO;AACd,YAAQ,MAAM,oDAAoD,KAAK;AAAA,EACzE;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/reddit-conversions-api.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport { type ServerStandardEvent, mapRDTEvent, mapServerStandardEvent } from '../track/rdt';\nimport type { TrackEvent, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * https://ads-api.reddit.com/docs/v3/operations/Post%20Conversion%20Events\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport interface RedditEvent {\n /** Match keys: Share user identifiers to match conversions to a Reddit ad engagement. */\n click_id?: string;\n\n /** Unix epoch timestamp in milliseconds, event_at can't be older than seven days. */\n event_at: number;\n\n action_source: 'WEBSITE' | 'APP' | string;\n\n type: {\n tracking_type: ServerStandardEvent | 'CUSTOM';\n custom_event_name?: string;\n };\n\n /**\n * Event metadata\n * Share as much additional information about your conversion event as you'd like. If you're\n * using the Conversions API with the pixel, conversion_id is required for deduplication.\n */\n metadata?: {\n conversion_id?: string;\n currency?: string; // ISO 4217 3-letter currency code\n item_count?: number;\n value?: number;\n products?: { id: string; name?: string; category?: string }[];\n };\n\n user?: {\n email?: string;\n external_id?: string;\n ip_address?: string;\n phone_number?: string;\n user_agent?: string;\n\n /** The Identifier for Advertisers (IDFA) of the user's Apple device. */\n idfa?: string;\n\n /** The Android Advertising ID (AAID) of the user's Android device. */\n aaid?: string;\n /**\n * The value from the first-party Pixel _rdt_uuid cookie on your domain. Note that it is in\n * the {timestamp}.{uuid} format. You may use the full value or just the UUID portion.\n * Example: 1684189007728.7c73f2ae-a433-4d7b-9838-f467da98f48e\n */\n uuid?: string;\n\n screen_dimensions?: { width: number; height: number };\n\n /**\n * A structure of data processing options to specify the processing type for the event\n * https://business.reddithelp.com/s/article/Limited-Data-Use\n */\n data_processing_options?: {\n country: string;\n region: string;\n modes: string[] | ['LDU'];\n };\n };\n}\n\nexport interface CreateRedditEventDTO {\n data: { test_id?: string; events: RedditEvent[] };\n}\n\nexport function getServerEvent(\n //
|
|
1
|
+
{"version":3,"sources":["../../src/server/reddit-conversions-api.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport { type ServerStandardEvent, mapRDTEvent, mapServerStandardEvent } from '../track/rdt';\nimport type { TrackEvent, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * https://ads-api.reddit.com/docs/v3/operations/Post%20Conversion%20Events\n * https://business.reddithelp.com/s/article/map-a-catalog-to-a-signal-source\n */\nexport interface RedditEvent {\n /** Match keys: Share user identifiers to match conversions to a Reddit ad engagement. */\n click_id?: string;\n\n /** Unix epoch timestamp in milliseconds, event_at can't be older than seven days. */\n event_at: number;\n\n action_source: 'WEBSITE' | 'APP' | string;\n\n type: {\n tracking_type: ServerStandardEvent | 'CUSTOM';\n custom_event_name?: string;\n };\n\n /**\n * Event metadata\n * Share as much additional information about your conversion event as you'd like. If you're\n * using the Conversions API with the pixel, conversion_id is required for deduplication.\n */\n metadata?: {\n conversion_id?: string;\n currency?: string; // ISO 4217 3-letter currency code\n item_count?: number;\n value?: number;\n products?: { id: string; name?: string; category?: string }[];\n };\n\n user?: {\n email?: string;\n external_id?: string;\n ip_address?: string;\n phone_number?: string;\n user_agent?: string;\n\n /** The Identifier for Advertisers (IDFA) of the user's Apple device. */\n idfa?: string;\n\n /** The Android Advertising ID (AAID) of the user's Android device. */\n aaid?: string;\n /**\n * The value from the first-party Pixel _rdt_uuid cookie on your domain. Note that it is in\n * the {timestamp}.{uuid} format. You may use the full value or just the UUID portion.\n * Example: 1684189007728.7c73f2ae-a433-4d7b-9838-f467da98f48e\n */\n uuid?: string;\n\n screen_dimensions?: { width: number; height: number };\n\n /**\n * A structure of data processing options to specify the processing type for the event\n * https://business.reddithelp.com/s/article/Limited-Data-Use\n */\n data_processing_options?: {\n country: string;\n region: string;\n modes: string[] | ['LDU'];\n };\n };\n}\n\nexport interface CreateRedditEventDTO {\n data: { test_id?: string; events: RedditEvent[] };\n}\n\nexport function getServerEvent(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n event: TrackEvent<any>,\n data: UserProvidedData\n): RedditEvent {\n const { id, name, properties, tags } = event;\n const [type, params] = mapRDTEvent(name, properties, id);\n\n return {\n click_id: tags.rdt_cid,\n event_at: Date.now(),\n action_source: tags.source === 'web' ? 'WEBSITE' : tags.source === 'app' ? 'APP' : 'UNKNOWN',\n type: {\n tracking_type: type === 'Custom' ? 'CUSTOM' : mapServerStandardEvent(type),\n custom_event_name: type === 'Custom' ? params.customEventName : undefined,\n },\n metadata: {\n conversion_id: id,\n currency:\n 'currency' in params && typeof params.currency === 'string'\n ? params.currency.toUpperCase()\n : undefined,\n item_count:\n 'itemCount' in params && typeof params.itemCount === 'number'\n ? params.itemCount\n : undefined,\n value: 'value' in params && typeof params.value === 'number' ? params.value : undefined,\n products:\n 'products' in params && Array.isArray(params.products) && params.products.length > 0\n ? params.products\n : undefined,\n },\n user: {\n email: getFirst(data.email),\n external_id: data.user_id,\n ip_address: data.ip_address,\n phone_number: getFirst(data.phone_number),\n user_agent: data.user_agent,\n idfa: tags.platform === 'ios' ? tags.advertising_id : undefined,\n aaid: tags.platform === 'android' ? tags.advertising_id : undefined,\n uuid: tags.rdt_uuid,\n screen_dimensions:\n tags.screen_width && tags.screen_height\n ? { width: tags.screen_width, height: tags.screen_height }\n : undefined,\n },\n };\n}\n\nexport async function sendEvents(\n accessToken: string,\n pixelId: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {},\n testId?: string\n) {\n const dto: CreateRedditEventDTO = {\n data: {\n test_id: testId,\n events: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .map((event) => getServerEvent(event, data)),\n },\n };\n\n if (dto.data.events.length === 0) return;\n\n try {\n const response = await fetch(\n `https://ads-api.reddit.com/api/v3/pixels/${pixelId}/conversion_events`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify(dto),\n }\n );\n if (response.ok) return;\n const { status } = response;\n const message = await response.text();\n console.error(`Failed to send Reddit conversion, status: ${status}, body: ${message}`);\n } catch (error) {\n console.error('Failed to send Reddit conversion, network error:', error);\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAAmC,aAAa,8BAA8B;AAE9E,SAAS,gBAAgB;AAsElB,SAAS,eAEd,OACA,MACa;AACb,QAAM,EAAE,IAAI,MAAM,YAAY,KAAK,IAAI;AACvC,QAAM,CAAC,MAAM,MAAM,IAAI,YAAY,MAAM,YAAY,EAAE;AAEvD,SAAO;AAAA,IACL,UAAU,KAAK;AAAA,IACf,UAAU,KAAK,IAAI;AAAA,IACnB,eAAe,KAAK,WAAW,QAAQ,YAAY,KAAK,WAAW,QAAQ,QAAQ;AAAA,IACnF,MAAM;AAAA,MACJ,eAAe,SAAS,WAAW,WAAW,uBAAuB,IAAI;AAAA,MACzE,mBAAmB,SAAS,WAAW,OAAO,kBAAkB;AAAA,IAClE;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,MACf,UACE,cAAc,UAAU,OAAO,OAAO,aAAa,WAC/C,OAAO,SAAS,YAAY,IAC5B;AAAA,MACN,YACE,eAAe,UAAU,OAAO,OAAO,cAAc,WACjD,OAAO,YACP;AAAA,MACN,OAAO,WAAW,UAAU,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ;AAAA,MAC9E,UACE,cAAc,UAAU,MAAM,QAAQ,OAAO,QAAQ,KAAK,O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
package/dist/tanstack/index.cjs
CHANGED
|
@@ -46,6 +46,7 @@ function Analytics({
|
|
|
46
46
|
nonce,
|
|
47
47
|
debugMode,
|
|
48
48
|
metaPixelId,
|
|
49
|
+
openaiPixelId,
|
|
49
50
|
redditPixelId,
|
|
50
51
|
linkedInPartnerId,
|
|
51
52
|
hotjarId,
|
|
@@ -127,6 +128,33 @@ function Analytics({
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
),
|
|
131
|
+
openaiPixelId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
"script",
|
|
133
|
+
{
|
|
134
|
+
async: true,
|
|
135
|
+
id: "openai-pixel",
|
|
136
|
+
dangerouslySetInnerHTML: {
|
|
137
|
+
__html: `
|
|
138
|
+
(function (w, d, s, u) {
|
|
139
|
+
if (w.oaiq) return;
|
|
140
|
+
var q = function () {
|
|
141
|
+
q.q.push(arguments);
|
|
142
|
+
};
|
|
143
|
+
q.q = [];
|
|
144
|
+
w.oaiq = q;
|
|
145
|
+
var js = d.createElement(s);
|
|
146
|
+
js.async = true;
|
|
147
|
+
js.src = u;
|
|
148
|
+
var f = d.getElementsByTagName(s)[0];
|
|
149
|
+
f.parentNode.insertBefore(js, f);
|
|
150
|
+
})(window, document, "script", "https://bzrcdn.openai.com/sdk/oaiq.min.js");
|
|
151
|
+
|
|
152
|
+
oaiq("init", { pixelId: "${openaiPixelId}" });
|
|
153
|
+
oaiq("measure", "page_viewed", { type: "contents" });
|
|
154
|
+
`
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
),
|
|
130
158
|
redditPixelId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
159
|
"script",
|
|
132
160
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tanstack/index.tsx"],"sourcesContent":["import { useLocation } from '@tanstack/react-router';\nimport { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport { track } from '../track/index';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gaSrc?: string;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n gaSrc,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n useClickIdPersistence();\n\n const { pathname } = useLocation();\n useWebAnalytics(pathname);\n useOutboundClickAnalytics();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={gaSrc ?? `https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {metaPixelId && (\n <script\n async\n id=\"meta-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B;AAC5B,mBAA0B;AAC1B,wBAAgE;AAChE,sCAAsC;AACtC,0CAA0C;AAC1C,+BAAgC;AAGhC,mBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../src/tanstack/index.tsx"],"sourcesContent":["import { useLocation } from '@tanstack/react-router';\nimport { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport { track } from '../track/index';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gaSrc?: string;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n openaiPixelId?: string;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n gaSrc,\n nonce,\n debugMode,\n metaPixelId,\n openaiPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n useClickIdPersistence();\n\n const { pathname } = useLocation();\n useWebAnalytics(pathname);\n useOutboundClickAnalytics();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={gaSrc ?? `https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {metaPixelId && (\n <script\n async\n id=\"meta-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {openaiPixelId && (\n <script\n async\n id=\"openai-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n (function (w, d, s, u) {\n if (w.oaiq) return;\n var q = function () {\n q.q.push(arguments);\n };\n q.q = [];\n w.oaiq = q;\n var js = d.createElement(s);\n js.async = true;\n js.src = u;\n var f = d.getElementsByTagName(s)[0];\n f.parentNode.insertBefore(js, f);\n })(window, document, \"script\", \"https://bzrcdn.openai.com/sdk/oaiq.min.js\");\n\n oaiq(\"init\", { pixelId: \"${openaiPixelId}\" });\n oaiq(\"measure\", \"page_viewed\", { type: \"contents\" });\n `,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B;AAC5B,mBAA0B;AAC1B,wBAAgE;AAChE,sCAAsC;AACtC,0CAA0C;AAC1C,+BAAgC;AAGhC,mBAAsB;AA+DE;AA5DxB,SAAS,mBAAmB,mBAA6C;AACvE,8BAAU,MAAM;AACd,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,iCAAM,iBAAiB;AACvB,kCAAO,iBAAiB;AAAA,EAC1B,GAAG,CAAC,iBAAiB,CAAC;AACxB;AAiBO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAAU;AACR,6DAAsB;AAEtB,QAAM,EAAE,SAAS,QAAI,iCAAY;AACjC,gDAAgB,QAAQ;AACxB,qEAA0B;AAE1B,qBAAmB,CAAC,WAAW;AAC7B,QAAI,CAAC,gBAAiB;AACtB,UAAM,aAAa;AAAA,MACjB,OAAO,OAAO;AAAA,MACd,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,MACrB,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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAcO,aAAa;AAAA;AAAA,QAE9B;AAAA;AAAA,IACF;AAAA,IAED,qBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA,sCACkB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAkB7C;AAAA;AAAA,IACF;AAAA,IAED,YACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAK;AAAA,QACL,IAAG;AAAA,QACH,yBAAyB;AAAA,UACvB,QAAQ;AAAA;AAAA;AAAA,oCAGgB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -9,6 +9,7 @@ interface Props {
|
|
|
9
9
|
gaSrc?: string;
|
|
10
10
|
gtmId?: GtmId;
|
|
11
11
|
metaPixelId?: PixelId;
|
|
12
|
+
openaiPixelId?: string;
|
|
12
13
|
redditPixelId?: PixelId$1;
|
|
13
14
|
linkedInPartnerId?: `${number}`;
|
|
14
15
|
hotjarId?: `${number}`;
|
|
@@ -17,6 +18,6 @@ interface Props {
|
|
|
17
18
|
debugMode?: boolean;
|
|
18
19
|
reportWebVitals?: boolean;
|
|
19
20
|
}
|
|
20
|
-
declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, redditPixelId, linkedInPartnerId, hotjarId, facebookAppId, reportWebVitals, }: Props): react_jsx_runtime.JSX.Element;
|
|
21
|
+
declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, openaiPixelId, redditPixelId, linkedInPartnerId, hotjarId, facebookAppId, reportWebVitals, }: Props): react_jsx_runtime.JSX.Element;
|
|
21
22
|
|
|
22
23
|
export { Analytics };
|
package/dist/tanstack/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface Props {
|
|
|
9
9
|
gaSrc?: string;
|
|
10
10
|
gtmId?: GtmId;
|
|
11
11
|
metaPixelId?: PixelId;
|
|
12
|
+
openaiPixelId?: string;
|
|
12
13
|
redditPixelId?: PixelId$1;
|
|
13
14
|
linkedInPartnerId?: `${number}`;
|
|
14
15
|
hotjarId?: `${number}`;
|
|
@@ -17,6 +18,6 @@ interface Props {
|
|
|
17
18
|
debugMode?: boolean;
|
|
18
19
|
reportWebVitals?: boolean;
|
|
19
20
|
}
|
|
20
|
-
declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, redditPixelId, linkedInPartnerId, hotjarId, facebookAppId, reportWebVitals, }: Props): react_jsx_runtime.JSX.Element;
|
|
21
|
+
declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, openaiPixelId, redditPixelId, linkedInPartnerId, hotjarId, facebookAppId, reportWebVitals, }: Props): react_jsx_runtime.JSX.Element;
|
|
21
22
|
|
|
22
23
|
export { Analytics };
|
package/dist/tanstack/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ function Analytics({
|
|
|
22
22
|
nonce,
|
|
23
23
|
debugMode,
|
|
24
24
|
metaPixelId,
|
|
25
|
+
openaiPixelId,
|
|
25
26
|
redditPixelId,
|
|
26
27
|
linkedInPartnerId,
|
|
27
28
|
hotjarId,
|
|
@@ -103,6 +104,33 @@ function Analytics({
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
),
|
|
107
|
+
openaiPixelId && /* @__PURE__ */ jsx(
|
|
108
|
+
"script",
|
|
109
|
+
{
|
|
110
|
+
async: true,
|
|
111
|
+
id: "openai-pixel",
|
|
112
|
+
dangerouslySetInnerHTML: {
|
|
113
|
+
__html: `
|
|
114
|
+
(function (w, d, s, u) {
|
|
115
|
+
if (w.oaiq) return;
|
|
116
|
+
var q = function () {
|
|
117
|
+
q.q.push(arguments);
|
|
118
|
+
};
|
|
119
|
+
q.q = [];
|
|
120
|
+
w.oaiq = q;
|
|
121
|
+
var js = d.createElement(s);
|
|
122
|
+
js.async = true;
|
|
123
|
+
js.src = u;
|
|
124
|
+
var f = d.getElementsByTagName(s)[0];
|
|
125
|
+
f.parentNode.insertBefore(js, f);
|
|
126
|
+
})(window, document, "script", "https://bzrcdn.openai.com/sdk/oaiq.min.js");
|
|
127
|
+
|
|
128
|
+
oaiq("init", { pixelId: "${openaiPixelId}" });
|
|
129
|
+
oaiq("measure", "page_viewed", { type: "contents" });
|
|
130
|
+
`
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
),
|
|
106
134
|
redditPixelId && /* @__PURE__ */ jsx(
|
|
107
135
|
"script",
|
|
108
136
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tanstack/index.tsx"],"sourcesContent":["import { useLocation } from '@tanstack/react-router';\nimport { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport { track } from '../track/index';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gaSrc?: string;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n gaSrc,\n nonce,\n debugMode,\n metaPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n useClickIdPersistence();\n\n const { pathname } = useLocation();\n useWebAnalytics(pathname);\n useOutboundClickAnalytics();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={gaSrc ?? `https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {metaPixelId && (\n <script\n async\n id=\"meta-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAsB,OAAO,OAAO,OAAO,OAAO,cAAc;AAChE,SAAS,6BAA6B;AACtC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAGhC,SAAS,aAAa;
|
|
1
|
+
{"version":3,"sources":["../../src/tanstack/index.tsx"],"sourcesContent":["import { useLocation } from '@tanstack/react-router';\nimport { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\nimport { useClickIdPersistence } from '../hooks/use-click-id-persistence';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport type { PixelId as MetaPixelId } from '../track/fbq';\nimport type { GaId, GtmId } from '../track/gtag';\nimport { track } from '../track/index';\nimport type { PixelId as RedditPixelId } from '../track/rdt';\n\nfunction useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(reportWebVitalsFn);\n onLCP(reportWebVitalsFn);\n onINP(reportWebVitalsFn);\n onFCP(reportWebVitalsFn);\n onTTFB(reportWebVitalsFn);\n }, [reportWebVitalsFn]);\n}\n\ninterface Props {\n gaId?: GaId;\n gaSrc?: string;\n gtmId?: GtmId;\n metaPixelId?: MetaPixelId;\n openaiPixelId?: string;\n redditPixelId?: RedditPixelId;\n linkedInPartnerId?: `${number}`;\n hotjarId?: `${number}`;\n facebookAppId?: string;\n nonce?: string;\n debugMode?: boolean;\n reportWebVitals?: boolean;\n}\n\nexport function Analytics({\n gaId,\n gaSrc,\n nonce,\n debugMode,\n metaPixelId,\n openaiPixelId,\n redditPixelId,\n linkedInPartnerId,\n hotjarId,\n facebookAppId,\n reportWebVitals = true,\n}: Props) {\n useClickIdPersistence();\n\n const { pathname } = useLocation();\n useWebAnalytics(pathname);\n useOutboundClickAnalytics();\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {gaId && (\n <>\n <script\n async\n id=\"gtag\"\n nonce={nonce}\n src={gaSrc ?? `https://www.googletagmanager.com/gtag/js?id=${gaId}`}\n />\n <script\n async\n nonce={nonce}\n id=\"gtag-init\"\n dangerouslySetInnerHTML={{\n __html: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${gaId}'${debugMode ? \" ,{ 'debug_mode': true }\" : ''});\n `,\n }}\n />\n </>\n )}\n {metaPixelId && (\n <script\n async\n id=\"meta-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '${metaPixelId}');\n fbq('track', 'PageView');`,\n }}\n />\n )}\n {openaiPixelId && (\n <script\n async\n id=\"openai-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n (function (w, d, s, u) {\n if (w.oaiq) return;\n var q = function () {\n q.q.push(arguments);\n };\n q.q = [];\n w.oaiq = q;\n var js = d.createElement(s);\n js.async = true;\n js.src = u;\n var f = d.getElementsByTagName(s)[0];\n f.parentNode.insertBefore(js, f);\n })(window, document, \"script\", \"https://bzrcdn.openai.com/sdk/oaiq.min.js\");\n\n oaiq(\"init\", { pixelId: \"${openaiPixelId}\" });\n oaiq(\"measure\", \"page_viewed\", { type: \"contents\" });\n `,\n }}\n />\n )}\n {redditPixelId && (\n <script\n async\n id=\"reddit-pixel\"\n dangerouslySetInnerHTML={{\n __html: `\n !function(w,d) {\n if(!w.rdt) {\n var p = w.rdt = function() {\n p.sendEvent ? p.sendEvent.apply(p,arguments) : p.callQueue.push(arguments)\n };\n p.callQueue = [];\n var t = d.createElement(\"script\");\n t.src = \"https://www.redditstatic.com/ads/pixel.js\";\n t.async = !0;\n var s = d.getElementsByTagName(\"script\")[0];\n s.parentNode.insertBefore(t,s)\n }\n }(window, document);\n rdt('init', '${redditPixelId}');\n rdt('track', 'PageVisit');`,\n }}\n />\n )}\n {linkedInPartnerId && (\n <script\n async\n id=\"linkedin-insight-tag\"\n dangerouslySetInnerHTML={{\n __html: `\n _linkedin_partner_id = \"${linkedInPartnerId}\";\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n }}\n />\n )}\n {hotjarId && (\n <script\n async\n id=\"hotjar\"\n dangerouslySetInnerHTML={{\n __html: `\n (function(h,o,t,j,a,r){\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\n h._hjSettings={hjid:${hotjarId},hjsv:6};\n a=o.getElementsByTagName('head')[0];\n r=o.createElement('script');r.async=1;\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\n a.appendChild(r);\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\n `,\n }}\n />\n )}\n </>\n );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAsB,OAAO,OAAO,OAAO,OAAO,cAAc;AAChE,SAAS,6BAA6B;AACtC,SAAS,iCAAiC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OlC;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Gtag {}\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, data, properties }: UpdateVisitorDTO) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (data) window.gtag('set', 'user_data', data);\n if (properties) window.gtag('set', 'user_properties', properties);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,YACd,MACA,YACA;AACA,MAAI,CAAC,OAAO,MAAM;AAChB,YAAQ,KAAK,6BAA6B;AAC1C;AAAA,EACF;AACA,SAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEO,SAAS,UAAU,EAAE,SAAS,MAAM,WAAW,GAAqB;AACzE,MAAI,CAAC,OAAO,MAAM;AAChB,YAAQ,KAAK,6BAA6B;AAC1C;AAAA,EACF;AACA,MAAI,QAAS,QAAO,KAAK,OAAO,WAAW,OAAO;AAClD,MAAI,KAAM,QAAO,KAAK,OAAO,aAAa,IAAI;AAC9C,MAAI,WAAY,QAAO,KAAK,OAAO,mBAAmB,UAAU;AAClE;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Gtag {}\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, data, properties }: UpdateVisitorDTO) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (data) window.gtag('set', 'user_data', data);\n if (properties) window.gtag('set', 'user_properties', properties);\n}\n"],"mappings":";AASO,SAAS,YACd,MACA,YACA;AACA,MAAI,CAAC,OAAO,MAAM;AAChB,YAAQ,KAAK,6BAA6B;AAC1C;AAAA,EACF;AACA,SAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEO,SAAS,UAAU,EAAE,SAAS,MAAM,WAAW,GAAqB;AACzE,MAAI,CAAC,OAAO,MAAM;AAChB,YAAQ,KAAK,6BAA6B;AAC1C;AAAA,EACF;AACA,MAAI,QAAS,QAAO,KAAK,OAAO,WAAW,OAAO;AAClD,MAAI,KAAM,QAAO,KAAK,OAAO,aAAa,IAAI;AAC9C,MAAI,WAAY,QAAO,KAAK,OAAO,mBAAmB,UAAU;AAClE;","names":[]}
|
|
@@ -23,26 +23,31 @@ __export(third_parties_exports, {
|
|
|
23
23
|
sendFBEvent: () => import_meta_pixel.sendFBEvent,
|
|
24
24
|
sendGAEvent: () => import_google_analytics.sendGAEvent,
|
|
25
25
|
sendLinkedinEvent: () => import_linkedin_insight_tag.sendLinkedinEvent,
|
|
26
|
+
sendOpenAIEvent: () => import_openai_pixel.sendOpenAIEvent,
|
|
26
27
|
sendRedditEvent: () => import_reddit_pixel.sendRedditEvent,
|
|
27
28
|
setFBUser: () => import_meta_pixel.setFBUser,
|
|
28
29
|
setGAUser: () => import_google_analytics.setGAUser,
|
|
29
30
|
setLinkedinUser: () => import_linkedin_insight_tag.setLinkedinUser,
|
|
31
|
+
setOpenAIUser: () => import_openai_pixel.setOpenAIUser,
|
|
30
32
|
setRedditUser: () => import_reddit_pixel.setRedditUser
|
|
31
33
|
});
|
|
32
34
|
module.exports = __toCommonJS(third_parties_exports);
|
|
33
35
|
var import_google_analytics = require("./google-analytics.cjs");
|
|
34
36
|
var import_meta_pixel = require("./meta-pixel.cjs");
|
|
35
37
|
var import_linkedin_insight_tag = require("./linkedin-insight-tag.cjs");
|
|
38
|
+
var import_openai_pixel = require("./openai-pixel.cjs");
|
|
36
39
|
var import_reddit_pixel = require("./reddit-pixel.cjs");
|
|
37
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
41
|
0 && (module.exports = {
|
|
39
42
|
sendFBEvent,
|
|
40
43
|
sendGAEvent,
|
|
41
44
|
sendLinkedinEvent,
|
|
45
|
+
sendOpenAIEvent,
|
|
42
46
|
sendRedditEvent,
|
|
43
47
|
setFBUser,
|
|
44
48
|
setGAUser,
|
|
45
49
|
setLinkedinUser,
|
|
50
|
+
setOpenAIUser,
|
|
46
51
|
setRedditUser
|
|
47
52
|
});
|
|
48
53
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAuC;AACvC,wBAAuC;AACvC,kCAAmD;AACnD,0BAA+C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendOpenAIEvent, setOpenAIUser } from './openai-pixel';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAuC;AACvC,wBAAuC;AACvC,kCAAmD;AACnD,0BAA+C;AAC/C,0BAA+C;","names":[]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { sendGAEvent, setGAUser } from './google-analytics.cjs';
|
|
2
2
|
export { sendFBEvent, setFBUser } from './meta-pixel.cjs';
|
|
3
3
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag.cjs';
|
|
4
|
+
export { sendOpenAIEvent, setOpenAIUser } from './openai-pixel.cjs';
|
|
4
5
|
export { sendRedditEvent, setRedditUser } from './reddit-pixel.cjs';
|
|
5
6
|
import '../track/gtag.cjs';
|
|
6
7
|
import '../track/types.cjs';
|
|
7
8
|
import '../visitor/types.cjs';
|
|
8
9
|
import '../track/fbq.cjs';
|
|
9
10
|
import '../track/lintrk.cjs';
|
|
11
|
+
import '../track/oaiq.cjs';
|
|
10
12
|
import '../track/rdt.cjs';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { sendGAEvent, setGAUser } from './google-analytics.js';
|
|
2
2
|
export { sendFBEvent, setFBUser } from './meta-pixel.js';
|
|
3
3
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag.js';
|
|
4
|
+
export { sendOpenAIEvent, setOpenAIUser } from './openai-pixel.js';
|
|
4
5
|
export { sendRedditEvent, setRedditUser } from './reddit-pixel.js';
|
|
5
6
|
import '../track/gtag.js';
|
|
6
7
|
import '../track/types.js';
|
|
7
8
|
import '../visitor/types.js';
|
|
8
9
|
import '../track/fbq.js';
|
|
9
10
|
import '../track/lintrk.js';
|
|
11
|
+
import '../track/oaiq.js';
|
|
10
12
|
import '../track/rdt.js';
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
import { sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
3
3
|
import { sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
4
4
|
import { sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
5
|
+
import { sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
|
|
5
6
|
import { sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
6
7
|
export {
|
|
7
8
|
sendFBEvent,
|
|
8
9
|
sendGAEvent,
|
|
9
10
|
sendLinkedinEvent,
|
|
11
|
+
sendOpenAIEvent,
|
|
10
12
|
sendRedditEvent,
|
|
11
13
|
setFBUser,
|
|
12
14
|
setGAUser,
|
|
13
15
|
setLinkedinUser,
|
|
16
|
+
setOpenAIUser,
|
|
14
17
|
setRedditUser
|
|
15
18
|
};
|
|
16
19
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";AAAA,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,iBAAiB;AACvC,SAAS,mBAAmB,uBAAuB;AACnD,SAAS,iBAAiB,qBAAqB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendOpenAIEvent, setOpenAIUser } from './openai-pixel';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";AAAA,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,iBAAiB;AACvC,SAAS,mBAAmB,uBAAuB;AACnD,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,iBAAiB,qBAAqB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAyB;AAmBlB,SAAS,kBAAkB,QAAkC;AAClE,SAAO,CACL,MACA,aACA,aACG;AACH,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,cAAQ,KAAK,iCAAiC;AAC9C;AAAA,IACF;AACA,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,UAAM,gBAAgB,OAAO,IAAyB;AACtD,QAAI,CAAC,cAAe;AACpB,WAAO,OAAO,SAAS,EAAE,eAAe,SAAS,CAAC;AAAA,EACpD;AACF;AAEO,SAAS,gBAAgB,EAAE,KAAK,GAAqB;AAC1D,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,YAAQ,KAAK,iCAAiC;AAC9C;AAAA,EACF;AAEA,QAAM,YAAQ,uBAAS,6BAAM,KAAK;AAClC,MAAI,CAAC,MAAO;AACZ,SAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AAmBlB,SAAS,kBAAkB,QAAkC;AAClE,SAAO,CACL,MACA,aACA,aACG;AACH,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,cAAQ,KAAK,iCAAiC;AAC9C;AAAA,IACF;AACA,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,UAAM,gBAAgB,OAAO,IAAyB;AACtD,QAAI,CAAC,cAAe;AACpB,WAAO,OAAO,SAAS,EAAE,eAAe,SAAS,CAAC;AAAA,EACpD;AACF;AAEO,SAAS,gBAAgB,EAAE,KAAK,GAAqB;AAC1D,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,YAAQ,KAAK,iCAAiC;AAC9C;AAAA,EACF;AAEA,QAAM,QAAQ,SAAS,6BAAM,KAAK;AAClC,MAAI,CAAC,MAAO;AACZ,SAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmD;AAEnD,mBAAyB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,YACd,MACA,YACA,UACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,UAAU,EAAE,SAAS,SAAS;AACpC,QAAM,CAAC,MAAM,aAAa,iBAAiB,QAAI,uBAAW,MAAM,UAAU;AAC1E,MAAI,SAAS,SAAS;AACpB,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D,OAAO;AACL,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D;AACF;AAEO,SAAS,UAAU,SAAkB;AAC1C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,UAAM,cAAU,uBAAS,6BAAM,OAAO;AAEtC,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,QAAI,uBAAS,6BAAM,KAAK;AAAA,MACxB,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,QAAI,uBAAS,6BAAM,YAAY;AAAA,MAC/B,aAAa;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,SAAS,mCAAS;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";AAAA,SAAiC,kBAAkB;AAEnD,SAAS,gBAAgB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,YACd,MACA,YACA,UACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,UAAU,EAAE,SAAS,SAAS;AACpC,QAAM,CAAC,MAAM,aAAa,iBAAiB,IAAI,WAAW,MAAM,UAAU;AAC1E,MAAI,SAAS,SAAS;AACpB,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D,OAAO;AACL,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D;AACF;AAEO,SAAS,UAAU,SAAkB;AAC1C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,UAAM,UAAU,SAAS,6BAAM,OAAO;AAEtC,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,IAAI,SAAS,6BAAM,KAAK;AAAA,MACxB,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,SAAS,6BAAM,YAAY;AAAA,MAC/B,aAAa;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,SAAS,mCAAS;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/third-parties/openai-pixel.ts
|
|
21
|
+
var openai_pixel_exports = {};
|
|
22
|
+
__export(openai_pixel_exports, {
|
|
23
|
+
sendOpenAIEvent: () => sendOpenAIEvent,
|
|
24
|
+
setOpenAIUser: () => setOpenAIUser
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(openai_pixel_exports);
|
|
27
|
+
var import_oaiq = require("../track/oaiq.cjs");
|
|
28
|
+
var import_field = require("../utils/field.cjs");
|
|
29
|
+
function clean(value) {
|
|
30
|
+
return JSON.parse(JSON.stringify(value));
|
|
31
|
+
}
|
|
32
|
+
function sendOpenAIEvent(name, properties, eventId) {
|
|
33
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
34
|
+
console.warn("oaiq has not been initialized");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (import_oaiq.NON_AD_EVENTS.includes(name)) return;
|
|
38
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
39
|
+
if (window.location.host.includes("localhost")) return;
|
|
40
|
+
const { type, data } = (0, import_oaiq.mapOAIEvent)(name, properties);
|
|
41
|
+
if (type === "custom") {
|
|
42
|
+
window.oaiq("measure", "custom", clean(data), { event_id: eventId, custom_event_name: name });
|
|
43
|
+
} else {
|
|
44
|
+
window.oaiq("measure", type, clean(data), { event_id: eventId });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function sha256(value) {
|
|
48
|
+
const bytes = new TextEncoder().encode(value);
|
|
49
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
50
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
51
|
+
}
|
|
52
|
+
function setOpenAIUser(pixelId) {
|
|
53
|
+
return ({ user_id, data }) => {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
56
|
+
console.warn("oaiq has not been initialized");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const email = (_a = (0, import_field.getFirst)(data == null ? void 0 : data.email)) == null ? void 0 : _a.trim().toLowerCase();
|
|
60
|
+
const address = (0, import_field.getFirst)(data == null ? void 0 : data.address);
|
|
61
|
+
const base = {
|
|
62
|
+
country: (_b = address == null ? void 0 : address.country) == null ? void 0 : _b.trim().toUpperCase(),
|
|
63
|
+
city: (_c = address == null ? void 0 : address.city) == null ? void 0 : _c.trim().toLowerCase(),
|
|
64
|
+
zip_code: address == null ? void 0 : address.postal_code
|
|
65
|
+
};
|
|
66
|
+
const init = (hashed) => {
|
|
67
|
+
window.oaiq("init", { pixelId, user: clean({ ...base, ...hashed }) });
|
|
68
|
+
};
|
|
69
|
+
Promise.all([email ? sha256(email) : void 0, user_id ? sha256(user_id) : void 0]).then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 })).catch(() => init({}));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
sendOpenAIEvent,
|
|
75
|
+
setOpenAIUser
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=openai-pixel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (NON_AD_EVENTS.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqE;AAErE,mBAAyB;AAUzB,SAAS,MAAM,OAAqB;AAClC,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AAOO,SAAS,gBACd,MACA,YACA,SACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,YAAQ,KAAK,+BAA+B;AAC5C;AAAA,EACF;AACA,MAAI,0BAAc,SAAS,IAAI,EAAG;AAClC,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,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IAAI,MAAS,CAAC,EACnF,KAAK,CAAC,CAAC,cAAc,kBAAkB,MAAM,KAAK,EAAE,cAAc,mBAAmB,CAAC,CAAC,EACvF,MAAM,MAAM,KAAK,CAAC,CAAC,CAAC;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OAIQ } from '../track/oaiq.cjs';
|
|
2
|
+
import { EventName, TrackName, TrackProperties } from '../track/types.cjs';
|
|
3
|
+
import { UpdateVisitorDTO } from '../visitor/types.cjs';
|
|
4
|
+
import '../track/gtag.cjs';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window extends OAIQ {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Forward an internal track event to the OpenAI measurement pixel.
|
|
12
|
+
* `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the
|
|
13
|
+
* Conversions API. https://developers.openai.com/ads/measurement-pixel
|
|
14
|
+
*/
|
|
15
|
+
declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, eventId?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Re-initialize the pixel with hashed user identity for better conversion matching. Email and
|
|
18
|
+
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
19
|
+
* so the `init` call is deferred until the digests resolve.
|
|
20
|
+
*/
|
|
21
|
+
declare function setOpenAIUser(pixelId: string): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
22
|
+
|
|
23
|
+
export { sendOpenAIEvent, setOpenAIUser };
|