@aranova/tracking-react 1.4.1 → 1.6.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/README.md +16 -3
- package/dist/{bookings-DIu1ho6v.d.ts → bookings-B50X7GSG.d.ts} +20 -1
- package/dist/{bookings-CqCuuyP6.d.mts → bookings-n8UUzrak.d.mts} +20 -1
- package/dist/client.d.mts +4 -3
- package/dist/client.d.ts +4 -3
- package/dist/client.js +25 -4
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +25 -4
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +55 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -37
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-D7UZr0EM.d.mts → ingest-typed-ABH28Ips.d.mts} +16 -2
- package/dist/{ingest-typed-D2S3Kb8m.d.ts → ingest-typed-vP-DqpxO.d.ts} +16 -2
- package/dist/{sales-hlcVTJSS.d.ts → sales-D4QRnpdz.d.ts} +1 -1
- package/dist/{sales-CxJVthx_.d.mts → sales-DByfvgzT.d.mts} +1 -1
- package/dist/sales.d.mts +2 -2
- package/dist/sales.d.ts +2 -2
- package/dist/sales.js +36 -36
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +36 -36
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sales.mjs
CHANGED
|
@@ -189,7 +189,12 @@ function getBookingIntegration(integrations) {
|
|
|
189
189
|
timezone: booking.timezone,
|
|
190
190
|
configVersion: booking.config_version,
|
|
191
191
|
rules,
|
|
192
|
-
options: booking.options.map((option) => ({
|
|
192
|
+
options: booking.options.map((option) => ({
|
|
193
|
+
key: option.key,
|
|
194
|
+
label: option.label,
|
|
195
|
+
group: option.group,
|
|
196
|
+
description: option.description
|
|
197
|
+
})),
|
|
193
198
|
mode: booking.mode ?? "live"
|
|
194
199
|
};
|
|
195
200
|
}
|
|
@@ -411,7 +416,7 @@ function outcomeOf(body) {
|
|
|
411
416
|
if (body.status === "pending") return { status: "pending", id: body.id, mode };
|
|
412
417
|
return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
|
|
413
418
|
}
|
|
414
|
-
function formSubmitPayload(input,
|
|
419
|
+
function formSubmitPayload(input, formSubmit, labels) {
|
|
415
420
|
const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
|
|
416
421
|
const field = (name, type, label, value) => ({
|
|
417
422
|
name,
|
|
@@ -419,32 +424,31 @@ function formSubmitPayload(input, formId, labels) {
|
|
|
419
424
|
label,
|
|
420
425
|
value
|
|
421
426
|
});
|
|
427
|
+
const fields = [
|
|
428
|
+
field("first_name", "text", "First name", input.firstName),
|
|
429
|
+
field("last_name", "text", "Last name", input.lastName),
|
|
430
|
+
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
431
|
+
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
432
|
+
field("email", "email", "Email", input.email ?? ""),
|
|
433
|
+
field(
|
|
434
|
+
"service",
|
|
435
|
+
"select",
|
|
436
|
+
"Service",
|
|
437
|
+
input.services.map((key) => labels.get(key) ?? key).join(", ")
|
|
438
|
+
),
|
|
439
|
+
field("vehicle", "text", "Vehicle", vehicle),
|
|
440
|
+
field(
|
|
441
|
+
"start",
|
|
442
|
+
"text",
|
|
443
|
+
"Requested time",
|
|
444
|
+
`${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
|
|
445
|
+
),
|
|
446
|
+
field("note", "textarea", "Notes", input.notes ?? "")
|
|
447
|
+
];
|
|
448
|
+
const reported = new Set(fields.map((item) => item.name));
|
|
449
|
+
const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
|
|
422
450
|
return {
|
|
423
|
-
form: {
|
|
424
|
-
id: formId,
|
|
425
|
-
action: "/tracking/bookings",
|
|
426
|
-
fields: [
|
|
427
|
-
field("first_name", "text", "First name", input.firstName),
|
|
428
|
-
field("last_name", "text", "Last name", input.lastName),
|
|
429
|
-
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
430
|
-
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
431
|
-
field("email", "email", "Email", input.email ?? ""),
|
|
432
|
-
field(
|
|
433
|
-
"service",
|
|
434
|
-
"select",
|
|
435
|
-
"Service",
|
|
436
|
-
input.services.map((key) => labels.get(key) ?? key).join(", ")
|
|
437
|
-
),
|
|
438
|
-
field("vehicle", "text", "Vehicle", vehicle),
|
|
439
|
-
field(
|
|
440
|
-
"start",
|
|
441
|
-
"text",
|
|
442
|
-
"Requested time",
|
|
443
|
-
`${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
|
|
444
|
-
),
|
|
445
|
-
field("note", "textarea", "Notes", input.notes ?? "")
|
|
446
|
-
]
|
|
447
|
-
},
|
|
451
|
+
form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
|
|
448
452
|
page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
|
|
449
453
|
};
|
|
450
454
|
}
|
|
@@ -532,7 +536,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
532
536
|
return failedBeforeSend(input);
|
|
533
537
|
}
|
|
534
538
|
return {
|
|
535
|
-
async submit(input, { attemptKey, formSubmit, simulate }) {
|
|
539
|
+
async submit(input, { attemptKey, formSubmit, simulate, onPending }) {
|
|
536
540
|
registerCapability("booking_integration");
|
|
537
541
|
const runtime = runtimeOf(firing);
|
|
538
542
|
warnOnSetupMismatch(runtime);
|
|
@@ -543,10 +547,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
543
547
|
if (formSubmit && !submittedForms.has(attemptKey)) {
|
|
544
548
|
submittedForms.add(attemptKey);
|
|
545
549
|
const labels = new Map(booking.options.map((option) => [option.key, option.label]));
|
|
546
|
-
formSubmit.tracking.trackEvent(
|
|
547
|
-
"form_submit",
|
|
548
|
-
formSubmitPayload(input, formSubmit.formId, labels)
|
|
549
|
-
);
|
|
550
|
+
formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
|
|
550
551
|
}
|
|
551
552
|
const body = {
|
|
552
553
|
idempotency_key: attemptKey,
|
|
@@ -580,10 +581,9 @@ function createSalesBookingsClient(config, firing) {
|
|
|
580
581
|
return rejected(error, input, attemptKey, runtime);
|
|
581
582
|
}
|
|
582
583
|
const outcome = outcomeOf(response);
|
|
583
|
-
return withHandoff(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
);
|
|
584
|
+
if (outcome.status !== "pending") return withHandoff(outcome, input);
|
|
585
|
+
onPending?.(outcome);
|
|
586
|
+
return withHandoff(await poll(outcome.id, outcome.mode), input);
|
|
587
587
|
},
|
|
588
588
|
async status(id) {
|
|
589
589
|
return outcomeOf(
|