@shware/analytics 11.13.4 → 11.15.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.
package/README.md CHANGED
@@ -149,6 +149,20 @@ function Button() {
149
149
  }
150
150
  ```
151
151
 
152
+ ### Tracking an occurrence once (`trackOnce`)
153
+
154
+ 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:
155
+
156
+ ```ts
157
+ import { trackOnce } from '@shware/analytics';
158
+
159
+ trackOnce('purchase', properties, { key: checkoutSessionId });
160
+ ```
161
+
162
+ - `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.
163
+ - 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.
164
+ - 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.
165
+
152
166
  ## Page views
153
167
 
154
168
  `page_view` fires on a path or query change, never on a hash change — GA4's enhanced measurement,
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_setup_index = require("./setup/index.cjs");
3
3
  const require_visitor_id = require("./visitor/id.cjs");
4
4
  const require_track_index = require("./track/index.cjs");
5
+ const require_track_once = require("./track/once.cjs");
5
6
  const require_visitor_index = require("./visitor/index.cjs");
6
7
  const require_feedback_index = require("./feedback/index.cjs");
7
8
  const require_link_index = require("./link/index.cjs");
@@ -35,6 +36,7 @@ Object.defineProperty(exports, "stripeMinorUnits", {
35
36
  });
36
37
  exports.track = require_track_index.track;
37
38
  exports.trackAsync = require_track_index.trackAsync;
39
+ exports.trackOnce = require_track_once.trackOnce;
38
40
  exports.updateVisitorSchema = require_schema_index.updateVisitorSchema;
39
41
  exports.useTrackImpression = require_hooks_use_track_impression.useTrackImpression;
40
42
  exports.visitorId = require_visitor_id.visitorId;
package/dist/index.d.cts CHANGED
@@ -6,8 +6,9 @@ import { useTrackImpression } from "./hooks/use-track-impression.cjs";
6
6
  import { VisitorProperties } from "./visitor/types.cjs";
7
7
  import { setupAnalytics } from "./setup/index.cjs";
8
8
  import { sendBeacon, sendPendingEvents, track, trackAsync } from "./track/index.cjs";
9
+ import { TrackOnceOptions, trackOnce } from "./track/once.cjs";
9
10
  import { visitorId } from "./visitor/id.cjs";
10
11
  import { IDENTIFY_EVENT, setVisitor } from "./visitor/index.cjs";
11
12
  import { Link, createLink, getLink } from "./link/index.cjs";
12
13
  import { stripeMinorUnits } from "./utils/stripe.cjs";
13
- 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 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, updateVisitorSchema, useTrackImpression, visitorId };
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 };
package/dist/index.d.mts CHANGED
@@ -6,8 +6,9 @@ import { useTrackImpression } from "./hooks/use-track-impression.mjs";
6
6
  import { VisitorProperties } from "./visitor/types.mjs";
7
7
  import { setupAnalytics } from "./setup/index.mjs";
8
8
  import { sendBeacon, sendPendingEvents, track, trackAsync } from "./track/index.mjs";
9
+ import { TrackOnceOptions, trackOnce } from "./track/once.mjs";
9
10
  import { visitorId } from "./visitor/id.mjs";
10
11
  import { IDENTIFY_EVENT, setVisitor } from "./visitor/index.mjs";
11
12
  import { Link, createLink, getLink } from "./link/index.mjs";
12
13
  import { stripeMinorUnits } from "./utils/stripe.mjs";
13
- 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 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, updateVisitorSchema, useTrackImpression, visitorId };
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 };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { setupAnalytics } from "./setup/index.mjs";
2
2
  import { visitorId } from "./visitor/id.mjs";
3
3
  import { sendBeacon, sendPendingEvents, track, trackAsync } from "./track/index.mjs";
4
+ import { trackOnce } from "./track/once.mjs";
4
5
  import { IDENTIFY_EVENT, setVisitor } from "./visitor/index.mjs";
5
6
  import { sendFeedback } from "./feedback/index.mjs";
6
7
  import { createLink, getLink } from "./link/index.mjs";
@@ -8,4 +9,4 @@ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, createFeedbackSchema, createLinkSchema
8
9
  import { BOT_CATEGORIES, NOT_A_BOT, botOf } from "./bot/index.mjs";
9
10
  import { stripeMinorUnits } from "./utils/stripe.mjs";
10
11
  import { useTrackImpression } from "./hooks/use-track-impression.mjs";
11
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, BOT_CATEGORIES, IDENTIFY_EVENT, NOT_A_BOT, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, updateVisitorSchema, useTrackImpression, visitorId };
12
+ export { ALL_ENVIRONMENTS, ALL_PLATFORMS, BOT_CATEGORIES, IDENTIFY_EVENT, NOT_A_BOT, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, trackOnce, updateVisitorSchema, useTrackImpression, visitorId };
@@ -12,6 +12,16 @@ const MAX_PROPERTIES = 64;
12
12
  */
13
13
  const propertyText = (0, zod_mini.pipe)((0, zod_mini.string)(), (0, zod_mini.transform)((value) => value.slice(0, MAX_VALUE_LENGTH)));
14
14
  /**
15
+ * Tags are truncated for the same reason property values are, and they are stored more than once
16
+ * (on the event, the session and the visitor), so an unbounded one costs several times over.
17
+ * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of
18
+ * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones
19
+ * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and
20
+ * path — is the part that matters.
21
+ */
22
+ const MAX_TAG_LENGTH = 1024;
23
+ const tagText = (0, zod_mini.pipe)((0, zod_mini.string)(), (0, zod_mini.transform)((value) => value.slice(0, MAX_TAG_LENGTH)));
24
+ /**
15
25
  * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host
16
26
  * rather than something the visitor typed. It is still dropped rather than rejected, for the same
17
27
  * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a
@@ -56,92 +66,92 @@ const ALL_PLATFORMS = [
56
66
  ];
57
67
  const ALL_ENVIRONMENTS = ["development", "production"];
58
68
  const tagsSchema = (0, zod_mini.object)({
59
- os: (0, zod_mini.optional)((0, zod_mini.string)()),
60
- os_name: (0, zod_mini.optional)((0, zod_mini.string)()),
61
- os_version: (0, zod_mini.optional)((0, zod_mini.string)()),
62
- browser: (0, zod_mini.optional)((0, zod_mini.string)()),
63
- browser_name: (0, zod_mini.optional)((0, zod_mini.string)()),
64
- browser_version: (0, zod_mini.optional)((0, zod_mini.string)()),
65
- device: (0, zod_mini.optional)((0, zod_mini.string)()),
69
+ os: (0, zod_mini.optional)(tagText),
70
+ os_name: (0, zod_mini.optional)(tagText),
71
+ os_version: (0, zod_mini.optional)(tagText),
72
+ browser: (0, zod_mini.optional)(tagText),
73
+ browser_name: (0, zod_mini.optional)(tagText),
74
+ browser_version: (0, zod_mini.optional)(tagText),
75
+ device: (0, zod_mini.optional)(tagText),
66
76
  device_id: (0, zod_mini.optional)((0, zod_mini.string)().check((0, zod_mini.trim)(), (0, zod_mini.minLength)(1), (0, zod_mini.maxLength)(36))),
67
- device_type: (0, zod_mini.optional)((0, zod_mini.string)()),
68
- device_vendor: (0, zod_mini.optional)((0, zod_mini.string)()),
77
+ device_type: (0, zod_mini.optional)(tagText),
78
+ device_vendor: (0, zod_mini.optional)(tagText),
69
79
  device_pixel_ratio: (0, zod_mini.optional)((0, zod_mini.number)()),
70
80
  screen_width: (0, zod_mini.optional)((0, zod_mini.number)()),
71
81
  screen_height: (0, zod_mini.optional)((0, zod_mini.number)()),
72
82
  screen_resolution: (0, zod_mini.optional)((0, zod_mini.pipe)((0, zod_mini.string)().check((0, zod_mini.regex)(/^\d+x\d+$/)), (0, zod_mini.transform)((v) => v))),
73
83
  webdriver: (0, zod_mini.optional)((0, zod_mini.boolean)()),
74
- release: (0, zod_mini.optional)((0, zod_mini.string)()),
75
- language: (0, zod_mini.optional)((0, zod_mini.string)()),
76
- time_zone: (0, zod_mini.optional)((0, zod_mini.string)()),
77
- page_location: (0, zod_mini.optional)((0, zod_mini.string)()),
78
- page_referrer: (0, zod_mini.optional)((0, zod_mini.string)()),
79
- page_title: (0, zod_mini.optional)((0, zod_mini.string)()),
80
- page_load_id: (0, zod_mini.optional)((0, zod_mini.string)()),
84
+ release: (0, zod_mini.optional)(tagText),
85
+ language: (0, zod_mini.optional)(tagText),
86
+ time_zone: (0, zod_mini.optional)(tagText),
87
+ page_location: (0, zod_mini.optional)(tagText),
88
+ page_referrer: (0, zod_mini.optional)(tagText),
89
+ page_title: (0, zod_mini.optional)(tagText),
90
+ page_load_id: (0, zod_mini.optional)(tagText),
81
91
  /**
82
92
  * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients
83
93
  * still on an older SDK are not stripped of their page URL at this boundary — a browser
84
94
  * bundle stays cached long after a backend deploys. Remove once those clients are gone;
85
95
  * `pageLocation` in `server/page-location.ts` is the only reader.
86
96
  */
87
- source_url: (0, zod_mini.optional)((0, zod_mini.string)()),
88
- advertising_id: (0, zod_mini.optional)((0, zod_mini.string)()),
89
- install_referrer: (0, zod_mini.optional)((0, zod_mini.string)()),
90
- fbclid: (0, zod_mini.optional)((0, zod_mini.string)()),
91
- ad_id: (0, zod_mini.optional)((0, zod_mini.string)()),
92
- ad_name: (0, zod_mini.optional)((0, zod_mini.string)()),
93
- adset_id: (0, zod_mini.optional)((0, zod_mini.string)()),
94
- adset_name: (0, zod_mini.optional)((0, zod_mini.string)()),
95
- campaign_id: (0, zod_mini.optional)((0, zod_mini.string)()),
96
- campaign_name: (0, zod_mini.optional)((0, zod_mini.string)()),
97
- placement: (0, zod_mini.optional)((0, zod_mini.string)()),
98
- _fbc: (0, zod_mini.optional)((0, zod_mini.string)()),
99
- _fbp: (0, zod_mini.optional)((0, zod_mini.string)()),
97
+ source_url: (0, zod_mini.optional)(tagText),
98
+ advertising_id: (0, zod_mini.optional)(tagText),
99
+ install_referrer: (0, zod_mini.optional)(tagText),
100
+ fbclid: (0, zod_mini.optional)(tagText),
101
+ ad_id: (0, zod_mini.optional)(tagText),
102
+ ad_name: (0, zod_mini.optional)(tagText),
103
+ adset_id: (0, zod_mini.optional)(tagText),
104
+ adset_name: (0, zod_mini.optional)(tagText),
105
+ campaign_id: (0, zod_mini.optional)(tagText),
106
+ campaign_name: (0, zod_mini.optional)(tagText),
107
+ placement: (0, zod_mini.optional)(tagText),
108
+ _fbc: (0, zod_mini.optional)(tagText),
109
+ _fbp: (0, zod_mini.optional)(tagText),
100
110
  /**
101
111
  * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.
102
112
  * Accepted so that conversions from clients still on an older SDK keep their match keys; the
103
113
  * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are
104
114
  * gone.
105
115
  */
106
- fbc: (0, zod_mini.optional)((0, zod_mini.string)()),
107
- fbp: (0, zod_mini.optional)((0, zod_mini.string)()),
108
- rdt_uuid: (0, zod_mini.optional)((0, zod_mini.string)()),
109
- gclid: (0, zod_mini.optional)((0, zod_mini.string)()),
110
- gclsrc: (0, zod_mini.optional)((0, zod_mini.string)()),
111
- gad_source: (0, zod_mini.optional)((0, zod_mini.string)()),
112
- gad_campaignid: (0, zod_mini.optional)((0, zod_mini.string)()),
113
- network: (0, zod_mini.optional)((0, zod_mini.string)()),
114
- match_type: (0, zod_mini.optional)((0, zod_mini.string)()),
115
- wbraid: (0, zod_mini.optional)((0, zod_mini.string)()),
116
- gbraid: (0, zod_mini.optional)((0, zod_mini.string)()),
117
- dclid: (0, zod_mini.optional)((0, zod_mini.string)()),
118
- _gcl_aw: (0, zod_mini.optional)((0, zod_mini.string)()),
119
- _gcl_gb: (0, zod_mini.optional)((0, zod_mini.string)()),
120
- msclkid: (0, zod_mini.optional)((0, zod_mini.string)()),
121
- _uetmsclkid: (0, zod_mini.optional)((0, zod_mini.string)()),
122
- rdt_cid: (0, zod_mini.optional)((0, zod_mini.string)()),
123
- _rdt_cid: (0, zod_mini.optional)((0, zod_mini.string)()),
124
- _rdt_uuid: (0, zod_mini.optional)((0, zod_mini.string)()),
125
- li_fat_id: (0, zod_mini.optional)((0, zod_mini.string)()),
126
- _li_fat_id: (0, zod_mini.optional)((0, zod_mini.string)()),
127
- oppref: (0, zod_mini.optional)((0, zod_mini.string)()),
128
- __oppref: (0, zod_mini.optional)((0, zod_mini.string)()),
129
- __obref: (0, zod_mini.optional)((0, zod_mini.string)()),
130
- ko_click_id: (0, zod_mini.optional)((0, zod_mini.string)()),
131
- ScCid: (0, zod_mini.optional)((0, zod_mini.string)()),
132
- ttclid: (0, zod_mini.optional)((0, zod_mini.string)()),
133
- twclid: (0, zod_mini.optional)((0, zod_mini.string)()),
134
- yclid: (0, zod_mini.optional)((0, zod_mini.string)()),
135
- epik: (0, zod_mini.optional)((0, zod_mini.string)()),
136
- utm_source: (0, zod_mini.optional)((0, zod_mini.string)()),
137
- utm_medium: (0, zod_mini.optional)((0, zod_mini.string)()),
138
- utm_campaign: (0, zod_mini.optional)((0, zod_mini.string)()),
139
- utm_term: (0, zod_mini.optional)((0, zod_mini.string)()),
140
- utm_content: (0, zod_mini.optional)((0, zod_mini.string)()),
141
- utm_id: (0, zod_mini.optional)((0, zod_mini.string)()),
142
- utm_source_platform: (0, zod_mini.optional)((0, zod_mini.string)()),
143
- utm_creative_format: (0, zod_mini.optional)((0, zod_mini.string)()),
144
- utm_marketing_tactic: (0, zod_mini.optional)((0, zod_mini.string)())
116
+ fbc: (0, zod_mini.optional)(tagText),
117
+ fbp: (0, zod_mini.optional)(tagText),
118
+ rdt_uuid: (0, zod_mini.optional)(tagText),
119
+ gclid: (0, zod_mini.optional)(tagText),
120
+ gclsrc: (0, zod_mini.optional)(tagText),
121
+ gad_source: (0, zod_mini.optional)(tagText),
122
+ gad_campaignid: (0, zod_mini.optional)(tagText),
123
+ network: (0, zod_mini.optional)(tagText),
124
+ match_type: (0, zod_mini.optional)(tagText),
125
+ wbraid: (0, zod_mini.optional)(tagText),
126
+ gbraid: (0, zod_mini.optional)(tagText),
127
+ dclid: (0, zod_mini.optional)(tagText),
128
+ _gcl_aw: (0, zod_mini.optional)(tagText),
129
+ _gcl_gb: (0, zod_mini.optional)(tagText),
130
+ msclkid: (0, zod_mini.optional)(tagText),
131
+ _uetmsclkid: (0, zod_mini.optional)(tagText),
132
+ rdt_cid: (0, zod_mini.optional)(tagText),
133
+ _rdt_cid: (0, zod_mini.optional)(tagText),
134
+ _rdt_uuid: (0, zod_mini.optional)(tagText),
135
+ li_fat_id: (0, zod_mini.optional)(tagText),
136
+ _li_fat_id: (0, zod_mini.optional)(tagText),
137
+ oppref: (0, zod_mini.optional)(tagText),
138
+ __oppref: (0, zod_mini.optional)(tagText),
139
+ __obref: (0, zod_mini.optional)(tagText),
140
+ ko_click_id: (0, zod_mini.optional)(tagText),
141
+ ScCid: (0, zod_mini.optional)(tagText),
142
+ ttclid: (0, zod_mini.optional)(tagText),
143
+ twclid: (0, zod_mini.optional)(tagText),
144
+ yclid: (0, zod_mini.optional)(tagText),
145
+ epik: (0, zod_mini.optional)(tagText),
146
+ utm_source: (0, zod_mini.optional)(tagText),
147
+ utm_medium: (0, zod_mini.optional)(tagText),
148
+ utm_campaign: (0, zod_mini.optional)(tagText),
149
+ utm_term: (0, zod_mini.optional)(tagText),
150
+ utm_content: (0, zod_mini.optional)(tagText),
151
+ utm_id: (0, zod_mini.optional)(tagText),
152
+ utm_source_platform: (0, zod_mini.optional)(tagText),
153
+ utm_creative_format: (0, zod_mini.optional)(tagText),
154
+ utm_marketing_tactic: (0, zod_mini.optional)(tagText)
145
155
  });
146
156
  const propertiesSchema = (0, zod_mini.optional)((0, zod_mini.pipe)((0, zod_mini.record)((0, zod_mini.string)(), (0, zod_mini.union)([
147
157
  propertyText,
@@ -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 * 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(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\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(string()),\n language: optional(string()),\n time_zone: optional(string()),\n page_location: optional(string()),\n page_referrer: optional(string()),\n page_title: optional(string()),\n page_load_id: optional(string()),\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(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n _fbc: optional(string()),\n _fbp: optional(string()),\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(string()),\n fbp: optional(string()),\n rdt_uuid: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n network: optional(string()),\n match_type: optional(string()),\n wbraid: optional(string()),\n gbraid: optional(string()),\n dclid: optional(string()),\n _gcl_aw: optional(string()),\n _gcl_gb: optional(string()),\n // Microsoft Ads\n msclkid: optional(string()),\n _uetmsclkid: optional(string()),\n // Reddit Ads\n rdt_cid: optional(string()),\n _rdt_cid: optional(string()),\n _rdt_uuid: optional(string()),\n // LinkedIn Ads\n li_fat_id: optional(string()),\n _li_fat_id: optional(string()),\n // OpenAI Ads\n oppref: optional(string()),\n __oppref: optional(string()),\n __obref: optional(string()),\n // other click ids\n ko_click_id: optional(string()),\n ScCid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n yclid: optional(string()),\n epik: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\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,EAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;;;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,EAAAA,GACZG,SAAAA,MAAAA,EAAAA,GACEH,SAAAA,KAAAA,EAAAA,GACEI,SAAAA,OAAAA,EAAAA,GAAOH,SAAAA,OAAAA,CAAO,IAAA,GAAGI,SAAAA,MAAAA,CAAM;CAAC;EAAcC,GAAAA,SAAAA,OAAAA,CAAO;EAAGC,GAAAA,SAAAA,QAAAA,CAAQ;EAAGC,GAAAA,SAAAA,KAAAA,CAAM;AAAC,CAAC,CAAC,IAAA,GACpEN,SAAAA,UAAAA,CAAU,cAAc,CAC1B,CACF,IAAA,GACAA,SAAAA,UAAAA,EAAW,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC,CAC9C;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,cAAA,GAAaO,SAAAA,OAAAA,CAAO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AA,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"}
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,EAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;AAUA,MAAM,iBAAiB;AAEvB,MAAM,WAAA,GAAUF,SAAAA,K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