@shware/analytics 16.5.0 → 16.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -2
  2. package/dist/ads/google.d.cts +13 -0
  3. package/dist/ads/google.d.cts.map +1 -1
  4. package/dist/ads/google.d.mts +13 -0
  5. package/dist/ads/google.d.mts.map +1 -1
  6. package/dist/ads/index.cjs +1 -1
  7. package/dist/ads/index.d.cts +1 -1
  8. package/dist/ads/index.d.mts +1 -1
  9. package/dist/ads/index.mjs +1 -1
  10. package/dist/ads/meta.cjs.map +1 -1
  11. package/dist/ads/meta.mjs.map +1 -1
  12. package/dist/ads/types.d.cts +1 -0
  13. package/dist/ads/types.d.cts.map +1 -1
  14. package/dist/attribution/index.cjs +1 -1
  15. package/dist/attribution/index.d.cts +1 -1
  16. package/dist/attribution/index.d.mts +1 -1
  17. package/dist/attribution/index.mjs +1 -1
  18. package/dist/click-id/index.cjs.map +1 -1
  19. package/dist/hooks/use-app-analytics.cjs +1 -1
  20. package/dist/hooks/use-app-analytics.cjs.map +1 -1
  21. package/dist/hooks/use-app-analytics.mjs +1 -1
  22. package/dist/hooks/use-outbound-click-analytics.cjs.map +1 -1
  23. package/dist/hooks/use-report-web-vitals.cjs.map +1 -1
  24. package/dist/hooks/use-track-impression.cjs.map +1 -1
  25. package/dist/hooks/use-uet-id-sync.cjs.map +1 -1
  26. package/dist/hooks/use-uet-id-sync.mjs.map +1 -1
  27. package/dist/hooks/use-web-analytics.cjs +2 -2
  28. package/dist/hooks/use-web-analytics.cjs.map +1 -1
  29. package/dist/hooks/use-web-analytics.mjs +2 -2
  30. package/dist/index.d.cts +7 -7
  31. package/dist/index.d.mts +7 -7
  32. package/dist/link/index.cjs.map +1 -1
  33. package/dist/link/index.d.cts +12 -1
  34. package/dist/link/index.d.cts.map +1 -1
  35. package/dist/link/index.d.mts +12 -1
  36. package/dist/link/index.d.mts.map +1 -1
  37. package/dist/link/index.mjs.map +1 -1
  38. package/dist/native/deep-link.cjs.map +1 -1
  39. package/dist/native/fbsdk.cjs +1 -1
  40. package/dist/native/fbsdk.cjs.map +1 -1
  41. package/dist/native/fbsdk.d.cts +1 -1
  42. package/dist/native/fbsdk.d.mts +1 -1
  43. package/dist/native/fbsdk.mjs +1 -1
  44. package/dist/native/firebase.cjs.map +1 -1
  45. package/dist/native/firebase.d.cts +1 -1
  46. package/dist/native/firebase.d.mts +1 -1
  47. package/dist/native/index.cjs +2 -2
  48. package/dist/native/index.d.cts +2 -2
  49. package/dist/native/index.d.mts +2 -2
  50. package/dist/native/index.mjs +2 -2
  51. package/dist/native/setup.cjs +1 -1
  52. package/dist/native/setup.cjs.map +1 -1
  53. package/dist/native/setup.d.cts +1 -2
  54. package/dist/native/setup.d.cts.map +1 -1
  55. package/dist/native/setup.d.mts +1 -1
  56. package/dist/native/setup.mjs +1 -1
  57. package/dist/next/index.cjs +2 -2
  58. package/dist/next/index.cjs.map +1 -1
  59. package/dist/next/index.mjs +2 -2
  60. package/dist/node_modules/.pnpm/bowser@2.15.0/node_modules/bowser/bowser.cjs +2157 -0
  61. package/dist/node_modules/.pnpm/bowser@2.15.0/node_modules/bowser/bowser.cjs.map +1 -0
  62. package/dist/node_modules/.pnpm/bowser@2.15.0/node_modules/bowser/bowser.mjs +2152 -0
  63. package/dist/node_modules/.pnpm/bowser@2.15.0/node_modules/bowser/bowser.mjs.map +1 -0
  64. package/dist/react/index.cjs +2 -2
  65. package/dist/react/index.cjs.map +1 -1
  66. package/dist/react/index.mjs +2 -2
  67. package/dist/react/posthog-error-boundary.cjs.map +1 -1
  68. package/dist/react/posthog-error-boundary.mjs.map +1 -1
  69. package/dist/server/conversions-api-error.cjs.map +1 -1
  70. package/dist/server/conversions-api-error.mjs.map +1 -1
  71. package/dist/server/index.cjs +4 -4
  72. package/dist/server/index.d.cts +6 -6
  73. package/dist/server/index.d.mts +6 -6
  74. package/dist/server/index.mjs +4 -4
  75. package/dist/server/linkedin-conversions-api.d.cts +1 -1
  76. package/dist/server/linkedin-conversions-api.d.mts +1 -1
  77. package/dist/server/meta-capi.cjs +1 -1
  78. package/dist/server/meta-capi.d.cts +1 -1
  79. package/dist/server/meta-capi.d.mts +1 -1
  80. package/dist/server/meta-capi.mjs +1 -1
  81. package/dist/server/microsoft-conversions-api.cjs +3 -3
  82. package/dist/server/microsoft-conversions-api.d.cts +1 -1
  83. package/dist/server/microsoft-conversions-api.d.mts +1 -1
  84. package/dist/server/microsoft-conversions-api.mjs +3 -3
  85. package/dist/server/openai-conversions-api.cjs +2 -2
  86. package/dist/server/openai-conversions-api.d.cts +2 -2
  87. package/dist/server/openai-conversions-api.d.mts +2 -2
  88. package/dist/server/openai-conversions-api.mjs +2 -2
  89. package/dist/server/reddit-conversions-api.cjs +3 -3
  90. package/dist/server/reddit-conversions-api.d.cts +2 -2
  91. package/dist/server/reddit-conversions-api.d.mts +2 -2
  92. package/dist/server/reddit-conversions-api.mjs +3 -3
  93. package/dist/setup/index.d.cts +1 -1
  94. package/dist/setup/index.d.mts +1 -1
  95. package/dist/setup/session.cjs +1 -1
  96. package/dist/setup/session.cjs.map +1 -1
  97. package/dist/setup/session.mjs +1 -1
  98. package/dist/test/setup.cjs +1 -1
  99. package/dist/test/setup.cjs.map +1 -1
  100. package/dist/test/setup.mjs +1 -1
  101. package/dist/test/setup.mjs.map +1 -1
  102. package/dist/third-parties/google-analytics.d.cts +1 -1
  103. package/dist/third-parties/google-analytics.d.mts +1 -1
  104. package/dist/third-parties/index.cjs +3 -3
  105. package/dist/third-parties/index.d.cts +5 -5
  106. package/dist/third-parties/index.d.mts +5 -5
  107. package/dist/third-parties/index.mjs +3 -3
  108. package/dist/third-parties/linkedin-insight-tag.d.cts +2 -2
  109. package/dist/third-parties/linkedin-insight-tag.d.mts +2 -2
  110. package/dist/third-parties/meta-pixel.cjs +1 -1
  111. package/dist/third-parties/meta-pixel.d.cts +2 -2
  112. package/dist/third-parties/meta-pixel.d.mts +2 -2
  113. package/dist/third-parties/meta-pixel.mjs +1 -1
  114. package/dist/third-parties/microsoft-uet.cjs +1 -1
  115. package/dist/third-parties/microsoft-uet.cjs.map +1 -1
  116. package/dist/third-parties/microsoft-uet.d.cts +2 -2
  117. package/dist/third-parties/microsoft-uet.d.mts +2 -2
  118. package/dist/third-parties/microsoft-uet.mjs +1 -1
  119. package/dist/third-parties/microsoft-uet.mjs.map +1 -1
  120. package/dist/third-parties/openai-pixel.cjs +1 -1
  121. package/dist/third-parties/openai-pixel.d.cts +2 -2
  122. package/dist/third-parties/openai-pixel.d.mts +2 -2
  123. package/dist/third-parties/openai-pixel.mjs +1 -1
  124. package/dist/third-parties/posthog.d.cts +1 -1
  125. package/dist/third-parties/posthog.d.mts +1 -1
  126. package/dist/third-parties/reddit-pixel.cjs +1 -1
  127. package/dist/third-parties/reddit-pixel.d.cts +2 -2
  128. package/dist/third-parties/reddit-pixel.d.mts +2 -2
  129. package/dist/third-parties/reddit-pixel.mjs +1 -1
  130. package/dist/track/index.cjs.map +1 -1
  131. package/dist/track/index.mjs.map +1 -1
  132. package/dist/track/once.cjs.map +1 -1
  133. package/dist/track/once.d.cts +1 -1
  134. package/dist/track/once.d.mts +1 -1
  135. package/dist/visitor/id.cjs +1 -1
  136. package/dist/visitor/id.cjs.map +1 -1
  137. package/dist/visitor/id.mjs +1 -1
  138. package/dist/visitor/index.cjs +2 -2
  139. package/dist/visitor/index.cjs.map +1 -1
  140. package/dist/visitor/index.mjs +2 -2
  141. package/dist/web/index.cjs +3 -5
  142. package/dist/web/index.cjs.map +1 -1
  143. package/dist/web/index.d.cts +1 -1
  144. package/dist/web/index.d.mts +1 -1
  145. package/dist/web/index.mjs +3 -5
  146. package/dist/web/index.mjs.map +1 -1
  147. package/package.json +11 -11
  148. package/dist/_virtual/_rolldown/runtime.mjs +0 -23
  149. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs +0 -1724
  150. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs.map +0 -1
  151. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs +0 -1721
  152. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-report-web-vitals.cjs","names":["useEffectEvent"],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n // Callers (e.g. `Analytics`) pass an inline callback and re-render on every\n // navigation, and the published build is not React Compiler output, so the\n // reference changes each render. web-vitals offers no way to unsubscribe, so\n // subscribe once per mount and always forward to the latest callback.\n const report = useEffectEvent((metric: Metric) => reportWebVitalsFn(metric));\n\n useEffect(() => {\n onCLS(report);\n onLCP(report);\n onINP(report);\n onFCP(report);\n onTTFB(report);\n }, []);\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmB,mBAA6C;CAK9E,MAAM,UAAA,GAASA,MAAAA,eAAAA,EAAgB,WAAmB,kBAAkB,MAAM,CAAC;CAE3E,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,OAAA,CAAO,MAAM;CACf,GAAG,CAAC,CAAC;AACP"}
1
+ {"version":3,"file":"use-report-web-vitals.cjs","names":["useEffectEvent","useEffect","onCLS","onLCP","onINP","onFCP","onTTFB"],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n // Callers (e.g. `Analytics`) pass an inline callback and re-render on every\n // navigation, and the published build is not React Compiler output, so the\n // reference changes each render. web-vitals offers no way to unsubscribe, so\n // subscribe once per mount and always forward to the latest callback.\n const report = useEffectEvent((metric: Metric) => reportWebVitalsFn(metric));\n\n useEffect(() => {\n onCLS(report);\n onLCP(report);\n onINP(report);\n onFCP(report);\n onTTFB(report);\n }, []);\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmB,mBAA6C;CAK9E,MAAM,UAAA,GAASA,MAAAA,eAAAA,EAAgB,WAAmB,kBAAkB,MAAM,CAAC;CAE3EC,CAAAA,GAAAA,MAAAA,UAAAA,OAAgB;EACdC,CAAAA,GAAAA,WAAAA,MAAAA,CAAM,MAAM;EACZC,CAAAA,GAAAA,WAAAA,MAAAA,CAAM,MAAM;EACZC,CAAAA,GAAAA,WAAAA,MAAAA,CAAM,MAAM;EACZC,CAAAA,GAAAA,WAAAA,MAAAA,CAAM,MAAM;EACZC,CAAAA,GAAAA,WAAAA,OAAAA,CAAO,MAAM;CACf,GAAG,CAAC,CAAC;AACP"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-track-impression.cjs","names":["useRef","useState","useEffectEvent"],"sources":["../../src/hooks/use-track-impression.ts"],"sourcesContent":["import { type RefCallback, useEffect, useEffectEvent, useRef, useState } from 'react';\nimport { track } from '../track/index';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nexport function useTrackImpression<T extends EventName = EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n): RefCallback<Element> {\n const fired = useRef(false);\n const [node, setNode] = useState<Element | null>(null);\n\n const onTrack = useEffectEvent(() => {\n if (fired.current) return;\n track(name, properties);\n fired.current = true;\n });\n\n useEffect(() => {\n if (!node) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry.isIntersecting) return;\n onTrack();\n observer.disconnect();\n },\n { threshold: 0.5 }\n );\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [node]);\n\n // A callback ref (contravariant in the element type) instead of a RefObject:\n // it attaches to any element without an R type parameter, so `name` stays the\n // only inference site and explicit type arguments are never needed. It also\n // observes elements that mount late, which the previous [ref.current] effect\n // dependency missed.\n return setNode;\n}\n"],"mappings":";;;;AAIA,SAAgB,mBACd,MACA,YACsB;CACtB,MAAM,SAAA,GAAQA,MAAAA,OAAAA,CAAO,KAAK;CAC1B,MAAM,CAAC,MAAM,YAAA,GAAWC,MAAAA,SAAAA,CAAyB,IAAI;CAErD,MAAM,WAAA,GAAUC,MAAAA,eAAAA,OAAqB;EACnC,IAAI,MAAM,SAAS;EACnB,oBAAA,MAAM,MAAM,UAAU;EACtB,MAAM,UAAU;CAClB,CAAC;CAED,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,MAAM;EAEX,MAAM,WAAW,IAAI,sBAClB,CAAC,WAAW;GACX,IAAI,CAAC,MAAM,gBAAgB;GAC3B,QAAQ;GACR,SAAS,WAAW;EACtB,GACA,EAAE,WAAW,GAAI,CACnB;EAEA,SAAS,QAAQ,IAAI;EACrB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,IAAI,CAAC;CAOT,OAAO;AACT"}
1
+ {"version":3,"file":"use-track-impression.cjs","names":["useRef","useState","useEffectEvent","track","useEffect"],"sources":["../../src/hooks/use-track-impression.ts"],"sourcesContent":["import { type RefCallback, useEffect, useEffectEvent, useRef, useState } from 'react';\nimport { track } from '../track/index';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nexport function useTrackImpression<T extends EventName = EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n): RefCallback<Element> {\n const fired = useRef(false);\n const [node, setNode] = useState<Element | null>(null);\n\n const onTrack = useEffectEvent(() => {\n if (fired.current) return;\n track(name, properties);\n fired.current = true;\n });\n\n useEffect(() => {\n if (!node) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry.isIntersecting) return;\n onTrack();\n observer.disconnect();\n },\n { threshold: 0.5 }\n );\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [node]);\n\n // A callback ref (contravariant in the element type) instead of a RefObject:\n // it attaches to any element without an R type parameter, so `name` stays the\n // only inference site and explicit type arguments are never needed. It also\n // observes elements that mount late, which the previous [ref.current] effect\n // dependency missed.\n return setNode;\n}\n"],"mappings":";;;;AAIA,SAAgB,mBACd,MACA,YACsB;CACtB,MAAM,SAAA,GAAQA,MAAAA,OAAAA,CAAO,KAAK;CAC1B,MAAM,CAAC,MAAM,YAAA,GAAWC,MAAAA,SAAAA,CAAyB,IAAI;CAErD,MAAM,WAAA,GAAUC,MAAAA,eAAAA,OAAqB;EACnC,IAAI,MAAM,SAAS;EACnBC,oBAAAA,MAAM,MAAM,UAAU;EACtB,MAAM,UAAU;CAClB,CAAC;CAEDC,CAAAA,GAAAA,MAAAA,UAAAA,OAAgB;EACd,IAAI,CAAC,MAAM;EAEX,MAAM,WAAW,IAAI,sBAClB,CAAC,WAAW;GACX,IAAI,CAAC,MAAM,gBAAgB;GAC3B,QAAQ;GACR,SAAS,WAAW;EACtB,GACA,EAAE,WAAW,GAAI,CACnB;EAEA,SAAS,QAAQ,IAAI;EACrB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,IAAI,CAAC;CAOT,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-uet-id-sync.cjs","names":["syncUETVisitor"],"sources":["../../src/hooks/use-uet-id-sync.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { configureUET, syncUETVisitor } from '../third-parties/microsoft-uet';\n\n/**\n * Microsoft Advertising ID Sync from the framework `Analytics` components: record the customer\n * id for `setUETUser` and sync the visitor once per mount — the first page view of the visit,\n * which is where Microsoft wants it. No-op without a customer id.\n */\nexport function useUETIdSync(customerId: string | number | undefined) {\n useEffect(() => {\n configureUET({ customerId });\n if (customerId !== undefined) void syncUETVisitor();\n }, [customerId]);\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,aAAa,YAAyC;CACpE,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,oCAAA,aAAa,EAAE,WAAW,CAAC;EAC3B,IAAI,eAAe,KAAA,GAAW,oCAAKA,eAAe;CACpD,GAAG,CAAC,UAAU,CAAC;AACjB"}
1
+ {"version":3,"file":"use-uet-id-sync.cjs","names":["useEffect","configureUET","syncUETVisitor"],"sources":["../../src/hooks/use-uet-id-sync.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { configureUET, syncUETVisitor } from '../third-parties/microsoft-uet';\n\n/**\n * Microsoft Advertising ID Sync from the framework `Analytics` components: record the customer\n * id for `setUETUser` and sync the visitor once per mount — the first page view of the visit,\n * which is where Microsoft wants it. No-op without a customer id.\n */\nexport function useUETIdSync(customerId: string | number | undefined) {\n useEffect(() => {\n configureUET({ customerId });\n if (customerId !== undefined) void syncUETVisitor();\n }, [customerId]);\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,aAAa,YAAyC;CACpEA,CAAAA,GAAAA,MAAAA,UAAAA,OAAgB;EACdC,oCAAAA,aAAa,EAAE,WAAW,CAAC;EAC3B,IAAI,eAAe,KAAA,GAAgBC,oCAAAA,eAAe;CACpD,GAAG,CAAC,UAAU,CAAC;AACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-uet-id-sync.mjs","names":[],"sources":["../../src/hooks/use-uet-id-sync.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { configureUET, syncUETVisitor } from '../third-parties/microsoft-uet';\n\n/**\n * Microsoft Advertising ID Sync from the framework `Analytics` components: record the customer\n * id for `setUETUser` and sync the visitor once per mount — the first page view of the visit,\n * which is where Microsoft wants it. No-op without a customer id.\n */\nexport function useUETIdSync(customerId: string | number | undefined) {\n useEffect(() => {\n configureUET({ customerId });\n if (customerId !== undefined) void syncUETVisitor();\n }, [customerId]);\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,aAAa,YAAyC;CACpE,gBAAgB;EACd,aAAa,EAAE,WAAW,CAAC;EAC3B,IAAI,eAAe,KAAA,GAAW,eAAoB;CACpD,GAAG,CAAC,UAAU,CAAC;AACjB"}
1
+ {"version":3,"file":"use-uet-id-sync.mjs","names":[],"sources":["../../src/hooks/use-uet-id-sync.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { configureUET, syncUETVisitor } from '../third-parties/microsoft-uet';\n\n/**\n * Microsoft Advertising ID Sync from the framework `Analytics` components: record the customer\n * id for `setUETUser` and sync the visitor once per mount — the first page view of the visit,\n * which is where Microsoft wants it. No-op without a customer id.\n */\nexport function useUETIdSync(customerId: string | number | undefined) {\n useEffect(() => {\n configureUET({ customerId });\n if (customerId !== undefined) void syncUETVisitor();\n }, [customerId]);\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,aAAa,YAAyC;CACpE,gBAAgB;EACd,aAAa,EAAE,WAAW,CAAC;EAC3B,IAAI,eAAe,KAAA,GAAgB,eAAe;CACpD,GAAG,CAAC,UAAU,CAAC;AACjB"}
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_setup_index = require("../setup/index.cjs");
3
2
  const require_constants_storage = require("../constants/storage.cjs");
3
+ const require_setup_index = require("../setup/index.cjs");
4
4
  const require_setup_session = require("../setup/session.cjs");
5
5
  const require_track_index = require("../track/index.cjs");
6
- const require_web_page_key = require("../web/page-key.cjs");
7
6
  const require_web_index = require("../web/index.cjs");
7
+ const require_web_page_key = require("../web/page-key.cjs");
8
8
  let _shware_utils = require("@shware/utils");
9
9
  let react = require("react");
10
10
  // src/hooks/use-web-analytics.ts
@@ -1 +1 @@
1
- {"version":3,"file":"use-web-analytics.cjs","names":["config","keys","getPageReferrer","getPageLocation","getSession","getPageKey","useRef","throttle"],"sources":["../../src/hooks/use-web-analytics.ts"],"sourcesContent":["import { throttle } from '@shware/utils';\nimport { useEffect, useRef } from 'react';\nimport { keys } from '../constants/storage';\nimport { config } from '../setup/index';\nimport { getSession } from '../setup/session';\nimport { sendBeacon, sendPendingEvents, track } from '../track/index';\nimport { getPageLocation, getPageReferrer } from '../web/index';\nimport { getPageKey } from '../web/page-key';\n\nfunction sendFirstVisit(pathname: string) {\n if (config.storage.getItem(keys.first_visit_time)) return;\n track('first_visit', {\n page_path: pathname,\n page_title: document.title,\n page_referrer: getPageReferrer(),\n page_location: getPageLocation(),\n });\n config.storage.setItem(keys.first_visit_time, new Date().toISOString());\n}\n\nfunction sendUserEngagement(trigger: 'pagehide' | 'visibilitychange') {\n const engagement_time_msec = getSession().flush();\n if (engagement_time_msec <= 0) return;\n sendBeacon('user_engagement', { engagement_time_msec, trigger });\n}\n\n/** Whether the event was actually sent — a zero-engagement crossing reports nothing. */\nfunction sendScroll(): boolean {\n const engagement_time_msec = getSession().flush();\n if (engagement_time_msec <= 0) return false;\n track('scroll', { engagement_time_msec });\n return true;\n}\n\nfunction getScrollPercent() {\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n const windowHeight = window.innerHeight;\n const docHeight = document.documentElement.scrollHeight;\n if (docHeight === 0) return 0;\n return ((scrollTop + windowHeight) * 100) / docHeight;\n}\n\n// The queue goes first: a new session's `session_start` is in it, ahead of the engagement that\n// reports for that session. On `hidden` as well as on `pagehide`, as GA4 does: a mobile browser\n// often discards a hidden page without firing `pagehide`.\nfunction onPageHide() {\n getSession().pagehide();\n sendPendingEvents();\n sendUserEngagement('pagehide');\n}\n\nfunction onVisibilityChange() {\n getSession().visibilitychange(document.visibilityState);\n if (document.visibilityState === 'hidden') {\n sendPendingEvents();\n sendUserEngagement('visibilitychange');\n }\n}\n\n/**\n * 1. send session_start event when the page is loaded\n * 2. send scroll event when the user scrolls more than 90% of the page\n * 3. send user_engagement event when the page is hidden or the user is not focused\n * 4. send page_view when the page changes — path or query, see `getPageKey`; `search` is the\n * router's query string (`?a=1`, or `''`), required so no caller forgets that the query is\n * part of what makes a page\n */\nexport function useWebAnalytics(pathname: string, search: string) {\n const page = getPageKey(pathname, search);\n const lastViewPath = useRef<string | undefined>(undefined);\n\n // reset state when the page changes and send scroll when the user navigates to a new page\n const hasSendScroll = useRef(false);\n useEffect(() => {\n hasSendScroll.current = false;\n }, [page]);\n\n useEffect(() => {\n // One lookup for the whole effect: `addEventListener` and its matching\n // `removeEventListener` have to be handed the very same function.\n const session = getSession();\n\n sendFirstVisit(pathname);\n\n const onScroll = throttle(() => {\n session.updateAccumulator();\n if (hasSendScroll.current) return;\n // only send scroll when the user has scrolled more than 90% of the page\n if (getScrollPercent() < 90) return;\n // A crossing with no engaged time (a restored scroll position in an unfocused window) must\n // not consume the page's one shot: the flag is set only once the event is actually sent.\n hasSendScroll.current = sendScroll();\n }, 500);\n\n const checkpointEvents = ['mousedown', 'keydown', 'touchstart'];\n const checkpoint = throttle(session.updateAccumulator, 1000);\n\n window.addEventListener('focus', session.focus);\n window.addEventListener('blur', session.blur);\n window.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('pageshow', session.pageshow);\n window.addEventListener('pagehide', onPageHide);\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n // save checkpoint\n checkpointEvents.forEach((e) => {\n window.addEventListener(e, checkpoint, { passive: true, capture: true });\n });\n\n return () => {\n window.removeEventListener('focus', session.focus);\n window.removeEventListener('blur', session.blur);\n window.removeEventListener('scroll', onScroll);\n window.removeEventListener('pageshow', session.pageshow);\n window.removeEventListener('pagehide', onPageHide);\n document.removeEventListener('visibilitychange', onVisibilityChange);\n checkpointEvents.forEach((e) => window.removeEventListener(e, checkpoint, { capture: true }));\n\n onScroll.cancel();\n checkpoint.cancel();\n };\n }, []);\n\n useEffect(() => {\n // `page_path` stays the path — the query is in `page_location` — and the previous page is\n // named by its path too, so a query-only change reports the same path as its predecessor.\n const prevPathname = lastViewPath.current;\n track('page_view', {\n page_path: pathname,\n page_title: document.title,\n page_referrer: getPageReferrer(),\n page_location: getPageLocation(),\n previous_page_path: prevPathname,\n engagement_time_msec: prevPathname === undefined ? undefined : getSession().flush(),\n });\n // Advance only after this view is queued; effect restoration also emits a new view.\n lastViewPath.current = pathname;\n }, [page]);\n}\n"],"mappings":";;;;;;;;;;AASA,SAAS,eAAe,UAAkB;CACxC,IAAIA,oBAAAA,OAAO,QAAQ,QAAQC,0BAAAA,KAAK,gBAAgB,GAAG;CACnD,oBAAA,MAAM,eAAe;EACnB,WAAW;EACX,YAAY,SAAS;EACrB,eAAeC,kBAAAA,gBAAgB;EAC/B,eAAeC,kBAAAA,gBAAgB;CACjC,CAAC;CACD,oBAAA,OAAO,QAAQ,QAAQF,0BAAAA,KAAK,mCAAkB,IAAI,KAAK,EAAA,CAAE,YAAY,CAAC;AACxE;AAEA,SAAS,mBAAmB,SAA0C;CACpE,MAAM,uBAAuBG,sBAAAA,WAAW,CAAC,CAAC,MAAM;CAChD,IAAI,wBAAwB,GAAG;CAC/B,oBAAA,WAAW,mBAAmB;EAAE;EAAsB;CAAQ,CAAC;AACjE;;AAGA,SAAS,aAAsB;CAC7B,MAAM,uBAAuBA,sBAAAA,WAAW,CAAC,CAAC,MAAM;CAChD,IAAI,wBAAwB,GAAG,OAAO;CACtC,oBAAA,MAAM,UAAU,EAAE,qBAAqB,CAAC;CACxC,OAAO;AACT;AAEA,SAAS,mBAAmB;CAC1B,MAAM,YAAY,OAAO,WAAW,SAAS,gBAAgB;CAC7D,MAAM,eAAe,OAAO;CAC5B,MAAM,YAAY,SAAS,gBAAgB;CAC3C,IAAI,cAAc,GAAG,OAAO;CAC5B,QAAS,YAAY,gBAAgB,MAAO;AAC9C;AAKA,SAAS,aAAa;CACpB,sBAAA,WAAW,CAAC,CAAC,SAAS;CACtB,oBAAA,kBAAkB;CAClB,mBAAmB,UAAU;AAC/B;AAEA,SAAS,qBAAqB;CAC5B,sBAAA,WAAW,CAAC,CAAC,iBAAiB,SAAS,eAAe;CACtD,IAAI,SAAS,oBAAoB,UAAU;EACzC,oBAAA,kBAAkB;EAClB,mBAAmB,kBAAkB;CACvC;AACF;;;;;;;;;AAUA,SAA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oBAAoB,kBAAkB;GACnE,iBAAiB,SAAS,MAAM,OAAO,oBAAoB,GAAG,YAAY,EAAE,SAAS,KAAK,CAAC,CAAC;GAE5F,SAAS,OAAO;GAChB,WAAW,OAAO;EACpB;CACF,GAAG,CAAC,CAAC;CAEL,CAAA,GAAA,MAAA,UAAA,OAAgB;EAGd,MAAM,eAAe,aAAa;EAClC,oBAAA,MAAM,aAAa;GACjB,WAAW;GACX,YAAY,SAAS;GACrB,eAAeL,kBAAAA,gBAAgB;GAC/B,eAAeC,kBAAAA,gBAAgB;GAC/B,oBAAoB;GACpB,sBAAsB,iBAAiB,KAAA,IAAY,KAAA,IAAYC,sBAAAA,WAAW,CAAC,CAAC,MAAM;EACpF,CAAC;EAED,aAAa,UAAU;CACzB,GAAG,CAAC,IAAI,CAAC;AACX"}
1
+ {"version":3,"file":"use-web-analytics.cjs","names":["config","keys","track","getPageReferrer","getPageLocation","getSession","sendBeacon","sendPendingEvents","getPageKey","useRef","useEffect","throttle"],"sources":["../../src/hooks/use-web-analytics.ts"],"sourcesContent":["import { throttle } from '@shware/utils';\nimport { useEffect, useRef } from 'react';\nimport { keys } from '../constants/storage';\nimport { config } from '../setup/index';\nimport { getSession } from '../setup/session';\nimport { sendBeacon, sendPendingEvents, track } from '../track/index';\nimport { getPageLocation, getPageReferrer } from '../web/index';\nimport { getPageKey } from '../web/page-key';\n\nfunction sendFirstVisit(pathname: string) {\n if (config.storage.getItem(keys.first_visit_time)) return;\n track('first_visit', {\n page_path: pathname,\n page_title: document.title,\n page_referrer: getPageReferrer(),\n page_location: getPageLocation(),\n });\n config.storage.setItem(keys.first_visit_time, new Date().toISOString());\n}\n\nfunction sendUserEngagement(trigger: 'pagehide' | 'visibilitychange') {\n const engagement_time_msec = getSession().flush();\n if (engagement_time_msec <= 0) return;\n sendBeacon('user_engagement', { engagement_time_msec, trigger });\n}\n\n/** Whether the event was actually sent — a zero-engagement crossing reports nothing. */\nfunction sendScroll(): boolean {\n const engagement_time_msec = getSession().flush();\n if (engagement_time_msec <= 0) return false;\n track('scroll', { engagement_time_msec });\n return true;\n}\n\nfunction getScrollPercent() {\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n const windowHeight = window.innerHeight;\n const docHeight = document.documentElement.scrollHeight;\n if (docHeight === 0) return 0;\n return ((scrollTop + windowHeight) * 100) / docHeight;\n}\n\n// The queue goes first: a new session's `session_start` is in it, ahead of the engagement that\n// reports for that session. On `hidden` as well as on `pagehide`, as GA4 does: a mobile browser\n// often discards a hidden page without firing `pagehide`.\nfunction onPageHide() {\n getSession().pagehide();\n sendPendingEvents();\n sendUserEngagement('pagehide');\n}\n\nfunction onVisibilityChange() {\n getSession().visibilitychange(document.visibilityState);\n if (document.visibilityState === 'hidden') {\n sendPendingEvents();\n sendUserEngagement('visibilitychange');\n }\n}\n\n/**\n * 1. send session_start event when the page is loaded\n * 2. send scroll event when the user scrolls more than 90% of the page\n * 3. send user_engagement event when the page is hidden or the user is not focused\n * 4. send page_view when the page changes — path or query, see `getPageKey`; `search` is the\n * router's query string (`?a=1`, or `''`), required so no caller forgets that the query is\n * part of what makes a page\n */\nexport function useWebAnalytics(pathname: string, search: string) {\n const page = getPageKey(pathname, search);\n const lastViewPath = useRef<string | undefined>(undefined);\n\n // reset state when the page changes and send scroll when the user navigates to a new page\n const hasSendScroll = useRef(false);\n useEffect(() => {\n hasSendScroll.current = false;\n }, [page]);\n\n useEffect(() => {\n // One lookup for the whole effect: `addEventListener` and its matching\n // `removeEventListener` have to be handed the very same function.\n const session = getSession();\n\n sendFirstVisit(pathname);\n\n const onScroll = throttle(() => {\n session.updateAccumulator();\n if (hasSendScroll.current) return;\n // only send scroll when the user has scrolled more than 90% of the page\n if (getScrollPercent() < 90) return;\n // A crossing with no engaged time (a restored scroll position in an unfocused window) must\n // not consume the page's one shot: the flag is set only once the event is actually sent.\n hasSendScroll.current = sendScroll();\n }, 500);\n\n const checkpointEvents = ['mousedown', 'keydown', 'touchstart'];\n const checkpoint = throttle(session.updateAccumulator, 1000);\n\n window.addEventListener('focus', session.focus);\n window.addEventListener('blur', session.blur);\n window.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('pageshow', session.pageshow);\n window.addEventListener('pagehide', onPageHide);\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n // save checkpoint\n checkpointEvents.forEach((e) => {\n window.addEventListener(e, checkpoint, { passive: true, capture: true });\n });\n\n return () => {\n window.removeEventListener('focus', session.focus);\n window.removeEventListener('blur', session.blur);\n window.removeEventListener('scroll', onScroll);\n window.removeEventListener('pageshow', session.pageshow);\n window.removeEventListener('pagehide', onPageHide);\n document.removeEventListener('visibilitychange', onVisibilityChange);\n checkpointEvents.forEach((e) => window.removeEventListener(e, checkpoint, { capture: true }));\n\n onScroll.cancel();\n checkpoint.cancel();\n };\n }, []);\n\n useEffect(() => {\n // `page_path` stays the path — the query is in `page_location` — and the previous page is\n // named by its path too, so a query-only change reports the same path as its predecessor.\n const prevPathname = lastViewPath.current;\n track('page_view', {\n page_path: pathname,\n page_title: document.title,\n page_referrer: getPageReferrer(),\n page_location: getPageLocation(),\n previous_page_path: prevPathname,\n engagement_time_msec: prevPathname === undefined ? undefined : getSession().flush(),\n });\n // Advance only after this view is queued; effect restoration also emits a new view.\n lastViewPath.current = pathname;\n }, [page]);\n}\n"],"mappings":";;;;;;;;;;AASA,SAAS,eAAe,UAAkB;CACxC,IAAIA,oBAAAA,OAAO,QAAQ,QAAQC,0BAAAA,KAAK,gBAAgB,GAAG;CACnDC,oBAAAA,MAAM,eAAe;EACnB,WAAW;EACX,YAAY,SAAS;EACrB,eAAeC,kBAAAA,gBAAgB;EAC/B,eAAeC,kBAAAA,gBAAgB;CACjC,CAAC;CACDJ,oBAAAA,OAAO,QAAQ,QAAQC,0BAAAA,KAAK,mCAAkB,IAAI,KAAK,EAAA,CAAE,YAAY,CAAC;AACxE;AAEA,SAAS,mBAAmB,SAA0C;CACpE,MAAM,uBAAuBI,sBAAAA,WAAW,CAAC,CAAC,MAAM;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AAa,UAAU;CACzB,GAAG,CAAC,IAAI,CAAC;AACX"}
@@ -1,9 +1,9 @@
1
- import { config } from "../setup/index.mjs";
2
1
  import { keys } from "../constants/storage.mjs";
2
+ import { config } from "../setup/index.mjs";
3
3
  import { getSession } from "../setup/session.mjs";
4
4
  import { sendBeacon, sendPendingEvents, track } from "../track/index.mjs";
5
- import { getPageKey } from "../web/page-key.mjs";
6
5
  import { getPageLocation, getPageReferrer } from "../web/index.mjs";
6
+ import { getPageKey } from "../web/page-key.mjs";
7
7
  import { throttle } from "@shware/utils";
8
8
  import { useEffect, useRef } from "react";
9
9
  // src/hooks/use-web-analytics.ts
package/dist/index.d.cts CHANGED
@@ -1,14 +1,14 @@
1
- import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.cjs";
2
- import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.cjs";
3
- import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.cjs";
4
- import { sendFeedback } from "./feedback/index.cjs";
5
- import { useTrackImpression } from "./hooks/use-track-impression.cjs";
6
- import { VisitorProperties } from "./visitor/types.cjs";
7
1
  import { setupAnalytics } from "./setup/index.cjs";
8
2
  import { sendBeacon, sendPendingEvents, track } from "./track/index.cjs";
9
3
  import { TrackOnceOptions, trackOnce } from "./track/once.cjs";
10
- import { visitorId } from "./visitor/id.cjs";
11
4
  import { IDENTIFY_EVENT, identify, reset } from "./visitor/index.cjs";
5
+ import { sendFeedback } from "./feedback/index.cjs";
12
6
  import { Link, createLink, getLink } from "./link/index.cjs";
7
+ import { visitorId } from "./visitor/id.cjs";
8
+ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.cjs";
9
+ import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.cjs";
13
10
  import { stripeMinorUnits } from "./utils/stripe.cjs";
11
+ import { useTrackImpression } from "./hooks/use-track-impression.cjs";
12
+ import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.cjs";
13
+ import { VisitorProperties } from "./visitor/types.cjs";
14
14
  export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, type AnalyticsOptions, BOT_CATEGORIES, type Bot, type BotCategory, type CreateFeedbackDTO, type CreateLinkDTO, type CreateTrackEventDTO, type CreateVisitorDTO, type CustomEventProperties, type Environment, IDENTIFY_EVENT, type Link, NOT_A_BOT, type Platform, type TrackOnceOptions, type TrackProperties, type TrackTags, type UTMParams, type UpdateVisitorDTO, type UserProvidedData, type VisitorProperties, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, identify, reset, sendBeacon, sendFeedback, sendPendingEvents, setupAnalytics, stripeMinorUnits, track, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,14 @@
1
- import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.mjs";
2
- import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.mjs";
3
- import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.mjs";
4
- import { sendFeedback } from "./feedback/index.mjs";
5
- import { useTrackImpression } from "./hooks/use-track-impression.mjs";
6
- import { VisitorProperties } from "./visitor/types.mjs";
7
1
  import { setupAnalytics } from "./setup/index.mjs";
8
2
  import { sendBeacon, sendPendingEvents, track } from "./track/index.mjs";
9
3
  import { TrackOnceOptions, trackOnce } from "./track/once.mjs";
10
- import { visitorId } from "./visitor/id.mjs";
11
4
  import { IDENTIFY_EVENT, identify, reset } from "./visitor/index.mjs";
5
+ import { sendFeedback } from "./feedback/index.mjs";
12
6
  import { Link, createLink, getLink } from "./link/index.mjs";
7
+ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.mjs";
8
+ import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.mjs";
13
9
  import { stripeMinorUnits } from "./utils/stripe.mjs";
10
+ import { visitorId } from "./visitor/id.mjs";
11
+ import { useTrackImpression } from "./hooks/use-track-impression.mjs";
12
+ import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.mjs";
13
+ import { VisitorProperties } from "./visitor/types.mjs";
14
14
  export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, type AnalyticsOptions, BOT_CATEGORIES, type Bot, type BotCategory, type CreateFeedbackDTO, type CreateLinkDTO, type CreateTrackEventDTO, type CreateVisitorDTO, type CustomEventProperties, type Environment, IDENTIFY_EVENT, type Link, NOT_A_BOT, type Platform, type TrackOnceOptions, type TrackProperties, type TrackTags, type UTMParams, type UpdateVisitorDTO, type UserProvidedData, type VisitorProperties, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, identify, reset, sendBeacon, sendFeedback, sendPendingEvents, setupAnalytics, stripeMinorUnits, track, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fetch","config"],"sources":["../../src/link/index.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport type { CreateLinkDTO } from '../schema/index';\nimport { config } from '../setup/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\n/**\n * The link a `?s=` id names. `null` when the server says there is none (a 4xx: a mistyped or\n * expired id, or a `?s=` that was never a link id): that answer will not change while the page is\n * open, so callers cache it. A 5xx or a network failure, once the retrying `fetch` gives up, is\n * thrown instead — the link may well exist, so a caller should look it up again later rather than\n * remember \"no link\".\n */\nexport async function getLink(id: string): Promise<Link | null> {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n if (response.ok) return (await response.json()) as Link;\n const detail = `${response.status} ${await response.text()}`;\n if (response.status >= 400 && response.status < 500) {\n console.error(`No link(${id}): ${detail}`);\n return null;\n }\n throw new Error(`Failed to get link(${id}): ${detail}`);\n}\n"],"mappings":";;;;AASA,eAAsB,WAAW,KAAoB;CACnD,MAAM,WAAW,OAAA,GAAMA,cAAAA,MAAAA,CAAM,GAAGC,oBAAAA,OAAO,SAAS,SAAS;EACvD,QAAQ;EACR,aAAa;EACb,SAAS,MAAMA,oBAAAA,OAAO,WAAW;EACjC,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK,GAAG;CAEtF,OAAO,SAAS,KAAK;AACvB;;;;;;;;AASA,eAAsB,QAAQ,IAAkC;CAC9D,MAAM,WAAW,OAAA,GAAMD,cAAAA,MAAAA,CAAM,GAAGC,oBAAAA,OAAO,SAAS,SAAS,MAAM;EAC7D,QAAQ;EACR,aAAa;EACb,SAAS,MAAMA,oBAAAA,OAAO,WAAW;CACnC,CAAC;CACD,IAAI,SAAS,IAAI,OAAQ,MAAM,SAAS,KAAK;CAC7C,MAAM,SAAS,GAAG,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK;CACzD,IAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAAK;EACnD,QAAQ,MAAM,WAAW,GAAG,KAAK,QAAQ;EACzC,OAAO;CACT;CACA,MAAM,IAAI,MAAM,sBAAsB,GAAG,KAAK,QAAQ;AACxD"}
1
+ {"version":3,"file":"index.cjs","names":["fetch","config"],"sources":["../../src/link/index.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport type { CreateLinkDTO } from '../schema/index';\nimport { config } from '../setup/index';\n\n/** A stored link as the server answers it: a tag the link was created without comes back `null`. */\nexport interface Link {\n id: string;\n created_at: string;\n url: string;\n utm_source: string;\n utm_medium: string;\n utm_campaign: string;\n utm_id?: string | null;\n utm_term?: string | null;\n utm_content?: string | null;\n utm_source_platform?: string | null;\n utm_creative_format?: string | null;\n utm_marketing_tactic?: string | null;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\n/**\n * The link a `?s=` id names. `null` when the server says there is none (a 4xx: a mistyped or\n * expired id, or a `?s=` that was never a link id): that answer will not change while the page is\n * open, so callers cache it. A 5xx or a network failure, once the retrying `fetch` gives up, is\n * thrown instead — the link may well exist, so a caller should look it up again later rather than\n * remember \"no link\".\n */\nexport async function getLink(id: string): Promise<Link | null> {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n if (response.ok) return (await response.json()) as Link;\n const detail = `${response.status} ${await response.text()}`;\n if (response.status >= 400 && response.status < 500) {\n console.error(`No link(${id}): ${detail}`);\n return null;\n }\n throw new Error(`Failed to get link(${id}): ${detail}`);\n}\n"],"mappings":";;;;AAoBA,eAAsB,WAAW,KAAoB;CACnD,MAAM,WAAW,OAAA,GAAMA,cAAAA,MAAAA,CAAM,GAAGC,oBAAAA,OAAO,SAAS,SAAS;EACvD,QAAQ;EACR,aAAa;EACb,SAAS,MAAMA,oBAAAA,OAAO,WAAW;EACjC,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK,GAAG;CAEtF,OAAO,SAAS,KAAK;AACvB;;;;;;;;AASA,eAAsB,QAAQ,IAAkC;CAC9D,MAAM,WAAW,OAAA,GAAMD,cAAAA,MAAAA,CAAM,GAAGC,oBAAAA,OAAO,SAAS,SAAS,MAAM;EAC7D,QAAQ;EACR,aAAa;EACb,SAAS,MAAMA,oBAAAA,OAAO,WAAW;CACnC,CAAC;CACD,IAAI,SAAS,IAAI,OAAQ,MAAM,SAAS,KAAK;CAC7C,MAAM,SAAS,GAAG,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK;CACzD,IAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAAK;EACnD,QAAQ,MAAM,WAAW,GAAG,KAAK,QAAQ;EACzC,OAAO;CACT;CACA,MAAM,IAAI,MAAM,sBAAsB,GAAG,KAAK,QAAQ;AACxD"}
@@ -1,7 +1,18 @@
1
1
  import { CreateLinkDTO } from "../schema/index.cjs";
2
- export interface Link extends CreateLinkDTO {
2
+ /** A stored link as the server answers it: a tag the link was created without comes back `null`. */
3
+ export interface Link {
3
4
  id: string;
4
5
  created_at: string;
6
+ url: string;
7
+ utm_source: string;
8
+ utm_medium: string;
9
+ utm_campaign: string;
10
+ utm_id?: string | null;
11
+ utm_term?: string | null;
12
+ utm_content?: string | null;
13
+ utm_source_platform?: string | null;
14
+ utm_creative_format?: string | null;
15
+ utm_marketing_tactic?: string | null;
5
16
  }
6
17
  export declare function createLink(dto: CreateLinkDTO): Promise<Link>;
7
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/link/index.ts"],"mappings":";iBAIiB,aAAa;EAC5B;EACA;;wBAGoB,WAAW,KAAK,gBAAa,QAAA;;;;;;;;wBAqB7B,QAAQ,aAAa,QAAQ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/link/index.ts"],"mappings":";;iBAKiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,WAAW,KAAK,gBAAa,QAAA;;;;;;;;wBAqB7B,QAAQ,aAAa,QAAQ"}
@@ -1,7 +1,18 @@
1
1
  import { CreateLinkDTO } from "../schema/index.mjs";
2
- export interface Link extends CreateLinkDTO {
2
+ /** A stored link as the server answers it: a tag the link was created without comes back `null`. */
3
+ export interface Link {
3
4
  id: string;
4
5
  created_at: string;
6
+ url: string;
7
+ utm_source: string;
8
+ utm_medium: string;
9
+ utm_campaign: string;
10
+ utm_id?: string | null;
11
+ utm_term?: string | null;
12
+ utm_content?: string | null;
13
+ utm_source_platform?: string | null;
14
+ utm_creative_format?: string | null;
15
+ utm_marketing_tactic?: string | null;
5
16
  }
6
17
  export declare function createLink(dto: CreateLinkDTO): Promise<Link>;
7
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/link/index.ts"],"mappings":";iBAIiB,aAAa;EAC5B;EACA;;wBAGoB,WAAW,KAAK,gBAAa,QAAA;;;;;;;;wBAqB7B,QAAQ,aAAa,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/link/index.ts"],"mappings":";;iBAKiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGoB,WAAW,KAAK,gBAAa,QAAA;;;;;;;;wBAqB7B,QAAQ,aAAa,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/link/index.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport type { CreateLinkDTO } from '../schema/index';\nimport { config } from '../setup/index';\n\nexport interface Link extends CreateLinkDTO {\n id: string;\n created_at: string;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\n/**\n * The link a `?s=` id names. `null` when the server says there is none (a 4xx: a mistyped or\n * expired id, or a `?s=` that was never a link id): that answer will not change while the page is\n * open, so callers cache it. A 5xx or a network failure, once the retrying `fetch` gives up, is\n * thrown instead — the link may well exist, so a caller should look it up again later rather than\n * remember \"no link\".\n */\nexport async function getLink(id: string): Promise<Link | null> {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n if (response.ok) return (await response.json()) as Link;\n const detail = `${response.status} ${await response.text()}`;\n if (response.status >= 400 && response.status < 500) {\n console.error(`No link(${id}): ${detail}`);\n return null;\n }\n throw new Error(`Failed to get link(${id}): ${detail}`);\n}\n"],"mappings":";;;AASA,eAAsB,WAAW,KAAoB;CACnD,MAAM,WAAW,MAAM,MAAM,GAAG,OAAO,SAAS,SAAS;EACvD,QAAQ;EACR,aAAa;EACb,SAAS,MAAM,OAAO,WAAW;EACjC,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK,GAAG;CAEtF,OAAO,SAAS,KAAK;AACvB;;;;;;;;AASA,eAAsB,QAAQ,IAAkC;CAC9D,MAAM,WAAW,MAAM,MAAM,GAAG,OAAO,SAAS,SAAS,MAAM;EAC7D,QAAQ;EACR,aAAa;EACb,SAAS,MAAM,OAAO,WAAW;CACnC,CAAC;CACD,IAAI,SAAS,IAAI,OAAQ,MAAM,SAAS,KAAK;CAC7C,MAAM,SAAS,GAAG,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK;CACzD,IAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAAK;EACnD,QAAQ,MAAM,WAAW,GAAG,KAAK,QAAQ;EACzC,OAAO;CACT;CACA,MAAM,IAAI,MAAM,sBAAsB,GAAG,KAAK,QAAQ;AACxD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/link/index.ts"],"sourcesContent":["import { fetch } from '@shware/utils';\nimport type { CreateLinkDTO } from '../schema/index';\nimport { config } from '../setup/index';\n\n/** A stored link as the server answers it: a tag the link was created without comes back `null`. */\nexport interface Link {\n id: string;\n created_at: string;\n url: string;\n utm_source: string;\n utm_medium: string;\n utm_campaign: string;\n utm_id?: string | null;\n utm_term?: string | null;\n utm_content?: string | null;\n utm_source_platform?: string | null;\n utm_creative_format?: string | null;\n utm_marketing_tactic?: string | null;\n}\n\nexport async function createLink(dto: CreateLinkDTO) {\n const response = await fetch(`${config.endpoint}/links`, {\n method: 'POST',\n credentials: 'include',\n headers: await config.getHeaders(),\n body: JSON.stringify(dto),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create link: ${response.status} ${await response.text()}`);\n }\n return response.json() as Promise<Link>;\n}\n\n/**\n * The link a `?s=` id names. `null` when the server says there is none (a 4xx: a mistyped or\n * expired id, or a `?s=` that was never a link id): that answer will not change while the page is\n * open, so callers cache it. A 5xx or a network failure, once the retrying `fetch` gives up, is\n * thrown instead — the link may well exist, so a caller should look it up again later rather than\n * remember \"no link\".\n */\nexport async function getLink(id: string): Promise<Link | null> {\n const response = await fetch(`${config.endpoint}/links/${id}`, {\n method: 'GET',\n credentials: 'include',\n headers: await config.getHeaders(),\n });\n if (response.ok) return (await response.json()) as Link;\n const detail = `${response.status} ${await response.text()}`;\n if (response.status >= 400 && response.status < 500) {\n console.error(`No link(${id}): ${detail}`);\n return null;\n }\n throw new Error(`Failed to get link(${id}): ${detail}`);\n}\n"],"mappings":";;;AAoBA,eAAsB,WAAW,KAAoB;CACnD,MAAM,WAAW,MAAM,MAAM,GAAG,OAAO,SAAS,SAAS;EACvD,QAAQ;EACR,aAAa;EACb,SAAS,MAAM,OAAO,WAAW;EACjC,MAAM,KAAK,UAAU,GAAG;CAC1B,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK,GAAG;CAEtF,OAAO,SAAS,KAAK;AACvB;;;;;;;;AASA,eAAsB,QAAQ,IAAkC;CAC9D,MAAM,WAAW,MAAM,MAAM,GAAG,OAAO,SAAS,SAAS,MAAM;EAC7D,QAAQ;EACR,aAAa;EACb,SAAS,MAAM,OAAO,WAAW;CACnC,CAAC;CACD,IAAI,SAAS,IAAI,OAAQ,MAAM,SAAS,KAAK;CAC7C,MAAM,SAAS,GAAG,SAAS,OAAO,GAAG,MAAM,SAAS,KAAK;CACzD,IAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAAK;EACnD,QAAQ,MAAM,WAAW,GAAG,KAAK,QAAQ;EACzC,OAAO;CACT;CACA,MAAM,IAAI,MAAM,sBAAsB,GAAG,KAAK,QAAQ;AACxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"deep-link.cjs","names":["Linking","redactUrl"],"sources":["../../src/native/deep-link.ts"],"sourcesContent":["import { AppState, Linking } from 'react-native';\nimport type { DeepLink } from '../setup/index';\nimport type { TrackTags, UTMParams } from '../track/types';\nimport { redactUrl } from '../utils/redact-url';\n\n/**\n * The link that opened the app for this visit, the app's landing page: `getTags` merges its URL\n * (as `page_location`) and utm into every event's tags, so the session it starts is\n * classified as a web page's URL would be. A universal link or an app link from an email or an ad\n * opens the app rather than the site, and without this every one of those sessions was direct.\n *\n * The visit lasts from the open to the app going to the background, so every event in between\n * carries the link, as every event of a web page carries that page's query; the next open, with a\n * link or without, starts from nothing. Only the event that starts a session gets it classified:\n * a link tapped while the session is still running joins it, as GA4 keeps one session across a\n * change of campaign.\n *\n * Read from React Native's `Linking`: the URL that launched the process, and each one that brings\n * the running app to the front. Pass it to `setupAnalytics({ deepLink })`, which starts the\n * listening; nothing happens at import.\n */\nlet openUrl: string | undefined;\n\n/**\n * The parameters a deep link carries: the utm its sender tagged it with. An ad platform's click id\n * rides on the web landing page, not on a link into the app.\n */\nconst UTM_KEYS = [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_term',\n 'utm_content',\n 'utm_id',\n 'utm_source_platform',\n 'utm_creative_format',\n 'utm_marketing_tactic',\n] as const satisfies readonly (keyof UTMParams)[];\nlet initialUrlPromise: Promise<void> | undefined;\nlet listening = false;\n\n/** The URL that launched the process, read once; a link that arrived since has the last word. */\nfunction resolveInitialUrl(): Promise<void> {\n initialUrlPromise ??= Linking.getInitialURL().then(\n (url) => {\n if (url && openUrl === undefined) openUrl = url;\n },\n () => undefined\n );\n return initialUrlPromise;\n}\n\nexport const deepLink: DeepLink & {\n /** The link this visit opened with, for an entry `Linking` does not see, such as a push notification. */\n open: (url: string | null | undefined) => void;\n} = {\n listen() {\n if (listening) return;\n listening = true;\n Linking.addEventListener('url', ({ url }) => deepLink.open(url));\n // `background`, not `inactive`: iOS goes inactive for a system sheet or the control center,\n // with the visit still on.\n AppState.addEventListener('change', (state) => {\n if (state === 'background') openUrl = undefined;\n });\n },\n /** Waits for the launch URL, so the first event of a launch has it. */\n async getTags(): Promise<TrackTags> {\n await resolveInitialUrl();\n if (!openUrl) return {};\n const at = openUrl.indexOf('?');\n const params = new URLSearchParams(at === -1 ? '' : openUrl.slice(at + 1).split('#')[0]);\n const tags: TrackTags = { page_location: redactUrl(openUrl) };\n for (const key of UTM_KEYS) {\n const value = params.get(key);\n if (value !== null) tags[key] = value;\n }\n return tags;\n },\n open(url) {\n openUrl = url || undefined;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,IAAI;;;;;AAMJ,MAAM,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,IAAI;AACJ,IAAI,YAAY;;AAGhB,SAAS,oBAAmC;CAC1C,sBAAsBA,aAAAA,QAAQ,cAAc,CAAC,CAAC,MAC3C,QAAQ;EACP,IAAI,OAAO,YAAY,KAAA,GAAW,UAAU;CAC9C,SACM,KAAA,CACR;CACA,OAAO;AACT;AAEA,MAAa,WAGT;CACF,SAAS;EACP,IAAI,WAAW;EACf,YAAY;EACZ,aAAA,QAAQ,iBAAiB,QAAQ,EAAE,UAAU,SAAS,KAAK,GAAG,CAAC;EAG/D,aAAA,SAAS,iBAAiB,WAAW,UAAU;GAC7C,IAAI,UAAU,cAAc,UAAU,KAAA;EACxC,CAAC;CACH;;CAEA,MAAM,UAA8B;EAClC,MAAM,kBAAkB;EACxB,IAAI,CAAC,SAAS,OAAO,CAAC;EACtB,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,MAAM,SAAS,IAAI,gBAAgB,OAAO,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;EACvF,MAAM,OAAkB,EAAE,eAAeC,yBAAAA,UAAU,OAAO,EAAE;EAC5D,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,QAAQ,OAAO,IAAI,GAAG;GAC5B,IAAI,UAAU,MAAM,KAAK,OAAO;EAClC;EACA,OAAO;CACT;CACA,KAAK,KAAK;EACR,UAAU,OAAO,KAAA;CACnB;AACF"}
1
+ {"version":3,"file":"deep-link.cjs","names":["Linking","AppState","redactUrl"],"sources":["../../src/native/deep-link.ts"],"sourcesContent":["import { AppState, Linking } from 'react-native';\nimport type { DeepLink } from '../setup/index';\nimport type { TrackTags, UTMParams } from '../track/types';\nimport { redactUrl } from '../utils/redact-url';\n\n/**\n * The link that opened the app for this visit, the app's landing page: `getTags` merges its URL\n * (as `page_location`) and utm into every event's tags, so the session it starts is\n * classified as a web page's URL would be. A universal link or an app link from an email or an ad\n * opens the app rather than the site, and without this every one of those sessions was direct.\n *\n * The visit lasts from the open to the app going to the background, so every event in between\n * carries the link, as every event of a web page carries that page's query; the next open, with a\n * link or without, starts from nothing. Only the event that starts a session gets it classified:\n * a link tapped while the session is still running joins it, as GA4 keeps one session across a\n * change of campaign.\n *\n * Read from React Native's `Linking`: the URL that launched the process, and each one that brings\n * the running app to the front. Pass it to `setupAnalytics({ deepLink })`, which starts the\n * listening; nothing happens at import.\n */\nlet openUrl: string | undefined;\n\n/**\n * The parameters a deep link carries: the utm its sender tagged it with. An ad platform's click id\n * rides on the web landing page, not on a link into the app.\n */\nconst UTM_KEYS = [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_term',\n 'utm_content',\n 'utm_id',\n 'utm_source_platform',\n 'utm_creative_format',\n 'utm_marketing_tactic',\n] as const satisfies readonly (keyof UTMParams)[];\nlet initialUrlPromise: Promise<void> | undefined;\nlet listening = false;\n\n/** The URL that launched the process, read once; a link that arrived since has the last word. */\nfunction resolveInitialUrl(): Promise<void> {\n initialUrlPromise ??= Linking.getInitialURL().then(\n (url) => {\n if (url && openUrl === undefined) openUrl = url;\n },\n () => undefined\n );\n return initialUrlPromise;\n}\n\nexport const deepLink: DeepLink & {\n /** The link this visit opened with, for an entry `Linking` does not see, such as a push notification. */\n open: (url: string | null | undefined) => void;\n} = {\n listen() {\n if (listening) return;\n listening = true;\n Linking.addEventListener('url', ({ url }) => deepLink.open(url));\n // `background`, not `inactive`: iOS goes inactive for a system sheet or the control center,\n // with the visit still on.\n AppState.addEventListener('change', (state) => {\n if (state === 'background') openUrl = undefined;\n });\n },\n /** Waits for the launch URL, so the first event of a launch has it. */\n async getTags(): Promise<TrackTags> {\n await resolveInitialUrl();\n if (!openUrl) return {};\n const at = openUrl.indexOf('?');\n const params = new URLSearchParams(at === -1 ? '' : openUrl.slice(at + 1).split('#')[0]);\n const tags: TrackTags = { page_location: redactUrl(openUrl) };\n for (const key of UTM_KEYS) {\n const value = params.get(key);\n if (value !== null) tags[key] = value;\n }\n return tags;\n },\n open(url) {\n openUrl = url || undefined;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,IAAI;;;;;AAMJ,MAAM,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,IAAI;AACJ,IAAI,YAAY;;AAGhB,SAAS,oBAAmC;CAC1C,sBAAsBA,aAAAA,QAAQ,cAAc,CAAC,CAAC,MAC3C,QAAQ;EACP,IAAI,OAAO,YAAY,KAAA,GAAW,UAAU;CAC9C,SACM,KAAA,CACR;CACA,OAAO;AACT;AAEA,MAAa,WAGT;CACF,SAAS;EACP,IAAI,WAAW;EACf,YAAY;EACZA,aAAAA,QAAQ,iBAAiB,QAAQ,EAAE,UAAU,SAAS,KAAK,GAAG,CAAC;EAG/DC,aAAAA,SAAS,iBAAiB,WAAW,UAAU;GAC7C,IAAI,UAAU,cAAc,UAAU,KAAA;EACxC,CAAC;CACH;;CAEA,MAAM,UAA8B;EAClC,MAAM,kBAAkB;EACxB,IAAI,CAAC,SAAS,OAAO,CAAC;EACtB,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,MAAM,SAAS,IAAI,gBAAgB,OAAO,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;EACvF,MAAM,OAAkB,EAAE,eAAeC,yBAAAA,UAAU,OAAO,EAAE;EAC5D,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,QAAQ,OAAO,IAAI,GAAG;GAC5B,IAAI,UAAU,MAAM,KAAK,OAAO;EAClC;EACA,OAAO;CACT;CACA,KAAK,KAAK;EACR,UAAU,OAAO,KAAA;CACnB;AACF"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils_field = require("../utils/field.cjs");
3
2
  const require_third_parties_integration = require("../third-parties/integration.cjs");
4
3
  const require_track_fbq = require("../track/fbq.cjs");
4
+ const require_utils_field = require("../utils/field.cjs");
5
5
  let react_native_fbsdk_next = require("react-native-fbsdk-next");
6
6
  // src/native/fbsdk.ts
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fbsdk.cjs","names":["mapFBEvent","getFirst","adsTracker","adEvents","isStandardFBEvent"],"sources":["../../src/native/fbsdk.ts"],"sourcesContent":["import { AppEventsLogger, type Params } from 'react-native-fbsdk-next';\nimport type { UpdateVisitorDTO } from '../schema/index';\nimport {\n type AdsOptions,\n type Integration,\n adEvents,\n adsTracker,\n} from '../third-parties/integration';\nimport { isStandardFBEvent, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * ref: https://developers.facebook.com/docs/app-events/guides/maximize-in-app-ad-revenue/\n *\n * Synchronous, like `logEvent`: a tracker returns `void | boolean`, which an `async` function's\n * promise would not satisfy. Callers that still `await` it keep compiling.\n */\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n const [_, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n AppEventsLogger.logEvent(fbEventName, fbEventProperties as Params);\n}\n\n/**\n * Hands the signed-in user to Facebook App Events, as `setFBUser` does the Pixel: the user id\n * (`external_id`) and the advanced matching fields, which the SDK hashes on the device. No user is\n * sign-out (`reset()`): the user id is cleared, but the matching fields may not be.\n *\n * Known gap, kept on purpose: the fields go to the native `setUserData`, which on Android only\n * updates the fields it is given, so the empty ones sent at sign-out leave the previous user's\n * email and phone in place, and later anonymous events (or another user's without an email) can\n * still carry them. `react-native-fbsdk-next` does not expose the native `clearUserData`. Dropping\n * the fields would avoid it, but cost more in ad conversion matching than the gap does.\n */\nexport function setFBUser({ user_id, user_data }: Omit<UpdateVisitorDTO, 'tags'>) {\n AppEventsLogger.setUserID(user_id || null);\n const address = getFirst(user_data?.address);\n AppEventsLogger.setUserData({\n email: getFirst(user_data?.email),\n phone: getFirst(user_data?.phone_number),\n firstName: address?.first_name,\n lastName: address?.last_name,\n city: address?.city,\n state: address?.region,\n zip: address?.postal_code,\n country: address?.country,\n });\n}\n\n/**\n * Facebook App Events: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`\n * — the app's counterpart of `metaAds`.\n */\nexport function metaAppEvents(options: AdsOptions = {}): Integration {\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, adEvents(isStandardFBEvent, options.customEvents)),\n setUser: setFBUser,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,YACd,MACA,YACA;CACA,MAAM,CAAC,GAAG,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CACvE,wBAAA,gBAAgB,SAAS,aAAa,iBAA2B;AACnE;;;;;;;;;;;;AAaA,SAAgB,UAAU,EAAE,SAAS,aAA6C;CAChF,wBAAA,gBAAgB,UAAU,WAAW,IAAI;CACzC,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;CAC3C,wBAAA,gBAAgB,YAAY;EAC1B,OAAOA,oBAAAA,SAAS,WAAW,KAAK;EAChC,OAAOA,oBAAAA,SAAS,WAAW,YAAY;EACvC,WAAW,SAAS;EACpB,UAAU,SAAS;EACnB,MAAM,SAAS;EACf,OAAO,SAAS;EAChB,KAAK,SAAS;EACd,SAAS,SAAS;CACpB,CAAC;AACH;;;;;AAMA,SAAgB,cAAc,UAAsB,CAAC,GAAgB;CACnE,OAAO;EACL,MAAM;EACN,OAAOC,kCAAAA,WAAW,aAAaC,kCAAAA,SAASC,kBAAAA,mBAAmB,QAAQ,YAAY,CAAC;EAChF,SAAS;CACX;AACF"}
1
+ {"version":3,"file":"fbsdk.cjs","names":["mapFBEvent","AppEventsLogger","getFirst","adsTracker","adEvents","isStandardFBEvent"],"sources":["../../src/native/fbsdk.ts"],"sourcesContent":["import { AppEventsLogger, type Params } from 'react-native-fbsdk-next';\nimport type { UpdateVisitorDTO } from '../schema/index';\nimport {\n type AdsOptions,\n type Integration,\n adEvents,\n adsTracker,\n} from '../third-parties/integration';\nimport { isStandardFBEvent, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\n/**\n * ref: https://developers.facebook.com/docs/app-events/guides/maximize-in-app-ad-revenue/\n *\n * Synchronous, like `logEvent`: a tracker returns `void | boolean`, which an `async` function's\n * promise would not satisfy. Callers that still `await` it keep compiling.\n */\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n const [_, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n AppEventsLogger.logEvent(fbEventName, fbEventProperties as Params);\n}\n\n/**\n * Hands the signed-in user to Facebook App Events, as `setFBUser` does the Pixel: the user id\n * (`external_id`) and the advanced matching fields, which the SDK hashes on the device. No user is\n * sign-out (`reset()`): the user id is cleared, but the matching fields may not be.\n *\n * Known gap, kept on purpose: the fields go to the native `setUserData`, which on Android only\n * updates the fields it is given, so the empty ones sent at sign-out leave the previous user's\n * email and phone in place, and later anonymous events (or another user's without an email) can\n * still carry them. `react-native-fbsdk-next` does not expose the native `clearUserData`. Dropping\n * the fields would avoid it, but cost more in ad conversion matching than the gap does.\n */\nexport function setFBUser({ user_id, user_data }: Omit<UpdateVisitorDTO, 'tags'>) {\n AppEventsLogger.setUserID(user_id || null);\n const address = getFirst(user_data?.address);\n AppEventsLogger.setUserData({\n email: getFirst(user_data?.email),\n phone: getFirst(user_data?.phone_number),\n firstName: address?.first_name,\n lastName: address?.last_name,\n city: address?.city,\n state: address?.region,\n zip: address?.postal_code,\n country: address?.country,\n });\n}\n\n/**\n * Facebook App Events: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`\n * — the app's counterpart of `metaAds`.\n */\nexport function metaAppEvents(options: AdsOptions = {}): Integration {\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, adEvents(isStandardFBEvent, options.customEvents)),\n setUser: setFBUser,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,YACd,MACA,YACA;CACA,MAAM,CAAC,GAAG,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CACvEC,wBAAAA,gBAAgB,SAAS,aAAa,iBAA2B;AACnE;;;;;;;;;;;;AAaA,SAAgB,UAAU,EAAE,SAAS,aAA6C;CAChFA,wBAAAA,gBAAgB,UAAU,WAAW,IAAI;CACzC,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;CAC3CD,wBAAAA,gBAAgB,YAAY;EAC1B,OAAOC,oBAAAA,SAAS,WAAW,KAAK;EAChC,OAAOA,oBAAAA,SAAS,WAAW,YAAY;EACvC,WAAW,SAAS;EACpB,UAAU,SAAS;EACnB,MAAM,SAAS;EACf,OAAO,SAAS;EAChB,KAAK,SAAS;EACd,SAAS,SAAS;CACpB,CAAC;AACH;;;;;AAMA,SAAgB,cAAc,UAAsB,CAAC,GAAgB;CACnE,OAAO;EACL,MAAM;EACN,OAAOC,kCAAAA,WAAW,aAAaC,kCAAAA,SAASC,kBAAAA,mBAAmB,QAAQ,YAAY,CAAC;EAChF,SAAS;CACX;AACF"}
@@ -1,6 +1,6 @@
1
- import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
2
1
  import { UpdateVisitorDTO } from "../schema/index.cjs";
3
2
  import { AdsOptions, Integration } from "../third-parties/integration.cjs";
3
+ import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
4
4
  /**
5
5
  * ref: https://developers.facebook.com/docs/app-events/guides/maximize-in-app-ad-revenue/
6
6
  *
@@ -1,6 +1,6 @@
1
- import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
2
1
  import { UpdateVisitorDTO } from "../schema/index.mjs";
3
2
  import { AdsOptions, Integration } from "../third-parties/integration.mjs";
3
+ import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
4
4
  /**
5
5
  * ref: https://developers.facebook.com/docs/app-events/guides/maximize-in-app-ad-revenue/
6
6
  *
@@ -1,6 +1,6 @@
1
- import { getFirst } from "../utils/field.mjs";
2
1
  import { adEvents, adsTracker } from "../third-parties/integration.mjs";
3
2
  import { isStandardFBEvent, mapFBEvent } from "../track/fbq.mjs";
3
+ import { getFirst } from "../utils/field.mjs";
4
4
  import { AppEventsLogger } from "react-native-fbsdk-next";
5
5
  // src/native/fbsdk.ts
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.cjs","names":["getAnalytics","getFirst"],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import {\n getAnalytics,\n initiateOnDeviceConversionMeasurementWithEmailAddress,\n initiateOnDeviceConversionMeasurementWithPhoneNumber,\n logEvent,\n setUserId,\n} from '@react-native-firebase/analytics';\nimport type { UpdateVisitorDTO } from '../schema/index';\nimport type { Integration } from '../third-parties/integration';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\nconst analytics = getAnalytics();\n\n/**\n * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26\n * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`\n * (`false` meaning \"not ready\"), which an `async` function's promise would not satisfy. Callers\n * that still `await` it keep compiling.\n */\nexport function sendFirebaseEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (name === 'screen_view') {\n logEvent(analytics, 'screen_view', {\n firebase_screen: (properties as StandardEvents['screen_view'] | undefined)?.screen_name,\n firebase_screen_class: (properties as StandardEvents['screen_view'] | undefined)\n ?.screen_class,\n });\n } else {\n logEvent(analytics, name, properties);\n }\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) console.log(e.message);\n}\n\n/**\n * Sets Firebase's user id to the signed-in user, as `setGAUser` does GA's; no user is sign-out\n * (`reset()`), which clears it. The user properties stay free of PII, as Google requires: the\n * email and phone number go to on-device conversion measurement instead, which matches Google\n * Ads app campaign clicks on the device without them leaving it — iOS only, a no-op elsewhere.\n */\nexport function setFirebaseUser({ user_id, user_data }: Omit<UpdateVisitorDTO, 'tags'>) {\n setUserId(analytics, user_id || null).catch(logError);\n const email = getFirst(user_data?.email);\n if (email)\n initiateOnDeviceConversionMeasurementWithEmailAddress(analytics, email).catch(logError);\n const phone = getFirst(user_data?.phone_number);\n if (phone) initiateOnDeviceConversionMeasurementWithPhoneNumber(analytics, phone).catch(logError);\n}\n\n/** Firebase Analytics: every event, for behavior analysis — the app's counterpart of GA4. */\nexport function firebaseAnalytics(): Integration {\n return { type: 'analytics', track: sendFirebaseEvent, setUser: setFirebaseUser };\n}\n"],"mappings":";;;;AAaA,MAAM,aAAA,GAAYA,iCAAAA,aAAAA,CAAa;;;;;;;AAQ/B,SAAgB,kBACd,MACA,YACA;CACA,IAAI,SAAS,eACX,CAAA,GAAA,iCAAA,SAAA,CAAS,WAAW,eAAe;EACjC,iBAAkB,YAA0D;EAC5E,uBAAwB,YACpB;CACN,CAAC;MAED,CAAA,GAAA,iCAAA,SAAA,CAAS,WAAW,MAAM,UAAU;AAExC;AAEA,SAAS,SAAS,GAAY;CAC5B,IAAI,aAAa,OAAO,QAAQ,IAAI,EAAE,OAAO;AAC/C;;;;;;;AAQA,SAAgB,gBAAgB,EAAE,SAAS,aAA6C;CACtF,CAAA,GAAA,iCAAA,UAAA,CAAU,WAAW,WAAW,IAAI,CAAC,CAAC,MAAM,QAAQ;CACpD,MAAM,QAAQC,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,OACF,CAAA,GAAA,iCAAA,sDAAA,CAAsD,WAAW,KAAK,CAAC,CAAC,MAAM,QAAQ;CACxF,MAAM,QAAQA,oBAAAA,SAAS,WAAW,YAAY;CAC9C,IAAI,OAAO,CAAA,GAAA,iCAAA,qDAAA,CAAqD,WAAW,KAAK,CAAC,CAAC,MAAM,QAAQ;AAClG;;AAGA,SAAgB,oBAAiC;CAC/C,OAAO;EAAE,MAAM;EAAa,OAAO;EAAmB,SAAS;CAAgB;AACjF"}
1
+ {"version":3,"file":"firebase.cjs","names":["getAnalytics","logEvent","setUserId","getFirst","initiateOnDeviceConversionMeasurementWithEmailAddress","initiateOnDeviceConversionMeasurementWithPhoneNumber"],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import {\n getAnalytics,\n initiateOnDeviceConversionMeasurementWithEmailAddress,\n initiateOnDeviceConversionMeasurementWithPhoneNumber,\n logEvent,\n setUserId,\n} from '@react-native-firebase/analytics';\nimport type { UpdateVisitorDTO } from '../schema/index';\nimport type { Integration } from '../third-parties/integration';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\nconst analytics = getAnalytics();\n\n/**\n * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26\n * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`\n * (`false` meaning \"not ready\"), which an `async` function's promise would not satisfy. Callers\n * that still `await` it keep compiling.\n */\nexport function sendFirebaseEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (name === 'screen_view') {\n logEvent(analytics, 'screen_view', {\n firebase_screen: (properties as StandardEvents['screen_view'] | undefined)?.screen_name,\n firebase_screen_class: (properties as StandardEvents['screen_view'] | undefined)\n ?.screen_class,\n });\n } else {\n logEvent(analytics, name, properties);\n }\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) console.log(e.message);\n}\n\n/**\n * Sets Firebase's user id to the signed-in user, as `setGAUser` does GA's; no user is sign-out\n * (`reset()`), which clears it. The user properties stay free of PII, as Google requires: the\n * email and phone number go to on-device conversion measurement instead, which matches Google\n * Ads app campaign clicks on the device without them leaving it — iOS only, a no-op elsewhere.\n */\nexport function setFirebaseUser({ user_id, user_data }: Omit<UpdateVisitorDTO, 'tags'>) {\n setUserId(analytics, user_id || null).catch(logError);\n const email = getFirst(user_data?.email);\n if (email)\n initiateOnDeviceConversionMeasurementWithEmailAddress(analytics, email).catch(logError);\n const phone = getFirst(user_data?.phone_number);\n if (phone) initiateOnDeviceConversionMeasurementWithPhoneNumber(analytics, phone).catch(logError);\n}\n\n/** Firebase Analytics: every event, for behavior analysis — the app's counterpart of GA4. */\nexport function firebaseAnalytics(): Integration {\n return { type: 'analytics', track: sendFirebaseEvent, setUser: setFirebaseUser };\n}\n"],"mappings":";;;;AAaA,MAAM,aAAA,GAAYA,iCAAAA,aAAAA,CAAa;;;;;;;AAQ/B,SAAgB,kBACd,MACA,YACA;CACA,IAAI,SAAS,eACXC,CAAAA,GAAAA,iCAAAA,SAAAA,CAAS,WAAW,eAAe;EACjC,iBAAkB,YAA0D;EAC5E,uBAAwB,YACpB;CACN,CAAC;MAEDA,CAAAA,GAAAA,iCAAAA,SAAAA,CAAS,WAAW,MAAM,UAAU;AAExC;AAEA,SAAS,SAAS,GAAY;CAC5B,IAAI,aAAa,OAAO,QAAQ,IAAI,EAAE,OAAO;AAC/C;;;;;;;AAQA,SAAgB,gBAAgB,EAAE,SAAS,aAA6C;CACtFC,CAAAA,GAAAA,iCAAAA,UAAAA,CAAU,WAAW,WAAW,IAAI,CAAC,CAAC,MAAM,QAAQ;CACpD,MAAM,QAAQC,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,OACFC,CAAAA,GAAAA,iCAAAA,sDAAAA,CAAsD,WAAW,KAAK,CAAC,CAAC,MAAM,QAAQ;CACxF,MAAM,QAAQD,oBAAAA,SAAS,WAAW,YAAY;CAC9C,IAAI,OAAOE,CAAAA,GAAAA,iCAAAA,qDAAAA,CAAqD,WAAW,KAAK,CAAC,CAAC,MAAM,QAAQ;AAClG;;AAGA,SAAgB,oBAAiC;CAC/C,OAAO;EAAE,MAAM;EAAa,OAAO;EAAmB,SAAS;CAAgB;AACjF"}
@@ -1,6 +1,6 @@
1
- import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
2
1
  import { UpdateVisitorDTO } from "../schema/index.cjs";
3
2
  import { Integration } from "../third-parties/integration.cjs";
3
+ import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
4
4
  /**
5
5
  * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
6
6
  * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
@@ -1,6 +1,6 @@
1
- import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
2
1
  import { UpdateVisitorDTO } from "../schema/index.mjs";
3
2
  import { Integration } from "../third-parties/integration.mjs";
3
+ import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
4
4
  /**
5
5
  * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
6
6
  * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_hooks_use_app_analytics = require("../hooks/use-app-analytics.cjs");
2
+ const require_native_setup = require("./setup.cjs");
3
3
  const require_native_deep_link = require("./deep-link.cjs");
4
+ const require_hooks_use_app_analytics = require("../hooks/use-app-analytics.cjs");
4
5
  const require_native_fingerprint = require("./fingerprint.cjs");
5
- const require_native_setup = require("./setup.cjs");
6
6
  exports.deepLink = require_native_deep_link.deepLink;
7
7
  exports.getDeterministicFingerprint = require_native_fingerprint.getDeterministicFingerprint;
8
8
  exports.getDeviceId = require_native_setup.getDeviceId;
@@ -1,5 +1,5 @@
1
- import { useAppAnalytics } from "../hooks/use-app-analytics.cjs";
1
+ import { getDeviceId, getDeviceType, getTags, storage } from "./setup.cjs";
2
2
  import { deepLink } from "./deep-link.cjs";
3
+ import { useAppAnalytics } from "../hooks/use-app-analytics.cjs";
3
4
  import { DeterministicFingerprint, ProbabilisticFingerprint, getDeterministicFingerprint, getProbabilisticFingerprint } from "./fingerprint.cjs";
4
- import { getDeviceId, getDeviceType, getTags, storage } from "./setup.cjs";
5
5
  export { type DeterministicFingerprint, type ProbabilisticFingerprint, deepLink, getDeterministicFingerprint, getDeviceId, getDeviceType, getProbabilisticFingerprint, getTags, storage, useAppAnalytics };
@@ -1,5 +1,5 @@
1
- import { useAppAnalytics } from "../hooks/use-app-analytics.mjs";
1
+ import { getDeviceId, getDeviceType, getTags, storage } from "./setup.mjs";
2
2
  import { deepLink } from "./deep-link.mjs";
3
+ import { useAppAnalytics } from "../hooks/use-app-analytics.mjs";
3
4
  import { DeterministicFingerprint, ProbabilisticFingerprint, getDeterministicFingerprint, getProbabilisticFingerprint } from "./fingerprint.mjs";
4
- import { getDeviceId, getDeviceType, getTags, storage } from "./setup.mjs";
5
5
  export { type DeterministicFingerprint, type ProbabilisticFingerprint, deepLink, getDeterministicFingerprint, getDeviceId, getDeviceType, getProbabilisticFingerprint, getTags, storage, useAppAnalytics };
@@ -1,5 +1,5 @@
1
- import { useAppAnalytics } from "../hooks/use-app-analytics.mjs";
1
+ import { getDeviceId, getDeviceType, getTags, storage } from "./setup.mjs";
2
2
  import { deepLink } from "./deep-link.mjs";
3
+ import { useAppAnalytics } from "../hooks/use-app-analytics.mjs";
3
4
  import { getDeterministicFingerprint, getProbabilisticFingerprint } from "./fingerprint.mjs";
4
- import { getDeviceId, getDeviceType, getTags, storage } from "./setup.mjs";
5
5
  export { deepLink, getDeterministicFingerprint, getDeviceId, getDeviceType, getProbabilisticFingerprint, getTags, storage, useAppAnalytics };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_setup_index = require("../setup/index.cjs");
3
2
  const require_constants_storage = require("../constants/storage.cjs");
3
+ const require_setup_index = require("../setup/index.cjs");
4
4
  let react_native = require("react-native");
5
5
  let expo_application = require("expo-application");
6
6
  let expo_device = require("expo-device");
@@ -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.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,GAA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Y,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","cache"],"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,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,uBAAAA,CAAuB;MACnC,IAAIF,aAAAA,SAAS,OAAO,WACzB,YAAA,GAAWG,iBAAAA,aAAAA,CAAa;CAE1B,IAAI,CAAC,UAAU;EACb,WAAW,aAAa,QAAQ,WAAW;EAC3C,IAAI,CAAC,UAAU;GACb,YA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C;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;CAEAC,oBAAAA,MAAM,OAAO;CACb,OAAO;AACT"}
@@ -1,6 +1,5 @@
1
- import { TrackTags } from "../track/types.cjs";
2
1
  import { Storage } from "../setup/index.cjs";
3
- import "expo-sqlite/localStorage/install";
2
+ import { TrackTags } from "../track/types.cjs";
4
3
  export declare const storage: Storage;
5
4
  export declare function getDeviceId(): Promise<string>;
6
5
  export declare function getDeviceType(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.cts","names":[],"sources":["../../src/native/setup.ts"],"mappings":";;;qBAqBa,SAAS;wBA2BN,eAAe;wBAkCf;wBA0CM,WAAW,QAAQ"}
1
+ {"version":3,"file":"setup.d.cts","names":[],"sources":["../../src/native/setup.ts"],"mappings":";;qBAqBa,SAAS;wBA2BN,eAAe;wBAkCf;wBA0CM,WAAW,QAAQ"}
@@ -1,5 +1,5 @@
1
- import { TrackTags } from "../track/types.mjs";
2
1
  import { Storage } from "../setup/index.mjs";
2
+ import { TrackTags } from "../track/types.mjs";
3
3
  import "expo-sqlite/localStorage/install";
4
4
  export declare const storage: Storage;
5
5
  export declare function getDeviceId(): Promise<string>;
@@ -1,5 +1,5 @@
1
- import { cache, config } from "../setup/index.mjs";
2
1
  import { keys } from "../constants/storage.mjs";
2
+ import { cache, config } from "../setup/index.mjs";
3
3
  import { Dimensions, PixelRatio, Platform } from "react-native";
4
4
  import { getAndroidId, getInstallReferrerAsync, getIosIdForVendorAsync } from "expo-application";
5
5
  import { DeviceType, deviceType, manufacturer, modelId, modelName, osName, osVersion } from "expo-device";
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
4
- const require_track_index = require("../track/index.cjs");
5
4
  const require_hooks_use_outbound_click_analytics = require("../hooks/use-outbound-click-analytics.cjs");
6
- const require_third_parties_microsoft_uet = require("../third-parties/microsoft-uet.cjs");
7
5
  const require_hooks_use_uet_id_sync = require("../hooks/use-uet-id-sync.cjs");
8
6
  const require_hooks_use_web_analytics = require("../hooks/use-web-analytics.cjs");
9
7
  const require_third_parties_analytics_props = require("../third-parties/analytics-props.cjs");
8
+ const require_third_parties_microsoft_uet = require("../third-parties/microsoft-uet.cjs");
9
+ const require_track_index = require("../track/index.cjs");
10
10
  let react = require("react");
11
11
  let next_navigation = require("next/navigation");
12
12
  let next_script = require("next/script");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["usePathname","useSearchParams","uetCustomerIdOf","Suspense","Script"],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrations\n .flatMap(({ script }) => (script ? [script] : []))\n .map((script) => (\n <Script\n key={script.id}\n id={script.id}\n nonce={nonce}\n strategy={script.strategy ?? 'afterInteractive'}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAY;CACnB,MAAM,YAAA,GAAWA,gBAAAA,YAAAA,CAAY;CAC7B,MAAM,gBAAA,GAAeC,gBAAAA,gBAAAA,CAAgB;CACrC,gCAAA,gBAAgB,UAAU,aAAa,SAAS,CAAC;CACjD,OAAO;AACT;AAEA,SAAgB,UAAU,EACxB,eAAe,CAAC,GAChB,eACA,OACA,kBAAkB,QACD;CACjB,2CAAA,0BAA0B;CAC1B,8BAAA,aAAaC,oCAAAA,gBAAgB,YAAY,CAAC;CAC1C,sCAAA,uBAAuB,YAAY;CAEnC,CAAA,GAAA,gBAAA,mBAAA,EAAoB,WAAW;EAC7B,IAAI,CAAC,iBAAiB;EACtB,MAAM,aAAa;GACjB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,cAAc,OAAO;GACrB,cAAc,OAAO;GACrB,eAAe,OAAO;GACtB,wBAAwB,OAAO;GAC/B,iBAAiB;EACnB;EACA,oBAAA,MAAM,OAAO,MAAM,UAAU;CAC/B,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,MAAAA,UAAD;GAAU,UAAU;GAClB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD,CAAY,CAAA;EACJ,CAAA;EACT,iBAAiB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,UAAS;GAAY,SAAS;EAAgB,CAAA;EACrE,aACE,SAAS,EAAE,aAAc,SAAS,CAAC,MAAM,IAAI,CAAC,CAAE,CAAC,CACjD,KAAK,WACJ,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,SAAD;GAEE,IAAI,OAAO;GACJ;GACP,UAAU,OAAO,YAAY;GAC7B,yBAAyB,EAAE,QAAQ,OAAO,OAAO;EAClD,GALM,OAAO,EAKb,CACF;CACH,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"index.cjs","names":["usePathname","useSearchParams","useWebAnalytics","useOutboundClickAnalytics","useUETIdSync","uetCustomerIdOf","preconnectIntegrations","useReportWebVitals","track","Suspense","Script"],"sources":["../../src/next/index.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport Script from 'next/script';\nimport { useReportWebVitals } from 'next/web-vitals';\nimport { Suspense } from 'react';\nimport { useOutboundClickAnalytics } from '../hooks/use-outbound-click-analytics';\nimport { useUETIdSync } from '../hooks/use-uet-id-sync';\nimport { useWebAnalytics } from '../hooks/use-web-analytics';\nimport { type AnalyticsProps, preconnectIntegrations } from '../third-parties/analytics-props';\nimport { uetCustomerIdOf } from '../third-parties/microsoft-uet';\nimport { track } from '../track/index';\n\n/**\n * Its own component under a Suspense boundary: `useSearchParams` in a statically rendered route\n * bails the whole tree out to client rendering unless something above it suspends, and Next\n * fails the build for a page that lets it. The boundary is here so a host does not have to know.\n */\nfunction PageViews() {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n useWebAnalytics(pathname, searchParams.toString());\n return null;\n}\n\nexport function Analytics({\n integrations = [],\n facebookAppId,\n nonce,\n reportWebVitals = true,\n}: AnalyticsProps) {\n useOutboundClickAnalytics();\n useUETIdSync(uetCustomerIdOf(integrations));\n preconnectIntegrations(integrations);\n\n useReportWebVitals((metric) => {\n if (!reportWebVitals) return;\n const properties = {\n value: metric.delta,\n metric_id: metric.id,\n metric_value: metric.value,\n metric_delta: metric.delta,\n metric_rating: metric.rating,\n metric_navigation_type: metric.navigationType,\n non_interaction: true, // avoids affecting bounce rate.\n };\n track(metric.name, properties);\n });\n\n return (\n <>\n <Suspense fallback={null}>\n <PageViews />\n </Suspense>\n {facebookAppId && <meta property=\"fb:app_id\" content={facebookAppId} />}\n {integrations\n .flatMap(({ script }) => (script ? [script] : []))\n .map((script) => (\n <Script\n key={script.id}\n id={script.id}\n nonce={nonce}\n strategy={script.strategy ?? 'afterInteractive'}\n dangerouslySetInnerHTML={{ __html: script.inline }}\n />\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAY;CACnB,MAAM,YAAA,GAAWA,gBAAAA,YAAAA,CAAY;CAC7B,MAAM,gBAAA,GAAeC,gBAAAA,gBAAAA,CAAgB;CACrCC,gCAAAA,gBAAgB,UAAU,aAAa,SAAS,CAAC;CACjD,OAAO;AACT;AAEA,SAAgB,UAAU,EACxB,eAAe,CAAC,GAChB,eACA,OACA,kBAAkB,QACD;CACjBC,2CAAAA,0BAA0B;CAC1BC,8BAAAA,aAAaC,oCAAAA,gBAAgB,YAAY,CAAC;CAC1CC,sCAAAA,uBAAuB,YAAY;CAEnCC,CAAAA,GAAAA,gBAAAA,mBAAAA,EAAoB,WAAW;EAC7B,IAAI,CAAC,iBAAiB;EACtB,MAAM,aAAa;GACjB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,cAAc,OAAO;GACrB,cAAc,OAAO;GACrB,eAAe,OAAO;GACtB,wBAAwB,OAAO;GAC/B,iBAAiB;EACnB;EACAC,oBAAAA,MAAM,OAAO,MAAM,UAAU;CAC/B,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,MAAAA,UAAD;GAAU,UAAU;GAClB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD,CAAY,CAAA;EACJ,CAAA;EACT,iBAAiB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,UAAS;GAAY,SAAS;EAAgB,CAAA;EACrE,aACE,SAAS,EAAE,aAAc,SAAS,CAAC,MAAM,IAAI,CAAC,CAAE,CAAC,CACjD,KAAK,WACJ,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,SAAD;GAEE,IAAI,OAAO;GACJ;GACP,UAAU,OAAO,YAAY;GAC7B,yBAAyB,EAAE,QAAQ,OAAO,OAAO;EAClD,GALM,OAAO,EAKb,CACF;CACH,EAAA,CAAA;AAEN"}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import { track } from "../track/index.mjs";
3
2
  import { useOutboundClickAnalytics } from "../hooks/use-outbound-click-analytics.mjs";
4
- import { uetCustomerIdOf } from "../third-parties/microsoft-uet.mjs";
5
3
  import { useUETIdSync } from "../hooks/use-uet-id-sync.mjs";
6
4
  import { useWebAnalytics } from "../hooks/use-web-analytics.mjs";
7
5
  import { preconnectIntegrations } from "../third-parties/analytics-props.mjs";
6
+ import { uetCustomerIdOf } from "../third-parties/microsoft-uet.mjs";
7
+ import { track } from "../track/index.mjs";
8
8
  import { Suspense } from "react";
9
9
  import { usePathname, useSearchParams } from "next/navigation";
10
10
  import Script from "next/script";