@shware/analytics 3.8.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.mjs +1 -1
- package/dist/react-router/index.cjs +1 -1
- package/dist/react-router/index.mjs +1 -1
- package/dist/schema/index.cjs +32 -0
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +130 -1
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +130 -1
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +33 -2
- package/dist/schema/index.mjs.map +1 -1
- package/dist/tanstack/index.cjs +1 -1
- package/dist/tanstack/index.mjs +1 -1
- package/dist/third-parties/google-analytics.cjs +2 -2
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +2 -2
- package/dist/third-parties/google-analytics.d.cts.map +1 -1
- package/dist/third-parties/google-analytics.d.mts +2 -2
- package/dist/third-parties/google-analytics.d.mts.map +1 -1
- package/dist/third-parties/google-analytics.mjs +2 -2
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +2 -2
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +2 -2
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +4 -4
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +2 -2
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts +2 -2
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.mjs +4 -4
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +3 -3
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +2 -2
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts +2 -2
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.mjs +3 -3
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/posthog.cjs +2 -2
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts +2 -2
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts +2 -2
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/posthog.mjs +2 -2
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs +3 -3
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +2 -2
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +2 -2
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs +3 -3
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/visitor/index.cjs +6 -5
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.d.cts +3 -2
- package/dist/visitor/index.d.cts.map +1 -1
- package/dist/visitor/index.d.mts +3 -2
- package/dist/visitor/index.d.mts.map +1 -1
- package/dist/visitor/index.mjs +6 -5
- package/dist/visitor/index.mjs.map +1 -1
- package/dist/visitor/types.d.cts +2 -7
- package/dist/visitor/types.d.cts.map +1 -1
- package/dist/visitor/types.d.mts +2 -7
- package/dist/visitor/types.d.mts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n coerce,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n refine,\n regex,\n string,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst items = array(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n )\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n platform: _enum(ALL_PLATFORMS),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n environment: _enum(ALL_ENVIRONMENTS),\n source_url: optional(string()),\n source: optional(_enum(['web', 'app', 'offline'])),\n page_referrer: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n site_source_name: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null(), items])\n ).check(refine((data) => Object.keys(data).length <= 64))\n);\n\n/** @deprecated */\nexport const createTrackEventSchemaV1 = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: coerce.bigint(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createTrackEventSchema = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n distinct_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA2BA,MAAM,QAAQ,MACZ,OACE,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,GACnD,MAAM;CAAC,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CAAG,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CACtE,CACF;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO,CAAC;CACrB,SAAS,SAAS,OAAO,CAAC;CAC1B,YAAY,SAAS,OAAO,CAAC;CAC7B,SAAS,SAAS,OAAO,CAAC;CAC1B,cAAc,SAAS,OAAO,CAAC;CAC/B,iBAAiB,SAAS,OAAO,CAAC;CAClC,UAAUC,OAAM,aAAa;CAC7B,QAAQ,SAAS,OAAO,CAAC;CACzB,WAAW,SAAS,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC;CACvE,aAAa,SAAS,OAAO,CAAC;CAC9B,eAAe,SAAS,OAAO,CAAC;CAChC,oBAAoB,SAAS,OAAO,CAAC;CACrC,cAAc,SAAS,OAAO,CAAC;CAC/B,eAAe,SAAS,OAAO,CAAC;CAChC,mBAAmB,SACjB,KACE,OAAO,CAAC,CAAC,MAAM,MAAM,WAAW,CAAC,GACjC,WAAW,MAAM,CAA0B,CAC7C,CACF;CACA,S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AAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n coerce,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n refine,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst items = array(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n )\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n platform: _enum(ALL_PLATFORMS),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n environment: _enum(ALL_ENVIRONMENTS),\n source_url: optional(string()),\n source: optional(_enum(['web', 'app', 'offline'])),\n page_referrer: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n site_source_name: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null(), items])\n ).check(refine((data) => Object.keys(data).length <= 64))\n);\n\n/** @deprecated */\nexport const createTrackEventSchemaV1 = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: coerce.bigint(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createTrackEventSchema = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n distinct_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA8BA,MAAM,QAAQ,MACZ,OACE,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,GACnD,MAAM;CAAC,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CAAG,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CACtE,CACF;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO,CAAC;CACrB,SAAS,SAAS,OAAO,CAAC;CAC1B,YAAY,SAAS,OAAO,CAAC;CAC7B,SAAS,SAAS,OAAO,CAAC;CAC1B,cAAc,SAAS,OAAO,CAAC;CAC/B,iBAAiB,SAAS,OAAO,CAAC;CAClC,UAAUC,OAAM,aAAa;CAC7B,QAAQ,SAAS,OAAO,CAAC;CACzB,WAAW,SAAS,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC;CACvE,aAAa,SAAS,OAAO,CAAC;CAC9B,eAAe,SAAS,OAAO,CAAC;CA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nC,SAAS,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,KAAK,CAAC;AACxD,CAAC;AAED,MAAM,gBAAgB,KACpB,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC,GAC7B,WAAW,MAAO,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,mBAAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
package/dist/tanstack/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ const require_hooks_use_click_id_persistence = require("../hooks/use-click-id-pe
|
|
|
4
4
|
const require_hooks_use_outbound_click_analytics = require("../hooks/use-outbound-click-analytics.cjs");
|
|
5
5
|
const require_hooks_use_web_analytics = require("../hooks/use-web-analytics.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
|
-
let web_vitals = require("web-vitals");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let web_vitals = require("web-vitals");
|
|
9
9
|
let _tanstack_react_router = require("@tanstack/react-router");
|
|
10
10
|
//#region src/tanstack/index.tsx
|
|
11
11
|
function useReportWebVitals(reportWebVitalsFn) {
|
package/dist/tanstack/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { useClickIdPersistence } from "../hooks/use-click-id-persistence.mjs";
|
|
|
3
3
|
import { useOutboundClickAnalytics } from "../hooks/use-outbound-click-analytics.mjs";
|
|
4
4
|
import { useWebAnalytics } from "../hooks/use-web-analytics.mjs";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
|
-
import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals";
|
|
7
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals";
|
|
8
8
|
import { useLocation } from "@tanstack/react-router";
|
|
9
9
|
//#region src/tanstack/index.tsx
|
|
10
10
|
function useReportWebVitals(reportWebVitalsFn) {
|
|
@@ -7,13 +7,13 @@ function sendGAEvent(name, properties) {
|
|
|
7
7
|
}
|
|
8
8
|
window.gtag("event", name, properties);
|
|
9
9
|
}
|
|
10
|
-
function setGAUser({ user_id,
|
|
10
|
+
function setGAUser({ user_id, user_data, properties }) {
|
|
11
11
|
if (!window.gtag) {
|
|
12
12
|
console.warn("GA has not been initialized");
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
if (user_id) window.gtag("set", "user_id", user_id);
|
|
16
|
-
if (
|
|
16
|
+
if (user_data) window.gtag("set", "user_data", user_data);
|
|
17
17
|
if (properties) window.gtag("set", "user_properties", properties);
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/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, user_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 (user_data) window.gtag('set', 'user_data', user_data);\n if (properties) window.gtag('set', 'user_properties', properties as never);\n}\n"],"mappings":";;AASA,SAAgB,YACd,MACA,YACA;CACA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,WAAW,cAAgC;CAC9E,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;CACxD,IAAI,YAAY,OAAO,KAAK,OAAO,mBAAmB,UAAmB;AAC3E"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { Gtag } from "../track/gtag.cjs";
|
|
2
3
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
3
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
4
4
|
//#region src/third-parties/google-analytics.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends Gtag {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
9
|
-
declare function setGAUser({ user_id,
|
|
9
|
+
declare function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO): void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendGAEvent, setGAUser };
|
|
12
12
|
//# sourceMappingURL=google-analytics.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.d.cts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,
|
|
1
|
+
{"version":3,"file":"google-analytics.d.cts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,WAAW,cAAc"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { Gtag } from "../track/gtag.mjs";
|
|
2
3
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
3
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
4
4
|
//#region src/third-parties/google-analytics.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends Gtag {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
9
|
-
declare function setGAUser({ user_id,
|
|
9
|
+
declare function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO): void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendGAEvent, setGAUser };
|
|
12
12
|
//# sourceMappingURL=google-analytics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,
|
|
1
|
+
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,WAAW,cAAc"}
|
|
@@ -6,13 +6,13 @@ function sendGAEvent(name, properties) {
|
|
|
6
6
|
}
|
|
7
7
|
window.gtag("event", name, properties);
|
|
8
8
|
}
|
|
9
|
-
function setGAUser({ user_id,
|
|
9
|
+
function setGAUser({ user_id, user_data, properties }) {
|
|
10
10
|
if (!window.gtag) {
|
|
11
11
|
console.warn("GA has not been initialized");
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
if (user_id) window.gtag("set", "user_id", user_id);
|
|
15
|
-
if (
|
|
15
|
+
if (user_data) window.gtag("set", "user_data", user_data);
|
|
16
16
|
if (properties) window.gtag("set", "user_properties", properties);
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/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, user_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 (user_data) window.gtag('set', 'user_data', user_data);\n if (properties) window.gtag('set', 'user_properties', properties as never);\n}\n"],"mappings":";AASA,SAAgB,YACd,MACA,YACA;CACA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,WAAW,cAAgC;CAC9E,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;CACxD,IAAI,YAAY,OAAO,KAAK,OAAO,mBAAmB,UAAmB;AAC3E"}
|
|
@@ -17,12 +17,12 @@ function sendLinkedinEvent(config) {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function setLinkedinUser({
|
|
20
|
+
function setLinkedinUser({ user_data }) {
|
|
21
21
|
if (typeof window === "undefined" || !window.lintrk) {
|
|
22
22
|
console.warn("lintrk has not been initialized");
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const email = require_utils_field.getFirst(
|
|
25
|
+
const email = require_utils_field.getFirst(user_data?.email);
|
|
26
26
|
if (!email) return;
|
|
27
27
|
window.lintrk("setUserData", { email });
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"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';\
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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({ user_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(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;;AAqBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C;EACF;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQA,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
import { Lintrk } from "../track/lintrk.cjs";
|
|
4
4
|
//#region src/third-parties/linkedin-insight-tag.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare global {
|
|
|
16
16
|
*/
|
|
17
17
|
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
18
18
|
declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => void;
|
|
19
|
-
declare function setLinkedinUser({
|
|
19
|
+
declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser };
|
|
22
22
|
//# sourceMappingURL=linkedin-insight-tag.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
3
|
import { Lintrk } from "../track/lintrk.mjs";
|
|
4
4
|
//#region src/third-parties/linkedin-insight-tag.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare global {
|
|
|
16
16
|
*/
|
|
17
17
|
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
18
18
|
declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => void;
|
|
19
|
-
declare function setLinkedinUser({
|
|
19
|
+
declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser };
|
|
22
22
|
//# sourceMappingURL=linkedin-insight-tag.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,aAAa"}
|
|
@@ -16,12 +16,12 @@ function sendLinkedinEvent(config) {
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function setLinkedinUser({
|
|
19
|
+
function setLinkedinUser({ user_data }) {
|
|
20
20
|
if (typeof window === "undefined" || !window.lintrk) {
|
|
21
21
|
console.warn("lintrk has not been initialized");
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
const email = getFirst(
|
|
24
|
+
const email = getFirst(user_data?.email);
|
|
25
25
|
if (!email) return;
|
|
26
26
|
window.lintrk("setUserData", { email });
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"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';\
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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({ user_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(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;AAqBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C;EACF;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
|
|
@@ -24,17 +24,17 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
24
24
|
else window.fbq(type, fbEventName, fbEventProperties, options);
|
|
25
25
|
}
|
|
26
26
|
function setFBUser(pixelId) {
|
|
27
|
-
return ({ user_id,
|
|
27
|
+
return ({ user_id, user_data }) => {
|
|
28
28
|
if (typeof window === "undefined" || !window.fbq) {
|
|
29
29
|
console.warn("fbq has not been initialized");
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const address = require_utils_field.getFirst(
|
|
32
|
+
const address = require_utils_field.getFirst(user_data?.address);
|
|
33
33
|
window.fbq("init", pixelId, {
|
|
34
|
-
em: require_utils_field.getFirst(
|
|
34
|
+
em: require_utils_field.getFirst(user_data?.email),
|
|
35
35
|
fn: address?.first_name,
|
|
36
36
|
ln: address?.last_name,
|
|
37
|
-
ph: require_utils_field.getFirst(
|
|
37
|
+
ph: require_utils_field.getFirst(user_data?.phone_number),
|
|
38
38
|
external_id: user_id,
|
|
39
39
|
ct: address?.city,
|
|
40
40
|
st: address?.street,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst"],"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';\
|
|
1
|
+
{"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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, user_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(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_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":";;;;AAUA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C;CACF;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAC1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
import { FBQ, PixelId } from "../track/fbq.cjs";
|
|
4
4
|
//#region src/third-parties/meta-pixel.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends FBQ {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): void;
|
|
9
|
-
declare function setFBUser(pixelId: PixelId): ({ user_id,
|
|
9
|
+
declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendFBEvent, setFBUser };
|
|
12
12
|
//# sourceMappingURL=meta-pixel.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,aACR"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
3
|
import { FBQ, PixelId } from "../track/fbq.mjs";
|
|
4
4
|
//#region src/third-parties/meta-pixel.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends FBQ {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): void;
|
|
9
|
-
declare function setFBUser(pixelId: PixelId): ({ user_id,
|
|
9
|
+
declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendFBEvent, setFBUser };
|
|
12
12
|
//# sourceMappingURL=meta-pixel.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,aACR"}
|
|
@@ -23,17 +23,17 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
23
23
|
else window.fbq(type, fbEventName, fbEventProperties, options);
|
|
24
24
|
}
|
|
25
25
|
function setFBUser(pixelId) {
|
|
26
|
-
return ({ user_id,
|
|
26
|
+
return ({ user_id, user_data }) => {
|
|
27
27
|
if (typeof window === "undefined" || !window.fbq) {
|
|
28
28
|
console.warn("fbq has not been initialized");
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const address = getFirst(
|
|
31
|
+
const address = getFirst(user_data?.address);
|
|
32
32
|
window.fbq("init", pixelId, {
|
|
33
|
-
em: getFirst(
|
|
33
|
+
em: getFirst(user_data?.email),
|
|
34
34
|
fn: address?.first_name,
|
|
35
35
|
ln: address?.last_name,
|
|
36
|
-
ph: getFirst(
|
|
36
|
+
ph: getFirst(user_data?.phone_number),
|
|
37
37
|
external_id: user_id,
|
|
38
38
|
ct: address?.city,
|
|
39
39
|
st: address?.street,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.mjs","names":[],"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';\
|
|
1
|
+
{"version":3,"file":"meta-pixel.mjs","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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, user_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(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_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":";;;AAUA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C;CACF;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqB,WAAW,MAAM,UAAU;CAC1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAU,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAI,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
|
|
@@ -38,13 +38,13 @@ async function sha256(value) {
|
|
|
38
38
|
* so the `init` call is deferred until the digests resolve.
|
|
39
39
|
*/
|
|
40
40
|
function setOpenAIUser(pixelId) {
|
|
41
|
-
return ({ user_id,
|
|
41
|
+
return ({ user_id, user_data }) => {
|
|
42
42
|
if (typeof window === "undefined" || !window.oaiq) {
|
|
43
43
|
console.warn("oaiq has not been initialized");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const email = require_utils_field.getFirst(
|
|
47
|
-
const address = require_utils_field.getFirst(
|
|
46
|
+
const email = require_utils_field.getFirst(user_data?.email)?.trim().toLowerCase();
|
|
47
|
+
const address = require_utils_field.getFirst(user_data?.address);
|
|
48
48
|
const base = {
|
|
49
49
|
country: address?.country?.trim().toUpperCase(),
|
|
50
50
|
city: address?.city?.trim().toLowerCase(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-pixel.cjs","names":["NON_AD_EVENTS","mapOAIEvent","getFirst"],"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';\
|
|
1
|
+
{"version":3,"file":"openai-pixel.cjs","names":["NON_AD_EVENTS","mapOAIEvent","getFirst"],"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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, user_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(user_data?.email)?.trim().toLowerCase();\n const address = getFirst(user_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":";;;;;AAYA,SAAS,MAAM,OAAqB;CAClC,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;;;;;;AAOA,SAAgB,gBACd,MACA,YACA,SACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,+BAA+B;EAC5C;CACF;CACA,IAAIA,mBAAAA,cAAc,SAAS,IA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,OAAO,KAAK,IAAI,KAAA,GAAW,UAAU,OAAO,OAAO,IAAI,KAAA,CAAS,CAAC,CAAC,CACpF,MAAM,CAAC,cAAc,wBAAwB,KAAK;GAAE;GAAc;EAAmB,CAAC,CAAC,CAAC,CACxF,YAAY,KAAK,CAAC,CAAC,CAAC;CACzB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
import { OAIQ } from "../track/oaiq.cjs";
|
|
4
4
|
//#region src/third-parties/openai-pixel.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, proper
|
|
|
16
16
|
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
17
17
|
* so the `init` call is deferred until the digests resolve.
|
|
18
18
|
*/
|
|
19
|
-
declare function setOpenAIUser(pixelId: string): ({ user_id,
|
|
19
|
+
declare function setOpenAIUser(pixelId: string): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { sendOpenAIEvent, setOpenAIUser };
|
|
22
22
|
//# sourceMappingURL=openai-pixel.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-pixel.d.cts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,
|
|
1
|
+
{"version":3,"file":"openai-pixel.d.cts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,aACX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
3
|
import { OAIQ } from "../track/oaiq.mjs";
|
|
4
4
|
//#region src/third-parties/openai-pixel.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, proper
|
|
|
16
16
|
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
17
17
|
* so the `init` call is deferred until the digests resolve.
|
|
18
18
|
*/
|
|
19
|
-
declare function setOpenAIUser(pixelId: string): ({ user_id,
|
|
19
|
+
declare function setOpenAIUser(pixelId: string): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { sendOpenAIEvent, setOpenAIUser };
|
|
22
22
|
//# sourceMappingURL=openai-pixel.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-pixel.d.mts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,
|
|
1
|
+
{"version":3,"file":"openai-pixel.d.mts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,aACX"}
|
|
@@ -37,13 +37,13 @@ async function sha256(value) {
|
|
|
37
37
|
* so the `init` call is deferred until the digests resolve.
|
|
38
38
|
*/
|
|
39
39
|
function setOpenAIUser(pixelId) {
|
|
40
|
-
return ({ user_id,
|
|
40
|
+
return ({ user_id, user_data }) => {
|
|
41
41
|
if (typeof window === "undefined" || !window.oaiq) {
|
|
42
42
|
console.warn("oaiq has not been initialized");
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
const email = getFirst(
|
|
46
|
-
const address = getFirst(
|
|
45
|
+
const email = getFirst(user_data?.email)?.trim().toLowerCase();
|
|
46
|
+
const address = getFirst(user_data?.address);
|
|
47
47
|
const base = {
|
|
48
48
|
country: address?.country?.trim().toUpperCase(),
|
|
49
49
|
city: address?.city?.trim().toLowerCase(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-pixel.mjs","names":[],"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';\
|
|
1
|
+
{"version":3,"file":"openai-pixel.mjs","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\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, user_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(user_data?.email)?.trim().toLowerCase();\n const address = getFirst(user_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":";;;;AAYA,SAAS,MAAM,OAAqB;CAClC,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;;;;;;AAOA,SAAgB,gBACd,MACA,YACA,SACA;CACA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E,GAAG;KAAM,GAAG;IAAO,CAAC;GAAE,CAAC;EACtE;EAEA,QAAQ,IAAI,CAAC,QAAQ,OAAO,KAAK,IAAI,KAAA,GAAW,UAAU,OAAO,OAAO,IAAI,KAAA,CAAS,CAAC,CAAC,CACpF,MAAM,CAAC,cAAc,wBAAwB,KAAK;GAAE;GAAc;EAAmB,CAAC,CAAC,CAAC,CACxF,YAAY,KAAK,CAAC,CAAC,CAAC;CACzB;AACF"}
|
|
@@ -17,9 +17,9 @@ function sendPosthogEvent(name, properties) {
|
|
|
17
17
|
posthog_js.posthog.capture(name, properties);
|
|
18
18
|
if (name === "logout") posthog_js.posthog.reset();
|
|
19
19
|
}
|
|
20
|
-
function setPosthogUser({ user_id, distinct_id,
|
|
20
|
+
function setPosthogUser({ user_id, distinct_id, user_data }) {
|
|
21
21
|
if (!distinct_id && !user_id) return;
|
|
22
|
-
posthog_js.posthog.identify(distinct_id ?? user_id, { email: require_utils_field.getFirst(
|
|
22
|
+
posthog_js.posthog.identify(distinct_id ?? user_id, { email: require_utils_field.getFirst(user_data?.email) });
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
25
|
exports.sendPosthogEvent = sendPosthogEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog.cjs","names":["getFirst"],"sources":["../../src/third-parties/posthog.ts"],"sourcesContent":["import { posthog } from 'posthog-js';\nimport type {
|
|
1
|
+
{"version":3,"file":"posthog.cjs","names":["getFirst"],"sources":["../../src/third-parties/posthog.ts"],"sourcesContent":["import { posthog } from 'posthog-js';\nimport type { UpdateVisitorDTO } from '../schema/index';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendPosthogEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\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 posthog.capture(name, properties);\n if (name === 'logout') {\n posthog.reset();\n }\n}\n\nexport function setPosthogUser({ user_id, distinct_id, user_data }: UpdateVisitorDTO) {\n if (!distinct_id && !user_id) return;\n posthog.identify(distinct_id ?? user_id, { email: getFirst(user_data?.email) });\n}\n"],"mappings":";;;;AAKA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,iBACd,MACA,YACA;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,WAAA,QAAQ,QAAQ,MAAM,UAAU;CAChC,IAAI,SAAS,UACX,WAAA,QAAQ,MAAM;AAElB;AAEA,SAAgB,eAAe,EAAE,SAAS,aAAa,aAA+B;CACpF,IAAI,CAAC,eAAe,CAAC,SAAS;CAC9B,WAAA,QAAQ,SAAS,eAAe,SAAS,EAAE,OAAOA,oBAAAA,SAAS,WAAW,KAAK,EAAE,CAAC;AAChF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
//#region src/third-parties/posthog.d.ts
|
|
4
4
|
declare function sendPosthogEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
5
|
-
declare function setPosthogUser({ user_id, distinct_id,
|
|
5
|
+
declare function setPosthogUser({ user_id, distinct_id, user_data }: UpdateVisitorDTO): void;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { sendPosthogEvent, setPosthogUser };
|
|
8
8
|
//# sourceMappingURL=posthog.d.cts.map
|