@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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqBtB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqBtB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK9B,EAAA,KAAA;;;;;;;;;;;qBA6BW,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;GAIjC,EAAA,KAAA;qBAEW,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS9B,EAAA,KAAA;qBAEW,sBAAoB,EAAA;;;;GAI/B,EAAA,KAAA;;;;;qBAWW,kBAAgB,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"}
@@ -11,6 +11,16 @@ const MAX_PROPERTIES = 64;
11
11
  */
12
12
  const propertyText = pipe(string(), transform((value) => value.slice(0, MAX_VALUE_LENGTH)));
13
13
  /**
14
+ * Tags are truncated for the same reason property values are, and they are stored more than once
15
+ * (on the event, the session and the visitor), so an unbounded one costs several times over.
16
+ * 1024 sits just above what GA4 itself keeps (1000 characters of page_location, 420 of
17
+ * page_referrer, 300 of page_title). Real tags stay under ~500 characters; the rare longer ones
18
+ * are page_referrer values from search and ad redirect URLs, where the kept prefix — host and
19
+ * path — is the part that matters.
20
+ */
21
+ const MAX_TAG_LENGTH = 1024;
22
+ const tagText = pipe(string(), transform((value) => value.slice(0, MAX_TAG_LENGTH)));
23
+ /**
14
24
  * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host
15
25
  * rather than something the visitor typed. It is still dropped rather than rejected, for the same
16
26
  * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a
@@ -55,92 +65,92 @@ const ALL_PLATFORMS = [
55
65
  ];
56
66
  const ALL_ENVIRONMENTS = ["development", "production"];
57
67
  const tagsSchema = object({
58
- os: optional(string()),
59
- os_name: optional(string()),
60
- os_version: optional(string()),
61
- browser: optional(string()),
62
- browser_name: optional(string()),
63
- browser_version: optional(string()),
64
- device: optional(string()),
68
+ os: optional(tagText),
69
+ os_name: optional(tagText),
70
+ os_version: optional(tagText),
71
+ browser: optional(tagText),
72
+ browser_name: optional(tagText),
73
+ browser_version: optional(tagText),
74
+ device: optional(tagText),
65
75
  device_id: optional(string().check(trim(), minLength(1), maxLength(36))),
66
- device_type: optional(string()),
67
- device_vendor: optional(string()),
76
+ device_type: optional(tagText),
77
+ device_vendor: optional(tagText),
68
78
  device_pixel_ratio: optional(number()),
69
79
  screen_width: optional(number()),
70
80
  screen_height: optional(number()),
71
81
  screen_resolution: optional(pipe(string().check(regex(/^\d+x\d+$/)), transform((v) => v))),
72
82
  webdriver: optional(boolean()),
73
- release: optional(string()),
74
- language: optional(string()),
75
- time_zone: optional(string()),
76
- page_location: optional(string()),
77
- page_referrer: optional(string()),
78
- page_title: optional(string()),
79
- page_load_id: optional(string()),
83
+ release: optional(tagText),
84
+ language: optional(tagText),
85
+ time_zone: optional(tagText),
86
+ page_location: optional(tagText),
87
+ page_referrer: optional(tagText),
88
+ page_title: optional(tagText),
89
+ page_load_id: optional(tagText),
80
90
  /**
81
91
  * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients
82
92
  * still on an older SDK are not stripped of their page URL at this boundary — a browser
83
93
  * bundle stays cached long after a backend deploys. Remove once those clients are gone;
84
94
  * `pageLocation` in `server/page-location.ts` is the only reader.
85
95
  */
86
- source_url: optional(string()),
87
- advertising_id: optional(string()),
88
- install_referrer: optional(string()),
89
- fbclid: optional(string()),
90
- ad_id: optional(string()),
91
- ad_name: optional(string()),
92
- adset_id: optional(string()),
93
- adset_name: optional(string()),
94
- campaign_id: optional(string()),
95
- campaign_name: optional(string()),
96
- placement: optional(string()),
97
- _fbc: optional(string()),
98
- _fbp: optional(string()),
96
+ source_url: optional(tagText),
97
+ advertising_id: optional(tagText),
98
+ install_referrer: optional(tagText),
99
+ fbclid: optional(tagText),
100
+ ad_id: optional(tagText),
101
+ ad_name: optional(tagText),
102
+ adset_id: optional(tagText),
103
+ adset_name: optional(tagText),
104
+ campaign_id: optional(tagText),
105
+ campaign_name: optional(tagText),
106
+ placement: optional(tagText),
107
+ _fbc: optional(tagText),
108
+ _fbp: optional(tagText),
99
109
  /**
100
110
  * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.
101
111
  * Accepted so that conversions from clients still on an older SDK keep their match keys; the
102
112
  * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are
103
113
  * gone.
104
114
  */
105
- fbc: optional(string()),
106
- fbp: optional(string()),
107
- rdt_uuid: optional(string()),
108
- gclid: optional(string()),
109
- gclsrc: optional(string()),
110
- gad_source: optional(string()),
111
- gad_campaignid: optional(string()),
112
- network: optional(string()),
113
- match_type: optional(string()),
114
- wbraid: optional(string()),
115
- gbraid: optional(string()),
116
- dclid: optional(string()),
117
- _gcl_aw: optional(string()),
118
- _gcl_gb: optional(string()),
119
- msclkid: optional(string()),
120
- _uetmsclkid: optional(string()),
121
- rdt_cid: optional(string()),
122
- _rdt_cid: optional(string()),
123
- _rdt_uuid: optional(string()),
124
- li_fat_id: optional(string()),
125
- _li_fat_id: optional(string()),
126
- oppref: optional(string()),
127
- __oppref: optional(string()),
128
- __obref: optional(string()),
129
- ko_click_id: optional(string()),
130
- ScCid: optional(string()),
131
- ttclid: optional(string()),
132
- twclid: optional(string()),
133
- yclid: optional(string()),
134
- epik: optional(string()),
135
- utm_source: optional(string()),
136
- utm_medium: optional(string()),
137
- utm_campaign: optional(string()),
138
- utm_term: optional(string()),
139
- utm_content: optional(string()),
140
- utm_id: optional(string()),
141
- utm_source_platform: optional(string()),
142
- utm_creative_format: optional(string()),
143
- utm_marketing_tactic: optional(string())
115
+ fbc: optional(tagText),
116
+ fbp: optional(tagText),
117
+ rdt_uuid: optional(tagText),
118
+ gclid: optional(tagText),
119
+ gclsrc: optional(tagText),
120
+ gad_source: optional(tagText),
121
+ gad_campaignid: optional(tagText),
122
+ network: optional(tagText),
123
+ match_type: optional(tagText),
124
+ wbraid: optional(tagText),
125
+ gbraid: optional(tagText),
126
+ dclid: optional(tagText),
127
+ _gcl_aw: optional(tagText),
128
+ _gcl_gb: optional(tagText),
129
+ msclkid: optional(tagText),
130
+ _uetmsclkid: optional(tagText),
131
+ rdt_cid: optional(tagText),
132
+ _rdt_cid: optional(tagText),
133
+ _rdt_uuid: optional(tagText),
134
+ li_fat_id: optional(tagText),
135
+ _li_fat_id: optional(tagText),
136
+ oppref: optional(tagText),
137
+ __oppref: optional(tagText),
138
+ __obref: optional(tagText),
139
+ ko_click_id: optional(tagText),
140
+ ScCid: optional(tagText),
141
+ ttclid: optional(tagText),
142
+ twclid: optional(tagText),
143
+ yclid: optional(tagText),
144
+ epik: optional(tagText),
145
+ utm_source: optional(tagText),
146
+ utm_medium: optional(tagText),
147
+ utm_campaign: optional(tagText),
148
+ utm_term: optional(tagText),
149
+ utm_content: optional(tagText),
150
+ utm_id: optional(tagText),
151
+ utm_source_platform: optional(tagText),
152
+ utm_creative_format: optional(tagText),
153
+ utm_marketing_tactic: optional(tagText)
144
154
  });
145
155
  const propertiesSchema = optional(pipe(record(string(), union([
146
156
  propertyText,
@@ -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 * 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,eAAe,KACnB,OAAO,GACP,WAAW,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,QAAQ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AAU,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 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,MAAM,YAAY;AAElB,MAAM,QAAQ,KACZ,MACE,KACE,OAAO,OAAO,GAAG,MAAM;CAAC;CAAc,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CAAC,GACpE,UAAU,cAAc,CAC1B,CACF,GACA,WAAW,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,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO;CACpB,SAAS,SAAS,OAAO;CACzB,YAAY,SAAS,OAAO;CAC5B,SAAS,SAAS,OAAO;CACzB,cAAc,SAAS,OAAO;CAC9B,iBAAiB,SAAS,OAAO;CACjC,QAAQ,SAAS,OAAO;CACxB,WAAW,SAAS,OAAO,CAAC,CAAC,MAAM,K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G,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"}
@@ -0,0 +1,111 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_setup_index = require("../setup/index.cjs");
3
+ const require_track_index = require("./index.cjs");
4
+ //#region src/track/once.ts
5
+ const DEFAULT_TTL = 7776e6;
6
+ /**
7
+ * `{"v":1,"entries":[[key, expiresAt], …]}`, oldest first. Entries are tuples in an array rather
8
+ * than an object keyed by `key`: an object would move integer-like keys ("123") to the front and
9
+ * lose the order the oldest are dropped by. Escaping the value for the medium is the storage's
10
+ * job, so this is plain JSON.
11
+ */
12
+ const VERSION = 1;
13
+ function storageKey(name) {
14
+ return `track_once.${name}`;
15
+ }
16
+ /** The stored entries, or none for a record that is missing, of another version or malformed. */
17
+ function read(name) {
18
+ const raw = require_setup_index.config.storage.getItem(storageKey(name));
19
+ if (!raw) return [];
20
+ let record;
21
+ try {
22
+ record = JSON.parse(raw);
23
+ } catch {
24
+ return [];
25
+ }
26
+ if (typeof record !== "object" || record === null) return [];
27
+ const { v, entries } = record;
28
+ if (v !== VERSION || !Array.isArray(entries)) return [];
29
+ return entries.flatMap((entry) => {
30
+ if (!Array.isArray(entry)) return [];
31
+ const [key, expiresAt] = entry;
32
+ if (typeof key !== "string" || typeof expiresAt !== "number") return [];
33
+ return [{
34
+ key,
35
+ expiresAt
36
+ }];
37
+ });
38
+ }
39
+ function write(name, entries) {
40
+ const record = {
41
+ v: VERSION,
42
+ entries: entries.slice(-20).map((entry) => [entry.key, entry.expiresAt])
43
+ };
44
+ require_setup_index.config.storage.setItem(storageKey(name), JSON.stringify(record));
45
+ }
46
+ function live(entries, now) {
47
+ return entries.filter((entry) => entry.expiresAt > now);
48
+ }
49
+ /** Keys queued in this page (or app process) but not confirmed sent yet, per event name. */
50
+ const pending = /* @__PURE__ */ new Map();
51
+ function isPending(name, key) {
52
+ return pending.get(name)?.has(key) ?? false;
53
+ }
54
+ function markPending(name, key) {
55
+ const keys = pending.get(name);
56
+ if (keys) keys.add(key);
57
+ else pending.set(name, /* @__PURE__ */ new Set([key]));
58
+ }
59
+ function clearPending(name, key) {
60
+ const keys = pending.get(name);
61
+ if (!keys) return;
62
+ keys.delete(key);
63
+ if (keys.size === 0) pending.delete(name);
64
+ }
65
+ /**
66
+ * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a
67
+ * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event
68
+ * was queued.
69
+ *
70
+ * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a
71
+ * send that fails is tried again by the next call instead of being lost; within one page a key
72
+ * already queued is not queued twice. When the storage cannot be read or written the event is
73
+ * tracked anyway: a rare duplicate is better than a lost conversion.
74
+ *
75
+ * Deduplication is per device and storage. A second device still reports its own occurrence, so
76
+ * figures that must be exact (revenue) belong to server-side records.
77
+ */
78
+ function trackOnce(name, properties, { key, ttl = DEFAULT_TTL, ...options }) {
79
+ if (isPending(name, key)) return false;
80
+ const now = Date.now();
81
+ try {
82
+ if (live(read(name), now).some((entry) => entry.key === key)) return false;
83
+ } catch (e) {
84
+ if (e instanceof Error) console.log(e.message);
85
+ }
86
+ markPending(name, key);
87
+ require_track_index.track(name, properties, {
88
+ ...options,
89
+ onSucceed: (response) => {
90
+ clearPending(name, key);
91
+ try {
92
+ write(name, [...live(read(name), Date.now()).filter((entry) => entry.key !== key), {
93
+ key,
94
+ expiresAt: Date.now() + ttl
95
+ }]);
96
+ } catch (e) {
97
+ if (e instanceof Error) console.log(e.message);
98
+ }
99
+ options.onSucceed?.(response);
100
+ },
101
+ onError: (error) => {
102
+ clearPending(name, key);
103
+ options.onError?.(error);
104
+ }
105
+ });
106
+ return true;
107
+ }
108
+ //#endregion
109
+ exports.trackOnce = trackOnce;
110
+
111
+ //# sourceMappingURL=once.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.cjs","names":["config"],"sources":["../../src/track/once.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { type TrackOptions, track } from './index';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\nexport interface TrackOnceOptions extends TrackOptions {\n /**\n * What makes this occurrence the same one again: a checkout session id for `purchase`, an order\n * id, a transaction id. Required, never derived from the properties, so the caller decides what\n * \"once\" means. The same key under another event name is a different occurrence.\n */\n key: string;\n /** How long a sent key is remembered, in milliseconds. 90 days by default. */\n ttl?: number;\n}\n\nconst DEFAULT_TTL = 90 * 24 * 60 * 60 * 1000;\n/** Keys remembered per event name; the oldest are forgotten first. */\nconst MAX_ENTRIES = 20;\n\n/**\n * `{\"v\":1,\"entries\":[[key, expiresAt], …]}`, oldest first. Entries are tuples in an array rather\n * than an object keyed by `key`: an object would move integer-like keys (\"123\") to the front and\n * lose the order the oldest are dropped by. Escaping the value for the medium is the storage's\n * job, so this is plain JSON.\n */\nconst VERSION = 1;\n\ntype Entry = { key: string; expiresAt: number };\n\nfunction storageKey(name: string) {\n return `track_once.${name}`;\n}\n\n/** The stored entries, or none for a record that is missing, of another version or malformed. */\nfunction read(name: string): Entry[] {\n const raw = config.storage.getItem(storageKey(name));\n if (!raw) return [];\n let record: unknown;\n try {\n record = JSON.parse(raw);\n } catch {\n return [];\n }\n if (typeof record !== 'object' || record === null) return [];\n const { v, entries } = record as { v?: unknown; entries?: unknown };\n if (v !== VERSION || !Array.isArray(entries)) return [];\n return entries.flatMap((entry: unknown) => {\n if (!Array.isArray(entry)) return [];\n const [key, expiresAt] = entry as unknown[];\n if (typeof key !== 'string' || typeof expiresAt !== 'number') return [];\n return [{ key, expiresAt }];\n });\n}\n\nfunction write(name: string, entries: Entry[]) {\n const record = {\n v: VERSION,\n entries: entries.slice(-MAX_ENTRIES).map((entry) => [entry.key, entry.expiresAt]),\n };\n config.storage.setItem(storageKey(name), JSON.stringify(record));\n}\n\nfunction live(entries: Entry[], now: number) {\n return entries.filter((entry) => entry.expiresAt > now);\n}\n\n/** Keys queued in this page (or app process) but not confirmed sent yet, per event name. */\nconst pending = new Map<string, Set<string>>();\n\nfunction isPending(name: string, key: string) {\n return pending.get(name)?.has(key) ?? false;\n}\n\nfunction markPending(name: string, key: string) {\n const keys = pending.get(name);\n if (keys) keys.add(key);\n else pending.set(name, new Set([key]));\n}\n\nfunction clearPending(name: string, key: string) {\n const keys = pending.get(name);\n if (!keys) return;\n keys.delete(key);\n if (keys.size === 0) pending.delete(name);\n}\n\n/**\n * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a\n * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event\n * was queued.\n *\n * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a\n * send that fails is tried again by the next call instead of being lost; within one page a key\n * already queued is not queued twice. When the storage cannot be read or written the event is\n * tracked anyway: a rare duplicate is better than a lost conversion.\n *\n * Deduplication is per device and storage. A second device still reports its own occurrence, so\n * figures that must be exact (revenue) belong to server-side records.\n */\nexport function trackOnce<T extends EventName = EventName>(\n name: TrackName<T>,\n properties: TrackProperties<T> | undefined,\n { key, ttl = DEFAULT_TTL, ...options }: TrackOnceOptions\n): boolean {\n if (isPending(name, key)) return false;\n\n const now = Date.now();\n try {\n if (live(read(name), now).some((entry) => entry.key === key)) return false;\n } catch (e: unknown) {\n if (e instanceof Error) console.log(e.message);\n }\n\n markPending(name, key);\n track(name, properties, {\n ...options,\n onSucceed: (response) => {\n clearPending(name, key);\n try {\n const entries = live(read(name), Date.now()).filter((entry) => entry.key !== key);\n write(name, [...entries, { key, expiresAt: Date.now() + ttl }]);\n } catch (e: unknown) {\n if (e instanceof Error) console.log(e.message);\n }\n options.onSucceed?.(response);\n },\n onError: (error) => {\n // Not sent: forget it here so a later call can try again.\n clearPending(name, key);\n options.onError?.(error);\n },\n });\n return true;\n}\n"],"mappings":";;;;AAeA,MAAM,cAAc;;;;;;;AAUpB,MAAM,UAAU;AAIhB,SAAS,WAAW,MAAc;CAChC,OAAO,cAAc;AACvB;;AAGA,SAAS,KAAK,MAAuB;CACnC,MAAM,MAAMA,oBAAAA,OAAO,QAAQ,QAAQ,WAAW,IAAI,CAAC;CACnD,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,GAAG;CACzB,QAAQ;EACN,OAAO,CAAC;CACV;CACA,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO,CAAC;CAC3D,MAAM,EAAE,GAAG,YAAY;CACvB,IAAI,MAAM,WAAW,CAAC,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC;CACtD,OAAO,QAAQ,SAAS,UAAmB;EACzC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;EACnC,MAAM,CAAC,KAAK,aAAa;EACzB,IAAI,OAAO,QAAQ,YAAY,OAAO,cAAc,UAAU,OAAO,CAAC;EACtE,OAAO,CAAC;GAAE;GAAK;EAAU,CAAC;CAC5B,CAAC;AACH;AAEA,SAAS,MAAM,MAAc,SAAkB;CAC7C,MAAM,SAAS;EACb,GAAG;EACH,SAAS,QAAQ,MAAM,GAAY,CAAC,CAAC,KAAK,UAAU,CAAC,MAAM,KAAK,MAAM,SAAS,CAAC;CAClF;CACA,oBAAA,OAAO,QAAQ,QAAQ,WAAW,IAAI,GAAG,KAAK,UAAU,MAAM,CAAC;AACjE;AAEA,SAAS,KAAK,SAAkB,KAAa;CAC3C,OAAO,QAAQ,QAAQ,UAAU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Q;EAC9B;EACA,UAAU,UAAU;GAElB,aAAa,MAAM,GAAG;GACtB,QAAQ,UAAU,KAAK;EACzB;CACF,CAAC;CACD,OAAO;AACT"}
@@ -0,0 +1,29 @@
1
+ import { EventName, TrackName, TrackProperties } from "./types.cjs";
2
+ import { TrackOptions } from "./index.cjs";
3
+ //#region src/track/once.d.ts
4
+ export interface TrackOnceOptions extends TrackOptions {
5
+ /**
6
+ * What makes this occurrence the same one again: a checkout session id for `purchase`, an order
7
+ * id, a transaction id. Required, never derived from the properties, so the caller decides what
8
+ * "once" means. The same key under another event name is a different occurrence.
9
+ */
10
+ key: string;
11
+ /** How long a sent key is remembered, in milliseconds. 90 days by default. */
12
+ ttl?: number;
13
+ }
14
+ /**
15
+ * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a
16
+ * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event
17
+ * was queued.
18
+ *
19
+ * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a
20
+ * send that fails is tried again by the next call instead of being lost; within one page a key
21
+ * already queued is not queued twice. When the storage cannot be read or written the event is
22
+ * tracked anyway: a rare duplicate is better than a lost conversion.
23
+ *
24
+ * Deduplication is per device and storage. A second device still reports its own occurrence, so
25
+ * figures that must be exact (revenue) belong to server-side records.
26
+ */
27
+ export declare function trackOnce<T extends EventName = EventName>(name: TrackName<T>, properties: TrackProperties<T> | undefined, { key, ttl, ...options }: TrackOnceOptions): boolean;
28
+ //#endregion
29
+ //# sourceMappingURL=once.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.d.cts","names":[],"sources":["../../src/track/once.ts"],"mappings":";;;iBAIiB,yBAAyB;;;;;;EAMxC;;EAEA;;;;;;;;;;;;;;;wBAuFc,UAAU,UAAU,YAAY,WAC9C,MAAM,UAAU,IAChB,YAAY,gBAAgB,kBAC1B,KAAK,QAAsB,WAAW"}
@@ -0,0 +1,29 @@
1
+ import { EventName, TrackName, TrackProperties } from "./types.mjs";
2
+ import { TrackOptions } from "./index.mjs";
3
+ //#region src/track/once.d.ts
4
+ export interface TrackOnceOptions extends TrackOptions {
5
+ /**
6
+ * What makes this occurrence the same one again: a checkout session id for `purchase`, an order
7
+ * id, a transaction id. Required, never derived from the properties, so the caller decides what
8
+ * "once" means. The same key under another event name is a different occurrence.
9
+ */
10
+ key: string;
11
+ /** How long a sent key is remembered, in milliseconds. 90 days by default. */
12
+ ttl?: number;
13
+ }
14
+ /**
15
+ * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a
16
+ * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event
17
+ * was queued.
18
+ *
19
+ * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a
20
+ * send that fails is tried again by the next call instead of being lost; within one page a key
21
+ * already queued is not queued twice. When the storage cannot be read or written the event is
22
+ * tracked anyway: a rare duplicate is better than a lost conversion.
23
+ *
24
+ * Deduplication is per device and storage. A second device still reports its own occurrence, so
25
+ * figures that must be exact (revenue) belong to server-side records.
26
+ */
27
+ export declare function trackOnce<T extends EventName = EventName>(name: TrackName<T>, properties: TrackProperties<T> | undefined, { key, ttl, ...options }: TrackOnceOptions): boolean;
28
+ //#endregion
29
+ //# sourceMappingURL=once.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.d.mts","names":[],"sources":["../../src/track/once.ts"],"mappings":";;;iBAIiB,yBAAyB;;;;;;EAMxC;;EAEA;;;;;;;;;;;;;;;wBAuFc,UAAU,UAAU,YAAY,WAC9C,MAAM,UAAU,IAChB,YAAY,gBAAgB,kBAC1B,KAAK,QAAsB,WAAW"}
@@ -0,0 +1,110 @@
1
+ import { config } from "../setup/index.mjs";
2
+ import { track } from "./index.mjs";
3
+ //#region src/track/once.ts
4
+ const DEFAULT_TTL = 7776e6;
5
+ /**
6
+ * `{"v":1,"entries":[[key, expiresAt], …]}`, oldest first. Entries are tuples in an array rather
7
+ * than an object keyed by `key`: an object would move integer-like keys ("123") to the front and
8
+ * lose the order the oldest are dropped by. Escaping the value for the medium is the storage's
9
+ * job, so this is plain JSON.
10
+ */
11
+ const VERSION = 1;
12
+ function storageKey(name) {
13
+ return `track_once.${name}`;
14
+ }
15
+ /** The stored entries, or none for a record that is missing, of another version or malformed. */
16
+ function read(name) {
17
+ const raw = config.storage.getItem(storageKey(name));
18
+ if (!raw) return [];
19
+ let record;
20
+ try {
21
+ record = JSON.parse(raw);
22
+ } catch {
23
+ return [];
24
+ }
25
+ if (typeof record !== "object" || record === null) return [];
26
+ const { v, entries } = record;
27
+ if (v !== VERSION || !Array.isArray(entries)) return [];
28
+ return entries.flatMap((entry) => {
29
+ if (!Array.isArray(entry)) return [];
30
+ const [key, expiresAt] = entry;
31
+ if (typeof key !== "string" || typeof expiresAt !== "number") return [];
32
+ return [{
33
+ key,
34
+ expiresAt
35
+ }];
36
+ });
37
+ }
38
+ function write(name, entries) {
39
+ const record = {
40
+ v: VERSION,
41
+ entries: entries.slice(-20).map((entry) => [entry.key, entry.expiresAt])
42
+ };
43
+ config.storage.setItem(storageKey(name), JSON.stringify(record));
44
+ }
45
+ function live(entries, now) {
46
+ return entries.filter((entry) => entry.expiresAt > now);
47
+ }
48
+ /** Keys queued in this page (or app process) but not confirmed sent yet, per event name. */
49
+ const pending = /* @__PURE__ */ new Map();
50
+ function isPending(name, key) {
51
+ return pending.get(name)?.has(key) ?? false;
52
+ }
53
+ function markPending(name, key) {
54
+ const keys = pending.get(name);
55
+ if (keys) keys.add(key);
56
+ else pending.set(name, /* @__PURE__ */ new Set([key]));
57
+ }
58
+ function clearPending(name, key) {
59
+ const keys = pending.get(name);
60
+ if (!keys) return;
61
+ keys.delete(key);
62
+ if (keys.size === 0) pending.delete(name);
63
+ }
64
+ /**
65
+ * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a
66
+ * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event
67
+ * was queued.
68
+ *
69
+ * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a
70
+ * send that fails is tried again by the next call instead of being lost; within one page a key
71
+ * already queued is not queued twice. When the storage cannot be read or written the event is
72
+ * tracked anyway: a rare duplicate is better than a lost conversion.
73
+ *
74
+ * Deduplication is per device and storage. A second device still reports its own occurrence, so
75
+ * figures that must be exact (revenue) belong to server-side records.
76
+ */
77
+ function trackOnce(name, properties, { key, ttl = DEFAULT_TTL, ...options }) {
78
+ if (isPending(name, key)) return false;
79
+ const now = Date.now();
80
+ try {
81
+ if (live(read(name), now).some((entry) => entry.key === key)) return false;
82
+ } catch (e) {
83
+ if (e instanceof Error) console.log(e.message);
84
+ }
85
+ markPending(name, key);
86
+ track(name, properties, {
87
+ ...options,
88
+ onSucceed: (response) => {
89
+ clearPending(name, key);
90
+ try {
91
+ write(name, [...live(read(name), Date.now()).filter((entry) => entry.key !== key), {
92
+ key,
93
+ expiresAt: Date.now() + ttl
94
+ }]);
95
+ } catch (e) {
96
+ if (e instanceof Error) console.log(e.message);
97
+ }
98
+ options.onSucceed?.(response);
99
+ },
100
+ onError: (error) => {
101
+ clearPending(name, key);
102
+ options.onError?.(error);
103
+ }
104
+ });
105
+ return true;
106
+ }
107
+ //#endregion
108
+ export { trackOnce };
109
+
110
+ //# sourceMappingURL=once.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.mjs","names":[],"sources":["../../src/track/once.ts"],"sourcesContent":["import { config } from '../setup/index';\nimport { type TrackOptions, track } from './index';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\nexport interface TrackOnceOptions extends TrackOptions {\n /**\n * What makes this occurrence the same one again: a checkout session id for `purchase`, an order\n * id, a transaction id. Required, never derived from the properties, so the caller decides what\n * \"once\" means. The same key under another event name is a different occurrence.\n */\n key: string;\n /** How long a sent key is remembered, in milliseconds. 90 days by default. */\n ttl?: number;\n}\n\nconst DEFAULT_TTL = 90 * 24 * 60 * 60 * 1000;\n/** Keys remembered per event name; the oldest are forgotten first. */\nconst MAX_ENTRIES = 20;\n\n/**\n * `{\"v\":1,\"entries\":[[key, expiresAt], …]}`, oldest first. Entries are tuples in an array rather\n * than an object keyed by `key`: an object would move integer-like keys (\"123\") to the front and\n * lose the order the oldest are dropped by. Escaping the value for the medium is the storage's\n * job, so this is plain JSON.\n */\nconst VERSION = 1;\n\ntype Entry = { key: string; expiresAt: number };\n\nfunction storageKey(name: string) {\n return `track_once.${name}`;\n}\n\n/** The stored entries, or none for a record that is missing, of another version or malformed. */\nfunction read(name: string): Entry[] {\n const raw = config.storage.getItem(storageKey(name));\n if (!raw) return [];\n let record: unknown;\n try {\n record = JSON.parse(raw);\n } catch {\n return [];\n }\n if (typeof record !== 'object' || record === null) return [];\n const { v, entries } = record as { v?: unknown; entries?: unknown };\n if (v !== VERSION || !Array.isArray(entries)) return [];\n return entries.flatMap((entry: unknown) => {\n if (!Array.isArray(entry)) return [];\n const [key, expiresAt] = entry as unknown[];\n if (typeof key !== 'string' || typeof expiresAt !== 'number') return [];\n return [{ key, expiresAt }];\n });\n}\n\nfunction write(name: string, entries: Entry[]) {\n const record = {\n v: VERSION,\n entries: entries.slice(-MAX_ENTRIES).map((entry) => [entry.key, entry.expiresAt]),\n };\n config.storage.setItem(storageKey(name), JSON.stringify(record));\n}\n\nfunction live(entries: Entry[], now: number) {\n return entries.filter((entry) => entry.expiresAt > now);\n}\n\n/** Keys queued in this page (or app process) but not confirmed sent yet, per event name. */\nconst pending = new Map<string, Set<string>>();\n\nfunction isPending(name: string, key: string) {\n return pending.get(name)?.has(key) ?? false;\n}\n\nfunction markPending(name: string, key: string) {\n const keys = pending.get(name);\n if (keys) keys.add(key);\n else pending.set(name, new Set([key]));\n}\n\nfunction clearPending(name: string, key: string) {\n const keys = pending.get(name);\n if (!keys) return;\n keys.delete(key);\n if (keys.size === 0) pending.delete(name);\n}\n\n/**\n * Tracks an event at most once per `key`: a reloaded or revisited payment result page, a\n * re-delivered store transaction, a confirmation screen opened twice. Returns whether the event\n * was queued.\n *\n * The key is remembered in `config.storage` only once the event has been sent (`onSucceed`), so a\n * send that fails is tried again by the next call instead of being lost; within one page a key\n * already queued is not queued twice. When the storage cannot be read or written the event is\n * tracked anyway: a rare duplicate is better than a lost conversion.\n *\n * Deduplication is per device and storage. A second device still reports its own occurrence, so\n * figures that must be exact (revenue) belong to server-side records.\n */\nexport function trackOnce<T extends EventName = EventName>(\n name: TrackName<T>,\n properties: TrackProperties<T> | undefined,\n { key, ttl = DEFAULT_TTL, ...options }: TrackOnceOptions\n): boolean {\n if (isPending(name, key)) return false;\n\n const now = Date.now();\n try {\n if (live(read(name), now).some((entry) => entry.key === key)) return false;\n } catch (e: unknown) {\n if (e instanceof Error) console.log(e.message);\n }\n\n markPending(name, key);\n track(name, properties, {\n ...options,\n onSucceed: (response) => {\n clearPending(name, key);\n try {\n const entries = live(read(name), Date.now()).filter((entry) => entry.key !== key);\n write(name, [...entries, { key, expiresAt: Date.now() + ttl }]);\n } catch (e: unknown) {\n if (e instanceof Error) console.log(e.message);\n }\n options.onSucceed?.(response);\n },\n onError: (error) => {\n // Not sent: forget it here so a later call can try again.\n clearPending(name, key);\n options.onError?.(error);\n },\n });\n return true;\n}\n"],"mappings":";;;AAeA,MAAM,cAAc;;;;;;;AAUpB,MAAM,UAAU;AAIhB,SAAS,WAAW,MAAc;CAChC,OAAO,cAAc;AACvB;;AAGA,SAAS,KAAK,MAAuB;CACnC,MAAM,MAAM,OAAO,QAAQ,QAAQ,WAAW,IAAI,CAAC;CACnD,IAAI,CAAC,KAAK,OAAO,CAAC;CAClB,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,GAAG;CACzB,QAAQ;EACN,OAAO,CAAC;CACV;CACA,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO,CAAC;CAC3D,MAAM,EAAE,GAAG,YAAY;CACvB,IAAI,MAAM,WAAW,CAAC,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC;CACtD,OAAO,QAAQ,SAAS,UAAmB;EACzC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;EACnC,MAAM,CAA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OAAO,QAAQ,IAAI,EAAE,OAAO;CAC/C;CAEA,YAAY,MAAM,GAAG;CACrB,MAAM,MAAM,YAAY;EACtB,GAAG;EACH,YAAY,aAAa;GACvB,aAAa,MAAM,GAAG;GACtB,IAAI;IAEF,MAAM,MAAM,CAAC,GADG,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,UAAU,MAAM,QAAQ,GACvD,GAAG;KAAE;KAAK,WAAW,KAAK,IAAI,IAAI;IAAI,CAAC,CAAC;GAChE,SAAS,GAAY;IACnB,IAAI,aAAa,OAAO,QAAQ,IAAI,EAAE,OAAO;GAC/C;GACA,QAAQ,YAAY,QAAQ;EAC9B;EACA,UAAU,UAAU;GAElB,aAAa,MAAM,GAAG;GACtB,QAAQ,UAAU,KAAK;EACzB;CACF,CAAC;CACD,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/analytics",
3
- "version": "11.13.4",
3
+ "version": "11.15.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",