@aranova/tracking-next 0.11.0 → 0.12.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/index.d.mts CHANGED
@@ -1,9 +1,12 @@
1
- import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, G as GtagEnvironmentMap } from './types-BPJLgMsG.mjs';
2
- export { f as TrackingInitConfig } from './types-BPJLgMsG.mjs';
1
+ import { C as ConsentState, a as TrackingInstallSurface, b as TrackingEnvironment, c as TrackingClientContext, T as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, F as FormSubmitConfig, f as FormSubmitMetadata, G as GtagEnvironmentMap, P as PhoneConfig, g as ParsedPhone, h as PhoneDisplayFormat } from './phone-utils-DZ0Ger64.mjs';
2
+ export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formatPhone, l as formatPhoneAsTyped, p as parsePhone, m as phoneField, t as toE164 } from './phone-utils-DZ0Ger64.mjs';
3
3
  import { z } from 'zod';
4
4
  import * as src from 'src';
5
- import { ReactNode, CSSProperties } from 'react';
5
+ import * as react from 'react';
6
+ import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
6
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
+ import { CountryCode } from 'libphonenumber-js';
9
+ export { CountryCode } from 'libphonenumber-js';
7
10
 
8
11
  /**
9
12
  * Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
@@ -234,131 +237,6 @@ declare const formStartConfigSchema: z.ZodObject<{
234
237
  }>;
235
238
  type FormStartConfig = z.infer<typeof formStartConfigSchema>;
236
239
 
237
- /**
238
- * JSON-serializable value accepted by `form_submit.fields[].value`.
239
- *
240
- * This intentionally excludes `undefined`, functions, symbols, `Date`
241
- * instances, and non-finite numbers. Values are stored in PostgreSQL JSONB, so
242
- * consumers should send only data that has a stable JSON representation.
243
- */
244
- type JsonValue = string | number | boolean | null | JsonValue[] | {
245
- [key: string]: JsonValue;
246
- };
247
- /**
248
- * Metadata for a manually fired `form_submit` event.
249
- *
250
- * Register the event with `manual: { form_submit: {} }`, then call
251
- * `trackEvent('form_submit', metadata)` from the host site's submit handler.
252
- *
253
- * `fields` is optional. If present, each field value must be JSON-serializable
254
- * and should be explicitly allowlisted by the integration. Do not send names,
255
- * emails, visitor phone numbers, addresses, payment data, medical details,
256
- * passwords, file contents, or free-text messages.
257
- *
258
- * @example
259
- * ```ts
260
- * tracking.trackEvent('form_submit', {
261
- * form: {
262
- * id: 'lead-form',
263
- * action: '/api/lead',
264
- * fields: [
265
- * {
266
- * name: 'service_interest',
267
- * type: 'select',
268
- * label: 'Service interest',
269
- * value: 'teeth_whitening',
270
- * },
271
- * ],
272
- * },
273
- * page: { path: window.location.pathname },
274
- * });
275
- * ```
276
- */
277
- declare const formSubmitMetadataSchema: z.ZodObject<{
278
- form: z.ZodObject<{
279
- id: z.ZodString;
280
- action: z.ZodNullable<z.ZodString>;
281
- fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
282
- name: z.ZodString;
283
- type: z.ZodString;
284
- label: z.ZodNullable<z.ZodString>;
285
- value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
286
- }, "strict", z.ZodTypeAny, {
287
- label: string | null;
288
- value: JsonValue;
289
- type: string;
290
- name: string;
291
- }, {
292
- label: string | null;
293
- value: JsonValue;
294
- type: string;
295
- name: string;
296
- }>, "many">>;
297
- }, "strict", z.ZodTypeAny, {
298
- id: string;
299
- action: string | null;
300
- fields?: {
301
- label: string | null;
302
- value: JsonValue;
303
- type: string;
304
- name: string;
305
- }[] | undefined;
306
- }, {
307
- id: string;
308
- action: string | null;
309
- fields?: {
310
- label: string | null;
311
- value: JsonValue;
312
- type: string;
313
- name: string;
314
- }[] | undefined;
315
- }>;
316
- page: z.ZodObject<{
317
- path: z.ZodString;
318
- }, "strict", z.ZodTypeAny, {
319
- path: string;
320
- }, {
321
- path: string;
322
- }>;
323
- }, "strict", z.ZodTypeAny, {
324
- form: {
325
- id: string;
326
- action: string | null;
327
- fields?: {
328
- label: string | null;
329
- value: JsonValue;
330
- type: string;
331
- name: string;
332
- }[] | undefined;
333
- };
334
- page: {
335
- path: string;
336
- };
337
- }, {
338
- form: {
339
- id: string;
340
- action: string | null;
341
- fields?: {
342
- label: string | null;
343
- value: JsonValue;
344
- type: string;
345
- name: string;
346
- }[] | undefined;
347
- };
348
- page: {
349
- path: string;
350
- };
351
- }>;
352
- type FormSubmitMetadata = z.infer<typeof formSubmitMetadataSchema>;
353
- /**
354
- * Registration config for `form_submit`.
355
- *
356
- * This event is manual-only and currently has no registration options. The
357
- * empty object enables typed `trackEvent('form_submit', ...)` calls.
358
- */
359
- declare const formSubmitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
360
- type FormSubmitConfig = z.infer<typeof formSubmitConfigSchema>;
361
-
362
240
  /**
363
241
  * Metadata for the automatic `multi_page_session` event.
364
242
  *
@@ -412,14 +290,14 @@ declare const pageViewMetadataSchema: z.ZodObject<{
412
290
  search: z.ZodString;
413
291
  hash: z.ZodString;
414
292
  }, "strict", z.ZodTypeAny, {
293
+ path: string;
415
294
  search: string;
416
295
  title: string | null;
417
- path: string;
418
296
  hash: string;
419
297
  }, {
298
+ path: string;
420
299
  search: string;
421
300
  title: string | null;
422
- path: string;
423
301
  hash: string;
424
302
  }>;
425
303
  referrer: z.ZodNullable<z.ZodString>;
@@ -435,9 +313,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
435
313
  }>>>;
436
314
  }, "strict", z.ZodTypeAny, {
437
315
  page: {
316
+ path: string;
438
317
  search: string;
439
318
  title: string | null;
440
- path: string;
441
319
  hash: string;
442
320
  };
443
321
  referrer: string | null;
@@ -447,9 +325,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
447
325
  } | null | undefined;
448
326
  }, {
449
327
  page: {
328
+ path: string;
450
329
  search: string;
451
330
  title: string | null;
452
- path: string;
453
331
  hash: string;
454
332
  };
455
333
  referrer: string | null;
@@ -658,14 +536,14 @@ declare const EVENT_REGISTRY: {
658
536
  search: z.ZodString;
659
537
  hash: z.ZodString;
660
538
  }, "strict", z.ZodTypeAny, {
539
+ path: string;
661
540
  search: string;
662
541
  title: string | null;
663
- path: string;
664
542
  hash: string;
665
543
  }, {
544
+ path: string;
666
545
  search: string;
667
546
  title: string | null;
668
- path: string;
669
547
  hash: string;
670
548
  }>;
671
549
  referrer: z.ZodNullable<z.ZodString>;
@@ -681,9 +559,9 @@ declare const EVENT_REGISTRY: {
681
559
  }>>>;
682
560
  }, "strict", z.ZodTypeAny, {
683
561
  page: {
562
+ path: string;
684
563
  search: string;
685
564
  title: string | null;
686
- path: string;
687
565
  hash: string;
688
566
  };
689
567
  referrer: string | null;
@@ -693,9 +571,9 @@ declare const EVENT_REGISTRY: {
693
571
  } | null | undefined;
694
572
  }, {
695
573
  page: {
574
+ path: string;
696
575
  search: string;
697
576
  title: string | null;
698
- path: string;
699
577
  hash: string;
700
578
  };
701
579
  referrer: string | null;
@@ -939,33 +817,33 @@ declare const EVENT_REGISTRY: {
939
817
  label: z.ZodNullable<z.ZodString>;
940
818
  value: z.ZodType<src.JsonValue, z.ZodTypeDef, src.JsonValue>;
941
819
  }, "strict", z.ZodTypeAny, {
942
- label: string | null;
943
820
  value: src.JsonValue;
944
821
  type: string;
945
822
  name: string;
946
- }, {
947
823
  label: string | null;
824
+ }, {
948
825
  value: src.JsonValue;
949
826
  type: string;
950
827
  name: string;
828
+ label: string | null;
951
829
  }>, "many">>;
952
830
  }, "strict", z.ZodTypeAny, {
953
831
  id: string;
954
832
  action: string | null;
955
833
  fields?: {
956
- label: string | null;
957
834
  value: src.JsonValue;
958
835
  type: string;
959
836
  name: string;
837
+ label: string | null;
960
838
  }[] | undefined;
961
839
  }, {
962
840
  id: string;
963
841
  action: string | null;
964
842
  fields?: {
965
- label: string | null;
966
843
  value: src.JsonValue;
967
844
  type: string;
968
845
  name: string;
846
+ label: string | null;
969
847
  }[] | undefined;
970
848
  }>;
971
849
  page: z.ZodObject<{
@@ -980,10 +858,10 @@ declare const EVENT_REGISTRY: {
980
858
  id: string;
981
859
  action: string | null;
982
860
  fields?: {
983
- label: string | null;
984
861
  value: src.JsonValue;
985
862
  type: string;
986
863
  name: string;
864
+ label: string | null;
987
865
  }[] | undefined;
988
866
  };
989
867
  page: {
@@ -994,10 +872,10 @@ declare const EVENT_REGISTRY: {
994
872
  id: string;
995
873
  action: string | null;
996
874
  fields?: {
997
- label: string | null;
998
875
  value: src.JsonValue;
999
876
  type: string;
1000
877
  name: string;
878
+ label: string | null;
1001
879
  }[] | undefined;
1002
880
  };
1003
881
  page: {
@@ -1614,7 +1492,11 @@ interface SaleListPage {
1614
1492
  interface SaleCursorPage {
1615
1493
  items: Sale[];
1616
1494
  next_cursor: string | null;
1495
+ /** Populated only when `want_total` was requested (a single indexed COUNT). */
1496
+ total_count?: number;
1497
+ has_more?: boolean;
1617
1498
  }
1499
+ type SaleSortOrder = 'asc' | 'desc';
1618
1500
  /**
1619
1501
  * Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
1620
1502
  *
@@ -1627,6 +1509,8 @@ interface SaleFilters {
1627
1509
  business_id?: string;
1628
1510
  external_id?: string;
1629
1511
  service_id?: string;
1512
+ /** E.164 phone — the canonical customer key; filters sales for one customer. */
1513
+ customer_phone?: string;
1630
1514
  currency?: SupportedCurrency;
1631
1515
  environment?: (typeof TRACKING_ENVIRONMENTS)[number];
1632
1516
  since?: string;
@@ -1650,6 +1534,15 @@ interface SaleListQuery extends SaleFilters {
1650
1534
  limit?: number;
1651
1535
  cursor?: string | null;
1652
1536
  }
1537
+ /** Keyset-safe sort columns (NOT-NULL, indexed). */
1538
+ type SaleKeysetSortField = 'occurred_at' | 'created_at' | 'amount_total_cents';
1539
+ /** v2 list query — adds server sort + opt-in total. */
1540
+ interface SaleListQueryV2 extends SaleListQuery {
1541
+ sort?: SaleKeysetSortField;
1542
+ order?: SaleSortOrder;
1543
+ /** Opt-in: a single indexed COUNT over the filtered set. */
1544
+ want_total?: boolean;
1545
+ }
1653
1546
  declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
1654
1547
  type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
1655
1548
  /** Query input for `SalesClient.summary()` — filters + range + options. */
@@ -1705,6 +1598,175 @@ interface SaleSummary {
1705
1598
  by_category: SalesCategoryBreakdown[];
1706
1599
  series: SalesTrendPoint[];
1707
1600
  }
1601
+ declare const NAMED_RANGES: readonly ["today", "yesterday", "wtd", "mtd", "qtd", "ytd", "24h", "7d", "30d", "90d", "custom"];
1602
+ /** Superset of `TrackingOverviewRange` (`24h`/`7d`/`30d` stay valid). */
1603
+ type NamedRange = (typeof NAMED_RANGES)[number];
1604
+ type Granularity = 'hour' | 'day' | 'week' | 'month' | 'auto';
1605
+ type CompareTo = 'previous_period' | 'previous_year' | 'none';
1606
+ interface DistinctCustomersByCurrency {
1607
+ currency: SupportedCurrency;
1608
+ distinct_customers: number;
1609
+ }
1610
+ interface SummaryWindow {
1611
+ since: string;
1612
+ until: string;
1613
+ }
1614
+ interface SummaryCurrencyDelta {
1615
+ currency: SupportedCurrency;
1616
+ revenue_cents_delta: number;
1617
+ /** Ratio (0.12 = +12%); null when previous revenue was 0. */
1618
+ revenue_pct_delta: number | null;
1619
+ sale_count_delta: number;
1620
+ }
1621
+ interface SummaryDeltas {
1622
+ by_currency: SummaryCurrencyDelta[];
1623
+ sale_count_delta: number;
1624
+ distinct_customers_delta: number;
1625
+ }
1626
+ interface SaleSummaryPrevious {
1627
+ window: SummaryWindow;
1628
+ metrics: SaleSummaryV2['metrics'];
1629
+ by_currency: CurrencyRevenue[];
1630
+ series: SalesTrendPoint[];
1631
+ }
1632
+ /** Query input for `SalesClient.summary()` v2 — widened range + tz/compare options. */
1633
+ interface SaleSummaryQueryV2 extends SaleFilters {
1634
+ range?: NamedRange;
1635
+ /** Required when `range === 'custom'`. */
1636
+ since?: string;
1637
+ until?: string;
1638
+ /** IANA tz, e.g. `America/Toronto`. Default = business tz. */
1639
+ timezone?: string;
1640
+ granularity?: Granularity;
1641
+ compare_to?: CompareTo;
1642
+ include_categories?: boolean;
1643
+ include_deleted_services?: boolean;
1644
+ top_n?: number;
1645
+ }
1646
+ /** Superset of `SaleSummary` (assignable to it). */
1647
+ interface SaleSummaryV2 extends Omit<SaleSummary, 'range' | 'metrics'> {
1648
+ range: NamedRange;
1649
+ metrics: SaleSummary['metrics'] & {
1650
+ distinct_customers_by_currency: DistinctCustomersByCurrency[];
1651
+ };
1652
+ timezone: string | null;
1653
+ window: SummaryWindow | null;
1654
+ granularity: string | null;
1655
+ previous: SaleSummaryPrevious | null;
1656
+ deltas: SummaryDeltas | null;
1657
+ }
1658
+ type CustomerSegment = 'new' | 'returning' | 'repeat' | 'lapsed';
1659
+ type CustomerSortField = 'total_spent' | 'last_purchase' | 'purchases' | 'first_purchase';
1660
+ interface CustomerCurrencyTotal {
1661
+ currency: SupportedCurrency;
1662
+ revenue_cents: number;
1663
+ sale_count: number;
1664
+ average_order_value_cents: number;
1665
+ }
1666
+ interface CustomerSummary {
1667
+ /** The E.164 phone — the canonical customer id. */
1668
+ customer_id: string;
1669
+ display_name: string | null;
1670
+ email: string | null;
1671
+ phone: string;
1672
+ first_purchase_at: string;
1673
+ last_purchase_at: string;
1674
+ purchase_count: number;
1675
+ segment: CustomerSegment;
1676
+ totals: CustomerCurrencyTotal[];
1677
+ }
1678
+ type CustomerProfile = CustomerSummary;
1679
+ interface CustomerListQuery extends Omit<SaleFilters, 'external_id'> {
1680
+ segment?: CustomerSegment;
1681
+ sort?: CustomerSortField;
1682
+ order?: SaleSortOrder;
1683
+ cursor?: string | null;
1684
+ limit?: number;
1685
+ want_total?: boolean;
1686
+ }
1687
+ interface CustomerListPage {
1688
+ items: CustomerSummary[];
1689
+ next_cursor: string | null;
1690
+ total_count: number | null;
1691
+ }
1692
+ interface CustomerGetOptions {
1693
+ include_sales?: boolean;
1694
+ limit?: number;
1695
+ cursor?: string | null;
1696
+ }
1697
+ interface CustomerGetResult {
1698
+ customer: CustomerProfile;
1699
+ /** Present only when `include_sales: true` (and a business-scoped key). */
1700
+ sales?: SaleCursorPage | null;
1701
+ }
1702
+ interface CustomerSummaryQuery extends SaleFilters {
1703
+ range?: NamedRange;
1704
+ since?: string;
1705
+ until?: string;
1706
+ timezone?: string;
1707
+ compare_to?: CompareTo;
1708
+ }
1709
+ interface CustomerSegmentCount {
1710
+ segment: CustomerSegment;
1711
+ count: number;
1712
+ }
1713
+ interface CustomerCurrencyDelta {
1714
+ currency: SupportedCurrency;
1715
+ revenue_cents_delta: number;
1716
+ /** Ratio (0.12 = +12%); null when previous revenue was 0. */
1717
+ revenue_pct_delta: number | null;
1718
+ }
1719
+ interface CustomerKpisDeltas {
1720
+ total_customers_delta: number;
1721
+ new_customers_delta: number;
1722
+ returning_customers_delta: number;
1723
+ repeat_rate_delta: number;
1724
+ ltv_by_currency: CustomerCurrencyDelta[];
1725
+ }
1726
+ interface CustomerKpisPrevious {
1727
+ window_since: string;
1728
+ window_until: string;
1729
+ total_customers: number;
1730
+ new_customers: number;
1731
+ returning_customers: number;
1732
+ repeat_rate: number;
1733
+ ltv_by_currency: CustomerCurrencyTotal[];
1734
+ }
1735
+ interface CustomerKpis {
1736
+ range: NamedRange;
1737
+ timezone: string;
1738
+ window_since: string;
1739
+ window_until: string;
1740
+ total_customers: number;
1741
+ new_customers: number;
1742
+ returning_customers: number;
1743
+ repeat_rate: number;
1744
+ by_segment: CustomerSegmentCount[];
1745
+ ltv_by_currency: CustomerCurrencyTotal[];
1746
+ /** Present only when `compare_to` is set. */
1747
+ previous?: CustomerKpisPrevious | null;
1748
+ deltas?: CustomerKpisDeltas | null;
1749
+ }
1750
+ interface BusinessConfigService {
1751
+ key: string;
1752
+ label: string;
1753
+ archived: boolean;
1754
+ }
1755
+ interface BusinessConfigFeatures {
1756
+ customers: boolean;
1757
+ comparisons: boolean;
1758
+ retention: boolean;
1759
+ }
1760
+ interface BusinessConfig {
1761
+ business_id: string;
1762
+ display_name: string;
1763
+ timezone: string;
1764
+ primary_currency: SupportedCurrency;
1765
+ currencies: SupportedCurrency[];
1766
+ default_phone_country: string | null;
1767
+ services: BusinessConfigService[];
1768
+ features: BusinessConfigFeatures;
1769
+ }
1708
1770
 
1709
1771
  /** Shared config for every sales HTTP helper. */
1710
1772
  interface SalesTransportConfig {
@@ -1727,6 +1789,17 @@ interface SalesClientConfig extends SalesTransportConfig {
1727
1789
  /** Applied when an individual `record()` call omits `currency`. */
1728
1790
  defaultCurrency?: SupportedCurrency;
1729
1791
  }
1792
+ /** Phone-keyed customer rollups (sk-only; a public key gets a `403`). */
1793
+ interface SalesCustomersClient {
1794
+ list(query?: CustomerListQuery): Promise<CustomerListPage>;
1795
+ /** `id` is the customer's E.164 phone. */
1796
+ get(id: string, options?: CustomerGetOptions): Promise<CustomerGetResult>;
1797
+ summary(query?: CustomerSummaryQuery): Promise<CustomerKpis>;
1798
+ }
1799
+ /** Business config (low-sensitivity — accepts a public or secret key). */
1800
+ interface SalesBusinessClient {
1801
+ config(): Promise<BusinessConfig>;
1802
+ }
1730
1803
  /**
1731
1804
  * One isomorphic sales client — what a key may *do* is enforced by the backend,
1732
1805
  * not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
@@ -1747,13 +1820,14 @@ interface SalesClient<TService extends string = string> {
1747
1820
  currency?: SupportedCurrency;
1748
1821
  occurred_at?: string;
1749
1822
  }): Promise<Sale>;
1750
- list(query?: SaleListQuery): Promise<SaleCursorPage>;
1823
+ /** Keyset list with optional server sort + opt-in `total_count`. */
1824
+ list(query?: SaleListQueryV2): Promise<SaleCursorPage>;
1751
1825
  /**
1752
- * Currency-grouped aggregations for the key's business (revenue per currency,
1753
- * AOV, distinct customers, by-service / by-currency / by-category breakdowns,
1754
- * and a revenue/count trend). Secret key only — a public key gets a `403`.
1826
+ * Currency-grouped aggregations for the key's business. Additive v2 options:
1827
+ * calendar/custom ranges, IANA `timezone`, `granularity`, and `compare_to`.
1828
+ * Legacy `24h/7d/30d` keep their exact prior numbers. Secret key only.
1755
1829
  */
1756
- summary(query: SaleSummaryQuery): Promise<SaleSummary>;
1830
+ summary(query: SaleSummaryQueryV2): Promise<SaleSummaryV2>;
1757
1831
  get(id: string): Promise<Sale>;
1758
1832
  update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
1759
1833
  service?: TService | null;
@@ -1763,6 +1837,10 @@ interface SalesClient<TService extends string = string> {
1763
1837
  }>;
1764
1838
  }): Promise<Sale>;
1765
1839
  delete(id: string): Promise<void>;
1840
+ /** Phone-keyed customer rollups (sk-only). */
1841
+ customers: SalesCustomersClient;
1842
+ /** Business config (pk or sk). */
1843
+ business: SalesBusinessClient;
1766
1844
  }
1767
1845
  declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
1768
1846
 
@@ -1794,6 +1872,12 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
1794
1872
  * Uses the built-in `Intl.NumberFormat` — no extra dependency.
1795
1873
  */
1796
1874
  declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
1875
+ /**
1876
+ * Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
1877
+ * so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
1878
+ * `opts` to override fields. The `timeZone` is always forced to the argument.
1879
+ */
1880
+ declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
1797
1881
 
1798
1882
  /**
1799
1883
  * Error thrown by the sales client (`createSalesClient`) on a
@@ -1988,6 +2072,11 @@ interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
1988
2072
  * analytics can never throw into the host app.
1989
2073
  */
1990
2074
  debug?: boolean;
2075
+ /**
2076
+ * Phone-field display + default-country config, read by `usePhoneField` /
2077
+ * `<PhoneField>`. Display is customizable; the transmitted value is always E.164.
2078
+ */
2079
+ phone?: PhoneConfig;
1991
2080
  }
1992
2081
  interface TrackingProviderProps {
1993
2082
  /**
@@ -2019,4 +2108,71 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
2019
2108
  */
2020
2109
  declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
2021
2110
 
2022
- export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type CurrencyRevenue, type EventConfig, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, type FormSubmitConfig, type FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type JsonValue, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, type PhoneClickConfig, type PhoneClickMetadata, type PublicServiceItem, type RegisteredAutomaticEvents, type RegisteredManualEvents, type Sale, type SaleCursorPage, type SaleInput, type SaleItem, type SaleItemInput, type SaleListPage, type SaleListQuery, type SaleService, type SaleServiceInput, type SaleSummary, type SaleSummaryQuery, type SaleUpdateInput, type SalesCategoryBreakdown, type SalesClient, type SalesClientConfig, type SalesServiceBreakdown, type SalesTransportConfig, type SalesTrendPoint, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, type SupportedCurrency, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, type TrackingOverviewRange, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, useTrackingParams };
2111
+ /** Carries `createTracking({ phone })` config to `usePhoneField`. Separate from the
2112
+ * tracking client context so `useTracking()`'s type is untouched.
2113
+ *
2114
+ * Caveat: this module is bundled into BOTH `@aranova/tracking-react` and
2115
+ * `@aranova/tracking-next`, so each package has its own context instance at
2116
+ * runtime. Within one installed package the provider + hook share it (correct);
2117
+ * mixing `createTracking` from one package with `usePhoneField` from the other
2118
+ * won't share config (the hook falls back to the `CA`/`national` defaults). Use a
2119
+ * single tracking package per app. */
2120
+ declare const PhoneConfigContext: react.Context<PhoneConfig | null>;
2121
+ /** Resolve the effective phone config (provider value or built-in defaults). */
2122
+ declare function usePhoneConfig(): {
2123
+ defaultCountry: CountryCode;
2124
+ display: PhoneDisplayFormat;
2125
+ };
2126
+ interface UsePhoneFieldOptions {
2127
+ defaultValue?: string;
2128
+ /** Overrides the provider's `defaultCountry`. */
2129
+ country?: CountryCode;
2130
+ /** Overrides the provider's `display` (applied to the settled value on blur). */
2131
+ display?: PhoneDisplayFormat;
2132
+ /** Notified with the canonical E.164 (or `null`) on every change. */
2133
+ onValueChange?: (e164: string | null) => void;
2134
+ }
2135
+ interface PhoneInputProps {
2136
+ value: string;
2137
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
2138
+ onBlur: (event: FocusEvent<HTMLInputElement>) => void;
2139
+ type: 'tel';
2140
+ inputMode: 'tel';
2141
+ autoComplete: 'tel';
2142
+ }
2143
+ interface PhoneFieldApi {
2144
+ /** Display value for the `<input>` (live `AsYouType` while typing). */
2145
+ value: string;
2146
+ /** Canonical E.164 — what gets transmitted. `null` while invalid/incomplete. */
2147
+ e164: string | null;
2148
+ isValid: boolean;
2149
+ /** Validation message, surfaced only after blur with non-empty invalid input. */
2150
+ error: string | null;
2151
+ parsed: ParsedPhone;
2152
+ /** Spread onto an `<input>`: pre-wires value/onChange/onBlur/type/inputMode/autoComplete. */
2153
+ inputProps: PhoneInputProps;
2154
+ }
2155
+ /** Headless phone field — the client owns the markup. */
2156
+ declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
2157
+ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> {
2158
+ country?: CountryCode;
2159
+ /** Controlled display value. */
2160
+ value?: string;
2161
+ /** Uncontrolled initial value. */
2162
+ defaultValue?: string;
2163
+ /** Receives the native change event (RHF `register().onChange` or your own); the
2164
+ * event's `target.value` is already `AsYouType`-formatted. */
2165
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
2166
+ /** Receives the canonical E.164 (or `null`) on every change. */
2167
+ onE164Change?: (e164: string | null) => void;
2168
+ }
2169
+ /**
2170
+ * Batteries-included phone input. Composes identically with react-hook-form
2171
+ * `{...register('phone')}` and with controlled state — the `AsYouType` +
2172
+ * mutate-`e.target.value`-before-`onChange` technique lives inside, so RHF and
2173
+ * controlled parents both receive the formatted value, and the wire value stays
2174
+ * E.164.
2175
+ */
2176
+ declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
2177
+
2178
+ export { AranovaApiError, type AutomaticEventName, type BusinessConfig, type BusinessConfigFeatures, type BusinessConfigService, type CompareTo, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type CurrencyRevenue, type CustomerCurrencyDelta, type CustomerCurrencyTotal, type CustomerGetOptions, type CustomerGetResult, type CustomerKpis, type CustomerKpisDeltas, type CustomerKpisPrevious, type CustomerListPage, type CustomerListQuery, type CustomerProfile, type CustomerSegment, type CustomerSegmentCount, type CustomerSortField, type CustomerSummary, type CustomerSummaryQuery, type DistinctCustomersByCurrency, type EventConfig, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type Granularity, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type NamedRange, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneConfigContext, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type PublicServiceItem, type RegisteredAutomaticEvents, type RegisteredManualEvents, type Sale, type SaleCursorPage, type SaleInput, type SaleItem, type SaleItemInput, type SaleKeysetSortField, type SaleListPage, type SaleListQuery, type SaleListQueryV2, type SaleService, type SaleServiceInput, type SaleSortOrder, type SaleSummary, type SaleSummaryPrevious, type SaleSummaryQuery, type SaleSummaryQueryV2, type SaleSummaryV2, type SaleUpdateInput, type SalesBusinessClient, type SalesCategoryBreakdown, type SalesClient, type SalesClientConfig, type SalesCustomersClient, type SalesServiceBreakdown, type SalesTransportConfig, type SalesTrendPoint, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, type SummaryCurrencyDelta, type SummaryDeltas, type SummaryWindow, type SupportedCurrency, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, type TrackingOverviewRange, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatDateInTz, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };