@aranova/tracking-react 0.26.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/client.d.mts +5 -4
  2. package/dist/client.d.ts +5 -4
  3. package/dist/client.js +207 -283
  4. package/dist/client.js.map +1 -1
  5. package/dist/client.mjs +169 -255
  6. package/dist/client.mjs.map +1 -1
  7. package/dist/index.d.mts +7 -6
  8. package/dist/index.d.ts +7 -6
  9. package/dist/index.js +275 -391
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +264 -391
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/ingest-typed-BdKmlouW.d.ts +791 -0
  14. package/dist/ingest-typed-Bo7WPmpU.d.mts +791 -0
  15. package/dist/{phone-utils-BVzSNBf1.d.mts → phone-utils-CubQif9Z.d.mts} +18 -78
  16. package/dist/{phone-utils-BVzSNBf1.d.ts → phone-utils-CubQif9Z.d.ts} +18 -78
  17. package/dist/phone.d.mts +2 -2
  18. package/dist/phone.d.ts +2 -2
  19. package/dist/phone.js +0 -462
  20. package/dist/phone.js.map +1 -1
  21. package/dist/phone.mjs +0 -462
  22. package/dist/phone.mjs.map +1 -1
  23. package/dist/{sales-1J-Z4AvL.d.ts → sales-Bhh9mLBA.d.ts} +90 -329
  24. package/dist/{sales-DzKvyVjY.d.mts → sales-C7Xjsq-a.d.mts} +90 -329
  25. package/dist/sales.d.mts +3 -3
  26. package/dist/sales.d.ts +3 -3
  27. package/dist/sales.js +265 -127
  28. package/dist/sales.js.map +1 -1
  29. package/dist/sales.mjs +254 -127
  30. package/dist/sales.mjs.map +1 -1
  31. package/dist/{tracking-config-runtime-BnUlS_Ae.d.mts → tracking-config-runtime-D7prdTE1.d.mts} +6 -0
  32. package/dist/{tracking-config-runtime-BnUlS_Ae.d.ts → tracking-config-runtime-D7prdTE1.d.ts} +6 -0
  33. package/package.json +2 -2
  34. package/dist/ingest-typed-BioxtBJD.d.mts +0 -1365
  35. package/dist/ingest-typed-C-SPiigr.d.ts +0 -1365
package/dist/client.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  "use client";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/client.ts
@@ -631,10 +641,10 @@ function readStoredRecord() {
631
641
  return null;
632
642
  }
633
643
  }
634
- function writeRecord(record) {
635
- memoryRecord = record;
644
+ function writeRecord(record3) {
645
+ memoryRecord = record3;
636
646
  try {
637
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
647
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record3));
638
648
  } catch {
639
649
  }
640
650
  }
@@ -656,9 +666,9 @@ function getOrCaptureLandingParams(sessionId, url) {
656
666
  if (memoryRecord && memoryRecord.session_id === sessionId) {
657
667
  return memoryRecord.params;
658
668
  }
659
- const record = { session_id: sessionId, params: captureFromUrl(url) };
660
- writeRecord(record);
661
- return record.params;
669
+ const record3 = { session_id: sessionId, params: captureFromUrl(url) };
670
+ writeRecord(record3);
671
+ return record3.params;
662
672
  }
663
673
  function buildLandingPayloadFields(sessionId, override) {
664
674
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -993,14 +1003,15 @@ function fromMinor(cents, currency) {
993
1003
 
994
1004
  // ../tracking-core/src/resources/tracking-config-runtime.ts
995
1005
  var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
996
- function trackingConfigKey(businessId, environment) {
997
- return `tracking-config/v1/${businessId}-${environment}.json`;
1006
+ function trackingConfigKey(ref) {
1007
+ if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
1008
+ return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
998
1009
  }
999
1010
  function resolveTrackingConfigUrl(ref) {
1000
1011
  if (ref.cdnUrl) return ref.cdnUrl;
1001
1012
  const configured = ref.cdnBaseUrl?.trim();
1002
1013
  const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
1003
- return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
1014
+ return `${base}/${trackingConfigKey(ref)}`;
1004
1015
  }
1005
1016
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
1006
1017
  var AUTHORITY_TTL_MS = 6e4;
@@ -1489,25 +1500,32 @@ function getOrRotateSessionId(now = Date.now()) {
1489
1500
  return { id: fresh.id, isNew: true };
1490
1501
  }
1491
1502
 
1503
+ // ../tracking-core/src/page-view.ts
1504
+ var import_mini = require("zod/mini");
1505
+
1492
1506
  // ../tracking-core/src/events/page-view.ts
1493
- var import_zod = require("zod");
1494
- var pageViewMetadataSchema = import_zod.z.object({
1495
- page: import_zod.z.object({
1496
- title: import_zod.z.string().nullable(),
1497
- path: import_zod.z.string(),
1498
- search: import_zod.z.string(),
1499
- hash: import_zod.z.string()
1500
- }).strict(),
1501
- referrer: import_zod.z.string().nullable(),
1502
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1507
+ var z = __toESM(require("zod/mini"));
1508
+ var pageViewMetadataSchema = z.strictObject({
1509
+ page: z.strictObject({
1510
+ title: z.nullable(z.string()),
1511
+ path: z.string(),
1512
+ search: z.string(),
1513
+ hash: z.string()
1514
+ }),
1515
+ referrer: z.nullable(z.string()),
1516
+ // Optional + nullable — absent (undefined) OR explicit null OR a
1503
1517
  // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1504
1518
  // on the backend side so the drift test stays clean.
1505
- viewport: import_zod.z.object({
1506
- w: import_zod.z.number(),
1507
- h: import_zod.z.number()
1508
- }).strict().nullable().optional()
1509
- }).strict();
1510
- var pageViewConfigSchema = import_zod.z.object({}).strict();
1519
+ viewport: z.optional(
1520
+ z.nullable(
1521
+ z.strictObject({
1522
+ w: z.number(),
1523
+ h: z.number()
1524
+ })
1525
+ )
1526
+ )
1527
+ });
1528
+ var pageViewConfigSchema = z.strictObject({});
1511
1529
 
1512
1530
  // ../tracking-core/src/page-view.ts
1513
1531
  var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
@@ -1543,7 +1561,7 @@ function setLastFiredUrl(url) {
1543
1561
  }
1544
1562
  function buildPageViewMetadata(referrerOverride) {
1545
1563
  if (typeof window === "undefined" || typeof document === "undefined") return null;
1546
- return pageViewMetadataSchema.parse({
1564
+ return (0, import_mini.parse)(pageViewMetadataSchema, {
1547
1565
  page: {
1548
1566
  title: document.title || null,
1549
1567
  path: window.location.pathname,
@@ -1635,7 +1653,7 @@ function serializeValue(value) {
1635
1653
  }
1636
1654
  return value;
1637
1655
  }
1638
- function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null) {
1656
+ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null, configSiteId = null) {
1639
1657
  const automaticNames = triggers ? Object.keys(triggers.automatic) : [];
1640
1658
  const manualNames = triggers?.manual ? Object.keys(triggers.manual) : [];
1641
1659
  let triggerConfig = null;
@@ -1669,7 +1687,8 @@ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtag
1669
1687
  manual: manualNames
1670
1688
  },
1671
1689
  trigger_config: triggerConfig,
1672
- configured_gtag_ids: gtagIds
1690
+ configured_gtag_ids: gtagIds,
1691
+ config_site_id: configSiteId
1673
1692
  };
1674
1693
  }
1675
1694
 
@@ -1866,7 +1885,8 @@ function createTrackingClient(config) {
1866
1885
  sdkVersion,
1867
1886
  packageName,
1868
1887
  config.triggers ?? null,
1869
- activeGtagIds
1888
+ activeGtagIds,
1889
+ config.configSiteId ?? null
1870
1890
  );
1871
1891
  queue.push({
1872
1892
  event_type: "sdk_heartbeat",
@@ -2037,184 +2057,198 @@ function createTrackingClient(config) {
2037
2057
  };
2038
2058
  }
2039
2059
 
2060
+ // ../tracking-core/src/ingest-typed.ts
2061
+ var import_mini2 = require("zod/mini");
2062
+
2040
2063
  // ../tracking-core/src/events/cta-click.ts
2041
- var import_zod2 = require("zod");
2042
- var ctaClickMetadataSchema = import_zod2.z.object({
2043
- cta_name: import_zod2.z.string(),
2044
- page: import_zod2.z.object({
2045
- path: import_zod2.z.string()
2046
- }).strict(),
2047
- section: import_zod2.z.string().nullable().optional(),
2048
- destination_url: import_zod2.z.string().nullable().optional(),
2064
+ var z2 = __toESM(require("zod/mini"));
2065
+ var ctaClickMetadataSchema = z2.strictObject({
2066
+ cta_name: z2.string(),
2067
+ page: z2.strictObject({
2068
+ path: z2.string()
2069
+ }),
2070
+ section: z2.optional(z2.nullable(z2.string())),
2071
+ destination_url: z2.optional(z2.nullable(z2.string())),
2049
2072
  // Set by auto-capture (and available to manual callers): the link target
2050
2073
  // and a short element descriptor (tag#id) for tying clicks to specific UI.
2051
- href: import_zod2.z.string().nullable().optional(),
2052
- element: import_zod2.z.string().nullable().optional()
2053
- }).strict();
2054
- var ctaClickConfigSchema = import_zod2.z.object({
2055
- autoCapture: import_zod2.z.object({
2056
- selector: import_zod2.z.string().optional()
2057
- }).strict().optional()
2058
- }).strict();
2074
+ href: z2.optional(z2.nullable(z2.string())),
2075
+ element: z2.optional(z2.nullable(z2.string()))
2076
+ });
2077
+ var ctaClickConfigSchema = z2.strictObject({
2078
+ autoCapture: z2.optional(
2079
+ z2.strictObject({
2080
+ selector: z2.optional(z2.string())
2081
+ })
2082
+ )
2083
+ });
2059
2084
 
2060
2085
  // ../tracking-core/src/events/sdk-heartbeat.ts
2061
- var import_zod3 = require("zod");
2062
- var sdkHeartbeatTriggersSchema = import_zod3.z.object({
2063
- automatic: import_zod3.z.array(import_zod3.z.string()),
2064
- manual: import_zod3.z.array(import_zod3.z.string())
2065
- }).strict();
2066
- var sdkHeartbeatMetadataSchema = import_zod3.z.object({
2067
- sdk_version: import_zod3.z.string(),
2068
- package_name: import_zod3.z.string().nullable(),
2069
- surface: import_zod3.z.enum(["next", "react", "script"]),
2086
+ var z3 = __toESM(require("zod/mini"));
2087
+ var sdkHeartbeatTriggersSchema = z3.strictObject({
2088
+ automatic: z3.array(z3.string()),
2089
+ manual: z3.array(z3.string())
2090
+ });
2091
+ var sdkHeartbeatMetadataSchema = z3.strictObject({
2092
+ sdk_version: z3.string(),
2093
+ package_name: z3.nullable(z3.string()),
2094
+ surface: z3.enum(["next", "react", "script"]),
2070
2095
  triggers: sdkHeartbeatTriggersSchema,
2071
- trigger_config: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown())).nullable().optional(),
2072
- configured_gtag_ids: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).nullable().optional()
2073
- }).strict();
2074
- var sdkHeartbeatConfigSchema = import_zod3.z.object({}).strict();
2096
+ trigger_config: z3.optional(z3.nullable(z3.record(z3.string(), z3.record(z3.string(), z3.unknown())))),
2097
+ configured_gtag_ids: z3.optional(z3.nullable(z3.record(z3.string(), z3.string()))),
2098
+ // Site whose config object the SDK resolves; null on a legacy business ref.
2099
+ config_site_id: z3.optional(z3.nullable(z3.uuid()))
2100
+ });
2101
+ var sdkHeartbeatConfigSchema = z3.strictObject({});
2075
2102
 
2076
2103
  // ../tracking-core/src/events/form-start.ts
2077
- var import_zod4 = require("zod");
2078
- var formStartMetadataSchema = import_zod4.z.object({
2079
- form: import_zod4.z.object({
2080
- id: import_zod4.z.string(),
2081
- action: import_zod4.z.string().nullable()
2082
- }).strict(),
2083
- page: import_zod4.z.object({
2084
- path: import_zod4.z.string()
2085
- }).strict()
2086
- }).strict();
2087
- var formStartConfigSchema = import_zod4.z.object({
2088
- selector: import_zod4.z.string().optional()
2089
- }).strict();
2104
+ var z4 = __toESM(require("zod/mini"));
2105
+ var formStartMetadataSchema = z4.strictObject({
2106
+ form: z4.strictObject({
2107
+ id: z4.string(),
2108
+ action: z4.nullable(z4.string())
2109
+ }),
2110
+ page: z4.strictObject({
2111
+ path: z4.string()
2112
+ })
2113
+ });
2114
+ var formStartConfigSchema = z4.strictObject({
2115
+ selector: z4.optional(z4.string())
2116
+ });
2090
2117
 
2091
2118
  // ../tracking-core/src/events/form-submit.ts
2092
- var import_zod5 = require("zod");
2093
- var jsonValueSchema = import_zod5.z.lazy(
2094
- () => import_zod5.z.union([
2095
- import_zod5.z.string(),
2096
- import_zod5.z.number().finite(),
2097
- import_zod5.z.boolean(),
2098
- import_zod5.z.null(),
2099
- import_zod5.z.array(jsonValueSchema),
2100
- import_zod5.z.record(jsonValueSchema)
2119
+ var z5 = __toESM(require("zod/mini"));
2120
+ var jsonValueSchema = z5.lazy(
2121
+ () => z5.union([
2122
+ z5.string(),
2123
+ z5.number(),
2124
+ z5.boolean(),
2125
+ z5.null(),
2126
+ z5.array(jsonValueSchema),
2127
+ z5.record(z5.string(), jsonValueSchema)
2101
2128
  ])
2102
- );
2103
- var formSubmitMetadataSchema = import_zod5.z.object({
2104
- form: import_zod5.z.object({
2105
- id: import_zod5.z.string(),
2106
- action: import_zod5.z.string().nullable(),
2107
- fields: import_zod5.z.array(
2108
- import_zod5.z.object({
2109
- name: import_zod5.z.string(),
2110
- type: import_zod5.z.string(),
2111
- label: import_zod5.z.string().nullable(),
2112
- value: jsonValueSchema
2113
- }).strict()
2114
- ).optional()
2115
- }).strict(),
2116
- page: import_zod5.z.object({
2117
- path: import_zod5.z.string()
2118
- }).strict()
2119
- }).strict();
2120
- var formSubmitConfigSchema = import_zod5.z.object({}).strict();
2129
+ ).register(z5.globalRegistry, { id: "JsonSerializableValue" });
2130
+ var formSubmitMetadataSchema = z5.strictObject({
2131
+ form: z5.strictObject({
2132
+ id: z5.string(),
2133
+ action: z5.nullable(z5.string()),
2134
+ fields: z5.optional(
2135
+ z5.array(
2136
+ z5.strictObject({
2137
+ name: z5.string(),
2138
+ type: z5.string(),
2139
+ label: z5.nullable(z5.string()),
2140
+ value: jsonValueSchema
2141
+ })
2142
+ )
2143
+ )
2144
+ }),
2145
+ page: z5.strictObject({
2146
+ path: z5.string()
2147
+ })
2148
+ });
2149
+ var formSubmitConfigSchema = z5.strictObject({});
2121
2150
 
2122
2151
  // ../tracking-core/src/events/multi-page-session.ts
2123
- var import_zod6 = require("zod");
2124
- var multiPageSessionMetadataSchema = import_zod6.z.object({
2125
- page_count: import_zod6.z.number().int().min(2),
2126
- page: import_zod6.z.object({
2127
- path: import_zod6.z.string()
2128
- }).strict()
2129
- }).strict();
2130
- var multiPageSessionConfigSchema = import_zod6.z.object({
2131
- pageThreshold: import_zod6.z.number().int().min(2)
2132
- }).strict();
2152
+ var z6 = __toESM(require("zod/mini"));
2153
+ var multiPageSessionMetadataSchema = z6.strictObject({
2154
+ page_count: z6.int().check(z6.gte(2)),
2155
+ page: z6.strictObject({
2156
+ path: z6.string()
2157
+ })
2158
+ });
2159
+ var multiPageSessionConfigSchema = z6.strictObject({
2160
+ pageThreshold: z6.int().check(z6.gte(2))
2161
+ });
2133
2162
 
2134
2163
  // ../tracking-core/src/events/page-exit.ts
2135
- var import_zod7 = require("zod");
2136
- var pageExitMetadataSchema = import_zod7.z.object({
2137
- dwell_ms: import_zod7.z.number().int().min(0),
2164
+ var z7 = __toESM(require("zod/mini"));
2165
+ var pageExitMetadataSchema = z7.strictObject({
2166
+ dwell_ms: z7.int().check(z7.gte(0)),
2138
2167
  // null = left without any scroll signal; floor is 0 so a valid 0% is never
2139
2168
  // rejected (a single bad field 422s the whole keepalive beacon batch).
2140
- max_scroll_percent: import_zod7.z.number().int().min(0).max(100).nullable(),
2169
+ max_scroll_percent: z7.nullable(z7.int().check(z7.gte(0), z7.lte(100))),
2141
2170
  // The gating baseline: the fraction of the page visible at load with
2142
2171
  // zero scrolling — or, for pages that grew after the post-paint snapshot
2143
2172
  // (skeleton/streaming renders), the first-scroll position that
2144
2173
  // established it. null = page had no scrollable range, or the segment
2145
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
2174
+ // ended before the snapshot. Optionality is load-bearing: SDK builds
2146
2175
  // predating this field keep POSTing page_exit without the key —
2147
2176
  // requiring it would 422 whole keepalive beacon batches.
2148
- scroll_baseline_percent: import_zod7.z.number().int().min(0).max(100).nullable().optional(),
2149
- page: import_zod7.z.object({
2150
- path: import_zod7.z.string()
2151
- }).strict()
2152
- }).strict();
2153
- var pageExitConfigSchema = import_zod7.z.object({}).strict();
2177
+ scroll_baseline_percent: z7.optional(z7.nullable(z7.int().check(z7.gte(0), z7.lte(100)))),
2178
+ page: z7.strictObject({
2179
+ path: z7.string()
2180
+ })
2181
+ });
2182
+ var pageExitConfigSchema = z7.strictObject({});
2154
2183
 
2155
2184
  // ../tracking-core/src/events/phone-click.ts
2156
- var import_zod8 = require("zod");
2157
- var phoneClickMetadataSchema = import_zod8.z.object({
2158
- phone_number: import_zod8.z.string(),
2159
- page: import_zod8.z.object({
2160
- path: import_zod8.z.string()
2161
- }).strict(),
2162
- section: import_zod8.z.string().nullable().optional()
2163
- }).strict();
2164
- var phoneClickConfigSchema = import_zod8.z.object({
2165
- autoCapture: import_zod8.z.object({
2166
- selector: import_zod8.z.string().optional()
2167
- }).strict().optional()
2168
- }).strict();
2185
+ var z8 = __toESM(require("zod/mini"));
2186
+ var phoneClickMetadataSchema = z8.strictObject({
2187
+ phone_number: z8.string(),
2188
+ page: z8.strictObject({
2189
+ path: z8.string()
2190
+ }),
2191
+ section: z8.optional(z8.nullable(z8.string()))
2192
+ });
2193
+ var phoneClickConfigSchema = z8.strictObject({
2194
+ autoCapture: z8.optional(
2195
+ z8.strictObject({
2196
+ selector: z8.optional(z8.string())
2197
+ })
2198
+ )
2199
+ });
2169
2200
 
2170
2201
  // ../tracking-core/src/events/scroll-depth.ts
2171
- var import_zod9 = require("zod");
2172
- var scrollDepthMetadataSchema = import_zod9.z.object({
2173
- depth_percent: import_zod9.z.number().int().min(1).max(100),
2174
- page: import_zod9.z.object({
2175
- path: import_zod9.z.string()
2176
- }).strict()
2177
- }).strict();
2178
- var scrollDepthConfigSchema = import_zod9.z.object({
2179
- thresholds: import_zod9.z.array(import_zod9.z.number().int().min(1).max(100)).min(1)
2180
- }).strict();
2202
+ var z9 = __toESM(require("zod/mini"));
2203
+ var scrollDepthMetadataSchema = z9.strictObject({
2204
+ depth_percent: z9.int().check(z9.gte(1), z9.lte(100)),
2205
+ page: z9.strictObject({
2206
+ path: z9.string()
2207
+ })
2208
+ });
2209
+ var scrollDepthConfigSchema = z9.strictObject({
2210
+ thresholds: z9.array(z9.int().check(z9.gte(1), z9.lte(100))).check(z9.minLength(1))
2211
+ });
2181
2212
 
2182
2213
  // ../tracking-core/src/events/specific-page-visit.ts
2183
- var import_zod10 = require("zod");
2214
+ var z10 = __toESM(require("zod/mini"));
2184
2215
  var PAGE_IDENTITY_MAX_LENGTH = 64;
2185
2216
  var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2186
- var pageIdentitySchema = import_zod10.z.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
2187
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2188
- });
2217
+ var pageIdentitySchema = z10.string().check(
2218
+ z10.maxLength(PAGE_IDENTITY_MAX_LENGTH),
2219
+ z10.regex(PAGE_IDENTITY_PATTERN, {
2220
+ message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2221
+ })
2222
+ );
2189
2223
  var specificPageNameSchema = pageIdentitySchema;
2190
- var specificPageVisitMetadataSchema = import_zod10.z.object({
2224
+ var specificPageVisitMetadataSchema = z10.strictObject({
2191
2225
  page_name: specificPageNameSchema,
2192
- page: import_zod10.z.object({
2193
- path: import_zod10.z.string()
2194
- }).strict()
2195
- }).strict();
2196
- var specificPageVisitConfigSchema = import_zod10.z.object({
2197
- pages: import_zod10.z.array(
2198
- import_zod10.z.object({
2226
+ page: z10.strictObject({
2227
+ path: z10.string()
2228
+ })
2229
+ });
2230
+ var specificPageVisitConfigSchema = z10.strictObject({
2231
+ pages: z10.array(
2232
+ z10.strictObject({
2199
2233
  name: specificPageNameSchema,
2200
- pathPattern: import_zod10.z.custom((value) => value instanceof RegExp, {
2234
+ pathPattern: z10.custom((value) => value instanceof RegExp, {
2201
2235
  message: "pathPattern must be a RegExp"
2202
2236
  })
2203
- }).strict()
2204
- ).min(1)
2205
- }).strict();
2237
+ })
2238
+ ).check(z10.minLength(1))
2239
+ });
2206
2240
 
2207
2241
  // ../tracking-core/src/events/time-on-site.ts
2208
- var import_zod11 = require("zod");
2209
- var timeOnSiteMetadataSchema = import_zod11.z.object({
2210
- duration_ms: import_zod11.z.number().int().nonnegative(),
2211
- page: import_zod11.z.object({
2212
- path: import_zod11.z.string()
2213
- }).strict()
2214
- }).strict();
2215
- var timeOnSiteConfigSchema = import_zod11.z.object({
2216
- thresholdSeconds: import_zod11.z.number().int().positive()
2217
- }).strict();
2242
+ var z11 = __toESM(require("zod/mini"));
2243
+ var timeOnSiteMetadataSchema = z11.strictObject({
2244
+ duration_ms: z11.int().check(z11.nonnegative()),
2245
+ page: z11.strictObject({
2246
+ path: z11.string()
2247
+ })
2248
+ });
2249
+ var timeOnSiteConfigSchema = z11.strictObject({
2250
+ thresholdSeconds: z11.int().check(z11.positive())
2251
+ });
2218
2252
 
2219
2253
  // ../tracking-core/src/events/semantics.ts
2220
2254
  var EVENT_SEMANTICS = {
@@ -2373,7 +2407,7 @@ function createTypedClient(raw, registry, options = {}) {
2373
2407
  trackEvent(eventType, metadata, opts) {
2374
2408
  if (debug) {
2375
2409
  const def = getEventDefinition(eventType);
2376
- def.metadataSchema.parse(metadata);
2410
+ (0, import_mini2.parse)(def.metadataSchema, metadata);
2377
2411
  }
2378
2412
  raw.trackEvent({
2379
2413
  eventType,
@@ -2997,117 +3031,6 @@ function attachPhoneClickCapture(client, config) {
2997
3031
  };
2998
3032
  }
2999
3033
 
3000
- // ../tracking-core/src/resources/sales/schema.ts
3001
- var import_zod12 = require("zod");
3002
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
3003
- var TRACKING_ENVIRONMENTS = ["production", "development"];
3004
- var currencySchema = import_zod12.z.enum(SUPPORTED_CURRENCIES);
3005
- var centsSchema = import_zod12.z.number().int().nonnegative();
3006
- var quantitySchema = import_zod12.z.string().regex(/^\d+(\.\d{1,3})?$/);
3007
- var metadataSchema = import_zod12.z.record(import_zod12.z.unknown());
3008
- var saleItemSchema = import_zod12.z.object({
3009
- external_item_id: import_zod12.z.string().nullable().optional(),
3010
- name: import_zod12.z.string().nullable().optional(),
3011
- category: import_zod12.z.string().nullable().optional(),
3012
- quantity: quantitySchema,
3013
- unit_price_cents: centsSchema,
3014
- // Non-negativity validated on the wire — same contract as the other cents
3015
- // fields — and backstopped by the DB CHECK.
3016
- unit_cost_cents: centsSchema.nullable().optional()
3017
- }).strict();
3018
- var saleServiceSchema = import_zod12.z.object({
3019
- service: import_zod12.z.string(),
3020
- amount_cents: centsSchema
3021
- }).strict();
3022
- var customerNameSchema = import_zod12.z.string().max(200);
3023
- var customerPhoneSchema = import_zod12.z.string().max(64);
3024
- var customerEmailSchema = import_zod12.z.string().max(320).email();
3025
- function refineServiceXor(val, ctx, { requireAmount }) {
3026
- if (val.services != null) {
3027
- if (val.service != null) {
3028
- ctx.addIssue({
3029
- code: import_zod12.z.ZodIssueCode.custom,
3030
- message: "pass either `service` or `services`, not both",
3031
- path: ["services"]
3032
- });
3033
- }
3034
- if (val.services.length === 0) {
3035
- ctx.addIssue({
3036
- code: import_zod12.z.ZodIssueCode.custom,
3037
- message: "`services` must not be empty",
3038
- path: ["services"]
3039
- });
3040
- }
3041
- const keys = val.services.map((s) => s.service);
3042
- if (new Set(keys).size !== keys.length) {
3043
- ctx.addIssue({
3044
- code: import_zod12.z.ZodIssueCode.custom,
3045
- message: "`services` must not list the same service more than once",
3046
- path: ["services"]
3047
- });
3048
- }
3049
- if (val.amount_total_cents != null) {
3050
- const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
3051
- if (val.amount_total_cents !== sum) {
3052
- ctx.addIssue({
3053
- code: import_zod12.z.ZodIssueCode.custom,
3054
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
3055
- path: ["amount_total_cents"]
3056
- });
3057
- }
3058
- }
3059
- } else if (requireAmount && val.amount_total_cents == null) {
3060
- ctx.addIssue({
3061
- code: import_zod12.z.ZodIssueCode.custom,
3062
- message: "amount_total_cents is required unless `services` is provided",
3063
- path: ["amount_total_cents"]
3064
- });
3065
- }
3066
- }
3067
- var saleCreateSchema = import_zod12.z.object({
3068
- external_id: import_zod12.z.string().nullable().optional(),
3069
- description: import_zod12.z.string().nullable().optional(),
3070
- service: import_zod12.z.string().nullable().optional(),
3071
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
3072
- currency: currencySchema,
3073
- // Optional only because the plural `services` form derives it from the sum
3074
- // (see refineServiceXor); the singular/serviceless path still requires it.
3075
- amount_total_cents: centsSchema.nullable().optional(),
3076
- occurred_at: import_zod12.z.string().datetime(),
3077
- environment: import_zod12.z.enum(TRACKING_ENVIRONMENTS).default("production"),
3078
- items: import_zod12.z.array(saleItemSchema).default([]),
3079
- metadata: metadataSchema.nullable().optional(),
3080
- customer_name: customerNameSchema.nullable().optional(),
3081
- customer_phone: customerPhoneSchema.nullable().optional(),
3082
- customer_email: customerEmailSchema.nullable().optional(),
3083
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
3084
- // with a timestamp server-side; every SMS send path gates on it.
3085
- //
3086
- // Tri-state: omit it (or send null) to let the server apply the business's
3087
- // configured default-opt-in policy, honouring a returning customer's
3088
- // remembered preference. Send an explicit boolean to assert consent state
3089
- // yourself — `false` records a deliberate opt-out.
3090
- sms_consent: import_zod12.z.boolean().nullable().optional()
3091
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
3092
- var saleUpdateSchema = import_zod12.z.object({
3093
- description: import_zod12.z.string().nullable().optional(),
3094
- service: import_zod12.z.string().nullable().optional(),
3095
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
3096
- currency: currencySchema.optional(),
3097
- amount_total_cents: centsSchema.optional(),
3098
- occurred_at: import_zod12.z.string().datetime().optional(),
3099
- items: import_zod12.z.array(saleItemSchema).optional(),
3100
- metadata: metadataSchema.nullable().optional(),
3101
- customer_name: customerNameSchema.nullable().optional(),
3102
- // Re-attest when changing a filler-looking name; the server clears the
3103
- // prior attestation whenever `customer_name` changes.
3104
- customer_name_placeholder_confirmed: import_zod12.z.boolean().optional(),
3105
- customer_phone: customerPhoneSchema.nullable().optional(),
3106
- customer_email: customerEmailSchema.nullable().optional(),
3107
- // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
3108
- sms_consent: import_zod12.z.boolean().optional()
3109
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
3110
-
3111
3034
  // src/hooks.ts
3112
3035
  function useGclid() {
3113
3036
  const [gclid, setGclid] = (0, import_react.useState)(null);
@@ -3387,7 +3310,7 @@ function AdPlatformTracking({
3387
3310
  metaPixelId,
3388
3311
  metaPixelIds
3389
3312
  }) {
3390
- const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
3313
+ const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.siteId ?? ""}:${trackingConfig.environment}` : "";
3391
3314
  const gtagIdsKey = (0, import_react3.useMemo)(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
3392
3315
  const metaPixelIdsKey = (0, import_react3.useMemo)(
3393
3316
  () => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
@@ -3439,7 +3362,7 @@ function GoogleAdsTracking(props) {
3439
3362
  var import_react6 = require("react");
3440
3363
 
3441
3364
  // package.json
3442
- var version = "0.26.0";
3365
+ var version = "1.0.0";
3443
3366
 
3444
3367
  // ../tracking-core/src/phone-react.tsx
3445
3368
  var import_react5 = require("react");
@@ -3591,6 +3514,7 @@ function createTracking(options) {
3591
3514
  triggers,
3592
3515
  environment,
3593
3516
  activeGtagIds: resolvedGtagIds,
3517
+ configSiteId: trackingConfig?.siteId ?? null,
3594
3518
  debug
3595
3519
  }),
3596
3520
  [resolvedGtagIds]