@aranova/tracking-react 1.5.0 → 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 +13 -3
- package/dist/{bookings-aJuXoVwX.d.ts → bookings-B50X7GSG.d.ts} +16 -1
- package/dist/{bookings-CGWiBxnC.d.mts → bookings-n8UUzrak.d.mts} +16 -1
- package/dist/client.d.mts +4 -3
- package/dist/client.d.ts +4 -3
- package/dist/client.js +11 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +11 -2
- 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 +30 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -35
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-CytXGVw4.d.mts → ingest-typed-ABH28Ips.d.mts} +1 -1
- package/dist/{ingest-typed-DpT-uFme.d.ts → ingest-typed-vP-DqpxO.d.ts} +1 -1
- package/dist/{sales-Dvh-tPsk.d.ts → sales-D4QRnpdz.d.ts} +1 -1
- package/dist/{sales-BdU9BRdG.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 +30 -35
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +30 -35
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sales.mjs
CHANGED
|
@@ -416,7 +416,7 @@ function outcomeOf(body) {
|
|
|
416
416
|
if (body.status === "pending") return { status: "pending", id: body.id, mode };
|
|
417
417
|
return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
|
|
418
418
|
}
|
|
419
|
-
function formSubmitPayload(input,
|
|
419
|
+
function formSubmitPayload(input, formSubmit, labels) {
|
|
420
420
|
const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
|
|
421
421
|
const field = (name, type, label, value) => ({
|
|
422
422
|
name,
|
|
@@ -424,32 +424,31 @@ function formSubmitPayload(input, formId, labels) {
|
|
|
424
424
|
label,
|
|
425
425
|
value
|
|
426
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));
|
|
427
450
|
return {
|
|
428
|
-
form: {
|
|
429
|
-
id: formId,
|
|
430
|
-
action: "/tracking/bookings",
|
|
431
|
-
fields: [
|
|
432
|
-
field("first_name", "text", "First name", input.firstName),
|
|
433
|
-
field("last_name", "text", "Last name", input.lastName),
|
|
434
|
-
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
435
|
-
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
436
|
-
field("email", "email", "Email", input.email ?? ""),
|
|
437
|
-
field(
|
|
438
|
-
"service",
|
|
439
|
-
"select",
|
|
440
|
-
"Service",
|
|
441
|
-
input.services.map((key) => labels.get(key) ?? key).join(", ")
|
|
442
|
-
),
|
|
443
|
-
field("vehicle", "text", "Vehicle", vehicle),
|
|
444
|
-
field(
|
|
445
|
-
"start",
|
|
446
|
-
"text",
|
|
447
|
-
"Requested time",
|
|
448
|
-
`${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
|
|
449
|
-
),
|
|
450
|
-
field("note", "textarea", "Notes", input.notes ?? "")
|
|
451
|
-
]
|
|
452
|
-
},
|
|
451
|
+
form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
|
|
453
452
|
page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
|
|
454
453
|
};
|
|
455
454
|
}
|
|
@@ -537,7 +536,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
537
536
|
return failedBeforeSend(input);
|
|
538
537
|
}
|
|
539
538
|
return {
|
|
540
|
-
async submit(input, { attemptKey, formSubmit, simulate }) {
|
|
539
|
+
async submit(input, { attemptKey, formSubmit, simulate, onPending }) {
|
|
541
540
|
registerCapability("booking_integration");
|
|
542
541
|
const runtime = runtimeOf(firing);
|
|
543
542
|
warnOnSetupMismatch(runtime);
|
|
@@ -548,10 +547,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
548
547
|
if (formSubmit && !submittedForms.has(attemptKey)) {
|
|
549
548
|
submittedForms.add(attemptKey);
|
|
550
549
|
const labels = new Map(booking.options.map((option) => [option.key, option.label]));
|
|
551
|
-
formSubmit.tracking.trackEvent(
|
|
552
|
-
"form_submit",
|
|
553
|
-
formSubmitPayload(input, formSubmit.formId, labels)
|
|
554
|
-
);
|
|
550
|
+
formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
|
|
555
551
|
}
|
|
556
552
|
const body = {
|
|
557
553
|
idempotency_key: attemptKey,
|
|
@@ -585,10 +581,9 @@ function createSalesBookingsClient(config, firing) {
|
|
|
585
581
|
return rejected(error, input, attemptKey, runtime);
|
|
586
582
|
}
|
|
587
583
|
const outcome = outcomeOf(response);
|
|
588
|
-
return withHandoff(
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
);
|
|
584
|
+
if (outcome.status !== "pending") return withHandoff(outcome, input);
|
|
585
|
+
onPending?.(outcome);
|
|
586
|
+
return withHandoff(await poll(outcome.id, outcome.mode), input);
|
|
592
587
|
},
|
|
593
588
|
async status(id) {
|
|
594
589
|
return outcomeOf(
|