@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.
- package/dist/client.d.mts +5 -4
- package/dist/client.d.ts +5 -4
- package/dist/client.js +207 -283
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +169 -255
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +275 -391
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +264 -391
- package/dist/index.mjs.map +1 -1
- package/dist/ingest-typed-BdKmlouW.d.ts +791 -0
- package/dist/ingest-typed-Bo7WPmpU.d.mts +791 -0
- package/dist/{phone-utils-BVzSNBf1.d.mts → phone-utils-CubQif9Z.d.mts} +18 -78
- package/dist/{phone-utils-BVzSNBf1.d.ts → phone-utils-CubQif9Z.d.ts} +18 -78
- package/dist/phone.d.mts +2 -2
- package/dist/phone.d.ts +2 -2
- package/dist/phone.js +0 -462
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +0 -462
- package/dist/phone.mjs.map +1 -1
- package/dist/{sales-1J-Z4AvL.d.ts → sales-Bhh9mLBA.d.ts} +90 -329
- package/dist/{sales-DzKvyVjY.d.mts → sales-C7Xjsq-a.d.mts} +90 -329
- package/dist/sales.d.mts +3 -3
- package/dist/sales.d.ts +3 -3
- package/dist/sales.js +265 -127
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +254 -127
- package/dist/sales.mjs.map +1 -1
- package/dist/{tracking-config-runtime-BnUlS_Ae.d.mts → tracking-config-runtime-D7prdTE1.d.mts} +6 -0
- package/dist/{tracking-config-runtime-BnUlS_Ae.d.ts → tracking-config-runtime-D7prdTE1.d.ts} +6 -0
- package/package.json +2 -2
- package/dist/ingest-typed-BioxtBJD.d.mts +0 -1365
- package/dist/ingest-typed-C-SPiigr.d.ts +0 -1365
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -39,6 +49,7 @@ __export(src_exports, {
|
|
|
39
49
|
createTrackingClientContext: () => createTrackingClientContext,
|
|
40
50
|
createTrackingEventCreatePayload: () => createTrackingEventCreatePayload,
|
|
41
51
|
createTrackingSessionUpsertPayload: () => createTrackingSessionUpsertPayload,
|
|
52
|
+
currencySchema: () => currencySchema,
|
|
42
53
|
fetchServices: () => fetchServices,
|
|
43
54
|
formatDateInTz: () => formatDateInTz,
|
|
44
55
|
formatMoney: () => formatMoney,
|
|
@@ -126,7 +137,7 @@ function normalizeEmail(raw) {
|
|
|
126
137
|
return EMAIL_SHAPE.test(cleaned) ? cleaned : null;
|
|
127
138
|
}
|
|
128
139
|
function stashUserData(data, country) {
|
|
129
|
-
const
|
|
140
|
+
const email3 = normalizeEmail(data.email);
|
|
130
141
|
let phoneNumber = null;
|
|
131
142
|
if (typeof data.phone === "string" && data.phone.length > 0) {
|
|
132
143
|
try {
|
|
@@ -136,7 +147,7 @@ function stashUserData(data, country) {
|
|
|
136
147
|
}
|
|
137
148
|
}
|
|
138
149
|
stash = {
|
|
139
|
-
email:
|
|
150
|
+
email: email3 ?? stash.email,
|
|
140
151
|
phoneNumber: phoneNumber ?? stash.phoneNumber
|
|
141
152
|
};
|
|
142
153
|
}
|
|
@@ -145,11 +156,11 @@ function clearStashedUserData() {
|
|
|
145
156
|
}
|
|
146
157
|
function applyUserDataForConversion(explicit, country) {
|
|
147
158
|
if (typeof window === "undefined" || typeof window.gtag !== "function") return false;
|
|
148
|
-
let
|
|
159
|
+
let email3 = stash.email;
|
|
149
160
|
let phoneNumber = stash.phoneNumber;
|
|
150
161
|
if (explicit) {
|
|
151
162
|
const normalizedEmail = normalizeEmail(explicit.email);
|
|
152
|
-
if (normalizedEmail)
|
|
163
|
+
if (normalizedEmail) email3 = normalizedEmail;
|
|
153
164
|
if (typeof explicit.phone === "string" && explicit.phone.length > 0) {
|
|
154
165
|
try {
|
|
155
166
|
phoneNumber = toE164(explicit.phone, country) ?? phoneNumber;
|
|
@@ -157,10 +168,10 @@ function applyUserDataForConversion(explicit, country) {
|
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
|
-
if (
|
|
171
|
+
if (email3 === null && phoneNumber === null) return false;
|
|
161
172
|
try {
|
|
162
173
|
window.gtag("set", "user_data", {
|
|
163
|
-
...
|
|
174
|
+
...email3 !== null ? { email: email3 } : {},
|
|
164
175
|
...phoneNumber !== null ? { phone_number: phoneNumber } : {}
|
|
165
176
|
});
|
|
166
177
|
return true;
|
|
@@ -516,10 +527,10 @@ function readStoredRecord() {
|
|
|
516
527
|
return null;
|
|
517
528
|
}
|
|
518
529
|
}
|
|
519
|
-
function writeRecord(
|
|
520
|
-
memoryRecord =
|
|
530
|
+
function writeRecord(record3) {
|
|
531
|
+
memoryRecord = record3;
|
|
521
532
|
try {
|
|
522
|
-
window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(
|
|
533
|
+
window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record3));
|
|
523
534
|
} catch {
|
|
524
535
|
}
|
|
525
536
|
}
|
|
@@ -541,9 +552,9 @@ function getOrCaptureLandingParams(sessionId, url) {
|
|
|
541
552
|
if (memoryRecord && memoryRecord.session_id === sessionId) {
|
|
542
553
|
return memoryRecord.params;
|
|
543
554
|
}
|
|
544
|
-
const
|
|
545
|
-
writeRecord(
|
|
546
|
-
return
|
|
555
|
+
const record3 = { session_id: sessionId, params: captureFromUrl(url) };
|
|
556
|
+
writeRecord(record3);
|
|
557
|
+
return record3.params;
|
|
547
558
|
}
|
|
548
559
|
function buildLandingPayloadFields(sessionId, override) {
|
|
549
560
|
const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
|
|
@@ -920,9 +931,9 @@ function automaticThresholdMet(goal, eventType, metadata) {
|
|
|
920
931
|
}
|
|
921
932
|
|
|
922
933
|
// ../tracking-core/src/resources/intl/date.ts
|
|
923
|
-
function formatDateInTz(
|
|
924
|
-
const date = new Date(
|
|
925
|
-
if (Number.isNaN(date.getTime())) return
|
|
934
|
+
function formatDateInTz(iso3, timeZone, opts, locale) {
|
|
935
|
+
const date = new Date(iso3);
|
|
936
|
+
if (Number.isNaN(date.getTime())) return iso3;
|
|
926
937
|
return new Intl.DateTimeFormat(locale, {
|
|
927
938
|
year: "numeric",
|
|
928
939
|
month: "short",
|
|
@@ -956,14 +967,15 @@ function formatMoney(cents, currency, locale) {
|
|
|
956
967
|
|
|
957
968
|
// ../tracking-core/src/resources/tracking-config-runtime.ts
|
|
958
969
|
var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
|
|
959
|
-
function trackingConfigKey(
|
|
960
|
-
return `tracking-config/v1/${
|
|
970
|
+
function trackingConfigKey(ref) {
|
|
971
|
+
if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
|
|
972
|
+
return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
|
|
961
973
|
}
|
|
962
974
|
function resolveTrackingConfigUrl(ref) {
|
|
963
975
|
if (ref.cdnUrl) return ref.cdnUrl;
|
|
964
976
|
const configured = ref.cdnBaseUrl?.trim();
|
|
965
977
|
const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
|
|
966
|
-
return `${base}/${trackingConfigKey(ref
|
|
978
|
+
return `${base}/${trackingConfigKey(ref)}`;
|
|
967
979
|
}
|
|
968
980
|
var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
|
|
969
981
|
var AUTHORITY_TTL_MS = 6e4;
|
|
@@ -1333,29 +1345,6 @@ function getTrackingConfigRuntime(ref, fetchImpl) {
|
|
|
1333
1345
|
return runtime;
|
|
1334
1346
|
}
|
|
1335
1347
|
|
|
1336
|
-
// ../tracking-core/src/session.ts
|
|
1337
|
-
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
1338
|
-
|
|
1339
|
-
// ../tracking-core/src/events/page-view.ts
|
|
1340
|
-
var import_zod = require("zod");
|
|
1341
|
-
var pageViewMetadataSchema = import_zod.z.object({
|
|
1342
|
-
page: import_zod.z.object({
|
|
1343
|
-
title: import_zod.z.string().nullable(),
|
|
1344
|
-
path: import_zod.z.string(),
|
|
1345
|
-
search: import_zod.z.string(),
|
|
1346
|
-
hash: import_zod.z.string()
|
|
1347
|
-
}).strict(),
|
|
1348
|
-
referrer: import_zod.z.string().nullable(),
|
|
1349
|
-
// `.nullable().optional()` — absent (undefined) OR explicit null OR a
|
|
1350
|
-
// real viewport object. Mirrors Pydantic's `_Viewport | None = None`
|
|
1351
|
-
// on the backend side so the drift test stays clean.
|
|
1352
|
-
viewport: import_zod.z.object({
|
|
1353
|
-
w: import_zod.z.number(),
|
|
1354
|
-
h: import_zod.z.number()
|
|
1355
|
-
}).strict().nullable().optional()
|
|
1356
|
-
}).strict();
|
|
1357
|
-
var pageViewConfigSchema = import_zod.z.object({}).strict();
|
|
1358
|
-
|
|
1359
1348
|
// ../tracking-core/src/ingest.ts
|
|
1360
1349
|
var API_KEY_HEADER = "X-Aranova-Api-Key";
|
|
1361
1350
|
var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
|
|
@@ -1363,185 +1352,6 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
1363
1352
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
1364
1353
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
1365
1354
|
|
|
1366
|
-
// ../tracking-core/src/events/cta-click.ts
|
|
1367
|
-
var import_zod2 = require("zod");
|
|
1368
|
-
var ctaClickMetadataSchema = import_zod2.z.object({
|
|
1369
|
-
cta_name: import_zod2.z.string(),
|
|
1370
|
-
page: import_zod2.z.object({
|
|
1371
|
-
path: import_zod2.z.string()
|
|
1372
|
-
}).strict(),
|
|
1373
|
-
section: import_zod2.z.string().nullable().optional(),
|
|
1374
|
-
destination_url: import_zod2.z.string().nullable().optional(),
|
|
1375
|
-
// Set by auto-capture (and available to manual callers): the link target
|
|
1376
|
-
// and a short element descriptor (tag#id) for tying clicks to specific UI.
|
|
1377
|
-
href: import_zod2.z.string().nullable().optional(),
|
|
1378
|
-
element: import_zod2.z.string().nullable().optional()
|
|
1379
|
-
}).strict();
|
|
1380
|
-
var ctaClickConfigSchema = import_zod2.z.object({
|
|
1381
|
-
autoCapture: import_zod2.z.object({
|
|
1382
|
-
selector: import_zod2.z.string().optional()
|
|
1383
|
-
}).strict().optional()
|
|
1384
|
-
}).strict();
|
|
1385
|
-
|
|
1386
|
-
// ../tracking-core/src/events/sdk-heartbeat.ts
|
|
1387
|
-
var import_zod3 = require("zod");
|
|
1388
|
-
var sdkHeartbeatTriggersSchema = import_zod3.z.object({
|
|
1389
|
-
automatic: import_zod3.z.array(import_zod3.z.string()),
|
|
1390
|
-
manual: import_zod3.z.array(import_zod3.z.string())
|
|
1391
|
-
}).strict();
|
|
1392
|
-
var sdkHeartbeatMetadataSchema = import_zod3.z.object({
|
|
1393
|
-
sdk_version: import_zod3.z.string(),
|
|
1394
|
-
package_name: import_zod3.z.string().nullable(),
|
|
1395
|
-
surface: import_zod3.z.enum(["next", "react", "script"]),
|
|
1396
|
-
triggers: sdkHeartbeatTriggersSchema,
|
|
1397
|
-
trigger_config: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown())).nullable().optional(),
|
|
1398
|
-
configured_gtag_ids: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).nullable().optional()
|
|
1399
|
-
}).strict();
|
|
1400
|
-
var sdkHeartbeatConfigSchema = import_zod3.z.object({}).strict();
|
|
1401
|
-
|
|
1402
|
-
// ../tracking-core/src/events/form-start.ts
|
|
1403
|
-
var import_zod4 = require("zod");
|
|
1404
|
-
var formStartMetadataSchema = import_zod4.z.object({
|
|
1405
|
-
form: import_zod4.z.object({
|
|
1406
|
-
id: import_zod4.z.string(),
|
|
1407
|
-
action: import_zod4.z.string().nullable()
|
|
1408
|
-
}).strict(),
|
|
1409
|
-
page: import_zod4.z.object({
|
|
1410
|
-
path: import_zod4.z.string()
|
|
1411
|
-
}).strict()
|
|
1412
|
-
}).strict();
|
|
1413
|
-
var formStartConfigSchema = import_zod4.z.object({
|
|
1414
|
-
selector: import_zod4.z.string().optional()
|
|
1415
|
-
}).strict();
|
|
1416
|
-
|
|
1417
|
-
// ../tracking-core/src/events/form-submit.ts
|
|
1418
|
-
var import_zod5 = require("zod");
|
|
1419
|
-
var jsonValueSchema = import_zod5.z.lazy(
|
|
1420
|
-
() => import_zod5.z.union([
|
|
1421
|
-
import_zod5.z.string(),
|
|
1422
|
-
import_zod5.z.number().finite(),
|
|
1423
|
-
import_zod5.z.boolean(),
|
|
1424
|
-
import_zod5.z.null(),
|
|
1425
|
-
import_zod5.z.array(jsonValueSchema),
|
|
1426
|
-
import_zod5.z.record(jsonValueSchema)
|
|
1427
|
-
])
|
|
1428
|
-
);
|
|
1429
|
-
var formSubmitMetadataSchema = import_zod5.z.object({
|
|
1430
|
-
form: import_zod5.z.object({
|
|
1431
|
-
id: import_zod5.z.string(),
|
|
1432
|
-
action: import_zod5.z.string().nullable(),
|
|
1433
|
-
fields: import_zod5.z.array(
|
|
1434
|
-
import_zod5.z.object({
|
|
1435
|
-
name: import_zod5.z.string(),
|
|
1436
|
-
type: import_zod5.z.string(),
|
|
1437
|
-
label: import_zod5.z.string().nullable(),
|
|
1438
|
-
value: jsonValueSchema
|
|
1439
|
-
}).strict()
|
|
1440
|
-
).optional()
|
|
1441
|
-
}).strict(),
|
|
1442
|
-
page: import_zod5.z.object({
|
|
1443
|
-
path: import_zod5.z.string()
|
|
1444
|
-
}).strict()
|
|
1445
|
-
}).strict();
|
|
1446
|
-
var formSubmitConfigSchema = import_zod5.z.object({}).strict();
|
|
1447
|
-
|
|
1448
|
-
// ../tracking-core/src/events/multi-page-session.ts
|
|
1449
|
-
var import_zod6 = require("zod");
|
|
1450
|
-
var multiPageSessionMetadataSchema = import_zod6.z.object({
|
|
1451
|
-
page_count: import_zod6.z.number().int().min(2),
|
|
1452
|
-
page: import_zod6.z.object({
|
|
1453
|
-
path: import_zod6.z.string()
|
|
1454
|
-
}).strict()
|
|
1455
|
-
}).strict();
|
|
1456
|
-
var multiPageSessionConfigSchema = import_zod6.z.object({
|
|
1457
|
-
pageThreshold: import_zod6.z.number().int().min(2)
|
|
1458
|
-
}).strict();
|
|
1459
|
-
|
|
1460
|
-
// ../tracking-core/src/events/page-exit.ts
|
|
1461
|
-
var import_zod7 = require("zod");
|
|
1462
|
-
var pageExitMetadataSchema = import_zod7.z.object({
|
|
1463
|
-
dwell_ms: import_zod7.z.number().int().min(0),
|
|
1464
|
-
// null = left without any scroll signal; floor is 0 so a valid 0% is never
|
|
1465
|
-
// rejected (a single bad field 422s the whole keepalive beacon batch).
|
|
1466
|
-
max_scroll_percent: import_zod7.z.number().int().min(0).max(100).nullable(),
|
|
1467
|
-
// The gating baseline: the fraction of the page visible at load with
|
|
1468
|
-
// zero scrolling — or, for pages that grew after the post-paint snapshot
|
|
1469
|
-
// (skeleton/streaming renders), the first-scroll position that
|
|
1470
|
-
// established it. null = page had no scrollable range, or the segment
|
|
1471
|
-
// ended before the snapshot. `.optional()` is load-bearing: SDK builds
|
|
1472
|
-
// predating this field keep POSTing page_exit without the key —
|
|
1473
|
-
// requiring it would 422 whole keepalive beacon batches.
|
|
1474
|
-
scroll_baseline_percent: import_zod7.z.number().int().min(0).max(100).nullable().optional(),
|
|
1475
|
-
page: import_zod7.z.object({
|
|
1476
|
-
path: import_zod7.z.string()
|
|
1477
|
-
}).strict()
|
|
1478
|
-
}).strict();
|
|
1479
|
-
var pageExitConfigSchema = import_zod7.z.object({}).strict();
|
|
1480
|
-
|
|
1481
|
-
// ../tracking-core/src/events/phone-click.ts
|
|
1482
|
-
var import_zod8 = require("zod");
|
|
1483
|
-
var phoneClickMetadataSchema = import_zod8.z.object({
|
|
1484
|
-
phone_number: import_zod8.z.string(),
|
|
1485
|
-
page: import_zod8.z.object({
|
|
1486
|
-
path: import_zod8.z.string()
|
|
1487
|
-
}).strict(),
|
|
1488
|
-
section: import_zod8.z.string().nullable().optional()
|
|
1489
|
-
}).strict();
|
|
1490
|
-
var phoneClickConfigSchema = import_zod8.z.object({
|
|
1491
|
-
autoCapture: import_zod8.z.object({
|
|
1492
|
-
selector: import_zod8.z.string().optional()
|
|
1493
|
-
}).strict().optional()
|
|
1494
|
-
}).strict();
|
|
1495
|
-
|
|
1496
|
-
// ../tracking-core/src/events/scroll-depth.ts
|
|
1497
|
-
var import_zod9 = require("zod");
|
|
1498
|
-
var scrollDepthMetadataSchema = import_zod9.z.object({
|
|
1499
|
-
depth_percent: import_zod9.z.number().int().min(1).max(100),
|
|
1500
|
-
page: import_zod9.z.object({
|
|
1501
|
-
path: import_zod9.z.string()
|
|
1502
|
-
}).strict()
|
|
1503
|
-
}).strict();
|
|
1504
|
-
var scrollDepthConfigSchema = import_zod9.z.object({
|
|
1505
|
-
thresholds: import_zod9.z.array(import_zod9.z.number().int().min(1).max(100)).min(1)
|
|
1506
|
-
}).strict();
|
|
1507
|
-
|
|
1508
|
-
// ../tracking-core/src/events/specific-page-visit.ts
|
|
1509
|
-
var import_zod10 = require("zod");
|
|
1510
|
-
var PAGE_IDENTITY_MAX_LENGTH = 64;
|
|
1511
|
-
var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
1512
|
-
var pageIdentitySchema = import_zod10.z.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
|
|
1513
|
-
message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
|
|
1514
|
-
});
|
|
1515
|
-
var specificPageNameSchema = pageIdentitySchema;
|
|
1516
|
-
var specificPageVisitMetadataSchema = import_zod10.z.object({
|
|
1517
|
-
page_name: specificPageNameSchema,
|
|
1518
|
-
page: import_zod10.z.object({
|
|
1519
|
-
path: import_zod10.z.string()
|
|
1520
|
-
}).strict()
|
|
1521
|
-
}).strict();
|
|
1522
|
-
var specificPageVisitConfigSchema = import_zod10.z.object({
|
|
1523
|
-
pages: import_zod10.z.array(
|
|
1524
|
-
import_zod10.z.object({
|
|
1525
|
-
name: specificPageNameSchema,
|
|
1526
|
-
pathPattern: import_zod10.z.custom((value) => value instanceof RegExp, {
|
|
1527
|
-
message: "pathPattern must be a RegExp"
|
|
1528
|
-
})
|
|
1529
|
-
}).strict()
|
|
1530
|
-
).min(1)
|
|
1531
|
-
}).strict();
|
|
1532
|
-
|
|
1533
|
-
// ../tracking-core/src/events/time-on-site.ts
|
|
1534
|
-
var import_zod11 = require("zod");
|
|
1535
|
-
var timeOnSiteMetadataSchema = import_zod11.z.object({
|
|
1536
|
-
duration_ms: import_zod11.z.number().int().nonnegative(),
|
|
1537
|
-
page: import_zod11.z.object({
|
|
1538
|
-
path: import_zod11.z.string()
|
|
1539
|
-
}).strict()
|
|
1540
|
-
}).strict();
|
|
1541
|
-
var timeOnSiteConfigSchema = import_zod11.z.object({
|
|
1542
|
-
thresholdSeconds: import_zod11.z.number().int().positive()
|
|
1543
|
-
}).strict();
|
|
1544
|
-
|
|
1545
1355
|
// ../tracking-core/src/events/semantics.ts
|
|
1546
1356
|
var EVENT_SEMANTICS = {
|
|
1547
1357
|
page_view: {
|
|
@@ -1615,82 +1425,6 @@ function getEventSemantics(eventName) {
|
|
|
1615
1425
|
return eventName in EVENT_SEMANTICS ? EVENT_SEMANTICS[eventName] : null;
|
|
1616
1426
|
}
|
|
1617
1427
|
|
|
1618
|
-
// ../tracking-core/src/events/registry.ts
|
|
1619
|
-
var EVENT_REGISTRY = {
|
|
1620
|
-
// --- automatic triggers ---
|
|
1621
|
-
page_view: {
|
|
1622
|
-
kind: "automatic",
|
|
1623
|
-
semantics: EVENT_SEMANTICS.page_view,
|
|
1624
|
-
metadataSchema: pageViewMetadataSchema,
|
|
1625
|
-
configSchema: pageViewConfigSchema
|
|
1626
|
-
},
|
|
1627
|
-
time_on_site: {
|
|
1628
|
-
kind: "automatic",
|
|
1629
|
-
semantics: EVENT_SEMANTICS.time_on_site,
|
|
1630
|
-
metadataSchema: timeOnSiteMetadataSchema,
|
|
1631
|
-
configSchema: timeOnSiteConfigSchema
|
|
1632
|
-
},
|
|
1633
|
-
specific_page_visit: {
|
|
1634
|
-
kind: "automatic",
|
|
1635
|
-
semantics: EVENT_SEMANTICS.specific_page_visit,
|
|
1636
|
-
metadataSchema: specificPageVisitMetadataSchema,
|
|
1637
|
-
configSchema: specificPageVisitConfigSchema
|
|
1638
|
-
},
|
|
1639
|
-
scroll_depth: {
|
|
1640
|
-
kind: "automatic",
|
|
1641
|
-
semantics: EVENT_SEMANTICS.scroll_depth,
|
|
1642
|
-
metadataSchema: scrollDepthMetadataSchema,
|
|
1643
|
-
configSchema: scrollDepthConfigSchema
|
|
1644
|
-
},
|
|
1645
|
-
multi_page_session: {
|
|
1646
|
-
kind: "automatic",
|
|
1647
|
-
semantics: EVENT_SEMANTICS.multi_page_session,
|
|
1648
|
-
metadataSchema: multiPageSessionMetadataSchema,
|
|
1649
|
-
configSchema: multiPageSessionConfigSchema
|
|
1650
|
-
},
|
|
1651
|
-
form_start: {
|
|
1652
|
-
kind: "automatic",
|
|
1653
|
-
semantics: EVENT_SEMANTICS.form_start,
|
|
1654
|
-
metadataSchema: formStartMetadataSchema,
|
|
1655
|
-
configSchema: formStartConfigSchema
|
|
1656
|
-
},
|
|
1657
|
-
// --- SDK-internal automatic (not consumer-configurable) ---
|
|
1658
|
-
sdk_heartbeat: {
|
|
1659
|
-
kind: "automatic",
|
|
1660
|
-
semantics: EVENT_SEMANTICS.sdk_heartbeat,
|
|
1661
|
-
metadataSchema: sdkHeartbeatMetadataSchema,
|
|
1662
|
-
configSchema: sdkHeartbeatConfigSchema
|
|
1663
|
-
},
|
|
1664
|
-
page_exit: {
|
|
1665
|
-
kind: "automatic",
|
|
1666
|
-
semantics: EVENT_SEMANTICS.page_exit,
|
|
1667
|
-
metadataSchema: pageExitMetadataSchema,
|
|
1668
|
-
configSchema: pageExitConfigSchema
|
|
1669
|
-
},
|
|
1670
|
-
// --- manual triggers ---
|
|
1671
|
-
form_submit: {
|
|
1672
|
-
kind: "manual",
|
|
1673
|
-
semantics: EVENT_SEMANTICS.form_submit,
|
|
1674
|
-
metadataSchema: formSubmitMetadataSchema,
|
|
1675
|
-
configSchema: formSubmitConfigSchema
|
|
1676
|
-
},
|
|
1677
|
-
phone_click: {
|
|
1678
|
-
kind: "manual",
|
|
1679
|
-
semantics: EVENT_SEMANTICS.phone_click,
|
|
1680
|
-
metadataSchema: phoneClickMetadataSchema,
|
|
1681
|
-
configSchema: phoneClickConfigSchema
|
|
1682
|
-
},
|
|
1683
|
-
cta_click: {
|
|
1684
|
-
kind: "manual",
|
|
1685
|
-
semantics: EVENT_SEMANTICS.cta_click,
|
|
1686
|
-
metadataSchema: ctaClickMetadataSchema,
|
|
1687
|
-
configSchema: ctaClickConfigSchema
|
|
1688
|
-
}
|
|
1689
|
-
};
|
|
1690
|
-
var ALL_AUTOMATIC_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "automatic").map(([name]) => name);
|
|
1691
|
-
var ALL_MANUAL_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "manual").map(([name]) => name);
|
|
1692
|
-
var ALL_LEAD_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.semantics.outcomeRole === "lead").map(([name]) => name);
|
|
1693
|
-
|
|
1694
1428
|
// ../tracking-core/src/resources/http/errors.ts
|
|
1695
1429
|
var AranovaApiError = class extends Error {
|
|
1696
1430
|
constructor(message, options) {
|
|
@@ -1728,9 +1462,9 @@ async function apiRequest(config, method, path, body, extraHeaders) {
|
|
|
1728
1462
|
try {
|
|
1729
1463
|
const parsed = await response.json();
|
|
1730
1464
|
if (parsed && typeof parsed === "object") {
|
|
1731
|
-
const
|
|
1732
|
-
if (typeof
|
|
1733
|
-
if (typeof
|
|
1465
|
+
const record3 = parsed;
|
|
1466
|
+
if (typeof record3.detail === "string") detail = record3.detail;
|
|
1467
|
+
if (typeof record3.code === "string") code = record3.code;
|
|
1734
1468
|
}
|
|
1735
1469
|
} catch {
|
|
1736
1470
|
}
|
|
@@ -1779,7 +1513,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
|
1779
1513
|
}
|
|
1780
1514
|
function createSalesClient(config) {
|
|
1781
1515
|
if (config.firing) registerCapability("conversion_goals_manual");
|
|
1782
|
-
async function
|
|
1516
|
+
async function record3(input) {
|
|
1783
1517
|
const currency = input.currency ?? config.defaultCurrency;
|
|
1784
1518
|
if (!currency) {
|
|
1785
1519
|
throw new Error(
|
|
@@ -1805,9 +1539,9 @@ function createSalesClient(config) {
|
|
|
1805
1539
|
return sale;
|
|
1806
1540
|
}
|
|
1807
1541
|
return {
|
|
1808
|
-
record,
|
|
1542
|
+
record: record3,
|
|
1809
1543
|
// recordSale is the intent-revealing alias — same behavior, clearer call site.
|
|
1810
|
-
recordSale:
|
|
1544
|
+
recordSale: record3,
|
|
1811
1545
|
trackConversion(key, options) {
|
|
1812
1546
|
if (config.firing && "fireConversion" in config.firing) {
|
|
1813
1547
|
if (options?.userData && getConsentState() !== "denied") stashUserData(options.userData);
|
|
@@ -1926,115 +1660,264 @@ function createSalesClient(config) {
|
|
|
1926
1660
|
}
|
|
1927
1661
|
|
|
1928
1662
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
1929
|
-
var
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
var
|
|
1933
|
-
var
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1663
|
+
var z2 = __toESM(require("zod/mini"));
|
|
1664
|
+
|
|
1665
|
+
// ../tracking-core/src/resources/sales/generated/zod.gen.ts
|
|
1666
|
+
var z = __toESM(require("zod/mini"));
|
|
1667
|
+
var zErrorCode = z.enum([
|
|
1668
|
+
"missing_credentials",
|
|
1669
|
+
"invalid_api_key",
|
|
1670
|
+
"not_authenticated",
|
|
1671
|
+
"wrong_key_type",
|
|
1672
|
+
"origin_missing",
|
|
1673
|
+
"origin_not_allowed",
|
|
1674
|
+
"capability_denied",
|
|
1675
|
+
"session_required",
|
|
1676
|
+
"operator_only",
|
|
1677
|
+
"cross_tenant",
|
|
1678
|
+
"business_id_required",
|
|
1679
|
+
"bad_request",
|
|
1680
|
+
"not_found",
|
|
1681
|
+
"conflict",
|
|
1682
|
+
"incompatible_payload",
|
|
1683
|
+
"repeat_confirmation_required",
|
|
1684
|
+
"idempotency_conflict",
|
|
1685
|
+
"validation_error",
|
|
1686
|
+
"unknown_service",
|
|
1687
|
+
"invalid_sale_properties",
|
|
1688
|
+
"invalid_cursor",
|
|
1689
|
+
"rate_limited",
|
|
1690
|
+
"internal_error"
|
|
1691
|
+
]);
|
|
1692
|
+
var zSaleItemEntitySchema = z.object({
|
|
1693
|
+
category: z.nullable(z.string()),
|
|
1694
|
+
external_item_id: z.nullable(z.string()),
|
|
1695
|
+
id: z.uuid(),
|
|
1696
|
+
name: z.nullable(z.string()),
|
|
1697
|
+
quantity: z.string().check(z.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
|
|
1698
|
+
unit_cost_cents: z.nullable(z.int()),
|
|
1699
|
+
unit_price_cents: z.int()
|
|
1700
|
+
});
|
|
1701
|
+
var zSaleItemInputSchema = z.strictObject({
|
|
1702
|
+
category: z.nullish(z.string()),
|
|
1703
|
+
external_item_id: z.nullish(z.string()),
|
|
1704
|
+
name: z.nullish(z.string()),
|
|
1705
|
+
quantity: z.string().check(z.regex(/^\d+(\.\d{1,3})?$/)),
|
|
1706
|
+
unit_cost_cents: z.nullish(z.int().check(z.gte(0))),
|
|
1707
|
+
unit_price_cents: z.int().check(z.gte(0))
|
|
1708
|
+
});
|
|
1709
|
+
var zSaleServiceEntitySchema = z.object({
|
|
1710
|
+
amount_cents: z.int(),
|
|
1711
|
+
id: z.uuid(),
|
|
1712
|
+
mapped: z.nullable(z.boolean()),
|
|
1713
|
+
service_id: z.uuid(),
|
|
1714
|
+
service_key: z.string(),
|
|
1715
|
+
service_label: z.string()
|
|
1716
|
+
});
|
|
1717
|
+
var zSaleServiceInputSchema = z.strictObject({
|
|
1718
|
+
amount_cents: z.int().check(z.gte(0)),
|
|
1719
|
+
service: z.string()
|
|
1720
|
+
});
|
|
1721
|
+
var zSmsAutomationState = z.enum([
|
|
1722
|
+
"needs_check",
|
|
1723
|
+
"failed",
|
|
1724
|
+
"undelivered",
|
|
1725
|
+
"blocked_opted_out",
|
|
1726
|
+
"withheld",
|
|
1727
|
+
"queued",
|
|
1728
|
+
"sent",
|
|
1729
|
+
"delivered",
|
|
1730
|
+
"eligible",
|
|
1731
|
+
"not_applicable"
|
|
1732
|
+
]);
|
|
1733
|
+
var zSmsWithheldReason = z.enum([
|
|
1734
|
+
"automation_disabled",
|
|
1735
|
+
"sms_disabled",
|
|
1736
|
+
"no_phone",
|
|
1737
|
+
"no_consent",
|
|
1738
|
+
"no_customer_identity",
|
|
1739
|
+
"missing_customer_name",
|
|
1740
|
+
"placeholder_customer_name",
|
|
1741
|
+
"opted_out",
|
|
1742
|
+
"already_messaged",
|
|
1743
|
+
"sender_not_ready",
|
|
1744
|
+
"missing_review_url",
|
|
1745
|
+
"no_handler",
|
|
1746
|
+
"dispatch_already_recorded"
|
|
1747
|
+
]);
|
|
1748
|
+
var zSaleSmsStatusSchema = z.object({
|
|
1749
|
+
can_send_now: z._default(z.boolean(), false),
|
|
1750
|
+
last_message_at: z.nullable(z.iso.datetime({ offset: true })),
|
|
1751
|
+
reason_detail: z.nullable(z.string()),
|
|
1752
|
+
state: zSmsAutomationState,
|
|
1753
|
+
suppressed_by_other_sale: z._default(z.boolean(), false),
|
|
1754
|
+
withheld_reason: z.nullable(zSmsWithheldReason)
|
|
1755
|
+
});
|
|
1756
|
+
var zSupportedCurrency = z.enum(["USD", "CAD"]);
|
|
1757
|
+
var zTrackingEnvironment = z.enum(["production", "development"]);
|
|
1758
|
+
var zSaleCreateSchema = z.strictObject({
|
|
1759
|
+
amount_total_cents: z.nullish(z.int().check(z.gte(0))),
|
|
1760
|
+
currency: zSupportedCurrency,
|
|
1761
|
+
customer_email: z.nullish(z.email().check(z.maxLength(320))),
|
|
1762
|
+
customer_name: z.nullish(z.string().check(z.maxLength(200))),
|
|
1763
|
+
customer_phone: z.nullish(z.string().check(z.maxLength(64))),
|
|
1764
|
+
description: z.nullish(z.string()),
|
|
1765
|
+
environment: z._default(z.optional(zTrackingEnvironment), "production"),
|
|
1766
|
+
external_id: z.nullish(z.string()),
|
|
1767
|
+
items: z.optional(z.array(zSaleItemInputSchema)),
|
|
1768
|
+
metadata: z.nullish(z.record(z.string(), z.unknown())),
|
|
1769
|
+
occurred_at: z.iso.datetime({ offset: true }),
|
|
1770
|
+
service: z.nullish(z.string()),
|
|
1771
|
+
services: z.nullish(z.array(zSaleServiceInputSchema)),
|
|
1772
|
+
sms_consent: z.nullish(z.boolean())
|
|
1773
|
+
});
|
|
1774
|
+
var zValidationError = z.object({
|
|
1775
|
+
ctx: z.optional(z.record(z.string(), z.unknown())),
|
|
1776
|
+
input: z.optional(z.unknown()),
|
|
1777
|
+
loc: z.array(z.union([z.string(), z.int()])),
|
|
1778
|
+
msg: z.string(),
|
|
1779
|
+
type: z.string()
|
|
1780
|
+
});
|
|
1781
|
+
var zHttpValidationError = z.object({
|
|
1782
|
+
detail: z.optional(z.array(zValidationError))
|
|
1783
|
+
});
|
|
1784
|
+
var zValidationErrorItem = z.object({
|
|
1785
|
+
loc: z.array(z.union([z.string(), z.int()])),
|
|
1786
|
+
msg: z.string(),
|
|
1787
|
+
type: z.string()
|
|
1788
|
+
});
|
|
1789
|
+
var zApiErrorSchema = z.object({
|
|
1790
|
+
code: zErrorCode,
|
|
1791
|
+
context: z._default(z.nullish(z.record(z.string(), z.unknown())), null),
|
|
1792
|
+
detail: z.string(),
|
|
1793
|
+
errors: z._default(z.nullish(z.array(zValidationErrorItem)), null),
|
|
1794
|
+
request_id: z._default(z.nullish(z.string()), null)
|
|
1795
|
+
});
|
|
1796
|
+
var zWritebackEmailSource = z.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
|
|
1797
|
+
var zWritebackEnrichmentStatus = z.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
|
|
1798
|
+
var zWritebackSaleUploadCounts = z.object({
|
|
1799
|
+
failed: z._default(z.int(), 0),
|
|
1800
|
+
pending: z._default(z.int(), 0),
|
|
1801
|
+
skipped: z._default(z.int(), 0),
|
|
1802
|
+
submitted: z._default(z.int(), 0),
|
|
1803
|
+
total: z._default(z.int(), 0),
|
|
1804
|
+
uploaded: z._default(z.int(), 0)
|
|
1805
|
+
});
|
|
1806
|
+
var zSaleWritebackStatusSchema = z.object({
|
|
1807
|
+
blocked_reason: z.nullable(z.string()),
|
|
1808
|
+
can_dispatch: z._default(z.boolean(), false),
|
|
1809
|
+
email_source: z.nullable(zWritebackEmailSource),
|
|
1810
|
+
enrichment_status: z.nullable(zWritebackEnrichmentStatus),
|
|
1811
|
+
gclid_attached: z._default(z.boolean(), false),
|
|
1812
|
+
identifiers_sent: z.nullable(z.string()),
|
|
1813
|
+
mapped_service_ids: z.array(z.uuid()),
|
|
1814
|
+
matched_submit_count: z.nullable(z.int()),
|
|
1815
|
+
needs_force: z._default(z.boolean(), false),
|
|
1816
|
+
rollup: z.enum([
|
|
1817
|
+
"failed",
|
|
1818
|
+
"skipped",
|
|
1819
|
+
"pending",
|
|
1820
|
+
"submitted",
|
|
1821
|
+
"uploaded",
|
|
1822
|
+
"not_uploaded",
|
|
1823
|
+
"out_of_window",
|
|
1824
|
+
"blocked"
|
|
1825
|
+
]),
|
|
1826
|
+
stale: z._default(z.boolean(), false),
|
|
1827
|
+
uncovered_service_ids: z.array(z.uuid()),
|
|
1828
|
+
uploads: zWritebackSaleUploadCounts
|
|
1829
|
+
});
|
|
1830
|
+
var zSaleEntitySchema = z.object({
|
|
1831
|
+
amount_total_cents: z.int(),
|
|
1832
|
+
business_id: z.uuid(),
|
|
1833
|
+
business_name: z.nullable(z.string()),
|
|
1834
|
+
created_at: z.iso.datetime({ offset: true }),
|
|
1835
|
+
currency: z.string(),
|
|
1836
|
+
customer_email: z.nullable(z.string()),
|
|
1837
|
+
customer_name: z.nullable(z.string()),
|
|
1838
|
+
customer_name_placeholder_confirmed: z._default(z.boolean(), false),
|
|
1839
|
+
customer_name_placeholder_confirmed_at: z.nullable(z.iso.datetime({ offset: true })),
|
|
1840
|
+
customer_phone: z.nullable(z.string()),
|
|
1841
|
+
description: z.nullable(z.string()),
|
|
1842
|
+
environment: zTrackingEnvironment,
|
|
1843
|
+
external_id: z.nullable(z.string()),
|
|
1844
|
+
id: z.uuid(),
|
|
1845
|
+
items: z.array(zSaleItemEntitySchema),
|
|
1846
|
+
metadata: z.nullable(z.record(z.string(), z.unknown())),
|
|
1847
|
+
occurred_at: z.iso.datetime({ offset: true }),
|
|
1848
|
+
service_id: z.nullable(z.uuid()),
|
|
1849
|
+
service_key: z.nullable(z.string()),
|
|
1850
|
+
service_label: z.nullable(z.string()),
|
|
1851
|
+
services: z.array(zSaleServiceEntitySchema),
|
|
1852
|
+
sms_automation: z.nullable(zSaleSmsStatusSchema),
|
|
1853
|
+
sms_consent: z._default(z.boolean(), false),
|
|
1854
|
+
sms_consent_granted_at: z.nullable(z.iso.datetime({ offset: true })),
|
|
1855
|
+
updated_at: z.iso.datetime({ offset: true }),
|
|
1856
|
+
writeback: z.nullable(zSaleWritebackStatusSchema)
|
|
1857
|
+
});
|
|
1858
|
+
|
|
1859
|
+
// ../tracking-core/src/resources/sales/schema.ts
|
|
1860
|
+
var saleItemSchema = zSaleItemInputSchema;
|
|
1861
|
+
var saleServiceSchema = zSaleServiceInputSchema;
|
|
1862
|
+
var currencySchema = zSupportedCurrency;
|
|
1863
|
+
var SUPPORTED_CURRENCIES = currencySchema.options;
|
|
1864
|
+
var centsSchema = z2.int().check(z2.gte(0));
|
|
1865
|
+
var metadataSchema = z2.record(z2.string(), z2.unknown());
|
|
1866
|
+
var customerNameSchema = z2.string().check(z2.maxLength(200));
|
|
1867
|
+
var customerPhoneSchema = z2.string().check(z2.maxLength(64));
|
|
1868
|
+
var customerEmailSchema = z2.email().check(z2.maxLength(320));
|
|
1869
|
+
function addIssue(ctx, path, message) {
|
|
1870
|
+
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
1871
|
+
}
|
|
1953
1872
|
function refineServiceXor(val, ctx, { requireAmount }) {
|
|
1954
1873
|
if (val.services != null) {
|
|
1955
1874
|
if (val.service != null) {
|
|
1956
|
-
|
|
1957
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
1958
|
-
message: "pass either `service` or `services`, not both",
|
|
1959
|
-
path: ["services"]
|
|
1960
|
-
});
|
|
1875
|
+
addIssue(ctx, ["services"], "pass either `service` or `services`, not both");
|
|
1961
1876
|
}
|
|
1962
1877
|
if (val.services.length === 0) {
|
|
1963
|
-
|
|
1964
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
1965
|
-
message: "`services` must not be empty",
|
|
1966
|
-
path: ["services"]
|
|
1967
|
-
});
|
|
1878
|
+
addIssue(ctx, ["services"], "`services` must not be empty");
|
|
1968
1879
|
}
|
|
1969
1880
|
const keys = val.services.map((s) => s.service);
|
|
1970
1881
|
if (new Set(keys).size !== keys.length) {
|
|
1971
|
-
|
|
1972
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
1973
|
-
message: "`services` must not list the same service more than once",
|
|
1974
|
-
path: ["services"]
|
|
1975
|
-
});
|
|
1882
|
+
addIssue(ctx, ["services"], "`services` must not list the same service more than once");
|
|
1976
1883
|
}
|
|
1977
1884
|
if (val.amount_total_cents != null) {
|
|
1978
1885
|
const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
|
|
1979
1886
|
if (val.amount_total_cents !== sum) {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1887
|
+
addIssue(
|
|
1888
|
+
ctx,
|
|
1889
|
+
["amount_total_cents"],
|
|
1890
|
+
"amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)"
|
|
1891
|
+
);
|
|
1985
1892
|
}
|
|
1986
1893
|
}
|
|
1987
1894
|
} else if (requireAmount && val.amount_total_cents == null) {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1895
|
+
addIssue(
|
|
1896
|
+
ctx,
|
|
1897
|
+
["amount_total_cents"],
|
|
1898
|
+
"amount_total_cents is required unless `services` is provided"
|
|
1899
|
+
);
|
|
1993
1900
|
}
|
|
1994
1901
|
}
|
|
1995
|
-
var saleCreateSchema =
|
|
1996
|
-
|
|
1997
|
-
description:
|
|
1998
|
-
service:
|
|
1999
|
-
services:
|
|
2000
|
-
currency: currencySchema,
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
items: import_zod12.z.array(saleItemSchema).default([]),
|
|
2007
|
-
metadata: metadataSchema.nullable().optional(),
|
|
2008
|
-
customer_name: customerNameSchema.nullable().optional(),
|
|
2009
|
-
customer_phone: customerPhoneSchema.nullable().optional(),
|
|
2010
|
-
customer_email: customerEmailSchema.nullable().optional(),
|
|
2011
|
-
// CASL consent attestation: the customer agreed to receive SMS. Recorded
|
|
2012
|
-
// with a timestamp server-side; every SMS send path gates on it.
|
|
2013
|
-
//
|
|
2014
|
-
// Tri-state: omit it (or send null) to let the server apply the business's
|
|
2015
|
-
// configured default-opt-in policy, honouring a returning customer's
|
|
2016
|
-
// remembered preference. Send an explicit boolean to assert consent state
|
|
2017
|
-
// yourself — `false` records a deliberate opt-out.
|
|
2018
|
-
sms_consent: import_zod12.z.boolean().nullable().optional()
|
|
2019
|
-
}).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
|
|
2020
|
-
var saleUpdateSchema = import_zod12.z.object({
|
|
2021
|
-
description: import_zod12.z.string().nullable().optional(),
|
|
2022
|
-
service: import_zod12.z.string().nullable().optional(),
|
|
2023
|
-
services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
|
|
2024
|
-
currency: currencySchema.optional(),
|
|
2025
|
-
amount_total_cents: centsSchema.optional(),
|
|
2026
|
-
occurred_at: import_zod12.z.string().datetime().optional(),
|
|
2027
|
-
items: import_zod12.z.array(saleItemSchema).optional(),
|
|
2028
|
-
metadata: metadataSchema.nullable().optional(),
|
|
2029
|
-
customer_name: customerNameSchema.nullable().optional(),
|
|
1902
|
+
var saleCreateSchema = z2.extend(zSaleCreateSchema, { items: z2._default(z2.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
|
|
1903
|
+
var saleUpdateSchema = z2.strictObject({
|
|
1904
|
+
description: z2.nullish(z2.string()),
|
|
1905
|
+
service: z2.nullish(z2.string()),
|
|
1906
|
+
services: z2.nullish(z2.array(saleServiceSchema)),
|
|
1907
|
+
currency: z2.optional(currencySchema),
|
|
1908
|
+
amount_total_cents: z2.optional(centsSchema),
|
|
1909
|
+
occurred_at: z2.optional(z2.iso.datetime()),
|
|
1910
|
+
items: z2.optional(z2.array(saleItemSchema)),
|
|
1911
|
+
metadata: z2.nullish(metadataSchema),
|
|
1912
|
+
customer_name: z2.nullish(customerNameSchema),
|
|
2030
1913
|
// Re-attest when changing a filler-looking name; the server clears the
|
|
2031
1914
|
// prior attestation whenever `customer_name` changes.
|
|
2032
|
-
customer_name_placeholder_confirmed:
|
|
2033
|
-
customer_phone:
|
|
2034
|
-
customer_email:
|
|
1915
|
+
customer_name_placeholder_confirmed: z2.optional(z2.boolean()),
|
|
1916
|
+
customer_phone: z2.nullish(customerPhoneSchema),
|
|
1917
|
+
customer_email: z2.nullish(customerEmailSchema),
|
|
2035
1918
|
// NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
|
|
2036
|
-
sms_consent:
|
|
2037
|
-
}).
|
|
1919
|
+
sms_consent: z2.optional(z2.boolean())
|
|
1920
|
+
}).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
|
|
2038
1921
|
var TRACKING_RANGES = ["24h", "7d", "30d"];
|
|
2039
1922
|
var NAMED_RANGES = [
|
|
2040
1923
|
"today",
|
|
@@ -2083,6 +1966,7 @@ var import_client2 = require("@aranova/tracking-react/client");
|
|
|
2083
1966
|
createTrackingClientContext,
|
|
2084
1967
|
createTrackingEventCreatePayload,
|
|
2085
1968
|
createTrackingSessionUpsertPayload,
|
|
1969
|
+
currencySchema,
|
|
2086
1970
|
fetchServices,
|
|
2087
1971
|
formatDateInTz,
|
|
2088
1972
|
formatMoney,
|