@shware/analytics 15.0.1 → 16.0.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 (162) hide show
  1. package/README.md +89 -36
  2. package/dist/native/fbsdk.cjs +45 -1
  3. package/dist/native/fbsdk.cjs.map +1 -1
  4. package/dist/native/fbsdk.d.cts +23 -1
  5. package/dist/native/fbsdk.d.cts.map +1 -1
  6. package/dist/native/fbsdk.d.mts +23 -1
  7. package/dist/native/fbsdk.d.mts.map +1 -1
  8. package/dist/native/fbsdk.mjs +44 -2
  9. package/dist/native/fbsdk.mjs.map +1 -1
  10. package/dist/native/firebase.cjs +27 -0
  11. package/dist/native/firebase.cjs.map +1 -1
  12. package/dist/native/firebase.d.cts +11 -0
  13. package/dist/native/firebase.d.cts.map +1 -1
  14. package/dist/native/firebase.d.mts +11 -0
  15. package/dist/native/firebase.d.mts.map +1 -1
  16. package/dist/native/firebase.mjs +27 -2
  17. package/dist/native/firebase.mjs.map +1 -1
  18. package/dist/next/index.cjs +10 -123
  19. package/dist/next/index.cjs.map +1 -1
  20. package/dist/next/index.d.cts +2 -31
  21. package/dist/next/index.d.cts.map +1 -1
  22. package/dist/next/index.d.mts +2 -31
  23. package/dist/next/index.d.mts.map +1 -1
  24. package/dist/next/index.mjs +10 -123
  25. package/dist/next/index.mjs.map +1 -1
  26. package/dist/react/index.cjs +45 -0
  27. package/dist/react/index.cjs.map +1 -0
  28. package/dist/react/index.d.cts +15 -0
  29. package/dist/react/index.d.cts.map +1 -0
  30. package/dist/react/index.d.mts +15 -0
  31. package/dist/react/index.d.mts.map +1 -0
  32. package/dist/react/index.mjs +43 -0
  33. package/dist/react/index.mjs.map +1 -0
  34. package/dist/react/use-feature-flag.cjs +23 -0
  35. package/dist/react/use-feature-flag.cjs.map +1 -0
  36. package/dist/react/use-feature-flag.d.cts +10 -0
  37. package/dist/react/use-feature-flag.d.cts.map +1 -0
  38. package/dist/react/use-feature-flag.d.mts +10 -0
  39. package/dist/react/use-feature-flag.d.mts.map +1 -0
  40. package/dist/react/use-feature-flag.mjs +22 -0
  41. package/dist/react/use-feature-flag.mjs.map +1 -0
  42. package/dist/server/reddit-conversions-api.d.cts +1 -1
  43. package/dist/server/reddit-conversions-api.d.mts +1 -1
  44. package/dist/setup/index.cjs +4 -4
  45. package/dist/setup/index.cjs.map +1 -1
  46. package/dist/setup/index.d.cts +16 -6
  47. package/dist/setup/index.d.cts.map +1 -1
  48. package/dist/setup/index.d.mts +16 -6
  49. package/dist/setup/index.d.mts.map +1 -1
  50. package/dist/setup/index.mjs +4 -4
  51. package/dist/setup/index.mjs.map +1 -1
  52. package/dist/tanstack/index.cjs +0 -2
  53. package/dist/tanstack/index.d.cts +1 -2
  54. package/dist/tanstack/index.d.mts +1 -2
  55. package/dist/tanstack/index.mjs +1 -3
  56. package/dist/third-parties/analytics-props.cjs +28 -0
  57. package/dist/third-parties/analytics-props.cjs.map +1 -0
  58. package/dist/third-parties/analytics-props.d.cts +23 -0
  59. package/dist/third-parties/analytics-props.d.cts.map +1 -0
  60. package/dist/third-parties/analytics-props.d.mts +23 -0
  61. package/dist/third-parties/analytics-props.d.mts.map +1 -0
  62. package/dist/third-parties/analytics-props.mjs +26 -0
  63. package/dist/third-parties/analytics-props.mjs.map +1 -0
  64. package/dist/third-parties/google-analytics.cjs +32 -0
  65. package/dist/third-parties/google-analytics.cjs.map +1 -1
  66. package/dist/third-parties/google-analytics.d.cts +11 -1
  67. package/dist/third-parties/google-analytics.d.cts.map +1 -1
  68. package/dist/third-parties/google-analytics.d.mts +11 -1
  69. package/dist/third-parties/google-analytics.d.mts.map +1 -1
  70. package/dist/third-parties/google-analytics.mjs +32 -1
  71. package/dist/third-parties/google-analytics.mjs.map +1 -1
  72. package/dist/third-parties/index.cjs +16 -0
  73. package/dist/third-parties/index.d.cts +9 -7
  74. package/dist/third-parties/index.d.mts +9 -7
  75. package/dist/third-parties/index.mjs +9 -7
  76. package/dist/third-parties/integration.cjs +39 -0
  77. package/dist/third-parties/integration.cjs.map +1 -0
  78. package/dist/third-parties/integration.d.cts +57 -0
  79. package/dist/third-parties/integration.d.cts.map +1 -0
  80. package/dist/third-parties/integration.d.mts +57 -0
  81. package/dist/third-parties/integration.d.mts.map +1 -0
  82. package/dist/third-parties/integration.mjs +37 -0
  83. package/dist/third-parties/integration.mjs.map +1 -0
  84. package/dist/third-parties/linkedin-insight-tag.cjs +33 -0
  85. package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
  86. package/dist/third-parties/linkedin-insight-tag.d.cts +12 -8
  87. package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
  88. package/dist/third-parties/linkedin-insight-tag.d.mts +12 -8
  89. package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
  90. package/dist/third-parties/linkedin-insight-tag.mjs +33 -1
  91. package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
  92. package/dist/third-parties/meta-pixel.cjs +34 -0
  93. package/dist/third-parties/meta-pixel.cjs.map +1 -1
  94. package/dist/third-parties/meta-pixel.d.cts +5 -0
  95. package/dist/third-parties/meta-pixel.d.cts.map +1 -1
  96. package/dist/third-parties/meta-pixel.d.mts +5 -0
  97. package/dist/third-parties/meta-pixel.d.mts.map +1 -1
  98. package/dist/third-parties/meta-pixel.mjs +34 -1
  99. package/dist/third-parties/meta-pixel.mjs.map +1 -1
  100. package/dist/third-parties/microsoft-uet.cjs +49 -0
  101. package/dist/third-parties/microsoft-uet.cjs.map +1 -1
  102. package/dist/third-parties/microsoft-uet.d.cts +29 -0
  103. package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
  104. package/dist/third-parties/microsoft-uet.d.mts +29 -0
  105. package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
  106. package/dist/third-parties/microsoft-uet.mjs +48 -1
  107. package/dist/third-parties/microsoft-uet.mjs.map +1 -1
  108. package/dist/third-parties/openai-pixel.cjs +31 -0
  109. package/dist/third-parties/openai-pixel.cjs.map +1 -1
  110. package/dist/third-parties/openai-pixel.d.cts +5 -0
  111. package/dist/third-parties/openai-pixel.d.cts.map +1 -1
  112. package/dist/third-parties/openai-pixel.d.mts +5 -0
  113. package/dist/third-parties/openai-pixel.d.mts.map +1 -1
  114. package/dist/third-parties/openai-pixel.mjs +31 -1
  115. package/dist/third-parties/openai-pixel.mjs.map +1 -1
  116. package/dist/third-parties/posthog.cjs +97 -4
  117. package/dist/third-parties/posthog.cjs.map +1 -1
  118. package/dist/third-parties/posthog.d.cts +56 -1
  119. package/dist/third-parties/posthog.d.cts.map +1 -1
  120. package/dist/third-parties/posthog.d.mts +56 -1
  121. package/dist/third-parties/posthog.d.mts.map +1 -1
  122. package/dist/third-parties/posthog.mjs +91 -2
  123. package/dist/third-parties/posthog.mjs.map +1 -1
  124. package/dist/third-parties/reddit-pixel.cjs +32 -0
  125. package/dist/third-parties/reddit-pixel.cjs.map +1 -1
  126. package/dist/third-parties/reddit-pixel.d.cts +5 -0
  127. package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
  128. package/dist/third-parties/reddit-pixel.d.mts +5 -0
  129. package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
  130. package/dist/third-parties/reddit-pixel.mjs +32 -1
  131. package/dist/third-parties/reddit-pixel.mjs.map +1 -1
  132. package/dist/track/fbq.cjs +1 -1
  133. package/dist/track/fbq.cjs.map +1 -1
  134. package/dist/track/fbq.mjs +1 -1
  135. package/dist/track/fbq.mjs.map +1 -1
  136. package/dist/track/index.cjs +7 -7
  137. package/dist/track/index.cjs.map +1 -1
  138. package/dist/track/index.d.cts.map +1 -1
  139. package/dist/track/index.d.mts.map +1 -1
  140. package/dist/track/index.mjs +7 -7
  141. package/dist/track/index.mjs.map +1 -1
  142. package/dist/visitor/index.cjs +3 -3
  143. package/dist/visitor/index.cjs.map +1 -1
  144. package/dist/visitor/index.mjs +3 -3
  145. package/dist/visitor/index.mjs.map +1 -1
  146. package/package.json +11 -24
  147. package/dist/react-router/index.cjs +0 -160
  148. package/dist/react-router/index.cjs.map +0 -1
  149. package/dist/react-router/index.d.cts +0 -22
  150. package/dist/react-router/index.d.cts.map +0 -1
  151. package/dist/react-router/index.d.mts +0 -22
  152. package/dist/react-router/index.d.mts.map +0 -1
  153. package/dist/react-router/index.mjs +0 -159
  154. package/dist/react-router/index.mjs.map +0 -1
  155. package/dist/tanstack/analytics.cjs +0 -184
  156. package/dist/tanstack/analytics.cjs.map +0 -1
  157. package/dist/tanstack/analytics.d.cts +0 -33
  158. package/dist/tanstack/analytics.d.cts.map +0 -1
  159. package/dist/tanstack/analytics.d.mts +0 -33
  160. package/dist/tanstack/analytics.d.mts.map +0 -1
  161. package/dist/tanstack/analytics.mjs +0 -183
  162. package/dist/tanstack/analytics.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return false;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n // No user is sign-out (`reset()`): GA keeps a set user_id for every later event on the page, so\n // it is cleared explicitly.\n window.gtag('set', 'user_id', user_id || null);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n"],"mappings":";AAWA,SAAgB,YACd,MACA,YACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C,OAAO;CACT;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,aAA+B;CAClE,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CAGA,OAAO,KAAK,OAAO,WAAW,WAAW,IAAI;CAC7C,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;AAC1D"}
1
+ {"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { GaId, Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Integration } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return false;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n // No user is sign-out (`reset()`): GA keeps a set user_id for every later event on the page, so\n // it is cleared explicitly.\n window.gtag('set', 'user_id', user_id || null);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n\n/**\n * Google Analytics 4 (gtag.js): every event, for behavior analysis. `src` serves gtag.js from\n * another path (a first-party proxy); `debug` turns on GA4's DebugView for this page.\n */\nexport function googleAnalytics(options: { id: GaId; src?: string; debug?: boolean }): Integration {\n const src = options.src ?? `https://www.googletagmanager.com/gtag/js?id=${options.id}`;\n return {\n type: 'analytics',\n track: sendGAEvent,\n setUser: setGAUser,\n script: {\n id: 'gtag',\n inline: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', ${JSON.stringify(options.id)}${options.debug ? ', { debug_mode: true }' : ''});\n (function (d, s, u) {\n var j = d.createElement(s);\n j.async = true;\n // A script added here does not inherit the nonce: hand it this one's, or a CSP that\n // allows scripts by nonce (without 'strict-dynamic') blocks gtag.js.\n j.nonce = d.currentScript && d.currentScript.nonce;\n j.src = u;\n var f = d.getElementsByTagName(s)[0];\n f.parentNode.insertBefore(j, f);\n })(document, 'script', ${JSON.stringify(src)});\n `,\n },\n };\n}\n"],"mappings":";AAYA,SAAgB,YACd,MACA,YACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C,OAAO;CACT;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,aAA+B;CAClE,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CAGA,OAAO,KAAK,OAAO,WAAW,WAAW,IAAI;CAC7C,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;AAC1D;;;;;AAMA,SAAgB,gBAAgB,SAAmE;CACjG,MAAM,MAAM,QAAQ,OAAO,+CAA+C,QAAQ;CAClF,OAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;yBAIW,KAAK,UAAU,QAAQ,EAAE,IAAI,QAAQ,QAAQ,2BAA2B,GAAG;;;;;;;;;;iCAUnE,KAAK,UAAU,GAAG,EAAE;;EAEjD;CACF;AACF"}
@@ -1,15 +1,29 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_third_parties_integration = require("./integration.cjs");
2
3
  const require_third_parties_microsoft_uet = require("./microsoft-uet.cjs");
4
+ const require_third_parties_posthog = require("./posthog.cjs");
3
5
  const require_third_parties_google_analytics = require("./google-analytics.cjs");
4
6
  const require_third_parties_meta_pixel = require("./meta-pixel.cjs");
5
7
  const require_third_parties_linkedin_insight_tag = require("./linkedin-insight-tag.cjs");
6
8
  const require_third_parties_openai_pixel = require("./openai-pixel.cjs");
7
9
  const require_third_parties_reddit_pixel = require("./reddit-pixel.cjs");
10
+ exports.CONVERSION_EVENTS = require_third_parties_integration.CONVERSION_EVENTS;
8
11
  exports.configureUET = require_third_parties_microsoft_uet.configureUET;
12
+ exports.getLoadedPosthog = require_third_parties_posthog.getLoadedPosthog;
13
+ exports.getPosthog = require_third_parties_posthog.getPosthog;
14
+ exports.googleAnalytics = require_third_parties_google_analytics.googleAnalytics;
15
+ exports.linkedInAds = require_third_parties_linkedin_insight_tag.linkedInAds;
16
+ exports.metaAds = require_third_parties_meta_pixel.metaAds;
17
+ exports.microsoftAds = require_third_parties_microsoft_uet.microsoftAds;
18
+ exports.openaiAds = require_third_parties_openai_pixel.openaiAds;
19
+ exports.posthogAnalytics = require_third_parties_posthog.posthogAnalytics;
20
+ exports.posthogFlagsReady = require_third_parties_posthog.posthogFlagsReady;
21
+ exports.redditAds = require_third_parties_reddit_pixel.redditAds;
9
22
  exports.sendFBEvent = require_third_parties_meta_pixel.sendFBEvent;
10
23
  exports.sendGAEvent = require_third_parties_google_analytics.sendGAEvent;
11
24
  exports.sendLinkedinEvent = require_third_parties_linkedin_insight_tag.sendLinkedinEvent;
12
25
  exports.sendOpenAIEvent = require_third_parties_openai_pixel.sendOpenAIEvent;
26
+ exports.sendPosthogEvent = require_third_parties_posthog.sendPosthogEvent;
13
27
  exports.sendRedditEvent = require_third_parties_reddit_pixel.sendRedditEvent;
14
28
  exports.sendUETEvent = require_third_parties_microsoft_uet.sendUETEvent;
15
29
  exports.sendUETIdSync = require_third_parties_microsoft_uet.sendUETIdSync;
@@ -17,7 +31,9 @@ exports.setFBUser = require_third_parties_meta_pixel.setFBUser;
17
31
  exports.setGAUser = require_third_parties_google_analytics.setGAUser;
18
32
  exports.setLinkedinUser = require_third_parties_linkedin_insight_tag.setLinkedinUser;
19
33
  exports.setOpenAIUser = require_third_parties_openai_pixel.setOpenAIUser;
34
+ exports.setPosthogUser = require_third_parties_posthog.setPosthogUser;
20
35
  exports.setRedditUser = require_third_parties_reddit_pixel.setRedditUser;
21
36
  exports.setUETConsent = require_third_parties_microsoft_uet.setUETConsent;
22
37
  exports.setUETUser = require_third_parties_microsoft_uet.setUETUser;
23
38
  exports.syncUETVisitor = require_third_parties_microsoft_uet.syncUETVisitor;
39
+ exports.uetCustomerIdOf = require_third_parties_microsoft_uet.uetCustomerIdOf;
@@ -1,8 +1,10 @@
1
+ import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.cjs";
2
+ import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.cjs";
3
+ import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.cjs";
4
+ import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.cjs";
5
+ import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.cjs";
6
+ import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.cjs";
7
+ import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
1
8
  import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.cjs";
2
- import { sendGAEvent, setGAUser } from "./google-analytics.cjs";
3
- import { sendFBEvent, setFBUser } from "./meta-pixel.cjs";
4
- import { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.cjs";
5
- import { sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.cjs";
6
- import { sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
7
- import { configureUET, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor } from "./microsoft-uet.cjs";
8
- export { type LinkedinConversionConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor };
9
+ import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.cjs";
10
+ export { type AdsOptions, CONVERSION_EVENTS, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
@@ -1,8 +1,10 @@
1
+ import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.mjs";
2
+ import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
3
+ import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
4
+ import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
5
+ import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
6
+ import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
7
+ import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
1
8
  import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.mjs";
2
- import { sendGAEvent, setGAUser } from "./google-analytics.mjs";
3
- import { sendFBEvent, setFBUser } from "./meta-pixel.mjs";
4
- import { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
5
- import { sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
6
- import { sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
7
- import { configureUET, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor } from "./microsoft-uet.mjs";
8
- export { type LinkedinConversionConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor };
9
+ import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
10
+ export { type AdsOptions, CONVERSION_EVENTS, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
@@ -1,7 +1,9 @@
1
- import { configureUET, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor } from "./microsoft-uet.mjs";
2
- import { sendGAEvent, setGAUser } from "./google-analytics.mjs";
3
- import { sendFBEvent, setFBUser } from "./meta-pixel.mjs";
4
- import { sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
5
- import { sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
6
- import { sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
7
- export { configureUET, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor };
1
+ import { CONVERSION_EVENTS } from "./integration.mjs";
2
+ import { configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
3
+ import { getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
4
+ import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
5
+ import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
6
+ import { linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
7
+ import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
8
+ import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
9
+ export { CONVERSION_EVENTS, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
@@ -0,0 +1,39 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/third-parties/integration.ts
3
+ /**
4
+ * The GA4 recommended events that are conversions or close to one, for an ad platform with no
5
+ * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
6
+ */
7
+ const CONVERSION_EVENTS = [
8
+ "sign_up",
9
+ "login",
10
+ "generate_lead",
11
+ "view_item",
12
+ "add_to_cart",
13
+ "add_to_wishlist",
14
+ "begin_checkout",
15
+ "add_payment_info",
16
+ "purchase",
17
+ "subscribe",
18
+ "trial_begin",
19
+ "search",
20
+ "schedule",
21
+ "submit_application",
22
+ "contact"
23
+ ];
24
+ /**
25
+ * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
26
+ * turns into one of its standard events — and the custom events the host listed. Everything
27
+ * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
28
+ * GA4's and PostHog's job, and only noise to an ad platform's optimization.
29
+ */
30
+ function adsTracker(send, isStandard, customEvents) {
31
+ return (name, properties, eventId) => {
32
+ if (!isStandard(name) && !customEvents.includes(name)) return;
33
+ return send(name, properties, eventId);
34
+ };
35
+ }
36
+ exports.CONVERSION_EVENTS = CONVERSION_EVENTS;
37
+ exports.adsTracker = adsTracker;
38
+
39
+ //# sourceMappingURL=integration.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.cjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /** The element id; also its React key, and how a test or a CSP report finds it. */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it.\n */\n customEvents?: readonly EventName[];\n}\n\n/**\n * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper\n * turns into one of its standard events — and the custom events the host listed. Everything\n * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is\n * GA4's and PostHog's job, and only noise to an ad platform's optimization.\n */\nexport function adsTracker(\n send: ThirdPartyTracker,\n isStandard: (name: string) => boolean,\n customEvents: readonly string[]\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!isStandard(name) && !customEvents.includes(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;;AA2CA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAiBA,SAAgB,WACd,MACA,YACA,cACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa,SAAS,IAAI,GAAG;EACvD,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
@@ -0,0 +1,57 @@
1
+ import { EventName, ThirdPartyTracker } from "../track/types.cjs";
2
+ import { ThirdPartyUserSetter } from "../visitor/types.cjs";
3
+ /**
4
+ * The one script an integration puts on the page, rendered by `<Analytics integrations>`
5
+ * (react, next) with the request's `nonce`: an inline snippet that loads the
6
+ * vendor's own script from its host, as every vendor's official snippet does.
7
+ */
8
+ export interface IntegrationScript {
9
+ /** The element id; also its React key, and how a test or a CSP report finds it. */
10
+ readonly id: string;
11
+ readonly inline: string;
12
+ /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */
13
+ readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';
14
+ }
15
+ /**
16
+ * One third party, configured in one place: how events reach it, how it learns the signed-in
17
+ * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`
18
+ * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and
19
+ * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.
20
+ *
21
+ * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every
22
+ * event, for behavior analysis. An `ads` integration receives only what helps an ad platform
23
+ * optimize and build audiences — the conversion events it maps to its own standard events, plus
24
+ * the custom events it was explicitly given — and filters in its own `track`.
25
+ */
26
+ export interface Integration {
27
+ readonly type: 'analytics' | 'ads';
28
+ readonly track: ThirdPartyTracker;
29
+ readonly setUser?: ThirdPartyUserSetter;
30
+ readonly script?: IntegrationScript;
31
+ /**
32
+ * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up
33
+ * before the script asks for something there — e.g. where a snippet loads its library from.
34
+ */
35
+ readonly preconnect?: readonly string[];
36
+ }
37
+ /**
38
+ * The GA4 recommended events that are conversions or close to one, for an ad platform with no
39
+ * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
40
+ */
41
+ export declare const CONVERSION_EVENTS: readonly ["sign_up", "login", "generate_lead", "view_item", "add_to_cart", "add_to_wishlist", "begin_checkout", "add_payment_info", "purchase", "subscribe", "trial_begin", "search", "schedule", "submit_application", "contact"];
42
+ export interface AdsOptions {
43
+ /**
44
+ * Custom events this platform receives besides the conversions it maps to its standard
45
+ * events, e.g. one used as an optimization goal or for an audience. Everything else is not
46
+ * sent to it.
47
+ */
48
+ customEvents?: readonly EventName[];
49
+ }
50
+ /**
51
+ * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
52
+ * turns into one of its standard events — and the custom events the host listed. Everything
53
+ * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
54
+ * GA4's and PostHog's job, and only noise to an ad platform's optimization.
55
+ */
56
+ export declare function adsTracker(send: ThirdPartyTracker, isStandard: (name: string) => boolean, customEvents: readonly string[]): ThirdPartyTracker;
57
+ //# sourceMappingURL=integration.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.d.cts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;WAEN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;qBAOE;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;wBASV,WACd,MAAM,mBACN,aAAa,0BACb,kCACC"}
@@ -0,0 +1,57 @@
1
+ import { EventName, ThirdPartyTracker } from "../track/types.mjs";
2
+ import { ThirdPartyUserSetter } from "../visitor/types.mjs";
3
+ /**
4
+ * The one script an integration puts on the page, rendered by `<Analytics integrations>`
5
+ * (react, next) with the request's `nonce`: an inline snippet that loads the
6
+ * vendor's own script from its host, as every vendor's official snippet does.
7
+ */
8
+ export interface IntegrationScript {
9
+ /** The element id; also its React key, and how a test or a CSP report finds it. */
10
+ readonly id: string;
11
+ readonly inline: string;
12
+ /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */
13
+ readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';
14
+ }
15
+ /**
16
+ * One third party, configured in one place: how events reach it, how it learns the signed-in
17
+ * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`
18
+ * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and
19
+ * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.
20
+ *
21
+ * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every
22
+ * event, for behavior analysis. An `ads` integration receives only what helps an ad platform
23
+ * optimize and build audiences — the conversion events it maps to its own standard events, plus
24
+ * the custom events it was explicitly given — and filters in its own `track`.
25
+ */
26
+ export interface Integration {
27
+ readonly type: 'analytics' | 'ads';
28
+ readonly track: ThirdPartyTracker;
29
+ readonly setUser?: ThirdPartyUserSetter;
30
+ readonly script?: IntegrationScript;
31
+ /**
32
+ * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up
33
+ * before the script asks for something there — e.g. where a snippet loads its library from.
34
+ */
35
+ readonly preconnect?: readonly string[];
36
+ }
37
+ /**
38
+ * The GA4 recommended events that are conversions or close to one, for an ad platform with no
39
+ * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
40
+ */
41
+ export declare const CONVERSION_EVENTS: readonly ["sign_up", "login", "generate_lead", "view_item", "add_to_cart", "add_to_wishlist", "begin_checkout", "add_payment_info", "purchase", "subscribe", "trial_begin", "search", "schedule", "submit_application", "contact"];
42
+ export interface AdsOptions {
43
+ /**
44
+ * Custom events this platform receives besides the conversions it maps to its standard
45
+ * events, e.g. one used as an optimization goal or for an audience. Everything else is not
46
+ * sent to it.
47
+ */
48
+ customEvents?: readonly EventName[];
49
+ }
50
+ /**
51
+ * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
52
+ * turns into one of its standard events — and the custom events the host listed. Everything
53
+ * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
54
+ * GA4's and PostHog's job, and only noise to an ad platform's optimization.
55
+ */
56
+ export declare function adsTracker(send: ThirdPartyTracker, isStandard: (name: string) => boolean, customEvents: readonly string[]): ThirdPartyTracker;
57
+ //# sourceMappingURL=integration.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.d.mts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;WAEN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;qBAOE;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;wBASV,WACd,MAAM,mBACN,aAAa,0BACb,kCACC"}
@@ -0,0 +1,37 @@
1
+ // src/third-parties/integration.ts
2
+ /**
3
+ * The GA4 recommended events that are conversions or close to one, for an ad platform with no
4
+ * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
5
+ */
6
+ const CONVERSION_EVENTS = [
7
+ "sign_up",
8
+ "login",
9
+ "generate_lead",
10
+ "view_item",
11
+ "add_to_cart",
12
+ "add_to_wishlist",
13
+ "begin_checkout",
14
+ "add_payment_info",
15
+ "purchase",
16
+ "subscribe",
17
+ "trial_begin",
18
+ "search",
19
+ "schedule",
20
+ "submit_application",
21
+ "contact"
22
+ ];
23
+ /**
24
+ * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
25
+ * turns into one of its standard events — and the custom events the host listed. Everything
26
+ * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
27
+ * GA4's and PostHog's job, and only noise to an ad platform's optimization.
28
+ */
29
+ function adsTracker(send, isStandard, customEvents) {
30
+ return (name, properties, eventId) => {
31
+ if (!isStandard(name) && !customEvents.includes(name)) return;
32
+ return send(name, properties, eventId);
33
+ };
34
+ }
35
+ export { CONVERSION_EVENTS, adsTracker };
36
+
37
+ //# sourceMappingURL=integration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.mjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /** The element id; also its React key, and how a test or a CSP report finds it. */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it.\n */\n customEvents?: readonly EventName[];\n}\n\n/**\n * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper\n * turns into one of its standard events — and the custom events the host listed. Everything\n * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is\n * GA4's and PostHog's job, and only noise to an ad platform's optimization.\n */\nexport function adsTracker(\n send: ThirdPartyTracker,\n isStandard: (name: string) => boolean,\n customEvents: readonly string[]\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!isStandard(name) && !customEvents.includes(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;AA2CA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAiBA,SAAgB,WACd,MACA,YACA,cACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa,SAAS,IAAI,GAAG;EACvD,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
@@ -26,6 +26,39 @@ function setLinkedinUser({ user_data }) {
26
26
  if (!email) return;
27
27
  window.lintrk("setUserData", { email });
28
28
  }
29
+ /**
30
+ * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
31
+ * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
32
+ */
33
+ function linkedInAds(options) {
34
+ return {
35
+ type: "ads",
36
+ track: sendLinkedinEvent(options.conversions),
37
+ setUser: setLinkedinUser,
38
+ script: {
39
+ id: "linkedin-insight-tag",
40
+ inline: `
41
+ _linkedin_partner_id = ${JSON.stringify(options.partnerId)};
42
+ window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
43
+ window._linkedin_data_partner_ids.push(_linkedin_partner_id);
44
+ (function(l) {
45
+ if (!l){
46
+ window.lintrk = function(a,b){
47
+ window.lintrk.q.push([a,b])
48
+ };
49
+ window.lintrk.q=[]
50
+ }
51
+ var s = document.getElementsByTagName("script")[0];
52
+ var b = document.createElement("script");
53
+ b.type = "text/javascript";b.async = true;
54
+ b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
55
+ s.parentNode.insertBefore(b, s);
56
+ })(window.lintrk);
57
+ `
58
+ }
59
+ };
60
+ }
61
+ exports.linkedInAds = linkedInAds;
29
62
  exports.sendLinkedinEvent = sendLinkedinEvent;
30
63
  exports.setLinkedinUser = setLinkedinUser;
31
64
 
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;;AAuBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQA,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
1
+ {"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { Integration } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the\n * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.\n */\nexport type LinkedinConversionConfig = { readonly [K in TrackName]?: number };\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n\n/**\n * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps\n * to (LinkedIn conversions are created in Campaign Manager and addressed by id).\n */\nexport function linkedInAds(options: {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}): Integration {\n return {\n type: 'ads',\n track: sendLinkedinEvent(options.conversions),\n setUser: setLinkedinUser,\n script: {\n id: 'linkedin-insight-tag',\n inline: `\n _linkedin_partner_id = ${JSON.stringify(options.partnerId)};\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n },\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQA,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;;;;;AAMA,SAAgB,YAAY,SAGZ;CACd,OAAO;EACL,MAAM;EACN,OAAO,kBAAkB,QAAQ,WAAW;EAC5C,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;iCACmB,KAAK,UAAU,QAAQ,SAAS,EAAE;;;;;;;;;;;;;;;;;EAiB/D;CACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
2
2
  import { UpdateVisitorDTO } from "../schema/index.cjs";
3
+ import { Integration } from "./integration.cjs";
3
4
  import { Lintrk } from "../track/lintrk.cjs";
4
5
  declare global {
5
6
  interface Window {
@@ -8,15 +9,18 @@ declare global {
8
9
  }
9
10
  }
10
11
  /**
11
- * LinkedIn Conversion Config:
12
- * example:
13
- * {
14
- * purchase: 123,
15
- * add_to_cart: 456,
16
- * add_to_wishlist: 789,
17
- * }
12
+ * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the
13
+ * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.
18
14
  */
19
- export type LinkedinConversionConfig = Record<Lowercase<string>, number>;
15
+ export type LinkedinConversionConfig = { readonly [K in TrackName]?: number; };
20
16
  export declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => false | undefined;
21
17
  export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
18
+ /**
19
+ * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
20
+ * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
21
+ */
22
+ export declare function linkedInAds(options: {
23
+ partnerId: `${number}`;
24
+ conversions: LinkedinConversionConfig;
25
+ }): Integration;
22
26
  //# sourceMappingURL=linkedin-insight-tag.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;QAKQ;YACI;;IAER,SAAS;;;;;;;;;;;;YAaD,2BAA2B,OAAO;wBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa"}
1
+ {"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;wBAe/B,YAAY;EAC1B;EACA,aAAa;IACX"}
@@ -1,5 +1,6 @@
1
1
  import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
2
2
  import { UpdateVisitorDTO } from "../schema/index.mjs";
3
+ import { Integration } from "./integration.mjs";
3
4
  import { Lintrk } from "../track/lintrk.mjs";
4
5
  declare global {
5
6
  interface Window {
@@ -8,15 +9,18 @@ declare global {
8
9
  }
9
10
  }
10
11
  /**
11
- * LinkedIn Conversion Config:
12
- * example:
13
- * {
14
- * purchase: 123,
15
- * add_to_cart: 456,
16
- * add_to_wishlist: 789,
17
- * }
12
+ * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the
13
+ * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.
18
14
  */
19
- export type LinkedinConversionConfig = Record<Lowercase<string>, number>;
15
+ export type LinkedinConversionConfig = { readonly [K in TrackName]?: number; };
20
16
  export declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => false | undefined;
21
17
  export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
18
+ /**
19
+ * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
20
+ * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
21
+ */
22
+ export declare function linkedInAds(options: {
23
+ partnerId: `${number}`;
24
+ conversions: LinkedinConversionConfig;
25
+ }): Integration;
22
26
  //# sourceMappingURL=linkedin-insight-tag.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;QAKQ;YACI;;IAER,SAAS;;;;;;;;;;;;YAaD,2BAA2B,OAAO;wBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa"}
1
+ {"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;wBAe/B,YAAY;EAC1B;EACA,aAAa;IACX"}
@@ -25,6 +25,38 @@ function setLinkedinUser({ user_data }) {
25
25
  if (!email) return;
26
26
  window.lintrk("setUserData", { email });
27
27
  }
28
- export { sendLinkedinEvent, setLinkedinUser };
28
+ /**
29
+ * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
30
+ * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
31
+ */
32
+ function linkedInAds(options) {
33
+ return {
34
+ type: "ads",
35
+ track: sendLinkedinEvent(options.conversions),
36
+ setUser: setLinkedinUser,
37
+ script: {
38
+ id: "linkedin-insight-tag",
39
+ inline: `
40
+ _linkedin_partner_id = ${JSON.stringify(options.partnerId)};
41
+ window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
42
+ window._linkedin_data_partner_ids.push(_linkedin_partner_id);
43
+ (function(l) {
44
+ if (!l){
45
+ window.lintrk = function(a,b){
46
+ window.lintrk.q.push([a,b])
47
+ };
48
+ window.lintrk.q=[]
49
+ }
50
+ var s = document.getElementsByTagName("script")[0];
51
+ var b = document.createElement("script");
52
+ b.type = "text/javascript";b.async = true;
53
+ b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
54
+ s.parentNode.insertBefore(b, s);
55
+ })(window.lintrk);
56
+ `
57
+ }
58
+ };
59
+ }
60
+ export { linkedInAds, sendLinkedinEvent, setLinkedinUser };
29
61
 
30
62
  //# sourceMappingURL=linkedin-insight-tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;AAuBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
1
+ {"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { Integration } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the\n * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.\n */\nexport type LinkedinConversionConfig = { readonly [K in TrackName]?: number };\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n\n/**\n * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps\n * to (LinkedIn conversions are created in Campaign Manager and addressed by id).\n */\nexport function linkedInAds(options: {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}): Integration {\n return {\n type: 'ads',\n track: sendLinkedinEvent(options.conversions),\n setUser: setLinkedinUser,\n script: {\n id: 'linkedin-insight-tag',\n inline: `\n _linkedin_partner_id = ${JSON.stringify(options.partnerId)};\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n },\n };\n}\n"],"mappings":";;AAmBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;;;;;AAMA,SAAgB,YAAY,SAGZ;CACd,OAAO;EACL,MAAM;EACN,OAAO,kBAAkB,QAAQ,WAAW;EAC5C,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;iCACmB,KAAK,UAAU,QAAQ,SAAS,EAAE;;;;;;;;;;;;;;;;;EAiB/D;CACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_field = require("../utils/field.cjs");
3
+ const require_third_parties_integration = require("./integration.cjs");
3
4
  const require_track_fbq = require("../track/fbq.cjs");
4
5
  // src/third-parties/meta-pixel.ts
5
6
  const metrics = [
@@ -43,6 +44,39 @@ function setFBUser(pixelId) {
43
44
  });
44
45
  };
45
46
  }
47
+ /** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */
48
+ function metaAds(options) {
49
+ const isStandard = (name) => require_track_fbq.mapFBEvent(name)[0] === "track";
50
+ return {
51
+ type: "ads",
52
+ track: require_third_parties_integration.adsTracker(sendFBEvent, isStandard, options.customEvents ?? []),
53
+ setUser: setFBUser(options.pixelId),
54
+ script: {
55
+ id: "meta-pixel",
56
+ inline: `
57
+ !(function (f, b, e, v, n, t, s) {
58
+ if (f.fbq) return;
59
+ n = f.fbq = function () {
60
+ n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
61
+ };
62
+ if (!f._fbq) f._fbq = n;
63
+ n.push = n;
64
+ n.loaded = !0;
65
+ n.version = '2.0';
66
+ n.queue = [];
67
+ t = b.createElement(e);
68
+ t.async = !0;
69
+ t.src = v;
70
+ s = b.getElementsByTagName(e)[0];
71
+ s.parentNode.insertBefore(t, s);
72
+ })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
73
+ fbq('init', ${JSON.stringify(options.pixelId)});
74
+ fbq('track', 'PageView');
75
+ `
76
+ }
77
+ };
78
+ }
79
+ exports.metaAds = metaAds;
46
80
  exports.sendFBEvent = sendFBEvent;
47
81
  exports.setFBUser = setFBUser;
48
82
 
@@ -1 +1 @@
1
- {"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n interface Window {\n /** Undefined until the Meta Pixel script has loaded. */\n fbq?: FBQ['fbq'];\n }\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return false;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n // The two branches are identical on purpose. `fbq` is overloaded per `type` — 'track' takes a\n // standard event name with its typed properties, 'trackCustom' an arbitrary string — and what\n // `mapFBEvent` returns is a union of both shapes. Narrowing `type` is what picks a single\n // overload; collapsing the branches leaves the call matching none of them.\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, user_data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n // `st` is Meta's state/province field, not the street address.\n st: address?.region,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;;AAYA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C,OAAO;CACT;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAK1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GAEb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst","adsTracker"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { type AdsOptions, type Integration, adsTracker } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Meta Pixel script has loaded. */\n fbq?: FBQ['fbq'];\n }\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return false;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n // The two branches are identical on purpose. `fbq` is overloaded per `type` — 'track' takes a\n // standard event name with its typed properties, 'trackCustom' an arbitrary string — and what\n // `mapFBEvent` returns is a union of both shapes. Narrowing `type` is what picks a single\n // overload; collapsing the branches leaves the call matching none of them.\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, user_data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n // `st` is Meta's state/province field, not the street address.\n st: address?.region,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n\n/** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */\nexport function metaAds(options: { pixelId: PixelId } & AdsOptions): Integration {\n const isStandard = (name: string) => mapFBEvent(name as TrackName)[0] === 'track';\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, isStandard, options.customEvents ?? []),\n setUser: setFBUser(options.pixelId),\n script: {\n id: 'meta-pixel',\n inline: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', ${JSON.stringify(options.pixelId)});\n fbq('track', 'PageView');\n `,\n },\n };\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C,OAAO;CACT;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAK1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GAEb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF;;AAGA,SAAgB,QAAQ,SAAyD;CAC/E,MAAM,cAAc,SAAiBD,kBAAAA,WAAW,IAAiB,CAAC,CAAC,OAAO;CAC1E,OAAO;EACL,MAAM;EACN,OAAOE,kCAAAA,WAAW,aAAa,YAAY,QAAQ,gBAAgB,CAAC,CAAC;EACrE,SAAS,UAAU,QAAQ,OAAO;EAClC,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;;;;;;;;;;;;;;sBAiBQ,KAAK,UAAU,QAAQ,OAAO,EAAE;;;EAGlD;CACF;AACF"}