@aranova/tracking-next 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/README.md +79 -71
- package/dist/index.d.mts +137 -722
- package/dist/index.d.ts +137 -722
- package/dist/index.js +408 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +385 -60
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.js +101 -0
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +101 -0
- package/dist/middleware.mjs.map +1 -1
- package/dist/phone-utils-dd1tW7sb.d.mts +344 -0
- package/dist/phone-utils-dd1tW7sb.d.ts +344 -0
- package/dist/phone.d.mts +3 -0
- package/dist/phone.d.ts +3 -0
- package/dist/phone.js +416 -0
- package/dist/phone.js.map +1 -0
- package/dist/phone.mjs +384 -0
- package/dist/phone.mjs.map +1 -0
- package/dist/sales.d.mts +784 -0
- package/dist/sales.d.ts +784 -0
- package/dist/sales.js +400 -0
- package/dist/sales.js.map +1 -0
- package/dist/sales.mjs +359 -0
- package/dist/sales.mjs.map +1 -0
- package/dist/server.d.mts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +101 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +101 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +51 -10
- package/dist/types-BPJLgMsG.d.mts +0 -161
- package/dist/types-BPJLgMsG.d.ts +0 -161
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { C as ConsentState,
|
|
2
|
-
export {
|
|
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-dd1tW7sb.js';
|
|
2
|
+
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-dd1tW7sb.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as src from 'src';
|
|
5
|
-
|
|
5
|
+
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';
|
|
6
|
+
import * as react from 'react';
|
|
7
|
+
import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
|
|
6
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
10
|
+
export { CountryCode } from 'libphonenumber-js';
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
10
14
|
*/
|
|
11
|
-
type GtagConsentValue =
|
|
15
|
+
type GtagConsentValue = "granted" | "denied";
|
|
12
16
|
/**
|
|
13
17
|
* Read the persisted visitor consent state from localStorage.
|
|
14
18
|
*
|
|
@@ -125,6 +129,19 @@ type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
|
|
|
125
129
|
declare const ctaClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
126
130
|
type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
|
|
127
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Registered trigger names reported by the SDK heartbeat.
|
|
134
|
+
*/
|
|
135
|
+
declare const sdkHeartbeatTriggersSchema: z.ZodObject<{
|
|
136
|
+
automatic: z.ZodArray<z.ZodString, "many">;
|
|
137
|
+
manual: z.ZodArray<z.ZodString, "many">;
|
|
138
|
+
}, "strict", z.ZodTypeAny, {
|
|
139
|
+
automatic: string[];
|
|
140
|
+
manual: string[];
|
|
141
|
+
}, {
|
|
142
|
+
automatic: string[];
|
|
143
|
+
manual: string[];
|
|
144
|
+
}>;
|
|
128
145
|
/**
|
|
129
146
|
* Metadata for the SDK-internal `sdk_heartbeat` event.
|
|
130
147
|
*
|
|
@@ -234,131 +251,6 @@ declare const formStartConfigSchema: z.ZodObject<{
|
|
|
234
251
|
}>;
|
|
235
252
|
type FormStartConfig = z.infer<typeof formStartConfigSchema>;
|
|
236
253
|
|
|
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
254
|
/**
|
|
363
255
|
* Metadata for the automatic `multi_page_session` event.
|
|
364
256
|
*
|
|
@@ -412,14 +304,14 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
412
304
|
search: z.ZodString;
|
|
413
305
|
hash: z.ZodString;
|
|
414
306
|
}, "strict", z.ZodTypeAny, {
|
|
307
|
+
path: string;
|
|
415
308
|
search: string;
|
|
416
309
|
title: string | null;
|
|
417
|
-
path: string;
|
|
418
310
|
hash: string;
|
|
419
311
|
}, {
|
|
312
|
+
path: string;
|
|
420
313
|
search: string;
|
|
421
314
|
title: string | null;
|
|
422
|
-
path: string;
|
|
423
315
|
hash: string;
|
|
424
316
|
}>;
|
|
425
317
|
referrer: z.ZodNullable<z.ZodString>;
|
|
@@ -435,9 +327,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
435
327
|
}>>>;
|
|
436
328
|
}, "strict", z.ZodTypeAny, {
|
|
437
329
|
page: {
|
|
330
|
+
path: string;
|
|
438
331
|
search: string;
|
|
439
332
|
title: string | null;
|
|
440
|
-
path: string;
|
|
441
333
|
hash: string;
|
|
442
334
|
};
|
|
443
335
|
referrer: string | null;
|
|
@@ -447,9 +339,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
447
339
|
} | null | undefined;
|
|
448
340
|
}, {
|
|
449
341
|
page: {
|
|
342
|
+
path: string;
|
|
450
343
|
search: string;
|
|
451
344
|
title: string | null;
|
|
452
|
-
path: string;
|
|
453
345
|
hash: string;
|
|
454
346
|
};
|
|
455
347
|
referrer: string | null;
|
|
@@ -552,6 +444,7 @@ type ScrollDepthConfig = z.infer<typeof scrollDepthConfigSchema>;
|
|
|
552
444
|
*/
|
|
553
445
|
declare const SPECIFIC_PAGE_NAMES: readonly ["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"];
|
|
554
446
|
type SpecificPageName = (typeof SPECIFIC_PAGE_NAMES)[number];
|
|
447
|
+
declare const specificPageNameSchema: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
|
|
555
448
|
/**
|
|
556
449
|
* Metadata for the automatic `specific_page_visit` event.
|
|
557
450
|
*
|
|
@@ -648,6 +541,7 @@ declare const timeOnSiteConfigSchema: z.ZodObject<{
|
|
|
648
541
|
}>;
|
|
649
542
|
type TimeOnSiteConfig = z.infer<typeof timeOnSiteConfigSchema>;
|
|
650
543
|
|
|
544
|
+
type EventKind = "automatic" | "manual";
|
|
651
545
|
declare const EVENT_REGISTRY: {
|
|
652
546
|
readonly page_view: {
|
|
653
547
|
readonly kind: "automatic";
|
|
@@ -658,14 +552,14 @@ declare const EVENT_REGISTRY: {
|
|
|
658
552
|
search: z.ZodString;
|
|
659
553
|
hash: z.ZodString;
|
|
660
554
|
}, "strict", z.ZodTypeAny, {
|
|
555
|
+
path: string;
|
|
661
556
|
search: string;
|
|
662
557
|
title: string | null;
|
|
663
|
-
path: string;
|
|
664
558
|
hash: string;
|
|
665
559
|
}, {
|
|
560
|
+
path: string;
|
|
666
561
|
search: string;
|
|
667
562
|
title: string | null;
|
|
668
|
-
path: string;
|
|
669
563
|
hash: string;
|
|
670
564
|
}>;
|
|
671
565
|
referrer: z.ZodNullable<z.ZodString>;
|
|
@@ -681,9 +575,9 @@ declare const EVENT_REGISTRY: {
|
|
|
681
575
|
}>>>;
|
|
682
576
|
}, "strict", z.ZodTypeAny, {
|
|
683
577
|
page: {
|
|
578
|
+
path: string;
|
|
684
579
|
search: string;
|
|
685
580
|
title: string | null;
|
|
686
|
-
path: string;
|
|
687
581
|
hash: string;
|
|
688
582
|
};
|
|
689
583
|
referrer: string | null;
|
|
@@ -693,9 +587,9 @@ declare const EVENT_REGISTRY: {
|
|
|
693
587
|
} | null | undefined;
|
|
694
588
|
}, {
|
|
695
589
|
page: {
|
|
590
|
+
path: string;
|
|
696
591
|
search: string;
|
|
697
592
|
title: string | null;
|
|
698
|
-
path: string;
|
|
699
593
|
hash: string;
|
|
700
594
|
};
|
|
701
595
|
referrer: string | null;
|
|
@@ -939,33 +833,33 @@ declare const EVENT_REGISTRY: {
|
|
|
939
833
|
label: z.ZodNullable<z.ZodString>;
|
|
940
834
|
value: z.ZodType<src.JsonValue, z.ZodTypeDef, src.JsonValue>;
|
|
941
835
|
}, "strict", z.ZodTypeAny, {
|
|
942
|
-
label: string | null;
|
|
943
836
|
value: src.JsonValue;
|
|
944
837
|
type: string;
|
|
945
838
|
name: string;
|
|
946
|
-
}, {
|
|
947
839
|
label: string | null;
|
|
840
|
+
}, {
|
|
948
841
|
value: src.JsonValue;
|
|
949
842
|
type: string;
|
|
950
843
|
name: string;
|
|
844
|
+
label: string | null;
|
|
951
845
|
}>, "many">>;
|
|
952
846
|
}, "strict", z.ZodTypeAny, {
|
|
953
847
|
id: string;
|
|
954
848
|
action: string | null;
|
|
955
849
|
fields?: {
|
|
956
|
-
label: string | null;
|
|
957
850
|
value: src.JsonValue;
|
|
958
851
|
type: string;
|
|
959
852
|
name: string;
|
|
853
|
+
label: string | null;
|
|
960
854
|
}[] | undefined;
|
|
961
855
|
}, {
|
|
962
856
|
id: string;
|
|
963
857
|
action: string | null;
|
|
964
858
|
fields?: {
|
|
965
|
-
label: string | null;
|
|
966
859
|
value: src.JsonValue;
|
|
967
860
|
type: string;
|
|
968
861
|
name: string;
|
|
862
|
+
label: string | null;
|
|
969
863
|
}[] | undefined;
|
|
970
864
|
}>;
|
|
971
865
|
page: z.ZodObject<{
|
|
@@ -980,10 +874,10 @@ declare const EVENT_REGISTRY: {
|
|
|
980
874
|
id: string;
|
|
981
875
|
action: string | null;
|
|
982
876
|
fields?: {
|
|
983
|
-
label: string | null;
|
|
984
877
|
value: src.JsonValue;
|
|
985
878
|
type: string;
|
|
986
879
|
name: string;
|
|
880
|
+
label: string | null;
|
|
987
881
|
}[] | undefined;
|
|
988
882
|
};
|
|
989
883
|
page: {
|
|
@@ -994,10 +888,10 @@ declare const EVENT_REGISTRY: {
|
|
|
994
888
|
id: string;
|
|
995
889
|
action: string | null;
|
|
996
890
|
fields?: {
|
|
997
|
-
label: string | null;
|
|
998
891
|
value: src.JsonValue;
|
|
999
892
|
type: string;
|
|
1000
893
|
name: string;
|
|
894
|
+
label: string | null;
|
|
1001
895
|
}[] | undefined;
|
|
1002
896
|
};
|
|
1003
897
|
page: {
|
|
@@ -1074,13 +968,13 @@ type EventName = keyof typeof EVENT_REGISTRY;
|
|
|
1074
968
|
* Automatic events are not accepted by the typed `trackEvent()` API.
|
|
1075
969
|
*/
|
|
1076
970
|
type AutomaticEventName = {
|
|
1077
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
971
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "automatic" ? K : never;
|
|
1078
972
|
}[EventName];
|
|
1079
973
|
/**
|
|
1080
974
|
* Event names that consumer code can fire manually after registering them.
|
|
1081
975
|
*/
|
|
1082
976
|
type ManualEventName = {
|
|
1083
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
977
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "manual" ? K : never;
|
|
1084
978
|
}[EventName];
|
|
1085
979
|
type MetadataByName = {
|
|
1086
980
|
page_view: PageViewMetadata;
|
|
@@ -1119,6 +1013,14 @@ type EventMetadata<K extends EventName> = MetadataByName[K];
|
|
|
1119
1013
|
* Trigger registration config type for a specific tracking event.
|
|
1120
1014
|
*/
|
|
1121
1015
|
type EventConfig<K extends EventName> = ConfigByName[K];
|
|
1016
|
+
/**
|
|
1017
|
+
* Runtime list of automatic event names.
|
|
1018
|
+
*/
|
|
1019
|
+
declare const ALL_AUTOMATIC_EVENT_NAMES: readonly AutomaticEventName[];
|
|
1020
|
+
/**
|
|
1021
|
+
* Runtime list of manual event names.
|
|
1022
|
+
*/
|
|
1023
|
+
declare const ALL_MANUAL_EVENT_NAMES: readonly ManualEventName[];
|
|
1122
1024
|
/**
|
|
1123
1025
|
* Trigger registry passed to `createTracking({ triggers })`.
|
|
1124
1026
|
*
|
|
@@ -1146,18 +1048,18 @@ type EventConfig<K extends EventName> = ConfigByName[K];
|
|
|
1146
1048
|
*/
|
|
1147
1049
|
type TriggerRegistryConfig = {
|
|
1148
1050
|
automatic: {
|
|
1149
|
-
page_view: EventConfig<
|
|
1051
|
+
page_view: EventConfig<"page_view">;
|
|
1150
1052
|
} & Partial<{
|
|
1151
|
-
time_on_site: EventConfig<
|
|
1152
|
-
specific_page_visit: EventConfig<
|
|
1153
|
-
scroll_depth: EventConfig<
|
|
1154
|
-
multi_page_session: EventConfig<
|
|
1155
|
-
form_start: EventConfig<
|
|
1053
|
+
time_on_site: EventConfig<"time_on_site">;
|
|
1054
|
+
specific_page_visit: EventConfig<"specific_page_visit">;
|
|
1055
|
+
scroll_depth: EventConfig<"scroll_depth">;
|
|
1056
|
+
multi_page_session: EventConfig<"multi_page_session">;
|
|
1057
|
+
form_start: EventConfig<"form_start">;
|
|
1156
1058
|
}>;
|
|
1157
1059
|
manual?: Partial<{
|
|
1158
|
-
form_submit: EventConfig<
|
|
1159
|
-
phone_click: EventConfig<
|
|
1160
|
-
cta_click: EventConfig<
|
|
1060
|
+
form_submit: EventConfig<"form_submit">;
|
|
1061
|
+
phone_click: EventConfig<"phone_click">;
|
|
1062
|
+
cta_click: EventConfig<"cta_click">;
|
|
1161
1063
|
}>;
|
|
1162
1064
|
};
|
|
1163
1065
|
/**
|
|
@@ -1166,11 +1068,25 @@ type TriggerRegistryConfig = {
|
|
|
1166
1068
|
* Used by `TypedTrackingClient` so `trackEvent()` only accepts events the
|
|
1167
1069
|
* consumer explicitly enabled.
|
|
1168
1070
|
*/
|
|
1169
|
-
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry[
|
|
1071
|
+
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry["manual"]>, ManualEventName>;
|
|
1170
1072
|
/**
|
|
1171
1073
|
* Automatic event names registered in a concrete trigger registry.
|
|
1172
1074
|
*/
|
|
1173
|
-
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry[
|
|
1075
|
+
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry["automatic"], AutomaticEventName>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Discriminated union of valid manual tracking calls for a registry.
|
|
1078
|
+
*/
|
|
1079
|
+
type TrackableEvent<TRegistry extends TriggerRegistryConfig> = {
|
|
1080
|
+
[K in RegisteredManualEvents<TRegistry>]: {
|
|
1081
|
+
eventType: K;
|
|
1082
|
+
metadata: EventMetadata<K>;
|
|
1083
|
+
};
|
|
1084
|
+
}[RegisteredManualEvents<TRegistry>];
|
|
1085
|
+
declare function getEventDefinition(name: EventName): {
|
|
1086
|
+
kind: EventKind;
|
|
1087
|
+
metadataSchema: z.ZodTypeAny;
|
|
1088
|
+
configSchema: z.ZodTypeAny;
|
|
1089
|
+
};
|
|
1174
1090
|
|
|
1175
1091
|
/**
|
|
1176
1092
|
* Input accepted by the low-level stringly-typed client.
|
|
@@ -1248,569 +1164,6 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1248
1164
|
getVisitorId(): string;
|
|
1249
1165
|
}
|
|
1250
1166
|
|
|
1251
|
-
/**
|
|
1252
|
-
* Sales / Conversions wire schemas — the client-side source of truth.
|
|
1253
|
-
*
|
|
1254
|
-
* `saleCreateSchema` is mirrored by `SaleCreateSchema` in
|
|
1255
|
-
* `apps/api/src/schemas/tracking_sales.py` and enforced by the backend drift
|
|
1256
|
-
* test (the `resources` section of `events.schema.json`). Keep them in lockstep.
|
|
1257
|
-
*
|
|
1258
|
-
* Money is **integer minor units (cents)**; `quantity` is a decimal string;
|
|
1259
|
-
* `currency` is the required `SupportedCurrency` enum.
|
|
1260
|
-
*/
|
|
1261
|
-
declare const SUPPORTED_CURRENCIES: readonly ["USD", "CAD"];
|
|
1262
|
-
type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
1263
|
-
declare const TRACKING_ENVIRONMENTS: readonly ["production", "development"];
|
|
1264
|
-
declare const saleItemSchema: z.ZodObject<{
|
|
1265
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1266
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1267
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1268
|
-
quantity: z.ZodString;
|
|
1269
|
-
unit_price_cents: z.ZodNumber;
|
|
1270
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1271
|
-
}, "strict", z.ZodTypeAny, {
|
|
1272
|
-
quantity: string;
|
|
1273
|
-
unit_price_cents: number;
|
|
1274
|
-
name?: string | null | undefined;
|
|
1275
|
-
external_item_id?: string | null | undefined;
|
|
1276
|
-
category?: string | null | undefined;
|
|
1277
|
-
unit_cost_cents?: number | null | undefined;
|
|
1278
|
-
}, {
|
|
1279
|
-
quantity: string;
|
|
1280
|
-
unit_price_cents: number;
|
|
1281
|
-
name?: string | null | undefined;
|
|
1282
|
-
external_item_id?: string | null | undefined;
|
|
1283
|
-
category?: string | null | undefined;
|
|
1284
|
-
unit_cost_cents?: number | null | undefined;
|
|
1285
|
-
}>;
|
|
1286
|
-
declare const saleServiceSchema: z.ZodObject<{
|
|
1287
|
-
service: z.ZodString;
|
|
1288
|
-
amount_cents: z.ZodNumber;
|
|
1289
|
-
}, "strict", z.ZodTypeAny, {
|
|
1290
|
-
service: string;
|
|
1291
|
-
amount_cents: number;
|
|
1292
|
-
}, {
|
|
1293
|
-
service: string;
|
|
1294
|
-
amount_cents: number;
|
|
1295
|
-
}>;
|
|
1296
|
-
declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
1297
|
-
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1298
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1299
|
-
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1300
|
-
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1301
|
-
service: z.ZodString;
|
|
1302
|
-
amount_cents: z.ZodNumber;
|
|
1303
|
-
}, "strict", z.ZodTypeAny, {
|
|
1304
|
-
service: string;
|
|
1305
|
-
amount_cents: number;
|
|
1306
|
-
}, {
|
|
1307
|
-
service: string;
|
|
1308
|
-
amount_cents: number;
|
|
1309
|
-
}>, "many">>>;
|
|
1310
|
-
currency: z.ZodEnum<["USD", "CAD"]>;
|
|
1311
|
-
amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1312
|
-
occurred_at: z.ZodString;
|
|
1313
|
-
environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
|
|
1314
|
-
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1315
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1316
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1317
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1318
|
-
quantity: z.ZodString;
|
|
1319
|
-
unit_price_cents: z.ZodNumber;
|
|
1320
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1321
|
-
}, "strict", z.ZodTypeAny, {
|
|
1322
|
-
quantity: string;
|
|
1323
|
-
unit_price_cents: number;
|
|
1324
|
-
name?: string | null | undefined;
|
|
1325
|
-
external_item_id?: string | null | undefined;
|
|
1326
|
-
category?: string | null | undefined;
|
|
1327
|
-
unit_cost_cents?: number | null | undefined;
|
|
1328
|
-
}, {
|
|
1329
|
-
quantity: string;
|
|
1330
|
-
unit_price_cents: number;
|
|
1331
|
-
name?: string | null | undefined;
|
|
1332
|
-
external_item_id?: string | null | undefined;
|
|
1333
|
-
category?: string | null | undefined;
|
|
1334
|
-
unit_cost_cents?: number | null | undefined;
|
|
1335
|
-
}>, "many">>;
|
|
1336
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1337
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1338
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1339
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1340
|
-
}, "strict", z.ZodTypeAny, {
|
|
1341
|
-
currency: "USD" | "CAD";
|
|
1342
|
-
occurred_at: string;
|
|
1343
|
-
environment: "production" | "development";
|
|
1344
|
-
items: {
|
|
1345
|
-
quantity: string;
|
|
1346
|
-
unit_price_cents: number;
|
|
1347
|
-
name?: string | null | undefined;
|
|
1348
|
-
external_item_id?: string | null | undefined;
|
|
1349
|
-
category?: string | null | undefined;
|
|
1350
|
-
unit_cost_cents?: number | null | undefined;
|
|
1351
|
-
}[];
|
|
1352
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1353
|
-
service?: string | null | undefined;
|
|
1354
|
-
services?: {
|
|
1355
|
-
service: string;
|
|
1356
|
-
amount_cents: number;
|
|
1357
|
-
}[] | null | undefined;
|
|
1358
|
-
amount_total_cents?: number | null | undefined;
|
|
1359
|
-
external_id?: string | null | undefined;
|
|
1360
|
-
description?: string | null | undefined;
|
|
1361
|
-
customer_name?: string | null | undefined;
|
|
1362
|
-
customer_phone?: string | null | undefined;
|
|
1363
|
-
customer_email?: string | null | undefined;
|
|
1364
|
-
}, {
|
|
1365
|
-
currency: "USD" | "CAD";
|
|
1366
|
-
occurred_at: string;
|
|
1367
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1368
|
-
service?: string | null | undefined;
|
|
1369
|
-
services?: {
|
|
1370
|
-
service: string;
|
|
1371
|
-
amount_cents: number;
|
|
1372
|
-
}[] | null | undefined;
|
|
1373
|
-
amount_total_cents?: number | null | undefined;
|
|
1374
|
-
external_id?: string | null | undefined;
|
|
1375
|
-
description?: string | null | undefined;
|
|
1376
|
-
environment?: "production" | "development" | undefined;
|
|
1377
|
-
items?: {
|
|
1378
|
-
quantity: string;
|
|
1379
|
-
unit_price_cents: number;
|
|
1380
|
-
name?: string | null | undefined;
|
|
1381
|
-
external_item_id?: string | null | undefined;
|
|
1382
|
-
category?: string | null | undefined;
|
|
1383
|
-
unit_cost_cents?: number | null | undefined;
|
|
1384
|
-
}[] | undefined;
|
|
1385
|
-
customer_name?: string | null | undefined;
|
|
1386
|
-
customer_phone?: string | null | undefined;
|
|
1387
|
-
customer_email?: string | null | undefined;
|
|
1388
|
-
}>, {
|
|
1389
|
-
currency: "USD" | "CAD";
|
|
1390
|
-
occurred_at: string;
|
|
1391
|
-
environment: "production" | "development";
|
|
1392
|
-
items: {
|
|
1393
|
-
quantity: string;
|
|
1394
|
-
unit_price_cents: number;
|
|
1395
|
-
name?: string | null | undefined;
|
|
1396
|
-
external_item_id?: string | null | undefined;
|
|
1397
|
-
category?: string | null | undefined;
|
|
1398
|
-
unit_cost_cents?: number | null | undefined;
|
|
1399
|
-
}[];
|
|
1400
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1401
|
-
service?: string | null | undefined;
|
|
1402
|
-
services?: {
|
|
1403
|
-
service: string;
|
|
1404
|
-
amount_cents: number;
|
|
1405
|
-
}[] | null | undefined;
|
|
1406
|
-
amount_total_cents?: number | null | undefined;
|
|
1407
|
-
external_id?: string | null | undefined;
|
|
1408
|
-
description?: string | null | undefined;
|
|
1409
|
-
customer_name?: string | null | undefined;
|
|
1410
|
-
customer_phone?: string | null | undefined;
|
|
1411
|
-
customer_email?: string | null | undefined;
|
|
1412
|
-
}, {
|
|
1413
|
-
currency: "USD" | "CAD";
|
|
1414
|
-
occurred_at: string;
|
|
1415
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1416
|
-
service?: string | null | undefined;
|
|
1417
|
-
services?: {
|
|
1418
|
-
service: string;
|
|
1419
|
-
amount_cents: number;
|
|
1420
|
-
}[] | null | undefined;
|
|
1421
|
-
amount_total_cents?: number | null | undefined;
|
|
1422
|
-
external_id?: string | null | undefined;
|
|
1423
|
-
description?: string | null | undefined;
|
|
1424
|
-
environment?: "production" | "development" | undefined;
|
|
1425
|
-
items?: {
|
|
1426
|
-
quantity: string;
|
|
1427
|
-
unit_price_cents: number;
|
|
1428
|
-
name?: string | null | undefined;
|
|
1429
|
-
external_item_id?: string | null | undefined;
|
|
1430
|
-
category?: string | null | undefined;
|
|
1431
|
-
unit_cost_cents?: number | null | undefined;
|
|
1432
|
-
}[] | undefined;
|
|
1433
|
-
customer_name?: string | null | undefined;
|
|
1434
|
-
customer_phone?: string | null | undefined;
|
|
1435
|
-
customer_email?: string | null | undefined;
|
|
1436
|
-
}>;
|
|
1437
|
-
declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
1438
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1439
|
-
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1440
|
-
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1441
|
-
service: z.ZodString;
|
|
1442
|
-
amount_cents: z.ZodNumber;
|
|
1443
|
-
}, "strict", z.ZodTypeAny, {
|
|
1444
|
-
service: string;
|
|
1445
|
-
amount_cents: number;
|
|
1446
|
-
}, {
|
|
1447
|
-
service: string;
|
|
1448
|
-
amount_cents: number;
|
|
1449
|
-
}>, "many">>>;
|
|
1450
|
-
currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
|
|
1451
|
-
amount_total_cents: z.ZodOptional<z.ZodNumber>;
|
|
1452
|
-
occurred_at: z.ZodOptional<z.ZodString>;
|
|
1453
|
-
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1454
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1455
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1456
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1457
|
-
quantity: z.ZodString;
|
|
1458
|
-
unit_price_cents: z.ZodNumber;
|
|
1459
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1460
|
-
}, "strict", z.ZodTypeAny, {
|
|
1461
|
-
quantity: string;
|
|
1462
|
-
unit_price_cents: number;
|
|
1463
|
-
name?: string | null | undefined;
|
|
1464
|
-
external_item_id?: string | null | undefined;
|
|
1465
|
-
category?: string | null | undefined;
|
|
1466
|
-
unit_cost_cents?: number | null | undefined;
|
|
1467
|
-
}, {
|
|
1468
|
-
quantity: string;
|
|
1469
|
-
unit_price_cents: number;
|
|
1470
|
-
name?: string | null | undefined;
|
|
1471
|
-
external_item_id?: string | null | undefined;
|
|
1472
|
-
category?: string | null | undefined;
|
|
1473
|
-
unit_cost_cents?: number | null | undefined;
|
|
1474
|
-
}>, "many">>;
|
|
1475
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1476
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1477
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1478
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1479
|
-
}, "strict", z.ZodTypeAny, {
|
|
1480
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1481
|
-
service?: string | null | undefined;
|
|
1482
|
-
services?: {
|
|
1483
|
-
service: string;
|
|
1484
|
-
amount_cents: number;
|
|
1485
|
-
}[] | null | undefined;
|
|
1486
|
-
amount_total_cents?: number | undefined;
|
|
1487
|
-
description?: string | null | undefined;
|
|
1488
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1489
|
-
occurred_at?: string | undefined;
|
|
1490
|
-
items?: {
|
|
1491
|
-
quantity: string;
|
|
1492
|
-
unit_price_cents: number;
|
|
1493
|
-
name?: string | null | undefined;
|
|
1494
|
-
external_item_id?: string | null | undefined;
|
|
1495
|
-
category?: string | null | undefined;
|
|
1496
|
-
unit_cost_cents?: number | null | undefined;
|
|
1497
|
-
}[] | undefined;
|
|
1498
|
-
customer_name?: string | null | undefined;
|
|
1499
|
-
customer_phone?: string | null | undefined;
|
|
1500
|
-
customer_email?: string | null | undefined;
|
|
1501
|
-
}, {
|
|
1502
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1503
|
-
service?: string | null | undefined;
|
|
1504
|
-
services?: {
|
|
1505
|
-
service: string;
|
|
1506
|
-
amount_cents: number;
|
|
1507
|
-
}[] | null | undefined;
|
|
1508
|
-
amount_total_cents?: number | undefined;
|
|
1509
|
-
description?: string | null | undefined;
|
|
1510
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1511
|
-
occurred_at?: string | undefined;
|
|
1512
|
-
items?: {
|
|
1513
|
-
quantity: string;
|
|
1514
|
-
unit_price_cents: number;
|
|
1515
|
-
name?: string | null | undefined;
|
|
1516
|
-
external_item_id?: string | null | undefined;
|
|
1517
|
-
category?: string | null | undefined;
|
|
1518
|
-
unit_cost_cents?: number | null | undefined;
|
|
1519
|
-
}[] | undefined;
|
|
1520
|
-
customer_name?: string | null | undefined;
|
|
1521
|
-
customer_phone?: string | null | undefined;
|
|
1522
|
-
customer_email?: string | null | undefined;
|
|
1523
|
-
}>, {
|
|
1524
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1525
|
-
service?: string | null | undefined;
|
|
1526
|
-
services?: {
|
|
1527
|
-
service: string;
|
|
1528
|
-
amount_cents: number;
|
|
1529
|
-
}[] | null | undefined;
|
|
1530
|
-
amount_total_cents?: number | undefined;
|
|
1531
|
-
description?: string | null | undefined;
|
|
1532
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1533
|
-
occurred_at?: string | undefined;
|
|
1534
|
-
items?: {
|
|
1535
|
-
quantity: string;
|
|
1536
|
-
unit_price_cents: number;
|
|
1537
|
-
name?: string | null | undefined;
|
|
1538
|
-
external_item_id?: string | null | undefined;
|
|
1539
|
-
category?: string | null | undefined;
|
|
1540
|
-
unit_cost_cents?: number | null | undefined;
|
|
1541
|
-
}[] | undefined;
|
|
1542
|
-
customer_name?: string | null | undefined;
|
|
1543
|
-
customer_phone?: string | null | undefined;
|
|
1544
|
-
customer_email?: string | null | undefined;
|
|
1545
|
-
}, {
|
|
1546
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1547
|
-
service?: string | null | undefined;
|
|
1548
|
-
services?: {
|
|
1549
|
-
service: string;
|
|
1550
|
-
amount_cents: number;
|
|
1551
|
-
}[] | null | undefined;
|
|
1552
|
-
amount_total_cents?: number | undefined;
|
|
1553
|
-
description?: string | null | undefined;
|
|
1554
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1555
|
-
occurred_at?: string | undefined;
|
|
1556
|
-
items?: {
|
|
1557
|
-
quantity: string;
|
|
1558
|
-
unit_price_cents: number;
|
|
1559
|
-
name?: string | null | undefined;
|
|
1560
|
-
external_item_id?: string | null | undefined;
|
|
1561
|
-
category?: string | null | undefined;
|
|
1562
|
-
unit_cost_cents?: number | null | undefined;
|
|
1563
|
-
}[] | undefined;
|
|
1564
|
-
customer_name?: string | null | undefined;
|
|
1565
|
-
customer_phone?: string | null | undefined;
|
|
1566
|
-
customer_email?: string | null | undefined;
|
|
1567
|
-
}>;
|
|
1568
|
-
type SaleItemInput = z.input<typeof saleItemSchema>;
|
|
1569
|
-
type SaleServiceInput = z.input<typeof saleServiceSchema>;
|
|
1570
|
-
type SaleInput = z.input<typeof saleCreateSchema>;
|
|
1571
|
-
type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
|
|
1572
|
-
interface SaleItem {
|
|
1573
|
-
id: string;
|
|
1574
|
-
external_item_id: string | null;
|
|
1575
|
-
name: string | null;
|
|
1576
|
-
category: string | null;
|
|
1577
|
-
quantity: string;
|
|
1578
|
-
unit_price_cents: number;
|
|
1579
|
-
unit_cost_cents: number | null;
|
|
1580
|
-
}
|
|
1581
|
-
interface SaleService {
|
|
1582
|
-
id: string;
|
|
1583
|
-
service_id: string;
|
|
1584
|
-
service_key: string;
|
|
1585
|
-
service_label: string;
|
|
1586
|
-
amount_cents: number;
|
|
1587
|
-
}
|
|
1588
|
-
interface Sale {
|
|
1589
|
-
id: string;
|
|
1590
|
-
business_id: string;
|
|
1591
|
-
business_name?: string | null;
|
|
1592
|
-
external_id: string | null;
|
|
1593
|
-
currency: SupportedCurrency;
|
|
1594
|
-
amount_total_cents: number;
|
|
1595
|
-
description: string | null;
|
|
1596
|
-
service_id: string | null;
|
|
1597
|
-
service_key?: string | null;
|
|
1598
|
-
service_label?: string | null;
|
|
1599
|
-
services: SaleService[];
|
|
1600
|
-
occurred_at: string;
|
|
1601
|
-
environment: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1602
|
-
metadata: Record<string, unknown> | null;
|
|
1603
|
-
customer_name: string | null;
|
|
1604
|
-
customer_phone: string | null;
|
|
1605
|
-
customer_email: string | null;
|
|
1606
|
-
created_at: string;
|
|
1607
|
-
updated_at: string;
|
|
1608
|
-
items: SaleItem[];
|
|
1609
|
-
}
|
|
1610
|
-
interface SaleListPage {
|
|
1611
|
-
items: Sale[];
|
|
1612
|
-
total: number;
|
|
1613
|
-
}
|
|
1614
|
-
interface SaleCursorPage {
|
|
1615
|
-
items: Sale[];
|
|
1616
|
-
next_cursor: string | null;
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
|
|
1620
|
-
*
|
|
1621
|
-
* `search` runs case-insensitively across `customer_name`, `customer_phone`,
|
|
1622
|
-
* `customer_email`, `description`, and `external_id` — the human-facing
|
|
1623
|
-
* columns. `service_id` is the resolved per-business service UUID (different
|
|
1624
|
-
* from the create-time `service` *key*).
|
|
1625
|
-
*/
|
|
1626
|
-
interface SaleFilters {
|
|
1627
|
-
business_id?: string;
|
|
1628
|
-
external_id?: string;
|
|
1629
|
-
service_id?: string;
|
|
1630
|
-
currency?: SupportedCurrency;
|
|
1631
|
-
environment?: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1632
|
-
since?: string;
|
|
1633
|
-
until?: string;
|
|
1634
|
-
min_amount_cents?: number;
|
|
1635
|
-
max_amount_cents?: number;
|
|
1636
|
-
search?: string;
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Full query input for `SalesClient.list()` — filters + pagination.
|
|
1640
|
-
*
|
|
1641
|
-
* Pagination is **keyset (cursor)**: `next_cursor` returned by one page is
|
|
1642
|
-
* passed back as `cursor` on the next. `null` / undefined cursor = first page.
|
|
1643
|
-
*
|
|
1644
|
-
* Ordering on this endpoint is fixed at **`occurred_at DESC, id DESC`** — the
|
|
1645
|
-
* cursor encodes a position in that index, so a different sort would
|
|
1646
|
-
* invalidate cursors mid-pagination. For ad-hoc sorted reads use the
|
|
1647
|
-
* dashboard admin endpoint, which is offset-paginated.
|
|
1648
|
-
*/
|
|
1649
|
-
interface SaleListQuery extends SaleFilters {
|
|
1650
|
-
limit?: number;
|
|
1651
|
-
cursor?: string | null;
|
|
1652
|
-
}
|
|
1653
|
-
declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
|
|
1654
|
-
type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
|
|
1655
|
-
/** Query input for `SalesClient.summary()` — filters + range + options. */
|
|
1656
|
-
interface SaleSummaryQuery extends SaleFilters {
|
|
1657
|
-
range: TrackingOverviewRange;
|
|
1658
|
-
/** Include the per-category line-item breakdown (extra join; default false). */
|
|
1659
|
-
include_categories?: boolean;
|
|
1660
|
-
/** Surface soft-deleted services individually (flagged "(deleted)") instead of
|
|
1661
|
-
* rolling them into a single "Deleted services" bucket. Default false. */
|
|
1662
|
-
include_deleted_services?: boolean;
|
|
1663
|
-
/** Cap on the by-service / by-category rows (1–50, default 10). */
|
|
1664
|
-
top_n?: number;
|
|
1665
|
-
}
|
|
1666
|
-
interface CurrencyRevenue {
|
|
1667
|
-
currency: SupportedCurrency;
|
|
1668
|
-
sale_count: number;
|
|
1669
|
-
revenue_cents: number;
|
|
1670
|
-
average_order_value_cents: number;
|
|
1671
|
-
}
|
|
1672
|
-
interface SalesServiceBreakdown {
|
|
1673
|
-
service_id: string | null;
|
|
1674
|
-
service_key: string | null;
|
|
1675
|
-
/** "Unassigned" when the sale has no service. */
|
|
1676
|
-
service_label: string | null;
|
|
1677
|
-
currency: SupportedCurrency;
|
|
1678
|
-
sale_count: number;
|
|
1679
|
-
revenue_cents: number;
|
|
1680
|
-
}
|
|
1681
|
-
interface SalesCategoryBreakdown {
|
|
1682
|
-
category: string | null;
|
|
1683
|
-
currency: SupportedCurrency;
|
|
1684
|
-
/** sum(unit_price_cents * quantity) — advisory, not authoritative. */
|
|
1685
|
-
revenue_cents: number;
|
|
1686
|
-
/** Decimal string. */
|
|
1687
|
-
quantity: string;
|
|
1688
|
-
}
|
|
1689
|
-
interface SalesTrendPoint {
|
|
1690
|
-
bucket_start: string;
|
|
1691
|
-
currency: SupportedCurrency;
|
|
1692
|
-
sale_count: number;
|
|
1693
|
-
revenue_cents: number;
|
|
1694
|
-
}
|
|
1695
|
-
interface SaleSummary {
|
|
1696
|
-
range: TrackingOverviewRange;
|
|
1697
|
-
business_id: string | null;
|
|
1698
|
-
metrics: {
|
|
1699
|
-
sale_count: number;
|
|
1700
|
-
distinct_customers: number;
|
|
1701
|
-
by_currency: CurrencyRevenue[];
|
|
1702
|
-
};
|
|
1703
|
-
by_service: SalesServiceBreakdown[];
|
|
1704
|
-
by_currency: CurrencyRevenue[];
|
|
1705
|
-
by_category: SalesCategoryBreakdown[];
|
|
1706
|
-
series: SalesTrendPoint[];
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
/** Shared config for every sales HTTP helper. */
|
|
1710
|
-
interface SalesTransportConfig {
|
|
1711
|
-
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
1712
|
-
apiKey: string;
|
|
1713
|
-
/**
|
|
1714
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
1715
|
-
* The `/sales` path is appended by the helpers.
|
|
1716
|
-
*/
|
|
1717
|
-
endpoint: string;
|
|
1718
|
-
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
1719
|
-
sdkVersion?: string;
|
|
1720
|
-
packageName?: string;
|
|
1721
|
-
surface?: string;
|
|
1722
|
-
environment?: string;
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
/** Config for {@link createSalesClient}. */
|
|
1726
|
-
interface SalesClientConfig extends SalesTransportConfig {
|
|
1727
|
-
/** Applied when an individual `record()` call omits `currency`. */
|
|
1728
|
-
defaultCurrency?: SupportedCurrency;
|
|
1729
|
-
}
|
|
1730
|
-
/**
|
|
1731
|
-
* One isomorphic sales client — what a key may *do* is enforced by the backend,
|
|
1732
|
-
* not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
|
|
1733
|
-
* backend rejects reads/CRUD from it with a `403`); a **secret** key
|
|
1734
|
-
* (`aranv_sk_…`), used **server-side only**, gets full read/list/update/delete.
|
|
1735
|
-
* Never ship a secret key in a browser bundle.
|
|
1736
|
-
*
|
|
1737
|
-
* Generic over the service-key union `TService`: bind the type emitted by
|
|
1738
|
-
* `@aranova/tracking-cli gen` for compile-time-checked `service` values.
|
|
1739
|
-
*/
|
|
1740
|
-
interface SalesClient<TService extends string = string> {
|
|
1741
|
-
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
|
|
1742
|
-
service?: TService | null;
|
|
1743
|
-
services?: Array<{
|
|
1744
|
-
service: TService;
|
|
1745
|
-
amount_cents: number;
|
|
1746
|
-
}>;
|
|
1747
|
-
currency?: SupportedCurrency;
|
|
1748
|
-
occurred_at?: string;
|
|
1749
|
-
}): Promise<Sale>;
|
|
1750
|
-
list(query?: SaleListQuery): Promise<SaleCursorPage>;
|
|
1751
|
-
/**
|
|
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`.
|
|
1755
|
-
*/
|
|
1756
|
-
summary(query: SaleSummaryQuery): Promise<SaleSummary>;
|
|
1757
|
-
get(id: string): Promise<Sale>;
|
|
1758
|
-
update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
|
|
1759
|
-
service?: TService | null;
|
|
1760
|
-
services?: Array<{
|
|
1761
|
-
service: TService;
|
|
1762
|
-
amount_cents: number;
|
|
1763
|
-
}>;
|
|
1764
|
-
}): Promise<Sale>;
|
|
1765
|
-
delete(id: string): Promise<void>;
|
|
1766
|
-
}
|
|
1767
|
-
declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
|
|
1768
|
-
|
|
1769
|
-
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
1770
|
-
interface PublicServiceItem {
|
|
1771
|
-
key: string;
|
|
1772
|
-
label: string;
|
|
1773
|
-
}
|
|
1774
|
-
/**
|
|
1775
|
-
* Fetch the caller's business's active service taxonomy. Accepts a public or
|
|
1776
|
-
* secret key (the taxonomy is low-sensitivity category names). Powers the
|
|
1777
|
-
* `@aranova/tracking-cli gen` codegen.
|
|
1778
|
-
*/
|
|
1779
|
-
declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
|
|
1780
|
-
|
|
1781
|
-
/**
|
|
1782
|
-
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
1783
|
-
*
|
|
1784
|
-
* Convenience only — the wire is always integer cents. Uses float multiply +
|
|
1785
|
-
* `Math.round`, so values that aren't exactly representable in binary float
|
|
1786
|
-
* (e.g. `1.005`) can round to the neighbouring cent. If you already hold an
|
|
1787
|
-
* exact cents integer, pass it straight through and skip this helper.
|
|
1788
|
-
*/
|
|
1789
|
-
declare function toMinor(amount: number, currency: SupportedCurrency): number;
|
|
1790
|
-
/** Convert integer minor units (`25050`) to a major amount (`250.5`). */
|
|
1791
|
-
declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
1792
|
-
/**
|
|
1793
|
-
* Format integer minor units as a localized currency string (e.g. `"$250.50"`).
|
|
1794
|
-
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
1795
|
-
*/
|
|
1796
|
-
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
1797
|
-
|
|
1798
|
-
/**
|
|
1799
|
-
* Error thrown by the sales client (`createSalesClient`) on a
|
|
1800
|
-
* non-2xx response. Unlike the fire-and-forget event queue (which swallows
|
|
1801
|
-
* failures), a sale is a transaction the caller must be able to react to.
|
|
1802
|
-
*/
|
|
1803
|
-
declare class AranovaApiError extends Error {
|
|
1804
|
-
readonly status: number;
|
|
1805
|
-
readonly code: string | undefined;
|
|
1806
|
-
readonly requestId: string | undefined;
|
|
1807
|
-
constructor(message: string, options: {
|
|
1808
|
-
status: number;
|
|
1809
|
-
code?: string;
|
|
1810
|
-
requestId?: string;
|
|
1811
|
-
});
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
1167
|
/**
|
|
1815
1168
|
* Default non-blocking consent banner.
|
|
1816
1169
|
*
|
|
@@ -1864,11 +1217,11 @@ interface ConsentBannerProps {
|
|
|
1864
1217
|
onAccept?: () => void;
|
|
1865
1218
|
onDecline?: () => void;
|
|
1866
1219
|
/** Where the banner docks. Default: `"bottom"`. */
|
|
1867
|
-
position?:
|
|
1220
|
+
position?: "top" | "bottom";
|
|
1868
1221
|
/**
|
|
1869
1222
|
* Visual theme. `"auto"` follows `prefers-color-scheme`. Default: `"light"`.
|
|
1870
1223
|
*/
|
|
1871
|
-
theme?:
|
|
1224
|
+
theme?: "light" | "dark" | "auto";
|
|
1872
1225
|
/** Class added to the outer wrapper for additional styling hooks. */
|
|
1873
1226
|
className?: string;
|
|
1874
1227
|
/** Inline style overrides applied to the outer wrapper after the defaults. */
|
|
@@ -1988,6 +1341,11 @@ interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
|
|
|
1988
1341
|
* analytics can never throw into the host app.
|
|
1989
1342
|
*/
|
|
1990
1343
|
debug?: boolean;
|
|
1344
|
+
/**
|
|
1345
|
+
* Phone-field display + default-country config, read by `usePhoneField` /
|
|
1346
|
+
* `<PhoneField>`. Display is customizable; the transmitted value is always E.164.
|
|
1347
|
+
*/
|
|
1348
|
+
phone?: PhoneConfig;
|
|
1991
1349
|
}
|
|
1992
1350
|
interface TrackingProviderProps {
|
|
1993
1351
|
/**
|
|
@@ -2019,4 +1377,61 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
|
|
|
2019
1377
|
*/
|
|
2020
1378
|
declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
|
|
2021
1379
|
|
|
2022
|
-
|
|
1380
|
+
/** Resolve the effective phone config (provider value or built-in defaults). */
|
|
1381
|
+
declare function usePhoneConfig(): {
|
|
1382
|
+
defaultCountry: CountryCode;
|
|
1383
|
+
display: PhoneDisplayFormat;
|
|
1384
|
+
};
|
|
1385
|
+
interface UsePhoneFieldOptions {
|
|
1386
|
+
defaultValue?: string;
|
|
1387
|
+
/** Overrides the provider's `defaultCountry`. */
|
|
1388
|
+
country?: CountryCode;
|
|
1389
|
+
/** Overrides the provider's `display` (applied to the settled value on blur). */
|
|
1390
|
+
display?: PhoneDisplayFormat;
|
|
1391
|
+
/** Notified with the canonical E.164 (or `null`) on every change. */
|
|
1392
|
+
onValueChange?: (e164: string | null) => void;
|
|
1393
|
+
}
|
|
1394
|
+
interface PhoneInputProps {
|
|
1395
|
+
value: string;
|
|
1396
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
1397
|
+
onBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
1398
|
+
type: "tel";
|
|
1399
|
+
inputMode: "tel";
|
|
1400
|
+
autoComplete: "tel";
|
|
1401
|
+
}
|
|
1402
|
+
interface PhoneFieldApi {
|
|
1403
|
+
/** Display value for the `<input>` (live `AsYouType` while typing). */
|
|
1404
|
+
value: string;
|
|
1405
|
+
/** Canonical E.164 — what gets transmitted. `null` while invalid/incomplete. */
|
|
1406
|
+
e164: string | null;
|
|
1407
|
+
isValid: boolean;
|
|
1408
|
+
/** Validation message, surfaced only after blur with non-empty invalid input. */
|
|
1409
|
+
error: string | null;
|
|
1410
|
+
parsed: ParsedPhone;
|
|
1411
|
+
/** Spread onto an `<input>`: pre-wires value/onChange/onBlur/type/inputMode/autoComplete. */
|
|
1412
|
+
inputProps: PhoneInputProps;
|
|
1413
|
+
}
|
|
1414
|
+
/** Headless phone field — the client owns the markup. */
|
|
1415
|
+
declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
|
|
1416
|
+
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> {
|
|
1417
|
+
country?: CountryCode;
|
|
1418
|
+
/** Controlled display value. */
|
|
1419
|
+
value?: string;
|
|
1420
|
+
/** Uncontrolled initial value. */
|
|
1421
|
+
defaultValue?: string;
|
|
1422
|
+
/** Receives the native change event (RHF `register().onChange` or your own); the
|
|
1423
|
+
* event's `target.value` is already `AsYouType`-formatted. */
|
|
1424
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
1425
|
+
/** Receives the canonical E.164 (or `null`) on every change. */
|
|
1426
|
+
onE164Change?: (e164: string | null) => void;
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Batteries-included phone input. Composes identically with react-hook-form
|
|
1430
|
+
* `{...register('phone')}` and with controlled state — the `AsYouType` +
|
|
1431
|
+
* mutate-`e.target.value`-before-`onChange` technique lives inside, so RHF and
|
|
1432
|
+
* controlled parents both receive the formatted value, and the wire value stays
|
|
1433
|
+
* E.164.
|
|
1434
|
+
*/
|
|
1435
|
+
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
1436
|
+
|
|
1437
|
+
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 };
|