@aranova/tracking-react 0.11.0 → 0.12.1

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.ts CHANGED
@@ -1,6 +1,12 @@
1
- import { ReactNode, CSSProperties } from 'react';
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
3
+ import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c 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-DXAki8pO.js';
4
+ export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formSubmitConfigSchema, l as formSubmitMetadataSchema, m as formatPhone, n as formatPhoneAsTyped, o as jsonValueSchema, p as parsePhone, q as phoneField, t as toE164 } from './phone-utils-DXAki8pO.js';
2
5
  import * as src from 'src';
3
6
  import { z } from 'zod';
7
+ export { AranovaApiError, BusinessConfig, BusinessConfigFeatures, BusinessConfigService, CompareTo, CurrencyRevenue, CustomerCurrencyDelta, CustomerCurrencyTotal, CustomerGetOptions, CustomerGetResult, CustomerKpis, CustomerKpisDeltas, CustomerKpisPrevious, CustomerListPage, CustomerListQuery, CustomerProfile, CustomerSegment, CustomerSegmentCount, CustomerSortField, CustomerSummary, CustomerSummaryQuery, DistinctCustomersByCurrency, Granularity, NAMED_RANGES, NamedRange, PublicServiceItem, SUPPORTED_CURRENCIES, Sale, SaleCursorPage, SaleFilters, SaleInput, SaleItem, SaleItemInput, SaleKeysetSortField, SaleListPage, SaleListQuery, SaleListQueryV2, SaleService, SaleServiceInput, SaleSortField, SaleSortOrder, SaleSummary, SaleSummaryPrevious, SaleSummaryQuery, SaleSummaryQueryV2, SaleSummaryV2, SaleUpdateInput, SalesBusinessClient, SalesCategoryBreakdown, SalesClient, SalesClientConfig, SalesCustomersClient, SalesServiceBreakdown, SalesTransportConfig, SalesTrendPoint, SummaryCurrencyDelta, SummaryDeltas, SummaryWindow, SupportedCurrency, TRACKING_RANGES, TrackingOverviewRange, createSalesClient, fetchServices, formatDateInTz, formatMoney, fromMinor, saleCreateSchema, saleItemSchema, saleServiceSchema, saleUpdateSchema, salesRequest, toMinor } from './sales.js';
8
+ import { CountryCode } from 'libphonenumber-js';
9
+ export { CountryCode } from 'libphonenumber-js';
4
10
 
5
11
  /**
6
12
  * Default non-blocking consent banner.
@@ -55,11 +61,11 @@ interface ConsentBannerProps {
55
61
  onAccept?: () => void;
56
62
  onDecline?: () => void;
57
63
  /** Where the banner docks. Default: `"bottom"`. */
58
- position?: 'top' | 'bottom';
64
+ position?: "top" | "bottom";
59
65
  /**
60
66
  * Visual theme. `"auto"` follows `prefers-color-scheme`. Default: `"light"`.
61
67
  */
62
- theme?: 'light' | 'dark' | 'auto';
68
+ theme?: "light" | "dark" | "auto";
63
69
  /** Class added to the outer wrapper for additional styling hooks. */
64
70
  className?: string;
65
71
  /** Inline style overrides applied to the outer wrapper after the defaults. */
@@ -67,170 +73,10 @@ interface ConsentBannerProps {
67
73
  }
68
74
  declare function ConsentBanner({ message, title, acceptLabel, declineLabel, policyHref, policyLabel, onAccept, onDecline, position, theme, className, style, }?: ConsentBannerProps): ReactNode;
69
75
 
70
- /**
71
- * Visitor consent state stored by the SDK.
72
- *
73
- * - `pending`: the visitor has not accepted or declined yet.
74
- * - `granted`: consent was accepted and Google Consent Mode is updated to granted.
75
- * - `denied`: consent was declined and Google Consent Mode is updated to denied.
76
- */
77
- type ConsentState = 'granted' | 'denied' | 'pending';
78
- /**
79
- * Attribution parameters captured from the landing URL and persisted in cookies.
80
- *
81
- * Missing params are represented as `null` so payloads can be serialized
82
- * directly without checking for `undefined`.
83
- */
84
- interface TrackingParams {
85
- /** Google Ads click id. */
86
- gclid: string | null;
87
- /** Meta/Facebook click id. */
88
- fbclid: string | null;
89
- /** UTM source, for example `google` or `newsletter`. */
90
- utm_source: string | null;
91
- /** UTM medium, for example `cpc` or `email`. */
92
- utm_medium: string | null;
93
- /** UTM campaign name. */
94
- utm_campaign: string | null;
95
- /** UTM paid-search term. */
96
- utm_term: string | null;
97
- /** UTM content/ad creative label. */
98
- utm_content: string | null;
99
- }
100
- /**
101
- * Runtime surface that installed the tracking SDK.
102
- *
103
- * Included in ingest payloads and heartbeat events so the dashboard can tell
104
- * whether a site uses the Next, React, or script-tag integration.
105
- */
106
- type TrackingInstallSurface = 'next' | 'react' | 'script';
107
- /**
108
- * Deployment environment label for event tagging.
109
- *
110
- * Used to stamp tracking events with the deployment context so the dashboard
111
- * can distinguish production traffic from dev test traffic. The backend
112
- * enforces this via a Postgres enum, so values are strictly one of
113
- * `'production'` or `'development'`.
114
- */
115
- type TrackingEnvironment = 'production' | 'development';
116
- /**
117
- * Labelled map of Google Ads tag IDs.
118
- *
119
- * ALL entries are loaded simultaneously via `gtag('config', ...)` — the keys
120
- * are human-readable labels (e.g. `production`, `test`) and the values are
121
- * Google Ads tag IDs (e.g. `AW-123456789`).
122
- */
123
- type GtagEnvironmentMap = Record<string, string>;
124
- /**
125
- * Runtime context attached to tracking sessions and events.
126
- */
127
- interface TrackingClientContext {
128
- /** Install surface that created the client. */
129
- surface: TrackingInstallSurface;
130
- /** Package version, when available. */
131
- sdk_version: string | null;
132
- /** Package name, for example `@aranova/tracking-react`. */
133
- package_name: string | null;
134
- /** Browser origin of the tracked site. */
135
- site_origin: string | null;
136
- /** Current document title at client creation time. */
137
- page_title: string | null;
138
- /** Browser document referrer at client creation time. */
139
- referrer: string | null;
140
- /**
141
- * Deployment environment label, e.g. `'production'`, `'development'`.
142
- *
143
- * Always set — defaults to `'production'` when the consumer doesn't
144
- * pass `environment` to the factory. Sending `null` would fail the
145
- * backend's strict enum validation.
146
- */
147
- environment: TrackingEnvironment;
148
- /** All active gtag IDs loaded on this page, keyed by label. */
149
- active_gtag_ids: Record<string, string> | null;
150
- }
151
- /**
152
- * Session payload sent to `POST /tracking/events`.
153
- *
154
- * The backend upserts this by `(business_id, session_id)` before inserting
155
- * individual events.
156
- */
157
- interface TrackingSessionUpsertPayload {
158
- /** Rolling 30-minute client-side session id. */
159
- session_id: string;
160
- /** Persistent client-side visitor id. */
161
- visitor_id: string | null;
162
- gclid: string | null;
163
- fbclid: string | null;
164
- utm_source: string | null;
165
- utm_medium: string | null;
166
- utm_campaign: string | null;
167
- utm_term: string | null;
168
- utm_content: string | null;
169
- first_page: string | null;
170
- consent_state: Record<string, unknown> | null;
171
- context: TrackingClientContext;
172
- }
173
- /**
174
- * Event payload shape before batching into the ingest request.
175
- */
176
- interface TrackingEventCreatePayload {
177
- /** Session id that logically owns the event. */
178
- session_id: string;
179
- /** Registered event name, for example `page_view` or `form_submit`. */
180
- event_type: string;
181
- gclid: string | null;
182
- fbclid: string | null;
183
- /** Full page URL associated with the event, if known. */
184
- page_url: string | null;
185
- /** Event-specific metadata. Runtime shape depends on `event_type`. */
186
- metadata: Record<string, unknown> | null;
187
- context: TrackingClientContext;
188
- }
189
- /**
190
- * Browser-script initialization config passed to `window.AranovaTracking.init()`.
191
- */
192
- interface TrackingInitConfig {
193
- /** Public tracking API key issued from the Aranova dashboard. */
194
- apiKey?: string;
195
- /** Tracking endpoint base URL, usually ending in `/tracking`. */
196
- endpoint?: string;
197
- /** Optional Google Ads tag id, for example `AW-123456789`. */
198
- gtagId?: string;
199
- /**
200
- * Labelled map of Google Ads tag IDs. ALL are loaded simultaneously.
201
- * When provided, `gtagId` is ignored.
202
- */
203
- gtagIds?: GtagEnvironmentMap;
204
- /** Deployment environment label reported in session context. */
205
- environment?: TrackingEnvironment;
206
- /** Whether to capture attribution params from `window.location`. Defaults to true. */
207
- autoCaptureTrackingParams?: boolean;
208
- /** Whether the browser script should inject the default consent banner. */
209
- renderConsentBanner?: boolean;
210
- /** Attribution cookie max age in seconds. Defaults to 90 days. */
211
- cookieMaxAgeSeconds?: number;
212
- /** Override the install surface reported in payload context. */
213
- surface?: TrackingInstallSurface;
214
- }
215
- declare global {
216
- interface Window {
217
- gtag?: (...args: unknown[]) => void;
218
- dataLayer?: unknown[];
219
- AranovaTracking?: {
220
- init: (config: TrackingInitConfig) => void;
221
- captureTrackingParams: () => TrackingParams;
222
- getTrackingParams: () => TrackingParams;
223
- getConsentState: () => ConsentState;
224
- setConsentState: (state: 'granted' | 'denied') => void;
225
- trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
226
- };
227
- }
228
- }
229
-
230
76
  /**
231
77
  * Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
232
78
  */
233
- type GtagConsentValue = 'granted' | 'denied';
79
+ type GtagConsentValue = "granted" | "denied";
234
80
  /**
235
81
  * Read the persisted visitor consent state from localStorage.
236
82
  *
@@ -347,6 +193,19 @@ type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
347
193
  declare const ctaClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
348
194
  type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
349
195
 
196
+ /**
197
+ * Registered trigger names reported by the SDK heartbeat.
198
+ */
199
+ declare const sdkHeartbeatTriggersSchema: z.ZodObject<{
200
+ automatic: z.ZodArray<z.ZodString, "many">;
201
+ manual: z.ZodArray<z.ZodString, "many">;
202
+ }, "strict", z.ZodTypeAny, {
203
+ automatic: string[];
204
+ manual: string[];
205
+ }, {
206
+ automatic: string[];
207
+ manual: string[];
208
+ }>;
350
209
  /**
351
210
  * Metadata for the SDK-internal `sdk_heartbeat` event.
352
211
  *
@@ -456,131 +315,6 @@ declare const formStartConfigSchema: z.ZodObject<{
456
315
  }>;
457
316
  type FormStartConfig = z.infer<typeof formStartConfigSchema>;
458
317
 
459
- /**
460
- * JSON-serializable value accepted by `form_submit.fields[].value`.
461
- *
462
- * This intentionally excludes `undefined`, functions, symbols, `Date`
463
- * instances, and non-finite numbers. Values are stored in PostgreSQL JSONB, so
464
- * consumers should send only data that has a stable JSON representation.
465
- */
466
- type JsonValue = string | number | boolean | null | JsonValue[] | {
467
- [key: string]: JsonValue;
468
- };
469
- /**
470
- * Metadata for a manually fired `form_submit` event.
471
- *
472
- * Register the event with `manual: { form_submit: {} }`, then call
473
- * `trackEvent('form_submit', metadata)` from the host site's submit handler.
474
- *
475
- * `fields` is optional. If present, each field value must be JSON-serializable
476
- * and should be explicitly allowlisted by the integration. Do not send names,
477
- * emails, visitor phone numbers, addresses, payment data, medical details,
478
- * passwords, file contents, or free-text messages.
479
- *
480
- * @example
481
- * ```ts
482
- * tracking.trackEvent('form_submit', {
483
- * form: {
484
- * id: 'lead-form',
485
- * action: '/api/lead',
486
- * fields: [
487
- * {
488
- * name: 'service_interest',
489
- * type: 'select',
490
- * label: 'Service interest',
491
- * value: 'teeth_whitening',
492
- * },
493
- * ],
494
- * },
495
- * page: { path: window.location.pathname },
496
- * });
497
- * ```
498
- */
499
- declare const formSubmitMetadataSchema: z.ZodObject<{
500
- form: z.ZodObject<{
501
- id: z.ZodString;
502
- action: z.ZodNullable<z.ZodString>;
503
- fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
504
- name: z.ZodString;
505
- type: z.ZodString;
506
- label: z.ZodNullable<z.ZodString>;
507
- value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
508
- }, "strict", z.ZodTypeAny, {
509
- label: string | null;
510
- value: JsonValue;
511
- type: string;
512
- name: string;
513
- }, {
514
- label: string | null;
515
- value: JsonValue;
516
- type: string;
517
- name: string;
518
- }>, "many">>;
519
- }, "strict", z.ZodTypeAny, {
520
- id: string;
521
- action: string | null;
522
- fields?: {
523
- label: string | null;
524
- value: JsonValue;
525
- type: string;
526
- name: string;
527
- }[] | undefined;
528
- }, {
529
- id: string;
530
- action: string | null;
531
- fields?: {
532
- label: string | null;
533
- value: JsonValue;
534
- type: string;
535
- name: string;
536
- }[] | undefined;
537
- }>;
538
- page: z.ZodObject<{
539
- path: z.ZodString;
540
- }, "strict", z.ZodTypeAny, {
541
- path: string;
542
- }, {
543
- path: string;
544
- }>;
545
- }, "strict", z.ZodTypeAny, {
546
- form: {
547
- id: string;
548
- action: string | null;
549
- fields?: {
550
- label: string | null;
551
- value: JsonValue;
552
- type: string;
553
- name: string;
554
- }[] | undefined;
555
- };
556
- page: {
557
- path: string;
558
- };
559
- }, {
560
- form: {
561
- id: string;
562
- action: string | null;
563
- fields?: {
564
- label: string | null;
565
- value: JsonValue;
566
- type: string;
567
- name: string;
568
- }[] | undefined;
569
- };
570
- page: {
571
- path: string;
572
- };
573
- }>;
574
- type FormSubmitMetadata = z.infer<typeof formSubmitMetadataSchema>;
575
- /**
576
- * Registration config for `form_submit`.
577
- *
578
- * This event is manual-only and currently has no registration options. The
579
- * empty object enables typed `trackEvent('form_submit', ...)` calls.
580
- */
581
- declare const formSubmitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
582
- type FormSubmitConfig = z.infer<typeof formSubmitConfigSchema>;
583
-
584
318
  /**
585
319
  * Metadata for the automatic `multi_page_session` event.
586
320
  *
@@ -634,14 +368,14 @@ declare const pageViewMetadataSchema: z.ZodObject<{
634
368
  search: z.ZodString;
635
369
  hash: z.ZodString;
636
370
  }, "strict", z.ZodTypeAny, {
371
+ path: string;
637
372
  search: string;
638
373
  title: string | null;
639
- path: string;
640
374
  hash: string;
641
375
  }, {
376
+ path: string;
642
377
  search: string;
643
378
  title: string | null;
644
- path: string;
645
379
  hash: string;
646
380
  }>;
647
381
  referrer: z.ZodNullable<z.ZodString>;
@@ -657,9 +391,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
657
391
  }>>>;
658
392
  }, "strict", z.ZodTypeAny, {
659
393
  page: {
394
+ path: string;
660
395
  search: string;
661
396
  title: string | null;
662
- path: string;
663
397
  hash: string;
664
398
  };
665
399
  referrer: string | null;
@@ -669,9 +403,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
669
403
  } | null | undefined;
670
404
  }, {
671
405
  page: {
406
+ path: string;
672
407
  search: string;
673
408
  title: string | null;
674
- path: string;
675
409
  hash: string;
676
410
  };
677
411
  referrer: string | null;
@@ -774,6 +508,7 @@ type ScrollDepthConfig = z.infer<typeof scrollDepthConfigSchema>;
774
508
  */
775
509
  declare const SPECIFIC_PAGE_NAMES: readonly ["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"];
776
510
  type SpecificPageName = (typeof SPECIFIC_PAGE_NAMES)[number];
511
+ declare const specificPageNameSchema: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
777
512
  /**
778
513
  * Metadata for the automatic `specific_page_visit` event.
779
514
  *
@@ -870,6 +605,7 @@ declare const timeOnSiteConfigSchema: z.ZodObject<{
870
605
  }>;
871
606
  type TimeOnSiteConfig = z.infer<typeof timeOnSiteConfigSchema>;
872
607
 
608
+ type EventKind = "automatic" | "manual";
873
609
  declare const EVENT_REGISTRY: {
874
610
  readonly page_view: {
875
611
  readonly kind: "automatic";
@@ -880,14 +616,14 @@ declare const EVENT_REGISTRY: {
880
616
  search: z.ZodString;
881
617
  hash: z.ZodString;
882
618
  }, "strict", z.ZodTypeAny, {
619
+ path: string;
883
620
  search: string;
884
621
  title: string | null;
885
- path: string;
886
622
  hash: string;
887
623
  }, {
624
+ path: string;
888
625
  search: string;
889
626
  title: string | null;
890
- path: string;
891
627
  hash: string;
892
628
  }>;
893
629
  referrer: z.ZodNullable<z.ZodString>;
@@ -903,9 +639,9 @@ declare const EVENT_REGISTRY: {
903
639
  }>>>;
904
640
  }, "strict", z.ZodTypeAny, {
905
641
  page: {
642
+ path: string;
906
643
  search: string;
907
644
  title: string | null;
908
- path: string;
909
645
  hash: string;
910
646
  };
911
647
  referrer: string | null;
@@ -915,9 +651,9 @@ declare const EVENT_REGISTRY: {
915
651
  } | null | undefined;
916
652
  }, {
917
653
  page: {
654
+ path: string;
918
655
  search: string;
919
656
  title: string | null;
920
- path: string;
921
657
  hash: string;
922
658
  };
923
659
  referrer: string | null;
@@ -1161,33 +897,33 @@ declare const EVENT_REGISTRY: {
1161
897
  label: z.ZodNullable<z.ZodString>;
1162
898
  value: z.ZodType<src.JsonValue, z.ZodTypeDef, src.JsonValue>;
1163
899
  }, "strict", z.ZodTypeAny, {
1164
- label: string | null;
1165
900
  value: src.JsonValue;
1166
901
  type: string;
1167
902
  name: string;
1168
- }, {
1169
903
  label: string | null;
904
+ }, {
1170
905
  value: src.JsonValue;
1171
906
  type: string;
1172
907
  name: string;
908
+ label: string | null;
1173
909
  }>, "many">>;
1174
910
  }, "strict", z.ZodTypeAny, {
1175
911
  id: string;
1176
912
  action: string | null;
1177
913
  fields?: {
1178
- label: string | null;
1179
914
  value: src.JsonValue;
1180
915
  type: string;
1181
916
  name: string;
917
+ label: string | null;
1182
918
  }[] | undefined;
1183
919
  }, {
1184
920
  id: string;
1185
921
  action: string | null;
1186
922
  fields?: {
1187
- label: string | null;
1188
923
  value: src.JsonValue;
1189
924
  type: string;
1190
925
  name: string;
926
+ label: string | null;
1191
927
  }[] | undefined;
1192
928
  }>;
1193
929
  page: z.ZodObject<{
@@ -1202,10 +938,10 @@ declare const EVENT_REGISTRY: {
1202
938
  id: string;
1203
939
  action: string | null;
1204
940
  fields?: {
1205
- label: string | null;
1206
941
  value: src.JsonValue;
1207
942
  type: string;
1208
943
  name: string;
944
+ label: string | null;
1209
945
  }[] | undefined;
1210
946
  };
1211
947
  page: {
@@ -1216,10 +952,10 @@ declare const EVENT_REGISTRY: {
1216
952
  id: string;
1217
953
  action: string | null;
1218
954
  fields?: {
1219
- label: string | null;
1220
955
  value: src.JsonValue;
1221
956
  type: string;
1222
957
  name: string;
958
+ label: string | null;
1223
959
  }[] | undefined;
1224
960
  };
1225
961
  page: {
@@ -1296,13 +1032,13 @@ type EventName = keyof typeof EVENT_REGISTRY;
1296
1032
  * Automatic events are not accepted by the typed `trackEvent()` API.
1297
1033
  */
1298
1034
  type AutomaticEventName = {
1299
- [K in EventName]: (typeof EVENT_REGISTRY)[K]['kind'] extends 'automatic' ? K : never;
1035
+ [K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "automatic" ? K : never;
1300
1036
  }[EventName];
1301
1037
  /**
1302
1038
  * Event names that consumer code can fire manually after registering them.
1303
1039
  */
1304
1040
  type ManualEventName = {
1305
- [K in EventName]: (typeof EVENT_REGISTRY)[K]['kind'] extends 'manual' ? K : never;
1041
+ [K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "manual" ? K : never;
1306
1042
  }[EventName];
1307
1043
  type MetadataByName = {
1308
1044
  page_view: PageViewMetadata;
@@ -1341,6 +1077,14 @@ type EventMetadata<K extends EventName> = MetadataByName[K];
1341
1077
  * Trigger registration config type for a specific tracking event.
1342
1078
  */
1343
1079
  type EventConfig<K extends EventName> = ConfigByName[K];
1080
+ /**
1081
+ * Runtime list of automatic event names.
1082
+ */
1083
+ declare const ALL_AUTOMATIC_EVENT_NAMES: readonly AutomaticEventName[];
1084
+ /**
1085
+ * Runtime list of manual event names.
1086
+ */
1087
+ declare const ALL_MANUAL_EVENT_NAMES: readonly ManualEventName[];
1344
1088
  /**
1345
1089
  * Trigger registry passed to `createTracking({ triggers })`.
1346
1090
  *
@@ -1368,18 +1112,18 @@ type EventConfig<K extends EventName> = ConfigByName[K];
1368
1112
  */
1369
1113
  type TriggerRegistryConfig = {
1370
1114
  automatic: {
1371
- page_view: EventConfig<'page_view'>;
1115
+ page_view: EventConfig<"page_view">;
1372
1116
  } & Partial<{
1373
- time_on_site: EventConfig<'time_on_site'>;
1374
- specific_page_visit: EventConfig<'specific_page_visit'>;
1375
- scroll_depth: EventConfig<'scroll_depth'>;
1376
- multi_page_session: EventConfig<'multi_page_session'>;
1377
- form_start: EventConfig<'form_start'>;
1117
+ time_on_site: EventConfig<"time_on_site">;
1118
+ specific_page_visit: EventConfig<"specific_page_visit">;
1119
+ scroll_depth: EventConfig<"scroll_depth">;
1120
+ multi_page_session: EventConfig<"multi_page_session">;
1121
+ form_start: EventConfig<"form_start">;
1378
1122
  }>;
1379
1123
  manual?: Partial<{
1380
- form_submit: EventConfig<'form_submit'>;
1381
- phone_click: EventConfig<'phone_click'>;
1382
- cta_click: EventConfig<'cta_click'>;
1124
+ form_submit: EventConfig<"form_submit">;
1125
+ phone_click: EventConfig<"phone_click">;
1126
+ cta_click: EventConfig<"cta_click">;
1383
1127
  }>;
1384
1128
  };
1385
1129
  /**
@@ -1388,11 +1132,25 @@ type TriggerRegistryConfig = {
1388
1132
  * Used by `TypedTrackingClient` so `trackEvent()` only accepts events the
1389
1133
  * consumer explicitly enabled.
1390
1134
  */
1391
- type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry['manual']>, ManualEventName>;
1135
+ type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry["manual"]>, ManualEventName>;
1392
1136
  /**
1393
1137
  * Automatic event names registered in a concrete trigger registry.
1394
1138
  */
1395
- type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry['automatic'], AutomaticEventName>;
1139
+ type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry["automatic"], AutomaticEventName>;
1140
+ /**
1141
+ * Discriminated union of valid manual tracking calls for a registry.
1142
+ */
1143
+ type TrackableEvent<TRegistry extends TriggerRegistryConfig> = {
1144
+ [K in RegisteredManualEvents<TRegistry>]: {
1145
+ eventType: K;
1146
+ metadata: EventMetadata<K>;
1147
+ };
1148
+ }[RegisteredManualEvents<TRegistry>];
1149
+ declare function getEventDefinition(name: EventName): {
1150
+ kind: EventKind;
1151
+ metadataSchema: z.ZodTypeAny;
1152
+ configSchema: z.ZodTypeAny;
1153
+ };
1396
1154
 
1397
1155
  /**
1398
1156
  * Input accepted by the low-level stringly-typed client.
@@ -1470,569 +1228,6 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
1470
1228
  getVisitorId(): string;
1471
1229
  }
1472
1230
 
1473
- /**
1474
- * Sales / Conversions wire schemas — the client-side source of truth.
1475
- *
1476
- * `saleCreateSchema` is mirrored by `SaleCreateSchema` in
1477
- * `apps/api/src/schemas/tracking_sales.py` and enforced by the backend drift
1478
- * test (the `resources` section of `events.schema.json`). Keep them in lockstep.
1479
- *
1480
- * Money is **integer minor units (cents)**; `quantity` is a decimal string;
1481
- * `currency` is the required `SupportedCurrency` enum.
1482
- */
1483
- declare const SUPPORTED_CURRENCIES: readonly ["USD", "CAD"];
1484
- type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
1485
- declare const TRACKING_ENVIRONMENTS: readonly ["production", "development"];
1486
- declare const saleItemSchema: z.ZodObject<{
1487
- external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1488
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1489
- category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1490
- quantity: z.ZodString;
1491
- unit_price_cents: z.ZodNumber;
1492
- unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1493
- }, "strict", z.ZodTypeAny, {
1494
- quantity: string;
1495
- unit_price_cents: number;
1496
- name?: string | null | undefined;
1497
- external_item_id?: string | null | undefined;
1498
- category?: string | null | undefined;
1499
- unit_cost_cents?: number | null | undefined;
1500
- }, {
1501
- quantity: string;
1502
- unit_price_cents: number;
1503
- name?: string | null | undefined;
1504
- external_item_id?: string | null | undefined;
1505
- category?: string | null | undefined;
1506
- unit_cost_cents?: number | null | undefined;
1507
- }>;
1508
- declare const saleServiceSchema: z.ZodObject<{
1509
- service: z.ZodString;
1510
- amount_cents: z.ZodNumber;
1511
- }, "strict", z.ZodTypeAny, {
1512
- service: string;
1513
- amount_cents: number;
1514
- }, {
1515
- service: string;
1516
- amount_cents: number;
1517
- }>;
1518
- declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
1519
- external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1520
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1521
- service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1522
- services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1523
- service: z.ZodString;
1524
- amount_cents: z.ZodNumber;
1525
- }, "strict", z.ZodTypeAny, {
1526
- service: string;
1527
- amount_cents: number;
1528
- }, {
1529
- service: string;
1530
- amount_cents: number;
1531
- }>, "many">>>;
1532
- currency: z.ZodEnum<["USD", "CAD"]>;
1533
- amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1534
- occurred_at: z.ZodString;
1535
- environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
1536
- items: z.ZodDefault<z.ZodArray<z.ZodObject<{
1537
- external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1538
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1539
- category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1540
- quantity: z.ZodString;
1541
- unit_price_cents: z.ZodNumber;
1542
- unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1543
- }, "strict", z.ZodTypeAny, {
1544
- quantity: string;
1545
- unit_price_cents: number;
1546
- name?: string | null | undefined;
1547
- external_item_id?: string | null | undefined;
1548
- category?: string | null | undefined;
1549
- unit_cost_cents?: number | null | undefined;
1550
- }, {
1551
- quantity: string;
1552
- unit_price_cents: number;
1553
- name?: string | null | undefined;
1554
- external_item_id?: string | null | undefined;
1555
- category?: string | null | undefined;
1556
- unit_cost_cents?: number | null | undefined;
1557
- }>, "many">>;
1558
- metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1559
- customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1560
- customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1561
- customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1562
- }, "strict", z.ZodTypeAny, {
1563
- currency: "USD" | "CAD";
1564
- occurred_at: string;
1565
- environment: "production" | "development";
1566
- items: {
1567
- quantity: string;
1568
- unit_price_cents: number;
1569
- name?: string | null | undefined;
1570
- external_item_id?: string | null | undefined;
1571
- category?: string | null | undefined;
1572
- unit_cost_cents?: number | null | undefined;
1573
- }[];
1574
- metadata?: Record<string, unknown> | null | undefined;
1575
- service?: string | null | undefined;
1576
- services?: {
1577
- service: string;
1578
- amount_cents: number;
1579
- }[] | null | undefined;
1580
- amount_total_cents?: number | null | undefined;
1581
- external_id?: string | null | undefined;
1582
- description?: string | null | undefined;
1583
- customer_name?: string | null | undefined;
1584
- customer_phone?: string | null | undefined;
1585
- customer_email?: string | null | undefined;
1586
- }, {
1587
- currency: "USD" | "CAD";
1588
- occurred_at: string;
1589
- metadata?: Record<string, unknown> | null | undefined;
1590
- service?: string | null | undefined;
1591
- services?: {
1592
- service: string;
1593
- amount_cents: number;
1594
- }[] | null | undefined;
1595
- amount_total_cents?: number | null | undefined;
1596
- external_id?: string | null | undefined;
1597
- description?: string | null | undefined;
1598
- environment?: "production" | "development" | undefined;
1599
- items?: {
1600
- quantity: string;
1601
- unit_price_cents: number;
1602
- name?: string | null | undefined;
1603
- external_item_id?: string | null | undefined;
1604
- category?: string | null | undefined;
1605
- unit_cost_cents?: number | null | undefined;
1606
- }[] | undefined;
1607
- customer_name?: string | null | undefined;
1608
- customer_phone?: string | null | undefined;
1609
- customer_email?: string | null | undefined;
1610
- }>, {
1611
- currency: "USD" | "CAD";
1612
- occurred_at: string;
1613
- environment: "production" | "development";
1614
- items: {
1615
- quantity: string;
1616
- unit_price_cents: number;
1617
- name?: string | null | undefined;
1618
- external_item_id?: string | null | undefined;
1619
- category?: string | null | undefined;
1620
- unit_cost_cents?: number | null | undefined;
1621
- }[];
1622
- metadata?: Record<string, unknown> | null | undefined;
1623
- service?: string | null | undefined;
1624
- services?: {
1625
- service: string;
1626
- amount_cents: number;
1627
- }[] | null | undefined;
1628
- amount_total_cents?: number | null | undefined;
1629
- external_id?: string | null | undefined;
1630
- description?: string | null | undefined;
1631
- customer_name?: string | null | undefined;
1632
- customer_phone?: string | null | undefined;
1633
- customer_email?: string | null | undefined;
1634
- }, {
1635
- currency: "USD" | "CAD";
1636
- occurred_at: string;
1637
- metadata?: Record<string, unknown> | null | undefined;
1638
- service?: string | null | undefined;
1639
- services?: {
1640
- service: string;
1641
- amount_cents: number;
1642
- }[] | null | undefined;
1643
- amount_total_cents?: number | null | undefined;
1644
- external_id?: string | null | undefined;
1645
- description?: string | null | undefined;
1646
- environment?: "production" | "development" | undefined;
1647
- items?: {
1648
- quantity: string;
1649
- unit_price_cents: number;
1650
- name?: string | null | undefined;
1651
- external_item_id?: string | null | undefined;
1652
- category?: string | null | undefined;
1653
- unit_cost_cents?: number | null | undefined;
1654
- }[] | undefined;
1655
- customer_name?: string | null | undefined;
1656
- customer_phone?: string | null | undefined;
1657
- customer_email?: string | null | undefined;
1658
- }>;
1659
- declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
1660
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1661
- service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1662
- services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1663
- service: z.ZodString;
1664
- amount_cents: z.ZodNumber;
1665
- }, "strict", z.ZodTypeAny, {
1666
- service: string;
1667
- amount_cents: number;
1668
- }, {
1669
- service: string;
1670
- amount_cents: number;
1671
- }>, "many">>>;
1672
- currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
1673
- amount_total_cents: z.ZodOptional<z.ZodNumber>;
1674
- occurred_at: z.ZodOptional<z.ZodString>;
1675
- items: z.ZodOptional<z.ZodArray<z.ZodObject<{
1676
- external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1677
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1678
- category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1679
- quantity: z.ZodString;
1680
- unit_price_cents: z.ZodNumber;
1681
- unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1682
- }, "strict", z.ZodTypeAny, {
1683
- quantity: string;
1684
- unit_price_cents: number;
1685
- name?: string | null | undefined;
1686
- external_item_id?: string | null | undefined;
1687
- category?: string | null | undefined;
1688
- unit_cost_cents?: number | null | undefined;
1689
- }, {
1690
- quantity: string;
1691
- unit_price_cents: number;
1692
- name?: string | null | undefined;
1693
- external_item_id?: string | null | undefined;
1694
- category?: string | null | undefined;
1695
- unit_cost_cents?: number | null | undefined;
1696
- }>, "many">>;
1697
- metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1698
- customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1699
- customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1700
- customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1701
- }, "strict", z.ZodTypeAny, {
1702
- metadata?: Record<string, unknown> | null | undefined;
1703
- service?: string | null | undefined;
1704
- services?: {
1705
- service: string;
1706
- amount_cents: number;
1707
- }[] | null | undefined;
1708
- amount_total_cents?: number | undefined;
1709
- description?: string | null | undefined;
1710
- currency?: "USD" | "CAD" | undefined;
1711
- occurred_at?: string | undefined;
1712
- items?: {
1713
- quantity: string;
1714
- unit_price_cents: number;
1715
- name?: string | null | undefined;
1716
- external_item_id?: string | null | undefined;
1717
- category?: string | null | undefined;
1718
- unit_cost_cents?: number | null | undefined;
1719
- }[] | undefined;
1720
- customer_name?: string | null | undefined;
1721
- customer_phone?: string | null | undefined;
1722
- customer_email?: string | null | undefined;
1723
- }, {
1724
- metadata?: Record<string, unknown> | null | undefined;
1725
- service?: string | null | undefined;
1726
- services?: {
1727
- service: string;
1728
- amount_cents: number;
1729
- }[] | null | undefined;
1730
- amount_total_cents?: number | undefined;
1731
- description?: string | null | undefined;
1732
- currency?: "USD" | "CAD" | undefined;
1733
- occurred_at?: string | undefined;
1734
- items?: {
1735
- quantity: string;
1736
- unit_price_cents: number;
1737
- name?: string | null | undefined;
1738
- external_item_id?: string | null | undefined;
1739
- category?: string | null | undefined;
1740
- unit_cost_cents?: number | null | undefined;
1741
- }[] | undefined;
1742
- customer_name?: string | null | undefined;
1743
- customer_phone?: string | null | undefined;
1744
- customer_email?: string | null | undefined;
1745
- }>, {
1746
- metadata?: Record<string, unknown> | null | undefined;
1747
- service?: string | null | undefined;
1748
- services?: {
1749
- service: string;
1750
- amount_cents: number;
1751
- }[] | null | undefined;
1752
- amount_total_cents?: number | undefined;
1753
- description?: string | null | undefined;
1754
- currency?: "USD" | "CAD" | undefined;
1755
- occurred_at?: string | undefined;
1756
- items?: {
1757
- quantity: string;
1758
- unit_price_cents: number;
1759
- name?: string | null | undefined;
1760
- external_item_id?: string | null | undefined;
1761
- category?: string | null | undefined;
1762
- unit_cost_cents?: number | null | undefined;
1763
- }[] | undefined;
1764
- customer_name?: string | null | undefined;
1765
- customer_phone?: string | null | undefined;
1766
- customer_email?: string | null | undefined;
1767
- }, {
1768
- metadata?: Record<string, unknown> | null | undefined;
1769
- service?: string | null | undefined;
1770
- services?: {
1771
- service: string;
1772
- amount_cents: number;
1773
- }[] | null | undefined;
1774
- amount_total_cents?: number | undefined;
1775
- description?: string | null | undefined;
1776
- currency?: "USD" | "CAD" | undefined;
1777
- occurred_at?: string | undefined;
1778
- items?: {
1779
- quantity: string;
1780
- unit_price_cents: number;
1781
- name?: string | null | undefined;
1782
- external_item_id?: string | null | undefined;
1783
- category?: string | null | undefined;
1784
- unit_cost_cents?: number | null | undefined;
1785
- }[] | undefined;
1786
- customer_name?: string | null | undefined;
1787
- customer_phone?: string | null | undefined;
1788
- customer_email?: string | null | undefined;
1789
- }>;
1790
- type SaleItemInput = z.input<typeof saleItemSchema>;
1791
- type SaleServiceInput = z.input<typeof saleServiceSchema>;
1792
- type SaleInput = z.input<typeof saleCreateSchema>;
1793
- type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
1794
- interface SaleItem {
1795
- id: string;
1796
- external_item_id: string | null;
1797
- name: string | null;
1798
- category: string | null;
1799
- quantity: string;
1800
- unit_price_cents: number;
1801
- unit_cost_cents: number | null;
1802
- }
1803
- interface SaleService {
1804
- id: string;
1805
- service_id: string;
1806
- service_key: string;
1807
- service_label: string;
1808
- amount_cents: number;
1809
- }
1810
- interface Sale {
1811
- id: string;
1812
- business_id: string;
1813
- business_name?: string | null;
1814
- external_id: string | null;
1815
- currency: SupportedCurrency;
1816
- amount_total_cents: number;
1817
- description: string | null;
1818
- service_id: string | null;
1819
- service_key?: string | null;
1820
- service_label?: string | null;
1821
- services: SaleService[];
1822
- occurred_at: string;
1823
- environment: (typeof TRACKING_ENVIRONMENTS)[number];
1824
- metadata: Record<string, unknown> | null;
1825
- customer_name: string | null;
1826
- customer_phone: string | null;
1827
- customer_email: string | null;
1828
- created_at: string;
1829
- updated_at: string;
1830
- items: SaleItem[];
1831
- }
1832
- interface SaleListPage {
1833
- items: Sale[];
1834
- total: number;
1835
- }
1836
- interface SaleCursorPage {
1837
- items: Sale[];
1838
- next_cursor: string | null;
1839
- }
1840
- /**
1841
- * Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
1842
- *
1843
- * `search` runs case-insensitively across `customer_name`, `customer_phone`,
1844
- * `customer_email`, `description`, and `external_id` — the human-facing
1845
- * columns. `service_id` is the resolved per-business service UUID (different
1846
- * from the create-time `service` *key*).
1847
- */
1848
- interface SaleFilters {
1849
- business_id?: string;
1850
- external_id?: string;
1851
- service_id?: string;
1852
- currency?: SupportedCurrency;
1853
- environment?: (typeof TRACKING_ENVIRONMENTS)[number];
1854
- since?: string;
1855
- until?: string;
1856
- min_amount_cents?: number;
1857
- max_amount_cents?: number;
1858
- search?: string;
1859
- }
1860
- /**
1861
- * Full query input for `SalesClient.list()` — filters + pagination.
1862
- *
1863
- * Pagination is **keyset (cursor)**: `next_cursor` returned by one page is
1864
- * passed back as `cursor` on the next. `null` / undefined cursor = first page.
1865
- *
1866
- * Ordering on this endpoint is fixed at **`occurred_at DESC, id DESC`** — the
1867
- * cursor encodes a position in that index, so a different sort would
1868
- * invalidate cursors mid-pagination. For ad-hoc sorted reads use the
1869
- * dashboard admin endpoint, which is offset-paginated.
1870
- */
1871
- interface SaleListQuery extends SaleFilters {
1872
- limit?: number;
1873
- cursor?: string | null;
1874
- }
1875
- declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
1876
- type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
1877
- /** Query input for `SalesClient.summary()` — filters + range + options. */
1878
- interface SaleSummaryQuery extends SaleFilters {
1879
- range: TrackingOverviewRange;
1880
- /** Include the per-category line-item breakdown (extra join; default false). */
1881
- include_categories?: boolean;
1882
- /** Surface soft-deleted services individually (flagged "(deleted)") instead of
1883
- * rolling them into a single "Deleted services" bucket. Default false. */
1884
- include_deleted_services?: boolean;
1885
- /** Cap on the by-service / by-category rows (1–50, default 10). */
1886
- top_n?: number;
1887
- }
1888
- interface CurrencyRevenue {
1889
- currency: SupportedCurrency;
1890
- sale_count: number;
1891
- revenue_cents: number;
1892
- average_order_value_cents: number;
1893
- }
1894
- interface SalesServiceBreakdown {
1895
- service_id: string | null;
1896
- service_key: string | null;
1897
- /** "Unassigned" when the sale has no service. */
1898
- service_label: string | null;
1899
- currency: SupportedCurrency;
1900
- sale_count: number;
1901
- revenue_cents: number;
1902
- }
1903
- interface SalesCategoryBreakdown {
1904
- category: string | null;
1905
- currency: SupportedCurrency;
1906
- /** sum(unit_price_cents * quantity) — advisory, not authoritative. */
1907
- revenue_cents: number;
1908
- /** Decimal string. */
1909
- quantity: string;
1910
- }
1911
- interface SalesTrendPoint {
1912
- bucket_start: string;
1913
- currency: SupportedCurrency;
1914
- sale_count: number;
1915
- revenue_cents: number;
1916
- }
1917
- interface SaleSummary {
1918
- range: TrackingOverviewRange;
1919
- business_id: string | null;
1920
- metrics: {
1921
- sale_count: number;
1922
- distinct_customers: number;
1923
- by_currency: CurrencyRevenue[];
1924
- };
1925
- by_service: SalesServiceBreakdown[];
1926
- by_currency: CurrencyRevenue[];
1927
- by_category: SalesCategoryBreakdown[];
1928
- series: SalesTrendPoint[];
1929
- }
1930
-
1931
- /** Shared config for every sales HTTP helper. */
1932
- interface SalesTransportConfig {
1933
- /** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
1934
- apiKey: string;
1935
- /**
1936
- * Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
1937
- * The `/sales` path is appended by the helpers.
1938
- */
1939
- endpoint: string;
1940
- /** Optional SDK identity headers (mirrors the event ingest client). */
1941
- sdkVersion?: string;
1942
- packageName?: string;
1943
- surface?: string;
1944
- environment?: string;
1945
- }
1946
-
1947
- /** Config for {@link createSalesClient}. */
1948
- interface SalesClientConfig extends SalesTransportConfig {
1949
- /** Applied when an individual `record()` call omits `currency`. */
1950
- defaultCurrency?: SupportedCurrency;
1951
- }
1952
- /**
1953
- * One isomorphic sales client — what a key may *do* is enforced by the backend,
1954
- * not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
1955
- * backend rejects reads/CRUD from it with a `403`); a **secret** key
1956
- * (`aranv_sk_…`), used **server-side only**, gets full read/list/update/delete.
1957
- * Never ship a secret key in a browser bundle.
1958
- *
1959
- * Generic over the service-key union `TService`: bind the type emitted by
1960
- * `@aranova/tracking-cli gen` for compile-time-checked `service` values.
1961
- */
1962
- interface SalesClient<TService extends string = string> {
1963
- record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
1964
- service?: TService | null;
1965
- services?: Array<{
1966
- service: TService;
1967
- amount_cents: number;
1968
- }>;
1969
- currency?: SupportedCurrency;
1970
- occurred_at?: string;
1971
- }): Promise<Sale>;
1972
- list(query?: SaleListQuery): Promise<SaleCursorPage>;
1973
- /**
1974
- * Currency-grouped aggregations for the key's business (revenue per currency,
1975
- * AOV, distinct customers, by-service / by-currency / by-category breakdowns,
1976
- * and a revenue/count trend). Secret key only — a public key gets a `403`.
1977
- */
1978
- summary(query: SaleSummaryQuery): Promise<SaleSummary>;
1979
- get(id: string): Promise<Sale>;
1980
- update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
1981
- service?: TService | null;
1982
- services?: Array<{
1983
- service: TService;
1984
- amount_cents: number;
1985
- }>;
1986
- }): Promise<Sale>;
1987
- delete(id: string): Promise<void>;
1988
- }
1989
- declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
1990
-
1991
- /** A business's active service, as returned by `GET /tracking/services`. */
1992
- interface PublicServiceItem {
1993
- key: string;
1994
- label: string;
1995
- }
1996
- /**
1997
- * Fetch the caller's business's active service taxonomy. Accepts a public or
1998
- * secret key (the taxonomy is low-sensitivity category names). Powers the
1999
- * `@aranova/tracking-cli gen` codegen.
2000
- */
2001
- declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
2002
-
2003
- /**
2004
- * Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
2005
- *
2006
- * Convenience only — the wire is always integer cents. Uses float multiply +
2007
- * `Math.round`, so values that aren't exactly representable in binary float
2008
- * (e.g. `1.005`) can round to the neighbouring cent. If you already hold an
2009
- * exact cents integer, pass it straight through and skip this helper.
2010
- */
2011
- declare function toMinor(amount: number, currency: SupportedCurrency): number;
2012
- /** Convert integer minor units (`25050`) to a major amount (`250.5`). */
2013
- declare function fromMinor(cents: number, currency: SupportedCurrency): number;
2014
- /**
2015
- * Format integer minor units as a localized currency string (e.g. `"$250.50"`).
2016
- * Uses the built-in `Intl.NumberFormat` — no extra dependency.
2017
- */
2018
- declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
2019
-
2020
- /**
2021
- * Error thrown by the sales client (`createSalesClient`) on a
2022
- * non-2xx response. Unlike the fire-and-forget event queue (which swallows
2023
- * failures), a sale is a transaction the caller must be able to react to.
2024
- */
2025
- declare class AranovaApiError extends Error {
2026
- readonly status: number;
2027
- readonly code: string | undefined;
2028
- readonly requestId: string | undefined;
2029
- constructor(message: string, options: {
2030
- status: number;
2031
- code?: string;
2032
- requestId?: string;
2033
- });
2034
- }
2035
-
2036
1231
  /**
2037
1232
  * Props for the Google Ads tracking component.
2038
1233
  *
@@ -2144,6 +1339,11 @@ interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
2144
1339
  * loudly. Leave off in prod; turn on in dev to catch shape bugs early.
2145
1340
  */
2146
1341
  debug?: boolean;
1342
+ /**
1343
+ * Phone-field display + default-country config, read by `usePhoneField` /
1344
+ * `<PhoneField>`. Display is customizable; the transmitted value is always E.164.
1345
+ */
1346
+ phone?: PhoneConfig;
2147
1347
  }
2148
1348
  interface TrackingProviderProps {
2149
1349
  /**
@@ -2179,4 +1379,61 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
2179
1379
  }
2180
1380
  declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
2181
1381
 
2182
- export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, type 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, type TrackingClientContext, type TrackingEventCreatePayload, type TrackingInitConfig, type TrackingInstallSurface, type TrackingOverviewRange, type TrackingParams, type TrackingProviderProps, type 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 };
1382
+ /** Resolve the effective phone config (provider value or built-in defaults). */
1383
+ declare function usePhoneConfig(): {
1384
+ defaultCountry: CountryCode;
1385
+ display: PhoneDisplayFormat;
1386
+ };
1387
+ interface UsePhoneFieldOptions {
1388
+ defaultValue?: string;
1389
+ /** Overrides the provider's `defaultCountry`. */
1390
+ country?: CountryCode;
1391
+ /** Overrides the provider's `display` (applied to the settled value on blur). */
1392
+ display?: PhoneDisplayFormat;
1393
+ /** Notified with the canonical E.164 (or `null`) on every change. */
1394
+ onValueChange?: (e164: string | null) => void;
1395
+ }
1396
+ interface PhoneInputProps {
1397
+ value: string;
1398
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
1399
+ onBlur: (event: FocusEvent<HTMLInputElement>) => void;
1400
+ type: "tel";
1401
+ inputMode: "tel";
1402
+ autoComplete: "tel";
1403
+ }
1404
+ interface PhoneFieldApi {
1405
+ /** Display value for the `<input>` (live `AsYouType` while typing). */
1406
+ value: string;
1407
+ /** Canonical E.164 — what gets transmitted. `null` while invalid/incomplete. */
1408
+ e164: string | null;
1409
+ isValid: boolean;
1410
+ /** Validation message, surfaced only after blur with non-empty invalid input. */
1411
+ error: string | null;
1412
+ parsed: ParsedPhone;
1413
+ /** Spread onto an `<input>`: pre-wires value/onChange/onBlur/type/inputMode/autoComplete. */
1414
+ inputProps: PhoneInputProps;
1415
+ }
1416
+ /** Headless phone field — the client owns the markup. */
1417
+ declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
1418
+ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> {
1419
+ country?: CountryCode;
1420
+ /** Controlled display value. */
1421
+ value?: string;
1422
+ /** Uncontrolled initial value. */
1423
+ defaultValue?: string;
1424
+ /** Receives the native change event (RHF `register().onChange` or your own); the
1425
+ * event's `target.value` is already `AsYouType`-formatted. */
1426
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
1427
+ /** Receives the canonical E.164 (or `null`) on every change. */
1428
+ onE164Change?: (e164: string | null) => void;
1429
+ }
1430
+ /**
1431
+ * Batteries-included phone input. Composes identically with react-hook-form
1432
+ * `{...register('phone')}` and with controlled state — the `AsYouType` +
1433
+ * mutate-`e.target.value`-before-`onChange` technique lives inside, so RHF and
1434
+ * controlled parents both receive the formatted value, and the wire value stays
1435
+ * E.164.
1436
+ */
1437
+ declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
1438
+
1439
+ export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getConsentState, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, resetConsent, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, setConsentState, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };