@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/index.mjs
CHANGED
|
@@ -1733,7 +1733,7 @@ function outcomeOf(body) {
|
|
|
1733
1733
|
if (body.status === "pending") return { status: "pending", id: body.id, mode };
|
|
1734
1734
|
return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
|
|
1735
1735
|
}
|
|
1736
|
-
function formSubmitPayload(input,
|
|
1736
|
+
function formSubmitPayload(input, formSubmit, labels) {
|
|
1737
1737
|
const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
|
|
1738
1738
|
const field = (name, type, label, value) => ({
|
|
1739
1739
|
name,
|
|
@@ -1741,32 +1741,31 @@ function formSubmitPayload(input, formId, labels) {
|
|
|
1741
1741
|
label,
|
|
1742
1742
|
value
|
|
1743
1743
|
});
|
|
1744
|
+
const fields = [
|
|
1745
|
+
field("first_name", "text", "First name", input.firstName),
|
|
1746
|
+
field("last_name", "text", "Last name", input.lastName),
|
|
1747
|
+
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
1748
|
+
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
1749
|
+
field("email", "email", "Email", input.email ?? ""),
|
|
1750
|
+
field(
|
|
1751
|
+
"service",
|
|
1752
|
+
"select",
|
|
1753
|
+
"Service",
|
|
1754
|
+
input.services.map((key) => labels.get(key) ?? key).join(", ")
|
|
1755
|
+
),
|
|
1756
|
+
field("vehicle", "text", "Vehicle", vehicle),
|
|
1757
|
+
field(
|
|
1758
|
+
"start",
|
|
1759
|
+
"text",
|
|
1760
|
+
"Requested time",
|
|
1761
|
+
`${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
|
|
1762
|
+
),
|
|
1763
|
+
field("note", "textarea", "Notes", input.notes ?? "")
|
|
1764
|
+
];
|
|
1765
|
+
const reported = new Set(fields.map((item) => item.name));
|
|
1766
|
+
const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
|
|
1744
1767
|
return {
|
|
1745
|
-
form: {
|
|
1746
|
-
id: formId,
|
|
1747
|
-
action: "/tracking/bookings",
|
|
1748
|
-
fields: [
|
|
1749
|
-
field("first_name", "text", "First name", input.firstName),
|
|
1750
|
-
field("last_name", "text", "Last name", input.lastName),
|
|
1751
|
-
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
1752
|
-
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
1753
|
-
field("email", "email", "Email", input.email ?? ""),
|
|
1754
|
-
field(
|
|
1755
|
-
"service",
|
|
1756
|
-
"select",
|
|
1757
|
-
"Service",
|
|
1758
|
-
input.services.map((key) => labels.get(key) ?? key).join(", ")
|
|
1759
|
-
),
|
|
1760
|
-
field("vehicle", "text", "Vehicle", vehicle),
|
|
1761
|
-
field(
|
|
1762
|
-
"start",
|
|
1763
|
-
"text",
|
|
1764
|
-
"Requested time",
|
|
1765
|
-
`${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
|
|
1766
|
-
),
|
|
1767
|
-
field("note", "textarea", "Notes", input.notes ?? "")
|
|
1768
|
-
]
|
|
1769
|
-
},
|
|
1768
|
+
form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
|
|
1770
1769
|
page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
|
|
1771
1770
|
};
|
|
1772
1771
|
}
|
|
@@ -1854,7 +1853,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
1854
1853
|
return failedBeforeSend(input);
|
|
1855
1854
|
}
|
|
1856
1855
|
return {
|
|
1857
|
-
async submit(input, { attemptKey, formSubmit, simulate }) {
|
|
1856
|
+
async submit(input, { attemptKey, formSubmit, simulate, onPending }) {
|
|
1858
1857
|
registerCapability("booking_integration");
|
|
1859
1858
|
const runtime = runtimeOf(firing);
|
|
1860
1859
|
warnOnSetupMismatch(runtime);
|
|
@@ -1865,10 +1864,7 @@ function createSalesBookingsClient(config, firing) {
|
|
|
1865
1864
|
if (formSubmit && !submittedForms.has(attemptKey)) {
|
|
1866
1865
|
submittedForms.add(attemptKey);
|
|
1867
1866
|
const labels = new Map(booking.options.map((option) => [option.key, option.label]));
|
|
1868
|
-
formSubmit.tracking.trackEvent(
|
|
1869
|
-
"form_submit",
|
|
1870
|
-
formSubmitPayload(input, formSubmit.formId, labels)
|
|
1871
|
-
);
|
|
1867
|
+
formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
|
|
1872
1868
|
}
|
|
1873
1869
|
const body = {
|
|
1874
1870
|
idempotency_key: attemptKey,
|
|
@@ -1902,10 +1898,9 @@ function createSalesBookingsClient(config, firing) {
|
|
|
1902
1898
|
return rejected(error, input, attemptKey, runtime);
|
|
1903
1899
|
}
|
|
1904
1900
|
const outcome = outcomeOf(response);
|
|
1905
|
-
return withHandoff(
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
);
|
|
1901
|
+
if (outcome.status !== "pending") return withHandoff(outcome, input);
|
|
1902
|
+
onPending?.(outcome);
|
|
1903
|
+
return withHandoff(await poll(outcome.id, outcome.mode), input);
|
|
1909
1904
|
},
|
|
1910
1905
|
async status(id) {
|
|
1911
1906
|
return outcomeOf(
|