@shware/analytics 11.12.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +93 -11
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  3. package/dist/_virtual/_rolldown/runtime.mjs +1 -1
  4. package/dist/ads/google.d.cts +1 -0
  5. package/dist/ads/google.d.mts +1 -0
  6. package/dist/click-id/index.cjs +5 -5
  7. package/dist/click-id/index.cjs.map +1 -1
  8. package/dist/next/index.d.cts +1 -0
  9. package/dist/next/index.d.mts +1 -0
  10. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs +2 -2
  11. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs.map +1 -1
  12. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs +2 -2
  13. package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs.map +1 -1
  14. package/dist/react-router/index.d.cts +1 -0
  15. package/dist/react-router/index.d.mts +1 -0
  16. package/dist/server/legacy.mjs +1 -2
  17. package/dist/server/linkedin-conversions-api.d.cts +1 -0
  18. package/dist/server/linkedin-conversions-api.d.mts +1 -0
  19. package/dist/server/meta-capi.d.cts +1 -0
  20. package/dist/server/meta-capi.d.mts +1 -0
  21. package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
  22. package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
  23. package/dist/server/openai-conversions-api.d.cts +1 -0
  24. package/dist/server/openai-conversions-api.d.mts +1 -0
  25. package/dist/setup/index.d.cts +1 -0
  26. package/dist/setup/index.d.mts +1 -0
  27. package/dist/setup/session.d.cts +1 -0
  28. package/dist/setup/session.d.mts +1 -0
  29. package/dist/tanstack/analytics.d.cts +1 -0
  30. package/dist/tanstack/analytics.d.mts +1 -0
  31. package/dist/test/setup.d.cts.map +1 -1
  32. package/dist/test/setup.d.mts.map +1 -1
  33. package/dist/track/fbq.d.cts +1 -0
  34. package/dist/track/fbq.d.mts +1 -0
  35. package/dist/track/gtag.d.cts +1 -0
  36. package/dist/track/gtag.d.mts +1 -0
  37. package/dist/track/rdt.d.cts +1 -0
  38. package/dist/track/rdt.d.mts +1 -0
  39. package/dist/track/types.d.cts +1 -0
  40. package/dist/track/types.d.mts +1 -0
  41. package/package.json +20 -19
package/README.md CHANGED
@@ -1,4 +1,42 @@
1
- # Shware Analytics SDK
1
+ # @shware/analytics
2
+
3
+ First-party product and marketing analytics for web (Next.js, TanStack Start, React Router) and
4
+ React Native (Expo). One `track()` call records the event against your own backend, forwards it to
5
+ the browser pixels you configure (GA4, PostHog, Meta, Reddit, LinkedIn, OpenAI, Microsoft UET),
6
+ and carries the visit's attribution (UTM, click ids, referrer) so the server can send the same
7
+ conversion on to the ad platforms' conversions APIs.
8
+
9
+ Related guides in this folder: [GA4.md](./GA4.md) (how sessions and engagement line up with GA4)
10
+ and [UTM.md](./UTM.md) (how to tag campaign links).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ pnpm add @shware/analytics zod
16
+ ```
17
+
18
+ Every framework and platform integration is an optional peer dependency: install only what your
19
+ entry point imports (`next`, `@tanstack/react-start`, `react-router`, `posthog-js`, the `expo-*`
20
+ modules for `/native`, `react-native-fbsdk-next` for `/native/fbsdk`, and so on).
21
+
22
+ ## Entry points
23
+
24
+ | Import | Runs on | What it is for |
25
+ | ----------------------------------------- | ------- | ----------------------------------------------------------------------- |
26
+ | `@shware/analytics` | client | `setupAnalytics`, `track`, `setVisitor`, `sendFeedback`, links, bots |
27
+ | `@shware/analytics/web` | browser | `storage`, `getTags`, `getDeviceId` for `setupAnalytics` on the web |
28
+ | `@shware/analytics/native` | Expo | The same for React Native, plus `deepLink` and `useAppAnalytics` |
29
+ | `@shware/analytics/native/firebase` | Expo | `sendFirebaseEvent`, a third-party tracker for Firebase Analytics |
30
+ | `@shware/analytics/native/fbsdk` | Expo | `sendFBEvent`, a third-party tracker for the Facebook SDK |
31
+ | `@shware/analytics/next` | browser | `<Analytics />` for the Next.js App Router |
32
+ | `@shware/analytics/tanstack` | both | `<Analytics />` and `createClickIdMiddleware` for TanStack Start |
33
+ | `@shware/analytics/react-router` | browser | `<Analytics />` for React Router |
34
+ | `@shware/analytics/third-parties` | browser | GA4, Meta Pixel, Reddit, LinkedIn, OpenAI and UET trackers and setters |
35
+ | `@shware/analytics/third-parties/posthog` | browser | `sendPosthogEvent` and `setPosthogUser` |
36
+ | `@shware/analytics/server` | server | Conversions APIs: Meta, Google Ads, Microsoft, Reddit, LinkedIn, OpenAI |
37
+ | `@shware/analytics/server/legacy` | server | The old Meta sender built on `facebook-nodejs-business-sdk` |
38
+ | `@shware/analytics/attribution` | server | `classifyTouch` and the channel vocabulary for reading sessions |
39
+ | `@shware/analytics/ads` | server | Pulling spend and performance from Google Ads and Meta |
2
40
 
3
41
  ## Client-side only
4
42
 
@@ -12,29 +50,37 @@ Server-side conversions go the other way: store the client's events, then hand t
12
50
  `@shware/analytics/server`, which takes a `TrackEvent` and forwards it to the Meta, Reddit, OpenAI,
13
51
  LinkedIn, Google Ads and Microsoft Advertising conversions APIs.
14
52
 
15
- ## Config
53
+ ## Setup
16
54
 
17
- layout.tsx
55
+ Call `setupAnalytics` once, at module scope of the client entry, before anything tracks. Web:
18
56
 
19
- ```tsx
57
+ ```ts
20
58
  import { setupAnalytics } from '@shware/analytics';
21
- import { getTags, getDeviceId, storage } from '@shware/analytics/web';
59
+ import { sendGAEvent, setGAUser } from '@shware/analytics/third-parties';
60
+ import { sendPosthogEvent, setPosthogUser } from '@shware/analytics/third-parties/posthog';
61
+ import { getDeviceId, getTags, storage } from '@shware/analytics/web';
62
+ import { version } from '../package.json';
22
63
 
23
64
  setupAnalytics({
24
65
  storage,
25
66
  getTags,
26
67
  getDeviceId,
68
+ release: version,
69
+ platform: 'web',
70
+ environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',
71
+ // Optional: every tracked event is also handed to these, and setVisitor to the setters.
72
+ thirdPartyTrackers: [sendGAEvent, sendPosthogEvent],
73
+ thirdPartyUserSetters: [setGAUser, setPosthogUser],
27
74
  endpoint: 'https://api.example.com/v1/analytics',
28
75
  });
29
-
30
- function App() {
31
- return <div>My React App</div>;
32
- }
33
76
  ```
34
77
 
78
+ `getHeaders` is also accepted, for a backend that wants extra headers on the analytics requests.
79
+
35
80
  React Native (Expo):
36
81
 
37
82
  ```ts
83
+ import { Platform } from 'react-native';
38
84
  import { setupAnalytics } from '@shware/analytics';
39
85
  import { deepLink, getDeviceId, getTags, storage } from '@shware/analytics/native';
40
86
 
@@ -42,6 +88,9 @@ setupAnalytics({
42
88
  storage,
43
89
  getTags,
44
90
  getDeviceId,
91
+ release: '1.0.0',
92
+ platform: Platform.OS === 'ios' ? 'ios' : 'android',
93
+ environment: __DEV__ ? 'development' : 'production',
45
94
  // The link that opened the app — a universal link, an app link, a custom scheme — lands the
46
95
  // visit as a web page's URL does: its URL and utm go into every event's tags until
47
96
  // the app goes to the background. `setupAnalytics` starts its listeners; nothing runs at import.
@@ -53,14 +102,47 @@ setupAnalytics({
53
102
  deepLink.open(url);
54
103
  ```
55
104
 
105
+ In the app, call `useAppAnalytics(pathname)` from `@shware/analytics/native` in the root layout
106
+ so screen changes are tracked as page views.
107
+
108
+ ### The `<Analytics />` component (web)
109
+
110
+ Each web framework entry exports an `Analytics` component. Render it once in the document head:
111
+ it tracks page views, outbound clicks and web vitals, and loads the pixels whose ids you pass
112
+ (`gaId`, `gtmId`, `metaPixelId`, `redditPixelId`, `linkedInPartnerId`, `uetTagId`, `hotjarId`,
113
+ and on TanStack Start `openaiPixelId`). On TanStack Start:
114
+
115
+ ```tsx
116
+ import { Analytics } from '@shware/analytics/tanstack';
117
+
118
+ <head>
119
+ <HeadContent />
120
+ <Analytics nonce={nonce} gaId="G-XXXXXXXXXX" debugMode={import.meta.env.DEV} />
121
+ </head>;
122
+ ```
123
+
124
+ On TanStack Start, also register the click-id middleware so the ad platforms' first-party cookies
125
+ survive Safari's 7-day cap (see [Keeping the cookies past Safari's limits](#keeping-the-cookies-past-safaris-limits-tanstack-start)):
126
+
127
+ ```ts
128
+ import { createClickIdMiddleware } from '@shware/analytics/tanstack';
129
+ import { createStart } from '@tanstack/react-start';
130
+
131
+ const clickIdMiddleware = createClickIdMiddleware({ domain: '.example.com' });
132
+
133
+ export const startInstance = createStart(() => ({ requestMiddleware: [clickIdMiddleware] }));
134
+ ```
135
+
56
136
  ## Usage
57
137
 
58
138
  ```tsx
59
- import { track } from '@shware/analytics';
139
+ import { setVisitor, track } from '@shware/analytics';
60
140
 
61
141
  function Button() {
62
142
  const onClick = async () => {
63
- await api.login();
143
+ const user = await api.login();
144
+ // Binds this visitor to the signed-in user (see Visitors below).
145
+ setVisitor({ user_id: user.id });
64
146
  track('login', { method: 'google' });
65
147
  };
66
148
  return <button onClick={onClick}>Login with Google</button>;
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
11
  key = keys[i];
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
11
  key = keys[i];
@@ -40,4 +40,5 @@ export declare class GoogleAdsReportError extends Error {
40
40
  */
41
41
  export declare function parseGoogleAdsScriptReport(body: unknown): AdPerformanceRow[];
42
42
  //#endregion
43
+ export {};
43
44
  //# sourceMappingURL=google.d.cts.map
@@ -40,4 +40,5 @@ export declare class GoogleAdsReportError extends Error {
40
40
  */
41
41
  export declare function parseGoogleAdsScriptReport(body: unknown): AdPerformanceRow[];
42
42
  //#endregion
43
+ export {};
43
44
  //# sourceMappingURL=google.d.mts.map
@@ -211,16 +211,16 @@ function resolveClickIdCookies(input) {
211
211
  urlClickId: params.get("wbraid") || void 0,
212
212
  assign: (value) => result.wbraid = value
213
213
  }];
214
- for (const { cookie: cookie$1, urlClickId, assign } of google) {
215
- const existing = parseGcl(jar[cookie$1], now);
214
+ for (const { cookie, urlClickId, assign } of google) {
215
+ const existing = parseGcl(jar[cookie], now);
216
216
  if (urlClickId && GCL_CLICK_ID.test(urlClickId) && urlClickId !== existing?.clickId) {
217
- set(cookie$1, formatGcl(urlClickId, now), GCL_TTL_MS);
217
+ set(cookie, formatGcl(urlClickId, now), GCL_TTL_MS);
218
218
  assign(urlClickId);
219
219
  } else if (existing) {
220
220
  const remainingMs = existing.creationTime + GCL_TTL_MS - now;
221
221
  if (remainingMs > 0) {
222
222
  assign(existing.clickId);
223
- if (refresh) set(cookie$1, existing.raw, remainingMs);
223
+ if (refresh) set(cookie, existing.raw, remainingMs);
224
224
  }
225
225
  }
226
226
  }
@@ -258,7 +258,7 @@ function resolveClickIdCookies(input) {
258
258
  }
259
259
  /** Serialize the resolved cookies into `Set-Cookie` header values. */
260
260
  function toSetCookieHeaders(cookies) {
261
- return cookies.map((cookie$2) => (0, cookie.stringifySetCookie)(cookie$2));
261
+ return cookies.map((cookie$1) => (0, cookie.stringifySetCookie)(cookie$1));
262
262
  }
263
263
  //#endregion
264
264
  exports.FBC_COOKIE = FBC_COOKIE;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["parseCookie","cookie","stringifySetCookie"],"sources":["../../src/click-id/index.ts"],"sourcesContent":["import { type SetCookie, parseCookie, stringifySetCookie } from 'cookie';\n\n/**\n * Server-side resolution of ad-click-id cookies (`_fbc`, `_gcl_aw`/`_gcl_gb`, `_rdt_cid`,\n * `_uetmsclkid`) from the incoming request.\n *\n * This is the framework-agnostic core meant to run on the *document* response (e.g. TanStack Start\n * server middleware, Next middleware). Setting `_fbc` via an HTTP `Set-Cookie` header on the top\n * document — rather than `document.cookie` on the client — is what Meta officially recommends and is\n * the only reliable way to keep the cookie alive for 90 days in Safari: ITP caps JavaScript-set\n * cookies on a fbclid-decorated landing page to 24 hours, and the document response is never\n * classified as CNAME/IP cloaking (it is the reference the browser measures cloaking against).\n *\n * The Google pair follows the same architecture Google itself ships for server containers —\n * sGTM's Conversion Linker sets FPGCLAW via Set-Cookie for 90 days — and the sGTM ecosystem\n * productized for gtag's own cookies (stape Cookie Keeper re-issues `_gcl_*` over HTTP; vendor\n * case studies report 5–20% of Google Ads conversions recovered, up to +44% on the Safari\n * slice). One deployment caveat from WebKit's rules: the HTTP-cookie exemption holds only for\n * responses from the site's own infrastructure — a CNAME or third-party-IP host (a tagging\n * subdomain on someone else's cloud) gets its Set-Cookie silently capped to 7 days. This module\n * runs on the host's own document response, which is exactly the exempt case.\n *\n * references:\n * - https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc\n * - https://webkit.org/tracking-prevention/ (7d JS cookies, 24h on ad-decorated landings,\n * CNAME/third-party-IP HTTP cookies capped to 7d, same-origin HTTP cookies exempt)\n * - https://www.simoahava.com/analytics/google-ads-server-side-tagging-google-tag-manager/\n * (Conversion Linker → FPGCLAW via Set-Cookie, Google's own server-side equivalent)\n * - https://stape.io/helpdesk/documentation/cookie-keeper-power-up (the productized re-issue)\n */\n\n// Meta's recommended _fbc cookie expiry. Events Manager warns (\"Server sending expired fbclid\")\n// when the embedded creationTime is older than 90 days and match quality/attribution may degrade;\n// no hard drop is documented.\nconst FBC_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Reddit's pixel.js rewrites `_rdt_cid` and `_rdt_uuid` for 90 days on every page load.\nconst RDT_CID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\nconst RDT_UUID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Meta's pixel rewrites `_fbp` for 90 days on every page load.\nconst FBP_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// OpenAI's oaiq: `__oppref` for 30 days (`720*60*60` s), `__obref` for 365 days.\nconst OPPREF_TTL_MS = 30 * 24 * 60 * 60 * 1000;\nconst OBREF_TTL_MS = 365 * 24 * 60 * 60 * 1000;\n// bat.js's own expiry for _uetmsclkid (`msClkIdExpirationTime`), the Microsoft Ads click window.\nconst MSCLKID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// gtag's own expiry for _gcl_* — 90 days, the length of a Google Ads click's upload window.\nconst GCL_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Tolerate a little clock skew when validating a creationTime against \"now\".\nconst CLOCK_SKEW_MS = 24 * 60 * 60 * 1000;\n\nexport const FBC_COOKIE = '_fbc';\nexport const RDT_CID_COOKIE = '_rdt_cid';\nexport const GCL_AW_COOKIE = '_gcl_aw';\nexport const GCL_GB_COOKIE = '_gcl_gb';\nexport const UET_MSCLKID_COOKIE = '_uetmsclkid';\nexport const RDT_UUID_COOKIE = '_rdt_uuid';\nexport const FBP_COOKIE = '_fbp';\nexport const OPPREF_COOKIE = '__oppref';\nexport const OBREF_COOKIE = '__obref';\n/** OpenAI's consent cookie; `false` is the visitor's opt-out, on which oaiq deletes its cookies. */\nexport const OAIQ_CONSENT_COOKIE = '__oaiq_consent';\n\nexport type ParsedFbc = { raw: string; creationTime: number; fbclid: string };\n\n/**\n * Parse `fb.<subdomainIndex>.<creationTime>.<fbclid>[.<appendix>]`. The appendix is what Meta's\n * Parameter Builder adds to the values it writes (\"an appendix field at the end of each\n * parameter\"); it is not part of the click id, so `fbclid` is the fourth segment alone and the\n * value is passed on as `raw`, unchanged. Returns undefined for anything malformed.\n * ref: https://developers.facebook.com/docs/marketing-api/conversions-api/parameter-builder-library\n */\nexport function parseFbc(\n raw: string | undefined | null,\n now: number = Date.now()\n): ParsedFbc | undefined {\n if (!raw) return undefined;\n const parts = raw.split('.');\n if (parts.length < 4 || parts.length > 5 || parts[0] !== 'fb') return undefined;\n if (parts.length === 5 && !parts[4]) return undefined;\n\n const creationTime = Number(parts[2]);\n const fbclid = parts[3];\n if (!fbclid) return undefined;\n // creationTime is UNIX ms; reject seconds-precision or future-dated values as malformed.\n if (!Number.isFinite(creationTime)) return undefined;\n if (creationTime < 1e12 || creationTime > now + CLOCK_SKEW_MS) return undefined;\n\n return { raw, creationTime, fbclid };\n}\n\n/**\n * Build a fresh `_fbc` value. subdomainIndex is the cookie's domain level (com=0, example.com=1,\n * www.example.com=2); 1 is correct for an apex-hosted cookie.\n */\nexport function formatFbc(fbclid: string, now: number, subdomainIndex = 1): string {\n return `fb.${subdomainIndex}.${now}.${fbclid}`;\n}\n\nexport type ParsedGcl = { raw: string; creationTime: number; clickId: string };\n\n/**\n * Whether a URL's `gclid` is a Google Ads click, by its `gclsrc` — gtag's own gating: absent or\n * `aw.ds` is Google Ads; `ds` / `3p.ds` are Search Ads 360's (a click on another engine, or on\n * Google with auto-tagging off), which gtag keeps in `_gcl_dc` and not `_gcl_aw`.\n * ref: https://support.google.com/sa360/answer/7342044\n */\nexport function isGoogleAdsGclid(gclsrc: string | null | undefined): boolean {\n return !gclsrc || gclsrc === 'aw.ds';\n}\n\n// gtag's own value validator, extracted from the live gtag.js bundle (2026-09): its parser\n// accepts version \"GCL\" or \"1\", a /^\\d+$/ seconds timestamp, and a click id matching this.\n// Re-verify against gtag.js before changing anything here — the format is gtag's, not ours.\nconst GCL_CLICK_ID = /^[\\w-]+$/;\n\n/**\n * Parse a `_gcl_aw`/`_gcl_gb` value: `GCL.<seconds>.<clickId>[.<labels…>]` — note the timestamp\n * is in SECONDS, unlike `_fbc`'s milliseconds. gtag's parser accepts version `GCL` or `1` and\n * validates the segments exactly this way (`/^\\d+$/` timestamp, `/^[\\w-]+$/` click id); any\n * labels tail is preserved through `raw` so a re-issue stays byte-identical.\n */\nexport function parseGcl(\n raw: string | undefined | null,\n now: number = Date.now()\n): ParsedGcl | undefined {\n if (!raw) return undefined;\n const parts = raw.split('.');\n if (parts.length < 3) return undefined;\n if (parts[0] !== 'GCL' && parts[0] !== '1') return undefined;\n const seconds = parts[1];\n const clickId = parts[2];\n if (seconds === undefined || !/^\\d+$/.test(seconds)) return undefined;\n if (clickId === undefined || !GCL_CLICK_ID.test(clickId)) return undefined;\n const creationTime = Number(seconds) * 1000;\n // Reject millisecond-precision or future-dated values as malformed.\n if (creationTime >= 1e15 || creationTime > now + CLOCK_SKEW_MS) return undefined;\n return { raw, creationTime, clickId };\n}\n\n/** Build a fresh `_gcl_aw`/`_gcl_gb` value in gtag's own format. */\nexport function formatGcl(clickId: string, now: number): string {\n return `GCL.${Math.floor(now / 1000)}.${clickId}`;\n}\n\n// bat.js writes the click id as `_uet<msclkid>` and reads it back only when what follows the\n// prefix is at most 32 characters (`msClkIdCookieValuePrefix`, `lengthMsClkId`); a msclkid is a\n// 32-hex-digit UUID without dashes. Re-verify against bat.js before changing anything here —\n// the format is UET's, not ours.\nconst UET_MSCLKID_PREFIX = '_uet';\nconst MSCLKID = /^[0-9a-f]{32}$/i;\n\n/** Whether a value has the shape of a Microsoft click id: 32 hex digits, no dashes. */\nexport function isMsclkid(value: string | null | undefined): value is string {\n return !!value && MSCLKID.test(value);\n}\n\n/**\n * Parse a `_uetmsclkid` value: `_uet<32 hex>`. Returns the click id, lowercased, or undefined\n * for anything bat.js itself would not read back.\n */\nexport function parseUetMsclkid(raw: string | undefined | null): string | undefined {\n if (!raw || !raw.startsWith(UET_MSCLKID_PREFIX)) return undefined;\n const clickId = raw.slice(UET_MSCLKID_PREFIX.length);\n return MSCLKID.test(clickId) ? clickId.toLowerCase() : undefined;\n}\n\n/** Build a `_uetmsclkid` value in bat.js's own format. */\nexport function formatUetMsclkid(clickId: string): string {\n return `${UET_MSCLKID_PREFIX}${clickId.toLowerCase()}`;\n}\n\n/**\n * The click id as the Conversions API wants it: a dashed, lowercase UUID. The URL and the cookie\n * carry the 32-hex form; a value in any other shape is returned untouched for the API to judge.\n */\nexport function formatMsclkid(clickId: string): string {\n const id = clickId.trim().toLowerCase();\n if (!MSCLKID.test(id)) return id;\n return `${id.slice(0, 8)}-${id.slice(8, 12)}-${id.slice(12, 16)}-${id.slice(16, 20)}-${id.slice(20)}`;\n}\n\nexport type ResolveClickIdCookiesInput = {\n /** The absolute request URL (must include the query string). */\n url: string;\n /** The raw `Cookie` request header, if any. */\n cookieHeader?: string | null;\n /** Overridable clock, primarily for tests. Defaults to `Date.now()`. */\n now?: number;\n /**\n * `Domain` attribute for the emitted cookies: the site's registrable domain, e.g.\n * `.shware.io`, where the pixels write theirs. Required in production: a host-only cookie is a\n * second cookie of the same name next to the pixel's, which the pixel then reads — or deletes,\n * as Reddit's does at every subdomain level before writing its own. `null` for a host-only\n * cookie, which only a local `localhost` setup should ask for.\n */\n domain: string | null;\n /** `Secure` attribute, default true. Set false only for local http testing. */\n secure?: boolean;\n /** subdomainIndex for a freshly built `_fbc` (see {@link formatFbc}). Default 1. */\n subdomainIndex?: number;\n /**\n * Re-issue the stored click and browser ids on every call. On by default, as an ITP self-heal:\n * cookies follow last-writer-wins, so when a pixel has rewritten one through `document.cookie`\n * (Safari caps JS-written cookies at 7 days, 24h on an ad-decorated landing), re-issuing the\n * long-lived HTTP cookie on the next navigation restores it — the same continuous-re-issue\n * mitigation the sGTM ecosystem uses (stape Cookie Keeper, Cookie Monster). `_fbc` and\n * `_gcl_*` are re-issued byte-for-byte at their *remaining* lifetime, so their window never\n * slides (Meta warns on a moved fbclid); the others at the lifetime their pixel itself gives\n * them on every page load (see each below).\n *\n * Set false to strictly follow Meta's documented conditional-write rule (\"only set the cookie if\n * it doesn't exist or the fbclid changed\") — e.g. to keep pages CDN-cacheable, since the\n * re-issue attaches a per-user `Set-Cookie` (forcing `no-store`) to every response carrying an\n * `_fbc`.\n */\n refresh?: boolean;\n};\n\nexport type ResolveClickIdCookiesResult = {\n /**\n * Cookies to emit on the response, ready for `Set-Cookie`. Empty when nothing needs to change.\n * A `value: ''`, `maxAge: 0` entry is a deletion (an expired or malformed leftover).\n */\n cookies: SetCookie[];\n /** The resolved `_fbc` value, for immediate server-side use (e.g. Conversions API). */\n fbc?: string;\n /** The resolved `_rdt_cid` value. */\n rdt_cid?: string;\n /** The resolved Google Ads click id (from the URL or a still-valid `_gcl_aw`). */\n gclid?: string;\n /** The resolved iOS web-to-app click id (from the URL or a still-valid `_gcl_gb`). */\n wbraid?: string;\n /** The resolved Microsoft Ads click id (from the URL or `_uetmsclkid`), 32-hex form. */\n msclkid?: string;\n};\n\nfunction searchParams(url: string): URLSearchParams {\n try {\n return new URL(url).searchParams;\n } catch {\n // Fall back to a manual split so a relative or slightly malformed URL still yields the query.\n const q = url.indexOf('?');\n return new URLSearchParams(q !== -1 ? url.slice(q + 1) : '');\n }\n}\n\n/**\n * Resolve the click-id cookies to set on the current document response.\n *\n * `_fbc` follows Meta's documented conditional-write rule value-wise: a new fbclid (or an absent\n * cookie) opens a fresh 90-day window; a same-fbclid cookie keeps its original value and\n * `creationTime`. Expired (>90d) or malformed values are cleared instead of forwarded. By default,\n * ({@link ResolveClickIdCookiesInput.refresh}) a still-valid cookie is re-issued unchanged at its\n * *remaining* lifetime — never `now + 90d` — so a returning visitor's window cannot slide forward\n * (which is what makes Meta flag an expired fbclid).\n */\nexport function resolveClickIdCookies(\n input: ResolveClickIdCookiesInput\n): ResolveClickIdCookiesResult {\n const { url, cookieHeader, domain, secure = true, subdomainIndex = 1, refresh = true } = input;\n const now = input.now ?? Date.now();\n\n const params = searchParams(url);\n const jar = parseCookie(cookieHeader ?? '');\n const cookies: SetCookie[] = [];\n const result: ResolveClickIdCookiesResult = { cookies };\n\n const base = { path: '/', secure, sameSite: 'lax', domain: domain ?? undefined } as const;\n const set = (name: string, value: string, ttlMs: number) =>\n cookies.push({ name, value, maxAge: Math.floor(ttlMs / 1000), ...base });\n const del = (name: string) => cookies.push({ name, value: '', maxAge: 0, ...base });\n\n // --- Meta _fbc ---\n const urlFbclid = params.get('fbclid') || undefined;\n const existingFbc = parseFbc(jar[FBC_COOKIE], now);\n\n if (urlFbclid && urlFbclid !== existingFbc?.fbclid) {\n // A new click always wins and opens a fresh 90-day window.\n const raw = formatFbc(urlFbclid, now, subdomainIndex);\n set(FBC_COOKIE, raw, FBC_TTL_MS);\n result.fbc = raw;\n } else if (existingFbc) {\n const remainingMs = existingFbc.creationTime + FBC_TTL_MS - now;\n if (remainingMs <= 0) {\n del(FBC_COOKIE);\n } else {\n // Same fbclid: the value and creationTime are preserved (Meta's rule); refresh (default)\n // re-issues it unchanged at its remaining lifetime as an ITP self-heal.\n result.fbc = existingFbc.raw;\n if (refresh) set(FBC_COOKIE, existingFbc.raw, remainingMs);\n }\n } else if (jar[FBC_COOKIE]) {\n // Malformed leftover — clear it rather than forwarding it to Meta.\n del(FBC_COOKIE);\n }\n\n // --- Google Ads _gcl_aw / _gcl_gb ---\n // The same first-party HTTP persistence Google's own server-side Conversion Linker performs\n // (it sets FPGCLAW via Set-Cookie for 90 days), applied to gtag's cookies the way the sGTM\n // ecosystem does (stape Cookie Keeper re-issues _gcl_* over HTTP). Ownership is shared with\n // gtag, so the rules are stricter than for _fbc: a value this module cannot parse is left\n // untouched — never rewritten, never deleted — and a re-issue is byte-identical (labels tail\n // included) at the window's REMAINING lifetime, so the 90-day click window never slides.\n const gclsrc = params.get('gclsrc') || undefined;\n const google = [\n {\n cookie: GCL_AW_COOKIE,\n // gtag's own gating (`isGoogleAdsGclid`): a gclid enters _gcl_aw only when gclsrc is\n // absent or 'aw.ds' — 'ds'/'3p.ds' clicks are Search Ads 360's and belong to _gcl_dc.\n urlClickId: isGoogleAdsGclid(gclsrc) ? params.get('gclid') || undefined : undefined,\n assign: (value: string) => (result.gclid = value),\n },\n {\n cookie: GCL_GB_COOKIE,\n urlClickId: params.get('wbraid') || undefined,\n assign: (value: string) => (result.wbraid = value),\n },\n ];\n for (const { cookie, urlClickId, assign } of google) {\n const existing = parseGcl(jar[cookie], now);\n if (urlClickId && GCL_CLICK_ID.test(urlClickId) && urlClickId !== existing?.clickId) {\n // A new click always wins and opens a fresh 90-day window, in gtag's exact format.\n set(cookie, formatGcl(urlClickId, now), GCL_TTL_MS);\n assign(urlClickId);\n } else if (existing) {\n const remainingMs = existing.creationTime + GCL_TTL_MS - now;\n if (remainingMs > 0) {\n assign(existing.clickId);\n if (refresh) set(cookie, existing.raw, remainingMs);\n }\n // Expired: not returned and not re-issued, but gtag owns the deletion.\n }\n }\n\n // --- Reddit _rdt_cid / _rdt_uuid ---\n // Reddit's pixel.js rewrites both on every page load through `document.cookie` — the click id\n // from the URL, else the stored one, and the browser id — each for a fresh 90 days. So Reddit\n // slides the window itself, and the re-issue (default on, see `refresh`) does the same over\n // HTTP: without it the pixel's JS copy, capped at 7 days in Safari, is the only one left.\n const urlRdtCid = params.get('rdt_cid') || undefined;\n const existingRdtCid = jar[RDT_CID_COOKIE] || undefined;\n if (urlRdtCid && urlRdtCid !== existingRdtCid) {\n set(RDT_CID_COOKIE, urlRdtCid, RDT_CID_TTL_MS);\n result.rdt_cid = urlRdtCid;\n } else if (existingRdtCid) {\n result.rdt_cid = existingRdtCid;\n if (refresh) set(RDT_CID_COOKIE, existingRdtCid, RDT_CID_TTL_MS);\n }\n const existingRdtUuid = jar[RDT_UUID_COOKIE] || undefined;\n if (existingRdtUuid && refresh) set(RDT_UUID_COOKIE, existingRdtUuid, RDT_UUID_TTL_MS);\n\n // --- Meta _fbp ---\n // The pixel's browser id: created by the pixel, which rewrites it for 90 days on every page\n // load, as Reddit's does its own. Re-issued as it is, never created here.\n const existingFbp = jar[FBP_COOKIE] || undefined;\n if (existingFbp && refresh) set(FBP_COOKIE, existingFbp, FBP_TTL_MS);\n\n // --- OpenAI __oppref / __obref ---\n // oaiq writes `__oppref` only when the URL carries `oppref` (30 days), and `__obref` — its\n // browser reference — only when there is none (365 days); otherwise it reads them, through\n // `document.cookie`, so in Safari each is gone after 7 days and the browser starts over with a\n // new reference. The first is captured here from the URL as well, and both are re-issued as\n // they are, `__obref` never created. Unlike oaiq, the re-issue restarts their windows: their\n // values carry no creation time to count a remaining lifetime from, and OpenAI applies its own\n // attribution window to the click whatever the cookie's age. Nothing is written once the\n // visitor has opted out of oaiq, which deletes both cookies then.\n if (jar[OAIQ_CONSENT_COOKIE] !== 'false') {\n const urlOppref = params.get('oppref') || undefined;\n const existingOppref = jar[OPPREF_COOKIE] || undefined;\n if (urlOppref) set(OPPREF_COOKIE, urlOppref, OPPREF_TTL_MS);\n else if (existingOppref && refresh) set(OPPREF_COOKIE, existingOppref, OPPREF_TTL_MS);\n const existingObref = jar[OBREF_COOKIE] || undefined;\n if (existingObref && refresh) set(OBREF_COOKIE, existingObref, OBREF_TTL_MS);\n }\n\n // --- Microsoft Ads _uetmsclkid ---\n // The UET tag's own cookie, in its own format, so the tag and this module read each other's\n // writes. Microsoft's ITP answer is this first-party cookie (plus a localStorage backup), but\n // bat.js writes it through `document.cookie`, which Safari caps at 7 days — 24 hours on a\n // landing page decorated by a classified domain, and a bing.com ad click is exactly that.\n // Persisting it here over HTTP on the document response restores the 90-day window.\n //\n // The re-issue (default on, see `refresh`) is the same self-heal as for `_fbc`, and it matters\n // more here: bat.js rewrites this cookie on EVERY page load, so without the re-issue the HTTP\n // copy is downgraded to a JS cookie on the very next page. There is no embedded timestamp to\n // compute a remaining lifetime from, so it is re-issued at a fresh 90 days — which is exactly\n // what bat.js itself does on each page (`msClkIdExpirationTime` from now), so the window\n // slides no more than the tag already slides it. A value this module cannot parse belongs to\n // the tag: never rewritten, never deleted.\n const urlMsclkid = params.get('msclkid')?.trim();\n const existingMsclkid = parseUetMsclkid(jar[UET_MSCLKID_COOKIE]);\n if (urlMsclkid && MSCLKID.test(urlMsclkid) && urlMsclkid.toLowerCase() !== existingMsclkid) {\n set(UET_MSCLKID_COOKIE, formatUetMsclkid(urlMsclkid), MSCLKID_TTL_MS);\n result.msclkid = urlMsclkid.toLowerCase();\n } else if (existingMsclkid) {\n result.msclkid = existingMsclkid;\n if (refresh) set(UET_MSCLKID_COOKIE, formatUetMsclkid(existingMsclkid), MSCLKID_TTL_MS);\n }\n\n return result;\n}\n\n/** Serialize the resolved cookies into `Set-Cookie` header values. */\nexport function toSetCookieHeaders(cookies: SetCookie[]): string[] {\n return cookies.map((cookie) => stringifySetCookie(cookie));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,aAAa;AAEnB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AAErB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,MAAa,aAAa;AAC1B,MAAa,iBAAiB;AAC9B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;AAC7B,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAC/B,MAAa,aAAa;AAC1B,MAAa,gBAAgB;AAC7B,MAAa,eAAe;;AAE5B,MAAa,sBAAsB;;;;;;;;AAWnC,SAAgB,SACd,KACA,MAAc,KAAK,IAAI,GACA;CACvB,IAAI,CAAC,KAAK,OAAO,KAAA;CACjB,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,IAAI,MAAM,SAAS,KAAK,MAAM,SAAS,KAAK,MAAM,OAAO,MAAM,OAAO,KAA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B;EAC1B,OAAO,UAAU;EACjB,IAAI,SAAS,IAAI,oBAAoB,iBAAiB,eAAe,GAAG,cAAc;CACxF;CAEA,OAAO;AACT;;AAGA,SAAgB,mBAAmB,SAAgC;CACjE,OAAO,QAAQ,KAAK,cAAA,GAAWC,OAAAA,mBAAAA,CAAmBD,QAAM,CAAC;AAC3D"}
1
+ {"version":3,"file":"index.cjs","names":["parseCookie","stringifySetCookie","cookie"],"sources":["../../src/click-id/index.ts"],"sourcesContent":["import { type SetCookie, parseCookie, stringifySetCookie } from 'cookie';\n\n/**\n * Server-side resolution of ad-click-id cookies (`_fbc`, `_gcl_aw`/`_gcl_gb`, `_rdt_cid`,\n * `_uetmsclkid`) from the incoming request.\n *\n * This is the framework-agnostic core meant to run on the *document* response (e.g. TanStack Start\n * server middleware, Next middleware). Setting `_fbc` via an HTTP `Set-Cookie` header on the top\n * document — rather than `document.cookie` on the client — is what Meta officially recommends and is\n * the only reliable way to keep the cookie alive for 90 days in Safari: ITP caps JavaScript-set\n * cookies on a fbclid-decorated landing page to 24 hours, and the document response is never\n * classified as CNAME/IP cloaking (it is the reference the browser measures cloaking against).\n *\n * The Google pair follows the same architecture Google itself ships for server containers —\n * sGTM's Conversion Linker sets FPGCLAW via Set-Cookie for 90 days — and the sGTM ecosystem\n * productized for gtag's own cookies (stape Cookie Keeper re-issues `_gcl_*` over HTTP; vendor\n * case studies report 5–20% of Google Ads conversions recovered, up to +44% on the Safari\n * slice). One deployment caveat from WebKit's rules: the HTTP-cookie exemption holds only for\n * responses from the site's own infrastructure — a CNAME or third-party-IP host (a tagging\n * subdomain on someone else's cloud) gets its Set-Cookie silently capped to 7 days. This module\n * runs on the host's own document response, which is exactly the exempt case.\n *\n * references:\n * - https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc\n * - https://webkit.org/tracking-prevention/ (7d JS cookies, 24h on ad-decorated landings,\n * CNAME/third-party-IP HTTP cookies capped to 7d, same-origin HTTP cookies exempt)\n * - https://www.simoahava.com/analytics/google-ads-server-side-tagging-google-tag-manager/\n * (Conversion Linker → FPGCLAW via Set-Cookie, Google's own server-side equivalent)\n * - https://stape.io/helpdesk/documentation/cookie-keeper-power-up (the productized re-issue)\n */\n\n// Meta's recommended _fbc cookie expiry. Events Manager warns (\"Server sending expired fbclid\")\n// when the embedded creationTime is older than 90 days and match quality/attribution may degrade;\n// no hard drop is documented.\nconst FBC_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Reddit's pixel.js rewrites `_rdt_cid` and `_rdt_uuid` for 90 days on every page load.\nconst RDT_CID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\nconst RDT_UUID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Meta's pixel rewrites `_fbp` for 90 days on every page load.\nconst FBP_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// OpenAI's oaiq: `__oppref` for 30 days (`720*60*60` s), `__obref` for 365 days.\nconst OPPREF_TTL_MS = 30 * 24 * 60 * 60 * 1000;\nconst OBREF_TTL_MS = 365 * 24 * 60 * 60 * 1000;\n// bat.js's own expiry for _uetmsclkid (`msClkIdExpirationTime`), the Microsoft Ads click window.\nconst MSCLKID_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// gtag's own expiry for _gcl_* — 90 days, the length of a Google Ads click's upload window.\nconst GCL_TTL_MS = 90 * 24 * 60 * 60 * 1000;\n// Tolerate a little clock skew when validating a creationTime against \"now\".\nconst CLOCK_SKEW_MS = 24 * 60 * 60 * 1000;\n\nexport const FBC_COOKIE = '_fbc';\nexport const RDT_CID_COOKIE = '_rdt_cid';\nexport const GCL_AW_COOKIE = '_gcl_aw';\nexport const GCL_GB_COOKIE = '_gcl_gb';\nexport const UET_MSCLKID_COOKIE = '_uetmsclkid';\nexport const RDT_UUID_COOKIE = '_rdt_uuid';\nexport const FBP_COOKIE = '_fbp';\nexport const OPPREF_COOKIE = '__oppref';\nexport const OBREF_COOKIE = '__obref';\n/** OpenAI's consent cookie; `false` is the visitor's opt-out, on which oaiq deletes its cookies. */\nexport const OAIQ_CONSENT_COOKIE = '__oaiq_consent';\n\nexport type ParsedFbc = { raw: string; creationTime: number; fbclid: string };\n\n/**\n * Parse `fb.<subdomainIndex>.<creationTime>.<fbclid>[.<appendix>]`. The appendix is what Meta's\n * Parameter Builder adds to the values it writes (\"an appendix field at the end of each\n * parameter\"); it is not part of the click id, so `fbclid` is the fourth segment alone and the\n * value is passed on as `raw`, unchanged. Returns undefined for anything malformed.\n * ref: https://developers.facebook.com/docs/marketing-api/conversions-api/parameter-builder-library\n */\nexport function parseFbc(\n raw: string | undefined | null,\n now: number = Date.now()\n): ParsedFbc | undefined {\n if (!raw) return undefined;\n const parts = raw.split('.');\n if (parts.length < 4 || parts.length > 5 || parts[0] !== 'fb') return undefined;\n if (parts.length === 5 && !parts[4]) return undefined;\n\n const creationTime = Number(parts[2]);\n const fbclid = parts[3];\n if (!fbclid) return undefined;\n // creationTime is UNIX ms; reject seconds-precision or future-dated values as malformed.\n if (!Number.isFinite(creationTime)) return undefined;\n if (creationTime < 1e12 || creationTime > now + CLOCK_SKEW_MS) return undefined;\n\n return { raw, creationTime, fbclid };\n}\n\n/**\n * Build a fresh `_fbc` value. subdomainIndex is the cookie's domain level (com=0, example.com=1,\n * www.example.com=2); 1 is correct for an apex-hosted cookie.\n */\nexport function formatFbc(fbclid: string, now: number, subdomainIndex = 1): string {\n return `fb.${subdomainIndex}.${now}.${fbclid}`;\n}\n\nexport type ParsedGcl = { raw: string; creationTime: number; clickId: string };\n\n/**\n * Whether a URL's `gclid` is a Google Ads click, by its `gclsrc` — gtag's own gating: absent or\n * `aw.ds` is Google Ads; `ds` / `3p.ds` are Search Ads 360's (a click on another engine, or on\n * Google with auto-tagging off), which gtag keeps in `_gcl_dc` and not `_gcl_aw`.\n * ref: https://support.google.com/sa360/answer/7342044\n */\nexport function isGoogleAdsGclid(gclsrc: string | null | undefined): boolean {\n return !gclsrc || gclsrc === 'aw.ds';\n}\n\n// gtag's own value validator, extracted from the live gtag.js bundle (2026-09): its parser\n// accepts version \"GCL\" or \"1\", a /^\\d+$/ seconds timestamp, and a click id matching this.\n// Re-verify against gtag.js before changing anything here — the format is gtag's, not ours.\nconst GCL_CLICK_ID = /^[\\w-]+$/;\n\n/**\n * Parse a `_gcl_aw`/`_gcl_gb` value: `GCL.<seconds>.<clickId>[.<labels…>]` — note the timestamp\n * is in SECONDS, unlike `_fbc`'s milliseconds. gtag's parser accepts version `GCL` or `1` and\n * validates the segments exactly this way (`/^\\d+$/` timestamp, `/^[\\w-]+$/` click id); any\n * labels tail is preserved through `raw` so a re-issue stays byte-identical.\n */\nexport function parseGcl(\n raw: string | undefined | null,\n now: number = Date.now()\n): ParsedGcl | undefined {\n if (!raw) return undefined;\n const parts = raw.split('.');\n if (parts.length < 3) return undefined;\n if (parts[0] !== 'GCL' && parts[0] !== '1') return undefined;\n const seconds = parts[1];\n const clickId = parts[2];\n if (seconds === undefined || !/^\\d+$/.test(seconds)) return undefined;\n if (clickId === undefined || !GCL_CLICK_ID.test(clickId)) return undefined;\n const creationTime = Number(seconds) * 1000;\n // Reject millisecond-precision or future-dated values as malformed.\n if (creationTime >= 1e15 || creationTime > now + CLOCK_SKEW_MS) return undefined;\n return { raw, creationTime, clickId };\n}\n\n/** Build a fresh `_gcl_aw`/`_gcl_gb` value in gtag's own format. */\nexport function formatGcl(clickId: string, now: number): string {\n return `GCL.${Math.floor(now / 1000)}.${clickId}`;\n}\n\n// bat.js writes the click id as `_uet<msclkid>` and reads it back only when what follows the\n// prefix is at most 32 characters (`msClkIdCookieValuePrefix`, `lengthMsClkId`); a msclkid is a\n// 32-hex-digit UUID without dashes. Re-verify against bat.js before changing anything here —\n// the format is UET's, not ours.\nconst UET_MSCLKID_PREFIX = '_uet';\nconst MSCLKID = /^[0-9a-f]{32}$/i;\n\n/** Whether a value has the shape of a Microsoft click id: 32 hex digits, no dashes. */\nexport function isMsclkid(value: string | null | undefined): value is string {\n return !!value && MSCLKID.test(value);\n}\n\n/**\n * Parse a `_uetmsclkid` value: `_uet<32 hex>`. Returns the click id, lowercased, or undefined\n * for anything bat.js itself would not read back.\n */\nexport function parseUetMsclkid(raw: string | undefined | null): string | undefined {\n if (!raw || !raw.startsWith(UET_MSCLKID_PREFIX)) return undefined;\n const clickId = raw.slice(UET_MSCLKID_PREFIX.length);\n return MSCLKID.test(clickId) ? clickId.toLowerCase() : undefined;\n}\n\n/** Build a `_uetmsclkid` value in bat.js's own format. */\nexport function formatUetMsclkid(clickId: string): string {\n return `${UET_MSCLKID_PREFIX}${clickId.toLowerCase()}`;\n}\n\n/**\n * The click id as the Conversions API wants it: a dashed, lowercase UUID. The URL and the cookie\n * carry the 32-hex form; a value in any other shape is returned untouched for the API to judge.\n */\nexport function formatMsclkid(clickId: string): string {\n const id = clickId.trim().toLowerCase();\n if (!MSCLKID.test(id)) return id;\n return `${id.slice(0, 8)}-${id.slice(8, 12)}-${id.slice(12, 16)}-${id.slice(16, 20)}-${id.slice(20)}`;\n}\n\nexport type ResolveClickIdCookiesInput = {\n /** The absolute request URL (must include the query string). */\n url: string;\n /** The raw `Cookie` request header, if any. */\n cookieHeader?: string | null;\n /** Overridable clock, primarily for tests. Defaults to `Date.now()`. */\n now?: number;\n /**\n * `Domain` attribute for the emitted cookies: the site's registrable domain, e.g.\n * `.shware.io`, where the pixels write theirs. Required in production: a host-only cookie is a\n * second cookie of the same name next to the pixel's, which the pixel then reads — or deletes,\n * as Reddit's does at every subdomain level before writing its own. `null` for a host-only\n * cookie, which only a local `localhost` setup should ask for.\n */\n domain: string | null;\n /** `Secure` attribute, default true. Set false only for local http testing. */\n secure?: boolean;\n /** subdomainIndex for a freshly built `_fbc` (see {@link formatFbc}). Default 1. */\n subdomainIndex?: number;\n /**\n * Re-issue the stored click and browser ids on every call. On by default, as an ITP self-heal:\n * cookies follow last-writer-wins, so when a pixel has rewritten one through `document.cookie`\n * (Safari caps JS-written cookies at 7 days, 24h on an ad-decorated landing), re-issuing the\n * long-lived HTTP cookie on the next navigation restores it — the same continuous-re-issue\n * mitigation the sGTM ecosystem uses (stape Cookie Keeper, Cookie Monster). `_fbc` and\n * `_gcl_*` are re-issued byte-for-byte at their *remaining* lifetime, so their window never\n * slides (Meta warns on a moved fbclid); the others at the lifetime their pixel itself gives\n * them on every page load (see each below).\n *\n * Set false to strictly follow Meta's documented conditional-write rule (\"only set the cookie if\n * it doesn't exist or the fbclid changed\") — e.g. to keep pages CDN-cacheable, since the\n * re-issue attaches a per-user `Set-Cookie` (forcing `no-store`) to every response carrying an\n * `_fbc`.\n */\n refresh?: boolean;\n};\n\nexport type ResolveClickIdCookiesResult = {\n /**\n * Cookies to emit on the response, ready for `Set-Cookie`. Empty when nothing needs to change.\n * A `value: ''`, `maxAge: 0` entry is a deletion (an expired or malformed leftover).\n */\n cookies: SetCookie[];\n /** The resolved `_fbc` value, for immediate server-side use (e.g. Conversions API). */\n fbc?: string;\n /** The resolved `_rdt_cid` value. */\n rdt_cid?: string;\n /** The resolved Google Ads click id (from the URL or a still-valid `_gcl_aw`). */\n gclid?: string;\n /** The resolved iOS web-to-app click id (from the URL or a still-valid `_gcl_gb`). */\n wbraid?: string;\n /** The resolved Microsoft Ads click id (from the URL or `_uetmsclkid`), 32-hex form. */\n msclkid?: string;\n};\n\nfunction searchParams(url: string): URLSearchParams {\n try {\n return new URL(url).searchParams;\n } catch {\n // Fall back to a manual split so a relative or slightly malformed URL still yields the query.\n const q = url.indexOf('?');\n return new URLSearchParams(q !== -1 ? url.slice(q + 1) : '');\n }\n}\n\n/**\n * Resolve the click-id cookies to set on the current document response.\n *\n * `_fbc` follows Meta's documented conditional-write rule value-wise: a new fbclid (or an absent\n * cookie) opens a fresh 90-day window; a same-fbclid cookie keeps its original value and\n * `creationTime`. Expired (>90d) or malformed values are cleared instead of forwarded. By default,\n * ({@link ResolveClickIdCookiesInput.refresh}) a still-valid cookie is re-issued unchanged at its\n * *remaining* lifetime — never `now + 90d` — so a returning visitor's window cannot slide forward\n * (which is what makes Meta flag an expired fbclid).\n */\nexport function resolveClickIdCookies(\n input: ResolveClickIdCookiesInput\n): ResolveClickIdCookiesResult {\n const { url, cookieHeader, domain, secure = true, subdomainIndex = 1, refresh = true } = input;\n const now = input.now ?? Date.now();\n\n const params = searchParams(url);\n const jar = parseCookie(cookieHeader ?? '');\n const cookies: SetCookie[] = [];\n const result: ResolveClickIdCookiesResult = { cookies };\n\n const base = { path: '/', secure, sameSite: 'lax', domain: domain ?? undefined } as const;\n const set = (name: string, value: string, ttlMs: number) =>\n cookies.push({ name, value, maxAge: Math.floor(ttlMs / 1000), ...base });\n const del = (name: string) => cookies.push({ name, value: '', maxAge: 0, ...base });\n\n // --- Meta _fbc ---\n const urlFbclid = params.get('fbclid') || undefined;\n const existingFbc = parseFbc(jar[FBC_COOKIE], now);\n\n if (urlFbclid && urlFbclid !== existingFbc?.fbclid) {\n // A new click always wins and opens a fresh 90-day window.\n const raw = formatFbc(urlFbclid, now, subdomainIndex);\n set(FBC_COOKIE, raw, FBC_TTL_MS);\n result.fbc = raw;\n } else if (existingFbc) {\n const remainingMs = existingFbc.creationTime + FBC_TTL_MS - now;\n if (remainingMs <= 0) {\n del(FBC_COOKIE);\n } else {\n // Same fbclid: the value and creationTime are preserved (Meta's rule); refresh (default)\n // re-issues it unchanged at its remaining lifetime as an ITP self-heal.\n result.fbc = existingFbc.raw;\n if (refresh) set(FBC_COOKIE, existingFbc.raw, remainingMs);\n }\n } else if (jar[FBC_COOKIE]) {\n // Malformed leftover — clear it rather than forwarding it to Meta.\n del(FBC_COOKIE);\n }\n\n // --- Google Ads _gcl_aw / _gcl_gb ---\n // The same first-party HTTP persistence Google's own server-side Conversion Linker performs\n // (it sets FPGCLAW via Set-Cookie for 90 days), applied to gtag's cookies the way the sGTM\n // ecosystem does (stape Cookie Keeper re-issues _gcl_* over HTTP). Ownership is shared with\n // gtag, so the rules are stricter than for _fbc: a value this module cannot parse is left\n // untouched — never rewritten, never deleted — and a re-issue is byte-identical (labels tail\n // included) at the window's REMAINING lifetime, so the 90-day click window never slides.\n const gclsrc = params.get('gclsrc') || undefined;\n const google = [\n {\n cookie: GCL_AW_COOKIE,\n // gtag's own gating (`isGoogleAdsGclid`): a gclid enters _gcl_aw only when gclsrc is\n // absent or 'aw.ds' — 'ds'/'3p.ds' clicks are Search Ads 360's and belong to _gcl_dc.\n urlClickId: isGoogleAdsGclid(gclsrc) ? params.get('gclid') || undefined : undefined,\n assign: (value: string) => (result.gclid = value),\n },\n {\n cookie: GCL_GB_COOKIE,\n urlClickId: params.get('wbraid') || undefined,\n assign: (value: string) => (result.wbraid = value),\n },\n ];\n for (const { cookie, urlClickId, assign } of google) {\n const existing = parseGcl(jar[cookie], now);\n if (urlClickId && GCL_CLICK_ID.test(urlClickId) && urlClickId !== existing?.clickId) {\n // A new click always wins and opens a fresh 90-day window, in gtag's exact format.\n set(cookie, formatGcl(urlClickId, now), GCL_TTL_MS);\n assign(urlClickId);\n } else if (existing) {\n const remainingMs = existing.creationTime + GCL_TTL_MS - now;\n if (remainingMs > 0) {\n assign(existing.clickId);\n if (refresh) set(cookie, existing.raw, remainingMs);\n }\n // Expired: not returned and not re-issued, but gtag owns the deletion.\n }\n }\n\n // --- Reddit _rdt_cid / _rdt_uuid ---\n // Reddit's pixel.js rewrites both on every page load through `document.cookie` — the click id\n // from the URL, else the stored one, and the browser id — each for a fresh 90 days. So Reddit\n // slides the window itself, and the re-issue (default on, see `refresh`) does the same over\n // HTTP: without it the pixel's JS copy, capped at 7 days in Safari, is the only one left.\n const urlRdtCid = params.get('rdt_cid') || undefined;\n const existingRdtCid = jar[RDT_CID_COOKIE] || undefined;\n if (urlRdtCid && urlRdtCid !== existingRdtCid) {\n set(RDT_CID_COOKIE, urlRdtCid, RDT_CID_TTL_MS);\n result.rdt_cid = urlRdtCid;\n } else if (existingRdtCid) {\n result.rdt_cid = existingRdtCid;\n if (refresh) set(RDT_CID_COOKIE, existingRdtCid, RDT_CID_TTL_MS);\n }\n const existingRdtUuid = jar[RDT_UUID_COOKIE] || undefined;\n if (existingRdtUuid && refresh) set(RDT_UUID_COOKIE, existingRdtUuid, RDT_UUID_TTL_MS);\n\n // --- Meta _fbp ---\n // The pixel's browser id: created by the pixel, which rewrites it for 90 days on every page\n // load, as Reddit's does its own. Re-issued as it is, never created here.\n const existingFbp = jar[FBP_COOKIE] || undefined;\n if (existingFbp && refresh) set(FBP_COOKIE, existingFbp, FBP_TTL_MS);\n\n // --- OpenAI __oppref / __obref ---\n // oaiq writes `__oppref` only when the URL carries `oppref` (30 days), and `__obref` — its\n // browser reference — only when there is none (365 days); otherwise it reads them, through\n // `document.cookie`, so in Safari each is gone after 7 days and the browser starts over with a\n // new reference. The first is captured here from the URL as well, and both are re-issued as\n // they are, `__obref` never created. Unlike oaiq, the re-issue restarts their windows: their\n // values carry no creation time to count a remaining lifetime from, and OpenAI applies its own\n // attribution window to the click whatever the cookie's age. Nothing is written once the\n // visitor has opted out of oaiq, which deletes both cookies then.\n if (jar[OAIQ_CONSENT_COOKIE] !== 'false') {\n const urlOppref = params.get('oppref') || undefined;\n const existingOppref = jar[OPPREF_COOKIE] || undefined;\n if (urlOppref) set(OPPREF_COOKIE, urlOppref, OPPREF_TTL_MS);\n else if (existingOppref && refresh) set(OPPREF_COOKIE, existingOppref, OPPREF_TTL_MS);\n const existingObref = jar[OBREF_COOKIE] || undefined;\n if (existingObref && refresh) set(OBREF_COOKIE, existingObref, OBREF_TTL_MS);\n }\n\n // --- Microsoft Ads _uetmsclkid ---\n // The UET tag's own cookie, in its own format, so the tag and this module read each other's\n // writes. Microsoft's ITP answer is this first-party cookie (plus a localStorage backup), but\n // bat.js writes it through `document.cookie`, which Safari caps at 7 days — 24 hours on a\n // landing page decorated by a classified domain, and a bing.com ad click is exactly that.\n // Persisting it here over HTTP on the document response restores the 90-day window.\n //\n // The re-issue (default on, see `refresh`) is the same self-heal as for `_fbc`, and it matters\n // more here: bat.js rewrites this cookie on EVERY page load, so without the re-issue the HTTP\n // copy is downgraded to a JS cookie on the very next page. There is no embedded timestamp to\n // compute a remaining lifetime from, so it is re-issued at a fresh 90 days — which is exactly\n // what bat.js itself does on each page (`msClkIdExpirationTime` from now), so the window\n // slides no more than the tag already slides it. A value this module cannot parse belongs to\n // the tag: never rewritten, never deleted.\n const urlMsclkid = params.get('msclkid')?.trim();\n const existingMsclkid = parseUetMsclkid(jar[UET_MSCLKID_COOKIE]);\n if (urlMsclkid && MSCLKID.test(urlMsclkid) && urlMsclkid.toLowerCase() !== existingMsclkid) {\n set(UET_MSCLKID_COOKIE, formatUetMsclkid(urlMsclkid), MSCLKID_TTL_MS);\n result.msclkid = urlMsclkid.toLowerCase();\n } else if (existingMsclkid) {\n result.msclkid = existingMsclkid;\n if (refresh) set(UET_MSCLKID_COOKIE, formatUetMsclkid(existingMsclkid), MSCLKID_TTL_MS);\n }\n\n return result;\n}\n\n/** Serialize the resolved cookies into `Set-Cookie` header values. */\nexport function toSetCookieHeaders(cookies: SetCookie[]): string[] {\n return cookies.map((cookie) => stringifySetCookie(cookie));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,aAAa;AAEnB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AAErB,MAAM,iBAAiB;AAEvB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,MAAa,aAAa;AAC1B,MAAa,iBAAiB;AAC9B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;AAC7B,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAC/B,MAAa,aAAa;AAC1B,MAAa,gBAAgB;AAC7B,MAAa,eAAe;;AAE5B,MAAa,sBAAsB;;;;;;;;AAWnC,SAAgB,SACd,KACA,MAAc,KAAK,IAAI,GACA;CACvB,IAAI,CAAC,KAAK,OAAO,KAAA;CACjB,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,IAAI,MAAM,SAAS,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AAU,WAAW,YAAY;CAC1C,OAAO,IAAI,iBAAiB;EAC1B,OAAO,UAAU;EACjB,IAAI,SAAS,IAAI,oBAAoB,iBAAiB,eAAe,GAAG,cAAc;CACxF;CAEA,OAAO;AACT;;AAGA,SAAgB,mBAAmB,SAAgC;CACjE,OAAO,QAAQ,KAAK,cAAA,GAAWC,OAAAA,mBAAAA,CAAmBC,QAAM,CAAC;AAC3D"}
@@ -31,4 +31,5 @@ interface Props {
31
31
  }
32
32
  export declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, hotjarId, redditPixelId, linkedInPartnerId, uetTagId, uetCustomerId, uetConsent, facebookAppId, reportWebVitals }: Props): import("react").JSX.Element;
33
33
  //#endregion
34
+ export {};
34
35
  //# sourceMappingURL=index.d.cts.map
@@ -31,4 +31,5 @@ interface Props {
31
31
  }
32
32
  export declare function Analytics({ gaId, gaSrc, nonce, debugMode, metaPixelId, hotjarId, redditPixelId, linkedInPartnerId, uetTagId, uetCustomerId, uetConsent, facebookAppId, reportWebVitals }: Props): import("react").JSX.Element;
33
33
  //#endregion
34
+ export {};
34
35
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,8 @@
1
1
  //#region ../../node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.js
2
- var require_es5 = /* @__PURE__ */ require("../../../../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
2
+ var require_es5 = /* @__PURE__ */ require("../../../../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module, this$1) => {
3
3
  (function(e, t) {
4
4
  "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.bowser = t() : e.bowser = t();
5
- })(exports, (function() {
5
+ })(this$1, (function() {
6
6
  return function(e) {
7
7
  var t = {};
8
8
  function r(i) {