@aranova/tracking-next 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -32
- package/dist/index.d.mts +469 -158
- package/dist/index.d.ts +469 -158
- package/dist/index.js +240 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -14
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.js +3 -0
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +3 -0
- package/dist/middleware.mjs.map +1 -1
- package/dist/phone-utils-DZ0Ger64.d.mts +343 -0
- package/dist/phone-utils-DZ0Ger64.d.ts +343 -0
- package/dist/phone.d.mts +3 -0
- package/dist/phone.d.ts +3 -0
- package/dist/phone.js +318 -0
- package/dist/phone.js.map +1 -0
- package/dist/phone.mjs +286 -0
- package/dist/phone.mjs.map +1 -0
- package/dist/server.d.mts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +9 -1
- package/dist/types-BPJLgMsG.d.mts +0 -161
- package/dist/types-BPJLgMsG.d.ts +0 -161
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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-DZ0Ger64.js';
|
|
2
|
+
export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formatPhone, l as formatPhoneAsTyped, p as parsePhone, m as phoneField, t as toE164 } from './phone-utils-DZ0Ger64.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as src from 'src';
|
|
5
|
-
import
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
|
|
6
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
9
|
+
export { CountryCode } from 'libphonenumber-js';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
@@ -234,131 +237,6 @@ declare const formStartConfigSchema: z.ZodObject<{
|
|
|
234
237
|
}>;
|
|
235
238
|
type FormStartConfig = z.infer<typeof formStartConfigSchema>;
|
|
236
239
|
|
|
237
|
-
/**
|
|
238
|
-
* JSON-serializable value accepted by `form_submit.fields[].value`.
|
|
239
|
-
*
|
|
240
|
-
* This intentionally excludes `undefined`, functions, symbols, `Date`
|
|
241
|
-
* instances, and non-finite numbers. Values are stored in PostgreSQL JSONB, so
|
|
242
|
-
* consumers should send only data that has a stable JSON representation.
|
|
243
|
-
*/
|
|
244
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
245
|
-
[key: string]: JsonValue;
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* Metadata for a manually fired `form_submit` event.
|
|
249
|
-
*
|
|
250
|
-
* Register the event with `manual: { form_submit: {} }`, then call
|
|
251
|
-
* `trackEvent('form_submit', metadata)` from the host site's submit handler.
|
|
252
|
-
*
|
|
253
|
-
* `fields` is optional. If present, each field value must be JSON-serializable
|
|
254
|
-
* and should be explicitly allowlisted by the integration. Do not send names,
|
|
255
|
-
* emails, visitor phone numbers, addresses, payment data, medical details,
|
|
256
|
-
* passwords, file contents, or free-text messages.
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* tracking.trackEvent('form_submit', {
|
|
261
|
-
* form: {
|
|
262
|
-
* id: 'lead-form',
|
|
263
|
-
* action: '/api/lead',
|
|
264
|
-
* fields: [
|
|
265
|
-
* {
|
|
266
|
-
* name: 'service_interest',
|
|
267
|
-
* type: 'select',
|
|
268
|
-
* label: 'Service interest',
|
|
269
|
-
* value: 'teeth_whitening',
|
|
270
|
-
* },
|
|
271
|
-
* ],
|
|
272
|
-
* },
|
|
273
|
-
* page: { path: window.location.pathname },
|
|
274
|
-
* });
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
declare const formSubmitMetadataSchema: z.ZodObject<{
|
|
278
|
-
form: z.ZodObject<{
|
|
279
|
-
id: z.ZodString;
|
|
280
|
-
action: z.ZodNullable<z.ZodString>;
|
|
281
|
-
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
282
|
-
name: z.ZodString;
|
|
283
|
-
type: z.ZodString;
|
|
284
|
-
label: z.ZodNullable<z.ZodString>;
|
|
285
|
-
value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
|
|
286
|
-
}, "strict", z.ZodTypeAny, {
|
|
287
|
-
label: string | null;
|
|
288
|
-
value: JsonValue;
|
|
289
|
-
type: string;
|
|
290
|
-
name: string;
|
|
291
|
-
}, {
|
|
292
|
-
label: string | null;
|
|
293
|
-
value: JsonValue;
|
|
294
|
-
type: string;
|
|
295
|
-
name: string;
|
|
296
|
-
}>, "many">>;
|
|
297
|
-
}, "strict", z.ZodTypeAny, {
|
|
298
|
-
id: string;
|
|
299
|
-
action: string | null;
|
|
300
|
-
fields?: {
|
|
301
|
-
label: string | null;
|
|
302
|
-
value: JsonValue;
|
|
303
|
-
type: string;
|
|
304
|
-
name: string;
|
|
305
|
-
}[] | undefined;
|
|
306
|
-
}, {
|
|
307
|
-
id: string;
|
|
308
|
-
action: string | null;
|
|
309
|
-
fields?: {
|
|
310
|
-
label: string | null;
|
|
311
|
-
value: JsonValue;
|
|
312
|
-
type: string;
|
|
313
|
-
name: string;
|
|
314
|
-
}[] | undefined;
|
|
315
|
-
}>;
|
|
316
|
-
page: z.ZodObject<{
|
|
317
|
-
path: z.ZodString;
|
|
318
|
-
}, "strict", z.ZodTypeAny, {
|
|
319
|
-
path: string;
|
|
320
|
-
}, {
|
|
321
|
-
path: string;
|
|
322
|
-
}>;
|
|
323
|
-
}, "strict", z.ZodTypeAny, {
|
|
324
|
-
form: {
|
|
325
|
-
id: string;
|
|
326
|
-
action: string | null;
|
|
327
|
-
fields?: {
|
|
328
|
-
label: string | null;
|
|
329
|
-
value: JsonValue;
|
|
330
|
-
type: string;
|
|
331
|
-
name: string;
|
|
332
|
-
}[] | undefined;
|
|
333
|
-
};
|
|
334
|
-
page: {
|
|
335
|
-
path: string;
|
|
336
|
-
};
|
|
337
|
-
}, {
|
|
338
|
-
form: {
|
|
339
|
-
id: string;
|
|
340
|
-
action: string | null;
|
|
341
|
-
fields?: {
|
|
342
|
-
label: string | null;
|
|
343
|
-
value: JsonValue;
|
|
344
|
-
type: string;
|
|
345
|
-
name: string;
|
|
346
|
-
}[] | undefined;
|
|
347
|
-
};
|
|
348
|
-
page: {
|
|
349
|
-
path: string;
|
|
350
|
-
};
|
|
351
|
-
}>;
|
|
352
|
-
type FormSubmitMetadata = z.infer<typeof formSubmitMetadataSchema>;
|
|
353
|
-
/**
|
|
354
|
-
* Registration config for `form_submit`.
|
|
355
|
-
*
|
|
356
|
-
* This event is manual-only and currently has no registration options. The
|
|
357
|
-
* empty object enables typed `trackEvent('form_submit', ...)` calls.
|
|
358
|
-
*/
|
|
359
|
-
declare const formSubmitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
360
|
-
type FormSubmitConfig = z.infer<typeof formSubmitConfigSchema>;
|
|
361
|
-
|
|
362
240
|
/**
|
|
363
241
|
* Metadata for the automatic `multi_page_session` event.
|
|
364
242
|
*
|
|
@@ -412,14 +290,14 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
412
290
|
search: z.ZodString;
|
|
413
291
|
hash: z.ZodString;
|
|
414
292
|
}, "strict", z.ZodTypeAny, {
|
|
293
|
+
path: string;
|
|
415
294
|
search: string;
|
|
416
295
|
title: string | null;
|
|
417
|
-
path: string;
|
|
418
296
|
hash: string;
|
|
419
297
|
}, {
|
|
298
|
+
path: string;
|
|
420
299
|
search: string;
|
|
421
300
|
title: string | null;
|
|
422
|
-
path: string;
|
|
423
301
|
hash: string;
|
|
424
302
|
}>;
|
|
425
303
|
referrer: z.ZodNullable<z.ZodString>;
|
|
@@ -435,9 +313,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
435
313
|
}>>>;
|
|
436
314
|
}, "strict", z.ZodTypeAny, {
|
|
437
315
|
page: {
|
|
316
|
+
path: string;
|
|
438
317
|
search: string;
|
|
439
318
|
title: string | null;
|
|
440
|
-
path: string;
|
|
441
319
|
hash: string;
|
|
442
320
|
};
|
|
443
321
|
referrer: string | null;
|
|
@@ -447,9 +325,9 @@ declare const pageViewMetadataSchema: z.ZodObject<{
|
|
|
447
325
|
} | null | undefined;
|
|
448
326
|
}, {
|
|
449
327
|
page: {
|
|
328
|
+
path: string;
|
|
450
329
|
search: string;
|
|
451
330
|
title: string | null;
|
|
452
|
-
path: string;
|
|
453
331
|
hash: string;
|
|
454
332
|
};
|
|
455
333
|
referrer: string | null;
|
|
@@ -658,14 +536,14 @@ declare const EVENT_REGISTRY: {
|
|
|
658
536
|
search: z.ZodString;
|
|
659
537
|
hash: z.ZodString;
|
|
660
538
|
}, "strict", z.ZodTypeAny, {
|
|
539
|
+
path: string;
|
|
661
540
|
search: string;
|
|
662
541
|
title: string | null;
|
|
663
|
-
path: string;
|
|
664
542
|
hash: string;
|
|
665
543
|
}, {
|
|
544
|
+
path: string;
|
|
666
545
|
search: string;
|
|
667
546
|
title: string | null;
|
|
668
|
-
path: string;
|
|
669
547
|
hash: string;
|
|
670
548
|
}>;
|
|
671
549
|
referrer: z.ZodNullable<z.ZodString>;
|
|
@@ -681,9 +559,9 @@ declare const EVENT_REGISTRY: {
|
|
|
681
559
|
}>>>;
|
|
682
560
|
}, "strict", z.ZodTypeAny, {
|
|
683
561
|
page: {
|
|
562
|
+
path: string;
|
|
684
563
|
search: string;
|
|
685
564
|
title: string | null;
|
|
686
|
-
path: string;
|
|
687
565
|
hash: string;
|
|
688
566
|
};
|
|
689
567
|
referrer: string | null;
|
|
@@ -693,9 +571,9 @@ declare const EVENT_REGISTRY: {
|
|
|
693
571
|
} | null | undefined;
|
|
694
572
|
}, {
|
|
695
573
|
page: {
|
|
574
|
+
path: string;
|
|
696
575
|
search: string;
|
|
697
576
|
title: string | null;
|
|
698
|
-
path: string;
|
|
699
577
|
hash: string;
|
|
700
578
|
};
|
|
701
579
|
referrer: string | null;
|
|
@@ -939,33 +817,33 @@ declare const EVENT_REGISTRY: {
|
|
|
939
817
|
label: z.ZodNullable<z.ZodString>;
|
|
940
818
|
value: z.ZodType<src.JsonValue, z.ZodTypeDef, src.JsonValue>;
|
|
941
819
|
}, "strict", z.ZodTypeAny, {
|
|
942
|
-
label: string | null;
|
|
943
820
|
value: src.JsonValue;
|
|
944
821
|
type: string;
|
|
945
822
|
name: string;
|
|
946
|
-
}, {
|
|
947
823
|
label: string | null;
|
|
824
|
+
}, {
|
|
948
825
|
value: src.JsonValue;
|
|
949
826
|
type: string;
|
|
950
827
|
name: string;
|
|
828
|
+
label: string | null;
|
|
951
829
|
}>, "many">>;
|
|
952
830
|
}, "strict", z.ZodTypeAny, {
|
|
953
831
|
id: string;
|
|
954
832
|
action: string | null;
|
|
955
833
|
fields?: {
|
|
956
|
-
label: string | null;
|
|
957
834
|
value: src.JsonValue;
|
|
958
835
|
type: string;
|
|
959
836
|
name: string;
|
|
837
|
+
label: string | null;
|
|
960
838
|
}[] | undefined;
|
|
961
839
|
}, {
|
|
962
840
|
id: string;
|
|
963
841
|
action: string | null;
|
|
964
842
|
fields?: {
|
|
965
|
-
label: string | null;
|
|
966
843
|
value: src.JsonValue;
|
|
967
844
|
type: string;
|
|
968
845
|
name: string;
|
|
846
|
+
label: string | null;
|
|
969
847
|
}[] | undefined;
|
|
970
848
|
}>;
|
|
971
849
|
page: z.ZodObject<{
|
|
@@ -980,10 +858,10 @@ declare const EVENT_REGISTRY: {
|
|
|
980
858
|
id: string;
|
|
981
859
|
action: string | null;
|
|
982
860
|
fields?: {
|
|
983
|
-
label: string | null;
|
|
984
861
|
value: src.JsonValue;
|
|
985
862
|
type: string;
|
|
986
863
|
name: string;
|
|
864
|
+
label: string | null;
|
|
987
865
|
}[] | undefined;
|
|
988
866
|
};
|
|
989
867
|
page: {
|
|
@@ -994,10 +872,10 @@ declare const EVENT_REGISTRY: {
|
|
|
994
872
|
id: string;
|
|
995
873
|
action: string | null;
|
|
996
874
|
fields?: {
|
|
997
|
-
label: string | null;
|
|
998
875
|
value: src.JsonValue;
|
|
999
876
|
type: string;
|
|
1000
877
|
name: string;
|
|
878
|
+
label: string | null;
|
|
1001
879
|
}[] | undefined;
|
|
1002
880
|
};
|
|
1003
881
|
page: {
|
|
@@ -1283,12 +1161,32 @@ declare const saleItemSchema: z.ZodObject<{
|
|
|
1283
1161
|
category?: string | null | undefined;
|
|
1284
1162
|
unit_cost_cents?: number | null | undefined;
|
|
1285
1163
|
}>;
|
|
1286
|
-
declare const
|
|
1164
|
+
declare const saleServiceSchema: z.ZodObject<{
|
|
1165
|
+
service: z.ZodString;
|
|
1166
|
+
amount_cents: z.ZodNumber;
|
|
1167
|
+
}, "strict", z.ZodTypeAny, {
|
|
1168
|
+
service: string;
|
|
1169
|
+
amount_cents: number;
|
|
1170
|
+
}, {
|
|
1171
|
+
service: string;
|
|
1172
|
+
amount_cents: number;
|
|
1173
|
+
}>;
|
|
1174
|
+
declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
1287
1175
|
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1288
1176
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1289
1177
|
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1178
|
+
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1179
|
+
service: z.ZodString;
|
|
1180
|
+
amount_cents: z.ZodNumber;
|
|
1181
|
+
}, "strict", z.ZodTypeAny, {
|
|
1182
|
+
service: string;
|
|
1183
|
+
amount_cents: number;
|
|
1184
|
+
}, {
|
|
1185
|
+
service: string;
|
|
1186
|
+
amount_cents: number;
|
|
1187
|
+
}>, "many">>>;
|
|
1290
1188
|
currency: z.ZodEnum<["USD", "CAD"]>;
|
|
1291
|
-
amount_total_cents: z.ZodNumber
|
|
1189
|
+
amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1292
1190
|
occurred_at: z.ZodString;
|
|
1293
1191
|
environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
|
|
1294
1192
|
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -1319,7 +1217,6 @@ declare const saleCreateSchema: z.ZodObject<{
|
|
|
1319
1217
|
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1320
1218
|
}, "strict", z.ZodTypeAny, {
|
|
1321
1219
|
currency: "USD" | "CAD";
|
|
1322
|
-
amount_total_cents: number;
|
|
1323
1220
|
occurred_at: string;
|
|
1324
1221
|
environment: "production" | "development";
|
|
1325
1222
|
items: {
|
|
@@ -1331,20 +1228,77 @@ declare const saleCreateSchema: z.ZodObject<{
|
|
|
1331
1228
|
unit_cost_cents?: number | null | undefined;
|
|
1332
1229
|
}[];
|
|
1333
1230
|
metadata?: Record<string, unknown> | null | undefined;
|
|
1231
|
+
service?: string | null | undefined;
|
|
1232
|
+
services?: {
|
|
1233
|
+
service: string;
|
|
1234
|
+
amount_cents: number;
|
|
1235
|
+
}[] | null | undefined;
|
|
1236
|
+
amount_total_cents?: number | null | undefined;
|
|
1334
1237
|
external_id?: string | null | undefined;
|
|
1335
1238
|
description?: string | null | undefined;
|
|
1336
|
-
service?: string | null | undefined;
|
|
1337
1239
|
customer_name?: string | null | undefined;
|
|
1338
1240
|
customer_phone?: string | null | undefined;
|
|
1339
1241
|
customer_email?: string | null | undefined;
|
|
1340
1242
|
}, {
|
|
1341
1243
|
currency: "USD" | "CAD";
|
|
1342
|
-
amount_total_cents: number;
|
|
1343
1244
|
occurred_at: string;
|
|
1344
1245
|
metadata?: Record<string, unknown> | null | undefined;
|
|
1246
|
+
service?: string | null | undefined;
|
|
1247
|
+
services?: {
|
|
1248
|
+
service: string;
|
|
1249
|
+
amount_cents: number;
|
|
1250
|
+
}[] | null | undefined;
|
|
1251
|
+
amount_total_cents?: number | null | undefined;
|
|
1252
|
+
external_id?: string | null | undefined;
|
|
1253
|
+
description?: string | null | undefined;
|
|
1254
|
+
environment?: "production" | "development" | undefined;
|
|
1255
|
+
items?: {
|
|
1256
|
+
quantity: string;
|
|
1257
|
+
unit_price_cents: number;
|
|
1258
|
+
name?: string | null | undefined;
|
|
1259
|
+
external_item_id?: string | null | undefined;
|
|
1260
|
+
category?: string | null | undefined;
|
|
1261
|
+
unit_cost_cents?: number | null | undefined;
|
|
1262
|
+
}[] | undefined;
|
|
1263
|
+
customer_name?: string | null | undefined;
|
|
1264
|
+
customer_phone?: string | null | undefined;
|
|
1265
|
+
customer_email?: string | null | undefined;
|
|
1266
|
+
}>, {
|
|
1267
|
+
currency: "USD" | "CAD";
|
|
1268
|
+
occurred_at: string;
|
|
1269
|
+
environment: "production" | "development";
|
|
1270
|
+
items: {
|
|
1271
|
+
quantity: string;
|
|
1272
|
+
unit_price_cents: number;
|
|
1273
|
+
name?: string | null | undefined;
|
|
1274
|
+
external_item_id?: string | null | undefined;
|
|
1275
|
+
category?: string | null | undefined;
|
|
1276
|
+
unit_cost_cents?: number | null | undefined;
|
|
1277
|
+
}[];
|
|
1278
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1279
|
+
service?: string | null | undefined;
|
|
1280
|
+
services?: {
|
|
1281
|
+
service: string;
|
|
1282
|
+
amount_cents: number;
|
|
1283
|
+
}[] | null | undefined;
|
|
1284
|
+
amount_total_cents?: number | null | undefined;
|
|
1345
1285
|
external_id?: string | null | undefined;
|
|
1346
1286
|
description?: string | null | undefined;
|
|
1287
|
+
customer_name?: string | null | undefined;
|
|
1288
|
+
customer_phone?: string | null | undefined;
|
|
1289
|
+
customer_email?: string | null | undefined;
|
|
1290
|
+
}, {
|
|
1291
|
+
currency: "USD" | "CAD";
|
|
1292
|
+
occurred_at: string;
|
|
1293
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1347
1294
|
service?: string | null | undefined;
|
|
1295
|
+
services?: {
|
|
1296
|
+
service: string;
|
|
1297
|
+
amount_cents: number;
|
|
1298
|
+
}[] | null | undefined;
|
|
1299
|
+
amount_total_cents?: number | null | undefined;
|
|
1300
|
+
external_id?: string | null | undefined;
|
|
1301
|
+
description?: string | null | undefined;
|
|
1348
1302
|
environment?: "production" | "development" | undefined;
|
|
1349
1303
|
items?: {
|
|
1350
1304
|
quantity: string;
|
|
@@ -1358,9 +1312,19 @@ declare const saleCreateSchema: z.ZodObject<{
|
|
|
1358
1312
|
customer_phone?: string | null | undefined;
|
|
1359
1313
|
customer_email?: string | null | undefined;
|
|
1360
1314
|
}>;
|
|
1361
|
-
declare const saleUpdateSchema: z.ZodObject<{
|
|
1315
|
+
declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
1362
1316
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1363
1317
|
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1318
|
+
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1319
|
+
service: z.ZodString;
|
|
1320
|
+
amount_cents: z.ZodNumber;
|
|
1321
|
+
}, "strict", z.ZodTypeAny, {
|
|
1322
|
+
service: string;
|
|
1323
|
+
amount_cents: number;
|
|
1324
|
+
}, {
|
|
1325
|
+
service: string;
|
|
1326
|
+
amount_cents: number;
|
|
1327
|
+
}>, "many">>>;
|
|
1364
1328
|
currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
|
|
1365
1329
|
amount_total_cents: z.ZodOptional<z.ZodNumber>;
|
|
1366
1330
|
occurred_at: z.ZodOptional<z.ZodString>;
|
|
@@ -1392,10 +1356,14 @@ declare const saleUpdateSchema: z.ZodObject<{
|
|
|
1392
1356
|
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1393
1357
|
}, "strict", z.ZodTypeAny, {
|
|
1394
1358
|
metadata?: Record<string, unknown> | null | undefined;
|
|
1395
|
-
description?: string | null | undefined;
|
|
1396
1359
|
service?: string | null | undefined;
|
|
1397
|
-
|
|
1360
|
+
services?: {
|
|
1361
|
+
service: string;
|
|
1362
|
+
amount_cents: number;
|
|
1363
|
+
}[] | null | undefined;
|
|
1398
1364
|
amount_total_cents?: number | undefined;
|
|
1365
|
+
description?: string | null | undefined;
|
|
1366
|
+
currency?: "USD" | "CAD" | undefined;
|
|
1399
1367
|
occurred_at?: string | undefined;
|
|
1400
1368
|
items?: {
|
|
1401
1369
|
quantity: string;
|
|
@@ -1410,10 +1378,58 @@ declare const saleUpdateSchema: z.ZodObject<{
|
|
|
1410
1378
|
customer_email?: string | null | undefined;
|
|
1411
1379
|
}, {
|
|
1412
1380
|
metadata?: Record<string, unknown> | null | undefined;
|
|
1381
|
+
service?: string | null | undefined;
|
|
1382
|
+
services?: {
|
|
1383
|
+
service: string;
|
|
1384
|
+
amount_cents: number;
|
|
1385
|
+
}[] | null | undefined;
|
|
1386
|
+
amount_total_cents?: number | undefined;
|
|
1413
1387
|
description?: string | null | undefined;
|
|
1388
|
+
currency?: "USD" | "CAD" | undefined;
|
|
1389
|
+
occurred_at?: string | undefined;
|
|
1390
|
+
items?: {
|
|
1391
|
+
quantity: string;
|
|
1392
|
+
unit_price_cents: number;
|
|
1393
|
+
name?: string | null | undefined;
|
|
1394
|
+
external_item_id?: string | null | undefined;
|
|
1395
|
+
category?: string | null | undefined;
|
|
1396
|
+
unit_cost_cents?: number | null | undefined;
|
|
1397
|
+
}[] | undefined;
|
|
1398
|
+
customer_name?: string | null | undefined;
|
|
1399
|
+
customer_phone?: string | null | undefined;
|
|
1400
|
+
customer_email?: string | null | undefined;
|
|
1401
|
+
}>, {
|
|
1402
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1414
1403
|
service?: string | null | undefined;
|
|
1404
|
+
services?: {
|
|
1405
|
+
service: string;
|
|
1406
|
+
amount_cents: number;
|
|
1407
|
+
}[] | null | undefined;
|
|
1408
|
+
amount_total_cents?: number | undefined;
|
|
1409
|
+
description?: string | null | undefined;
|
|
1415
1410
|
currency?: "USD" | "CAD" | undefined;
|
|
1411
|
+
occurred_at?: string | undefined;
|
|
1412
|
+
items?: {
|
|
1413
|
+
quantity: string;
|
|
1414
|
+
unit_price_cents: number;
|
|
1415
|
+
name?: string | null | undefined;
|
|
1416
|
+
external_item_id?: string | null | undefined;
|
|
1417
|
+
category?: string | null | undefined;
|
|
1418
|
+
unit_cost_cents?: number | null | undefined;
|
|
1419
|
+
}[] | undefined;
|
|
1420
|
+
customer_name?: string | null | undefined;
|
|
1421
|
+
customer_phone?: string | null | undefined;
|
|
1422
|
+
customer_email?: string | null | undefined;
|
|
1423
|
+
}, {
|
|
1424
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1425
|
+
service?: string | null | undefined;
|
|
1426
|
+
services?: {
|
|
1427
|
+
service: string;
|
|
1428
|
+
amount_cents: number;
|
|
1429
|
+
}[] | null | undefined;
|
|
1416
1430
|
amount_total_cents?: number | undefined;
|
|
1431
|
+
description?: string | null | undefined;
|
|
1432
|
+
currency?: "USD" | "CAD" | undefined;
|
|
1417
1433
|
occurred_at?: string | undefined;
|
|
1418
1434
|
items?: {
|
|
1419
1435
|
quantity: string;
|
|
@@ -1428,6 +1444,7 @@ declare const saleUpdateSchema: z.ZodObject<{
|
|
|
1428
1444
|
customer_email?: string | null | undefined;
|
|
1429
1445
|
}>;
|
|
1430
1446
|
type SaleItemInput = z.input<typeof saleItemSchema>;
|
|
1447
|
+
type SaleServiceInput = z.input<typeof saleServiceSchema>;
|
|
1431
1448
|
type SaleInput = z.input<typeof saleCreateSchema>;
|
|
1432
1449
|
type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
|
|
1433
1450
|
interface SaleItem {
|
|
@@ -1439,6 +1456,13 @@ interface SaleItem {
|
|
|
1439
1456
|
unit_price_cents: number;
|
|
1440
1457
|
unit_cost_cents: number | null;
|
|
1441
1458
|
}
|
|
1459
|
+
interface SaleService {
|
|
1460
|
+
id: string;
|
|
1461
|
+
service_id: string;
|
|
1462
|
+
service_key: string;
|
|
1463
|
+
service_label: string;
|
|
1464
|
+
amount_cents: number;
|
|
1465
|
+
}
|
|
1442
1466
|
interface Sale {
|
|
1443
1467
|
id: string;
|
|
1444
1468
|
business_id: string;
|
|
@@ -1450,6 +1474,7 @@ interface Sale {
|
|
|
1450
1474
|
service_id: string | null;
|
|
1451
1475
|
service_key?: string | null;
|
|
1452
1476
|
service_label?: string | null;
|
|
1477
|
+
services: SaleService[];
|
|
1453
1478
|
occurred_at: string;
|
|
1454
1479
|
environment: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1455
1480
|
metadata: Record<string, unknown> | null;
|
|
@@ -1467,7 +1492,11 @@ interface SaleListPage {
|
|
|
1467
1492
|
interface SaleCursorPage {
|
|
1468
1493
|
items: Sale[];
|
|
1469
1494
|
next_cursor: string | null;
|
|
1495
|
+
/** Populated only when `want_total` was requested (a single indexed COUNT). */
|
|
1496
|
+
total_count?: number;
|
|
1497
|
+
has_more?: boolean;
|
|
1470
1498
|
}
|
|
1499
|
+
type SaleSortOrder = 'asc' | 'desc';
|
|
1471
1500
|
/**
|
|
1472
1501
|
* Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
|
|
1473
1502
|
*
|
|
@@ -1480,6 +1509,8 @@ interface SaleFilters {
|
|
|
1480
1509
|
business_id?: string;
|
|
1481
1510
|
external_id?: string;
|
|
1482
1511
|
service_id?: string;
|
|
1512
|
+
/** E.164 phone — the canonical customer key; filters sales for one customer. */
|
|
1513
|
+
customer_phone?: string;
|
|
1483
1514
|
currency?: SupportedCurrency;
|
|
1484
1515
|
environment?: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1485
1516
|
since?: string;
|
|
@@ -1503,6 +1534,15 @@ interface SaleListQuery extends SaleFilters {
|
|
|
1503
1534
|
limit?: number;
|
|
1504
1535
|
cursor?: string | null;
|
|
1505
1536
|
}
|
|
1537
|
+
/** Keyset-safe sort columns (NOT-NULL, indexed). */
|
|
1538
|
+
type SaleKeysetSortField = 'occurred_at' | 'created_at' | 'amount_total_cents';
|
|
1539
|
+
/** v2 list query — adds server sort + opt-in total. */
|
|
1540
|
+
interface SaleListQueryV2 extends SaleListQuery {
|
|
1541
|
+
sort?: SaleKeysetSortField;
|
|
1542
|
+
order?: SaleSortOrder;
|
|
1543
|
+
/** Opt-in: a single indexed COUNT over the filtered set. */
|
|
1544
|
+
want_total?: boolean;
|
|
1545
|
+
}
|
|
1506
1546
|
declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
|
|
1507
1547
|
type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
|
|
1508
1548
|
/** Query input for `SalesClient.summary()` — filters + range + options. */
|
|
@@ -1558,6 +1598,175 @@ interface SaleSummary {
|
|
|
1558
1598
|
by_category: SalesCategoryBreakdown[];
|
|
1559
1599
|
series: SalesTrendPoint[];
|
|
1560
1600
|
}
|
|
1601
|
+
declare const NAMED_RANGES: readonly ["today", "yesterday", "wtd", "mtd", "qtd", "ytd", "24h", "7d", "30d", "90d", "custom"];
|
|
1602
|
+
/** Superset of `TrackingOverviewRange` (`24h`/`7d`/`30d` stay valid). */
|
|
1603
|
+
type NamedRange = (typeof NAMED_RANGES)[number];
|
|
1604
|
+
type Granularity = 'hour' | 'day' | 'week' | 'month' | 'auto';
|
|
1605
|
+
type CompareTo = 'previous_period' | 'previous_year' | 'none';
|
|
1606
|
+
interface DistinctCustomersByCurrency {
|
|
1607
|
+
currency: SupportedCurrency;
|
|
1608
|
+
distinct_customers: number;
|
|
1609
|
+
}
|
|
1610
|
+
interface SummaryWindow {
|
|
1611
|
+
since: string;
|
|
1612
|
+
until: string;
|
|
1613
|
+
}
|
|
1614
|
+
interface SummaryCurrencyDelta {
|
|
1615
|
+
currency: SupportedCurrency;
|
|
1616
|
+
revenue_cents_delta: number;
|
|
1617
|
+
/** Ratio (0.12 = +12%); null when previous revenue was 0. */
|
|
1618
|
+
revenue_pct_delta: number | null;
|
|
1619
|
+
sale_count_delta: number;
|
|
1620
|
+
}
|
|
1621
|
+
interface SummaryDeltas {
|
|
1622
|
+
by_currency: SummaryCurrencyDelta[];
|
|
1623
|
+
sale_count_delta: number;
|
|
1624
|
+
distinct_customers_delta: number;
|
|
1625
|
+
}
|
|
1626
|
+
interface SaleSummaryPrevious {
|
|
1627
|
+
window: SummaryWindow;
|
|
1628
|
+
metrics: SaleSummaryV2['metrics'];
|
|
1629
|
+
by_currency: CurrencyRevenue[];
|
|
1630
|
+
series: SalesTrendPoint[];
|
|
1631
|
+
}
|
|
1632
|
+
/** Query input for `SalesClient.summary()` v2 — widened range + tz/compare options. */
|
|
1633
|
+
interface SaleSummaryQueryV2 extends SaleFilters {
|
|
1634
|
+
range?: NamedRange;
|
|
1635
|
+
/** Required when `range === 'custom'`. */
|
|
1636
|
+
since?: string;
|
|
1637
|
+
until?: string;
|
|
1638
|
+
/** IANA tz, e.g. `America/Toronto`. Default = business tz. */
|
|
1639
|
+
timezone?: string;
|
|
1640
|
+
granularity?: Granularity;
|
|
1641
|
+
compare_to?: CompareTo;
|
|
1642
|
+
include_categories?: boolean;
|
|
1643
|
+
include_deleted_services?: boolean;
|
|
1644
|
+
top_n?: number;
|
|
1645
|
+
}
|
|
1646
|
+
/** Superset of `SaleSummary` (assignable to it). */
|
|
1647
|
+
interface SaleSummaryV2 extends Omit<SaleSummary, 'range' | 'metrics'> {
|
|
1648
|
+
range: NamedRange;
|
|
1649
|
+
metrics: SaleSummary['metrics'] & {
|
|
1650
|
+
distinct_customers_by_currency: DistinctCustomersByCurrency[];
|
|
1651
|
+
};
|
|
1652
|
+
timezone: string | null;
|
|
1653
|
+
window: SummaryWindow | null;
|
|
1654
|
+
granularity: string | null;
|
|
1655
|
+
previous: SaleSummaryPrevious | null;
|
|
1656
|
+
deltas: SummaryDeltas | null;
|
|
1657
|
+
}
|
|
1658
|
+
type CustomerSegment = 'new' | 'returning' | 'repeat' | 'lapsed';
|
|
1659
|
+
type CustomerSortField = 'total_spent' | 'last_purchase' | 'purchases' | 'first_purchase';
|
|
1660
|
+
interface CustomerCurrencyTotal {
|
|
1661
|
+
currency: SupportedCurrency;
|
|
1662
|
+
revenue_cents: number;
|
|
1663
|
+
sale_count: number;
|
|
1664
|
+
average_order_value_cents: number;
|
|
1665
|
+
}
|
|
1666
|
+
interface CustomerSummary {
|
|
1667
|
+
/** The E.164 phone — the canonical customer id. */
|
|
1668
|
+
customer_id: string;
|
|
1669
|
+
display_name: string | null;
|
|
1670
|
+
email: string | null;
|
|
1671
|
+
phone: string;
|
|
1672
|
+
first_purchase_at: string;
|
|
1673
|
+
last_purchase_at: string;
|
|
1674
|
+
purchase_count: number;
|
|
1675
|
+
segment: CustomerSegment;
|
|
1676
|
+
totals: CustomerCurrencyTotal[];
|
|
1677
|
+
}
|
|
1678
|
+
type CustomerProfile = CustomerSummary;
|
|
1679
|
+
interface CustomerListQuery extends Omit<SaleFilters, 'external_id'> {
|
|
1680
|
+
segment?: CustomerSegment;
|
|
1681
|
+
sort?: CustomerSortField;
|
|
1682
|
+
order?: SaleSortOrder;
|
|
1683
|
+
cursor?: string | null;
|
|
1684
|
+
limit?: number;
|
|
1685
|
+
want_total?: boolean;
|
|
1686
|
+
}
|
|
1687
|
+
interface CustomerListPage {
|
|
1688
|
+
items: CustomerSummary[];
|
|
1689
|
+
next_cursor: string | null;
|
|
1690
|
+
total_count: number | null;
|
|
1691
|
+
}
|
|
1692
|
+
interface CustomerGetOptions {
|
|
1693
|
+
include_sales?: boolean;
|
|
1694
|
+
limit?: number;
|
|
1695
|
+
cursor?: string | null;
|
|
1696
|
+
}
|
|
1697
|
+
interface CustomerGetResult {
|
|
1698
|
+
customer: CustomerProfile;
|
|
1699
|
+
/** Present only when `include_sales: true` (and a business-scoped key). */
|
|
1700
|
+
sales?: SaleCursorPage | null;
|
|
1701
|
+
}
|
|
1702
|
+
interface CustomerSummaryQuery extends SaleFilters {
|
|
1703
|
+
range?: NamedRange;
|
|
1704
|
+
since?: string;
|
|
1705
|
+
until?: string;
|
|
1706
|
+
timezone?: string;
|
|
1707
|
+
compare_to?: CompareTo;
|
|
1708
|
+
}
|
|
1709
|
+
interface CustomerSegmentCount {
|
|
1710
|
+
segment: CustomerSegment;
|
|
1711
|
+
count: number;
|
|
1712
|
+
}
|
|
1713
|
+
interface CustomerCurrencyDelta {
|
|
1714
|
+
currency: SupportedCurrency;
|
|
1715
|
+
revenue_cents_delta: number;
|
|
1716
|
+
/** Ratio (0.12 = +12%); null when previous revenue was 0. */
|
|
1717
|
+
revenue_pct_delta: number | null;
|
|
1718
|
+
}
|
|
1719
|
+
interface CustomerKpisDeltas {
|
|
1720
|
+
total_customers_delta: number;
|
|
1721
|
+
new_customers_delta: number;
|
|
1722
|
+
returning_customers_delta: number;
|
|
1723
|
+
repeat_rate_delta: number;
|
|
1724
|
+
ltv_by_currency: CustomerCurrencyDelta[];
|
|
1725
|
+
}
|
|
1726
|
+
interface CustomerKpisPrevious {
|
|
1727
|
+
window_since: string;
|
|
1728
|
+
window_until: string;
|
|
1729
|
+
total_customers: number;
|
|
1730
|
+
new_customers: number;
|
|
1731
|
+
returning_customers: number;
|
|
1732
|
+
repeat_rate: number;
|
|
1733
|
+
ltv_by_currency: CustomerCurrencyTotal[];
|
|
1734
|
+
}
|
|
1735
|
+
interface CustomerKpis {
|
|
1736
|
+
range: NamedRange;
|
|
1737
|
+
timezone: string;
|
|
1738
|
+
window_since: string;
|
|
1739
|
+
window_until: string;
|
|
1740
|
+
total_customers: number;
|
|
1741
|
+
new_customers: number;
|
|
1742
|
+
returning_customers: number;
|
|
1743
|
+
repeat_rate: number;
|
|
1744
|
+
by_segment: CustomerSegmentCount[];
|
|
1745
|
+
ltv_by_currency: CustomerCurrencyTotal[];
|
|
1746
|
+
/** Present only when `compare_to` is set. */
|
|
1747
|
+
previous?: CustomerKpisPrevious | null;
|
|
1748
|
+
deltas?: CustomerKpisDeltas | null;
|
|
1749
|
+
}
|
|
1750
|
+
interface BusinessConfigService {
|
|
1751
|
+
key: string;
|
|
1752
|
+
label: string;
|
|
1753
|
+
archived: boolean;
|
|
1754
|
+
}
|
|
1755
|
+
interface BusinessConfigFeatures {
|
|
1756
|
+
customers: boolean;
|
|
1757
|
+
comparisons: boolean;
|
|
1758
|
+
retention: boolean;
|
|
1759
|
+
}
|
|
1760
|
+
interface BusinessConfig {
|
|
1761
|
+
business_id: string;
|
|
1762
|
+
display_name: string;
|
|
1763
|
+
timezone: string;
|
|
1764
|
+
primary_currency: SupportedCurrency;
|
|
1765
|
+
currencies: SupportedCurrency[];
|
|
1766
|
+
default_phone_country: string | null;
|
|
1767
|
+
services: BusinessConfigService[];
|
|
1768
|
+
features: BusinessConfigFeatures;
|
|
1769
|
+
}
|
|
1561
1770
|
|
|
1562
1771
|
/** Shared config for every sales HTTP helper. */
|
|
1563
1772
|
interface SalesTransportConfig {
|
|
@@ -1580,6 +1789,17 @@ interface SalesClientConfig extends SalesTransportConfig {
|
|
|
1580
1789
|
/** Applied when an individual `record()` call omits `currency`. */
|
|
1581
1790
|
defaultCurrency?: SupportedCurrency;
|
|
1582
1791
|
}
|
|
1792
|
+
/** Phone-keyed customer rollups (sk-only; a public key gets a `403`). */
|
|
1793
|
+
interface SalesCustomersClient {
|
|
1794
|
+
list(query?: CustomerListQuery): Promise<CustomerListPage>;
|
|
1795
|
+
/** `id` is the customer's E.164 phone. */
|
|
1796
|
+
get(id: string, options?: CustomerGetOptions): Promise<CustomerGetResult>;
|
|
1797
|
+
summary(query?: CustomerSummaryQuery): Promise<CustomerKpis>;
|
|
1798
|
+
}
|
|
1799
|
+
/** Business config (low-sensitivity — accepts a public or secret key). */
|
|
1800
|
+
interface SalesBusinessClient {
|
|
1801
|
+
config(): Promise<BusinessConfig>;
|
|
1802
|
+
}
|
|
1583
1803
|
/**
|
|
1584
1804
|
* One isomorphic sales client — what a key may *do* is enforced by the backend,
|
|
1585
1805
|
* not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
|
|
@@ -1591,23 +1811,36 @@ interface SalesClientConfig extends SalesTransportConfig {
|
|
|
1591
1811
|
* `@aranova/tracking-cli gen` for compile-time-checked `service` values.
|
|
1592
1812
|
*/
|
|
1593
1813
|
interface SalesClient<TService extends string = string> {
|
|
1594
|
-
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service'> & {
|
|
1814
|
+
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
|
|
1595
1815
|
service?: TService | null;
|
|
1816
|
+
services?: Array<{
|
|
1817
|
+
service: TService;
|
|
1818
|
+
amount_cents: number;
|
|
1819
|
+
}>;
|
|
1596
1820
|
currency?: SupportedCurrency;
|
|
1597
1821
|
occurred_at?: string;
|
|
1598
1822
|
}): Promise<Sale>;
|
|
1599
|
-
list
|
|
1823
|
+
/** Keyset list with optional server sort + opt-in `total_count`. */
|
|
1824
|
+
list(query?: SaleListQueryV2): Promise<SaleCursorPage>;
|
|
1600
1825
|
/**
|
|
1601
|
-
* Currency-grouped aggregations for the key's business
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1826
|
+
* Currency-grouped aggregations for the key's business. Additive v2 options:
|
|
1827
|
+
* calendar/custom ranges, IANA `timezone`, `granularity`, and `compare_to`.
|
|
1828
|
+
* Legacy `24h/7d/30d` keep their exact prior numbers. Secret key only.
|
|
1604
1829
|
*/
|
|
1605
|
-
summary(query:
|
|
1830
|
+
summary(query: SaleSummaryQueryV2): Promise<SaleSummaryV2>;
|
|
1606
1831
|
get(id: string): Promise<Sale>;
|
|
1607
|
-
update(id: string, patch: Omit<SaleUpdateInput, 'service'> & {
|
|
1832
|
+
update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
|
|
1608
1833
|
service?: TService | null;
|
|
1834
|
+
services?: Array<{
|
|
1835
|
+
service: TService;
|
|
1836
|
+
amount_cents: number;
|
|
1837
|
+
}>;
|
|
1609
1838
|
}): Promise<Sale>;
|
|
1610
1839
|
delete(id: string): Promise<void>;
|
|
1840
|
+
/** Phone-keyed customer rollups (sk-only). */
|
|
1841
|
+
customers: SalesCustomersClient;
|
|
1842
|
+
/** Business config (pk or sk). */
|
|
1843
|
+
business: SalesBusinessClient;
|
|
1611
1844
|
}
|
|
1612
1845
|
declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
|
|
1613
1846
|
|
|
@@ -1639,6 +1872,12 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
|
1639
1872
|
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
1640
1873
|
*/
|
|
1641
1874
|
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
1875
|
+
/**
|
|
1876
|
+
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
1877
|
+
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
1878
|
+
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
1879
|
+
*/
|
|
1880
|
+
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
1642
1881
|
|
|
1643
1882
|
/**
|
|
1644
1883
|
* Error thrown by the sales client (`createSalesClient`) on a
|
|
@@ -1833,6 +2072,11 @@ interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
|
|
|
1833
2072
|
* analytics can never throw into the host app.
|
|
1834
2073
|
*/
|
|
1835
2074
|
debug?: boolean;
|
|
2075
|
+
/**
|
|
2076
|
+
* Phone-field display + default-country config, read by `usePhoneField` /
|
|
2077
|
+
* `<PhoneField>`. Display is customizable; the transmitted value is always E.164.
|
|
2078
|
+
*/
|
|
2079
|
+
phone?: PhoneConfig;
|
|
1836
2080
|
}
|
|
1837
2081
|
interface TrackingProviderProps {
|
|
1838
2082
|
/**
|
|
@@ -1864,4 +2108,71 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
|
|
|
1864
2108
|
*/
|
|
1865
2109
|
declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
|
|
1866
2110
|
|
|
1867
|
-
|
|
2111
|
+
/** Carries `createTracking({ phone })` config to `usePhoneField`. Separate from the
|
|
2112
|
+
* tracking client context so `useTracking()`'s type is untouched.
|
|
2113
|
+
*
|
|
2114
|
+
* Caveat: this module is bundled into BOTH `@aranova/tracking-react` and
|
|
2115
|
+
* `@aranova/tracking-next`, so each package has its own context instance at
|
|
2116
|
+
* runtime. Within one installed package the provider + hook share it (correct);
|
|
2117
|
+
* mixing `createTracking` from one package with `usePhoneField` from the other
|
|
2118
|
+
* won't share config (the hook falls back to the `CA`/`national` defaults). Use a
|
|
2119
|
+
* single tracking package per app. */
|
|
2120
|
+
declare const PhoneConfigContext: react.Context<PhoneConfig | null>;
|
|
2121
|
+
/** Resolve the effective phone config (provider value or built-in defaults). */
|
|
2122
|
+
declare function usePhoneConfig(): {
|
|
2123
|
+
defaultCountry: CountryCode;
|
|
2124
|
+
display: PhoneDisplayFormat;
|
|
2125
|
+
};
|
|
2126
|
+
interface UsePhoneFieldOptions {
|
|
2127
|
+
defaultValue?: string;
|
|
2128
|
+
/** Overrides the provider's `defaultCountry`. */
|
|
2129
|
+
country?: CountryCode;
|
|
2130
|
+
/** Overrides the provider's `display` (applied to the settled value on blur). */
|
|
2131
|
+
display?: PhoneDisplayFormat;
|
|
2132
|
+
/** Notified with the canonical E.164 (or `null`) on every change. */
|
|
2133
|
+
onValueChange?: (e164: string | null) => void;
|
|
2134
|
+
}
|
|
2135
|
+
interface PhoneInputProps {
|
|
2136
|
+
value: string;
|
|
2137
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
2138
|
+
onBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
2139
|
+
type: 'tel';
|
|
2140
|
+
inputMode: 'tel';
|
|
2141
|
+
autoComplete: 'tel';
|
|
2142
|
+
}
|
|
2143
|
+
interface PhoneFieldApi {
|
|
2144
|
+
/** Display value for the `<input>` (live `AsYouType` while typing). */
|
|
2145
|
+
value: string;
|
|
2146
|
+
/** Canonical E.164 — what gets transmitted. `null` while invalid/incomplete. */
|
|
2147
|
+
e164: string | null;
|
|
2148
|
+
isValid: boolean;
|
|
2149
|
+
/** Validation message, surfaced only after blur with non-empty invalid input. */
|
|
2150
|
+
error: string | null;
|
|
2151
|
+
parsed: ParsedPhone;
|
|
2152
|
+
/** Spread onto an `<input>`: pre-wires value/onChange/onBlur/type/inputMode/autoComplete. */
|
|
2153
|
+
inputProps: PhoneInputProps;
|
|
2154
|
+
}
|
|
2155
|
+
/** Headless phone field — the client owns the markup. */
|
|
2156
|
+
declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
|
|
2157
|
+
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> {
|
|
2158
|
+
country?: CountryCode;
|
|
2159
|
+
/** Controlled display value. */
|
|
2160
|
+
value?: string;
|
|
2161
|
+
/** Uncontrolled initial value. */
|
|
2162
|
+
defaultValue?: string;
|
|
2163
|
+
/** Receives the native change event (RHF `register().onChange` or your own); the
|
|
2164
|
+
* event's `target.value` is already `AsYouType`-formatted. */
|
|
2165
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
2166
|
+
/** Receives the canonical E.164 (or `null`) on every change. */
|
|
2167
|
+
onE164Change?: (e164: string | null) => void;
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Batteries-included phone input. Composes identically with react-hook-form
|
|
2171
|
+
* `{...register('phone')}` and with controlled state — the `AsYouType` +
|
|
2172
|
+
* mutate-`e.target.value`-before-`onChange` technique lives inside, so RHF and
|
|
2173
|
+
* controlled parents both receive the formatted value, and the wire value stays
|
|
2174
|
+
* E.164.
|
|
2175
|
+
*/
|
|
2176
|
+
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
2177
|
+
|
|
2178
|
+
export { AranovaApiError, type AutomaticEventName, type BusinessConfig, type BusinessConfigFeatures, type BusinessConfigService, type CompareTo, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type CurrencyRevenue, type CustomerCurrencyDelta, type CustomerCurrencyTotal, type CustomerGetOptions, type CustomerGetResult, type CustomerKpis, type CustomerKpisDeltas, type CustomerKpisPrevious, type CustomerListPage, type CustomerListQuery, type CustomerProfile, type CustomerSegment, type CustomerSegmentCount, type CustomerSortField, type CustomerSummary, type CustomerSummaryQuery, type DistinctCustomersByCurrency, type EventConfig, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type Granularity, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type NamedRange, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneConfigContext, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type PublicServiceItem, type RegisteredAutomaticEvents, type RegisteredManualEvents, type Sale, type SaleCursorPage, type SaleInput, type SaleItem, type SaleItemInput, type SaleKeysetSortField, type SaleListPage, type SaleListQuery, type SaleListQueryV2, type SaleService, type SaleServiceInput, type SaleSortOrder, type SaleSummary, type SaleSummaryPrevious, type SaleSummaryQuery, type SaleSummaryQueryV2, type SaleSummaryV2, type SaleUpdateInput, type SalesBusinessClient, type SalesCategoryBreakdown, type SalesClient, type SalesClientConfig, type SalesCustomersClient, type SalesServiceBreakdown, type SalesTransportConfig, type SalesTrendPoint, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, type SummaryCurrencyDelta, type SummaryDeltas, type SummaryWindow, type SupportedCurrency, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, type TrackingOverviewRange, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatDateInTz, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|