@aranova/tracking-react 1.18.0 → 1.20.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/{bookings-CVvpj_8K.d.mts → bookings-BpLjL5w1.d.mts} +25 -1
- package/dist/{bookings-CCGpXhYE.d.ts → bookings-CSDPoT-I.d.ts} +25 -1
- package/dist/client.d.mts +121 -4
- package/dist/client.d.ts +121 -4
- package/dist/client.js +1685 -31
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +1687 -31
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +15 -39
- package/dist/index.d.ts +15 -39
- package/dist/index.js +178 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-CoCjTqJs.d.mts → ingest-typed-BEFQd3WM.d.mts} +200 -2
- package/dist/{ingest-typed-C3XAjHlH.d.ts → ingest-typed-DChvvgwd.d.ts} +200 -2
- package/dist/{sales-Dlc_umAV.d.ts → sales-CM_dxsf8.d.ts} +1 -1
- package/dist/{sales-B1ONR-Yi.d.mts → sales-agx4zLC9.d.mts} +1 -1
- package/dist/sales.d.mts +2 -2
- package/dist/sales.d.ts +2 -2
- package/dist/sales.js +115 -5
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +115 -5
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -233,7 +233,8 @@ var TRACKING_CAPABILITIES = [
|
|
|
233
233
|
"form_capture",
|
|
234
234
|
"phone_click_capture",
|
|
235
235
|
"phone_fields",
|
|
236
|
-
"typed_form_submit"
|
|
236
|
+
"typed_form_submit",
|
|
237
|
+
"video_tracking"
|
|
237
238
|
];
|
|
238
239
|
var CAPABILITY_DOM_ATTRIBUTE = "data-aranova-capability";
|
|
239
240
|
var registered = /* @__PURE__ */ new Set();
|
|
@@ -774,8 +775,48 @@ function parseTrigger(value) {
|
|
|
774
775
|
if (typeof t.threshold_seconds === "number") spec.threshold_seconds = t.threshold_seconds;
|
|
775
776
|
if (typeof t.page_threshold === "number") spec.page_threshold = t.page_threshold;
|
|
776
777
|
if (typeof t.page_name === "string") spec.page_name = t.page_name;
|
|
778
|
+
if (t.metric === "percent" || t.metric === "seconds") spec.metric = t.metric;
|
|
779
|
+
if (typeof t.threshold === "number") spec.threshold = t.threshold;
|
|
780
|
+
if (typeof t.video_id === "string" || t.video_id === null) spec.video_id = t.video_id;
|
|
777
781
|
return spec;
|
|
778
782
|
}
|
|
783
|
+
function parseVideoEntry(fallbackKey2, entry) {
|
|
784
|
+
const key = typeof entry.key === "string" && entry.key ? entry.key : fallbackKey2;
|
|
785
|
+
if (!key) return null;
|
|
786
|
+
const host = typeof entry.host === "string" ? entry.host : "";
|
|
787
|
+
const title = typeof entry.title === "string" && entry.title ? entry.title : key;
|
|
788
|
+
const sourcesRaw = isRecord(entry.sources) ? entry.sources : null;
|
|
789
|
+
const desktop = sourcesRaw && typeof sourcesRaw.desktop === "string" ? sourcesRaw.desktop : typeof entry.desktop_uid === "string" ? entry.desktop_uid : "";
|
|
790
|
+
if (!host || !desktop) return null;
|
|
791
|
+
const mobile = sourcesRaw && typeof sourcesRaw.mobile === "string" ? sourcesRaw.mobile : typeof entry.mobile_uid === "string" ? entry.mobile_uid : null;
|
|
792
|
+
const posterTime = typeof entry.poster_time === "number" ? entry.poster_time : typeof entry.poster_time_s === "number" ? entry.poster_time_s : 4;
|
|
793
|
+
return {
|
|
794
|
+
key,
|
|
795
|
+
title,
|
|
796
|
+
host,
|
|
797
|
+
sources: { desktop, mobile },
|
|
798
|
+
poster_time: posterTime,
|
|
799
|
+
duration_s: typeof entry.duration_s === "number" ? entry.duration_s : null
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function parseVideos(value) {
|
|
803
|
+
const out = {};
|
|
804
|
+
if (Array.isArray(value)) {
|
|
805
|
+
for (const item of value) {
|
|
806
|
+
if (!isRecord(item)) continue;
|
|
807
|
+
const parsed = parseVideoEntry("", item);
|
|
808
|
+
if (parsed) out[parsed.key] = parsed;
|
|
809
|
+
}
|
|
810
|
+
return out;
|
|
811
|
+
}
|
|
812
|
+
if (!isRecord(value)) return out;
|
|
813
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
814
|
+
if (!isRecord(entry)) continue;
|
|
815
|
+
const parsed = parseVideoEntry(key, entry);
|
|
816
|
+
if (parsed) out[parsed.key] = parsed;
|
|
817
|
+
}
|
|
818
|
+
return out;
|
|
819
|
+
}
|
|
779
820
|
function parseConversionConfig(raw) {
|
|
780
821
|
if (!raw || typeof raw !== "object") return null;
|
|
781
822
|
const obj = raw;
|
|
@@ -826,7 +867,8 @@ function parseConversionConfig(raw) {
|
|
|
826
867
|
goals,
|
|
827
868
|
linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : [],
|
|
828
869
|
integrations: parseIntegrations(obj.integrations),
|
|
829
|
-
lead_forms: parseLeadForms(obj.lead_forms)
|
|
870
|
+
lead_forms: parseLeadForms(obj.lead_forms),
|
|
871
|
+
videos: parseVideos(obj.videos)
|
|
830
872
|
};
|
|
831
873
|
}
|
|
832
874
|
function parseLeadForms(value) {
|
|
@@ -1072,6 +1114,21 @@ function automaticThresholdMet(goal, eventType, metadata) {
|
|
|
1072
1114
|
case "form_start":
|
|
1073
1115
|
case "phone_click":
|
|
1074
1116
|
return true;
|
|
1117
|
+
case "video_play":
|
|
1118
|
+
return trigger.video_id == null || hasStringField(metadata, "video_id") && metadata.video_id === trigger.video_id;
|
|
1119
|
+
case "video_progress": {
|
|
1120
|
+
if (trigger.video_id != null && (!hasStringField(metadata, "video_id") || metadata.video_id !== trigger.video_id)) {
|
|
1121
|
+
return false;
|
|
1122
|
+
}
|
|
1123
|
+
if (typeof trigger.threshold !== "number") return false;
|
|
1124
|
+
if (trigger.metric === "seconds") {
|
|
1125
|
+
return hasNumberField(metadata, "watched_s") && metadata.watched_s >= trigger.threshold;
|
|
1126
|
+
}
|
|
1127
|
+
if (trigger.metric === "percent") {
|
|
1128
|
+
return hasNumberField(metadata, "max_percent") && metadata.max_percent >= trigger.threshold || hasNumberField(metadata, "watched_percent") && metadata.watched_percent >= trigger.threshold;
|
|
1129
|
+
}
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1075
1132
|
default:
|
|
1076
1133
|
return false;
|
|
1077
1134
|
}
|
|
@@ -1131,6 +1188,9 @@ var RETRY_BASE_MS = 5e3;
|
|
|
1131
1188
|
var RETRY_MAX_MS = 5 * 6e4;
|
|
1132
1189
|
var runtimes = /* @__PURE__ */ new Map();
|
|
1133
1190
|
var configuredIds = /* @__PURE__ */ new Set();
|
|
1191
|
+
var EMPTY_GOALS = [];
|
|
1192
|
+
var EMPTY_STRINGS = [];
|
|
1193
|
+
var EMPTY_VIDEOS = {};
|
|
1134
1194
|
var scriptLoad = null;
|
|
1135
1195
|
var jsInitialized = false;
|
|
1136
1196
|
function cacheKey2(url) {
|
|
@@ -1321,11 +1381,11 @@ var TrackingConfigRuntime = class {
|
|
|
1321
1381
|
void this.flush();
|
|
1322
1382
|
}
|
|
1323
1383
|
listGoals() {
|
|
1324
|
-
return this.current?.goals ??
|
|
1384
|
+
return this.current?.goals ?? EMPTY_GOALS;
|
|
1325
1385
|
}
|
|
1326
1386
|
/** Sibling hostnames for the linker — read from the cached object even while unconfirmed. */
|
|
1327
1387
|
linkedHostnames() {
|
|
1328
|
-
return this.current?.linked_hostnames ??
|
|
1388
|
+
return this.current?.linked_hostnames ?? EMPTY_STRINGS;
|
|
1329
1389
|
}
|
|
1330
1390
|
/**
|
|
1331
1391
|
* Integration blocks, from the cached object even while unconfirmed: the booking fallback
|
|
@@ -1338,6 +1398,14 @@ var TrackingConfigRuntime = class {
|
|
|
1338
1398
|
leadForms() {
|
|
1339
1399
|
return this.current?.lead_forms ?? null;
|
|
1340
1400
|
}
|
|
1401
|
+
/** Configured Cloudflare Stream tracked videos for this site. */
|
|
1402
|
+
videos() {
|
|
1403
|
+
return this.current?.videos ?? EMPTY_VIDEOS;
|
|
1404
|
+
}
|
|
1405
|
+
/** Look up one configured Cloudflare Stream tracked video by key. */
|
|
1406
|
+
getVideo(key) {
|
|
1407
|
+
return this.current?.videos?.[key] ?? null;
|
|
1408
|
+
}
|
|
1341
1409
|
async revalidateNow() {
|
|
1342
1410
|
try {
|
|
1343
1411
|
const headers = {};
|
|
@@ -1494,6 +1562,16 @@ var TrackingConfigRuntime = class {
|
|
|
1494
1562
|
this.scheduleRetry();
|
|
1495
1563
|
return;
|
|
1496
1564
|
}
|
|
1565
|
+
if (outcome === "fired" && typeof window !== "undefined" && typeof window.fbq === "function") {
|
|
1566
|
+
try {
|
|
1567
|
+
window.fbq("trackCustom", item.key, {
|
|
1568
|
+
...value != null ? { value } : {},
|
|
1569
|
+
...currency ? { currency } : {},
|
|
1570
|
+
...item.transactionId ? { transaction_id: item.transactionId } : {}
|
|
1571
|
+
});
|
|
1572
|
+
} catch {
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1497
1575
|
this.conversionQueue.shift();
|
|
1498
1576
|
}
|
|
1499
1577
|
}
|
|
@@ -1716,6 +1794,18 @@ var EVENT_SEMANTICS = {
|
|
|
1716
1794
|
category: "page",
|
|
1717
1795
|
outcomeRole: "navigation",
|
|
1718
1796
|
clientVisibility: "simple"
|
|
1797
|
+
},
|
|
1798
|
+
video_play: {
|
|
1799
|
+
label: "Video played",
|
|
1800
|
+
category: "engagement",
|
|
1801
|
+
outcomeRole: "engagement",
|
|
1802
|
+
clientVisibility: "simple"
|
|
1803
|
+
},
|
|
1804
|
+
video_progress: {
|
|
1805
|
+
label: "Video watched",
|
|
1806
|
+
category: "engagement",
|
|
1807
|
+
outcomeRole: "engagement",
|
|
1808
|
+
clientVisibility: "detailed"
|
|
1719
1809
|
}
|
|
1720
1810
|
};
|
|
1721
1811
|
function getEventSemantics(eventName) {
|
|
@@ -1798,6 +1888,36 @@ var formSubmitMetadataSchema = z2.strictObject({
|
|
|
1798
1888
|
});
|
|
1799
1889
|
var formSubmitConfigSchema = z2.strictObject({});
|
|
1800
1890
|
|
|
1891
|
+
// ../tracking-core/src/video-ranges.ts
|
|
1892
|
+
function roundVideoSeconds(value) {
|
|
1893
|
+
if (!Number.isFinite(value) || value < 0) return 0;
|
|
1894
|
+
return Math.round(value * 100) / 100;
|
|
1895
|
+
}
|
|
1896
|
+
function mergeVideoRanges(ranges, epsilonSeconds = 0.25) {
|
|
1897
|
+
const valid = ranges.filter((r) => Number.isFinite(r.start_s) && Number.isFinite(r.end_s) && r.end_s > r.start_s).map((r) => ({
|
|
1898
|
+
start_s: roundVideoSeconds(r.start_s),
|
|
1899
|
+
end_s: roundVideoSeconds(r.end_s)
|
|
1900
|
+
})).filter((r) => r.end_s - r.start_s >= 0.05).sort((a, b) => a.start_s - b.start_s || a.end_s - b.end_s);
|
|
1901
|
+
if (valid.length === 0) return [];
|
|
1902
|
+
const merged = [{ ...valid[0] }];
|
|
1903
|
+
for (let i = 1; i < valid.length; i += 1) {
|
|
1904
|
+
const cur = valid[i];
|
|
1905
|
+
const last = merged[merged.length - 1];
|
|
1906
|
+
if (cur.start_s <= last.end_s + epsilonSeconds) {
|
|
1907
|
+
last.end_s = roundVideoSeconds(Math.max(last.end_s, cur.end_s));
|
|
1908
|
+
} else {
|
|
1909
|
+
merged.push({ ...cur });
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return merged;
|
|
1913
|
+
}
|
|
1914
|
+
function sumVideoRangesSeconds(ranges, durationSeconds = 0) {
|
|
1915
|
+
const merged = mergeVideoRanges(ranges);
|
|
1916
|
+
const raw = merged.reduce((acc, r) => acc + Math.max(0, r.end_s - r.start_s), 0);
|
|
1917
|
+
const clamped = durationSeconds > 0 ? Math.min(raw, durationSeconds) : raw;
|
|
1918
|
+
return roundVideoSeconds(clamped);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1801
1921
|
// ../tracking-core/src/ingest-typed.ts
|
|
1802
1922
|
var clientSettings = /* @__PURE__ */ new WeakMap();
|
|
1803
1923
|
function typedClientSettings(client) {
|
|
@@ -2544,10 +2664,13 @@ var zErrorCode = z4.enum([
|
|
|
2544
2664
|
"bad_request",
|
|
2545
2665
|
"not_found",
|
|
2546
2666
|
"conflict",
|
|
2667
|
+
"already_disposed",
|
|
2547
2668
|
"gone",
|
|
2548
2669
|
"incompatible_payload",
|
|
2549
2670
|
"repeat_confirmation_required",
|
|
2550
2671
|
"idempotency_conflict",
|
|
2672
|
+
"autonomy_never_auto",
|
|
2673
|
+
"autonomy_auto_apply_closed",
|
|
2551
2674
|
"slot_unavailable",
|
|
2552
2675
|
"calendar_not_connected",
|
|
2553
2676
|
"calendar_disconnected",
|
|
@@ -2572,6 +2695,7 @@ var zErrorCode = z4.enum([
|
|
|
2572
2695
|
"unknown_service",
|
|
2573
2696
|
"invalid_sale_properties",
|
|
2574
2697
|
"invalid_cursor",
|
|
2698
|
+
"site_repo_unreadable",
|
|
2575
2699
|
"rate_limited",
|
|
2576
2700
|
"internal_error"
|
|
2577
2701
|
]);
|
|
@@ -2580,7 +2704,7 @@ var zSaleItemEntitySchema = z4.object({
|
|
|
2580
2704
|
external_item_id: z4.nullable(z4.string()),
|
|
2581
2705
|
id: z4.uuid(),
|
|
2582
2706
|
name: z4.nullable(z4.string()),
|
|
2583
|
-
quantity: z4.string()
|
|
2707
|
+
quantity: z4.string(),
|
|
2584
2708
|
unit_cost_cents: z4.nullable(z4.int()),
|
|
2585
2709
|
unit_price_cents: z4.int()
|
|
2586
2710
|
});
|
|
@@ -2702,6 +2826,17 @@ var zApiErrorSchema = z4.object({
|
|
|
2702
2826
|
errors: z4._default(z4.nullish(z4.array(zValidationErrorItem)), null),
|
|
2703
2827
|
request_id: z4._default(z4.nullish(z4.string()), null)
|
|
2704
2828
|
});
|
|
2829
|
+
var zWritebackCorrectionAction = z4.enum(["retry", "restate_now"]);
|
|
2830
|
+
var zWritebackCorrectionState = z4.enum([
|
|
2831
|
+
"queued",
|
|
2832
|
+
"sent",
|
|
2833
|
+
"restated",
|
|
2834
|
+
"failed",
|
|
2835
|
+
"limit_reached",
|
|
2836
|
+
"voided",
|
|
2837
|
+
"date_changed",
|
|
2838
|
+
"dry_run_ok"
|
|
2839
|
+
]);
|
|
2705
2840
|
var zWritebackEmailSource = z4.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
|
|
2706
2841
|
var zWritebackEnrichmentStatus = z4.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
|
|
2707
2842
|
var zWritebackSaleUploadCounts = z4.object({
|
|
@@ -2712,9 +2847,28 @@ var zWritebackSaleUploadCounts = z4.object({
|
|
|
2712
2847
|
total: z4._default(z4.int(), 0),
|
|
2713
2848
|
uploaded: z4._default(z4.int(), 0)
|
|
2714
2849
|
});
|
|
2850
|
+
var zWritebackValueDrift = z4.enum(["none", "open", "failed"]);
|
|
2851
|
+
var zWritebackCorrectionSchema = z4.object({
|
|
2852
|
+
action: z4.nullable(zWritebackCorrectionAction),
|
|
2853
|
+
can_restate: z4._default(z4.boolean(), false),
|
|
2854
|
+
drift: zWritebackValueDrift,
|
|
2855
|
+
error_message: z4.nullable(z4.string()),
|
|
2856
|
+
google_currency: z4.string(),
|
|
2857
|
+
google_value_cents: z4.int(),
|
|
2858
|
+
restated_at: z4.nullable(z4.iso.datetime({ offset: true })),
|
|
2859
|
+
restated_from_cents: z4.nullable(z4.int()),
|
|
2860
|
+
restatement_limit: z4.int(),
|
|
2861
|
+
restatements_used: z4.int(),
|
|
2862
|
+
sale_currency: z4.string(),
|
|
2863
|
+
sale_value_cents: z4.int(),
|
|
2864
|
+
sends_at: z4.nullable(z4.iso.datetime({ offset: true })),
|
|
2865
|
+
state: zWritebackCorrectionState,
|
|
2866
|
+
upload_id: z4.uuid()
|
|
2867
|
+
});
|
|
2715
2868
|
var zSaleWritebackStatusSchema = z4.object({
|
|
2716
2869
|
blocked_reason: z4.nullable(z4.string()),
|
|
2717
2870
|
can_dispatch: z4._default(z4.boolean(), false),
|
|
2871
|
+
correction: z4.nullable(zWritebackCorrectionSchema),
|
|
2718
2872
|
email_source: z4.nullable(zWritebackEmailSource),
|
|
2719
2873
|
enrichment_status: z4.nullable(zWritebackEnrichmentStatus),
|
|
2720
2874
|
gclid_attached: z4._default(z4.boolean(), false),
|
|
@@ -2732,7 +2886,6 @@ var zSaleWritebackStatusSchema = z4.object({
|
|
|
2732
2886
|
"out_of_window",
|
|
2733
2887
|
"blocked"
|
|
2734
2888
|
]),
|
|
2735
|
-
stale: z4._default(z4.boolean(), false),
|
|
2736
2889
|
uncovered_service_ids: z4.array(z4.uuid()),
|
|
2737
2890
|
uploads: zWritebackSaleUploadCounts
|
|
2738
2891
|
});
|
|
@@ -2869,6 +3022,14 @@ import {
|
|
|
2869
3022
|
useBookingSubmit
|
|
2870
3023
|
} from "@aranova/tracking-react/client";
|
|
2871
3024
|
import { createLeadFormSubmit } from "@aranova/tracking-react/client";
|
|
3025
|
+
import {
|
|
3026
|
+
DEFAULT_VIDEO_CHECKPOINTS,
|
|
3027
|
+
streamManifestUrl,
|
|
3028
|
+
streamPosterUrl,
|
|
3029
|
+
TrackedVideo,
|
|
3030
|
+
TrackedVideoStage,
|
|
3031
|
+
useTrackedVideoConfig
|
|
3032
|
+
} from "@aranova/tracking-react/client";
|
|
2872
3033
|
export {
|
|
2873
3034
|
AdPlatformTracking,
|
|
2874
3035
|
AranovaApiError,
|
|
@@ -2876,6 +3037,7 @@ export {
|
|
|
2876
3037
|
ConsentBanner,
|
|
2877
3038
|
DEFAULT_DECLINE_TTL_DAYS,
|
|
2878
3039
|
DEFAULT_PHONE_COUNTRY,
|
|
3040
|
+
DEFAULT_VIDEO_CHECKPOINTS,
|
|
2879
3041
|
EVENT_SEMANTICS,
|
|
2880
3042
|
GoogleAdsTracking,
|
|
2881
3043
|
LEAD_FORM_KINDS,
|
|
@@ -2889,6 +3051,8 @@ export {
|
|
|
2889
3051
|
SUPPORTED_CURRENCIES,
|
|
2890
3052
|
TRACKING_PARAM_KEYS,
|
|
2891
3053
|
TRACKING_RANGES,
|
|
3054
|
+
TrackedVideo,
|
|
3055
|
+
TrackedVideoStage,
|
|
2892
3056
|
bookableSlots,
|
|
2893
3057
|
buildBookingHandoffUrl,
|
|
2894
3058
|
captureTrackingParamsFromLocation,
|
|
@@ -2913,6 +3077,7 @@ export {
|
|
|
2913
3077
|
getTrackingConfigRuntime,
|
|
2914
3078
|
groupBookingOptions,
|
|
2915
3079
|
leadFormPrimitiveSchemas,
|
|
3080
|
+
mergeVideoRanges,
|
|
2916
3081
|
newBookingAttemptKey,
|
|
2917
3082
|
onConsentChange,
|
|
2918
3083
|
optIn,
|
|
@@ -2922,6 +3087,7 @@ export {
|
|
|
2922
3087
|
resetConsent,
|
|
2923
3088
|
resolveConversionConfig,
|
|
2924
3089
|
resolveTrackingConfigUrl,
|
|
3090
|
+
roundVideoSeconds,
|
|
2925
3091
|
saleCreateSchema,
|
|
2926
3092
|
saleItemSchema,
|
|
2927
3093
|
saleServiceSchema,
|
|
@@ -2931,6 +3097,9 @@ export {
|
|
|
2931
3097
|
shopToday,
|
|
2932
3098
|
slotFields,
|
|
2933
3099
|
stashUserData,
|
|
3100
|
+
streamManifestUrl,
|
|
3101
|
+
streamPosterUrl,
|
|
3102
|
+
sumVideoRangesSeconds,
|
|
2934
3103
|
timeWindow,
|
|
2935
3104
|
toE164,
|
|
2936
3105
|
toMinor,
|
|
@@ -2944,6 +3113,7 @@ export {
|
|
|
2944
3113
|
useGclid,
|
|
2945
3114
|
usePhoneConfig,
|
|
2946
3115
|
usePhoneField,
|
|
3116
|
+
useTrackedVideoConfig,
|
|
2947
3117
|
useTrackingParams
|
|
2948
3118
|
};
|
|
2949
3119
|
//# sourceMappingURL=index.mjs.map
|