@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.
@@ -1,4 +1,4 @@
1
- import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-CGWiBxnC.mjs';
1
+ import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-n8UUzrak.mjs';
2
2
  import * as zod_v4_core from 'zod/v4/core';
3
3
  import * as z from 'zod/mini';
4
4
  import { J as JsonValue, F as FormSubmitConfig, a as FormSubmitMetadata } from './form-submit-BLb28aCk.mjs';
@@ -1,4 +1,4 @@
1
- import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-aJuXoVwX.js';
1
+ import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-B50X7GSG.js';
2
2
  import * as zod_v4_core from 'zod/v4/core';
3
3
  import * as z from 'zod/mini';
4
4
  import { J as JsonValue, F as FormSubmitConfig, a as FormSubmitMetadata } from './form-submit-BLb28aCk.js';
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-aJuXoVwX.js';
2
+ import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-B50X7GSG.js';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-CGWiBxnC.mjs';
2
+ import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-n8UUzrak.mjs';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
package/dist/sales.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-BdU9BRdG.mjs';
2
- export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-CGWiBxnC.mjs';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-DByfvgzT.mjs';
2
+ export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-n8UUzrak.mjs';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
5
  import './form-submit-BLb28aCk.mjs';
package/dist/sales.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-Dvh-tPsk.js';
2
- export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-aJuXoVwX.js';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-D4QRnpdz.js';
2
+ export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-B50X7GSG.js';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
5
  import './form-submit-BLb28aCk.js';
package/dist/sales.js CHANGED
@@ -469,7 +469,7 @@ function outcomeOf(body) {
469
469
  if (body.status === "pending") return { status: "pending", id: body.id, mode };
470
470
  return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
471
471
  }
472
- function formSubmitPayload(input, formId, labels) {
472
+ function formSubmitPayload(input, formSubmit, labels) {
473
473
  const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
474
474
  const field = (name, type, label, value) => ({
475
475
  name,
@@ -477,32 +477,31 @@ function formSubmitPayload(input, formId, labels) {
477
477
  label,
478
478
  value
479
479
  });
480
+ const fields = [
481
+ field("first_name", "text", "First name", input.firstName),
482
+ field("last_name", "text", "Last name", input.lastName),
483
+ // E.164 on the wire: it keys the customer and enhanced-conversion matching.
484
+ field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
485
+ field("email", "email", "Email", input.email ?? ""),
486
+ field(
487
+ "service",
488
+ "select",
489
+ "Service",
490
+ input.services.map((key) => labels.get(key) ?? key).join(", ")
491
+ ),
492
+ field("vehicle", "text", "Vehicle", vehicle),
493
+ field(
494
+ "start",
495
+ "text",
496
+ "Requested time",
497
+ `${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
498
+ ),
499
+ field("note", "textarea", "Notes", input.notes ?? "")
500
+ ];
501
+ const reported = new Set(fields.map((item) => item.name));
502
+ const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
480
503
  return {
481
- form: {
482
- id: formId,
483
- action: "/tracking/bookings",
484
- fields: [
485
- field("first_name", "text", "First name", input.firstName),
486
- field("last_name", "text", "Last name", input.lastName),
487
- // E.164 on the wire: it keys the customer and enhanced-conversion matching.
488
- field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
489
- field("email", "email", "Email", input.email ?? ""),
490
- field(
491
- "service",
492
- "select",
493
- "Service",
494
- input.services.map((key) => labels.get(key) ?? key).join(", ")
495
- ),
496
- field("vehicle", "text", "Vehicle", vehicle),
497
- field(
498
- "start",
499
- "text",
500
- "Requested time",
501
- `${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
502
- ),
503
- field("note", "textarea", "Notes", input.notes ?? "")
504
- ]
505
- },
504
+ form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
506
505
  page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
507
506
  };
508
507
  }
@@ -590,7 +589,7 @@ function createSalesBookingsClient(config, firing) {
590
589
  return failedBeforeSend(input);
591
590
  }
592
591
  return {
593
- async submit(input, { attemptKey, formSubmit, simulate }) {
592
+ async submit(input, { attemptKey, formSubmit, simulate, onPending }) {
594
593
  registerCapability("booking_integration");
595
594
  const runtime = runtimeOf(firing);
596
595
  warnOnSetupMismatch(runtime);
@@ -601,10 +600,7 @@ function createSalesBookingsClient(config, firing) {
601
600
  if (formSubmit && !submittedForms.has(attemptKey)) {
602
601
  submittedForms.add(attemptKey);
603
602
  const labels = new Map(booking.options.map((option) => [option.key, option.label]));
604
- formSubmit.tracking.trackEvent(
605
- "form_submit",
606
- formSubmitPayload(input, formSubmit.formId, labels)
607
- );
603
+ formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
608
604
  }
609
605
  const body = {
610
606
  idempotency_key: attemptKey,
@@ -638,10 +634,9 @@ function createSalesBookingsClient(config, firing) {
638
634
  return rejected(error, input, attemptKey, runtime);
639
635
  }
640
636
  const outcome = outcomeOf(response);
641
- return withHandoff(
642
- outcome.status === "pending" ? await poll(outcome.id, outcome.mode) : outcome,
643
- input
644
- );
637
+ if (outcome.status !== "pending") return withHandoff(outcome, input);
638
+ onPending?.(outcome);
639
+ return withHandoff(await poll(outcome.id, outcome.mode), input);
645
640
  },
646
641
  async status(id) {
647
642
  return outcomeOf(