@shware/analytics 12.0.0 → 12.2.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 (76) hide show
  1. package/README.md +63 -1
  2. package/dist/index.d.cts +2 -2
  3. package/dist/index.d.mts +2 -2
  4. package/dist/native/firebase.cjs +7 -1
  5. package/dist/native/firebase.cjs.map +1 -1
  6. package/dist/native/firebase.d.cts +7 -1
  7. package/dist/native/firebase.d.cts.map +1 -1
  8. package/dist/native/firebase.d.mts +7 -1
  9. package/dist/native/firebase.d.mts.map +1 -1
  10. package/dist/native/firebase.mjs +7 -1
  11. package/dist/native/firebase.mjs.map +1 -1
  12. package/dist/schema/index.cjs +10 -2
  13. package/dist/schema/index.cjs.map +1 -1
  14. package/dist/schema/index.d.cts +3 -0
  15. package/dist/schema/index.d.cts.map +1 -1
  16. package/dist/schema/index.d.mts +3 -0
  17. package/dist/schema/index.d.mts.map +1 -1
  18. package/dist/schema/index.mjs +10 -2
  19. package/dist/schema/index.mjs.map +1 -1
  20. package/dist/third-parties/google-analytics.cjs +1 -1
  21. package/dist/third-parties/google-analytics.cjs.map +1 -1
  22. package/dist/third-parties/google-analytics.d.cts +1 -1
  23. package/dist/third-parties/google-analytics.d.mts +1 -1
  24. package/dist/third-parties/google-analytics.mjs +1 -1
  25. package/dist/third-parties/google-analytics.mjs.map +1 -1
  26. package/dist/third-parties/linkedin-insight-tag.cjs +1 -1
  27. package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
  28. package/dist/third-parties/linkedin-insight-tag.d.cts +1 -1
  29. package/dist/third-parties/linkedin-insight-tag.d.mts +1 -1
  30. package/dist/third-parties/linkedin-insight-tag.mjs +1 -1
  31. package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
  32. package/dist/third-parties/meta-pixel.cjs +1 -1
  33. package/dist/third-parties/meta-pixel.cjs.map +1 -1
  34. package/dist/third-parties/meta-pixel.d.cts +1 -1
  35. package/dist/third-parties/meta-pixel.d.mts +1 -1
  36. package/dist/third-parties/meta-pixel.mjs +1 -1
  37. package/dist/third-parties/meta-pixel.mjs.map +1 -1
  38. package/dist/third-parties/microsoft-uet.cjs +1 -1
  39. package/dist/third-parties/microsoft-uet.cjs.map +1 -1
  40. package/dist/third-parties/microsoft-uet.d.cts +1 -1
  41. package/dist/third-parties/microsoft-uet.d.mts +1 -1
  42. package/dist/third-parties/microsoft-uet.mjs +1 -1
  43. package/dist/third-parties/microsoft-uet.mjs.map +1 -1
  44. package/dist/third-parties/openai-pixel.cjs +1 -1
  45. package/dist/third-parties/openai-pixel.cjs.map +1 -1
  46. package/dist/third-parties/openai-pixel.d.cts +1 -1
  47. package/dist/third-parties/openai-pixel.d.mts +1 -1
  48. package/dist/third-parties/openai-pixel.mjs +1 -1
  49. package/dist/third-parties/openai-pixel.mjs.map +1 -1
  50. package/dist/third-parties/reddit-pixel.cjs +1 -1
  51. package/dist/third-parties/reddit-pixel.cjs.map +1 -1
  52. package/dist/third-parties/reddit-pixel.d.cts +1 -1
  53. package/dist/third-parties/reddit-pixel.d.mts +1 -1
  54. package/dist/third-parties/reddit-pixel.mjs +1 -1
  55. package/dist/third-parties/reddit-pixel.mjs.map +1 -1
  56. package/dist/track/index.cjs +77 -42
  57. package/dist/track/index.cjs.map +1 -1
  58. package/dist/track/index.d.cts +28 -4
  59. package/dist/track/index.d.cts.map +1 -1
  60. package/dist/track/index.d.mts +28 -4
  61. package/dist/track/index.d.mts.map +1 -1
  62. package/dist/track/index.mjs +77 -43
  63. package/dist/track/index.mjs.map +1 -1
  64. package/dist/track/once.cjs +65 -17
  65. package/dist/track/once.cjs.map +1 -1
  66. package/dist/track/once.d.cts +5 -4
  67. package/dist/track/once.d.cts.map +1 -1
  68. package/dist/track/once.d.mts +5 -4
  69. package/dist/track/once.d.mts.map +1 -1
  70. package/dist/track/once.mjs +66 -18
  71. package/dist/track/once.mjs.map +1 -1
  72. package/dist/track/types.d.cts +58 -5
  73. package/dist/track/types.d.cts.map +1 -1
  74. package/dist/track/types.d.mts +58 -5
  75. package/dist/track/types.d.mts.map +1 -1
  76. package/package.json +2 -2
package/README.md CHANGED
@@ -154,6 +154,51 @@ function Button() {
154
154
  }
155
155
  ```
156
156
 
157
+ ### Typed events and strict event names
158
+
159
+ An application types its own events, and adds properties to GA4's standard ones, by declaration merging into `CustomEventProperties` (see its doc comment). By default an event declared nowhere still compiles, with open properties, so `track('purchse', …)` or `track('begin_checkout ', …)` (a trailing space) quietly becomes a new event.
160
+
161
+ Turn on `strict` to make that a compile error. Merge it into `AnalyticsOptions`, preferably in the same file that declares `CustomEventProperties`, so the list of events and the rule that only they can be tracked live together:
162
+
163
+ ```ts
164
+ declare module '@shware/analytics' {
165
+ interface AnalyticsOptions {
166
+ strict: true;
167
+ }
168
+ interface CustomEventProperties {
169
+ plan_changed: { direction: 'upgrade' | 'downgrade' };
170
+ account_deleted: undefined; // an event with no properties
171
+ }
172
+ }
173
+ ```
174
+
175
+ With it on:
176
+
177
+ - Every function that takes an event name — `track`, `trackOnce`, `trackAsync`, `sendBeacon`, `useTrackImpression` and the third-party senders — accepts only GA4's standard events (`purchase`, `login`, `page_view`, …) and the keys of `CustomEventProperties`. Anything else is an error at the call site, so a new event has to be declared before it can be tracked.
178
+ - `TrackProperties` no longer falls back to the open `Record` for an undeclared event (there is none left to track); declared and standard events are typed exactly as before.
179
+
180
+ It is type-only: nothing changes at runtime, and without the merge the SDK behaves exactly as it always has.
181
+
182
+ ### When events reach the pixels and the server
183
+
184
+ Every event gets its id on the client, a uuidv7 generated by `track()` (and `trackOnce()`, `trackAsync()`) at the moment it is tracked. The same id goes to both places:
185
+
186
+ - **The pixels get it at once.** The third-party trackers you configure are called synchronously inside `track()`, with the id as their deduplication id (table below). They do not wait for the server, the 2 s batch window or a beacon, so an event right before a full-page navigation — an outbound link, `begin_checkout` before the redirect to Stripe, a landing page left at once — reaches the pixels before the page goes. A server that is down does not stop them either. A tracker whose pixel has not loaded yet (the SDK's trackers return `false` when their global — `fbq`, `rdt`, `gtag`, … — is missing) is called once more on the next macrotask, with the same event and id, once the inline snippets have run; one that is still missing then is skipped, as before.
187
+ - **The server gets it in the batch** (`id` in each event of `POST /events`), sent within 2 s, or right away by beacon when the page is hidden or left (`sendPendingEvents`, which the framework `Analytics` components call on `pagehide` and `visibilitychange`). A beacon fires no tracker again.
188
+
189
+ The server's conversions API, sending the stored event under the same id, then deduplicates against the browser event, as before.
190
+
191
+ | Tracker | Deduplication parameter the id is passed as |
192
+ | ------------------------------------------ | ------------------------------------------------ |
193
+ | Meta Pixel (`sendFBEvent`) | `eventID` (Conversions API `event_id`) |
194
+ | Reddit Pixel (`sendRedditEvent`) | `conversionId` (Conversions API `conversion_id`) |
195
+ | LinkedIn Insight Tag (`sendLinkedinEvent`) | `event_id` (Conversions API `eventId`) |
196
+ | Microsoft UET (`sendUETEvent`) | `event_id` (Conversions API `eventId`) |
197
+ | OpenAI pixel (`sendOpenAIEvent`) | `event_id` |
198
+ | GA4, PostHog, Firebase, Facebook SDK | not passed: they have no browser/server pairing |
199
+
200
+ `trackAsync` still sends at once and resolves once the server has answered (or the send was lost); await it when the next step needs the event stored. It is no longer needed to keep an event's pixels across a navigation: `track` does that.
201
+
157
202
  ### Tracking an occurrence once (`trackOnce`)
158
203
 
159
204
  A payment result page can be reloaded or reopened from history, and a store transaction can be delivered again; each would report the same `purchase` again. `trackOnce` takes the key that identifies the occurrence and tracks it at most once per key:
@@ -165,8 +210,9 @@ trackOnce('purchase', properties, { key: checkoutSessionId });
165
210
  ```
166
211
 
167
212
  - `key` is required and never derived from the properties; the same key under another event name is a different occurrence. `ttl` (ms, 90 days by default) is how long a sent key is remembered, up to the 20 latest keys per event.
168
- - The key is stored in the `storage` given to `setupAnalytics` only once the event has been sent, so a failed send is tried again by the next call; within one page a queued key is not queued twice. The record is plain JSON under `track_once.<event>`, e.g. `{"v":1,"entries":[["cs_test_a1B2c3",1799236800000]]}`; a storage that needs escaping (a cookie) escapes it itself.
213
+ - The key is stored in the `storage` given to `setupAnalytics` only once the event has been sent, so a failed send is tried again by the next call; within one page a queued key is not queued twice. The record is plain JSON under `track_once.<event>`, e.g. `{"v":2,"entries":[["cs_test_a1B2c3","019485d9-8b41-7000-8000-000000000003",1799236800000,true]]}` (key, event id, expiry, sent); a storage that needs escaping (a cookie) escapes it itself.
169
214
  - If the storage cannot be read or written the event is tracked anyway: a rare duplicate beats a lost conversion. Deduplication is per device, so exact figures such as revenue belong to server-side records.
215
+ - The pixels fire when the event is tracked, so a send that fails has already reported the occurrence to them. Each entry keeps the event id the key goes out under and whether it was sent; a call for a key that is remembered but not sent (a failed send, a page reloaded before its batch went out) reuses the id and fires no pixel again. Version 1 records (`[key, expiresAt]`) are read as sent keys.
170
216
 
171
217
  ## Page views
172
218
 
@@ -195,6 +241,22 @@ navigation do not advance the reporter's view history.
195
241
  - /analytics/tracks: track events
196
242
  - /analytics/visitor: app visitors
197
243
 
244
+ ## Events
245
+
246
+ `POST /events` takes a batch read by `createTrackEventSchema`. Since 12.1 every event carries `id`, the uuidv7 the client generated when it was tracked and gave the pixels (see "When events reach the pixels and the server"); the schema checks that it, `visitor_id` and `session_id` are version 7 uuids — all three are generated by the SDK, so the check lives here and the server need not repeat it. `id` is optional, for clients before 12.1. The server:
247
+
248
+ - **stores each event under its `id`**, generating one only when it is absent (an older client), and inserts with `on conflict (id) do nothing`. The batch request is retried by `fetch` on a network error, a 408, 429 or 5xx; a server that committed the batch and lost its answer receives it again, and the conflict clause makes that retry store nothing twice. Beacons are not retried, but a beacon and a send of the same queue cannot both happen. With Drizzle:
249
+
250
+ ```ts
251
+ const rows = events.map((e) => ({ id: e.id ?? uuidv7(), name: e.name /* , … */ }));
252
+ await tx.insert(event).values(rows).onConflictDoNothing({ target: event.id });
253
+ ```
254
+
255
+ A retried batch also forwards nothing twice when what you forward to (a journey engine, a conversions API) is keyed by the same id.
256
+
257
+ - **sends the stored id to the conversions APIs** as the event id, so they pair with the pixels the client fired under it.
258
+ - **answers one `{ id }` per event, in order** (`TrackEventResponse`), the stored ids. 12.1 clients no longer read the answer — any 2xx is a stored batch — but clients before 12.1 fire their pixels with the ids found there, so keep it while they are in use.
259
+
198
260
  ## Visitors
199
261
 
200
262
  Since 11.0 the SDK generates the visitor id itself — a uuidv7, kept in `config.storage` under
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AllowedPropertyValues, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.cjs";
1
+ import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.cjs";
2
2
  import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.cjs";
3
3
  import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.cjs";
4
4
  import { sendFeedback } from "./feedback/index.cjs";
@@ -11,4 +11,4 @@ import { visitorId } from "./visitor/id.cjs";
11
11
  import { IDENTIFY_EVENT, setVisitor } from "./visitor/index.cjs";
12
12
  import { Link, createLink, getLink } from "./link/index.cjs";
13
13
  import { stripeMinorUnits } from "./utils/stripe.cjs";
14
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, 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, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
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, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AllowedPropertyValues, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.mjs";
1
+ import { AllowedPropertyValues, AnalyticsOptions, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.mjs";
2
2
  import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.mjs";
3
3
  import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.mjs";
4
4
  import { sendFeedback } from "./feedback/index.mjs";
@@ -11,4 +11,4 @@ import { visitorId } from "./visitor/id.mjs";
11
11
  import { IDENTIFY_EVENT, setVisitor } from "./visitor/index.mjs";
12
12
  import { Link, createLink, getLink } from "./link/index.mjs";
13
13
  import { stripeMinorUnits } from "./utils/stripe.mjs";
14
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, 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, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
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, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
@@ -2,7 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _react_native_firebase_analytics = require("@react-native-firebase/analytics");
3
3
  //#region src/native/firebase.ts
4
4
  const analytics = (0, _react_native_firebase_analytics.getAnalytics)();
5
- async function sendFirebaseEvent(name, properties) {
5
+ /**
6
+ * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
7
+ * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
8
+ * (`false` meaning "not ready"), which an `async` function's promise would not satisfy. Callers
9
+ * that still `await` it keep compiling.
10
+ */
11
+ function sendFirebaseEvent(name, properties) {
6
12
  if (name === "screen_view") (0, _react_native_firebase_analytics.logEvent)(analytics, "screen_view", {
7
13
  firebase_screen: properties?.screen_name,
8
14
  firebase_screen_class: properties?.screen_class
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.cjs","names":["getAnalytics"],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import { getAnalytics, logEvent } from '@react-native-firebase/analytics';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nconst analytics = getAnalytics();\n\nexport async function sendFirebaseEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n // @react-native-firebase/analytics 26 made the modular logEvent fire-and-forget (void).\n // sendFirebaseEvent stays async so callers that await it keep compiling.\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"],"mappings":";;;AAIA,MAAM,aAAA,GAAYA,iCAAAA,aAAAA,CAAa;AAE/B,eAAsB,kBACpB,MACA,YACA;CAGA,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"}
1
+ {"version":3,"file":"firebase.cjs","names":["getAnalytics"],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import { getAnalytics, logEvent } from '@react-native-firebase/analytics';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\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"],"mappings":";;;AAIA,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"}
@@ -1,5 +1,11 @@
1
1
  import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
2
2
  //#region src/native/firebase.d.ts
3
- export declare function sendFirebaseEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): Promise<void>;
3
+ /**
4
+ * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
5
+ * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
6
+ * (`false` meaning "not ready"), which an `async` function's promise would not satisfy. Callers
7
+ * that still `await` it keep compiling.
8
+ */
9
+ export declare function sendFirebaseEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
4
10
  //#endregion
5
11
  //# sourceMappingURL=firebase.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.d.cts","names":[],"sources":["../../src/native/firebase.ts"],"mappings":";;wBAMsB,kBAAkB,UAAU,WAChD,MAAM,UAAU,IAChB,aAAa,gBAAgB,KAAE"}
1
+ {"version":3,"file":"firebase.d.cts","names":[],"sources":["../../src/native/firebase.ts"],"mappings":";;;;;;;;wBAYgB,kBAAkB,UAAU,WAC1C,MAAM,UAAU,IAChB,aAAa,gBAAgB"}
@@ -1,5 +1,11 @@
1
1
  import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
2
2
  //#region src/native/firebase.d.ts
3
- export declare function sendFirebaseEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): Promise<void>;
3
+ /**
4
+ * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
5
+ * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
6
+ * (`false` meaning "not ready"), which an `async` function's promise would not satisfy. Callers
7
+ * that still `await` it keep compiling.
8
+ */
9
+ export declare function sendFirebaseEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
4
10
  //#endregion
5
11
  //# sourceMappingURL=firebase.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.d.mts","names":[],"sources":["../../src/native/firebase.ts"],"mappings":";;wBAMsB,kBAAkB,UAAU,WAChD,MAAM,UAAU,IAChB,aAAa,gBAAgB,KAAE"}
1
+ {"version":3,"file":"firebase.d.mts","names":[],"sources":["../../src/native/firebase.ts"],"mappings":";;;;;;;;wBAYgB,kBAAkB,UAAU,WAC1C,MAAM,UAAU,IAChB,aAAa,gBAAgB"}
@@ -1,7 +1,13 @@
1
1
  import { getAnalytics, logEvent } from "@react-native-firebase/analytics";
2
2
  //#region src/native/firebase.ts
3
3
  const analytics = getAnalytics();
4
- async function sendFirebaseEvent(name, properties) {
4
+ /**
5
+ * A `ThirdPartyTracker` for Firebase Analytics. Synchronous: @react-native-firebase/analytics 26
6
+ * made the modular `logEvent` fire-and-forget (void), and a tracker's return is `void | boolean`
7
+ * (`false` meaning "not ready"), which an `async` function's promise would not satisfy. Callers
8
+ * that still `await` it keep compiling.
9
+ */
10
+ function sendFirebaseEvent(name, properties) {
5
11
  if (name === "screen_view") logEvent(analytics, "screen_view", {
6
12
  firebase_screen: properties?.screen_name,
7
13
  firebase_screen_class: properties?.screen_class
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.mjs","names":[],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import { getAnalytics, logEvent } from '@react-native-firebase/analytics';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\nconst analytics = getAnalytics();\n\nexport async function sendFirebaseEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n // @react-native-firebase/analytics 26 made the modular logEvent fire-and-forget (void).\n // sendFirebaseEvent stays async so callers that await it keep compiling.\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"],"mappings":";;AAIA,MAAM,YAAY,aAAa;AAE/B,eAAsB,kBACpB,MACA,YACA;CAGA,IAAI,SAAS,eACX,SAAS,WAAW,eAAe;EACjC,iBAAkB,YAA0D;EAC5E,uBAAwB,YACpB;CACN,CAAC;MAED,SAAS,WAAW,MAAM,UAAU;AAExC"}
1
+ {"version":3,"file":"firebase.mjs","names":[],"sources":["../../src/native/firebase.ts"],"sourcesContent":["import { getAnalytics, logEvent } from '@react-native-firebase/analytics';\nimport type { StandardEvents } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\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"],"mappings":";;AAIA,MAAM,YAAY,aAAa;;;;;;;AAQ/B,SAAgB,kBACd,MACA,YACA;CACA,IAAI,SAAS,eACX,SAAS,WAAW,eAAe;EACjC,iBAAkB,YAA0D;EAC5E,uBAAwB,YACpB;CACN,CAAC;MAED,SAAS,WAAW,MAAM,UAAU;AAExC"}
@@ -191,9 +191,17 @@ function alignClock(events, now = Date.now()) {
191
191
  });
192
192
  }
193
193
  const createTrackEventSchema = (0, zod_mini.pipe)((0, zod_mini.array)((0, zod_mini.object)({
194
+ /**
195
+ * The event's id, generated by the client when the event was tracked (12.1) and given to
196
+ * the browser pixels as their deduplication id. Store the event under it with
197
+ * `on conflict (id) do nothing`: a batch retried after the server committed it then
198
+ * stores nothing twice. Optional for clients before 12.1, which send none — generate one
199
+ * on the server for those.
200
+ */
201
+ id: (0, zod_mini.optional)((0, zod_mini.uuid)({ version: "v7" })),
194
202
  name: (0, zod_mini.string)().check((0, zod_mini.trim)(), (0, zod_mini.minLength)(1), (0, zod_mini.maxLength)(64)),
195
- visitor_id: (0, zod_mini.uuid)(),
196
- session_id: (0, zod_mini.uuid)(),
203
+ visitor_id: (0, zod_mini.uuid)({ version: "v7" }),
204
+ session_id: (0, zod_mini.uuid)({ version: "v7" }),
197
205
  platform: (0, zod_mini.enum)(ALL_PLATFORMS),
198
206
  environment: (0, zod_mini.enum)(ALL_ENVIRONMENTS),
199
207
  timestamp: zod_mini.iso.datetime(),
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["pipe","string","transform","array","record","union","number","boolean","_null","object","optional","trim","minLength","maxLength","regex","uuid","_enum","iso","toLowerCase","email","e164","toUpperCase","url"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Tags are truncated for the same reason property values are, and they are stored more than once\n * (on the event, the session and the visitor), so an unbounded one costs several times over.\n * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of\n * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones\n * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and\n * path — is the part that matters.\n */\nconst MAX_TAG_LENGTH = 1024;\n\nconst tagText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_TAG_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(tagText),\n os_name: optional(tagText),\n os_version: optional(tagText),\n browser: optional(tagText),\n browser_name: optional(tagText),\n browser_version: optional(tagText),\n device: optional(tagText),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(tagText),\n device_vendor: optional(tagText),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(tagText),\n language: optional(tagText),\n time_zone: optional(tagText),\n page_location: optional(tagText),\n page_referrer: optional(tagText),\n page_title: optional(tagText),\n page_load_id: optional(tagText),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy input from pre-7.0 clients must survive validation.\n source_url: optional(tagText),\n // app info\n advertising_id: optional(tagText),\n install_referrer: optional(tagText),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(tagText),\n ad_id: optional(tagText),\n ad_name: optional(tagText),\n adset_id: optional(tagText),\n adset_name: optional(tagText),\n campaign_id: optional(tagText),\n campaign_name: optional(tagText),\n placement: optional(tagText),\n _fbc: optional(tagText),\n _fbp: optional(tagText),\n /**\n * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.\n * Accepted so that conversions from clients still on an older SDK keep their match keys; the\n * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are\n * gone.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy pre-9.0 click-id fields must survive validation.\n fbc: optional(tagText),\n fbp: optional(tagText),\n rdt_uuid: optional(tagText),\n // Google Ads\n gclid: optional(tagText),\n gclsrc: optional(tagText),\n gad_source: optional(tagText),\n gad_campaignid: optional(tagText),\n network: optional(tagText),\n match_type: optional(tagText),\n wbraid: optional(tagText),\n gbraid: optional(tagText),\n dclid: optional(tagText),\n _gcl_aw: optional(tagText),\n _gcl_gb: optional(tagText),\n // Microsoft Ads\n msclkid: optional(tagText),\n _uetmsclkid: optional(tagText),\n // Reddit Ads\n rdt_cid: optional(tagText),\n _rdt_cid: optional(tagText),\n _rdt_uuid: optional(tagText),\n // LinkedIn Ads\n li_fat_id: optional(tagText),\n _li_fat_id: optional(tagText),\n // OpenAI Ads\n oppref: optional(tagText),\n __oppref: optional(tagText),\n __obref: optional(tagText),\n // other click ids\n ko_click_id: optional(tagText),\n ScCid: optional(tagText),\n ttclid: optional(tagText),\n twclid: optional(tagText),\n yclid: optional(tagText),\n epik: optional(tagText),\n // utm params\n utm_source: optional(tagText),\n utm_medium: optional(tagText),\n utm_campaign: optional(tagText),\n utm_term: optional(tagText),\n utm_content: optional(tagText),\n utm_id: optional(tagText),\n utm_source_platform: optional(tagText),\n utm_creative_format: optional(tagText),\n utm_marketing_tactic: optional(tagText),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\n/**\n * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id\n * itself and the server creates the visitor from its first events (README, \"Visitors\").\n * Kept for servers that still serve older clients.\n */\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n /**\n * Sent by clients before 11.1, which PATCHed their tags on every page load. From 11.1 the\n * server refreshes `visitor.tags` from each `session_start` — the moment the visit arrives —\n * and `setVisitor` sends none: at sign-in the page is no longer where the visit came in.\n */\n tags: optional(tagsSchema),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,gBAAA,GAAeA,SAAAA,KAAAA,EAAAA,GACnBC,SAAAA,OAAAA,CAAO,IAAA,GACPC,SAAAA,UAAAA,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;;;CAOnC,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,uBAAA,GAAsBA,SAAAA,SAAAA,CAAS,aAAa;AAC9C,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["pipe","string","transform","array","record","union","number","boolean","_null","object","optional","trim","minLength","maxLength","regex","uuid","_enum","iso","toLowerCase","email","e164","toUpperCase","url"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Tags are truncated for the same reason property values are, and they are stored more than once\n * (on the event, the session and the visitor), so an unbounded one costs several times over.\n * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of\n * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones\n * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and\n * path — is the part that matters.\n */\nconst MAX_TAG_LENGTH = 1024;\n\nconst tagText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_TAG_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(tagText),\n os_name: optional(tagText),\n os_version: optional(tagText),\n browser: optional(tagText),\n browser_name: optional(tagText),\n browser_version: optional(tagText),\n device: optional(tagText),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(tagText),\n device_vendor: optional(tagText),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(tagText),\n language: optional(tagText),\n time_zone: optional(tagText),\n page_location: optional(tagText),\n page_referrer: optional(tagText),\n page_title: optional(tagText),\n page_load_id: optional(tagText),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy input from pre-7.0 clients must survive validation.\n source_url: optional(tagText),\n // app info\n advertising_id: optional(tagText),\n install_referrer: optional(tagText),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(tagText),\n ad_id: optional(tagText),\n ad_name: optional(tagText),\n adset_id: optional(tagText),\n adset_name: optional(tagText),\n campaign_id: optional(tagText),\n campaign_name: optional(tagText),\n placement: optional(tagText),\n _fbc: optional(tagText),\n _fbp: optional(tagText),\n /**\n * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.\n * Accepted so that conversions from clients still on an older SDK keep their match keys; the\n * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are\n * gone.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy pre-9.0 click-id fields must survive validation.\n fbc: optional(tagText),\n fbp: optional(tagText),\n rdt_uuid: optional(tagText),\n // Google Ads\n gclid: optional(tagText),\n gclsrc: optional(tagText),\n gad_source: optional(tagText),\n gad_campaignid: optional(tagText),\n network: optional(tagText),\n match_type: optional(tagText),\n wbraid: optional(tagText),\n gbraid: optional(tagText),\n dclid: optional(tagText),\n _gcl_aw: optional(tagText),\n _gcl_gb: optional(tagText),\n // Microsoft Ads\n msclkid: optional(tagText),\n _uetmsclkid: optional(tagText),\n // Reddit Ads\n rdt_cid: optional(tagText),\n _rdt_cid: optional(tagText),\n _rdt_uuid: optional(tagText),\n // LinkedIn Ads\n li_fat_id: optional(tagText),\n _li_fat_id: optional(tagText),\n // OpenAI Ads\n oppref: optional(tagText),\n __oppref: optional(tagText),\n __obref: optional(tagText),\n // other click ids\n ko_click_id: optional(tagText),\n ScCid: optional(tagText),\n ttclid: optional(tagText),\n twclid: optional(tagText),\n yclid: optional(tagText),\n epik: optional(tagText),\n // utm params\n utm_source: optional(tagText),\n utm_medium: optional(tagText),\n utm_campaign: optional(tagText),\n utm_term: optional(tagText),\n utm_content: optional(tagText),\n utm_id: optional(tagText),\n utm_source_platform: optional(tagText),\n utm_creative_format: optional(tagText),\n utm_marketing_tactic: optional(tagText),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n /**\n * The event's id, generated by the client when the event was tracked (12.1) and given to\n * the browser pixels as their deduplication id. Store the event under it with\n * `on conflict (id) do nothing`: a batch retried after the server committed it then\n * stores nothing twice. Optional for clients before 12.1, which send none — generate one\n * on the server for those.\n */\n id: optional(uuid({ version: 'v7' })),\n name: string().check(trim(), minLength(1), maxLength(64)),\n // Generated by the SDK, like `id` (`visitorId()`, `Session`): uuidv7 as well, so the\n // constraint is checked here once and the server need not check it again.\n visitor_id: uuid({ version: 'v7' }),\n session_id: uuid({ version: 'v7' }),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\n/**\n * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id\n * itself and the server creates the visitor from its first events (README, \"Visitors\").\n * Kept for servers that still serve older clients.\n */\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n /**\n * Sent by clients before 11.1, which PATCHed their tags on every page load. From 11.1 the\n * server refreshes `visitor.tags` from each `session_start` — the moment the visit arrives —\n * and `setVisitor` sends none: at sign-in the page is no longer where the visit came in.\n */\n tags: optional(tagsSchema),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,gBAAA,GAAeA,SAAAA,KAAAA,EAAAA,GACnBC,SAAAA,OAAAA,CAAO,IAAA,GACPC,SAAAA,UAAAA,EAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;AAUA,MAAM,iBAAiB;AAEvB,MAAM,WAAA,GAAUF,SAAAA,KAAAA,EAAAA,GACdC,SAAAA,OAAAA,CAAO,IAAA,GACPC,SAAAA,UAAAA,EAAW,UAAU,MAAM,MAAM,GAAG,cAAc,CAAC,CACrD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CACnC,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,SAAS,gBAAgB;EAC7B,MAAM,MAAM,OAAO,KAAK;EACxB,IAAI,CAAC,OAAO,IAAI,SAAS,gBAAgB;EACzC,OAAO,OAAO;EACd;CACF;CACA,OAAO;AACT;;;;;;AAOA,MAAM,YAAY;AAElB,MAAM,SAAA,GAAQF,SAAAA,KAAAA,EAAA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,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,oBAAA,GAAmBO,SAAAA,OAAAA,CAAO;;CAErC,MAAA,GAAKa,SAAAA,IAAAA,CAAI,CAAC,CAAC,OAAA,GAAMV,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,IAAI,CAAC;;;;;CAM9C,SAAA,GAAQH,SAAAA,SAAAA,CAAS,aAAa;;CAG9B,aAAA,GAAYT,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGvD,aAAA,GAAYZ,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGvD,eAAA,GAAcZ,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGzD,WAAA,GAAUH,SAAAA,SAAAA,CAAS,aAAa;;;;;;CAOhC,cAAA,GAAaA,SAAAA,SAAAA,CAAS,aAAa;;;;;;CAOnC,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,uBAAA,GAAsBA,SAAAA,SAAAA,CAAS,aAAa;AAC9C,CAAC"}
@@ -80,6 +80,7 @@ export declare const tagsSchema: z.ZodMiniObject<{
80
80
  }, z.core.$strip>;
81
81
  export declare const propertiesSchema: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
82
82
  export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniObject<{
83
+ id: z.ZodMiniOptional<z.ZodMiniUUID>;
83
84
  name: z.ZodMiniString<string>;
84
85
  visitor_id: z.ZodMiniUUID;
85
86
  session_id: z.ZodMiniUUID;
@@ -175,6 +176,7 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
175
176
  }, z.core.$strip>;
176
177
  properties: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
177
178
  }, z.core.$strip>>, z.ZodMiniTransform<{
179
+ id?: string | undefined;
178
180
  name: string;
179
181
  visitor_id: string;
180
182
  session_id: string;
@@ -259,6 +261,7 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
259
261
  };
260
262
  properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
261
263
  }[], {
264
+ id?: string | undefined;
262
265
  name: string;
263
266
  visitor_id: string;
264
267
  session_id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAkGa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGrB,EAAA,KAAA;qBAEW,kBAAgB,EAAA,gBAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,aAAA,EAAA,YAAA,EAAA,aAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,gBAAA,EAAA,iBAAA,kDAAA,qDAAA,EAAA,iBAAA,oDAAA,yDAAA,EAAA,iBAAA,2CAAA,4DAAA,2CAAA;qBAoChB,wBAAsB,EAAA,YAAA,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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sSchema: z.ZodMiniObject<{
80
80
  }, z.core.$strip>;
81
81
  export declare const propertiesSchema: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
82
82
  export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniObject<{
83
+ id: z.ZodMiniOptional<z.ZodMiniUUID>;
83
84
  name: z.ZodMiniString<string>;
84
85
  visitor_id: z.ZodMiniUUID;
85
86
  session_id: z.ZodMiniUUID;
@@ -175,6 +176,7 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
175
176
  }, z.core.$strip>;
176
177
  properties: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
177
178
  }, z.core.$strip>>, z.ZodMiniTransform<{
179
+ id?: string | undefined;
178
180
  name: string;
179
181
  visitor_id: string;
180
182
  session_id: string;
@@ -259,6 +261,7 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
259
261
  };
260
262
  properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
261
263
  }[], {
264
+ id?: string | undefined;
262
265
  name: string;
263
266
  visitor_id: string;
264
267
  session_id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAkGa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGrB,EAAA,KAAA;qBAEW,kBAAgB,EAAA,gBAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,aAAA,EAAA,YAAA,EAAA,aAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,gBAAA,EAAA,iBAAA,kDAAA,qDAAA,EAAA,iBAAA,oDAAA,yDAAA,EAAA,iBAAA,2CAA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gB,EAAA;;;;;;;;;;;GA+C3B,EAAA,KAAA;YAEU,sBAAsB,EAAE,cAAc;YACtC,oBAAoB,EAAE,cAAc;YACpC,gBAAgB,EAAE,cAAc;YAChC,mBAAmB,EAAE,cAAc;YACnC,sBAAsB,EAAE,cAAc;YACtC,mBAAmB,EAAE,cAAc"}
@@ -190,9 +190,17 @@ function alignClock(events, now = Date.now()) {
190
190
  });
191
191
  }
192
192
  const createTrackEventSchema = pipe(array(object({
193
+ /**
194
+ * The event's id, generated by the client when the event was tracked (12.1) and given to
195
+ * the browser pixels as their deduplication id. Store the event under it with
196
+ * `on conflict (id) do nothing`: a batch retried after the server committed it then
197
+ * stores nothing twice. Optional for clients before 12.1, which send none — generate one
198
+ * on the server for those.
199
+ */
200
+ id: optional(uuid({ version: "v7" })),
193
201
  name: string().check(trim(), minLength(1), maxLength(64)),
194
- visitor_id: uuid(),
195
- session_id: uuid(),
202
+ visitor_id: uuid({ version: "v7" }),
203
+ session_id: uuid({ version: "v7" }),
196
204
  platform: enum$1(ALL_PLATFORMS),
197
205
  environment: enum$1(ALL_ENVIRONMENTS),
198
206
  timestamp: iso.datetime(),
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Tags are truncated for the same reason property values are, and they are stored more than once\n * (on the event, the session and the visitor), so an unbounded one costs several times over.\n * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of\n * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones\n * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and\n * path — is the part that matters.\n */\nconst MAX_TAG_LENGTH = 1024;\n\nconst tagText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_TAG_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(tagText),\n os_name: optional(tagText),\n os_version: optional(tagText),\n browser: optional(tagText),\n browser_name: optional(tagText),\n browser_version: optional(tagText),\n device: optional(tagText),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(tagText),\n device_vendor: optional(tagText),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(tagText),\n language: optional(tagText),\n time_zone: optional(tagText),\n page_location: optional(tagText),\n page_referrer: optional(tagText),\n page_title: optional(tagText),\n page_load_id: optional(tagText),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy input from pre-7.0 clients must survive validation.\n source_url: optional(tagText),\n // app info\n advertising_id: optional(tagText),\n install_referrer: optional(tagText),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(tagText),\n ad_id: optional(tagText),\n ad_name: optional(tagText),\n adset_id: optional(tagText),\n adset_name: optional(tagText),\n campaign_id: optional(tagText),\n campaign_name: optional(tagText),\n placement: optional(tagText),\n _fbc: optional(tagText),\n _fbp: optional(tagText),\n /**\n * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.\n * Accepted so that conversions from clients still on an older SDK keep their match keys; the\n * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are\n * gone.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy pre-9.0 click-id fields must survive validation.\n fbc: optional(tagText),\n fbp: optional(tagText),\n rdt_uuid: optional(tagText),\n // Google Ads\n gclid: optional(tagText),\n gclsrc: optional(tagText),\n gad_source: optional(tagText),\n gad_campaignid: optional(tagText),\n network: optional(tagText),\n match_type: optional(tagText),\n wbraid: optional(tagText),\n gbraid: optional(tagText),\n dclid: optional(tagText),\n _gcl_aw: optional(tagText),\n _gcl_gb: optional(tagText),\n // Microsoft Ads\n msclkid: optional(tagText),\n _uetmsclkid: optional(tagText),\n // Reddit Ads\n rdt_cid: optional(tagText),\n _rdt_cid: optional(tagText),\n _rdt_uuid: optional(tagText),\n // LinkedIn Ads\n li_fat_id: optional(tagText),\n _li_fat_id: optional(tagText),\n // OpenAI Ads\n oppref: optional(tagText),\n __oppref: optional(tagText),\n __obref: optional(tagText),\n // other click ids\n ko_click_id: optional(tagText),\n ScCid: optional(tagText),\n ttclid: optional(tagText),\n twclid: optional(tagText),\n yclid: optional(tagText),\n epik: optional(tagText),\n // utm params\n utm_source: optional(tagText),\n utm_medium: optional(tagText),\n utm_campaign: optional(tagText),\n utm_term: optional(tagText),\n utm_content: optional(tagText),\n utm_id: optional(tagText),\n utm_source_platform: optional(tagText),\n utm_creative_format: optional(tagText),\n utm_marketing_tactic: optional(tagText),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\n/**\n * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id\n * itself and the server creates the visitor from its first events (README, \"Visitors\").\n * Kept for servers that still serve older clients.\n */\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n /**\n * Sent by clients before 11.1, which PATCHed their tags on every page load. From 11.1 the\n * server refreshes `visitor.tags` from each `session_start` — the moment the visit arrives —\n * and `setVisitor` sends none: at sign-in the page is no longer where the visit came in.\n */\n tags: optional(tagsSchema),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,eAAe,KACnB,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;AAUA,MAAM,iBAAiB;AAEvB,MAAM,UAAU,KACd,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,cAAc,CAAC,CACrD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CACnC,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,SAAS,gBAAgB;EAC7B,MAAM,MAAM,OAAO,KAAK;EACxB,IAAI,CAAC,OAAO,IAAI,SAAS,gBAAgB;EACzC,OAAO,OAAO;EACd;CACF;CACA,OAAO;AACT;;;;;;AAOA,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AED,MAAa,sBAAsB,OAAO;CACxC,SAAS,SAAS,KAAK,CAAC;CACxB,WAAW,SAAS,sBAAsB;;;;;;CAM1C,MAAM,SAAS,UAAU;AAC3B,CAAC;AAED,MAAa,uBAAuB,OAAO;CACzC,MAAM,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;CACjD,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CACnC,SAAS,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,KAAK,CAAC;AACxD,CAAC;AAED,MAAM,gBAAgB,KACpB,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC,GAC7B,WAAW,MAAO,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,mBAAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Tags are truncated for the same reason property values are, and they are stored more than once\n * (on the event, the session and the visitor), so an unbounded one costs several times over.\n * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of\n * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones\n * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and\n * path — is the part that matters.\n */\nconst MAX_TAG_LENGTH = 1024;\n\nconst tagText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_TAG_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(tagText),\n os_name: optional(tagText),\n os_version: optional(tagText),\n browser: optional(tagText),\n browser_name: optional(tagText),\n browser_version: optional(tagText),\n device: optional(tagText),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(tagText),\n device_vendor: optional(tagText),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(tagText),\n language: optional(tagText),\n time_zone: optional(tagText),\n page_location: optional(tagText),\n page_referrer: optional(tagText),\n page_title: optional(tagText),\n page_load_id: optional(tagText),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy input from pre-7.0 clients must survive validation.\n source_url: optional(tagText),\n // app info\n advertising_id: optional(tagText),\n install_referrer: optional(tagText),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(tagText),\n ad_id: optional(tagText),\n ad_name: optional(tagText),\n adset_id: optional(tagText),\n adset_name: optional(tagText),\n campaign_id: optional(tagText),\n campaign_name: optional(tagText),\n placement: optional(tagText),\n _fbc: optional(tagText),\n _fbp: optional(tagText),\n /**\n * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.\n * Accepted so that conversions from clients still on an older SDK keep their match keys; the\n * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are\n * gone.\n */\n // oxlint-disable-next-line typescript/no-deprecated -- Legacy pre-9.0 click-id fields must survive validation.\n fbc: optional(tagText),\n fbp: optional(tagText),\n rdt_uuid: optional(tagText),\n // Google Ads\n gclid: optional(tagText),\n gclsrc: optional(tagText),\n gad_source: optional(tagText),\n gad_campaignid: optional(tagText),\n network: optional(tagText),\n match_type: optional(tagText),\n wbraid: optional(tagText),\n gbraid: optional(tagText),\n dclid: optional(tagText),\n _gcl_aw: optional(tagText),\n _gcl_gb: optional(tagText),\n // Microsoft Ads\n msclkid: optional(tagText),\n _uetmsclkid: optional(tagText),\n // Reddit Ads\n rdt_cid: optional(tagText),\n _rdt_cid: optional(tagText),\n _rdt_uuid: optional(tagText),\n // LinkedIn Ads\n li_fat_id: optional(tagText),\n _li_fat_id: optional(tagText),\n // OpenAI Ads\n oppref: optional(tagText),\n __oppref: optional(tagText),\n __obref: optional(tagText),\n // other click ids\n ko_click_id: optional(tagText),\n ScCid: optional(tagText),\n ttclid: optional(tagText),\n twclid: optional(tagText),\n yclid: optional(tagText),\n epik: optional(tagText),\n // utm params\n utm_source: optional(tagText),\n utm_medium: optional(tagText),\n utm_campaign: optional(tagText),\n utm_term: optional(tagText),\n utm_content: optional(tagText),\n utm_id: optional(tagText),\n utm_source_platform: optional(tagText),\n utm_creative_format: optional(tagText),\n utm_marketing_tactic: optional(tagText),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n /**\n * The event's id, generated by the client when the event was tracked (12.1) and given to\n * the browser pixels as their deduplication id. Store the event under it with\n * `on conflict (id) do nothing`: a batch retried after the server committed it then\n * stores nothing twice. Optional for clients before 12.1, which send none — generate one\n * on the server for those.\n */\n id: optional(uuid({ version: 'v7' })),\n name: string().check(trim(), minLength(1), maxLength(64)),\n // Generated by the SDK, like `id` (`visitorId()`, `Session`): uuidv7 as well, so the\n // constraint is checked here once and the server need not check it again.\n visitor_id: uuid({ version: 'v7' }),\n session_id: uuid({ version: 'v7' }),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\n/**\n * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id\n * itself and the server creates the visitor from its first events (README, \"Visitors\").\n * Kept for servers that still serve older clients.\n */\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n /**\n * Sent by clients before 11.1, which PATCHed their tags on every page load. From 11.1 the\n * server refreshes `visitor.tags` from each `session_start` — the moment the visit arrives —\n * and `setVisitor` sends none: at sign-in the page is no longer where the visit came in.\n */\n tags: optional(tagsSchema),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,i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AG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  function sendGAEvent(name, properties) {
4
4
  if (typeof window === "undefined" || !window.gtag) {
5
5
  console.warn("GA has not been initialized");
6
- return;
6
+ return false;
7
7
  }
8
8
  window.gtag("event", name, properties);
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n"],"mappings":";;AAWA,SAAgB,YACd,MACA,YACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,aAA+B;CAClE,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;AAC1D"}
1
+ {"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return false;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n"],"mappings":";;AAWA,SAAgB,YACd,MACA,YACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C,OAAO;CACT;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,aAA+B;CAClE,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;AAC1D"}
@@ -8,7 +8,7 @@ declare global {
8
8
  gtag?: Gtag['gtag'];
9
9
  }
10
10
  }
11
- export declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
11
+ export declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): false | undefined;
12
12
  export declare function setGAUser({ user_id, user_data }: UpdateVisitorDTO): void;
13
13
  //#endregion
14
14
  //# sourceMappingURL=google-analytics.d.cts.map