@aranova/tracking-react 0.27.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.
package/dist/client.d.mts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
3
- import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, k as PhoneConfig, P as ParsedPhone, l as PhoneDisplayFormat } from './phone-utils-BVzSNBf1.mjs';
3
+ import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, k as PhoneConfig, P as ParsedPhone, l as PhoneDisplayFormat } from './phone-utils-CubQif9Z.mjs';
4
4
  import { T as TrackingConfigReference, C as ConversionConfig } from './tracking-config-runtime-D7prdTE1.mjs';
5
- import { N as TriggerRegistryConfig, Q as TypedTrackingClient } from './ingest-typed-BxLFlZ7N.mjs';
5
+ import { N as TriggerRegistryConfig, Q as TypedTrackingClient } from './ingest-typed-Bo7WPmpU.mjs';
6
6
  import { CountryCode } from 'libphonenumber-js';
7
- import 'zod';
7
+ import 'zod/mini';
8
8
  import 'src';
9
+ import 'zod/v4/core';
9
10
 
10
11
  /**
11
12
  * Legacy opt-in-era consent banner.
package/dist/client.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
3
- import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, k as PhoneConfig, P as ParsedPhone, l as PhoneDisplayFormat } from './phone-utils-BVzSNBf1.js';
3
+ import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, k as PhoneConfig, P as ParsedPhone, l as PhoneDisplayFormat } from './phone-utils-CubQif9Z.js';
4
4
  import { T as TrackingConfigReference, C as ConversionConfig } from './tracking-config-runtime-D7prdTE1.js';
5
- import { N as TriggerRegistryConfig, Q as TypedTrackingClient } from './ingest-typed-ByQVRMvP.js';
5
+ import { N as TriggerRegistryConfig, Q as TypedTrackingClient } from './ingest-typed-BdKmlouW.js';
6
6
  import { CountryCode } from 'libphonenumber-js';
7
- import 'zod';
7
+ import 'zod/mini';
8
8
  import 'src';
9
+ import 'zod/v4/core';
9
10
 
10
11
  /**
11
12
  * Legacy opt-in-era consent banner.
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));
@@ -1490,25 +1500,32 @@ function getOrRotateSessionId(now = Date.now()) {
1490
1500
  return { id: fresh.id, isNew: true };
1491
1501
  }
1492
1502
 
1503
+ // ../tracking-core/src/page-view.ts
1504
+ var import_mini = require("zod/mini");
1505
+
1493
1506
  // ../tracking-core/src/events/page-view.ts
1494
- var import_zod = require("zod");
1495
- var pageViewMetadataSchema = import_zod.z.object({
1496
- page: import_zod.z.object({
1497
- title: import_zod.z.string().nullable(),
1498
- path: import_zod.z.string(),
1499
- search: import_zod.z.string(),
1500
- hash: import_zod.z.string()
1501
- }).strict(),
1502
- referrer: import_zod.z.string().nullable(),
1503
- // `.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
1504
1517
  // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1505
1518
  // on the backend side so the drift test stays clean.
1506
- viewport: import_zod.z.object({
1507
- w: import_zod.z.number(),
1508
- h: import_zod.z.number()
1509
- }).strict().nullable().optional()
1510
- }).strict();
1511
- 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({});
1512
1529
 
1513
1530
  // ../tracking-core/src/page-view.ts
1514
1531
  var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
@@ -1544,7 +1561,7 @@ function setLastFiredUrl(url) {
1544
1561
  }
1545
1562
  function buildPageViewMetadata(referrerOverride) {
1546
1563
  if (typeof window === "undefined" || typeof document === "undefined") return null;
1547
- return pageViewMetadataSchema.parse({
1564
+ return (0, import_mini.parse)(pageViewMetadataSchema, {
1548
1565
  page: {
1549
1566
  title: document.title || null,
1550
1567
  path: window.location.pathname,
@@ -2040,186 +2057,198 @@ function createTrackingClient(config) {
2040
2057
  };
2041
2058
  }
2042
2059
 
2060
+ // ../tracking-core/src/ingest-typed.ts
2061
+ var import_mini2 = require("zod/mini");
2062
+
2043
2063
  // ../tracking-core/src/events/cta-click.ts
2044
- var import_zod2 = require("zod");
2045
- var ctaClickMetadataSchema = import_zod2.z.object({
2046
- cta_name: import_zod2.z.string(),
2047
- page: import_zod2.z.object({
2048
- path: import_zod2.z.string()
2049
- }).strict(),
2050
- section: import_zod2.z.string().nullable().optional(),
2051
- 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())),
2052
2072
  // Set by auto-capture (and available to manual callers): the link target
2053
2073
  // and a short element descriptor (tag#id) for tying clicks to specific UI.
2054
- href: import_zod2.z.string().nullable().optional(),
2055
- element: import_zod2.z.string().nullable().optional()
2056
- }).strict();
2057
- var ctaClickConfigSchema = import_zod2.z.object({
2058
- autoCapture: import_zod2.z.object({
2059
- selector: import_zod2.z.string().optional()
2060
- }).strict().optional()
2061
- }).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
+ });
2062
2084
 
2063
2085
  // ../tracking-core/src/events/sdk-heartbeat.ts
2064
- var import_zod3 = require("zod");
2065
- var sdkHeartbeatTriggersSchema = import_zod3.z.object({
2066
- automatic: import_zod3.z.array(import_zod3.z.string()),
2067
- manual: import_zod3.z.array(import_zod3.z.string())
2068
- }).strict();
2069
- var sdkHeartbeatMetadataSchema = import_zod3.z.object({
2070
- sdk_version: import_zod3.z.string(),
2071
- package_name: import_zod3.z.string().nullable(),
2072
- 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"]),
2073
2095
  triggers: sdkHeartbeatTriggersSchema,
2074
- trigger_config: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown())).nullable().optional(),
2075
- configured_gtag_ids: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).nullable().optional(),
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()))),
2076
2098
  // Site whose config object the SDK resolves; null on a legacy business ref.
2077
- config_site_id: import_zod3.z.string().uuid().nullable().optional()
2078
- }).strict();
2079
- var sdkHeartbeatConfigSchema = import_zod3.z.object({}).strict();
2099
+ config_site_id: z3.optional(z3.nullable(z3.uuid()))
2100
+ });
2101
+ var sdkHeartbeatConfigSchema = z3.strictObject({});
2080
2102
 
2081
2103
  // ../tracking-core/src/events/form-start.ts
2082
- var import_zod4 = require("zod");
2083
- var formStartMetadataSchema = import_zod4.z.object({
2084
- form: import_zod4.z.object({
2085
- id: import_zod4.z.string(),
2086
- action: import_zod4.z.string().nullable()
2087
- }).strict(),
2088
- page: import_zod4.z.object({
2089
- path: import_zod4.z.string()
2090
- }).strict()
2091
- }).strict();
2092
- var formStartConfigSchema = import_zod4.z.object({
2093
- selector: import_zod4.z.string().optional()
2094
- }).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
+ });
2095
2117
 
2096
2118
  // ../tracking-core/src/events/form-submit.ts
2097
- var import_zod5 = require("zod");
2098
- var jsonValueSchema = import_zod5.z.lazy(
2099
- () => import_zod5.z.union([
2100
- import_zod5.z.string(),
2101
- import_zod5.z.number().finite(),
2102
- import_zod5.z.boolean(),
2103
- import_zod5.z.null(),
2104
- import_zod5.z.array(jsonValueSchema),
2105
- 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)
2106
2128
  ])
2107
- );
2108
- var formSubmitMetadataSchema = import_zod5.z.object({
2109
- form: import_zod5.z.object({
2110
- id: import_zod5.z.string(),
2111
- action: import_zod5.z.string().nullable(),
2112
- fields: import_zod5.z.array(
2113
- import_zod5.z.object({
2114
- name: import_zod5.z.string(),
2115
- type: import_zod5.z.string(),
2116
- label: import_zod5.z.string().nullable(),
2117
- value: jsonValueSchema
2118
- }).strict()
2119
- ).optional()
2120
- }).strict(),
2121
- page: import_zod5.z.object({
2122
- path: import_zod5.z.string()
2123
- }).strict()
2124
- }).strict();
2125
- 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({});
2126
2150
 
2127
2151
  // ../tracking-core/src/events/multi-page-session.ts
2128
- var import_zod6 = require("zod");
2129
- var multiPageSessionMetadataSchema = import_zod6.z.object({
2130
- page_count: import_zod6.z.number().int().min(2),
2131
- page: import_zod6.z.object({
2132
- path: import_zod6.z.string()
2133
- }).strict()
2134
- }).strict();
2135
- var multiPageSessionConfigSchema = import_zod6.z.object({
2136
- pageThreshold: import_zod6.z.number().int().min(2)
2137
- }).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
+ });
2138
2162
 
2139
2163
  // ../tracking-core/src/events/page-exit.ts
2140
- var import_zod7 = require("zod");
2141
- var pageExitMetadataSchema = import_zod7.z.object({
2142
- 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)),
2143
2167
  // null = left without any scroll signal; floor is 0 so a valid 0% is never
2144
2168
  // rejected (a single bad field 422s the whole keepalive beacon batch).
2145
- 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))),
2146
2170
  // The gating baseline: the fraction of the page visible at load with
2147
2171
  // zero scrolling — or, for pages that grew after the post-paint snapshot
2148
2172
  // (skeleton/streaming renders), the first-scroll position that
2149
2173
  // established it. null = page had no scrollable range, or the segment
2150
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
2174
+ // ended before the snapshot. Optionality is load-bearing: SDK builds
2151
2175
  // predating this field keep POSTing page_exit without the key —
2152
2176
  // requiring it would 422 whole keepalive beacon batches.
2153
- scroll_baseline_percent: import_zod7.z.number().int().min(0).max(100).nullable().optional(),
2154
- page: import_zod7.z.object({
2155
- path: import_zod7.z.string()
2156
- }).strict()
2157
- }).strict();
2158
- 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({});
2159
2183
 
2160
2184
  // ../tracking-core/src/events/phone-click.ts
2161
- var import_zod8 = require("zod");
2162
- var phoneClickMetadataSchema = import_zod8.z.object({
2163
- phone_number: import_zod8.z.string(),
2164
- page: import_zod8.z.object({
2165
- path: import_zod8.z.string()
2166
- }).strict(),
2167
- section: import_zod8.z.string().nullable().optional()
2168
- }).strict();
2169
- var phoneClickConfigSchema = import_zod8.z.object({
2170
- autoCapture: import_zod8.z.object({
2171
- selector: import_zod8.z.string().optional()
2172
- }).strict().optional()
2173
- }).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
+ });
2174
2200
 
2175
2201
  // ../tracking-core/src/events/scroll-depth.ts
2176
- var import_zod9 = require("zod");
2177
- var scrollDepthMetadataSchema = import_zod9.z.object({
2178
- depth_percent: import_zod9.z.number().int().min(1).max(100),
2179
- page: import_zod9.z.object({
2180
- path: import_zod9.z.string()
2181
- }).strict()
2182
- }).strict();
2183
- var scrollDepthConfigSchema = import_zod9.z.object({
2184
- thresholds: import_zod9.z.array(import_zod9.z.number().int().min(1).max(100)).min(1)
2185
- }).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
+ });
2186
2212
 
2187
2213
  // ../tracking-core/src/events/specific-page-visit.ts
2188
- var import_zod10 = require("zod");
2214
+ var z10 = __toESM(require("zod/mini"));
2189
2215
  var PAGE_IDENTITY_MAX_LENGTH = 64;
2190
2216
  var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2191
- var pageIdentitySchema = import_zod10.z.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
2192
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2193
- });
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
+ );
2194
2223
  var specificPageNameSchema = pageIdentitySchema;
2195
- var specificPageVisitMetadataSchema = import_zod10.z.object({
2224
+ var specificPageVisitMetadataSchema = z10.strictObject({
2196
2225
  page_name: specificPageNameSchema,
2197
- page: import_zod10.z.object({
2198
- path: import_zod10.z.string()
2199
- }).strict()
2200
- }).strict();
2201
- var specificPageVisitConfigSchema = import_zod10.z.object({
2202
- pages: import_zod10.z.array(
2203
- 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({
2204
2233
  name: specificPageNameSchema,
2205
- pathPattern: import_zod10.z.custom((value) => value instanceof RegExp, {
2234
+ pathPattern: z10.custom((value) => value instanceof RegExp, {
2206
2235
  message: "pathPattern must be a RegExp"
2207
2236
  })
2208
- }).strict()
2209
- ).min(1)
2210
- }).strict();
2237
+ })
2238
+ ).check(z10.minLength(1))
2239
+ });
2211
2240
 
2212
2241
  // ../tracking-core/src/events/time-on-site.ts
2213
- var import_zod11 = require("zod");
2214
- var timeOnSiteMetadataSchema = import_zod11.z.object({
2215
- duration_ms: import_zod11.z.number().int().nonnegative(),
2216
- page: import_zod11.z.object({
2217
- path: import_zod11.z.string()
2218
- }).strict()
2219
- }).strict();
2220
- var timeOnSiteConfigSchema = import_zod11.z.object({
2221
- thresholdSeconds: import_zod11.z.number().int().positive()
2222
- }).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
+ });
2223
2252
 
2224
2253
  // ../tracking-core/src/events/semantics.ts
2225
2254
  var EVENT_SEMANTICS = {
@@ -2378,7 +2407,7 @@ function createTypedClient(raw, registry, options = {}) {
2378
2407
  trackEvent(eventType, metadata, opts) {
2379
2408
  if (debug) {
2380
2409
  const def = getEventDefinition(eventType);
2381
- def.metadataSchema.parse(metadata);
2410
+ (0, import_mini2.parse)(def.metadataSchema, metadata);
2382
2411
  }
2383
2412
  raw.trackEvent({
2384
2413
  eventType,
@@ -3002,117 +3031,6 @@ function attachPhoneClickCapture(client, config) {
3002
3031
  };
3003
3032
  }
3004
3033
 
3005
- // ../tracking-core/src/resources/sales/schema.ts
3006
- var import_zod12 = require("zod");
3007
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
3008
- var TRACKING_ENVIRONMENTS = ["production", "development"];
3009
- var currencySchema = import_zod12.z.enum(SUPPORTED_CURRENCIES);
3010
- var centsSchema = import_zod12.z.number().int().nonnegative();
3011
- var quantitySchema = import_zod12.z.string().regex(/^\d+(\.\d{1,3})?$/);
3012
- var metadataSchema = import_zod12.z.record(import_zod12.z.unknown());
3013
- var saleItemSchema = import_zod12.z.object({
3014
- external_item_id: import_zod12.z.string().nullable().optional(),
3015
- name: import_zod12.z.string().nullable().optional(),
3016
- category: import_zod12.z.string().nullable().optional(),
3017
- quantity: quantitySchema,
3018
- unit_price_cents: centsSchema,
3019
- // Non-negativity validated on the wire — same contract as the other cents
3020
- // fields — and backstopped by the DB CHECK.
3021
- unit_cost_cents: centsSchema.nullable().optional()
3022
- }).strict();
3023
- var saleServiceSchema = import_zod12.z.object({
3024
- service: import_zod12.z.string(),
3025
- amount_cents: centsSchema
3026
- }).strict();
3027
- var customerNameSchema = import_zod12.z.string().max(200);
3028
- var customerPhoneSchema = import_zod12.z.string().max(64);
3029
- var customerEmailSchema = import_zod12.z.string().max(320).email();
3030
- function refineServiceXor(val, ctx, { requireAmount }) {
3031
- if (val.services != null) {
3032
- if (val.service != null) {
3033
- ctx.addIssue({
3034
- code: import_zod12.z.ZodIssueCode.custom,
3035
- message: "pass either `service` or `services`, not both",
3036
- path: ["services"]
3037
- });
3038
- }
3039
- if (val.services.length === 0) {
3040
- ctx.addIssue({
3041
- code: import_zod12.z.ZodIssueCode.custom,
3042
- message: "`services` must not be empty",
3043
- path: ["services"]
3044
- });
3045
- }
3046
- const keys = val.services.map((s) => s.service);
3047
- if (new Set(keys).size !== keys.length) {
3048
- ctx.addIssue({
3049
- code: import_zod12.z.ZodIssueCode.custom,
3050
- message: "`services` must not list the same service more than once",
3051
- path: ["services"]
3052
- });
3053
- }
3054
- if (val.amount_total_cents != null) {
3055
- const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
3056
- if (val.amount_total_cents !== sum) {
3057
- ctx.addIssue({
3058
- code: import_zod12.z.ZodIssueCode.custom,
3059
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
3060
- path: ["amount_total_cents"]
3061
- });
3062
- }
3063
- }
3064
- } else if (requireAmount && val.amount_total_cents == null) {
3065
- ctx.addIssue({
3066
- code: import_zod12.z.ZodIssueCode.custom,
3067
- message: "amount_total_cents is required unless `services` is provided",
3068
- path: ["amount_total_cents"]
3069
- });
3070
- }
3071
- }
3072
- var saleCreateSchema = import_zod12.z.object({
3073
- external_id: import_zod12.z.string().nullable().optional(),
3074
- description: import_zod12.z.string().nullable().optional(),
3075
- service: import_zod12.z.string().nullable().optional(),
3076
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
3077
- currency: currencySchema,
3078
- // Optional only because the plural `services` form derives it from the sum
3079
- // (see refineServiceXor); the singular/serviceless path still requires it.
3080
- amount_total_cents: centsSchema.nullable().optional(),
3081
- occurred_at: import_zod12.z.string().datetime(),
3082
- environment: import_zod12.z.enum(TRACKING_ENVIRONMENTS).default("production"),
3083
- items: import_zod12.z.array(saleItemSchema).default([]),
3084
- metadata: metadataSchema.nullable().optional(),
3085
- customer_name: customerNameSchema.nullable().optional(),
3086
- customer_phone: customerPhoneSchema.nullable().optional(),
3087
- customer_email: customerEmailSchema.nullable().optional(),
3088
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
3089
- // with a timestamp server-side; every SMS send path gates on it.
3090
- //
3091
- // Tri-state: omit it (or send null) to let the server apply the business's
3092
- // configured default-opt-in policy, honouring a returning customer's
3093
- // remembered preference. Send an explicit boolean to assert consent state
3094
- // yourself — `false` records a deliberate opt-out.
3095
- sms_consent: import_zod12.z.boolean().nullable().optional()
3096
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
3097
- var saleUpdateSchema = import_zod12.z.object({
3098
- description: import_zod12.z.string().nullable().optional(),
3099
- service: import_zod12.z.string().nullable().optional(),
3100
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
3101
- currency: currencySchema.optional(),
3102
- amount_total_cents: centsSchema.optional(),
3103
- occurred_at: import_zod12.z.string().datetime().optional(),
3104
- items: import_zod12.z.array(saleItemSchema).optional(),
3105
- metadata: metadataSchema.nullable().optional(),
3106
- customer_name: customerNameSchema.nullable().optional(),
3107
- // Re-attest when changing a filler-looking name; the server clears the
3108
- // prior attestation whenever `customer_name` changes.
3109
- customer_name_placeholder_confirmed: import_zod12.z.boolean().optional(),
3110
- customer_phone: customerPhoneSchema.nullable().optional(),
3111
- customer_email: customerEmailSchema.nullable().optional(),
3112
- // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
3113
- sms_consent: import_zod12.z.boolean().optional()
3114
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
3115
-
3116
3034
  // src/hooks.ts
3117
3035
  function useGclid() {
3118
3036
  const [gclid, setGclid] = (0, import_react.useState)(null);
@@ -3444,7 +3362,7 @@ function GoogleAdsTracking(props) {
3444
3362
  var import_react6 = require("react");
3445
3363
 
3446
3364
  // package.json
3447
- var version = "0.27.0";
3365
+ var version = "1.0.0";
3448
3366
 
3449
3367
  // ../tracking-core/src/phone-react.tsx
3450
3368
  var import_react5 = require("react");