@shware/analytics 16.3.6 → 16.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/native/fingerprint.cjs +6 -1
  2. package/dist/native/fingerprint.cjs.map +1 -1
  3. package/dist/native/fingerprint.d.cts +5 -0
  4. package/dist/native/fingerprint.d.cts.map +1 -1
  5. package/dist/native/fingerprint.d.mts +5 -0
  6. package/dist/native/fingerprint.d.mts.map +1 -1
  7. package/dist/native/fingerprint.mjs +6 -1
  8. package/dist/native/fingerprint.mjs.map +1 -1
  9. package/dist/native/setup.cjs +2 -2
  10. package/dist/native/setup.cjs.map +1 -1
  11. package/dist/native/setup.mjs +2 -2
  12. package/dist/native/setup.mjs.map +1 -1
  13. package/dist/server/linkedin-conversions-api.cjs +9 -3
  14. package/dist/server/linkedin-conversions-api.cjs.map +1 -1
  15. package/dist/server/linkedin-conversions-api.d.cts +3 -1
  16. package/dist/server/linkedin-conversions-api.d.cts.map +1 -1
  17. package/dist/server/linkedin-conversions-api.d.mts +3 -1
  18. package/dist/server/linkedin-conversions-api.d.mts.map +1 -1
  19. package/dist/server/linkedin-conversions-api.mjs +9 -3
  20. package/dist/server/linkedin-conversions-api.mjs.map +1 -1
  21. package/dist/server/meta-capi.cjs +5 -1
  22. package/dist/server/meta-capi.cjs.map +1 -1
  23. package/dist/server/meta-capi.d.cts.map +1 -1
  24. package/dist/server/meta-capi.d.mts.map +1 -1
  25. package/dist/server/meta-capi.mjs +5 -1
  26. package/dist/server/meta-capi.mjs.map +1 -1
  27. package/dist/track/index.cjs +4 -4
  28. package/dist/track/index.cjs.map +1 -1
  29. package/dist/track/index.mjs +4 -4
  30. package/dist/track/index.mjs.map +1 -1
  31. package/dist/web/index.cjs +2 -2
  32. package/dist/web/index.cjs.map +1 -1
  33. package/dist/web/index.mjs +2 -2
  34. package/dist/web/index.mjs.map +1 -1
  35. package/package.json +1 -1
@@ -14,7 +14,12 @@ async function getDeterministicFingerprint() {
14
14
  if (!install_referrer) return { click_id: null };
15
15
  return { click_id: new URLSearchParams(install_referrer).get("click_id") ?? null };
16
16
  }
17
- async function getProbabilisticFingerprint(shouldUseClipboard = true) {
17
+ /**
18
+ * The device profile used to match an install to the click that led to it. `shouldUseClipboard`
19
+ * also reads the clipboard for a pasted link; off by default, since reading it shows the system's
20
+ * "pasted from" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.
21
+ */
22
+ async function getProbabilisticFingerprint(shouldUseClipboard = false) {
18
23
  const screen = react_native.Dimensions.get("screen");
19
24
  const screen_width = Math.floor(screen.width);
20
25
  const screen_height = Math.floor(screen.height);
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.cjs","names":["Platform","getInstallReferrerAsync","Dimensions","osName","osVersion","supportedCpuArchitectures","modelName","manufacturer","modelId","PixelRatio","getLocales","getCalendars","getStringAsync"],"sources":["../../src/native/fingerprint.ts"],"sourcesContent":["/**\n * reference: https://docs.swmansion.com/detour/docs/Architecture/matching\n *\n */\nimport { getInstallReferrerAsync } from 'expo-application';\nimport { getStringAsync } from 'expo-clipboard';\nimport {\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n supportedCpuArchitectures,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\n\n// used when install referrer on android is available\nexport type DeterministicFingerprint = {\n click_id: string | null;\n};\n\nexport type ProbabilisticFingerprint = {\n os: string | null;\n os_name: string | null;\n os_version: string | null;\n cpu_architecture: string | null;\n platform: 'ios' | 'android' | 'web' | 'macos' | 'windows' | 'linux' | 'unknown';\n device: string | null;\n device_vendor: string | null;\n device_model_id: string | null;\n device_pixel_ratio: number;\n screen_width: number;\n screen_height: number;\n screen_resolution: string;\n language: string | null;\n time_zone: string | null;\n install_referrer: string | null;\n pasted_link: string | null;\n timestamp: number; // 7 days validity\n};\n\nexport async function getDeterministicFingerprint(): Promise<DeterministicFingerprint> {\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n if (!install_referrer) return { click_id: null };\n const params = new URLSearchParams(install_referrer);\n return { click_id: params.get('click_id') ?? null };\n}\n\nexport async function getProbabilisticFingerprint(\n shouldUseClipboard = true\n): Promise<ProbabilisticFingerprint> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n\n return {\n os: osName && osVersion ? `${osName} ${osVersion}` : null,\n os_name: osName,\n os_version: osVersion,\n cpu_architecture: supportedCpuArchitectures?.at(0) ?? null,\n platform: Platform.OS,\n device: modelName,\n device_vendor: manufacturer,\n device_model_id: modelId,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n language: getLocales().at(0)?.languageTag ?? null,\n time_zone: getCalendars().at(0)?.timeZone ?? null,\n install_referrer,\n pasted_link: shouldUseClipboard ? await getStringAsync() : null,\n timestamp: Date.now(),\n };\n}\n"],"mappings":";;;;;;;;;;;AA0CA,eAAsB,8BAAiE;CACrF,MAAM,mBAAmBA,aAAAA,SAAS,OAAO,YAAY,OAAA,GAAMC,iBAAAA,wBAAAA,CAAwB,IAAI;CACvF,IAAI,CAAC,kBAAkB,OAAO,EAAE,UAAU,KAAK;CAE/C,OAAO,EAAE,UAAU,IADA,gBAAgB,gBACX,CAAC,CAAC,IAAI,UAAU,KAAK,KAAK;AACpD;AAEA,eAAsB,4BACpB,qBAAqB,MACc;CACnC,MAAM,SAASC,aAAAA,WAAW,IAAI,QAAQ;CACtC,MAAM,eAAe,KAAK,MAAM,OAAO,KAAK;CAC5C,MAAM,gBAAgB,KAAK,MAAM,OAAO,MAAM;CAC9C,MAAM,mBAAmBF,aAAAA,SAAS,OAAO,YAAY,OAAA,GAAMC,iBAAAA,wBAAAA,CAAwB,IAAI;CAEvF,OAAO;EACL,IAAIE,YAAAA,UAAUC,YAAAA,YAAY,GAAGD,YAAAA,OAAO,GAAGC,YAAAA,cAAc;EACrD,SAASD,YAAAA;EACT,YAAYC,YAAAA;EACZ,kBAAkBC,YAAAA,2BAA2B,GAAG,CAAC,KAAK;EACtD,UAAUL,aAAAA,SAAS;EACnB,QAAQM,YAAAA;EACR,eAAeC,YAAAA;EACf,iBAAiBC,YAAAA;EACjB,oBAAoBC,aAAAA,WAAW,IAAI;EACnC;EACA;EACA,mBAAmB,GAAG,aAAa,GAAG;EACtC,WAAA,GAAUC,kBAAAA,WAAAA,CAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe;EAC7C,YAAA,GAAWC,kBAAAA,aAAAA,CAAa,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY;EAC7C;EACA,aAAa,qBAAqB,OAAA,GAAMC,eAAAA,eAAAA,CAAe,IAAI;EAC3D,WAAW,KAAK,IAAI;CACtB;AACF"}
1
+ {"version":3,"file":"fingerprint.cjs","names":["Platform","getInstallReferrerAsync","Dimensions","osName","osVersion","supportedCpuArchitectures","modelName","manufacturer","modelId","PixelRatio","getLocales","getCalendars","getStringAsync"],"sources":["../../src/native/fingerprint.ts"],"sourcesContent":["/**\n * reference: https://docs.swmansion.com/detour/docs/Architecture/matching\n *\n */\nimport { getInstallReferrerAsync } from 'expo-application';\nimport { getStringAsync } from 'expo-clipboard';\nimport {\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n supportedCpuArchitectures,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\n\n// used when install referrer on android is available\nexport type DeterministicFingerprint = {\n click_id: string | null;\n};\n\nexport type ProbabilisticFingerprint = {\n os: string | null;\n os_name: string | null;\n os_version: string | null;\n cpu_architecture: string | null;\n platform: 'ios' | 'android' | 'web' | 'macos' | 'windows' | 'linux' | 'unknown';\n device: string | null;\n device_vendor: string | null;\n device_model_id: string | null;\n device_pixel_ratio: number;\n screen_width: number;\n screen_height: number;\n screen_resolution: string;\n language: string | null;\n time_zone: string | null;\n install_referrer: string | null;\n pasted_link: string | null;\n timestamp: number; // 7 days validity\n};\n\nexport async function getDeterministicFingerprint(): Promise<DeterministicFingerprint> {\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n if (!install_referrer) return { click_id: null };\n const params = new URLSearchParams(install_referrer);\n return { click_id: params.get('click_id') ?? null };\n}\n\n/**\n * The device profile used to match an install to the click that led to it. `shouldUseClipboard`\n * also reads the clipboard for a pasted link; off by default, since reading it shows the system's\n * \"pasted from\" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.\n */\nexport async function getProbabilisticFingerprint(\n shouldUseClipboard = false\n): Promise<ProbabilisticFingerprint> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n\n return {\n os: osName && osVersion ? `${osName} ${osVersion}` : null,\n os_name: osName,\n os_version: osVersion,\n cpu_architecture: supportedCpuArchitectures?.at(0) ?? null,\n platform: Platform.OS,\n device: modelName,\n device_vendor: manufacturer,\n device_model_id: modelId,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n language: getLocales().at(0)?.languageTag ?? null,\n time_zone: getCalendars().at(0)?.timeZone ?? null,\n install_referrer,\n pasted_link: shouldUseClipboard ? await getStringAsync() : null,\n timestamp: Date.now(),\n };\n}\n"],"mappings":";;;;;;;;;;;AA0CA,eAAsB,8BAAiE;CACrF,MAAM,mBAAmBA,aAAAA,SAAS,OAAO,YAAY,OAAA,GAAMC,iBAAAA,wBAAAA,CAAwB,IAAI;CACvF,IAAI,CAAC,kBAAkB,OAAO,EAAE,UAAU,KAAK;CAE/C,OAAO,EAAE,UAAU,IADA,gBAAgB,gBACX,CAAC,CAAC,IAAI,UAAU,KAAK,KAAK;AACpD;;;;;;AAOA,eAAsB,4BACpB,qBAAqB,OACc;CACnC,MAAM,SAASC,aAAAA,WAAW,IAAI,QAAQ;CACtC,MAAM,eAAe,KAAK,MAAM,OAAO,KAAK;CAC5C,MAAM,gBAAgB,KAAK,MAAM,OAAO,MAAM;CAC9C,MAAM,mBAAmBF,aAAAA,SAAS,OAAO,YAAY,OAAA,GAAMC,iBAAAA,wBAAAA,CAAwB,IAAI;CAEvF,OAAO;EACL,IAAIE,YAAAA,UAAUC,YAAAA,YAAY,GAAGD,YAAAA,OAAO,GAAGC,YAAAA,cAAc;EACrD,SAASD,YAAAA;EACT,YAAYC,YAAAA;EACZ,kBAAkBC,YAAAA,2BAA2B,GAAG,CAAC,KAAK;EACtD,UAAUL,aAAAA,SAAS;EACnB,QAAQM,YAAAA;EACR,eAAeC,YAAAA;EACf,iBAAiBC,YAAAA;EACjB,oBAAoBC,aAAAA,WAAW,IAAI;EACnC;EACA;EACA,mBAAmB,GAAG,aAAa,GAAG;EACtC,WAAA,GAAUC,kBAAAA,WAAAA,CAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe;EAC7C,YAAA,GAAWC,kBAAAA,aAAAA,CAAa,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY;EAC7C;EACA,aAAa,qBAAqB,OAAA,GAAMC,eAAAA,eAAAA,CAAe,IAAI;EAC3D,WAAW,KAAK,IAAI;CACtB;AACF"}
@@ -21,5 +21,10 @@ export type ProbabilisticFingerprint = {
21
21
  timestamp: number;
22
22
  };
23
23
  export declare function getDeterministicFingerprint(): Promise<DeterministicFingerprint>;
24
+ /**
25
+ * The device profile used to match an install to the click that led to it. `shouldUseClipboard`
26
+ * also reads the clipboard for a pasted link; off by default, since reading it shows the system's
27
+ * "pasted from" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.
28
+ */
24
29
  export declare function getProbabilisticFingerprint(shouldUseClipboard?: boolean): Promise<ProbabilisticFingerprint>;
25
30
  //# sourceMappingURL=fingerprint.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.d.cts","names":[],"sources":["../../src/native/fingerprint.ts"],"mappings":"A,YAkBY;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,+BAA+B,QAAQ;wBAOvC,4BACpB,+BACC,QAAQ"}
1
+ {"version":3,"file":"fingerprint.d.cts","names":[],"sources":["../../src/native/fingerprint.ts"],"mappings":"A,YAkBY;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,+BAA+B,QAAQ;;;;;;wBAYvC,4BACpB,+BACC,QAAQ"}
@@ -21,5 +21,10 @@ export type ProbabilisticFingerprint = {
21
21
  timestamp: number;
22
22
  };
23
23
  export declare function getDeterministicFingerprint(): Promise<DeterministicFingerprint>;
24
+ /**
25
+ * The device profile used to match an install to the click that led to it. `shouldUseClipboard`
26
+ * also reads the clipboard for a pasted link; off by default, since reading it shows the system's
27
+ * "pasted from" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.
28
+ */
24
29
  export declare function getProbabilisticFingerprint(shouldUseClipboard?: boolean): Promise<ProbabilisticFingerprint>;
25
30
  //# sourceMappingURL=fingerprint.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.d.mts","names":[],"sources":["../../src/native/fingerprint.ts"],"mappings":"A,YAkBY;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,+BAA+B,QAAQ;wBAOvC,4BACpB,+BACC,QAAQ"}
1
+ {"version":3,"file":"fingerprint.d.mts","names":[],"sources":["../../src/native/fingerprint.ts"],"mappings":"A,YAkBY;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,+BAA+B,QAAQ;;;;;;wBAYvC,4BACpB,+BACC,QAAQ"}
@@ -13,7 +13,12 @@ async function getDeterministicFingerprint() {
13
13
  if (!install_referrer) return { click_id: null };
14
14
  return { click_id: new URLSearchParams(install_referrer).get("click_id") ?? null };
15
15
  }
16
- async function getProbabilisticFingerprint(shouldUseClipboard = true) {
16
+ /**
17
+ * The device profile used to match an install to the click that led to it. `shouldUseClipboard`
18
+ * also reads the clipboard for a pasted link; off by default, since reading it shows the system's
19
+ * "pasted from" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.
20
+ */
21
+ async function getProbabilisticFingerprint(shouldUseClipboard = false) {
17
22
  const screen = Dimensions.get("screen");
18
23
  const screen_width = Math.floor(screen.width);
19
24
  const screen_height = Math.floor(screen.height);
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.mjs","names":[],"sources":["../../src/native/fingerprint.ts"],"sourcesContent":["/**\n * reference: https://docs.swmansion.com/detour/docs/Architecture/matching\n *\n */\nimport { getInstallReferrerAsync } from 'expo-application';\nimport { getStringAsync } from 'expo-clipboard';\nimport {\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n supportedCpuArchitectures,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\n\n// used when install referrer on android is available\nexport type DeterministicFingerprint = {\n click_id: string | null;\n};\n\nexport type ProbabilisticFingerprint = {\n os: string | null;\n os_name: string | null;\n os_version: string | null;\n cpu_architecture: string | null;\n platform: 'ios' | 'android' | 'web' | 'macos' | 'windows' | 'linux' | 'unknown';\n device: string | null;\n device_vendor: string | null;\n device_model_id: string | null;\n device_pixel_ratio: number;\n screen_width: number;\n screen_height: number;\n screen_resolution: string;\n language: string | null;\n time_zone: string | null;\n install_referrer: string | null;\n pasted_link: string | null;\n timestamp: number; // 7 days validity\n};\n\nexport async function getDeterministicFingerprint(): Promise<DeterministicFingerprint> {\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n if (!install_referrer) return { click_id: null };\n const params = new URLSearchParams(install_referrer);\n return { click_id: params.get('click_id') ?? null };\n}\n\nexport async function getProbabilisticFingerprint(\n shouldUseClipboard = true\n): Promise<ProbabilisticFingerprint> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n\n return {\n os: osName && osVersion ? `${osName} ${osVersion}` : null,\n os_name: osName,\n os_version: osVersion,\n cpu_architecture: supportedCpuArchitectures?.at(0) ?? null,\n platform: Platform.OS,\n device: modelName,\n device_vendor: manufacturer,\n device_model_id: modelId,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n language: getLocales().at(0)?.languageTag ?? null,\n time_zone: getCalendars().at(0)?.timeZone ?? null,\n install_referrer,\n pasted_link: shouldUseClipboard ? await getStringAsync() : null,\n timestamp: Date.now(),\n };\n}\n"],"mappings":";;;;;;;;;;AA0CA,eAAsB,8BAAiE;CACrF,MAAM,mBAAmB,SAAS,OAAO,YAAY,MAAM,wBAAwB,IAAI;CACvF,IAAI,CAAC,kBAAkB,OAAO,EAAE,UAAU,KAAK;CAE/C,OAAO,EAAE,UAAU,IADA,gBAAgB,gBACX,CAAC,CAAC,IAAI,UAAU,KAAK,KAAK;AACpD;AAEA,eAAsB,4BACpB,qBAAqB,MACc;CACnC,MAAM,SAAS,WAAW,IAAI,QAAQ;CACtC,MAAM,eAAe,KAAK,MAAM,OAAO,KAAK;CAC5C,MAAM,gBAAgB,KAAK,MAAM,OAAO,MAAM;CAC9C,MAAM,mBAAmB,SAAS,OAAO,YAAY,MAAM,wBAAwB,IAAI;CAEvF,OAAO;EACL,IAAI,UAAU,YAAY,GAAG,OAAO,GAAG,cAAc;EACrD,SAAS;EACT,YAAY;EACZ,kBAAkB,2BAA2B,GAAG,CAAC,KAAK;EACtD,UAAU,SAAS;EACnB,QAAQ;EACR,eAAe;EACf,iBAAiB;EACjB,oBAAoB,WAAW,IAAI;EACnC;EACA;EACA,mBAAmB,GAAG,aAAa,GAAG;EACtC,UAAU,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe;EAC7C,WAAW,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY;EAC7C;EACA,aAAa,qBAAqB,MAAM,eAAe,IAAI;EAC3D,WAAW,KAAK,IAAI;CACtB;AACF"}
1
+ {"version":3,"file":"fingerprint.mjs","names":[],"sources":["../../src/native/fingerprint.ts"],"sourcesContent":["/**\n * reference: https://docs.swmansion.com/detour/docs/Architecture/matching\n *\n */\nimport { getInstallReferrerAsync } from 'expo-application';\nimport { getStringAsync } from 'expo-clipboard';\nimport {\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n supportedCpuArchitectures,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\n\n// used when install referrer on android is available\nexport type DeterministicFingerprint = {\n click_id: string | null;\n};\n\nexport type ProbabilisticFingerprint = {\n os: string | null;\n os_name: string | null;\n os_version: string | null;\n cpu_architecture: string | null;\n platform: 'ios' | 'android' | 'web' | 'macos' | 'windows' | 'linux' | 'unknown';\n device: string | null;\n device_vendor: string | null;\n device_model_id: string | null;\n device_pixel_ratio: number;\n screen_width: number;\n screen_height: number;\n screen_resolution: string;\n language: string | null;\n time_zone: string | null;\n install_referrer: string | null;\n pasted_link: string | null;\n timestamp: number; // 7 days validity\n};\n\nexport async function getDeterministicFingerprint(): Promise<DeterministicFingerprint> {\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n if (!install_referrer) return { click_id: null };\n const params = new URLSearchParams(install_referrer);\n return { click_id: params.get('click_id') ?? null };\n}\n\n/**\n * The device profile used to match an install to the click that led to it. `shouldUseClipboard`\n * also reads the clipboard for a pasted link; off by default, since reading it shows the system's\n * \"pasted from\" banner on iOS 14+ and Android 12+, so turn it on only where that is acceptable.\n */\nexport async function getProbabilisticFingerprint(\n shouldUseClipboard = false\n): Promise<ProbabilisticFingerprint> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n const install_referrer = Platform.OS === 'android' ? await getInstallReferrerAsync() : null;\n\n return {\n os: osName && osVersion ? `${osName} ${osVersion}` : null,\n os_name: osName,\n os_version: osVersion,\n cpu_architecture: supportedCpuArchitectures?.at(0) ?? null,\n platform: Platform.OS,\n device: modelName,\n device_vendor: manufacturer,\n device_model_id: modelId,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n language: getLocales().at(0)?.languageTag ?? null,\n time_zone: getCalendars().at(0)?.timeZone ?? null,\n install_referrer,\n pasted_link: shouldUseClipboard ? await getStringAsync() : null,\n timestamp: Date.now(),\n };\n}\n"],"mappings":";;;;;;;;;;AA0CA,eAAsB,8BAAiE;CACrF,MAAM,mBAAmB,SAAS,OAAO,YAAY,MAAM,wBAAwB,IAAI;CACvF,IAAI,CAAC,kBAAkB,OAAO,EAAE,UAAU,KAAK;CAE/C,OAAO,EAAE,UAAU,IADA,gBAAgB,gBACX,CAAC,CAAC,IAAI,UAAU,KAAK,KAAK;AACpD;;;;;;AAOA,eAAsB,4BACpB,qBAAqB,OACc;CACnC,MAAM,SAAS,WAAW,IAAI,QAAQ;CACtC,MAAM,eAAe,KAAK,MAAM,OAAO,KAAK;CAC5C,MAAM,gBAAgB,KAAK,MAAM,OAAO,MAAM;CAC9C,MAAM,mBAAmB,SAAS,OAAO,YAAY,MAAM,wBAAwB,IAAI;CAEvF,OAAO;EACL,IAAI,UAAU,YAAY,GAAG,OAAO,GAAG,cAAc;EACrD,SAAS;EACT,YAAY;EACZ,kBAAkB,2BAA2B,GAAG,CAAC,KAAK;EACtD,UAAU,SAAS;EACnB,QAAQ;EACR,eAAe;EACf,iBAAiB;EACjB,oBAAoB,WAAW,IAAI;EACnC;EACA;EACA,mBAAmB,GAAG,aAAa,GAAG;EACtC,UAAU,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe;EAC7C,WAAW,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY;EAC7C;EACA,aAAa,qBAAqB,MAAM,eAAe,IAAI;EAC3D,WAAW,KAAK,IAAI;CACtB;AACF"}
@@ -15,7 +15,7 @@ const storage = {
15
15
  try {
16
16
  return localStorage.getItem(key);
17
17
  } catch {
18
- console.error("localStorage is not available");
18
+ console.warn("localStorage is not available; falling back to in-memory storage");
19
19
  return map.get(key) ?? null;
20
20
  }
21
21
  },
@@ -23,7 +23,7 @@ const storage = {
23
23
  try {
24
24
  localStorage.setItem(key, value);
25
25
  } catch {
26
- console.error("localStorage is not available");
26
+ console.warn("localStorage is not available; falling back to in-memory storage");
27
27
  map.set(key, value);
28
28
  }
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setup.cjs","names":["Platform","getInstallReferrerAsync","getIosIdForVendorAsync","getAndroidId","randomUUID","deviceType","DeviceType","config","keys","Dimensions","osName","osVersion","modelName","manufacturer","modelId","PixelRatio","getLocales","getCalendars","getAdvertisingId"],"sources":["../../src/native/setup.ts"],"sourcesContent":["import 'expo-sqlite/localStorage/install';\nimport { getAndroidId, getInstallReferrerAsync, getIosIdForVendorAsync } from 'expo-application';\nimport { randomUUID } from 'expo-crypto';\nimport {\n DeviceType,\n deviceType,\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { getAdvertisingId } from 'expo-tracking-transparency';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\nimport { keys } from '../constants/storage';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n\n/**\n * `getTags` runs once per event now, and both of these reach for a native module. Neither answer\n * can change while the app is running, so each is resolved once and the promise is reused. A\n * failed lookup is not cached, so the next event tries again.\n */\nlet deviceIdPromise: Promise<string> | undefined;\nlet installReferrerPromise: Promise<string | undefined> | undefined;\n\nexport function getDeviceId(): Promise<string> {\n deviceIdPromise ??= resolveDeviceId().catch((error: unknown) => {\n deviceIdPromise = undefined;\n throw error;\n });\n return deviceIdPromise;\n}\n\nfunction getInstallReferrer(): Promise<string | undefined> {\n if (Platform.OS !== 'android') return Promise.resolve(undefined);\n installReferrerPromise ??= getInstallReferrerAsync().catch((error: unknown) => {\n installReferrerPromise = undefined;\n throw error;\n });\n return installReferrerPromise;\n}\n\nasync function resolveDeviceId(): Promise<string> {\n let deviceId: string | null = null;\n if (Platform.OS === 'ios') {\n deviceId = await getIosIdForVendorAsync();\n } else if (Platform.OS === 'android') {\n deviceId = getAndroidId();\n }\n if (!deviceId) {\n deviceId = localStorage.getItem('device_id');\n if (!deviceId) {\n deviceId = randomUUID();\n localStorage.setItem('device_id', deviceId);\n }\n }\n return deviceId;\n}\n\nexport function getDeviceType(): string | undefined {\n switch (deviceType) {\n case DeviceType.PHONE:\n return 'mobile';\n case DeviceType.TABLET:\n return 'tablet';\n case DeviceType.DESKTOP:\n return 'desktop';\n case DeviceType.TV:\n return 'smarttv';\n default:\n return undefined;\n }\n}\n\n/**\n * The install referrer's utm belongs to one launch: the first one that has the referrer in hand\n * — normally the install launch, since `first_open` is the first event the app tracks and\n * tracking it builds the first tags. That launch claims the referrer by writing a marker of its\n * own, and holds the claim for the rest of the process, so every event of the launch and the\n * visitor created from it carry the utm; every later launch finds the marker and sends the raw\n * `install_referrer` alone. Cleared storage and a reinstall lose the marker and claim again,\n * exactly as they make `first_open` fire again.\n *\n * Claimed only once a referrer has actually been resolved. The Install Referrer API needs the\n * Play Store service, which is at its least available right after an install; a launch that\n * could not reach it must not spend the claim on nothing, because the referrer stays readable\n * for 90 days and a later launch can still take it — late attribution, rather than none. iOS\n * has no referrer and so never claims.\n *\n * A marker of its own rather than `first_open_time`, so that nothing here depends on when the\n * hook writes that one relative to the first `getTags`. The storage read waits for that call:\n * `setupAnalytics` and this module's evaluation can run where no storage exists.\n */\nlet installLaunch: boolean | undefined;\n\nfunction claimInstallReferrer(): boolean {\n if (config.storage.getItem(keys.install_referrer_claim_time)) return false;\n config.storage.setItem(keys.install_referrer_claim_time, new Date().toISOString());\n return true;\n}\n\nexport async function getTags(): Promise<TrackTags> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n\n // The install referrer never changes, and it used to be spread into `utm_*` on every launch —\n // so every session of an Android install reported the install campaign as its own acquisition\n // for as long as the app stayed installed, and a report reading a session's tags could not tell\n // the install from the thousandth open. The campaign is the install's touch, not every\n // session's.\n const install_referrer = await getInstallReferrer();\n if (install_referrer && installLaunch === undefined) installLaunch = claimInstallReferrer();\n const params = new URLSearchParams(installLaunch ? install_referrer : undefined);\n const opening = await config.deepLink?.getTags();\n\n const tags: TrackTags = {\n os: `${osName} ${osVersion}`,\n os_name: osName ?? undefined,\n os_version: osVersion ?? undefined,\n device: modelName ?? undefined,\n device_id: await getDeviceId(),\n device_type: getDeviceType(),\n device_vendor: manufacturer ?? undefined,\n device_model_id: modelId ?? undefined,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n release: config.release,\n language: getLocales().at(0)?.languageTag ?? 'en',\n time_zone: getCalendars().at(0)?.timeZone ?? 'UTC',\n // ads\n advertising_id: getAdvertisingId() ?? undefined,\n install_referrer,\n // utm params: from the install referrer, on the launch that claimed it\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n utm_id: params.get('utm_id') ?? undefined,\n utm_source_platform: params.get('utm_source_platform') ?? undefined,\n utm_creative_format: params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic: params.get('utm_marketing_tactic') ?? undefined,\n // the link that opened the app (`setupAnalytics({ deepLink })`): its URL, utm and click ids,\n // over the install referrer's\n ...opening,\n };\n\n cache.tags = tags;\n return tags;\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,sBAAM,IAAI,IAAoB;AAEpC,MAAa,UAAmB;CAC9B,UAAU,QAAQ;EAChB,IAAI;GACF,OAAO,aAAa,QAAQ,GAAG;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,UAAU,KAAK,UAAU;EACvB,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,MAAM,+BAA+B;GAC7C,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF;;;;;;AAOA,IAAI;AACJ,IAAI;AAEJ,SAAgB,cAA+B;CAC7C,oBAAoB,gBAAgB,CAAC,CAAC,OAAO,UAAmB;EAC9D,kBAAkB,KAAA;EAClB,MAAM;CACR,CAAC;CACD,OAAO;AACT;AAEA,SAAS,qBAAkD;CACzD,IAAIA,aAAAA,SAAS,OAAO,WAAW,OAAO,QAAQ,QAAQ,KAAA,CAAS;CAC/D,4BAAA,GAA2BC,iBAAAA,wBAAAA,CAAwB,CAAC,CAAC,OAAO,UAAmB;EAC7E,yBAAyB,KAAA;EACzB,MAAM;CACR,CAAC;CACD,OAAO;AACT;AAEA,eAAe,kBAAmC;CAChD,IAAI,WAA0B;CAC9B,IAAID,aAAAA,SAAS,OAAO,OAClB,WAAW,OAAA,GAAME,iBAAAA,u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YAAAA,aAAa,KAAA;EACrB,WAAW,MAAM,YAAY;EAC7B,aAAa,cAAc;EAC3B,eAAeC,YAAAA,gBAAgB,KAAA;EAC/B,iBAAiBC,YAAAA,WAAW,KAAA;EAC5B,oBAAoBC,aAAAA,WAAW,IAAI;EACnC;EACA;EACA,mBAAmB,GAAG,aAAa,GAAG;EACtC,SAASR,oBAAAA,OAAO;EAChB,WAAA,GAAUS,kBAAAA,WAAAA,CAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe;EAC7C,YAAA,GAAWC,kBAAAA,aAAAA,CAAa,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY;EAE7C,iBAAA,GAAgBC,2BAAAA,iBAAAA,CAAiB,KAAK,KAAA;EACtC;EAEA,YAAY,OAAO,IAAI,YAAY,KAAK,KAAA;EACxC,YAAY,OAAO,IAAI,YAAY,KAAK,KAAA;EACxC,cAAc,OAAO,IAAI,cAAc,KAAK,KAAA;EAC5C,UAAU,OAAO,IAAI,UAAU,KAAK,KAAA;EACpC,aAAa,OAAO,IAAI,aAAa,KAAK,KAAA;EAC1C,QAAQ,OAAO,IAAI,QAAQ,KAAK,KAAA;EAChC,qBAAqB,OAAO,IAAI,qBAAqB,KAAK,KAAA;EAC1D,qBAAqB,OAAO,IAAI,qBAAqB,KAAK,KAAA;EAC1D,sBAAsB,OAAO,IAAI,sBAAsB,KAAK,KAAA;EAG5D,GAAG;CACL;CAEA,oBAAA,MAAM,OAAO;CACb,OAAO;AACT"}
1
+ {"version":3,"file":"setup.cjs","names":["Platform","getInstallReferrerAsync","getIosIdForVendorAsync","getAndroidId","randomUUID","deviceType","DeviceType","config","keys","Dimensions","osName","osVersion","modelName","manufacturer","modelId","PixelRatio","getLocales","getCalendars","getAdvertisingId"],"sources":["../../src/native/setup.ts"],"sourcesContent":["import 'expo-sqlite/localStorage/install';\nimport { getAndroidId, getInstallReferrerAsync, getIosIdForVendorAsync } from 'expo-application';\nimport { randomUUID } from 'expo-crypto';\nimport {\n DeviceType,\n deviceType,\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { getAdvertisingId } from 'expo-tracking-transparency';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\nimport { keys } from '../constants/storage';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.warn('localStorage is not available; falling back to in-memory storage');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.warn('localStorage is not available; falling back to in-memory storage');\n map.set(key, value);\n }\n },\n};\n\n/**\n * `getTags` runs once per event now, and both of these reach for a native module. Neither answer\n * can change while the app is running, so each is resolved once and the promise is reused. A\n * failed lookup is not cached, so the next event tries again.\n */\nlet deviceIdPromise: Promise<string> | undefined;\nlet installReferrerPromise: Promise<string | undefined> | undefined;\n\nexport function getDeviceId(): Promise<string> {\n deviceIdPromise ??= resolveDeviceId().catch((error: unknown) => {\n deviceIdPromise = undefined;\n throw error;\n });\n return deviceIdPromise;\n}\n\nfunction getInstallReferrer(): Promise<string | undefined> {\n if (Platform.OS !== 'android') return Promise.resolve(undefined);\n installReferrerPromise ??= getInstallReferrerAsync().catch((error: unknown) => {\n installReferrerPromise = undefined;\n throw error;\n });\n return installReferrerPromise;\n}\n\nasync function resolveDeviceId(): Promise<string> {\n let deviceId: string | null = null;\n if (Platform.OS === 'ios') {\n deviceId = await getIosIdForVendorAsync();\n } else if (Platform.OS === 'android') {\n deviceId = getAndroidId();\n }\n if (!deviceId) {\n deviceId = localStorage.getItem('device_id');\n if (!deviceId) {\n deviceId = randomUUID();\n localStorage.setItem('device_id', deviceId);\n }\n }\n return deviceId;\n}\n\nexport function getDeviceType(): string | undefined {\n switch (deviceType) {\n case DeviceType.PHONE:\n return 'mobile';\n case DeviceType.TABLET:\n return 'tablet';\n case DeviceType.DESKTOP:\n return 'desktop';\n case DeviceType.TV:\n return 'smarttv';\n default:\n return undefined;\n }\n}\n\n/**\n * The install referrer's utm belongs to one launch: the first one that has the referrer in hand\n * — normally the install launch, since `first_open` is the first event the app tracks and\n * tracking it builds the first tags. That launch claims the referrer by writing a marker of its\n * own, and holds the claim for the rest of the process, so every event of the launch and the\n * visitor created from it carry the utm; every later launch finds the marker and sends the raw\n * `install_referrer` alone. Cleared storage and a reinstall lose the marker and claim again,\n * exactly as they make `first_open` fire again.\n *\n * Claimed only once a referrer has actually been resolved. The Install Referrer API needs the\n * Play Store service, which is at its least available right after an install; a launch that\n * could not reach it must not spend the claim on nothing, because the referrer stays readable\n * for 90 days and a later launch can still take it — late attribution, rather than none. iOS\n * has no referrer and so never claims.\n *\n * A marker of its own rather than `first_open_time`, so that nothing here depends on when the\n * hook writes that one relative to the first `getTags`. The storage read waits for that call:\n * `setupAnalytics` and this module's evaluation can run where no storage exists.\n */\nlet installLaunch: boolean | undefined;\n\nfunction claimInstallReferrer(): boolean {\n if (config.storage.getItem(keys.install_referrer_claim_time)) return false;\n config.storage.setItem(keys.install_referrer_claim_time, new Date().toISOString());\n return true;\n}\n\nexport async function getTags(): Promise<TrackTags> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n\n // The install referrer never changes, and it used to be spread into `utm_*` on every launch —\n // so every session of an Android install reported the install campaign as its own acquisition\n // for as long as the app stayed installed, and a report reading a session's tags could not tell\n // the install from the thousandth open. The campaign is the install's touch, not every\n // session's.\n const install_referrer = await getInstallReferrer();\n if (install_referrer && installLaunch === undefined) installLaunch = claimInstallReferrer();\n const params = new URLSearchParams(installLaunch ? install_referrer : undefined);\n const opening = await config.deepLink?.getTags();\n\n const tags: TrackTags = {\n os: `${osName} ${osVersion}`,\n os_name: osName ?? undefined,\n os_version: osVersion ?? undefined,\n device: modelName ?? undefined,\n device_id: await getDeviceId(),\n device_type: getDeviceType(),\n device_vendor: manufacturer ?? undefined,\n device_model_id: modelId ?? undefined,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n release: config.release,\n language: getLocales().at(0)?.languageTag ?? 'en',\n time_zone: getCalendars().at(0)?.timeZone ?? 'UTC',\n // ads\n advertising_id: getAdvertisingId() ?? undefined,\n install_referrer,\n // utm params: from the install referrer, on the launch that claimed it\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n utm_id: params.get('utm_id') ?? undefined,\n utm_source_platform: params.get('utm_source_platform') ?? undefined,\n utm_creative_format: params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic: params.get('utm_marketing_tactic') ?? undefined,\n // the link that opened the app (`setupAnalytics({ deepLink })`): its URL, utm and click ids,\n // over the install referrer's\n ...opening,\n };\n\n cache.tags = tags;\n return tags;\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,sBAAM,IAAI,IAAoB;AAEpC,MAAa,UAAmB;CAC9B,UAAU,QAAQ;EAChB,IAAI;GACF,OAAO,aAAa,QAAQ,GAAG;EACjC,QAAQ;GACN,QAAQ,KAAK,kEAAkE;GAC/E,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,UAAU,KAAK,UAAU;EACvB,IAAI;GACF,aAAa,QAAQ,KAAK,KAAK;EACjC,QAAQ;GACN,QAAQ,KAAK,kEAAkE;GAC/E,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;AACF;;;;;;AAOA,IAAI;AACJ,IAAI;AAEJ,SAAgB,cAA+B;CAC7C,oBAAoB,gBAAgB,CAAC,CAAC,OAAO,UAAmB;EAC9D,kBAAkB,KAAA;EAClB,MAAM;CACR,CAAC;CACD,OAAO;AACT;AAEA,SAA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AO;CACb,OAAO;AACT"}
@@ -14,7 +14,7 @@ const storage = {
14
14
  try {
15
15
  return localStorage.getItem(key);
16
16
  } catch {
17
- console.error("localStorage is not available");
17
+ console.warn("localStorage is not available; falling back to in-memory storage");
18
18
  return map.get(key) ?? null;
19
19
  }
20
20
  },
@@ -22,7 +22,7 @@ const storage = {
22
22
  try {
23
23
  localStorage.setItem(key, value);
24
24
  } catch {
25
- console.error("localStorage is not available");
25
+ console.warn("localStorage is not available; falling back to in-memory storage");
26
26
  map.set(key, value);
27
27
  }
28
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setup.mjs","names":[],"sources":["../../src/native/setup.ts"],"sourcesContent":["import 'expo-sqlite/localStorage/install';\nimport { getAndroidId, getInstallReferrerAsync, getIosIdForVendorAsync } from 'expo-application';\nimport { randomUUID } from 'expo-crypto';\nimport {\n DeviceType,\n deviceType,\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { getAdvertisingId } from 'expo-tracking-transparency';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\nimport { keys } from '../constants/storage';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.error('localStorage is not available');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.error('localStorage is not available');\n map.set(key, value);\n }\n },\n};\n\n/**\n * `getTags` runs once per event now, and both of these reach for a native module. Neither answer\n * can change while the app is running, so each is resolved once and the promise is reused. A\n * failed lookup is not cached, so the next event tries again.\n */\nlet deviceIdPromise: Promise<string> | undefined;\nlet installReferrerPromise: Promise<string | undefined> | undefined;\n\nexport function getDeviceId(): Promise<string> {\n deviceIdPromise ??= resolveDeviceId().catch((error: unknown) => {\n deviceIdPromise = undefined;\n throw error;\n });\n return deviceIdPromise;\n}\n\nfunction getInstallReferrer(): Promise<string | undefined> {\n if (Platform.OS !== 'android') return Promise.resolve(undefined);\n installReferrerPromise ??= getInstallReferrerAsync().catch((error: unknown) => {\n installReferrerPromise = undefined;\n throw error;\n });\n return installReferrerPromise;\n}\n\nasync function resolveDeviceId(): Promise<string> {\n let deviceId: string | null = null;\n if (Platform.OS === 'ios') {\n deviceId = await getIosIdForVendorAsync();\n } else if (Platform.OS === 'android') {\n deviceId = getAndroidId();\n }\n if (!deviceId) {\n deviceId = localStorage.getItem('device_id');\n if (!deviceId) {\n deviceId = randomUUID();\n localStorage.setItem('device_id', deviceId);\n }\n }\n return deviceId;\n}\n\nexport function getDeviceType(): string | undefined {\n switch (deviceType) {\n case DeviceType.PHONE:\n return 'mobile';\n case DeviceType.TABLET:\n return 'tablet';\n case DeviceType.DESKTOP:\n return 'desktop';\n case DeviceType.TV:\n return 'smarttv';\n default:\n return undefined;\n }\n}\n\n/**\n * The install referrer's utm belongs to one launch: the first one that has the referrer in hand\n * — normally the install launch, since `first_open` is the first event the app tracks and\n * tracking it builds the first tags. That launch claims the referrer by writing a marker of its\n * own, and holds the claim for the rest of the process, so every event of the launch and the\n * visitor created from it carry the utm; every later launch finds the marker and sends the raw\n * `install_referrer` alone. Cleared storage and a reinstall lose the marker and claim again,\n * exactly as they make `first_open` fire again.\n *\n * Claimed only once a referrer has actually been resolved. The Install Referrer API needs the\n * Play Store service, which is at its least available right after an install; a launch that\n * could not reach it must not spend the claim on nothing, because the referrer stays readable\n * for 90 days and a later launch can still take it — late attribution, rather than none. iOS\n * has no referrer and so never claims.\n *\n * A marker of its own rather than `first_open_time`, so that nothing here depends on when the\n * hook writes that one relative to the first `getTags`. The storage read waits for that call:\n * `setupAnalytics` and this module's evaluation can run where no storage exists.\n */\nlet installLaunch: boolean | undefined;\n\nfunction claimInstallReferrer(): boolean {\n if (config.storage.getItem(keys.install_referrer_claim_time)) return false;\n config.storage.setItem(keys.install_referrer_claim_time, new Date().toISOString());\n return true;\n}\n\nexport async function getTags(): Promise<TrackTags> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n\n // The install referrer never changes, and it used to be spread into `utm_*` on every launch —\n // so every session of an Android install reported the install campaign as its own acquisition\n // for as long as the app stayed installed, and a report reading a session's tags could not tell\n // the install from the thousandth open. The campaign is the install's touch, not every\n // session's.\n const install_referrer = await getInstallReferrer();\n if (install_referrer && installLaunch === undefined) installLaunch = claimInstallReferrer();\n const params = new URLSearchParams(installLaunch ? install_referrer : undefined);\n const opening = await config.deepLink?.getTags();\n\n const tags: TrackTags = {\n os: `${osName} ${osVersion}`,\n os_name: osName ?? undefined,\n os_version: osVersion ?? undefined,\n device: modelName ?? undefined,\n device_id: await getDeviceId(),\n device_type: getDeviceType(),\n device_vendor: manufacturer ?? undefined,\n device_model_id: modelId ?? undefined,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n release: config.release,\n language: getLocales().at(0)?.languageTag ?? 'en',\n time_zone: getCalendars().at(0)?.timeZone ?? 'UTC',\n // ads\n advertising_id: getAdvertisingId() ?? undefined,\n install_referrer,\n // utm params: from the install referrer, on the launch that claimed it\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n utm_id: params.get('utm_id') ?? undefined,\n utm_source_platform: params.get('utm_source_platform') ?? undefined,\n utm_creative_format: params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic: params.get('utm_marketing_tactic') ?? undefined,\n // the link that opened the app (`setupAnalytics({ deepLink })`): its URL, utm and click ids,\n // over the install referrer's\n ...opening,\n };\n\n cache.tags = tags;\n return tags;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,sBAAM,IAAI,IAAoB;AAEp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KAAA;EAC1D,qBAAqB,OAAO,IAAI,qBAAqB,KAAK,KAAA;EAC1D,sBAAsB,OAAO,IAAI,sBAAsB,KAAK,KAAA;EAG5D,GAAG;CACL;CAEA,MAAM,OAAO;CACb,OAAO;AACT"}
1
+ {"version":3,"file":"setup.mjs","names":[],"sources":["../../src/native/setup.ts"],"sourcesContent":["import 'expo-sqlite/localStorage/install';\nimport { getAndroidId, getInstallReferrerAsync, getIosIdForVendorAsync } from 'expo-application';\nimport { randomUUID } from 'expo-crypto';\nimport {\n DeviceType,\n deviceType,\n manufacturer,\n modelId,\n modelName,\n osName,\n osVersion,\n} from 'expo-device';\nimport { getCalendars, getLocales } from 'expo-localization';\nimport { getAdvertisingId } from 'expo-tracking-transparency';\nimport { Dimensions, PixelRatio, Platform } from 'react-native';\nimport { keys } from '../constants/storage';\nimport { type Storage, cache, config } from '../setup/index';\nimport type { TrackTags } from '../track/types';\n\nconst map = new Map<string, string>();\n\nexport const storage: Storage = {\n getItem: (key) => {\n try {\n return localStorage.getItem(key);\n } catch {\n console.warn('localStorage is not available; falling back to in-memory storage');\n return map.get(key) ?? null;\n }\n },\n setItem: (key, value) => {\n try {\n localStorage.setItem(key, value);\n } catch {\n console.warn('localStorage is not available; falling back to in-memory storage');\n map.set(key, value);\n }\n },\n};\n\n/**\n * `getTags` runs once per event now, and both of these reach for a native module. Neither answer\n * can change while the app is running, so each is resolved once and the promise is reused. A\n * failed lookup is not cached, so the next event tries again.\n */\nlet deviceIdPromise: Promise<string> | undefined;\nlet installReferrerPromise: Promise<string | undefined> | undefined;\n\nexport function getDeviceId(): Promise<string> {\n deviceIdPromise ??= resolveDeviceId().catch((error: unknown) => {\n deviceIdPromise = undefined;\n throw error;\n });\n return deviceIdPromise;\n}\n\nfunction getInstallReferrer(): Promise<string | undefined> {\n if (Platform.OS !== 'android') return Promise.resolve(undefined);\n installReferrerPromise ??= getInstallReferrerAsync().catch((error: unknown) => {\n installReferrerPromise = undefined;\n throw error;\n });\n return installReferrerPromise;\n}\n\nasync function resolveDeviceId(): Promise<string> {\n let deviceId: string | null = null;\n if (Platform.OS === 'ios') {\n deviceId = await getIosIdForVendorAsync();\n } else if (Platform.OS === 'android') {\n deviceId = getAndroidId();\n }\n if (!deviceId) {\n deviceId = localStorage.getItem('device_id');\n if (!deviceId) {\n deviceId = randomUUID();\n localStorage.setItem('device_id', deviceId);\n }\n }\n return deviceId;\n}\n\nexport function getDeviceType(): string | undefined {\n switch (deviceType) {\n case DeviceType.PHONE:\n return 'mobile';\n case DeviceType.TABLET:\n return 'tablet';\n case DeviceType.DESKTOP:\n return 'desktop';\n case DeviceType.TV:\n return 'smarttv';\n default:\n return undefined;\n }\n}\n\n/**\n * The install referrer's utm belongs to one launch: the first one that has the referrer in hand\n * — normally the install launch, since `first_open` is the first event the app tracks and\n * tracking it builds the first tags. That launch claims the referrer by writing a marker of its\n * own, and holds the claim for the rest of the process, so every event of the launch and the\n * visitor created from it carry the utm; every later launch finds the marker and sends the raw\n * `install_referrer` alone. Cleared storage and a reinstall lose the marker and claim again,\n * exactly as they make `first_open` fire again.\n *\n * Claimed only once a referrer has actually been resolved. The Install Referrer API needs the\n * Play Store service, which is at its least available right after an install; a launch that\n * could not reach it must not spend the claim on nothing, because the referrer stays readable\n * for 90 days and a later launch can still take it — late attribution, rather than none. iOS\n * has no referrer and so never claims.\n *\n * A marker of its own rather than `first_open_time`, so that nothing here depends on when the\n * hook writes that one relative to the first `getTags`. The storage read waits for that call:\n * `setupAnalytics` and this module's evaluation can run where no storage exists.\n */\nlet installLaunch: boolean | undefined;\n\nfunction claimInstallReferrer(): boolean {\n if (config.storage.getItem(keys.install_referrer_claim_time)) return false;\n config.storage.setItem(keys.install_referrer_claim_time, new Date().toISOString());\n return true;\n}\n\nexport async function getTags(): Promise<TrackTags> {\n const screen = Dimensions.get('screen');\n const screen_width = Math.floor(screen.width);\n const screen_height = Math.floor(screen.height);\n\n // The install referrer never changes, and it used to be spread into `utm_*` on every launch —\n // so every session of an Android install reported the install campaign as its own acquisition\n // for as long as the app stayed installed, and a report reading a session's tags could not tell\n // the install from the thousandth open. The campaign is the install's touch, not every\n // session's.\n const install_referrer = await getInstallReferrer();\n if (install_referrer && installLaunch === undefined) installLaunch = claimInstallReferrer();\n const params = new URLSearchParams(installLaunch ? install_referrer : undefined);\n const opening = await config.deepLink?.getTags();\n\n const tags: TrackTags = {\n os: `${osName} ${osVersion}`,\n os_name: osName ?? undefined,\n os_version: osVersion ?? undefined,\n device: modelName ?? undefined,\n device_id: await getDeviceId(),\n device_type: getDeviceType(),\n device_vendor: manufacturer ?? undefined,\n device_model_id: modelId ?? undefined,\n device_pixel_ratio: PixelRatio.get(),\n screen_width,\n screen_height,\n screen_resolution: `${screen_width}x${screen_height}`,\n release: config.release,\n language: getLocales().at(0)?.languageTag ?? 'en',\n time_zone: getCalendars().at(0)?.timeZone ?? 'UTC',\n // ads\n advertising_id: getAdvertisingId() ?? undefined,\n install_referrer,\n // utm params: from the install referrer, on the launch that claimed it\n utm_source: params.get('utm_source') ?? undefined,\n utm_medium: params.get('utm_medium') ?? undefined,\n utm_campaign: params.get('utm_campaign') ?? undefined,\n utm_term: params.get('utm_term') ?? undefined,\n utm_content: params.get('utm_content') ?? undefined,\n utm_id: params.get('utm_id') ?? undefined,\n utm_source_platform: params.get('utm_source_platform') ?? undefined,\n utm_creative_format: params.get('utm_creative_format') ?? undefined,\n utm_marketing_tactic: params.get('utm_marketing_tactic') ?? undefined,\n // the link that opened the app (`setupAnalytics({ deepLink })`): its URL, utm and click ids,\n // over the install referrer's\n ...opening,\n };\n\n cache.tags = tags;\n return tags;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,sBAAM,IAAI,IAAoB;AAEpC,MAAa,UAAmB;CAC9B,UAAU,QAAQ;EAChB,IAAI;GACF,OAAO,aAAa,QAAQ,GAAG;EACjC,QAAQ;GACN,QAAQ,KAAK,kEAAkE;GAC/E,OAAO,IAAI,IAAI,GAAG,KAAK;EACzB;CACF;CACA,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 @@ const hashName = (name) => sha256(name.toLowerCase().replace(/[\s\p{P}]/gu, ""))
39
39
  * records fail"; such an event is left out, with a minute's margin for the trip.
40
40
  */
41
41
  const MAX_EVENT_AGE_MS = 777594e4;
42
- async function sendEvents(accessToken, config, events, data = {}) {
42
+ /**
43
+ * The `LinkedIn-Version` (YYYYMM) the request is made against. LinkedIn supports each version
44
+ * for one year from its release, then requests to it fail, so this must be bumped with each
45
+ * release (or overridden through `apiVersion`).
46
+ */
47
+ const API_VERSION = "202609";
48
+ async function sendEvents(accessToken, config, events, data = {}, apiVersion = API_VERSION) {
43
49
  const address = require_utils_field.getFirst(data.address);
44
50
  const userIds = [];
45
51
  const externalIds = data.user_id ? [data.user_id] : void 0;
@@ -99,7 +105,7 @@ async function sendEvents(accessToken, config, events, data = {}) {
99
105
  headers: {
100
106
  Authorization: `Bearer ${accessToken}`,
101
107
  "Content-Type": "application/json",
102
- "LinkedIn-Version": "202609",
108
+ "LinkedIn-Version": apiVersion,
103
109
  "X-Restli-Protocol-Version": "2.0.0",
104
110
  "X-RestLi-Method": "BATCH_CREATE"
105
111
  },
@@ -110,7 +116,7 @@ async function sendEvents(accessToken, config, events, data = {}) {
110
116
  }
111
117
  /** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */
112
118
  function linkedinConversions(options) {
113
- return require_server_setup_conversions.conversionDestination((name) => options.conversions[name] !== void 0, (events, data) => sendEvents(options.accessToken, options.conversions, events, data));
119
+ return require_server_setup_conversions.conversionDestination((name) => options.conversions[name] !== void 0, (events, data) => sendEvents(options.accessToken, options.conversions, events, data, options.apiVersion));
114
120
  }
115
121
  exports.linkedinConversions = linkedinConversions;
116
122
  exports.sendEvents = sendEvents;
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-conversions-api.cjs","names":["createHash","getFirst","isIPv4","linkedinFatId","IGNORED_EVENTS","fetch","ConversionsApiError","conversionDestination"],"sources":["../../src/server/linkedin-conversions-api.ts"],"sourcesContent":["/**\n * Conversions API Payload Builder: https://www.linkedin.com/developers/payload-builder\n * https://learn.microsoft.com/en-us/linkedin/marketing/conversions/conversions-overview?view=li-lms-2026-09\n */\nimport { createHash } from 'node:crypto';\nimport { isIPv4 } from 'node:net';\nimport { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport type {\n LinkedInAdsOptions,\n LinkedinConversionConfig,\n} from '../third-parties/linkedin-insight-tag';\nimport type { TrackEvent, TrackName, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { linkedinFatId } from './click-ids';\nimport { ConversionsApiError } from './conversions-api-error';\nimport { type ConversionDestination, conversionDestination } from './setup-conversions';\n\n/**\n * The identifier types LinkedIn matches on, as of version 202609. `ORACLE_MOAT_ID` used to be\n * here and is no longer in the schema; the IP and Android ones are.\n */\ntype UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'PLAINTEXT_IP_ADDRESS'\n | 'SHA256_IP_ADDRESS'\n | 'GOOGLE_AID';\n\nexport interface CreateLinkedinEventDTO {\n /**\n * For any conversion that you want to send through multiple methods, such as Insight Tag and\n * Conversions API, you must create a conversion rule for each data source (browser and server).\n * Then, you can implement a logic to pick up the eventId from the browser and send it with the\n * corresponding event from your server. If we receive an Insight Tag event and a Conversions API\n * event from the same account with the same eventId, we discard the Conversions API event and\n * count only the Insight Tag event in campaign reporting.\n */\n eventId?: string;\n\n /**\n * Replace <id> with the conversion ID extracted when creating the conversion rule\n * (e.g. urn:lla:llaPartnerConversion:<id>).\n */\n conversion: `urn:lla:llaPartnerConversion:${number}`;\n\n /** Epoch timestamp in milliseconds at which the conversion event happened. */\n conversionHappenedAt: number;\n conversionValue: { currencyCode: string; amount: string };\n user: {\n userIds: { idType: UserIdType; idValue: string }[];\n /**\n * Probabilistic matching fields. `hashedFirstName` / `hashedLastName` arrived in 202609 and\n * are what we send; the plaintext `firstName` / `lastName` they replace are still accepted by\n * the API but are not listed here, because sending a name in the clear is not something this\n * client should make easy to reach for.\n */\n userInfo?: {\n hashedFirstName?: string;\n hashedLastName?: string;\n companyName?: string;\n countryCode?: string;\n title?: string;\n };\n\n /**\n * The maximum supported size of the list is 1 at the moment. If the list contains multiple\n * values, only the first value will be used.\n */\n externalIds?: [string, ...string[]];\n\n /**\n * This is generated when users submit the Linkedin Lead-gen form\n * (e.g. urn:li:leadGenFormResponse:<id>).\n */\n lead?: `urn:li:leadGenFormResponse:${string}`;\n };\n}\n\nexport interface CreateMultipleLinkedinEventsDTO {\n elements: CreateLinkedinEventDTO[];\n}\n\n/**\n * The schema prescribes an exact normalization per field before hashing, and getting it wrong is\n * silent: LinkedIn accepts any 64-char hex digest and simply matches nobody. So these helpers are\n * the difference between attribution and nothing, not between 200 and 400.\n */\nconst sha256 = (value: string) => createHash('sha256').update(value).digest('hex');\n\n/**\n * An email is lower-cased and stripped of whitespace before hashing. Punctuation is left alone —\n * `@` and `.` are the address.\n */\nconst hashEmail = (email: string) => sha256(email.toLowerCase().replace(/\\s/g, ''));\n\n/**\n * A name is lower-cased and stripped of whitespace *and punctuation* before hashing, so that\n * `O'Brien`, `o brien` and `obrien` all land on the same digest. UTF-8 is what `update` already\n * encodes with.\n *\n * The schema's wording (\"lowercase with no spaces or punctuation\") leaves room to read the\n * apostrophe either way, so this is checked against its own worked example rather than guessed:\n * the `hashedFirstName` / `hashedLastName` digests it prints are sha256('mary') and\n * sha256('obrien') — Mary O'Brien with the apostrophe removed, not escaped or kept.\n */\nconst hashName = (name: string) => sha256(name.toLowerCase().replace(/[\\s\\p{P}]/gu, ''));\n\n/** The same event name → conversion id map `linkedInAds` takes in the browser. */\nexport type { LinkedinConversionConfig } from '../third-parties/linkedin-insight-tag';\n\n/**\n * `conversionHappenedAt` must be \"within the past 90 days\", and one invalid record makes \"all\n * records fail\"; such an event is left out, with a minute's margin for the trip.\n */\nconst MAX_EVENT_AGE_MS = 90 * 24 * 60 * 60 * 1000 - 60 * 1000;\n\nexport async function sendEvents(\n accessToken: string,\n config: LinkedinConversionConfig,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {}\n) {\n const address = getFirst(data.address);\n const userIds: { idType: UserIdType; idValue: string }[] = [];\n const externalIds: [string, ...string[]] | undefined = data.user_id ? [data.user_id] : undefined;\n const userInfo =\n address?.first_name && address.last_name\n ? {\n hashedFirstName: hashName(address.first_name),\n hashedLastName: hashName(address.last_name),\n countryCode: address.country,\n }\n : undefined;\n\n if (data.email) {\n const email = getFirst(data.email);\n if (email) userIds.push({ idType: 'SHA256_EMAIL', idValue: hashEmail(email) });\n }\n\n // LinkedIn takes the IP as is (it salts and hashes it itself), IPv4 only.\n // https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api\n if (data.ip_address && isIPv4(data.ip_address)) {\n userIds.push({ idType: 'PLAINTEXT_IP_ADDRESS', idValue: data.ip_address });\n }\n\n // The identifiers each event carries itself: the click id, and the Android advertising id.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const eventIds = (event: TrackEvent<any>): { idType: UserIdType; idValue: string }[] => {\n const ids: { idType: UserIdType; idValue: string }[] = [];\n const fatId = linkedinFatId(event.tags);\n if (fatId) ids.push({ idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID', idValue: fatId });\n if (event.platform === 'android' && event.tags.advertising_id) {\n ids.push({ idType: 'GOOGLE_AID', idValue: event.tags.advertising_id });\n }\n return ids;\n };\n\n const dto: CreateMultipleLinkedinEventsDTO = {\n elements: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .filter((event) => Date.now() - Date.parse(event.created_at) <= MAX_EVENT_AGE_MS)\n .flatMap((event) => {\n const conversionId = config[event.name as TrackName];\n return conversionId === undefined ? [] : [{ event, conversionId }];\n })\n .map(({ event, conversionId }): CreateLinkedinEventDTO => ({\n eventId: event.id,\n conversion: `urn:lla:llaPartnerConversion:${conversionId}`,\n conversionHappenedAt: new Date(event.created_at).getTime(),\n conversionValue: {\n currencyCode: event.properties?.currency?.toUpperCase() ?? 'USD',\n amount: event.properties?.value?.toString() ?? '0',\n },\n user: {\n userIds: [...eventIds(event), ...userIds],\n userInfo,\n externalIds,\n },\n }))\n // An element carrying no identifier at all fails validation, and LinkedIn fails the whole\n // batch when one element fails — so a single anonymous event would discard every\n // identifiable conversion sent alongside it. Dropped here instead.\n .filter(\n ({ user }) =>\n user.userIds.length > 0 || !!user.userInfo || !!user.externalIds || !!user.lead\n ),\n };\n\n if (dto.elements.length === 0) return;\n const response = await fetch('https://api.linkedin.com/rest/conversionEvents', {\n method: 'POST',\n // Retried although a POST: the platform deduplicates on the `eventId` each event carries.\n retries: 3,\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'LinkedIn-Version': '202609',\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n },\n body: JSON.stringify(dto),\n });\n\n if (response.ok) return;\n throw new ConversionsApiError('linkedin', response.status, await response.text());\n}\n\n/** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */\nexport function linkedinConversions(\n options: Pick<LinkedInAdsOptions, 'conversions'> & { accessToken: string }\n): ConversionDestination {\n return conversionDestination(\n (name) => options.conversions[name as TrackName] !== undefined,\n (events, data) => sendEvents(options.accessToken, options.conversions, events, data)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyFA,MAAM,UAAU,WAAA,GAAkBA,YAAAA,WAAAA,CAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;;;;;AAMjF,MAAM,aAAa,UAAkB,OAAO,MAAM,YAAY,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC;;;;;;;;;;;AAYlF,MAAM,YAAY,SAAiB,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,eAAe,EAAE,CAAC;;;;;AASvF,MAAM,mBAA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nE,CAAC,CAAC,CACD,KAAK,EAAE,OAAO,oBAA4C;EACzD,SAAS,MAAM;EACf,YAAY,gCAAgC;EAC5C,sBAAsB,IAAI,KAAK,MAAM,UAAU,CAAC,CAAC,QAAQ;EACzD,iBAAiB;GACf,cAAc,MAAM,YAAY,UAAU,YAAY,KAAK;GAC3D,QAAQ,MAAM,YAAY,OAAO,SAAS,KAAK;EACjD;EACA,MAAM;GACJ,SAAS,CAAC,GAAG,SAAS,KAAK,GAAG,GAAG,OAAO;GACxC;GACA;EACF;CACF,EAAE,CAAC,CAIF,QACE,EAAE,WACD,KAAK,QAAQ,SAAS,KAAK,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,KAAK,IAC/E,EACJ;CAEA,IAAI,IAAI,SAAS,WAAW,GAAG;CAC/B,MAAM,WAAW,OAAA,GAAMC,cAAAA,MAAAA,CAAM,kDAAkD;EAC7E,QAAQ;EAER,SAAS;EACT,SAAS;GACP,eAAe,UAAU;GACzB,gBAAgB;GAChB,oBAAoB;GACpB,6BAA6B;GAC7B,mBAAmB;EACrB;EACA,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,SAAS,IAAI;CACjB,MAAM,IAAIC,qCAAAA,oBAAoB,YAAY,SAAS,QAAQ,MAAM,SAAS,KAAK,CAAC;AAClF;;AAGA,SAAgB,oBACd,SACuB;CACvB,OAAOC,iCAAAA,uBACJ,SAAS,QAAQ,YAAY,UAAuB,KAAA,IACpD,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ,aAAa,QAAQ,IAAI,CACrF;AACF"}
1
+ {"version":3,"file":"linkedin-conversions-api.cjs","names":["createHash","getFirst","isIPv4","linkedinFatId","IGNORED_EVENTS","fetch","ConversionsApiError","conversionDestination"],"sources":["../../src/server/linkedin-conversions-api.ts"],"sourcesContent":["/**\n * Conversions API Payload Builder: https://www.linkedin.com/developers/payload-builder\n * https://learn.microsoft.com/en-us/linkedin/marketing/conversions/conversions-overview?view=li-lms-2026-09\n */\nimport { createHash } from 'node:crypto';\nimport { isIPv4 } from 'node:net';\nimport { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport type {\n LinkedInAdsOptions,\n LinkedinConversionConfig,\n} from '../third-parties/linkedin-insight-tag';\nimport type { TrackEvent, TrackName, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { linkedinFatId } from './click-ids';\nimport { ConversionsApiError } from './conversions-api-error';\nimport { type ConversionDestination, conversionDestination } from './setup-conversions';\n\n/**\n * The identifier types LinkedIn matches on, as of version 202609. `ORACLE_MOAT_ID` used to be\n * here and is no longer in the schema; the IP and Android ones are.\n */\ntype UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'PLAINTEXT_IP_ADDRESS'\n | 'SHA256_IP_ADDRESS'\n | 'GOOGLE_AID';\n\nexport interface CreateLinkedinEventDTO {\n /**\n * For any conversion that you want to send through multiple methods, such as Insight Tag and\n * Conversions API, you must create a conversion rule for each data source (browser and server).\n * Then, you can implement a logic to pick up the eventId from the browser and send it with the\n * corresponding event from your server. If we receive an Insight Tag event and a Conversions API\n * event from the same account with the same eventId, we discard the Conversions API event and\n * count only the Insight Tag event in campaign reporting.\n */\n eventId?: string;\n\n /**\n * Replace <id> with the conversion ID extracted when creating the conversion rule\n * (e.g. urn:lla:llaPartnerConversion:<id>).\n */\n conversion: `urn:lla:llaPartnerConversion:${number}`;\n\n /** Epoch timestamp in milliseconds at which the conversion event happened. */\n conversionHappenedAt: number;\n conversionValue: { currencyCode: string; amount: string };\n user: {\n userIds: { idType: UserIdType; idValue: string }[];\n /**\n * Probabilistic matching fields. `hashedFirstName` / `hashedLastName` arrived in 202609 and\n * are what we send; the plaintext `firstName` / `lastName` they replace are still accepted by\n * the API but are not listed here, because sending a name in the clear is not something this\n * client should make easy to reach for.\n */\n userInfo?: {\n hashedFirstName?: string;\n hashedLastName?: string;\n companyName?: string;\n countryCode?: string;\n title?: string;\n };\n\n /**\n * The maximum supported size of the list is 1 at the moment. If the list contains multiple\n * values, only the first value will be used.\n */\n externalIds?: [string, ...string[]];\n\n /**\n * This is generated when users submit the Linkedin Lead-gen form\n * (e.g. urn:li:leadGenFormResponse:<id>).\n */\n lead?: `urn:li:leadGenFormResponse:${string}`;\n };\n}\n\nexport interface CreateMultipleLinkedinEventsDTO {\n elements: CreateLinkedinEventDTO[];\n}\n\n/**\n * The schema prescribes an exact normalization per field before hashing, and getting it wrong is\n * silent: LinkedIn accepts any 64-char hex digest and simply matches nobody. So these helpers are\n * the difference between attribution and nothing, not between 200 and 400.\n */\nconst sha256 = (value: string) => createHash('sha256').update(value).digest('hex');\n\n/**\n * An email is lower-cased and stripped of whitespace before hashing. Punctuation is left alone —\n * `@` and `.` are the address.\n */\nconst hashEmail = (email: string) => sha256(email.toLowerCase().replace(/\\s/g, ''));\n\n/**\n * A name is lower-cased and stripped of whitespace *and punctuation* before hashing, so that\n * `O'Brien`, `o brien` and `obrien` all land on the same digest. UTF-8 is what `update` already\n * encodes with.\n *\n * The schema's wording (\"lowercase with no spaces or punctuation\") leaves room to read the\n * apostrophe either way, so this is checked against its own worked example rather than guessed:\n * the `hashedFirstName` / `hashedLastName` digests it prints are sha256('mary') and\n * sha256('obrien') — Mary O'Brien with the apostrophe removed, not escaped or kept.\n */\nconst hashName = (name: string) => sha256(name.toLowerCase().replace(/[\\s\\p{P}]/gu, ''));\n\n/** The same event name → conversion id map `linkedInAds` takes in the browser. */\nexport type { LinkedinConversionConfig } from '../third-parties/linkedin-insight-tag';\n\n/**\n * `conversionHappenedAt` must be \"within the past 90 days\", and one invalid record makes \"all\n * records fail\"; such an event is left out, with a minute's margin for the trip.\n */\nconst MAX_EVENT_AGE_MS = 90 * 24 * 60 * 60 * 1000 - 60 * 1000;\n\n/**\n * The `LinkedIn-Version` (YYYYMM) the request is made against. LinkedIn supports each version\n * for one year from its release, then requests to it fail, so this must be bumped with each\n * release (or overridden through `apiVersion`).\n */\nconst API_VERSION = '202609';\n\nexport async function sendEvents(\n accessToken: string,\n config: LinkedinConversionConfig,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {},\n apiVersion: string = API_VERSION\n) {\n const address = getFirst(data.address);\n const userIds: { idType: UserIdType; idValue: string }[] = [];\n const externalIds: [string, ...string[]] | undefined = data.user_id ? [data.user_id] : undefined;\n const userInfo =\n address?.first_name && address.last_name\n ? {\n hashedFirstName: hashName(address.first_name),\n hashedLastName: hashName(address.last_name),\n countryCode: address.country,\n }\n : undefined;\n\n if (data.email) {\n const email = getFirst(data.email);\n if (email) userIds.push({ idType: 'SHA256_EMAIL', idValue: hashEmail(email) });\n }\n\n // LinkedIn takes the IP as is (it salts and hashes it itself), IPv4 only.\n // https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api\n if (data.ip_address && isIPv4(data.ip_address)) {\n userIds.push({ idType: 'PLAINTEXT_IP_ADDRESS', idValue: data.ip_address });\n }\n\n // The identifiers each event carries itself: the click id, and the Android advertising id.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const eventIds = (event: TrackEvent<any>): { idType: UserIdType; idValue: string }[] => {\n const ids: { idType: UserIdType; idValue: string }[] = [];\n const fatId = linkedinFatId(event.tags);\n if (fatId) ids.push({ idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID', idValue: fatId });\n if (event.platform === 'android' && event.tags.advertising_id) {\n ids.push({ idType: 'GOOGLE_AID', idValue: event.tags.advertising_id });\n }\n return ids;\n };\n\n const dto: CreateMultipleLinkedinEventsDTO = {\n elements: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .filter((event) => Date.now() - Date.parse(event.created_at) <= MAX_EVENT_AGE_MS)\n .flatMap((event) => {\n const conversionId = config[event.name as TrackName];\n return conversionId === undefined ? [] : [{ event, conversionId }];\n })\n .map(({ event, conversionId }): CreateLinkedinEventDTO => ({\n eventId: event.id,\n conversion: `urn:lla:llaPartnerConversion:${conversionId}`,\n conversionHappenedAt: new Date(event.created_at).getTime(),\n conversionValue: {\n currencyCode: event.properties?.currency?.toUpperCase() ?? 'USD',\n amount: event.properties?.value?.toString() ?? '0',\n },\n user: {\n userIds: [...eventIds(event), ...userIds],\n userInfo,\n externalIds,\n },\n }))\n // An element carrying no identifier at all fails validation, and LinkedIn fails the whole\n // batch when one element fails — so a single anonymous event would discard every\n // identifiable conversion sent alongside it. Dropped here instead.\n .filter(\n ({ user }) =>\n user.userIds.length > 0 || !!user.userInfo || !!user.externalIds || !!user.lead\n ),\n };\n\n if (dto.elements.length === 0) return;\n const response = await fetch('https://api.linkedin.com/rest/conversionEvents', {\n method: 'POST',\n // Retried although a POST: the platform deduplicates on the `eventId` each event carries.\n retries: 3,\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'LinkedIn-Version': apiVersion,\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n },\n body: JSON.stringify(dto),\n });\n\n if (response.ok) return;\n throw new ConversionsApiError('linkedin', response.status, await response.text());\n}\n\n/** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */\nexport function linkedinConversions(\n options: Pick<LinkedInAdsOptions, 'conversions'> & {\n accessToken: string;\n /** `LinkedIn-Version` header (YYYYMM), e.g. '202609'. */\n apiVersion?: string;\n }\n): ConversionDestination {\n return conversionDestination(\n (name) => options.conversions[name as TrackName] !== undefined,\n (events, data) =>\n sendEvents(options.accessToken, options.conversions, events, data, options.apiVersion)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyFA,MAAM,UAAU,WAAA,GAAkBA,YAAAA,WAAAA,CAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;;;;;AAMjF,MAAM,aAAa,UAAkB,OAAO,MAAM,Y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 export interface CreateLinkedinEventDTO {
60
60
  export interface CreateMultipleLinkedinEventsDTO {
61
61
  elements: CreateLinkedinEventDTO[];
62
62
  }
63
- export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
63
+ export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, apiVersion?: string): Promise<void>;
64
64
  /** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */
65
65
  export declare function linkedinConversions(options: Pick<LinkedInAdsOptions, 'conversions'> & {
66
66
  accessToken: string;
67
+ /** `LinkedIn-Version` header (YYYYMM), e.g. '202609'. */
68
+ apiVersion?: string;
67
69
  }): ConversionDestination;
68
70
  export type { LinkedinConversionConfig };
69
71
  //# sourceMappingURL=linkedin-conversions-api.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-conversions-api.d.cts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;;KAsBK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;wBAqCU,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,mBAAqB;;wBAwFb,oBACd,SAAS,KAAK;EAAuC;IACpD"}
1
+ {"version":3,"file":"linkedin-conversions-api.d.cts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;;KAsBK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;wBA4CU,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,kBACN,sBAAgC;;wBAwFlB,oBACd,SAAS,KAAK;EACZ;;EAEA;IAED"}
@@ -60,10 +60,12 @@ export interface CreateLinkedinEventDTO {
60
60
  export interface CreateMultipleLinkedinEventsDTO {
61
61
  elements: CreateLinkedinEventDTO[];
62
62
  }
63
- export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
63
+ export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, apiVersion?: string): Promise<void>;
64
64
  /** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */
65
65
  export declare function linkedinConversions(options: Pick<LinkedInAdsOptions, 'conversions'> & {
66
66
  accessToken: string;
67
+ /** `LinkedIn-Version` header (YYYYMM), e.g. '202609'. */
68
+ apiVersion?: string;
67
69
  }): ConversionDestination;
68
70
  export type { LinkedinConversionConfig };
69
71
  //# sourceMappingURL=linkedin-conversions-api.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-conversions-api.d.mts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;;KAsBK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;wBAqCU,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,mBAAqB;;wBAwFb,oBACd,SAAS,KAAK;EAAuC;IACpD"}
1
+ {"version":3,"file":"linkedin-conversions-api.d.mts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;;KAsBK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;wBA4CU,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,kBACN,sBAAgC;;wBAwFlB,oBACd,SAAS,KAAK;EACZ;;EAEA;IAED"}
@@ -38,7 +38,13 @@ const hashName = (name) => sha256(name.toLowerCase().replace(/[\s\p{P}]/gu, ""))
38
38
  * records fail"; such an event is left out, with a minute's margin for the trip.
39
39
  */
40
40
  const MAX_EVENT_AGE_MS = 777594e4;
41
- async function sendEvents(accessToken, config, events, data = {}) {
41
+ /**
42
+ * The `LinkedIn-Version` (YYYYMM) the request is made against. LinkedIn supports each version
43
+ * for one year from its release, then requests to it fail, so this must be bumped with each
44
+ * release (or overridden through `apiVersion`).
45
+ */
46
+ const API_VERSION = "202609";
47
+ async function sendEvents(accessToken, config, events, data = {}, apiVersion = API_VERSION) {
42
48
  const address = getFirst(data.address);
43
49
  const userIds = [];
44
50
  const externalIds = data.user_id ? [data.user_id] : void 0;
@@ -98,7 +104,7 @@ async function sendEvents(accessToken, config, events, data = {}) {
98
104
  headers: {
99
105
  Authorization: `Bearer ${accessToken}`,
100
106
  "Content-Type": "application/json",
101
- "LinkedIn-Version": "202609",
107
+ "LinkedIn-Version": apiVersion,
102
108
  "X-Restli-Protocol-Version": "2.0.0",
103
109
  "X-RestLi-Method": "BATCH_CREATE"
104
110
  },
@@ -109,7 +115,7 @@ async function sendEvents(accessToken, config, events, data = {}) {
109
115
  }
110
116
  /** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */
111
117
  function linkedinConversions(options) {
112
- return conversionDestination((name) => options.conversions[name] !== void 0, (events, data) => sendEvents(options.accessToken, options.conversions, events, data));
118
+ return conversionDestination((name) => options.conversions[name] !== void 0, (events, data) => sendEvents(options.accessToken, options.conversions, events, data, options.apiVersion));
113
119
  }
114
120
  export { linkedinConversions, sendEvents };
115
121
 
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-conversions-api.mjs","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"sourcesContent":["/**\n * Conversions API Payload Builder: https://www.linkedin.com/developers/payload-builder\n * https://learn.microsoft.com/en-us/linkedin/marketing/conversions/conversions-overview?view=li-lms-2026-09\n */\nimport { createHash } from 'node:crypto';\nimport { isIPv4 } from 'node:net';\nimport { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport type {\n LinkedInAdsOptions,\n LinkedinConversionConfig,\n} from '../third-parties/linkedin-insight-tag';\nimport type { TrackEvent, TrackName, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { linkedinFatId } from './click-ids';\nimport { ConversionsApiError } from './conversions-api-error';\nimport { type ConversionDestination, conversionDestination } from './setup-conversions';\n\n/**\n * The identifier types LinkedIn matches on, as of version 202609. `ORACLE_MOAT_ID` used to be\n * here and is no longer in the schema; the IP and Android ones are.\n */\ntype UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'PLAINTEXT_IP_ADDRESS'\n | 'SHA256_IP_ADDRESS'\n | 'GOOGLE_AID';\n\nexport interface CreateLinkedinEventDTO {\n /**\n * For any conversion that you want to send through multiple methods, such as Insight Tag and\n * Conversions API, you must create a conversion rule for each data source (browser and server).\n * Then, you can implement a logic to pick up the eventId from the browser and send it with the\n * corresponding event from your server. If we receive an Insight Tag event and a Conversions API\n * event from the same account with the same eventId, we discard the Conversions API event and\n * count only the Insight Tag event in campaign reporting.\n */\n eventId?: string;\n\n /**\n * Replace <id> with the conversion ID extracted when creating the conversion rule\n * (e.g. urn:lla:llaPartnerConversion:<id>).\n */\n conversion: `urn:lla:llaPartnerConversion:${number}`;\n\n /** Epoch timestamp in milliseconds at which the conversion event happened. */\n conversionHappenedAt: number;\n conversionValue: { currencyCode: string; amount: string };\n user: {\n userIds: { idType: UserIdType; idValue: string }[];\n /**\n * Probabilistic matching fields. `hashedFirstName` / `hashedLastName` arrived in 202609 and\n * are what we send; the plaintext `firstName` / `lastName` they replace are still accepted by\n * the API but are not listed here, because sending a name in the clear is not something this\n * client should make easy to reach for.\n */\n userInfo?: {\n hashedFirstName?: string;\n hashedLastName?: string;\n companyName?: string;\n countryCode?: string;\n title?: string;\n };\n\n /**\n * The maximum supported size of the list is 1 at the moment. If the list contains multiple\n * values, only the first value will be used.\n */\n externalIds?: [string, ...string[]];\n\n /**\n * This is generated when users submit the Linkedin Lead-gen form\n * (e.g. urn:li:leadGenFormResponse:<id>).\n */\n lead?: `urn:li:leadGenFormResponse:${string}`;\n };\n}\n\nexport interface CreateMultipleLinkedinEventsDTO {\n elements: CreateLinkedinEventDTO[];\n}\n\n/**\n * The schema prescribes an exact normalization per field before hashing, and getting it wrong is\n * silent: LinkedIn accepts any 64-char hex digest and simply matches nobody. So these helpers are\n * the difference between attribution and nothing, not between 200 and 400.\n */\nconst sha256 = (value: string) => createHash('sha256').update(value).digest('hex');\n\n/**\n * An email is lower-cased and stripped of whitespace before hashing. Punctuation is left alone —\n * `@` and `.` are the address.\n */\nconst hashEmail = (email: string) => sha256(email.toLowerCase().replace(/\\s/g, ''));\n\n/**\n * A name is lower-cased and stripped of whitespace *and punctuation* before hashing, so that\n * `O'Brien`, `o brien` and `obrien` all land on the same digest. UTF-8 is what `update` already\n * encodes with.\n *\n * The schema's wording (\"lowercase with no spaces or punctuation\") leaves room to read the\n * apostrophe either way, so this is checked against its own worked example rather than guessed:\n * the `hashedFirstName` / `hashedLastName` digests it prints are sha256('mary') and\n * sha256('obrien') — Mary O'Brien with the apostrophe removed, not escaped or kept.\n */\nconst hashName = (name: string) => sha256(name.toLowerCase().replace(/[\\s\\p{P}]/gu, ''));\n\n/** The same event name → conversion id map `linkedInAds` takes in the browser. */\nexport type { LinkedinConversionConfig } from '../third-parties/linkedin-insight-tag';\n\n/**\n * `conversionHappenedAt` must be \"within the past 90 days\", and one invalid record makes \"all\n * records fail\"; such an event is left out, with a minute's margin for the trip.\n */\nconst MAX_EVENT_AGE_MS = 90 * 24 * 60 * 60 * 1000 - 60 * 1000;\n\nexport async function sendEvents(\n accessToken: string,\n config: LinkedinConversionConfig,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {}\n) {\n const address = getFirst(data.address);\n const userIds: { idType: UserIdType; idValue: string }[] = [];\n const externalIds: [string, ...string[]] | undefined = data.user_id ? [data.user_id] : undefined;\n const userInfo =\n address?.first_name && address.last_name\n ? {\n hashedFirstName: hashName(address.first_name),\n hashedLastName: hashName(address.last_name),\n countryCode: address.country,\n }\n : undefined;\n\n if (data.email) {\n const email = getFirst(data.email);\n if (email) userIds.push({ idType: 'SHA256_EMAIL', idValue: hashEmail(email) });\n }\n\n // LinkedIn takes the IP as is (it salts and hashes it itself), IPv4 only.\n // https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api\n if (data.ip_address && isIPv4(data.ip_address)) {\n userIds.push({ idType: 'PLAINTEXT_IP_ADDRESS', idValue: data.ip_address });\n }\n\n // The identifiers each event carries itself: the click id, and the Android advertising id.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const eventIds = (event: TrackEvent<any>): { idType: UserIdType; idValue: string }[] => {\n const ids: { idType: UserIdType; idValue: string }[] = [];\n const fatId = linkedinFatId(event.tags);\n if (fatId) ids.push({ idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID', idValue: fatId });\n if (event.platform === 'android' && event.tags.advertising_id) {\n ids.push({ idType: 'GOOGLE_AID', idValue: event.tags.advertising_id });\n }\n return ids;\n };\n\n const dto: CreateMultipleLinkedinEventsDTO = {\n elements: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .filter((event) => Date.now() - Date.parse(event.created_at) <= MAX_EVENT_AGE_MS)\n .flatMap((event) => {\n const conversionId = config[event.name as TrackName];\n return conversionId === undefined ? [] : [{ event, conversionId }];\n })\n .map(({ event, conversionId }): CreateLinkedinEventDTO => ({\n eventId: event.id,\n conversion: `urn:lla:llaPartnerConversion:${conversionId}`,\n conversionHappenedAt: new Date(event.created_at).getTime(),\n conversionValue: {\n currencyCode: event.properties?.currency?.toUpperCase() ?? 'USD',\n amount: event.properties?.value?.toString() ?? '0',\n },\n user: {\n userIds: [...eventIds(event), ...userIds],\n userInfo,\n externalIds,\n },\n }))\n // An element carrying no identifier at all fails validation, and LinkedIn fails the whole\n // batch when one element fails — so a single anonymous event would discard every\n // identifiable conversion sent alongside it. Dropped here instead.\n .filter(\n ({ user }) =>\n user.userIds.length > 0 || !!user.userInfo || !!user.externalIds || !!user.lead\n ),\n };\n\n if (dto.elements.length === 0) return;\n const response = await fetch('https://api.linkedin.com/rest/conversionEvents', {\n method: 'POST',\n // Retried although a POST: the platform deduplicates on the `eventId` each event carries.\n retries: 3,\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'LinkedIn-Version': '202609',\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n },\n body: JSON.stringify(dto),\n });\n\n if (response.ok) return;\n throw new ConversionsApiError('linkedin', response.status, await response.text());\n}\n\n/** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */\nexport function linkedinConversions(\n options: Pick<LinkedInAdsOptions, 'conversions'> & { accessToken: string }\n): ConversionDestination {\n return conversionDestination(\n (name) => options.conversions[name as TrackName] !== undefined,\n (events, data) => sendEvents(options.accessToken, options.conversions, events, data)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyFA,MAAM,UAAU,UAAkB,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;;;;;AAMjF,MAAM,aAAa,UAAkB,OAAO,MAAM,YAAY,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC;;;;;;;;;;;AAYlF,MAAM,YAAY,SAAiB,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,eAAe,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AK,EAAE,OAAO,oBAA4C;EACzD,SAAS,MAAM;EACf,YAAY,gCAAgC;EAC5C,sBAAsB,IAAI,KAAK,MAAM,UAAU,CAAC,CAAC,QAAQ;EACzD,iBAAiB;GACf,cAAc,MAAM,YAAY,UAAU,YAAY,KAAK;GAC3D,QAAQ,MAAM,YAAY,OAAO,SAAS,KAAK;EACjD;EACA,MAAM;GACJ,SAAS,CAAC,GAAG,SAAS,KAAK,GAAG,GAAG,OAAO;GACxC;GACA;EACF;CACF,EAAE,CAAC,CAIF,QACE,EAAE,WACD,KAAK,QAAQ,SAAS,KAAK,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,KAAK,IAC/E,EACJ;CAEA,IAAI,IAAI,SAAS,WAAW,GAAG;CAC/B,MAAM,WAAW,MAAM,MAAM,kDAAkD;EAC7E,QAAQ;EAER,SAAS;EACT,SAAS;GACP,eAAe,UAAU;GACzB,gBAAgB;GAChB,oBAAoB;GACpB,6BAA6B;GAC7B,mBAAmB;EACrB;EACA,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,SAAS,IAAI;CACjB,MAAM,IAAI,oBAAoB,YAAY,SAAS,QAAQ,MAAM,SAAS,KAAK,CAAC;AAClF;;AAGA,SAAgB,oBACd,SACuB;CACvB,OAAO,uBACJ,SAAS,QAAQ,YAAY,UAAuB,KAAA,IACpD,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ,aAAa,QAAQ,IAAI,CACrF;AACF"}
1
+ {"version":3,"file":"linkedin-conversions-api.mjs","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"sourcesContent":["/**\n * Conversions API Payload Builder: https://www.linkedin.com/developers/payload-builder\n * https://learn.microsoft.com/en-us/linkedin/marketing/conversions/conversions-overview?view=li-lms-2026-09\n */\nimport { createHash } from 'node:crypto';\nimport { isIPv4 } from 'node:net';\nimport { fetch } from '@shware/utils';\nimport { IGNORED_EVENTS } from '../third-parties/ignored-events';\nimport type {\n LinkedInAdsOptions,\n LinkedinConversionConfig,\n} from '../third-parties/linkedin-insight-tag';\nimport type { TrackEvent, TrackName, UserProvidedData } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { linkedinFatId } from './click-ids';\nimport { ConversionsApiError } from './conversions-api-error';\nimport { type ConversionDestination, conversionDestination } from './setup-conversions';\n\n/**\n * The identifier types LinkedIn matches on, as of version 202609. `ORACLE_MOAT_ID` used to be\n * here and is no longer in the schema; the IP and Android ones are.\n */\ntype UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'PLAINTEXT_IP_ADDRESS'\n | 'SHA256_IP_ADDRESS'\n | 'GOOGLE_AID';\n\nexport interface CreateLinkedinEventDTO {\n /**\n * For any conversion that you want to send through multiple methods, such as Insight Tag and\n * Conversions API, you must create a conversion rule for each data source (browser and server).\n * Then, you can implement a logic to pick up the eventId from the browser and send it with the\n * corresponding event from your server. If we receive an Insight Tag event and a Conversions API\n * event from the same account with the same eventId, we discard the Conversions API event and\n * count only the Insight Tag event in campaign reporting.\n */\n eventId?: string;\n\n /**\n * Replace <id> with the conversion ID extracted when creating the conversion rule\n * (e.g. urn:lla:llaPartnerConversion:<id>).\n */\n conversion: `urn:lla:llaPartnerConversion:${number}`;\n\n /** Epoch timestamp in milliseconds at which the conversion event happened. */\n conversionHappenedAt: number;\n conversionValue: { currencyCode: string; amount: string };\n user: {\n userIds: { idType: UserIdType; idValue: string }[];\n /**\n * Probabilistic matching fields. `hashedFirstName` / `hashedLastName` arrived in 202609 and\n * are what we send; the plaintext `firstName` / `lastName` they replace are still accepted by\n * the API but are not listed here, because sending a name in the clear is not something this\n * client should make easy to reach for.\n */\n userInfo?: {\n hashedFirstName?: string;\n hashedLastName?: string;\n companyName?: string;\n countryCode?: string;\n title?: string;\n };\n\n /**\n * The maximum supported size of the list is 1 at the moment. If the list contains multiple\n * values, only the first value will be used.\n */\n externalIds?: [string, ...string[]];\n\n /**\n * This is generated when users submit the Linkedin Lead-gen form\n * (e.g. urn:li:leadGenFormResponse:<id>).\n */\n lead?: `urn:li:leadGenFormResponse:${string}`;\n };\n}\n\nexport interface CreateMultipleLinkedinEventsDTO {\n elements: CreateLinkedinEventDTO[];\n}\n\n/**\n * The schema prescribes an exact normalization per field before hashing, and getting it wrong is\n * silent: LinkedIn accepts any 64-char hex digest and simply matches nobody. So these helpers are\n * the difference between attribution and nothing, not between 200 and 400.\n */\nconst sha256 = (value: string) => createHash('sha256').update(value).digest('hex');\n\n/**\n * An email is lower-cased and stripped of whitespace before hashing. Punctuation is left alone —\n * `@` and `.` are the address.\n */\nconst hashEmail = (email: string) => sha256(email.toLowerCase().replace(/\\s/g, ''));\n\n/**\n * A name is lower-cased and stripped of whitespace *and punctuation* before hashing, so that\n * `O'Brien`, `o brien` and `obrien` all land on the same digest. UTF-8 is what `update` already\n * encodes with.\n *\n * The schema's wording (\"lowercase with no spaces or punctuation\") leaves room to read the\n * apostrophe either way, so this is checked against its own worked example rather than guessed:\n * the `hashedFirstName` / `hashedLastName` digests it prints are sha256('mary') and\n * sha256('obrien') — Mary O'Brien with the apostrophe removed, not escaped or kept.\n */\nconst hashName = (name: string) => sha256(name.toLowerCase().replace(/[\\s\\p{P}]/gu, ''));\n\n/** The same event name → conversion id map `linkedInAds` takes in the browser. */\nexport type { LinkedinConversionConfig } from '../third-parties/linkedin-insight-tag';\n\n/**\n * `conversionHappenedAt` must be \"within the past 90 days\", and one invalid record makes \"all\n * records fail\"; such an event is left out, with a minute's margin for the trip.\n */\nconst MAX_EVENT_AGE_MS = 90 * 24 * 60 * 60 * 1000 - 60 * 1000;\n\n/**\n * The `LinkedIn-Version` (YYYYMM) the request is made against. LinkedIn supports each version\n * for one year from its release, then requests to it fail, so this must be bumped with each\n * release (or overridden through `apiVersion`).\n */\nconst API_VERSION = '202609';\n\nexport async function sendEvents(\n accessToken: string,\n config: LinkedinConversionConfig,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n events: TrackEvent<any>[],\n data: UserProvidedData = {},\n apiVersion: string = API_VERSION\n) {\n const address = getFirst(data.address);\n const userIds: { idType: UserIdType; idValue: string }[] = [];\n const externalIds: [string, ...string[]] | undefined = data.user_id ? [data.user_id] : undefined;\n const userInfo =\n address?.first_name && address.last_name\n ? {\n hashedFirstName: hashName(address.first_name),\n hashedLastName: hashName(address.last_name),\n countryCode: address.country,\n }\n : undefined;\n\n if (data.email) {\n const email = getFirst(data.email);\n if (email) userIds.push({ idType: 'SHA256_EMAIL', idValue: hashEmail(email) });\n }\n\n // LinkedIn takes the IP as is (it salts and hashes it itself), IPv4 only.\n // https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/conversions-api\n if (data.ip_address && isIPv4(data.ip_address)) {\n userIds.push({ idType: 'PLAINTEXT_IP_ADDRESS', idValue: data.ip_address });\n }\n\n // The identifiers each event carries itself: the click id, and the Android advertising id.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const eventIds = (event: TrackEvent<any>): { idType: UserIdType; idValue: string }[] => {\n const ids: { idType: UserIdType; idValue: string }[] = [];\n const fatId = linkedinFatId(event.tags);\n if (fatId) ids.push({ idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID', idValue: fatId });\n if (event.platform === 'android' && event.tags.advertising_id) {\n ids.push({ idType: 'GOOGLE_AID', idValue: event.tags.advertising_id });\n }\n return ids;\n };\n\n const dto: CreateMultipleLinkedinEventsDTO = {\n elements: events\n .filter((event) => !IGNORED_EVENTS.includes(event.name))\n .filter((event) => Date.now() - Date.parse(event.created_at) <= MAX_EVENT_AGE_MS)\n .flatMap((event) => {\n const conversionId = config[event.name as TrackName];\n return conversionId === undefined ? [] : [{ event, conversionId }];\n })\n .map(({ event, conversionId }): CreateLinkedinEventDTO => ({\n eventId: event.id,\n conversion: `urn:lla:llaPartnerConversion:${conversionId}`,\n conversionHappenedAt: new Date(event.created_at).getTime(),\n conversionValue: {\n currencyCode: event.properties?.currency?.toUpperCase() ?? 'USD',\n amount: event.properties?.value?.toString() ?? '0',\n },\n user: {\n userIds: [...eventIds(event), ...userIds],\n userInfo,\n externalIds,\n },\n }))\n // An element carrying no identifier at all fails validation, and LinkedIn fails the whole\n // batch when one element fails — so a single anonymous event would discard every\n // identifiable conversion sent alongside it. Dropped here instead.\n .filter(\n ({ user }) =>\n user.userIds.length > 0 || !!user.userInfo || !!user.externalIds || !!user.lead\n ),\n };\n\n if (dto.elements.length === 0) return;\n const response = await fetch('https://api.linkedin.com/rest/conversionEvents', {\n method: 'POST',\n // Retried although a POST: the platform deduplicates on the `eventId` each event carries.\n retries: 3,\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'LinkedIn-Version': apiVersion,\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n },\n body: JSON.stringify(dto),\n });\n\n if (response.ok) return;\n throw new ConversionsApiError('linkedin', response.status, await response.text());\n}\n\n/** LinkedIn's Conversions API, sent the events in `conversions`, as `linkedInAds` is. */\nexport function linkedinConversions(\n options: Pick<LinkedInAdsOptions, 'conversions'> & {\n accessToken: string;\n /** `LinkedIn-Version` header (YYYYMM), e.g. '202609'. */\n apiVersion?: string;\n }\n): ConversionDestination {\n return conversionDestination(\n (name) => options.conversions[name as TrackName] !== undefined,\n (events, data) =>\n sendEvents(options.accessToken, options.conversions, events, data, options.apiVersion)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyFA,MAAM,UAAU,UAAkB,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;;;;;AAMjF,MAAM,aAAa,UAAkB,OAAO,MAAM,YAAY,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC;;;;;;;;;;;AAYlF,MAAM,YAAY,SAAiB,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,eAAe,EAAE,CAAC;;;;;AASvF,MAAM,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C,CACD,KAAK,EAAE,OAAO,oBAA4C;EACzD,SAAS,MAAM;EACf,YAAY,gCAAgC;EAC5C,sBAAsB,IAAI,KAAK,MAAM,UAAU,CAAC,CAAC,QAAQ;EACzD,iBAAiB;GACf,cAAc,MAAM,YAAY,UAAU,YAAY,KAAK;GAC3D,QAAQ,MAAM,YAAY,OAAO,SAAS,KAAK;EACjD;EACA,MAAM;GACJ,SAAS,CAAC,GAAG,SAAS,KAAK,GAAG,GAAG,OAAO;GACxC;GACA;EACF;CACF,EAAE,CAAC,CAIF,QACE,EAAE,WACD,KAAK,QAAQ,SAAS,KAAK,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,KAAK,IAC/E,EACJ;CAEA,IAAI,IAAI,SAAS,WAAW,GAAG;CAC/B,MAAM,WAAW,MAAM,MAAM,kDAAkD;EAC7E,QAAQ;EAER,SAAS;EACT,SAAS;GACP,eAAe,UAAU;GACzB,gBAAgB;GAChB,oBAAoB;GACpB,6BAA6B;GAC7B,mBAAmB;EACrB;EACA,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,SAAS,IAAI;CACjB,MAAM,IAAI,oBAAoB,YAAY,SAAS,QAAQ,MAAM,SAAS,KAAK,CAAC;AAClF;;AAGA,SAAgB,oBACd,SAKuB;CACvB,OAAO,uBACJ,SAAS,QAAQ,YAAY,UAAuB,KAAA,IACpD,QAAQ,SACP,WAAW,QAAQ,aAAa,QAAQ,aAAa,QAAQ,MAAM,QAAQ,UAAU,CACzF;AACF"}
@@ -34,7 +34,11 @@ let capi_param_builder_nodejs = require("capi-param-builder-nodejs");
34
34
  * https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api
35
35
  * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters
36
36
  */
37
- /** Matches the Graph API version the pinned business SDK speaks (`FacebookAdsApi.VERSION`). */
37
+ /**
38
+ * Matches the Graph API version the pinned business SDK speaks (`FacebookAdsApi.VERSION`). Meta
39
+ * keeps each Graph API version for about two years from its release, then requests to it fail,
40
+ * so this must be bumped with each release (or overridden through `apiVersion`).
41
+ */
38
42
  const API_VERSION = "v24.0";
39
43
  const USER_ASSIGNED_COUNTRIES = ["xk"];
40
44
  function normalizeCountry(input) {