@aranova/tracking-next 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 (73) hide show
  1. package/dist/blog-server.d.mts +2 -1
  2. package/dist/blog-server.d.ts +2 -1
  3. package/dist/blog-server.js +121 -98
  4. package/dist/blog-server.js.map +1 -1
  5. package/dist/blog-server.mjs +86 -63
  6. package/dist/blog-server.mjs.map +1 -1
  7. package/dist/blog.d.mts +651 -1755
  8. package/dist/blog.d.ts +651 -1755
  9. package/dist/blog.js +121 -98
  10. package/dist/blog.js.map +1 -1
  11. package/dist/blog.mjs +86 -63
  12. package/dist/blog.mjs.map +1 -1
  13. package/dist/calendar-server.d.mts +2 -2
  14. package/dist/calendar-server.d.ts +2 -2
  15. package/dist/calendar-server.js +0 -26
  16. package/dist/calendar-server.js.map +1 -1
  17. package/dist/calendar-server.mjs +0 -26
  18. package/dist/calendar-server.mjs.map +1 -1
  19. package/dist/calendar.d.mts +3 -3
  20. package/dist/calendar.d.ts +3 -3
  21. package/dist/calendar.js +227 -126
  22. package/dist/calendar.js.map +1 -1
  23. package/dist/calendar.mjs +216 -125
  24. package/dist/calendar.mjs.map +1 -1
  25. package/dist/client.d.mts +5 -4
  26. package/dist/client.d.ts +5 -4
  27. package/dist/client.js +197 -283
  28. package/dist/client.js.map +1 -1
  29. package/dist/client.mjs +169 -255
  30. package/dist/client.mjs.map +1 -1
  31. package/dist/index.d.mts +9 -8
  32. package/dist/index.d.ts +9 -8
  33. package/dist/index.js +486 -485
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +475 -485
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/ingest-typed-BdKmlouW.d.ts +791 -0
  38. package/dist/ingest-typed-Bo7WPmpU.d.mts +791 -0
  39. package/dist/middleware.js +0 -465
  40. package/dist/middleware.js.map +1 -1
  41. package/dist/middleware.mjs +0 -465
  42. package/dist/middleware.mjs.map +1 -1
  43. package/dist/{phone-utils-BVzSNBf1.d.mts → phone-utils-CubQif9Z.d.mts} +18 -78
  44. package/dist/{phone-utils-BVzSNBf1.d.ts → phone-utils-CubQif9Z.d.ts} +18 -78
  45. package/dist/phone.d.mts +2 -2
  46. package/dist/phone.d.ts +2 -2
  47. package/dist/phone.js +0 -462
  48. package/dist/phone.js.map +1 -1
  49. package/dist/phone.mjs +0 -462
  50. package/dist/phone.mjs.map +1 -1
  51. package/dist/{sales-f1iXwlaV.d.mts → sales-D7KstKA-.d.mts} +90 -329
  52. package/dist/{sales-C3dIw4LW.d.ts → sales-DG150g3o.d.ts} +90 -329
  53. package/dist/sales.d.mts +3 -3
  54. package/dist/sales.d.ts +3 -3
  55. package/dist/sales.js +265 -127
  56. package/dist/sales.js.map +1 -1
  57. package/dist/sales.mjs +254 -127
  58. package/dist/sales.mjs.map +1 -1
  59. package/dist/server.d.mts +2 -2
  60. package/dist/server.d.ts +2 -2
  61. package/dist/server.js +0 -465
  62. package/dist/server.js.map +1 -1
  63. package/dist/server.mjs +0 -465
  64. package/dist/server.mjs.map +1 -1
  65. package/dist/{tracking-config-runtime-BnUlS_Ae.d.mts → tracking-config-runtime-D7prdTE1.d.mts} +6 -0
  66. package/dist/{tracking-config-runtime-BnUlS_Ae.d.ts → tracking-config-runtime-D7prdTE1.d.ts} +6 -0
  67. package/dist/transport-CDmGOiCq.d.ts +253 -0
  68. package/dist/transport-I_cMSFQ6.d.mts +253 -0
  69. package/package.json +2 -2
  70. package/dist/ingest-typed-BioxtBJD.d.mts +0 -1365
  71. package/dist/ingest-typed-C-SPiigr.d.ts +0 -1365
  72. package/dist/transport-C-_rFSR4.d.ts +0 -721
  73. package/dist/transport-yUF5Wize.d.mts +0 -721
package/dist/client.mjs CHANGED
@@ -580,10 +580,10 @@ function readStoredRecord() {
580
580
  return null;
581
581
  }
582
582
  }
583
- function writeRecord(record) {
584
- memoryRecord = record;
583
+ function writeRecord(record3) {
584
+ memoryRecord = record3;
585
585
  try {
586
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
586
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record3));
587
587
  } catch {
588
588
  }
589
589
  }
@@ -605,9 +605,9 @@ function getOrCaptureLandingParams(sessionId, url) {
605
605
  if (memoryRecord && memoryRecord.session_id === sessionId) {
606
606
  return memoryRecord.params;
607
607
  }
608
- const record = { session_id: sessionId, params: captureFromUrl(url) };
609
- writeRecord(record);
610
- return record.params;
608
+ const record3 = { session_id: sessionId, params: captureFromUrl(url) };
609
+ writeRecord(record3);
610
+ return record3.params;
611
611
  }
612
612
  function buildLandingPayloadFields(sessionId, override) {
613
613
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -942,14 +942,15 @@ function fromMinor(cents, currency) {
942
942
 
943
943
  // ../tracking-core/src/resources/tracking-config-runtime.ts
944
944
  var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
945
- function trackingConfigKey(businessId, environment) {
946
- return `tracking-config/v1/${businessId}-${environment}.json`;
945
+ function trackingConfigKey(ref) {
946
+ if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
947
+ return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
947
948
  }
948
949
  function resolveTrackingConfigUrl(ref) {
949
950
  if (ref.cdnUrl) return ref.cdnUrl;
950
951
  const configured = ref.cdnBaseUrl?.trim();
951
952
  const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
952
- return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
953
+ return `${base}/${trackingConfigKey(ref)}`;
953
954
  }
954
955
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
955
956
  var AUTHORITY_TTL_MS = 6e4;
@@ -1438,25 +1439,32 @@ function getOrRotateSessionId(now = Date.now()) {
1438
1439
  return { id: fresh.id, isNew: true };
1439
1440
  }
1440
1441
 
1442
+ // ../tracking-core/src/page-view.ts
1443
+ import { parse } from "zod/mini";
1444
+
1441
1445
  // ../tracking-core/src/events/page-view.ts
1442
- import { z } from "zod";
1443
- var pageViewMetadataSchema = z.object({
1444
- page: z.object({
1445
- title: z.string().nullable(),
1446
+ import * as z from "zod/mini";
1447
+ var pageViewMetadataSchema = z.strictObject({
1448
+ page: z.strictObject({
1449
+ title: z.nullable(z.string()),
1446
1450
  path: z.string(),
1447
1451
  search: z.string(),
1448
1452
  hash: z.string()
1449
- }).strict(),
1450
- referrer: z.string().nullable(),
1451
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1453
+ }),
1454
+ referrer: z.nullable(z.string()),
1455
+ // Optional + nullable — absent (undefined) OR explicit null OR a
1452
1456
  // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1453
1457
  // on the backend side so the drift test stays clean.
1454
- viewport: z.object({
1455
- w: z.number(),
1456
- h: z.number()
1457
- }).strict().nullable().optional()
1458
- }).strict();
1459
- var pageViewConfigSchema = z.object({}).strict();
1458
+ viewport: z.optional(
1459
+ z.nullable(
1460
+ z.strictObject({
1461
+ w: z.number(),
1462
+ h: z.number()
1463
+ })
1464
+ )
1465
+ )
1466
+ });
1467
+ var pageViewConfigSchema = z.strictObject({});
1460
1468
 
1461
1469
  // ../tracking-core/src/page-view.ts
1462
1470
  var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
@@ -1492,7 +1500,7 @@ function setLastFiredUrl(url) {
1492
1500
  }
1493
1501
  function buildPageViewMetadata(referrerOverride) {
1494
1502
  if (typeof window === "undefined" || typeof document === "undefined") return null;
1495
- return pageViewMetadataSchema.parse({
1503
+ return parse(pageViewMetadataSchema, {
1496
1504
  page: {
1497
1505
  title: document.title || null,
1498
1506
  path: window.location.pathname,
@@ -1546,7 +1554,7 @@ function serializeValue(value) {
1546
1554
  }
1547
1555
  return value;
1548
1556
  }
1549
- function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null) {
1557
+ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null, configSiteId = null) {
1550
1558
  const automaticNames = triggers ? Object.keys(triggers.automatic) : [];
1551
1559
  const manualNames = triggers?.manual ? Object.keys(triggers.manual) : [];
1552
1560
  let triggerConfig = null;
@@ -1580,7 +1588,8 @@ function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtag
1580
1588
  manual: manualNames
1581
1589
  },
1582
1590
  trigger_config: triggerConfig,
1583
- configured_gtag_ids: gtagIds
1591
+ configured_gtag_ids: gtagIds,
1592
+ config_site_id: configSiteId
1584
1593
  };
1585
1594
  }
1586
1595
 
@@ -1777,7 +1786,8 @@ function createTrackingClient(config) {
1777
1786
  sdkVersion,
1778
1787
  packageName,
1779
1788
  config.triggers ?? null,
1780
- activeGtagIds
1789
+ activeGtagIds,
1790
+ config.configSiteId ?? null
1781
1791
  );
1782
1792
  queue.push({
1783
1793
  event_type: "sdk_heartbeat",
@@ -1948,184 +1958,198 @@ function createTrackingClient(config) {
1948
1958
  };
1949
1959
  }
1950
1960
 
1961
+ // ../tracking-core/src/ingest-typed.ts
1962
+ import { parse as parse2 } from "zod/mini";
1963
+
1951
1964
  // ../tracking-core/src/events/cta-click.ts
1952
- import { z as z2 } from "zod";
1953
- var ctaClickMetadataSchema = z2.object({
1965
+ import * as z2 from "zod/mini";
1966
+ var ctaClickMetadataSchema = z2.strictObject({
1954
1967
  cta_name: z2.string(),
1955
- page: z2.object({
1968
+ page: z2.strictObject({
1956
1969
  path: z2.string()
1957
- }).strict(),
1958
- section: z2.string().nullable().optional(),
1959
- destination_url: z2.string().nullable().optional(),
1970
+ }),
1971
+ section: z2.optional(z2.nullable(z2.string())),
1972
+ destination_url: z2.optional(z2.nullable(z2.string())),
1960
1973
  // Set by auto-capture (and available to manual callers): the link target
1961
1974
  // and a short element descriptor (tag#id) for tying clicks to specific UI.
1962
- href: z2.string().nullable().optional(),
1963
- element: z2.string().nullable().optional()
1964
- }).strict();
1965
- var ctaClickConfigSchema = z2.object({
1966
- autoCapture: z2.object({
1967
- selector: z2.string().optional()
1968
- }).strict().optional()
1969
- }).strict();
1975
+ href: z2.optional(z2.nullable(z2.string())),
1976
+ element: z2.optional(z2.nullable(z2.string()))
1977
+ });
1978
+ var ctaClickConfigSchema = z2.strictObject({
1979
+ autoCapture: z2.optional(
1980
+ z2.strictObject({
1981
+ selector: z2.optional(z2.string())
1982
+ })
1983
+ )
1984
+ });
1970
1985
 
1971
1986
  // ../tracking-core/src/events/sdk-heartbeat.ts
1972
- import { z as z3 } from "zod";
1973
- var sdkHeartbeatTriggersSchema = z3.object({
1987
+ import * as z3 from "zod/mini";
1988
+ var sdkHeartbeatTriggersSchema = z3.strictObject({
1974
1989
  automatic: z3.array(z3.string()),
1975
1990
  manual: z3.array(z3.string())
1976
- }).strict();
1977
- var sdkHeartbeatMetadataSchema = z3.object({
1991
+ });
1992
+ var sdkHeartbeatMetadataSchema = z3.strictObject({
1978
1993
  sdk_version: z3.string(),
1979
- package_name: z3.string().nullable(),
1994
+ package_name: z3.nullable(z3.string()),
1980
1995
  surface: z3.enum(["next", "react", "script"]),
1981
1996
  triggers: sdkHeartbeatTriggersSchema,
1982
- trigger_config: z3.record(z3.string(), z3.record(z3.string(), z3.unknown())).nullable().optional(),
1983
- configured_gtag_ids: z3.record(z3.string(), z3.string()).nullable().optional()
1984
- }).strict();
1985
- var sdkHeartbeatConfigSchema = z3.object({}).strict();
1997
+ trigger_config: z3.optional(z3.nullable(z3.record(z3.string(), z3.record(z3.string(), z3.unknown())))),
1998
+ configured_gtag_ids: z3.optional(z3.nullable(z3.record(z3.string(), z3.string()))),
1999
+ // Site whose config object the SDK resolves; null on a legacy business ref.
2000
+ config_site_id: z3.optional(z3.nullable(z3.uuid()))
2001
+ });
2002
+ var sdkHeartbeatConfigSchema = z3.strictObject({});
1986
2003
 
1987
2004
  // ../tracking-core/src/events/form-start.ts
1988
- import { z as z4 } from "zod";
1989
- var formStartMetadataSchema = z4.object({
1990
- form: z4.object({
2005
+ import * as z4 from "zod/mini";
2006
+ var formStartMetadataSchema = z4.strictObject({
2007
+ form: z4.strictObject({
1991
2008
  id: z4.string(),
1992
- action: z4.string().nullable()
1993
- }).strict(),
1994
- page: z4.object({
2009
+ action: z4.nullable(z4.string())
2010
+ }),
2011
+ page: z4.strictObject({
1995
2012
  path: z4.string()
1996
- }).strict()
1997
- }).strict();
1998
- var formStartConfigSchema = z4.object({
1999
- selector: z4.string().optional()
2000
- }).strict();
2013
+ })
2014
+ });
2015
+ var formStartConfigSchema = z4.strictObject({
2016
+ selector: z4.optional(z4.string())
2017
+ });
2001
2018
 
2002
2019
  // ../tracking-core/src/events/form-submit.ts
2003
- import { z as z5 } from "zod";
2020
+ import * as z5 from "zod/mini";
2004
2021
  var jsonValueSchema = z5.lazy(
2005
2022
  () => z5.union([
2006
2023
  z5.string(),
2007
- z5.number().finite(),
2024
+ z5.number(),
2008
2025
  z5.boolean(),
2009
2026
  z5.null(),
2010
2027
  z5.array(jsonValueSchema),
2011
- z5.record(jsonValueSchema)
2028
+ z5.record(z5.string(), jsonValueSchema)
2012
2029
  ])
2013
- );
2014
- var formSubmitMetadataSchema = z5.object({
2015
- form: z5.object({
2030
+ ).register(z5.globalRegistry, { id: "JsonSerializableValue" });
2031
+ var formSubmitMetadataSchema = z5.strictObject({
2032
+ form: z5.strictObject({
2016
2033
  id: z5.string(),
2017
- action: z5.string().nullable(),
2018
- fields: z5.array(
2019
- z5.object({
2020
- name: z5.string(),
2021
- type: z5.string(),
2022
- label: z5.string().nullable(),
2023
- value: jsonValueSchema
2024
- }).strict()
2025
- ).optional()
2026
- }).strict(),
2027
- page: z5.object({
2034
+ action: z5.nullable(z5.string()),
2035
+ fields: z5.optional(
2036
+ z5.array(
2037
+ z5.strictObject({
2038
+ name: z5.string(),
2039
+ type: z5.string(),
2040
+ label: z5.nullable(z5.string()),
2041
+ value: jsonValueSchema
2042
+ })
2043
+ )
2044
+ )
2045
+ }),
2046
+ page: z5.strictObject({
2028
2047
  path: z5.string()
2029
- }).strict()
2030
- }).strict();
2031
- var formSubmitConfigSchema = z5.object({}).strict();
2048
+ })
2049
+ });
2050
+ var formSubmitConfigSchema = z5.strictObject({});
2032
2051
 
2033
2052
  // ../tracking-core/src/events/multi-page-session.ts
2034
- import { z as z6 } from "zod";
2035
- var multiPageSessionMetadataSchema = z6.object({
2036
- page_count: z6.number().int().min(2),
2037
- page: z6.object({
2053
+ import * as z6 from "zod/mini";
2054
+ var multiPageSessionMetadataSchema = z6.strictObject({
2055
+ page_count: z6.int().check(z6.gte(2)),
2056
+ page: z6.strictObject({
2038
2057
  path: z6.string()
2039
- }).strict()
2040
- }).strict();
2041
- var multiPageSessionConfigSchema = z6.object({
2042
- pageThreshold: z6.number().int().min(2)
2043
- }).strict();
2058
+ })
2059
+ });
2060
+ var multiPageSessionConfigSchema = z6.strictObject({
2061
+ pageThreshold: z6.int().check(z6.gte(2))
2062
+ });
2044
2063
 
2045
2064
  // ../tracking-core/src/events/page-exit.ts
2046
- import { z as z7 } from "zod";
2047
- var pageExitMetadataSchema = z7.object({
2048
- dwell_ms: z7.number().int().min(0),
2065
+ import * as z7 from "zod/mini";
2066
+ var pageExitMetadataSchema = z7.strictObject({
2067
+ dwell_ms: z7.int().check(z7.gte(0)),
2049
2068
  // null = left without any scroll signal; floor is 0 so a valid 0% is never
2050
2069
  // rejected (a single bad field 422s the whole keepalive beacon batch).
2051
- max_scroll_percent: z7.number().int().min(0).max(100).nullable(),
2070
+ max_scroll_percent: z7.nullable(z7.int().check(z7.gte(0), z7.lte(100))),
2052
2071
  // The gating baseline: the fraction of the page visible at load with
2053
2072
  // zero scrolling — or, for pages that grew after the post-paint snapshot
2054
2073
  // (skeleton/streaming renders), the first-scroll position that
2055
2074
  // established it. null = page had no scrollable range, or the segment
2056
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
2075
+ // ended before the snapshot. Optionality is load-bearing: SDK builds
2057
2076
  // predating this field keep POSTing page_exit without the key —
2058
2077
  // requiring it would 422 whole keepalive beacon batches.
2059
- scroll_baseline_percent: z7.number().int().min(0).max(100).nullable().optional(),
2060
- page: z7.object({
2078
+ scroll_baseline_percent: z7.optional(z7.nullable(z7.int().check(z7.gte(0), z7.lte(100)))),
2079
+ page: z7.strictObject({
2061
2080
  path: z7.string()
2062
- }).strict()
2063
- }).strict();
2064
- var pageExitConfigSchema = z7.object({}).strict();
2081
+ })
2082
+ });
2083
+ var pageExitConfigSchema = z7.strictObject({});
2065
2084
 
2066
2085
  // ../tracking-core/src/events/phone-click.ts
2067
- import { z as z8 } from "zod";
2068
- var phoneClickMetadataSchema = z8.object({
2086
+ import * as z8 from "zod/mini";
2087
+ var phoneClickMetadataSchema = z8.strictObject({
2069
2088
  phone_number: z8.string(),
2070
- page: z8.object({
2089
+ page: z8.strictObject({
2071
2090
  path: z8.string()
2072
- }).strict(),
2073
- section: z8.string().nullable().optional()
2074
- }).strict();
2075
- var phoneClickConfigSchema = z8.object({
2076
- autoCapture: z8.object({
2077
- selector: z8.string().optional()
2078
- }).strict().optional()
2079
- }).strict();
2091
+ }),
2092
+ section: z8.optional(z8.nullable(z8.string()))
2093
+ });
2094
+ var phoneClickConfigSchema = z8.strictObject({
2095
+ autoCapture: z8.optional(
2096
+ z8.strictObject({
2097
+ selector: z8.optional(z8.string())
2098
+ })
2099
+ )
2100
+ });
2080
2101
 
2081
2102
  // ../tracking-core/src/events/scroll-depth.ts
2082
- import { z as z9 } from "zod";
2083
- var scrollDepthMetadataSchema = z9.object({
2084
- depth_percent: z9.number().int().min(1).max(100),
2085
- page: z9.object({
2103
+ import * as z9 from "zod/mini";
2104
+ var scrollDepthMetadataSchema = z9.strictObject({
2105
+ depth_percent: z9.int().check(z9.gte(1), z9.lte(100)),
2106
+ page: z9.strictObject({
2086
2107
  path: z9.string()
2087
- }).strict()
2088
- }).strict();
2089
- var scrollDepthConfigSchema = z9.object({
2090
- thresholds: z9.array(z9.number().int().min(1).max(100)).min(1)
2091
- }).strict();
2108
+ })
2109
+ });
2110
+ var scrollDepthConfigSchema = z9.strictObject({
2111
+ thresholds: z9.array(z9.int().check(z9.gte(1), z9.lte(100))).check(z9.minLength(1))
2112
+ });
2092
2113
 
2093
2114
  // ../tracking-core/src/events/specific-page-visit.ts
2094
- import { z as z10 } from "zod";
2115
+ import * as z10 from "zod/mini";
2095
2116
  var PAGE_IDENTITY_MAX_LENGTH = 64;
2096
2117
  var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2097
- var pageIdentitySchema = z10.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
2098
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2099
- });
2118
+ var pageIdentitySchema = z10.string().check(
2119
+ z10.maxLength(PAGE_IDENTITY_MAX_LENGTH),
2120
+ z10.regex(PAGE_IDENTITY_PATTERN, {
2121
+ message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2122
+ })
2123
+ );
2100
2124
  var specificPageNameSchema = pageIdentitySchema;
2101
- var specificPageVisitMetadataSchema = z10.object({
2125
+ var specificPageVisitMetadataSchema = z10.strictObject({
2102
2126
  page_name: specificPageNameSchema,
2103
- page: z10.object({
2127
+ page: z10.strictObject({
2104
2128
  path: z10.string()
2105
- }).strict()
2106
- }).strict();
2107
- var specificPageVisitConfigSchema = z10.object({
2129
+ })
2130
+ });
2131
+ var specificPageVisitConfigSchema = z10.strictObject({
2108
2132
  pages: z10.array(
2109
- z10.object({
2133
+ z10.strictObject({
2110
2134
  name: specificPageNameSchema,
2111
2135
  pathPattern: z10.custom((value) => value instanceof RegExp, {
2112
2136
  message: "pathPattern must be a RegExp"
2113
2137
  })
2114
- }).strict()
2115
- ).min(1)
2116
- }).strict();
2138
+ })
2139
+ ).check(z10.minLength(1))
2140
+ });
2117
2141
 
2118
2142
  // ../tracking-core/src/events/time-on-site.ts
2119
- import { z as z11 } from "zod";
2120
- var timeOnSiteMetadataSchema = z11.object({
2121
- duration_ms: z11.number().int().nonnegative(),
2122
- page: z11.object({
2143
+ import * as z11 from "zod/mini";
2144
+ var timeOnSiteMetadataSchema = z11.strictObject({
2145
+ duration_ms: z11.int().check(z11.nonnegative()),
2146
+ page: z11.strictObject({
2123
2147
  path: z11.string()
2124
- }).strict()
2125
- }).strict();
2126
- var timeOnSiteConfigSchema = z11.object({
2127
- thresholdSeconds: z11.number().int().positive()
2128
- }).strict();
2148
+ })
2149
+ });
2150
+ var timeOnSiteConfigSchema = z11.strictObject({
2151
+ thresholdSeconds: z11.int().check(z11.positive())
2152
+ });
2129
2153
 
2130
2154
  // ../tracking-core/src/events/semantics.ts
2131
2155
  var EVENT_SEMANTICS = {
@@ -2284,7 +2308,7 @@ function createTypedClient(raw, registry, options = {}) {
2284
2308
  trackEvent(eventType, metadata, opts) {
2285
2309
  if (debug) {
2286
2310
  const def = getEventDefinition(eventType);
2287
- def.metadataSchema.parse(metadata);
2311
+ parse2(def.metadataSchema, metadata);
2288
2312
  }
2289
2313
  raw.trackEvent({
2290
2314
  eventType,
@@ -2773,117 +2797,6 @@ function attachPhoneClickCapture(client, config) {
2773
2797
  };
2774
2798
  }
2775
2799
 
2776
- // ../tracking-core/src/resources/sales/schema.ts
2777
- import { z as z12 } from "zod";
2778
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
2779
- var TRACKING_ENVIRONMENTS = ["production", "development"];
2780
- var currencySchema = z12.enum(SUPPORTED_CURRENCIES);
2781
- var centsSchema = z12.number().int().nonnegative();
2782
- var quantitySchema = z12.string().regex(/^\d+(\.\d{1,3})?$/);
2783
- var metadataSchema = z12.record(z12.unknown());
2784
- var saleItemSchema = z12.object({
2785
- external_item_id: z12.string().nullable().optional(),
2786
- name: z12.string().nullable().optional(),
2787
- category: z12.string().nullable().optional(),
2788
- quantity: quantitySchema,
2789
- unit_price_cents: centsSchema,
2790
- // Non-negativity validated on the wire — same contract as the other cents
2791
- // fields — and backstopped by the DB CHECK.
2792
- unit_cost_cents: centsSchema.nullable().optional()
2793
- }).strict();
2794
- var saleServiceSchema = z12.object({
2795
- service: z12.string(),
2796
- amount_cents: centsSchema
2797
- }).strict();
2798
- var customerNameSchema = z12.string().max(200);
2799
- var customerPhoneSchema = z12.string().max(64);
2800
- var customerEmailSchema = z12.string().max(320).email();
2801
- function refineServiceXor(val, ctx, { requireAmount }) {
2802
- if (val.services != null) {
2803
- if (val.service != null) {
2804
- ctx.addIssue({
2805
- code: z12.ZodIssueCode.custom,
2806
- message: "pass either `service` or `services`, not both",
2807
- path: ["services"]
2808
- });
2809
- }
2810
- if (val.services.length === 0) {
2811
- ctx.addIssue({
2812
- code: z12.ZodIssueCode.custom,
2813
- message: "`services` must not be empty",
2814
- path: ["services"]
2815
- });
2816
- }
2817
- const keys = val.services.map((s) => s.service);
2818
- if (new Set(keys).size !== keys.length) {
2819
- ctx.addIssue({
2820
- code: z12.ZodIssueCode.custom,
2821
- message: "`services` must not list the same service more than once",
2822
- path: ["services"]
2823
- });
2824
- }
2825
- if (val.amount_total_cents != null) {
2826
- const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
2827
- if (val.amount_total_cents !== sum) {
2828
- ctx.addIssue({
2829
- code: z12.ZodIssueCode.custom,
2830
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
2831
- path: ["amount_total_cents"]
2832
- });
2833
- }
2834
- }
2835
- } else if (requireAmount && val.amount_total_cents == null) {
2836
- ctx.addIssue({
2837
- code: z12.ZodIssueCode.custom,
2838
- message: "amount_total_cents is required unless `services` is provided",
2839
- path: ["amount_total_cents"]
2840
- });
2841
- }
2842
- }
2843
- var saleCreateSchema = z12.object({
2844
- external_id: z12.string().nullable().optional(),
2845
- description: z12.string().nullable().optional(),
2846
- service: z12.string().nullable().optional(),
2847
- services: z12.array(saleServiceSchema).nullable().optional(),
2848
- currency: currencySchema,
2849
- // Optional only because the plural `services` form derives it from the sum
2850
- // (see refineServiceXor); the singular/serviceless path still requires it.
2851
- amount_total_cents: centsSchema.nullable().optional(),
2852
- occurred_at: z12.string().datetime(),
2853
- environment: z12.enum(TRACKING_ENVIRONMENTS).default("production"),
2854
- items: z12.array(saleItemSchema).default([]),
2855
- metadata: metadataSchema.nullable().optional(),
2856
- customer_name: customerNameSchema.nullable().optional(),
2857
- customer_phone: customerPhoneSchema.nullable().optional(),
2858
- customer_email: customerEmailSchema.nullable().optional(),
2859
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
2860
- // with a timestamp server-side; every SMS send path gates on it.
2861
- //
2862
- // Tri-state: omit it (or send null) to let the server apply the business's
2863
- // configured default-opt-in policy, honouring a returning customer's
2864
- // remembered preference. Send an explicit boolean to assert consent state
2865
- // yourself — `false` records a deliberate opt-out.
2866
- sms_consent: z12.boolean().nullable().optional()
2867
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
2868
- var saleUpdateSchema = z12.object({
2869
- description: z12.string().nullable().optional(),
2870
- service: z12.string().nullable().optional(),
2871
- services: z12.array(saleServiceSchema).nullable().optional(),
2872
- currency: currencySchema.optional(),
2873
- amount_total_cents: centsSchema.optional(),
2874
- occurred_at: z12.string().datetime().optional(),
2875
- items: z12.array(saleItemSchema).optional(),
2876
- metadata: metadataSchema.nullable().optional(),
2877
- customer_name: customerNameSchema.nullable().optional(),
2878
- // Re-attest when changing a filler-looking name; the server clears the
2879
- // prior attestation whenever `customer_name` changes.
2880
- customer_name_placeholder_confirmed: z12.boolean().optional(),
2881
- customer_phone: customerPhoneSchema.nullable().optional(),
2882
- customer_email: customerEmailSchema.nullable().optional(),
2883
- // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2884
- sms_consent: z12.boolean().optional()
2885
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
2886
-
2887
2800
  // src/hooks.ts
2888
2801
  function useGclid() {
2889
2802
  const [gclid, setGclid] = useState(null);
@@ -3165,7 +3078,7 @@ function AdPlatformTracking({
3165
3078
  metaPixelId,
3166
3079
  metaPixelIds
3167
3080
  }) {
3168
- const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
3081
+ const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.siteId ?? ""}:${trackingConfig.environment}` : "";
3169
3082
  useEffect3(() => {
3170
3083
  if (!trackingConfig) return;
3171
3084
  const runtime = getTrackingConfigRuntime(trackingConfig);
@@ -3224,7 +3137,7 @@ function GoogleAdsTracking(props) {
3224
3137
  import { usePathname, useSearchParams } from "next/navigation";
3225
3138
 
3226
3139
  // package.json
3227
- var version = "0.26.0";
3140
+ var version = "1.0.0";
3228
3141
 
3229
3142
  // src/factory.tsx
3230
3143
  import {
@@ -3389,6 +3302,7 @@ function createTracking(options) {
3389
3302
  triggers,
3390
3303
  environment,
3391
3304
  activeGtagIds: gtagIds,
3305
+ configSiteId: trackingConfig?.siteId ?? null,
3392
3306
  debug
3393
3307
  }),
3394
3308
  []