@shware/analytics 10.3.0 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +33 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +3 -3
  4. package/dist/index.d.mts +3 -3
  5. package/dist/index.mjs +2 -2
  6. package/dist/schema/index.cjs +5 -0
  7. package/dist/schema/index.cjs.map +1 -1
  8. package/dist/schema/index.d.cts +5 -0
  9. package/dist/schema/index.d.cts.map +1 -1
  10. package/dist/schema/index.d.mts +5 -0
  11. package/dist/schema/index.d.mts.map +1 -1
  12. package/dist/schema/index.mjs +5 -0
  13. package/dist/schema/index.mjs.map +1 -1
  14. package/dist/server/openai-conversions-api.cjs +1 -1
  15. package/dist/server/openai-conversions-api.mjs +1 -1
  16. package/dist/server/reddit-conversions-api.cjs +1 -1
  17. package/dist/server/reddit-conversions-api.mjs +1 -1
  18. package/dist/setup/index.cjs +1 -4
  19. package/dist/setup/index.cjs.map +1 -1
  20. package/dist/setup/index.d.cts +1 -2
  21. package/dist/setup/index.d.cts.map +1 -1
  22. package/dist/setup/index.d.mts +1 -2
  23. package/dist/setup/index.d.mts.map +1 -1
  24. package/dist/setup/index.mjs +1 -4
  25. package/dist/setup/index.mjs.map +1 -1
  26. package/dist/third-parties/microsoft-uet.cjs +6 -9
  27. package/dist/third-parties/microsoft-uet.cjs.map +1 -1
  28. package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
  29. package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
  30. package/dist/third-parties/microsoft-uet.mjs +7 -10
  31. package/dist/third-parties/microsoft-uet.mjs.map +1 -1
  32. package/dist/track/index.cjs +11 -25
  33. package/dist/track/index.cjs.map +1 -1
  34. package/dist/track/index.d.cts +5 -5
  35. package/dist/track/index.d.cts.map +1 -1
  36. package/dist/track/index.d.mts +5 -5
  37. package/dist/track/index.d.mts.map +1 -1
  38. package/dist/track/index.mjs +12 -26
  39. package/dist/track/index.mjs.map +1 -1
  40. package/dist/visitor/index.cjs +19 -52
  41. package/dist/visitor/index.cjs.map +1 -1
  42. package/dist/visitor/index.d.cts +10 -1
  43. package/dist/visitor/index.d.cts.map +1 -1
  44. package/dist/visitor/index.d.mts +10 -1
  45. package/dist/visitor/index.d.mts.map +1 -1
  46. package/dist/visitor/index.mjs +20 -53
  47. package/dist/visitor/index.mjs.map +1 -1
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -60,6 +60,39 @@ changes. The framework `Analytics` components wire this up.
60
60
  - /analytics/tracks: track events
61
61
  - /analytics/visitor: app visitors
62
62
 
63
+ ## Visitors
64
+
65
+ Since 11.0 the SDK generates the visitor id itself — a uuidv7, kept in `config.storage` under
66
+ `visitor_id` (`visitorId()`) — as GA4 does its client id and PostHog its anonymous distinct id. The
67
+ first events of a visit, and the beacon of a visit left within a second, go out without waiting
68
+ for a round trip; before, a new visitor's events waited for `POST /visitors`, and a page left
69
+ before it returned lost them all, `session_start` included. An id a server issued to an older
70
+ client is kept as it is, so the visitor continues.
71
+
72
+ A visit sends no visitor request: as in PostHog, where person properties ride on the events,
73
+ the events are the visitor's record. The server:
74
+
75
+ - **creates the visitor from `POST /events`**: read the batch's visitors once — the query that also
76
+ tells which of them are bots — and create the missing ones before inserting the events, with
77
+ `insert ... on conflict (id) do nothing`. The conflict clause only settles two batches of the
78
+ same new visitor arriving at once: the second waits on the primary key until the first commits
79
+ and then does nothing, so the events' foreign key to the visitor holds. Build the row only for
80
+ the missing ids, from that visitor's first event in the batch: `device_id` from its tags (else
81
+ the visitor id), `platform` and `environment` from the event, its tags (with the request's
82
+ geolocation and user agent) as both `tags` and `initial_tags`, and the bot verdict from them.
83
+ - **refreshes `visitor.tags` from each `session_start`**: `tags` is the last-touch counterpart to
84
+ `initial_tags` (browser, release, landing), so once per session is enough, and the events route
85
+ already writes the session row there.
86
+ - **does not create it on `PATCH /visitors/:id`** (`setVisitor`): that is a sign-in handing the
87
+ user to the ad platforms' pixels and gtag, and by then the visitor's events have created it. On
88
+ the rare page where a signed-in user's sign-in lands before the first batch of a new visitor id
89
+ (storage cleared, the session kept), answer 404: `setVisitor` rejects, and the next page load
90
+ sets the user.
91
+ - **keeps `POST /visitors`** (`createVisitorSchema`) while clients before 11.0 are in use.
92
+
93
+ Deploy the server first: a server that only creates visitors on `POST /visitors` rejects the
94
+ events of a new visitor from an 11.0 client (the foreign key fails).
95
+
63
96
  ## Sessions and attribution
64
97
 
65
98
  How the events this SDK sends are meant to be read on the server side, for attribution. Three
package/dist/index.cjs CHANGED
@@ -19,7 +19,6 @@ exports.createLinkSchema = require_schema_index.createLinkSchema;
19
19
  exports.createTrackEventSchema = require_schema_index.createTrackEventSchema;
20
20
  exports.createVisitorSchema = require_schema_index.createVisitorSchema;
21
21
  exports.getLink = require_link_index.getLink;
22
- exports.getVisitor = require_visitor_index.getVisitor;
23
22
  exports.sendBeacon = require_track_index.sendBeacon;
24
23
  exports.sendFeedback = require_feedback_index.sendFeedback;
25
24
  exports.sendPendingEvents = require_track_index.sendPendingEvents;
@@ -30,3 +29,4 @@ exports.track = require_track_index.track;
30
29
  exports.trackAsync = require_track_index.trackAsync;
31
30
  exports.updateVisitorSchema = require_schema_index.updateVisitorSchema;
32
31
  exports.useTrackImpression = require_hooks_use_track_impression.useTrackImpression;
32
+ exports.visitorId = require_visitor_index.visitorId;
package/dist/index.d.cts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { AllowedPropertyValues, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.cjs";
2
2
  import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.cjs";
3
- import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.cjs";
3
+ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.cjs";
4
4
  import { sendFeedback } from "./feedback/index.cjs";
5
5
  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 { getVisitor, setVisitor } from "./visitor/index.cjs";
9
+ import { setVisitor, visitorId } from "./visitor/index.cjs";
10
10
  import { Link, createLink, getLink } from "./link/index.cjs";
11
11
  import { stripeMinorUnits } from "./utils/stripe.cjs";
12
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, BOT_CATEGORIES, type Bot, type BotCategory, type CreateFeedbackDTO, type CreateLinkDTO, type CustomEventProperties, type Environment, type Link, NOT_A_BOT, type Platform, type TrackProperties, type TrackTags, type UTMParams, type UserProvidedData, type VisitorProperties, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, getVisitor, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, updateVisitorSchema, useTrackImpression };
12
+ 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, 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 };
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { AllowedPropertyValues, CustomEventProperties, Environment, Platform, TrackProperties, TrackTags, UTMParams, UserProvidedData } from "./track/types.mjs";
2
2
  import { BOT_CATEGORIES, Bot, BotCategory, NOT_A_BOT, botOf } from "./bot/index.mjs";
3
- import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.mjs";
3
+ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, updateVisitorSchema } from "./schema/index.mjs";
4
4
  import { sendFeedback } from "./feedback/index.mjs";
5
5
  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 { getVisitor, setVisitor } from "./visitor/index.mjs";
9
+ import { setVisitor, visitorId } from "./visitor/index.mjs";
10
10
  import { Link, createLink, getLink } from "./link/index.mjs";
11
11
  import { stripeMinorUnits } from "./utils/stripe.mjs";
12
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, type AllowedPropertyValues, BOT_CATEGORIES, type Bot, type BotCategory, type CreateFeedbackDTO, type CreateLinkDTO, type CustomEventProperties, type Environment, type Link, NOT_A_BOT, type Platform, type TrackProperties, type TrackTags, type UTMParams, type UserProvidedData, type VisitorProperties, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, getVisitor, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, updateVisitorSchema, useTrackImpression };
12
+ 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, 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 };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setupAnalytics } from "./setup/index.mjs";
2
- import { getVisitor, setVisitor } from "./visitor/index.mjs";
2
+ import { setVisitor, visitorId } from "./visitor/index.mjs";
3
3
  import { sendBeacon, sendPendingEvents, track, trackAsync } from "./track/index.mjs";
4
4
  import { sendFeedback } from "./feedback/index.mjs";
5
5
  import { createLink, getLink } from "./link/index.mjs";
@@ -7,4 +7,4 @@ import { ALL_ENVIRONMENTS, ALL_PLATFORMS, createFeedbackSchema, createLinkSchema
7
7
  import { BOT_CATEGORIES, NOT_A_BOT, botOf } from "./bot/index.mjs";
8
8
  import { stripeMinorUnits } from "./utils/stripe.mjs";
9
9
  import { useTrackImpression } from "./hooks/use-track-impression.mjs";
10
- export { ALL_ENVIRONMENTS, ALL_PLATFORMS, BOT_CATEGORIES, NOT_A_BOT, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, getVisitor, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, updateVisitorSchema, useTrackImpression };
10
+ export { ALL_ENVIRONMENTS, ALL_PLATFORMS, BOT_CATEGORIES, NOT_A_BOT, botOf, createFeedbackSchema, createLink, createLinkSchema, createTrackEventSchema, createVisitorSchema, getLink, sendBeacon, sendFeedback, sendPendingEvents, setVisitor, setupAnalytics, stripeMinorUnits, track, trackAsync, updateVisitorSchema, useTrackImpression, visitorId };
@@ -195,6 +195,11 @@ const createTrackEventSchema = (0, zod_mini.pipe)((0, zod_mini.array)((0, zod_mi
195
195
  tags: tagsSchema,
196
196
  properties: propertiesSchema
197
197
  })).check((0, zod_mini.minLength)(1), (0, zod_mini.maxLength)(100)), (0, zod_mini.transform)((events) => alignClock(events)));
198
+ /**
199
+ * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id
200
+ * itself and the server creates the visitor from its first events (README, "Visitors").
201
+ * Kept for servers that still serve older clients.
202
+ */
198
203
  const createVisitorSchema = (0, zod_mini.object)({
199
204
  device_id: (0, zod_mini.string)().check((0, zod_mini.trim)(), (0, zod_mini.minLength)(1), (0, zod_mini.maxLength)(36)),
200
205
  platform: (0, zod_mini.enum)(ALL_PLATFORMS),
@@ -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 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 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 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/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\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\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 properties: visitorPropertiesSchema,\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 tags: tagsSchema,\n properties: visitorPropertiesSchema,\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,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IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,oBAAA,GAAmBO,SAAAA,OAAAA,CAAO;;CAErC,MAAA,GAAKa,SAAAA,IAAAA,CAAI,CAAC,CAAC,OAAA,GAAMV,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,IAAI,CAAC;;;;;CAM9C,SAAA,GAAQH,SAAAA,SAAAA,CAAS,aAAa;;CAG9B,aAAA,GAAYT,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGvD,aAAA,GAAYZ,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGvD,eAAA,GAAcZ,SAAAA,OAAAA,CAAO,CAAC,CAAC,OAAA,GAAMW,SAAAA,UAAAA,CAAU,CAAC,IAAA,GAAGC,SAAAA,UAAAA,CAAU,GAAG,CAAC;;CAGzD,WAAA,GAAUH,SAAAA,SAAAA,CAAS,aAAa;;;;;;CAOhC,cAAA,GAAaA,SAAAA,SAAAA,CAAS,aAAa;;;;;;CAOnC,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,sBAAA,GAAqBA,SAAAA,SAAAA,CAAS,aAAa;;;;;CAM3C,uBAAA,GAAsBA,SAAAA,SAAAA,CAAS,aAAa;AAC9C,CAAC"}
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 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 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 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/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\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 properties: visitorPropertiesSchema,\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 tags: tagsSchema,\n properties: visitorPropertiesSchema,\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,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AAAA,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"}
@@ -335,6 +335,11 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
335
335
  };
336
336
  properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
337
337
  }[]>>;
338
+ /**
339
+ * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id
340
+ * itself and the server creates the visitor from its first events (README, "Visitors").
341
+ * Kept for servers that still serve older clients.
342
+ */
338
343
  export declare const createVisitorSchema: z.ZodMiniObject<{
339
344
  device_id: z.ZodMiniString<string>;
340
345
  platform: z.ZodMiniEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGrB,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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AAA;YAEU,sBAAsB,EAAE,cAAc;YACtC,oBAAoB,EAAE,cAAc;YACpC,gBAAgB,EAAE,cAAc;YAChC,mBAAmB,EAAE,cAAc;YACnC,sBAAsB,EAAE,cAAc;YACtC,mBAAmB,EAAE,cAAc"}
@@ -335,6 +335,11 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
335
335
  };
336
336
  properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
337
337
  }[]>>;
338
+ /**
339
+ * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id
340
+ * itself and the server creates the visitor from its first events (README, "Visitors").
341
+ * Kept for servers that still serve older clients.
342
+ */
338
343
  export declare const createVisitorSchema: z.ZodMiniObject<{
339
344
  device_id: z.ZodMiniString<string>;
340
345
  platform: z.ZodMiniEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGrB,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;qBA4ChB,wBAAsB,EAAA,YAAA,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BAAmB,EAAE,cAAc;YACnC,sBAAsB,EAAE,cAAc;YACtC,mBAAmB,EAAE,cAAc"}
@@ -194,6 +194,11 @@ const createTrackEventSchema = pipe(array(object({
194
194
  tags: tagsSchema,
195
195
  properties: propertiesSchema
196
196
  })).check(minLength(1), maxLength(100)), transform((events) => alignClock(events)));
197
+ /**
198
+ * `POST /visitors`, what clients before 11.0 create their visitor with; 11.0 generates the id
199
+ * itself and the server creates the visitor from its first events (README, "Visitors").
200
+ * Kept for servers that still serve older clients.
201
+ */
197
202
  const createVisitorSchema = object({
198
203
  device_id: string().check(trim(), minLength(1), maxLength(36)),
199
204
  platform: enum$1(ALL_PLATFORMS),
@@ -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 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 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 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/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\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\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 properties: visitorPropertiesSchema,\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 tags: tagsSchema,\n properties: visitorPropertiesSchema,\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,KAA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I,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * 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 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 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 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/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\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 properties: visitorPropertiesSchema,\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 tags: tagsSchema,\n properties: visitorPropertiesSchema,\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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C;AAED,MAAM,gBAAgB,KACpB,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC,GAC7B,WAAW,MAAO,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,mBAAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_third_parties_ignored_events = require("../third-parties/ignored-events.cjs");
3
- const require_track_oaiq = require("../track/oaiq.cjs");
4
3
  const require_server_action_source = require("./action-source.cjs");
5
4
  const require_server_click_ids = require("./click-ids.cjs");
6
5
  const require_server_page_location = require("./page-location.cjs");
6
+ const require_track_oaiq = require("../track/oaiq.cjs");
7
7
  let _shware_utils = require("@shware/utils");
8
8
  let node_crypto = require("node:crypto");
9
9
  //#region src/server/openai-conversions-api.ts
@@ -1,8 +1,8 @@
1
1
  import { IGNORED_EVENTS } from "../third-parties/ignored-events.mjs";
2
- import { NON_AD_EVENTS, mapOAIEvent, normalizeOAIName, normalizeOAIPhone, oaiCustomEventName } from "../track/oaiq.mjs";
3
2
  import { resolveActionSource } from "./action-source.mjs";
4
3
  import { openaiOppref } from "./click-ids.mjs";
5
4
  import { pageLocation } from "./page-location.mjs";
5
+ import { NON_AD_EVENTS, mapOAIEvent, normalizeOAIName, normalizeOAIPhone, oaiCustomEventName } from "../track/oaiq.mjs";
6
6
  import { fetch } from "@shware/utils";
7
7
  import { createHash } from "node:crypto";
8
8
  //#region src/server/openai-conversions-api.ts
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_third_parties_ignored_events = require("../third-parties/ignored-events.cjs");
3
3
  const require_utils_field = require("../utils/field.cjs");
4
- const require_track_rdt = require("../track/rdt.cjs");
5
4
  const require_server_action_source = require("./action-source.cjs");
6
5
  const require_server_click_ids = require("./click-ids.cjs");
7
6
  const require_server_page_location = require("./page-location.cjs");
7
+ const require_track_rdt = require("../track/rdt.cjs");
8
8
  let _shware_utils = require("@shware/utils");
9
9
  //#region src/server/reddit-conversions-api.ts
10
10
  function getServerEvent(event, data, actionSource) {
@@ -1,9 +1,9 @@
1
1
  import { IGNORED_EVENTS } from "../third-parties/ignored-events.mjs";
2
2
  import { getFirst } from "../utils/field.mjs";
3
- import { mapRDTEvent, mapServerStandardEvent } from "../track/rdt.mjs";
4
3
  import { resolveActionSource } from "./action-source.mjs";
5
4
  import { redditClickId, redditUuid } from "./click-ids.mjs";
6
5
  import { pageLocation } from "./page-location.mjs";
6
+ import { mapRDTEvent, mapServerStandardEvent } from "../track/rdt.mjs";
7
7
  import { fetch } from "@shware/utils";
8
8
  //#region src/server/reddit-conversions-api.ts
9
9
  function getServerEvent(event, data, actionSource) {
@@ -1,9 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/setup/index.ts
3
- const cache = {
4
- tags: null,
5
- visitor: null
6
- };
3
+ const cache = { tags: null };
7
4
  const config = {
8
5
  endpoint: "",
9
6
  release: "0.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/setup/index.ts"],"sourcesContent":["import type { Environment, Platform, ThirdPartyTracker, TrackTags } from '../track/types';\nimport type { ThirdPartyUserSetter, Visitor } from '../visitor/types';\n\nexport interface Storage {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n}\n\nexport interface Options {\n release: string;\n storage: Storage;\n endpoint: string;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers?: ThirdPartyTracker[];\n thirdPartyUserSetters?: ThirdPartyUserSetter[];\n}\n\ninterface Config {\n release: string;\n endpoint: string;\n storage: Storage;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers: ThirdPartyTracker[];\n thirdPartyUserSetters: ThirdPartyUserSetter[];\n}\n\ninterface Cache {\n tags: TrackTags | null;\n visitor: Visitor | null;\n}\n\nexport const cache: Cache = {\n tags: null,\n visitor: null,\n};\n\n// oxlint-disable typescript/no-non-null-assertion\nexport const config: Config = {\n endpoint: '',\n release: '0.0.0',\n storage: null!,\n platform: null!,\n environment: null!,\n getTags: null!,\n getDeviceId: null!,\n getHeaders: null!,\n thirdPartyTrackers: [],\n thirdPartyUserSetters: [],\n};\n// oxlint-enable typescript/no-non-null-assertion\n\nexport function setupAnalytics(init: Options) {\n config.release = init.release;\n config.storage = init.storage;\n config.platform = init.platform;\n config.environment = init.environment;\n config.endpoint = init.endpoint.endsWith('/') ? init.endpoint.slice(0, -1) : init.endpoint;\n config.getTags = init.getTags;\n config.getDeviceId = init.getDeviceId;\n config.getHeaders = async () => ({\n 'Content-Type': 'application/json',\n ...(await init.getHeaders?.()),\n });\n config.thirdPartyTrackers = init.thirdPartyTrackers ?? [];\n config.thirdPartyUserSetters = init.thirdPartyUserSetters ?? [];\n}\n"],"mappings":";;AAuCA,MAAa,QAAe;CAC1B,MAAM;CACN,SAAS;AACX;AAGA,MAAa,SAAiB;CAC5B,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,aAAa;CACb,SAAS;CACT,aAAa;CACb,YAAY;CACZ,oBAAoB,CAAC;CACrB,uBAAuB,CAAC;AAC1B;AAGA,SAAgB,eAAe,MAAe;CAC5C,OAAO,UAAU,KAAK;CACtB,OAAO,UAAU,KAAK;CACtB,OAAO,WAAW,KAAK;CACvB,OAAO,cAAc,KAAK;CAC1B,OAAO,WAAW,KAAK,SAAS,SAAS,GAAG,IAAI,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;CAClF,OAAO,UAAU,KAAK;CACtB,OAAO,cAAc,KAAK;CAC1B,OAAO,aAAa,aAAa;EAC/B,gBAAgB;EAChB,GAAI,MAAM,KAAK,aAAa;CAC9B;CACA,OAAO,qBAAqB,KAAK,sBAAsB,CAAC;CACxD,OAAO,wBAAwB,KAAK,yBAAyB,CAAC;AAChE"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/setup/index.ts"],"sourcesContent":["import type { Environment, Platform, ThirdPartyTracker, TrackTags } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\nexport interface Storage {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n}\n\nexport interface Options {\n release: string;\n storage: Storage;\n endpoint: string;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers?: ThirdPartyTracker[];\n thirdPartyUserSetters?: ThirdPartyUserSetter[];\n}\n\ninterface Config {\n release: string;\n endpoint: string;\n storage: Storage;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers: ThirdPartyTracker[];\n thirdPartyUserSetters: ThirdPartyUserSetter[];\n}\n\ninterface Cache {\n tags: TrackTags | null;\n}\n\nexport const cache: Cache = {\n tags: null,\n};\n\n// oxlint-disable typescript/no-non-null-assertion\nexport const config: Config = {\n endpoint: '',\n release: '0.0.0',\n storage: null!,\n platform: null!,\n environment: null!,\n getTags: null!,\n getDeviceId: null!,\n getHeaders: null!,\n thirdPartyTrackers: [],\n thirdPartyUserSetters: [],\n};\n// oxlint-enable typescript/no-non-null-assertion\n\nexport function setupAnalytics(init: Options) {\n config.release = init.release;\n config.storage = init.storage;\n config.platform = init.platform;\n config.environment = init.environment;\n config.endpoint = init.endpoint.endsWith('/') ? init.endpoint.slice(0, -1) : init.endpoint;\n config.getTags = init.getTags;\n config.getDeviceId = init.getDeviceId;\n config.getHeaders = async () => ({\n 'Content-Type': 'application/json',\n ...(await init.getHeaders?.()),\n });\n config.thirdPartyTrackers = init.thirdPartyTrackers ?? [];\n config.thirdPartyUserSetters = init.thirdPartyUserSetters ?? [];\n}\n"],"mappings":";;AAsCA,MAAa,QAAe,EAC1B,MAAM,KACR;AAGA,MAAa,SAAiB;CAC5B,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,aAAa;CACb,SAAS;CACT,aAAa;CACb,YAAY;CACZ,oBAAoB,CAAC;CACrB,uBAAuB,CAAC;AAC1B;AAGA,SAAgB,eAAe,MAAe;CAC5C,OAAO,UAAU,KAAK;CACtB,OAAO,UAAU,KAAK;CACtB,OAAO,WAAW,KAAK;CACvB,OAAO,cAAc,KAAK;CAC1B,OAAO,WAAW,KAAK,SAAS,SAAS,GAAG,IAAI,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;CAClF,OAAO,UAAU,KAAK;CACtB,OAAO,cAAc,KAAK;CAC1B,OAAO,aAAa,aAAa;EAC/B,gBAAgB;EAChB,GAAI,MAAM,KAAK,aAAa;CAC9B;CACA,OAAO,qBAAqB,KAAK,sBAAsB,CAAC;CACxD,OAAO,wBAAwB,KAAK,yBAAyB,CAAC;AAChE"}
@@ -1,5 +1,5 @@
1
1
  import { Environment, Platform, ThirdPartyTracker, TrackTags } from "../track/types.cjs";
2
- import { ThirdPartyUserSetter, Visitor } from "../visitor/types.cjs";
2
+ import { ThirdPartyUserSetter } from "../visitor/types.cjs";
3
3
  //#region src/setup/index.d.ts
4
4
  export interface Storage {
5
5
  getItem: (key: string) => string | null;
@@ -31,7 +31,6 @@ interface Config {
31
31
  }
32
32
  interface Cache {
33
33
  tags: TrackTags | null;
34
- visitor: Visitor | null;
35
34
  }
36
35
  export declare const cache: Cache;
37
36
  export declare const config: Config;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/setup/index.ts"],"mappings":";;;iBAGiB;EACf,UAAU;EACV,UAAU,aAAa;;iBAGR;EACf;EACA,SAAS;EACT;EACA,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,mBAAmB,yBAAyB,QAAQ;EACpD,qBAAqB;EACrB,wBAAwB;;UAGhB;EACR;EACA;EACA,SAAS;EACT,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,kBAAkB,yBAAyB,QAAQ;EACnD,oBAAoB;EACpB,uBAAuB;;UAGf;EACR,MAAM;EACN,SAAS;;qBAGE,OAAO;qBAMP,QAAQ;wBAcL,eAAe,MAAM"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/setup/index.ts"],"mappings":";;;iBAGiB;EACf,UAAU;EACV,UAAU,aAAa;;iBAGR;EACf;EACA,SAAS;EACT;EACA,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,mBAAmB,yBAAyB,QAAQ;EACpD,qBAAqB;EACrB,wBAAwB;;UAGhB;EACR;EACA;EACA,SAAS;EACT,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,kBAAkB,yBAAyB,QAAQ;EACnD,oBAAoB;EACpB,uBAAuB;;UAGf;EACR,MAAM;;qBAGK,OAAO;qBAKP,QAAQ;wBAcL,eAAe,MAAM"}
@@ -1,5 +1,5 @@
1
1
  import { Environment, Platform, ThirdPartyTracker, TrackTags } from "../track/types.mjs";
2
- import { ThirdPartyUserSetter, Visitor } from "../visitor/types.mjs";
2
+ import { ThirdPartyUserSetter } from "../visitor/types.mjs";
3
3
  //#region src/setup/index.d.ts
4
4
  export interface Storage {
5
5
  getItem: (key: string) => string | null;
@@ -31,7 +31,6 @@ interface Config {
31
31
  }
32
32
  interface Cache {
33
33
  tags: TrackTags | null;
34
- visitor: Visitor | null;
35
34
  }
36
35
  export declare const cache: Cache;
37
36
  export declare const config: Config;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/setup/index.ts"],"mappings":";;;iBAGiB;EACf,UAAU;EACV,UAAU,aAAa;;iBAGR;EACf;EACA,SAAS;EACT;EACA,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,mBAAmB,yBAAyB,QAAQ;EACpD,qBAAqB;EACrB,wBAAwB;;UAGhB;EACR;EACA;EACA,SAAS;EACT,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,kBAAkB,yBAAyB,QAAQ;EACnD,oBAAoB;EACpB,uBAAuB;;UAGf;EACR,MAAM;EACN,SAAS;;qBAGE,OAAO;qBAMP,QAAQ;wBAcL,eAAe,MAAM"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/setup/index.ts"],"mappings":";;;iBAGiB;EACf,UAAU;EACV,UAAU,aAAa;;iBAGR;EACf;EACA,SAAS;EACT;EACA,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,mBAAmB,yBAAyB,QAAQ;EACpD,qBAAqB;EACrB,wBAAwB;;UAGhB;EACR;EACA;EACA,SAAS;EACT,UAAU;EACV,aAAa;EACb,eAAe,YAAY,QAAQ;EACnC,4BAA4B;EAC5B,kBAAkB,yBAAyB,QAAQ;EACnD,oBAAoB;EACpB,uBAAuB;;UAGf;EACR,MAAM;;qBAGK,OAAO;qBAKP,QAAQ;wBAcL,eAAe,MAAM"}
@@ -1,8 +1,5 @@
1
1
  //#region src/setup/index.ts
2
- const cache = {
3
- tags: null,
4
- visitor: null
5
- };
2
+ const cache = { tags: null };
6
3
  const config = {
7
4
  endpoint: "",
8
5
  release: "0.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/setup/index.ts"],"sourcesContent":["import type { Environment, Platform, ThirdPartyTracker, TrackTags } from '../track/types';\nimport type { ThirdPartyUserSetter, Visitor } from '../visitor/types';\n\nexport interface Storage {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n}\n\nexport interface Options {\n release: string;\n storage: Storage;\n endpoint: string;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers?: ThirdPartyTracker[];\n thirdPartyUserSetters?: ThirdPartyUserSetter[];\n}\n\ninterface Config {\n release: string;\n endpoint: string;\n storage: Storage;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers: ThirdPartyTracker[];\n thirdPartyUserSetters: ThirdPartyUserSetter[];\n}\n\ninterface Cache {\n tags: TrackTags | null;\n visitor: Visitor | null;\n}\n\nexport const cache: Cache = {\n tags: null,\n visitor: null,\n};\n\n// oxlint-disable typescript/no-non-null-assertion\nexport const config: Config = {\n endpoint: '',\n release: '0.0.0',\n storage: null!,\n platform: null!,\n environment: null!,\n getTags: null!,\n getDeviceId: null!,\n getHeaders: null!,\n thirdPartyTrackers: [],\n thirdPartyUserSetters: [],\n};\n// oxlint-enable typescript/no-non-null-assertion\n\nexport function setupAnalytics(init: Options) {\n config.release = init.release;\n config.storage = init.storage;\n config.platform = init.platform;\n config.environment = init.environment;\n config.endpoint = init.endpoint.endsWith('/') ? init.endpoint.slice(0, -1) : init.endpoint;\n config.getTags = init.getTags;\n config.getDeviceId = init.getDeviceId;\n config.getHeaders = async () => ({\n 'Content-Type': 'application/json',\n ...(await init.getHeaders?.()),\n });\n config.thirdPartyTrackers = init.thirdPartyTrackers ?? [];\n config.thirdPartyUserSetters = init.thirdPartyUserSetters ?? [];\n}\n"],"mappings":";AAuCA,MAAa,QAAe;CAC1B,MAAM;CACN,SAAS;AACX;AAGA,MAAa,SAAiB;CAC5B,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,aAAa;CACb,SAAS;CACT,aAAa;CACb,YAAY;CACZ,oBAAoB,CAAC;CACrB,uBAAuB,CAAC;AAC1B;AAGA,SAAgB,eAAe,MAAe;CAC5C,OAAO,UAAU,KAAK;CACtB,OAAO,UAAU,KAAK;CACtB,OAAO,WAAW,KAAK;CACvB,OAAO,cAAc,KAAK;CAC1B,OAAO,WAAW,KAAK,SAAS,SAAS,GAAG,IAAI,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;CAClF,OAAO,UAAU,KAAK;CACtB,OAAO,cAAc,KAAK;CAC1B,OAAO,aAAa,aAAa;EAC/B,gBAAgB;EAChB,GAAI,MAAM,KAAK,aAAa;CAC9B;CACA,OAAO,qBAAqB,KAAK,sBAAsB,CAAC;CACxD,OAAO,wBAAwB,KAAK,yBAAyB,CAAC;AAChE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/setup/index.ts"],"sourcesContent":["import type { Environment, Platform, ThirdPartyTracker, TrackTags } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\nexport interface Storage {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n}\n\nexport interface Options {\n release: string;\n storage: Storage;\n endpoint: string;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers?: ThirdPartyTracker[];\n thirdPartyUserSetters?: ThirdPartyUserSetter[];\n}\n\ninterface Config {\n release: string;\n endpoint: string;\n storage: Storage;\n platform: Platform;\n environment: Environment;\n getTags: () => TrackTags | Promise<TrackTags>;\n getDeviceId: () => string | Promise<string>;\n getHeaders: () => Record<string, string> | Promise<Record<string, string>>;\n thirdPartyTrackers: ThirdPartyTracker[];\n thirdPartyUserSetters: ThirdPartyUserSetter[];\n}\n\ninterface Cache {\n tags: TrackTags | null;\n}\n\nexport const cache: Cache = {\n tags: null,\n};\n\n// oxlint-disable typescript/no-non-null-assertion\nexport const config: Config = {\n endpoint: '',\n release: '0.0.0',\n storage: null!,\n platform: null!,\n environment: null!,\n getTags: null!,\n getDeviceId: null!,\n getHeaders: null!,\n thirdPartyTrackers: [],\n thirdPartyUserSetters: [],\n};\n// oxlint-enable typescript/no-non-null-assertion\n\nexport function setupAnalytics(init: Options) {\n config.release = init.release;\n config.storage = init.storage;\n config.platform = init.platform;\n config.environment = init.environment;\n config.endpoint = init.endpoint.endsWith('/') ? init.endpoint.slice(0, -1) : init.endpoint;\n config.getTags = init.getTags;\n config.getDeviceId = init.getDeviceId;\n config.getHeaders = async () => ({\n 'Content-Type': 'application/json',\n ...(await init.getHeaders?.()),\n });\n config.thirdPartyTrackers = init.thirdPartyTrackers ?? [];\n config.thirdPartyUserSetters = init.thirdPartyUserSetters ?? [];\n}\n"],"mappings":";AAsCA,MAAa,QAAe,EAC1B,MAAM,KACR;AAGA,MAAa,SAAiB;CAC5B,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,aAAa;CACb,SAAS;CACT,aAAa;CACb,YAAY;CACZ,oBAAoB,CAAC;CACrB,uBAAuB,CAAC;AAC1B;AAGA,SAAgB,eAAe,MAAe;CAC5C,OAAO,UAAU,KAAK;CACtB,OAAO,UAAU,KAAK;CACtB,OAAO,WAAW,KAAK;CACvB,OAAO,cAAc,KAAK;CAC1B,OAAO,WAAW,KAAK,SAAS,SAAS,GAAG,IAAI,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;CAClF,OAAO,UAAU,KAAK;CACtB,OAAO,cAAc,KAAK;CAC1B,OAAO,aAAa,aAAa;EAC/B,gBAAgB;EAChB,GAAI,MAAM,KAAK,aAAa;CAC9B;CACA,OAAO,qBAAqB,KAAK,sBAAsB,CAAC;CACxD,OAAO,wBAAwB,KAAK,yBAAyB,CAAC;AAChE"}
@@ -86,7 +86,7 @@ function setUETConsent(mode, consent) {
86
86
  * browser context of the sync, which a server-side call cannot carry.
87
87
  *
88
88
  * `customerId` is the Microsoft Advertising customer id (`cid` in the UI's URLs) — not the UET
89
- * tag id. `visitorId` is the SDK visitor id (`getVisitor().id`), which is what
89
+ * tag id. `visitorId` is the SDK visitor id (`visitorId()`), which is what
90
90
  * `sendMicrosoftEvents` sends as `anonymousId`; Microsoft requires the two to be equal.
91
91
  * `userId` is the raw signed-in user id: it is SHA-256 hashed here, exactly as the server sender
92
92
  * hashes it into `externalId`, so the pair matches as well. Hashing is asynchronous, so the
@@ -110,14 +110,11 @@ function configureUET(options) {
110
110
  */
111
111
  async function syncUETVisitor(userId) {
112
112
  if (!uetCustomerId) return;
113
- try {
114
- const { id } = await require_visitor_index.getVisitor();
115
- sendUETIdSync({
116
- customerId: uetCustomerId,
117
- visitorId: id,
118
- userId
119
- });
120
- } catch {}
113
+ sendUETIdSync({
114
+ customerId: uetCustomerId,
115
+ visitorId: require_visitor_index.visitorId(),
116
+ userId
117
+ });
121
118
  }
122
119
  function sendUETIdSync(options) {
123
120
  if (typeof window === "undefined" || typeof Image === "undefined") return;