@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.mjs CHANGED
@@ -595,10 +595,10 @@ function readStoredRecord() {
595
595
  return null;
596
596
  }
597
597
  }
598
- function writeRecord(record) {
599
- memoryRecord = record;
598
+ function writeRecord(record3) {
599
+ memoryRecord = record3;
600
600
  try {
601
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
601
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record3));
602
602
  } catch {
603
603
  }
604
604
  }
@@ -620,9 +620,9 @@ function getOrCaptureLandingParams(sessionId, url) {
620
620
  if (memoryRecord && memoryRecord.session_id === sessionId) {
621
621
  return memoryRecord.params;
622
622
  }
623
- const record = { session_id: sessionId, params: captureFromUrl(url) };
624
- writeRecord(record);
625
- return record.params;
623
+ const record3 = { session_id: sessionId, params: captureFromUrl(url) };
624
+ writeRecord(record3);
625
+ return record3.params;
626
626
  }
627
627
  function buildLandingPayloadFields(sessionId, override) {
628
628
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -957,14 +957,15 @@ function fromMinor(cents, currency) {
957
957
 
958
958
  // ../tracking-core/src/resources/tracking-config-runtime.ts
959
959
  var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
960
- function trackingConfigKey(businessId, environment) {
961
- return `tracking-config/v1/${businessId}-${environment}.json`;
960
+ function trackingConfigKey(ref) {
961
+ if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
962
+ return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
962
963
  }
963
964
  function resolveTrackingConfigUrl(ref) {
964
965
  if (ref.cdnUrl) return ref.cdnUrl;
965
966
  const configured = ref.cdnBaseUrl?.trim();
966
967
  const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
967
- return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
968
+ return `${base}/${trackingConfigKey(ref)}`;
968
969
  }
969
970
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
970
971
  var AUTHORITY_TTL_MS = 6e4;
@@ -1453,25 +1454,32 @@ function getOrRotateSessionId(now = Date.now()) {
1453
1454
  return { id: fresh.id, isNew: true };
1454
1455
  }
1455
1456
 
1457
+ // ../tracking-core/src/page-view.ts
1458
+ import { parse } from "zod/mini";
1459
+
1456
1460
  // ../tracking-core/src/events/page-view.ts
1457
- import { z } from "zod";
1458
- var pageViewMetadataSchema = z.object({
1459
- page: z.object({
1460
- title: z.string().nullable(),
1461
+ import * as z from "zod/mini";
1462
+ var pageViewMetadataSchema = z.strictObject({
1463
+ page: z.strictObject({
1464
+ title: z.nullable(z.string()),
1461
1465
  path: z.string(),
1462
1466
  search: z.string(),
1463
1467
  hash: z.string()
1464
- }).strict(),
1465
- referrer: z.string().nullable(),
1466
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1468
+ }),
1469
+ referrer: z.nullable(z.string()),
1470
+ // Optional + nullable — absent (undefined) OR explicit null OR a
1467
1471
  // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1468
1472
  // on the backend side so the drift test stays clean.
1469
- viewport: z.object({
1470
- w: z.number(),
1471
- h: z.number()
1472
- }).strict().nullable().optional()
1473
- }).strict();
1474
- var pageViewConfigSchema = z.object({}).strict();
1473
+ viewport: z.optional(
1474
+ z.nullable(
1475
+ z.strictObject({
1476
+ w: z.number(),
1477
+ h: z.number()
1478
+ })
1479
+ )
1480
+ )
1481
+ });
1482
+ var pageViewConfigSchema = z.strictObject({});
1475
1483
 
1476
1484
  // ../tracking-core/src/page-view.ts
1477
1485
  var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
@@ -1507,7 +1515,7 @@ function setLastFiredUrl(url) {
1507
1515
  }
1508
1516
  function buildPageViewMetadata(referrerOverride) {
1509
1517
  if (typeof window === "undefined" || typeof document === "undefined") return null;
1510
- return pageViewMetadataSchema.parse({
1518
+ return parse(pageViewMetadataSchema, {
1511
1519
  page: {
1512
1520
  title: document.title || null,
1513
1521
  path: window.location.pathname,
@@ -1599,7 +1607,7 @@ function serializeValue(value) {
1599
1607
  }
1600
1608
  return value;
1601
1609
  }
1602
- function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null) {
1610
+ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null, configSiteId = null) {
1603
1611
  const automaticNames = triggers ? Object.keys(triggers.automatic) : [];
1604
1612
  const manualNames = triggers?.manual ? Object.keys(triggers.manual) : [];
1605
1613
  let triggerConfig = null;
@@ -1633,7 +1641,8 @@ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtag
1633
1641
  manual: manualNames
1634
1642
  },
1635
1643
  trigger_config: triggerConfig,
1636
- configured_gtag_ids: gtagIds
1644
+ configured_gtag_ids: gtagIds,
1645
+ config_site_id: configSiteId
1637
1646
  };
1638
1647
  }
1639
1648
 
@@ -1830,7 +1839,8 @@ function createTrackingClient(config) {
1830
1839
  sdkVersion,
1831
1840
  packageName,
1832
1841
  config.triggers ?? null,
1833
- activeGtagIds
1842
+ activeGtagIds,
1843
+ config.configSiteId ?? null
1834
1844
  );
1835
1845
  queue.push({
1836
1846
  event_type: "sdk_heartbeat",
@@ -2001,184 +2011,198 @@ function createTrackingClient(config) {
2001
2011
  };
2002
2012
  }
2003
2013
 
2014
+ // ../tracking-core/src/ingest-typed.ts
2015
+ import { parse as parse2 } from "zod/mini";
2016
+
2004
2017
  // ../tracking-core/src/events/cta-click.ts
2005
- import { z as z2 } from "zod";
2006
- var ctaClickMetadataSchema = z2.object({
2018
+ import * as z2 from "zod/mini";
2019
+ var ctaClickMetadataSchema = z2.strictObject({
2007
2020
  cta_name: z2.string(),
2008
- page: z2.object({
2021
+ page: z2.strictObject({
2009
2022
  path: z2.string()
2010
- }).strict(),
2011
- section: z2.string().nullable().optional(),
2012
- destination_url: z2.string().nullable().optional(),
2023
+ }),
2024
+ section: z2.optional(z2.nullable(z2.string())),
2025
+ destination_url: z2.optional(z2.nullable(z2.string())),
2013
2026
  // Set by auto-capture (and available to manual callers): the link target
2014
2027
  // and a short element descriptor (tag#id) for tying clicks to specific UI.
2015
- href: z2.string().nullable().optional(),
2016
- element: z2.string().nullable().optional()
2017
- }).strict();
2018
- var ctaClickConfigSchema = z2.object({
2019
- autoCapture: z2.object({
2020
- selector: z2.string().optional()
2021
- }).strict().optional()
2022
- }).strict();
2028
+ href: z2.optional(z2.nullable(z2.string())),
2029
+ element: z2.optional(z2.nullable(z2.string()))
2030
+ });
2031
+ var ctaClickConfigSchema = z2.strictObject({
2032
+ autoCapture: z2.optional(
2033
+ z2.strictObject({
2034
+ selector: z2.optional(z2.string())
2035
+ })
2036
+ )
2037
+ });
2023
2038
 
2024
2039
  // ../tracking-core/src/events/sdk-heartbeat.ts
2025
- import { z as z3 } from "zod";
2026
- var sdkHeartbeatTriggersSchema = z3.object({
2040
+ import * as z3 from "zod/mini";
2041
+ var sdkHeartbeatTriggersSchema = z3.strictObject({
2027
2042
  automatic: z3.array(z3.string()),
2028
2043
  manual: z3.array(z3.string())
2029
- }).strict();
2030
- var sdkHeartbeatMetadataSchema = z3.object({
2044
+ });
2045
+ var sdkHeartbeatMetadataSchema = z3.strictObject({
2031
2046
  sdk_version: z3.string(),
2032
- package_name: z3.string().nullable(),
2047
+ package_name: z3.nullable(z3.string()),
2033
2048
  surface: z3.enum(["next", "react", "script"]),
2034
2049
  triggers: sdkHeartbeatTriggersSchema,
2035
- trigger_config: z3.record(z3.string(), z3.record(z3.string(), z3.unknown())).nullable().optional(),
2036
- configured_gtag_ids: z3.record(z3.string(), z3.string()).nullable().optional()
2037
- }).strict();
2038
- var sdkHeartbeatConfigSchema = z3.object({}).strict();
2050
+ trigger_config: z3.optional(z3.nullable(z3.record(z3.string(), z3.record(z3.string(), z3.unknown())))),
2051
+ configured_gtag_ids: z3.optional(z3.nullable(z3.record(z3.string(), z3.string()))),
2052
+ // Site whose config object the SDK resolves; null on a legacy business ref.
2053
+ config_site_id: z3.optional(z3.nullable(z3.uuid()))
2054
+ });
2055
+ var sdkHeartbeatConfigSchema = z3.strictObject({});
2039
2056
 
2040
2057
  // ../tracking-core/src/events/form-start.ts
2041
- import { z as z4 } from "zod";
2042
- var formStartMetadataSchema = z4.object({
2043
- form: z4.object({
2058
+ import * as z4 from "zod/mini";
2059
+ var formStartMetadataSchema = z4.strictObject({
2060
+ form: z4.strictObject({
2044
2061
  id: z4.string(),
2045
- action: z4.string().nullable()
2046
- }).strict(),
2047
- page: z4.object({
2062
+ action: z4.nullable(z4.string())
2063
+ }),
2064
+ page: z4.strictObject({
2048
2065
  path: z4.string()
2049
- }).strict()
2050
- }).strict();
2051
- var formStartConfigSchema = z4.object({
2052
- selector: z4.string().optional()
2053
- }).strict();
2066
+ })
2067
+ });
2068
+ var formStartConfigSchema = z4.strictObject({
2069
+ selector: z4.optional(z4.string())
2070
+ });
2054
2071
 
2055
2072
  // ../tracking-core/src/events/form-submit.ts
2056
- import { z as z5 } from "zod";
2073
+ import * as z5 from "zod/mini";
2057
2074
  var jsonValueSchema = z5.lazy(
2058
2075
  () => z5.union([
2059
2076
  z5.string(),
2060
- z5.number().finite(),
2077
+ z5.number(),
2061
2078
  z5.boolean(),
2062
2079
  z5.null(),
2063
2080
  z5.array(jsonValueSchema),
2064
- z5.record(jsonValueSchema)
2081
+ z5.record(z5.string(), jsonValueSchema)
2065
2082
  ])
2066
- );
2067
- var formSubmitMetadataSchema = z5.object({
2068
- form: z5.object({
2083
+ ).register(z5.globalRegistry, { id: "JsonSerializableValue" });
2084
+ var formSubmitMetadataSchema = z5.strictObject({
2085
+ form: z5.strictObject({
2069
2086
  id: z5.string(),
2070
- action: z5.string().nullable(),
2071
- fields: z5.array(
2072
- z5.object({
2073
- name: z5.string(),
2074
- type: z5.string(),
2075
- label: z5.string().nullable(),
2076
- value: jsonValueSchema
2077
- }).strict()
2078
- ).optional()
2079
- }).strict(),
2080
- page: z5.object({
2087
+ action: z5.nullable(z5.string()),
2088
+ fields: z5.optional(
2089
+ z5.array(
2090
+ z5.strictObject({
2091
+ name: z5.string(),
2092
+ type: z5.string(),
2093
+ label: z5.nullable(z5.string()),
2094
+ value: jsonValueSchema
2095
+ })
2096
+ )
2097
+ )
2098
+ }),
2099
+ page: z5.strictObject({
2081
2100
  path: z5.string()
2082
- }).strict()
2083
- }).strict();
2084
- var formSubmitConfigSchema = z5.object({}).strict();
2101
+ })
2102
+ });
2103
+ var formSubmitConfigSchema = z5.strictObject({});
2085
2104
 
2086
2105
  // ../tracking-core/src/events/multi-page-session.ts
2087
- import { z as z6 } from "zod";
2088
- var multiPageSessionMetadataSchema = z6.object({
2089
- page_count: z6.number().int().min(2),
2090
- page: z6.object({
2106
+ import * as z6 from "zod/mini";
2107
+ var multiPageSessionMetadataSchema = z6.strictObject({
2108
+ page_count: z6.int().check(z6.gte(2)),
2109
+ page: z6.strictObject({
2091
2110
  path: z6.string()
2092
- }).strict()
2093
- }).strict();
2094
- var multiPageSessionConfigSchema = z6.object({
2095
- pageThreshold: z6.number().int().min(2)
2096
- }).strict();
2111
+ })
2112
+ });
2113
+ var multiPageSessionConfigSchema = z6.strictObject({
2114
+ pageThreshold: z6.int().check(z6.gte(2))
2115
+ });
2097
2116
 
2098
2117
  // ../tracking-core/src/events/page-exit.ts
2099
- import { z as z7 } from "zod";
2100
- var pageExitMetadataSchema = z7.object({
2101
- dwell_ms: z7.number().int().min(0),
2118
+ import * as z7 from "zod/mini";
2119
+ var pageExitMetadataSchema = z7.strictObject({
2120
+ dwell_ms: z7.int().check(z7.gte(0)),
2102
2121
  // null = left without any scroll signal; floor is 0 so a valid 0% is never
2103
2122
  // rejected (a single bad field 422s the whole keepalive beacon batch).
2104
- max_scroll_percent: z7.number().int().min(0).max(100).nullable(),
2123
+ max_scroll_percent: z7.nullable(z7.int().check(z7.gte(0), z7.lte(100))),
2105
2124
  // The gating baseline: the fraction of the page visible at load with
2106
2125
  // zero scrolling — or, for pages that grew after the post-paint snapshot
2107
2126
  // (skeleton/streaming renders), the first-scroll position that
2108
2127
  // established it. null = page had no scrollable range, or the segment
2109
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
2128
+ // ended before the snapshot. Optionality is load-bearing: SDK builds
2110
2129
  // predating this field keep POSTing page_exit without the key —
2111
2130
  // requiring it would 422 whole keepalive beacon batches.
2112
- scroll_baseline_percent: z7.number().int().min(0).max(100).nullable().optional(),
2113
- page: z7.object({
2131
+ scroll_baseline_percent: z7.optional(z7.nullable(z7.int().check(z7.gte(0), z7.lte(100)))),
2132
+ page: z7.strictObject({
2114
2133
  path: z7.string()
2115
- }).strict()
2116
- }).strict();
2117
- var pageExitConfigSchema = z7.object({}).strict();
2134
+ })
2135
+ });
2136
+ var pageExitConfigSchema = z7.strictObject({});
2118
2137
 
2119
2138
  // ../tracking-core/src/events/phone-click.ts
2120
- import { z as z8 } from "zod";
2121
- var phoneClickMetadataSchema = z8.object({
2139
+ import * as z8 from "zod/mini";
2140
+ var phoneClickMetadataSchema = z8.strictObject({
2122
2141
  phone_number: z8.string(),
2123
- page: z8.object({
2142
+ page: z8.strictObject({
2124
2143
  path: z8.string()
2125
- }).strict(),
2126
- section: z8.string().nullable().optional()
2127
- }).strict();
2128
- var phoneClickConfigSchema = z8.object({
2129
- autoCapture: z8.object({
2130
- selector: z8.string().optional()
2131
- }).strict().optional()
2132
- }).strict();
2144
+ }),
2145
+ section: z8.optional(z8.nullable(z8.string()))
2146
+ });
2147
+ var phoneClickConfigSchema = z8.strictObject({
2148
+ autoCapture: z8.optional(
2149
+ z8.strictObject({
2150
+ selector: z8.optional(z8.string())
2151
+ })
2152
+ )
2153
+ });
2133
2154
 
2134
2155
  // ../tracking-core/src/events/scroll-depth.ts
2135
- import { z as z9 } from "zod";
2136
- var scrollDepthMetadataSchema = z9.object({
2137
- depth_percent: z9.number().int().min(1).max(100),
2138
- page: z9.object({
2156
+ import * as z9 from "zod/mini";
2157
+ var scrollDepthMetadataSchema = z9.strictObject({
2158
+ depth_percent: z9.int().check(z9.gte(1), z9.lte(100)),
2159
+ page: z9.strictObject({
2139
2160
  path: z9.string()
2140
- }).strict()
2141
- }).strict();
2142
- var scrollDepthConfigSchema = z9.object({
2143
- thresholds: z9.array(z9.number().int().min(1).max(100)).min(1)
2144
- }).strict();
2161
+ })
2162
+ });
2163
+ var scrollDepthConfigSchema = z9.strictObject({
2164
+ thresholds: z9.array(z9.int().check(z9.gte(1), z9.lte(100))).check(z9.minLength(1))
2165
+ });
2145
2166
 
2146
2167
  // ../tracking-core/src/events/specific-page-visit.ts
2147
- import { z as z10 } from "zod";
2168
+ import * as z10 from "zod/mini";
2148
2169
  var PAGE_IDENTITY_MAX_LENGTH = 64;
2149
2170
  var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2150
- var pageIdentitySchema = z10.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
2151
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2152
- });
2171
+ var pageIdentitySchema = z10.string().check(
2172
+ z10.maxLength(PAGE_IDENTITY_MAX_LENGTH),
2173
+ z10.regex(PAGE_IDENTITY_PATTERN, {
2174
+ message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2175
+ })
2176
+ );
2153
2177
  var specificPageNameSchema = pageIdentitySchema;
2154
- var specificPageVisitMetadataSchema = z10.object({
2178
+ var specificPageVisitMetadataSchema = z10.strictObject({
2155
2179
  page_name: specificPageNameSchema,
2156
- page: z10.object({
2180
+ page: z10.strictObject({
2157
2181
  path: z10.string()
2158
- }).strict()
2159
- }).strict();
2160
- var specificPageVisitConfigSchema = z10.object({
2182
+ })
2183
+ });
2184
+ var specificPageVisitConfigSchema = z10.strictObject({
2161
2185
  pages: z10.array(
2162
- z10.object({
2186
+ z10.strictObject({
2163
2187
  name: specificPageNameSchema,
2164
2188
  pathPattern: z10.custom((value) => value instanceof RegExp, {
2165
2189
  message: "pathPattern must be a RegExp"
2166
2190
  })
2167
- }).strict()
2168
- ).min(1)
2169
- }).strict();
2191
+ })
2192
+ ).check(z10.minLength(1))
2193
+ });
2170
2194
 
2171
2195
  // ../tracking-core/src/events/time-on-site.ts
2172
- import { z as z11 } from "zod";
2173
- var timeOnSiteMetadataSchema = z11.object({
2174
- duration_ms: z11.number().int().nonnegative(),
2175
- page: z11.object({
2196
+ import * as z11 from "zod/mini";
2197
+ var timeOnSiteMetadataSchema = z11.strictObject({
2198
+ duration_ms: z11.int().check(z11.nonnegative()),
2199
+ page: z11.strictObject({
2176
2200
  path: z11.string()
2177
- }).strict()
2178
- }).strict();
2179
- var timeOnSiteConfigSchema = z11.object({
2180
- thresholdSeconds: z11.number().int().positive()
2181
- }).strict();
2201
+ })
2202
+ });
2203
+ var timeOnSiteConfigSchema = z11.strictObject({
2204
+ thresholdSeconds: z11.int().check(z11.positive())
2205
+ });
2182
2206
 
2183
2207
  // ../tracking-core/src/events/semantics.ts
2184
2208
  var EVENT_SEMANTICS = {
@@ -2337,7 +2361,7 @@ function createTypedClient(raw, registry, options = {}) {
2337
2361
  trackEvent(eventType, metadata, opts) {
2338
2362
  if (debug) {
2339
2363
  const def = getEventDefinition(eventType);
2340
- def.metadataSchema.parse(metadata);
2364
+ parse2(def.metadataSchema, metadata);
2341
2365
  }
2342
2366
  raw.trackEvent({
2343
2367
  eventType,
@@ -2961,117 +2985,6 @@ function attachPhoneClickCapture(client, config) {
2961
2985
  };
2962
2986
  }
2963
2987
 
2964
- // ../tracking-core/src/resources/sales/schema.ts
2965
- import { z as z12 } from "zod";
2966
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
2967
- var TRACKING_ENVIRONMENTS = ["production", "development"];
2968
- var currencySchema = z12.enum(SUPPORTED_CURRENCIES);
2969
- var centsSchema = z12.number().int().nonnegative();
2970
- var quantitySchema = z12.string().regex(/^\d+(\.\d{1,3})?$/);
2971
- var metadataSchema = z12.record(z12.unknown());
2972
- var saleItemSchema = z12.object({
2973
- external_item_id: z12.string().nullable().optional(),
2974
- name: z12.string().nullable().optional(),
2975
- category: z12.string().nullable().optional(),
2976
- quantity: quantitySchema,
2977
- unit_price_cents: centsSchema,
2978
- // Non-negativity validated on the wire — same contract as the other cents
2979
- // fields — and backstopped by the DB CHECK.
2980
- unit_cost_cents: centsSchema.nullable().optional()
2981
- }).strict();
2982
- var saleServiceSchema = z12.object({
2983
- service: z12.string(),
2984
- amount_cents: centsSchema
2985
- }).strict();
2986
- var customerNameSchema = z12.string().max(200);
2987
- var customerPhoneSchema = z12.string().max(64);
2988
- var customerEmailSchema = z12.string().max(320).email();
2989
- function refineServiceXor(val, ctx, { requireAmount }) {
2990
- if (val.services != null) {
2991
- if (val.service != null) {
2992
- ctx.addIssue({
2993
- code: z12.ZodIssueCode.custom,
2994
- message: "pass either `service` or `services`, not both",
2995
- path: ["services"]
2996
- });
2997
- }
2998
- if (val.services.length === 0) {
2999
- ctx.addIssue({
3000
- code: z12.ZodIssueCode.custom,
3001
- message: "`services` must not be empty",
3002
- path: ["services"]
3003
- });
3004
- }
3005
- const keys = val.services.map((s) => s.service);
3006
- if (new Set(keys).size !== keys.length) {
3007
- ctx.addIssue({
3008
- code: z12.ZodIssueCode.custom,
3009
- message: "`services` must not list the same service more than once",
3010
- path: ["services"]
3011
- });
3012
- }
3013
- if (val.amount_total_cents != null) {
3014
- const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
3015
- if (val.amount_total_cents !== sum) {
3016
- ctx.addIssue({
3017
- code: z12.ZodIssueCode.custom,
3018
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
3019
- path: ["amount_total_cents"]
3020
- });
3021
- }
3022
- }
3023
- } else if (requireAmount && val.amount_total_cents == null) {
3024
- ctx.addIssue({
3025
- code: z12.ZodIssueCode.custom,
3026
- message: "amount_total_cents is required unless `services` is provided",
3027
- path: ["amount_total_cents"]
3028
- });
3029
- }
3030
- }
3031
- var saleCreateSchema = z12.object({
3032
- external_id: z12.string().nullable().optional(),
3033
- description: z12.string().nullable().optional(),
3034
- service: z12.string().nullable().optional(),
3035
- services: z12.array(saleServiceSchema).nullable().optional(),
3036
- currency: currencySchema,
3037
- // Optional only because the plural `services` form derives it from the sum
3038
- // (see refineServiceXor); the singular/serviceless path still requires it.
3039
- amount_total_cents: centsSchema.nullable().optional(),
3040
- occurred_at: z12.string().datetime(),
3041
- environment: z12.enum(TRACKING_ENVIRONMENTS).default("production"),
3042
- items: z12.array(saleItemSchema).default([]),
3043
- metadata: metadataSchema.nullable().optional(),
3044
- customer_name: customerNameSchema.nullable().optional(),
3045
- customer_phone: customerPhoneSchema.nullable().optional(),
3046
- customer_email: customerEmailSchema.nullable().optional(),
3047
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
3048
- // with a timestamp server-side; every SMS send path gates on it.
3049
- //
3050
- // Tri-state: omit it (or send null) to let the server apply the business's
3051
- // configured default-opt-in policy, honouring a returning customer's
3052
- // remembered preference. Send an explicit boolean to assert consent state
3053
- // yourself — `false` records a deliberate opt-out.
3054
- sms_consent: z12.boolean().nullable().optional()
3055
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
3056
- var saleUpdateSchema = z12.object({
3057
- description: z12.string().nullable().optional(),
3058
- service: z12.string().nullable().optional(),
3059
- services: z12.array(saleServiceSchema).nullable().optional(),
3060
- currency: currencySchema.optional(),
3061
- amount_total_cents: centsSchema.optional(),
3062
- occurred_at: z12.string().datetime().optional(),
3063
- items: z12.array(saleItemSchema).optional(),
3064
- metadata: metadataSchema.nullable().optional(),
3065
- customer_name: customerNameSchema.nullable().optional(),
3066
- // Re-attest when changing a filler-looking name; the server clears the
3067
- // prior attestation whenever `customer_name` changes.
3068
- customer_name_placeholder_confirmed: z12.boolean().optional(),
3069
- customer_phone: customerPhoneSchema.nullable().optional(),
3070
- customer_email: customerEmailSchema.nullable().optional(),
3071
- // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
3072
- sms_consent: z12.boolean().optional()
3073
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
3074
-
3075
2988
  // src/hooks.ts
3076
2989
  function useGclid() {
3077
2990
  const [gclid, setGclid] = useState(null);
@@ -3351,7 +3264,7 @@ function AdPlatformTracking({
3351
3264
  metaPixelId,
3352
3265
  metaPixelIds
3353
3266
  }) {
3354
- const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
3267
+ const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.siteId ?? ""}:${trackingConfig.environment}` : "";
3355
3268
  const gtagIdsKey = useMemo(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
3356
3269
  const metaPixelIdsKey = useMemo(
3357
3270
  () => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
@@ -3403,7 +3316,7 @@ function GoogleAdsTracking(props) {
3403
3316
  import { createContext as createContext2, useContext as useContext2, useEffect as useEffect5, useMemo as useMemo4 } from "react";
3404
3317
 
3405
3318
  // package.json
3406
- var version = "0.26.0";
3319
+ var version = "1.0.0";
3407
3320
 
3408
3321
  // ../tracking-core/src/phone-react.tsx
3409
3322
  import {
@@ -3562,6 +3475,7 @@ function createTracking(options) {
3562
3475
  triggers,
3563
3476
  environment,
3564
3477
  activeGtagIds: resolvedGtagIds,
3478
+ configSiteId: trackingConfig?.siteId ?? null,
3565
3479
  debug
3566
3480
  }),
3567
3481
  [resolvedGtagIds]