@aranova/tracking-react 0.12.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 +59 -48
- package/dist/index.d.mts +61 -802
- package/dist/index.d.ts +61 -802
- package/dist/index.js +190 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +183 -84
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-CVX7JmqB.d.mts → phone-utils-DXAki8pO.d.mts} +7 -6
- package/dist/{phone-utils-CVX7JmqB.d.ts → phone-utils-DXAki8pO.d.ts} +7 -6
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/phone.js +98 -0
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +98 -0
- package/dist/phone.mjs.map +1 -1
- 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/package.json +30 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
|
|
3
|
-
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, F as FormSubmitConfig, f as FormSubmitMetadata, G as GtagEnvironmentMap, P as PhoneConfig, g as ParsedPhone, h as PhoneDisplayFormat } from './phone-utils-
|
|
4
|
-
export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as
|
|
3
|
+
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, F as FormSubmitConfig, f as FormSubmitMetadata, G as GtagEnvironmentMap, P as PhoneConfig, g as ParsedPhone, h as PhoneDisplayFormat } from './phone-utils-DXAki8pO.mjs';
|
|
4
|
+
export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formSubmitConfigSchema, l as formSubmitMetadataSchema, m as formatPhone, n as formatPhoneAsTyped, o as jsonValueSchema, p as parsePhone, q as phoneField, t as toE164 } from './phone-utils-DXAki8pO.mjs';
|
|
5
5
|
import * as src from 'src';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
export { AranovaApiError, BusinessConfig, BusinessConfigFeatures, BusinessConfigService, CompareTo, CurrencyRevenue, CustomerCurrencyDelta, CustomerCurrencyTotal, CustomerGetOptions, CustomerGetResult, CustomerKpis, CustomerKpisDeltas, CustomerKpisPrevious, CustomerListPage, CustomerListQuery, CustomerProfile, CustomerSegment, CustomerSegmentCount, CustomerSortField, CustomerSummary, CustomerSummaryQuery, DistinctCustomersByCurrency, Granularity, NAMED_RANGES, NamedRange, PublicServiceItem, SUPPORTED_CURRENCIES, Sale, SaleCursorPage, SaleFilters, SaleInput, SaleItem, SaleItemInput, SaleKeysetSortField, SaleListPage, SaleListQuery, SaleListQueryV2, SaleService, SaleServiceInput, SaleSortField, SaleSortOrder, SaleSummary, SaleSummaryPrevious, SaleSummaryQuery, SaleSummaryQueryV2, SaleSummaryV2, SaleUpdateInput, SalesBusinessClient, SalesCategoryBreakdown, SalesClient, SalesClientConfig, SalesCustomersClient, SalesServiceBreakdown, SalesTransportConfig, SalesTrendPoint, SummaryCurrencyDelta, SummaryDeltas, SummaryWindow, SupportedCurrency, TRACKING_RANGES, TrackingOverviewRange, createSalesClient, fetchServices, formatDateInTz, formatMoney, fromMinor, saleCreateSchema, saleItemSchema, saleServiceSchema, saleUpdateSchema, salesRequest, toMinor } from './sales.mjs';
|
|
7
8
|
import { CountryCode } from 'libphonenumber-js';
|
|
8
9
|
export { CountryCode } from 'libphonenumber-js';
|
|
9
10
|
|
|
@@ -60,11 +61,11 @@ interface ConsentBannerProps {
|
|
|
60
61
|
onAccept?: () => void;
|
|
61
62
|
onDecline?: () => void;
|
|
62
63
|
/** Where the banner docks. Default: `"bottom"`. */
|
|
63
|
-
position?:
|
|
64
|
+
position?: "top" | "bottom";
|
|
64
65
|
/**
|
|
65
66
|
* Visual theme. `"auto"` follows `prefers-color-scheme`. Default: `"light"`.
|
|
66
67
|
*/
|
|
67
|
-
theme?:
|
|
68
|
+
theme?: "light" | "dark" | "auto";
|
|
68
69
|
/** Class added to the outer wrapper for additional styling hooks. */
|
|
69
70
|
className?: string;
|
|
70
71
|
/** Inline style overrides applied to the outer wrapper after the defaults. */
|
|
@@ -75,7 +76,7 @@ declare function ConsentBanner({ message, title, acceptLabel, declineLabel, poli
|
|
|
75
76
|
/**
|
|
76
77
|
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
77
78
|
*/
|
|
78
|
-
type GtagConsentValue =
|
|
79
|
+
type GtagConsentValue = "granted" | "denied";
|
|
79
80
|
/**
|
|
80
81
|
* Read the persisted visitor consent state from localStorage.
|
|
81
82
|
*
|
|
@@ -192,6 +193,19 @@ type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
|
|
|
192
193
|
declare const ctaClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
193
194
|
type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
|
|
194
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Registered trigger names reported by the SDK heartbeat.
|
|
198
|
+
*/
|
|
199
|
+
declare const sdkHeartbeatTriggersSchema: z.ZodObject<{
|
|
200
|
+
automatic: z.ZodArray<z.ZodString, "many">;
|
|
201
|
+
manual: z.ZodArray<z.ZodString, "many">;
|
|
202
|
+
}, "strict", z.ZodTypeAny, {
|
|
203
|
+
automatic: string[];
|
|
204
|
+
manual: string[];
|
|
205
|
+
}, {
|
|
206
|
+
automatic: string[];
|
|
207
|
+
manual: string[];
|
|
208
|
+
}>;
|
|
195
209
|
/**
|
|
196
210
|
* Metadata for the SDK-internal `sdk_heartbeat` event.
|
|
197
211
|
*
|
|
@@ -494,6 +508,7 @@ type ScrollDepthConfig = z.infer<typeof scrollDepthConfigSchema>;
|
|
|
494
508
|
*/
|
|
495
509
|
declare const SPECIFIC_PAGE_NAMES: readonly ["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"];
|
|
496
510
|
type SpecificPageName = (typeof SPECIFIC_PAGE_NAMES)[number];
|
|
511
|
+
declare const specificPageNameSchema: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
|
|
497
512
|
/**
|
|
498
513
|
* Metadata for the automatic `specific_page_visit` event.
|
|
499
514
|
*
|
|
@@ -590,6 +605,7 @@ declare const timeOnSiteConfigSchema: z.ZodObject<{
|
|
|
590
605
|
}>;
|
|
591
606
|
type TimeOnSiteConfig = z.infer<typeof timeOnSiteConfigSchema>;
|
|
592
607
|
|
|
608
|
+
type EventKind = "automatic" | "manual";
|
|
593
609
|
declare const EVENT_REGISTRY: {
|
|
594
610
|
readonly page_view: {
|
|
595
611
|
readonly kind: "automatic";
|
|
@@ -1016,13 +1032,13 @@ type EventName = keyof typeof EVENT_REGISTRY;
|
|
|
1016
1032
|
* Automatic events are not accepted by the typed `trackEvent()` API.
|
|
1017
1033
|
*/
|
|
1018
1034
|
type AutomaticEventName = {
|
|
1019
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
1035
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "automatic" ? K : never;
|
|
1020
1036
|
}[EventName];
|
|
1021
1037
|
/**
|
|
1022
1038
|
* Event names that consumer code can fire manually after registering them.
|
|
1023
1039
|
*/
|
|
1024
1040
|
type ManualEventName = {
|
|
1025
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
1041
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "manual" ? K : never;
|
|
1026
1042
|
}[EventName];
|
|
1027
1043
|
type MetadataByName = {
|
|
1028
1044
|
page_view: PageViewMetadata;
|
|
@@ -1061,6 +1077,14 @@ type EventMetadata<K extends EventName> = MetadataByName[K];
|
|
|
1061
1077
|
* Trigger registration config type for a specific tracking event.
|
|
1062
1078
|
*/
|
|
1063
1079
|
type EventConfig<K extends EventName> = ConfigByName[K];
|
|
1080
|
+
/**
|
|
1081
|
+
* Runtime list of automatic event names.
|
|
1082
|
+
*/
|
|
1083
|
+
declare const ALL_AUTOMATIC_EVENT_NAMES: readonly AutomaticEventName[];
|
|
1084
|
+
/**
|
|
1085
|
+
* Runtime list of manual event names.
|
|
1086
|
+
*/
|
|
1087
|
+
declare const ALL_MANUAL_EVENT_NAMES: readonly ManualEventName[];
|
|
1064
1088
|
/**
|
|
1065
1089
|
* Trigger registry passed to `createTracking({ triggers })`.
|
|
1066
1090
|
*
|
|
@@ -1088,18 +1112,18 @@ type EventConfig<K extends EventName> = ConfigByName[K];
|
|
|
1088
1112
|
*/
|
|
1089
1113
|
type TriggerRegistryConfig = {
|
|
1090
1114
|
automatic: {
|
|
1091
|
-
page_view: EventConfig<
|
|
1115
|
+
page_view: EventConfig<"page_view">;
|
|
1092
1116
|
} & Partial<{
|
|
1093
|
-
time_on_site: EventConfig<
|
|
1094
|
-
specific_page_visit: EventConfig<
|
|
1095
|
-
scroll_depth: EventConfig<
|
|
1096
|
-
multi_page_session: EventConfig<
|
|
1097
|
-
form_start: EventConfig<
|
|
1117
|
+
time_on_site: EventConfig<"time_on_site">;
|
|
1118
|
+
specific_page_visit: EventConfig<"specific_page_visit">;
|
|
1119
|
+
scroll_depth: EventConfig<"scroll_depth">;
|
|
1120
|
+
multi_page_session: EventConfig<"multi_page_session">;
|
|
1121
|
+
form_start: EventConfig<"form_start">;
|
|
1098
1122
|
}>;
|
|
1099
1123
|
manual?: Partial<{
|
|
1100
|
-
form_submit: EventConfig<
|
|
1101
|
-
phone_click: EventConfig<
|
|
1102
|
-
cta_click: EventConfig<
|
|
1124
|
+
form_submit: EventConfig<"form_submit">;
|
|
1125
|
+
phone_click: EventConfig<"phone_click">;
|
|
1126
|
+
cta_click: EventConfig<"cta_click">;
|
|
1103
1127
|
}>;
|
|
1104
1128
|
};
|
|
1105
1129
|
/**
|
|
@@ -1108,11 +1132,25 @@ type TriggerRegistryConfig = {
|
|
|
1108
1132
|
* Used by `TypedTrackingClient` so `trackEvent()` only accepts events the
|
|
1109
1133
|
* consumer explicitly enabled.
|
|
1110
1134
|
*/
|
|
1111
|
-
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry[
|
|
1135
|
+
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry["manual"]>, ManualEventName>;
|
|
1112
1136
|
/**
|
|
1113
1137
|
* Automatic event names registered in a concrete trigger registry.
|
|
1114
1138
|
*/
|
|
1115
|
-
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry[
|
|
1139
|
+
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry["automatic"], AutomaticEventName>;
|
|
1140
|
+
/**
|
|
1141
|
+
* Discriminated union of valid manual tracking calls for a registry.
|
|
1142
|
+
*/
|
|
1143
|
+
type TrackableEvent<TRegistry extends TriggerRegistryConfig> = {
|
|
1144
|
+
[K in RegisteredManualEvents<TRegistry>]: {
|
|
1145
|
+
eventType: K;
|
|
1146
|
+
metadata: EventMetadata<K>;
|
|
1147
|
+
};
|
|
1148
|
+
}[RegisteredManualEvents<TRegistry>];
|
|
1149
|
+
declare function getEventDefinition(name: EventName): {
|
|
1150
|
+
kind: EventKind;
|
|
1151
|
+
metadataSchema: z.ZodTypeAny;
|
|
1152
|
+
configSchema: z.ZodTypeAny;
|
|
1153
|
+
};
|
|
1116
1154
|
|
|
1117
1155
|
/**
|
|
1118
1156
|
* Input accepted by the low-level stringly-typed client.
|
|
@@ -1190,775 +1228,6 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1190
1228
|
getVisitorId(): string;
|
|
1191
1229
|
}
|
|
1192
1230
|
|
|
1193
|
-
/**
|
|
1194
|
-
* Sales / Conversions wire schemas — the client-side source of truth.
|
|
1195
|
-
*
|
|
1196
|
-
* `saleCreateSchema` is mirrored by `SaleCreateSchema` in
|
|
1197
|
-
* `apps/api/src/schemas/tracking_sales.py` and enforced by the backend drift
|
|
1198
|
-
* test (the `resources` section of `events.schema.json`). Keep them in lockstep.
|
|
1199
|
-
*
|
|
1200
|
-
* Money is **integer minor units (cents)**; `quantity` is a decimal string;
|
|
1201
|
-
* `currency` is the required `SupportedCurrency` enum.
|
|
1202
|
-
*/
|
|
1203
|
-
declare const SUPPORTED_CURRENCIES: readonly ["USD", "CAD"];
|
|
1204
|
-
type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
1205
|
-
declare const TRACKING_ENVIRONMENTS: readonly ["production", "development"];
|
|
1206
|
-
declare const saleItemSchema: z.ZodObject<{
|
|
1207
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1208
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1209
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1210
|
-
quantity: z.ZodString;
|
|
1211
|
-
unit_price_cents: z.ZodNumber;
|
|
1212
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1213
|
-
}, "strict", z.ZodTypeAny, {
|
|
1214
|
-
quantity: string;
|
|
1215
|
-
unit_price_cents: number;
|
|
1216
|
-
name?: string | null | undefined;
|
|
1217
|
-
external_item_id?: string | null | undefined;
|
|
1218
|
-
category?: string | null | undefined;
|
|
1219
|
-
unit_cost_cents?: number | null | undefined;
|
|
1220
|
-
}, {
|
|
1221
|
-
quantity: string;
|
|
1222
|
-
unit_price_cents: number;
|
|
1223
|
-
name?: string | null | undefined;
|
|
1224
|
-
external_item_id?: string | null | undefined;
|
|
1225
|
-
category?: string | null | undefined;
|
|
1226
|
-
unit_cost_cents?: number | null | undefined;
|
|
1227
|
-
}>;
|
|
1228
|
-
declare const saleServiceSchema: z.ZodObject<{
|
|
1229
|
-
service: z.ZodString;
|
|
1230
|
-
amount_cents: z.ZodNumber;
|
|
1231
|
-
}, "strict", z.ZodTypeAny, {
|
|
1232
|
-
service: string;
|
|
1233
|
-
amount_cents: number;
|
|
1234
|
-
}, {
|
|
1235
|
-
service: string;
|
|
1236
|
-
amount_cents: number;
|
|
1237
|
-
}>;
|
|
1238
|
-
declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
1239
|
-
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1240
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1241
|
-
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1242
|
-
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1243
|
-
service: z.ZodString;
|
|
1244
|
-
amount_cents: z.ZodNumber;
|
|
1245
|
-
}, "strict", z.ZodTypeAny, {
|
|
1246
|
-
service: string;
|
|
1247
|
-
amount_cents: number;
|
|
1248
|
-
}, {
|
|
1249
|
-
service: string;
|
|
1250
|
-
amount_cents: number;
|
|
1251
|
-
}>, "many">>>;
|
|
1252
|
-
currency: z.ZodEnum<["USD", "CAD"]>;
|
|
1253
|
-
amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1254
|
-
occurred_at: z.ZodString;
|
|
1255
|
-
environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
|
|
1256
|
-
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1257
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1258
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1259
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1260
|
-
quantity: z.ZodString;
|
|
1261
|
-
unit_price_cents: z.ZodNumber;
|
|
1262
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1263
|
-
}, "strict", z.ZodTypeAny, {
|
|
1264
|
-
quantity: string;
|
|
1265
|
-
unit_price_cents: number;
|
|
1266
|
-
name?: string | null | undefined;
|
|
1267
|
-
external_item_id?: string | null | undefined;
|
|
1268
|
-
category?: string | null | undefined;
|
|
1269
|
-
unit_cost_cents?: number | null | undefined;
|
|
1270
|
-
}, {
|
|
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
|
-
}>, "many">>;
|
|
1278
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1279
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1280
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1281
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1282
|
-
}, "strict", z.ZodTypeAny, {
|
|
1283
|
-
currency: "USD" | "CAD";
|
|
1284
|
-
occurred_at: string;
|
|
1285
|
-
environment: "production" | "development";
|
|
1286
|
-
items: {
|
|
1287
|
-
quantity: string;
|
|
1288
|
-
unit_price_cents: number;
|
|
1289
|
-
name?: string | null | undefined;
|
|
1290
|
-
external_item_id?: string | null | undefined;
|
|
1291
|
-
category?: string | null | undefined;
|
|
1292
|
-
unit_cost_cents?: number | null | undefined;
|
|
1293
|
-
}[];
|
|
1294
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1295
|
-
service?: string | null | undefined;
|
|
1296
|
-
services?: {
|
|
1297
|
-
service: string;
|
|
1298
|
-
amount_cents: number;
|
|
1299
|
-
}[] | null | undefined;
|
|
1300
|
-
amount_total_cents?: number | null | undefined;
|
|
1301
|
-
external_id?: string | null | undefined;
|
|
1302
|
-
description?: string | null | undefined;
|
|
1303
|
-
customer_name?: string | null | undefined;
|
|
1304
|
-
customer_phone?: string | null | undefined;
|
|
1305
|
-
customer_email?: string | null | undefined;
|
|
1306
|
-
}, {
|
|
1307
|
-
currency: "USD" | "CAD";
|
|
1308
|
-
occurred_at: string;
|
|
1309
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1310
|
-
service?: string | null | undefined;
|
|
1311
|
-
services?: {
|
|
1312
|
-
service: string;
|
|
1313
|
-
amount_cents: number;
|
|
1314
|
-
}[] | null | undefined;
|
|
1315
|
-
amount_total_cents?: number | null | undefined;
|
|
1316
|
-
external_id?: string | null | undefined;
|
|
1317
|
-
description?: string | null | undefined;
|
|
1318
|
-
environment?: "production" | "development" | undefined;
|
|
1319
|
-
items?: {
|
|
1320
|
-
quantity: string;
|
|
1321
|
-
unit_price_cents: number;
|
|
1322
|
-
name?: string | null | undefined;
|
|
1323
|
-
external_item_id?: string | null | undefined;
|
|
1324
|
-
category?: string | null | undefined;
|
|
1325
|
-
unit_cost_cents?: number | null | undefined;
|
|
1326
|
-
}[] | undefined;
|
|
1327
|
-
customer_name?: string | null | undefined;
|
|
1328
|
-
customer_phone?: string | null | undefined;
|
|
1329
|
-
customer_email?: string | null | undefined;
|
|
1330
|
-
}>, {
|
|
1331
|
-
currency: "USD" | "CAD";
|
|
1332
|
-
occurred_at: string;
|
|
1333
|
-
environment: "production" | "development";
|
|
1334
|
-
items: {
|
|
1335
|
-
quantity: string;
|
|
1336
|
-
unit_price_cents: number;
|
|
1337
|
-
name?: string | null | undefined;
|
|
1338
|
-
external_item_id?: string | null | undefined;
|
|
1339
|
-
category?: string | null | undefined;
|
|
1340
|
-
unit_cost_cents?: number | null | undefined;
|
|
1341
|
-
}[];
|
|
1342
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1343
|
-
service?: string | null | undefined;
|
|
1344
|
-
services?: {
|
|
1345
|
-
service: string;
|
|
1346
|
-
amount_cents: number;
|
|
1347
|
-
}[] | null | undefined;
|
|
1348
|
-
amount_total_cents?: number | null | undefined;
|
|
1349
|
-
external_id?: string | null | undefined;
|
|
1350
|
-
description?: string | null | undefined;
|
|
1351
|
-
customer_name?: string | null | undefined;
|
|
1352
|
-
customer_phone?: string | null | undefined;
|
|
1353
|
-
customer_email?: string | null | undefined;
|
|
1354
|
-
}, {
|
|
1355
|
-
currency: "USD" | "CAD";
|
|
1356
|
-
occurred_at: string;
|
|
1357
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1358
|
-
service?: string | null | undefined;
|
|
1359
|
-
services?: {
|
|
1360
|
-
service: string;
|
|
1361
|
-
amount_cents: number;
|
|
1362
|
-
}[] | null | undefined;
|
|
1363
|
-
amount_total_cents?: number | null | undefined;
|
|
1364
|
-
external_id?: string | null | undefined;
|
|
1365
|
-
description?: string | null | undefined;
|
|
1366
|
-
environment?: "production" | "development" | undefined;
|
|
1367
|
-
items?: {
|
|
1368
|
-
quantity: string;
|
|
1369
|
-
unit_price_cents: number;
|
|
1370
|
-
name?: string | null | undefined;
|
|
1371
|
-
external_item_id?: string | null | undefined;
|
|
1372
|
-
category?: string | null | undefined;
|
|
1373
|
-
unit_cost_cents?: number | null | undefined;
|
|
1374
|
-
}[] | undefined;
|
|
1375
|
-
customer_name?: string | null | undefined;
|
|
1376
|
-
customer_phone?: string | null | undefined;
|
|
1377
|
-
customer_email?: string | null | undefined;
|
|
1378
|
-
}>;
|
|
1379
|
-
declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
1380
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1381
|
-
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1382
|
-
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1383
|
-
service: z.ZodString;
|
|
1384
|
-
amount_cents: z.ZodNumber;
|
|
1385
|
-
}, "strict", z.ZodTypeAny, {
|
|
1386
|
-
service: string;
|
|
1387
|
-
amount_cents: number;
|
|
1388
|
-
}, {
|
|
1389
|
-
service: string;
|
|
1390
|
-
amount_cents: number;
|
|
1391
|
-
}>, "many">>>;
|
|
1392
|
-
currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
|
|
1393
|
-
amount_total_cents: z.ZodOptional<z.ZodNumber>;
|
|
1394
|
-
occurred_at: z.ZodOptional<z.ZodString>;
|
|
1395
|
-
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1396
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1397
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1398
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1399
|
-
quantity: z.ZodString;
|
|
1400
|
-
unit_price_cents: z.ZodNumber;
|
|
1401
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1402
|
-
}, "strict", z.ZodTypeAny, {
|
|
1403
|
-
quantity: string;
|
|
1404
|
-
unit_price_cents: number;
|
|
1405
|
-
name?: string | null | undefined;
|
|
1406
|
-
external_item_id?: string | null | undefined;
|
|
1407
|
-
category?: string | null | undefined;
|
|
1408
|
-
unit_cost_cents?: number | null | undefined;
|
|
1409
|
-
}, {
|
|
1410
|
-
quantity: string;
|
|
1411
|
-
unit_price_cents: number;
|
|
1412
|
-
name?: string | null | undefined;
|
|
1413
|
-
external_item_id?: string | null | undefined;
|
|
1414
|
-
category?: string | null | undefined;
|
|
1415
|
-
unit_cost_cents?: number | null | undefined;
|
|
1416
|
-
}>, "many">>;
|
|
1417
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1418
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1419
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1420
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1421
|
-
}, "strict", z.ZodTypeAny, {
|
|
1422
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1423
|
-
service?: string | null | undefined;
|
|
1424
|
-
services?: {
|
|
1425
|
-
service: string;
|
|
1426
|
-
amount_cents: number;
|
|
1427
|
-
}[] | null | undefined;
|
|
1428
|
-
amount_total_cents?: number | undefined;
|
|
1429
|
-
description?: string | null | undefined;
|
|
1430
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1431
|
-
occurred_at?: string | undefined;
|
|
1432
|
-
items?: {
|
|
1433
|
-
quantity: string;
|
|
1434
|
-
unit_price_cents: number;
|
|
1435
|
-
name?: string | null | undefined;
|
|
1436
|
-
external_item_id?: string | null | undefined;
|
|
1437
|
-
category?: string | null | undefined;
|
|
1438
|
-
unit_cost_cents?: number | null | undefined;
|
|
1439
|
-
}[] | undefined;
|
|
1440
|
-
customer_name?: string | null | undefined;
|
|
1441
|
-
customer_phone?: string | null | undefined;
|
|
1442
|
-
customer_email?: string | null | undefined;
|
|
1443
|
-
}, {
|
|
1444
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1445
|
-
service?: string | null | undefined;
|
|
1446
|
-
services?: {
|
|
1447
|
-
service: string;
|
|
1448
|
-
amount_cents: number;
|
|
1449
|
-
}[] | null | undefined;
|
|
1450
|
-
amount_total_cents?: number | undefined;
|
|
1451
|
-
description?: string | null | undefined;
|
|
1452
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1453
|
-
occurred_at?: string | undefined;
|
|
1454
|
-
items?: {
|
|
1455
|
-
quantity: string;
|
|
1456
|
-
unit_price_cents: number;
|
|
1457
|
-
name?: string | null | undefined;
|
|
1458
|
-
external_item_id?: string | null | undefined;
|
|
1459
|
-
category?: string | null | undefined;
|
|
1460
|
-
unit_cost_cents?: number | null | undefined;
|
|
1461
|
-
}[] | undefined;
|
|
1462
|
-
customer_name?: string | null | undefined;
|
|
1463
|
-
customer_phone?: string | null | undefined;
|
|
1464
|
-
customer_email?: string | null | undefined;
|
|
1465
|
-
}>, {
|
|
1466
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1467
|
-
service?: string | null | undefined;
|
|
1468
|
-
services?: {
|
|
1469
|
-
service: string;
|
|
1470
|
-
amount_cents: number;
|
|
1471
|
-
}[] | null | undefined;
|
|
1472
|
-
amount_total_cents?: number | undefined;
|
|
1473
|
-
description?: string | null | undefined;
|
|
1474
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1475
|
-
occurred_at?: string | undefined;
|
|
1476
|
-
items?: {
|
|
1477
|
-
quantity: string;
|
|
1478
|
-
unit_price_cents: number;
|
|
1479
|
-
name?: string | null | undefined;
|
|
1480
|
-
external_item_id?: string | null | undefined;
|
|
1481
|
-
category?: string | null | undefined;
|
|
1482
|
-
unit_cost_cents?: number | null | undefined;
|
|
1483
|
-
}[] | undefined;
|
|
1484
|
-
customer_name?: string | null | undefined;
|
|
1485
|
-
customer_phone?: string | null | undefined;
|
|
1486
|
-
customer_email?: string | null | undefined;
|
|
1487
|
-
}, {
|
|
1488
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1489
|
-
service?: string | null | undefined;
|
|
1490
|
-
services?: {
|
|
1491
|
-
service: string;
|
|
1492
|
-
amount_cents: number;
|
|
1493
|
-
}[] | null | undefined;
|
|
1494
|
-
amount_total_cents?: number | undefined;
|
|
1495
|
-
description?: string | null | undefined;
|
|
1496
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1497
|
-
occurred_at?: string | undefined;
|
|
1498
|
-
items?: {
|
|
1499
|
-
quantity: string;
|
|
1500
|
-
unit_price_cents: number;
|
|
1501
|
-
name?: string | null | undefined;
|
|
1502
|
-
external_item_id?: string | null | undefined;
|
|
1503
|
-
category?: string | null | undefined;
|
|
1504
|
-
unit_cost_cents?: number | null | undefined;
|
|
1505
|
-
}[] | undefined;
|
|
1506
|
-
customer_name?: string | null | undefined;
|
|
1507
|
-
customer_phone?: string | null | undefined;
|
|
1508
|
-
customer_email?: string | null | undefined;
|
|
1509
|
-
}>;
|
|
1510
|
-
type SaleItemInput = z.input<typeof saleItemSchema>;
|
|
1511
|
-
type SaleServiceInput = z.input<typeof saleServiceSchema>;
|
|
1512
|
-
type SaleInput = z.input<typeof saleCreateSchema>;
|
|
1513
|
-
type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
|
|
1514
|
-
interface SaleItem {
|
|
1515
|
-
id: string;
|
|
1516
|
-
external_item_id: string | null;
|
|
1517
|
-
name: string | null;
|
|
1518
|
-
category: string | null;
|
|
1519
|
-
quantity: string;
|
|
1520
|
-
unit_price_cents: number;
|
|
1521
|
-
unit_cost_cents: number | null;
|
|
1522
|
-
}
|
|
1523
|
-
interface SaleService {
|
|
1524
|
-
id: string;
|
|
1525
|
-
service_id: string;
|
|
1526
|
-
service_key: string;
|
|
1527
|
-
service_label: string;
|
|
1528
|
-
amount_cents: number;
|
|
1529
|
-
}
|
|
1530
|
-
interface Sale {
|
|
1531
|
-
id: string;
|
|
1532
|
-
business_id: string;
|
|
1533
|
-
business_name?: string | null;
|
|
1534
|
-
external_id: string | null;
|
|
1535
|
-
currency: SupportedCurrency;
|
|
1536
|
-
amount_total_cents: number;
|
|
1537
|
-
description: string | null;
|
|
1538
|
-
service_id: string | null;
|
|
1539
|
-
service_key?: string | null;
|
|
1540
|
-
service_label?: string | null;
|
|
1541
|
-
services: SaleService[];
|
|
1542
|
-
occurred_at: string;
|
|
1543
|
-
environment: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1544
|
-
metadata: Record<string, unknown> | null;
|
|
1545
|
-
customer_name: string | null;
|
|
1546
|
-
customer_phone: string | null;
|
|
1547
|
-
customer_email: string | null;
|
|
1548
|
-
created_at: string;
|
|
1549
|
-
updated_at: string;
|
|
1550
|
-
items: SaleItem[];
|
|
1551
|
-
}
|
|
1552
|
-
interface SaleListPage {
|
|
1553
|
-
items: Sale[];
|
|
1554
|
-
total: number;
|
|
1555
|
-
}
|
|
1556
|
-
interface SaleCursorPage {
|
|
1557
|
-
items: Sale[];
|
|
1558
|
-
next_cursor: string | null;
|
|
1559
|
-
/** Populated only when `want_total` was requested (a single indexed COUNT). */
|
|
1560
|
-
total_count?: number;
|
|
1561
|
-
has_more?: boolean;
|
|
1562
|
-
}
|
|
1563
|
-
type SaleSortOrder = 'asc' | 'desc';
|
|
1564
|
-
/**
|
|
1565
|
-
* Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
|
|
1566
|
-
*
|
|
1567
|
-
* `search` runs case-insensitively across `customer_name`, `customer_phone`,
|
|
1568
|
-
* `customer_email`, `description`, and `external_id` — the human-facing
|
|
1569
|
-
* columns. `service_id` is the resolved per-business service UUID (different
|
|
1570
|
-
* from the create-time `service` *key*).
|
|
1571
|
-
*/
|
|
1572
|
-
interface SaleFilters {
|
|
1573
|
-
business_id?: string;
|
|
1574
|
-
external_id?: string;
|
|
1575
|
-
service_id?: string;
|
|
1576
|
-
/** E.164 phone — the canonical customer key; filters sales for one customer. */
|
|
1577
|
-
customer_phone?: string;
|
|
1578
|
-
currency?: SupportedCurrency;
|
|
1579
|
-
environment?: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1580
|
-
since?: string;
|
|
1581
|
-
until?: string;
|
|
1582
|
-
min_amount_cents?: number;
|
|
1583
|
-
max_amount_cents?: number;
|
|
1584
|
-
search?: string;
|
|
1585
|
-
}
|
|
1586
|
-
/**
|
|
1587
|
-
* Full query input for `SalesClient.list()` — filters + pagination.
|
|
1588
|
-
*
|
|
1589
|
-
* Pagination is **keyset (cursor)**: `next_cursor` returned by one page is
|
|
1590
|
-
* passed back as `cursor` on the next. `null` / undefined cursor = first page.
|
|
1591
|
-
*
|
|
1592
|
-
* Ordering on this endpoint is fixed at **`occurred_at DESC, id DESC`** — the
|
|
1593
|
-
* cursor encodes a position in that index, so a different sort would
|
|
1594
|
-
* invalidate cursors mid-pagination. For ad-hoc sorted reads use the
|
|
1595
|
-
* dashboard admin endpoint, which is offset-paginated.
|
|
1596
|
-
*/
|
|
1597
|
-
interface SaleListQuery extends SaleFilters {
|
|
1598
|
-
limit?: number;
|
|
1599
|
-
cursor?: string | null;
|
|
1600
|
-
}
|
|
1601
|
-
/** Keyset-safe sort columns (NOT-NULL, indexed). */
|
|
1602
|
-
type SaleKeysetSortField = 'occurred_at' | 'created_at' | 'amount_total_cents';
|
|
1603
|
-
/** v2 list query — adds server sort + opt-in total. */
|
|
1604
|
-
interface SaleListQueryV2 extends SaleListQuery {
|
|
1605
|
-
sort?: SaleKeysetSortField;
|
|
1606
|
-
order?: SaleSortOrder;
|
|
1607
|
-
/** Opt-in: a single indexed COUNT over the filtered set. */
|
|
1608
|
-
want_total?: boolean;
|
|
1609
|
-
}
|
|
1610
|
-
declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
|
|
1611
|
-
type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
|
|
1612
|
-
/** Query input for `SalesClient.summary()` — filters + range + options. */
|
|
1613
|
-
interface SaleSummaryQuery extends SaleFilters {
|
|
1614
|
-
range: TrackingOverviewRange;
|
|
1615
|
-
/** Include the per-category line-item breakdown (extra join; default false). */
|
|
1616
|
-
include_categories?: boolean;
|
|
1617
|
-
/** Surface soft-deleted services individually (flagged "(deleted)") instead of
|
|
1618
|
-
* rolling them into a single "Deleted services" bucket. Default false. */
|
|
1619
|
-
include_deleted_services?: boolean;
|
|
1620
|
-
/** Cap on the by-service / by-category rows (1–50, default 10). */
|
|
1621
|
-
top_n?: number;
|
|
1622
|
-
}
|
|
1623
|
-
interface CurrencyRevenue {
|
|
1624
|
-
currency: SupportedCurrency;
|
|
1625
|
-
sale_count: number;
|
|
1626
|
-
revenue_cents: number;
|
|
1627
|
-
average_order_value_cents: number;
|
|
1628
|
-
}
|
|
1629
|
-
interface SalesServiceBreakdown {
|
|
1630
|
-
service_id: string | null;
|
|
1631
|
-
service_key: string | null;
|
|
1632
|
-
/** "Unassigned" when the sale has no service. */
|
|
1633
|
-
service_label: string | null;
|
|
1634
|
-
currency: SupportedCurrency;
|
|
1635
|
-
sale_count: number;
|
|
1636
|
-
revenue_cents: number;
|
|
1637
|
-
}
|
|
1638
|
-
interface SalesCategoryBreakdown {
|
|
1639
|
-
category: string | null;
|
|
1640
|
-
currency: SupportedCurrency;
|
|
1641
|
-
/** sum(unit_price_cents * quantity) — advisory, not authoritative. */
|
|
1642
|
-
revenue_cents: number;
|
|
1643
|
-
/** Decimal string. */
|
|
1644
|
-
quantity: string;
|
|
1645
|
-
}
|
|
1646
|
-
interface SalesTrendPoint {
|
|
1647
|
-
bucket_start: string;
|
|
1648
|
-
currency: SupportedCurrency;
|
|
1649
|
-
sale_count: number;
|
|
1650
|
-
revenue_cents: number;
|
|
1651
|
-
}
|
|
1652
|
-
interface SaleSummary {
|
|
1653
|
-
range: TrackingOverviewRange;
|
|
1654
|
-
business_id: string | null;
|
|
1655
|
-
metrics: {
|
|
1656
|
-
sale_count: number;
|
|
1657
|
-
distinct_customers: number;
|
|
1658
|
-
by_currency: CurrencyRevenue[];
|
|
1659
|
-
};
|
|
1660
|
-
by_service: SalesServiceBreakdown[];
|
|
1661
|
-
by_currency: CurrencyRevenue[];
|
|
1662
|
-
by_category: SalesCategoryBreakdown[];
|
|
1663
|
-
series: SalesTrendPoint[];
|
|
1664
|
-
}
|
|
1665
|
-
declare const NAMED_RANGES: readonly ["today", "yesterday", "wtd", "mtd", "qtd", "ytd", "24h", "7d", "30d", "90d", "custom"];
|
|
1666
|
-
/** Superset of `TrackingOverviewRange` (`24h`/`7d`/`30d` stay valid). */
|
|
1667
|
-
type NamedRange = (typeof NAMED_RANGES)[number];
|
|
1668
|
-
type Granularity = 'hour' | 'day' | 'week' | 'month' | 'auto';
|
|
1669
|
-
type CompareTo = 'previous_period' | 'previous_year' | 'none';
|
|
1670
|
-
interface DistinctCustomersByCurrency {
|
|
1671
|
-
currency: SupportedCurrency;
|
|
1672
|
-
distinct_customers: number;
|
|
1673
|
-
}
|
|
1674
|
-
interface SummaryWindow {
|
|
1675
|
-
since: string;
|
|
1676
|
-
until: string;
|
|
1677
|
-
}
|
|
1678
|
-
interface SummaryCurrencyDelta {
|
|
1679
|
-
currency: SupportedCurrency;
|
|
1680
|
-
revenue_cents_delta: number;
|
|
1681
|
-
/** Ratio (0.12 = +12%); null when previous revenue was 0. */
|
|
1682
|
-
revenue_pct_delta: number | null;
|
|
1683
|
-
sale_count_delta: number;
|
|
1684
|
-
}
|
|
1685
|
-
interface SummaryDeltas {
|
|
1686
|
-
by_currency: SummaryCurrencyDelta[];
|
|
1687
|
-
sale_count_delta: number;
|
|
1688
|
-
distinct_customers_delta: number;
|
|
1689
|
-
}
|
|
1690
|
-
interface SaleSummaryPrevious {
|
|
1691
|
-
window: SummaryWindow;
|
|
1692
|
-
metrics: SaleSummaryV2['metrics'];
|
|
1693
|
-
by_currency: CurrencyRevenue[];
|
|
1694
|
-
series: SalesTrendPoint[];
|
|
1695
|
-
}
|
|
1696
|
-
/** Query input for `SalesClient.summary()` v2 — widened range + tz/compare options. */
|
|
1697
|
-
interface SaleSummaryQueryV2 extends SaleFilters {
|
|
1698
|
-
range?: NamedRange;
|
|
1699
|
-
/** Required when `range === 'custom'`. */
|
|
1700
|
-
since?: string;
|
|
1701
|
-
until?: string;
|
|
1702
|
-
/** IANA tz, e.g. `America/Toronto`. Default = business tz. */
|
|
1703
|
-
timezone?: string;
|
|
1704
|
-
granularity?: Granularity;
|
|
1705
|
-
compare_to?: CompareTo;
|
|
1706
|
-
include_categories?: boolean;
|
|
1707
|
-
include_deleted_services?: boolean;
|
|
1708
|
-
top_n?: number;
|
|
1709
|
-
}
|
|
1710
|
-
/** Superset of `SaleSummary` (assignable to it). */
|
|
1711
|
-
interface SaleSummaryV2 extends Omit<SaleSummary, 'range' | 'metrics'> {
|
|
1712
|
-
range: NamedRange;
|
|
1713
|
-
metrics: SaleSummary['metrics'] & {
|
|
1714
|
-
distinct_customers_by_currency: DistinctCustomersByCurrency[];
|
|
1715
|
-
};
|
|
1716
|
-
timezone: string | null;
|
|
1717
|
-
window: SummaryWindow | null;
|
|
1718
|
-
granularity: string | null;
|
|
1719
|
-
previous: SaleSummaryPrevious | null;
|
|
1720
|
-
deltas: SummaryDeltas | null;
|
|
1721
|
-
}
|
|
1722
|
-
type CustomerSegment = 'new' | 'returning' | 'repeat' | 'lapsed';
|
|
1723
|
-
type CustomerSortField = 'total_spent' | 'last_purchase' | 'purchases' | 'first_purchase';
|
|
1724
|
-
interface CustomerCurrencyTotal {
|
|
1725
|
-
currency: SupportedCurrency;
|
|
1726
|
-
revenue_cents: number;
|
|
1727
|
-
sale_count: number;
|
|
1728
|
-
average_order_value_cents: number;
|
|
1729
|
-
}
|
|
1730
|
-
interface CustomerSummary {
|
|
1731
|
-
/** The E.164 phone — the canonical customer id. */
|
|
1732
|
-
customer_id: string;
|
|
1733
|
-
display_name: string | null;
|
|
1734
|
-
email: string | null;
|
|
1735
|
-
phone: string;
|
|
1736
|
-
first_purchase_at: string;
|
|
1737
|
-
last_purchase_at: string;
|
|
1738
|
-
purchase_count: number;
|
|
1739
|
-
segment: CustomerSegment;
|
|
1740
|
-
totals: CustomerCurrencyTotal[];
|
|
1741
|
-
}
|
|
1742
|
-
type CustomerProfile = CustomerSummary;
|
|
1743
|
-
interface CustomerListQuery extends Omit<SaleFilters, 'external_id'> {
|
|
1744
|
-
segment?: CustomerSegment;
|
|
1745
|
-
sort?: CustomerSortField;
|
|
1746
|
-
order?: SaleSortOrder;
|
|
1747
|
-
cursor?: string | null;
|
|
1748
|
-
limit?: number;
|
|
1749
|
-
want_total?: boolean;
|
|
1750
|
-
}
|
|
1751
|
-
interface CustomerListPage {
|
|
1752
|
-
items: CustomerSummary[];
|
|
1753
|
-
next_cursor: string | null;
|
|
1754
|
-
total_count: number | null;
|
|
1755
|
-
}
|
|
1756
|
-
interface CustomerGetOptions {
|
|
1757
|
-
include_sales?: boolean;
|
|
1758
|
-
limit?: number;
|
|
1759
|
-
cursor?: string | null;
|
|
1760
|
-
}
|
|
1761
|
-
interface CustomerGetResult {
|
|
1762
|
-
customer: CustomerProfile;
|
|
1763
|
-
/** Present only when `include_sales: true` (and a business-scoped key). */
|
|
1764
|
-
sales?: SaleCursorPage | null;
|
|
1765
|
-
}
|
|
1766
|
-
interface CustomerSummaryQuery extends SaleFilters {
|
|
1767
|
-
range?: NamedRange;
|
|
1768
|
-
since?: string;
|
|
1769
|
-
until?: string;
|
|
1770
|
-
timezone?: string;
|
|
1771
|
-
compare_to?: CompareTo;
|
|
1772
|
-
}
|
|
1773
|
-
interface CustomerSegmentCount {
|
|
1774
|
-
segment: CustomerSegment;
|
|
1775
|
-
count: number;
|
|
1776
|
-
}
|
|
1777
|
-
interface CustomerCurrencyDelta {
|
|
1778
|
-
currency: SupportedCurrency;
|
|
1779
|
-
revenue_cents_delta: number;
|
|
1780
|
-
/** Ratio (0.12 = +12%); null when previous revenue was 0. */
|
|
1781
|
-
revenue_pct_delta: number | null;
|
|
1782
|
-
}
|
|
1783
|
-
interface CustomerKpisDeltas {
|
|
1784
|
-
total_customers_delta: number;
|
|
1785
|
-
new_customers_delta: number;
|
|
1786
|
-
returning_customers_delta: number;
|
|
1787
|
-
repeat_rate_delta: number;
|
|
1788
|
-
ltv_by_currency: CustomerCurrencyDelta[];
|
|
1789
|
-
}
|
|
1790
|
-
interface CustomerKpisPrevious {
|
|
1791
|
-
window_since: string;
|
|
1792
|
-
window_until: string;
|
|
1793
|
-
total_customers: number;
|
|
1794
|
-
new_customers: number;
|
|
1795
|
-
returning_customers: number;
|
|
1796
|
-
repeat_rate: number;
|
|
1797
|
-
ltv_by_currency: CustomerCurrencyTotal[];
|
|
1798
|
-
}
|
|
1799
|
-
interface CustomerKpis {
|
|
1800
|
-
range: NamedRange;
|
|
1801
|
-
timezone: string;
|
|
1802
|
-
window_since: string;
|
|
1803
|
-
window_until: string;
|
|
1804
|
-
total_customers: number;
|
|
1805
|
-
new_customers: number;
|
|
1806
|
-
returning_customers: number;
|
|
1807
|
-
repeat_rate: number;
|
|
1808
|
-
by_segment: CustomerSegmentCount[];
|
|
1809
|
-
ltv_by_currency: CustomerCurrencyTotal[];
|
|
1810
|
-
/** Present only when `compare_to` is set. */
|
|
1811
|
-
previous?: CustomerKpisPrevious | null;
|
|
1812
|
-
deltas?: CustomerKpisDeltas | null;
|
|
1813
|
-
}
|
|
1814
|
-
interface BusinessConfigService {
|
|
1815
|
-
key: string;
|
|
1816
|
-
label: string;
|
|
1817
|
-
archived: boolean;
|
|
1818
|
-
}
|
|
1819
|
-
interface BusinessConfigFeatures {
|
|
1820
|
-
customers: boolean;
|
|
1821
|
-
comparisons: boolean;
|
|
1822
|
-
retention: boolean;
|
|
1823
|
-
}
|
|
1824
|
-
interface BusinessConfig {
|
|
1825
|
-
business_id: string;
|
|
1826
|
-
display_name: string;
|
|
1827
|
-
timezone: string;
|
|
1828
|
-
primary_currency: SupportedCurrency;
|
|
1829
|
-
currencies: SupportedCurrency[];
|
|
1830
|
-
default_phone_country: string | null;
|
|
1831
|
-
services: BusinessConfigService[];
|
|
1832
|
-
features: BusinessConfigFeatures;
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
/** Shared config for every sales HTTP helper. */
|
|
1836
|
-
interface SalesTransportConfig {
|
|
1837
|
-
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
1838
|
-
apiKey: string;
|
|
1839
|
-
/**
|
|
1840
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
1841
|
-
* The `/sales` path is appended by the helpers.
|
|
1842
|
-
*/
|
|
1843
|
-
endpoint: string;
|
|
1844
|
-
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
1845
|
-
sdkVersion?: string;
|
|
1846
|
-
packageName?: string;
|
|
1847
|
-
surface?: string;
|
|
1848
|
-
environment?: string;
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
/** Config for {@link createSalesClient}. */
|
|
1852
|
-
interface SalesClientConfig extends SalesTransportConfig {
|
|
1853
|
-
/** Applied when an individual `record()` call omits `currency`. */
|
|
1854
|
-
defaultCurrency?: SupportedCurrency;
|
|
1855
|
-
}
|
|
1856
|
-
/** Phone-keyed customer rollups (sk-only; a public key gets a `403`). */
|
|
1857
|
-
interface SalesCustomersClient {
|
|
1858
|
-
list(query?: CustomerListQuery): Promise<CustomerListPage>;
|
|
1859
|
-
/** `id` is the customer's E.164 phone. */
|
|
1860
|
-
get(id: string, options?: CustomerGetOptions): Promise<CustomerGetResult>;
|
|
1861
|
-
summary(query?: CustomerSummaryQuery): Promise<CustomerKpis>;
|
|
1862
|
-
}
|
|
1863
|
-
/** Business config (low-sensitivity — accepts a public or secret key). */
|
|
1864
|
-
interface SalesBusinessClient {
|
|
1865
|
-
config(): Promise<BusinessConfig>;
|
|
1866
|
-
}
|
|
1867
|
-
/**
|
|
1868
|
-
* One isomorphic sales client — what a key may *do* is enforced by the backend,
|
|
1869
|
-
* not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
|
|
1870
|
-
* backend rejects reads/CRUD from it with a `403`); a **secret** key
|
|
1871
|
-
* (`aranv_sk_…`), used **server-side only**, gets full read/list/update/delete.
|
|
1872
|
-
* Never ship a secret key in a browser bundle.
|
|
1873
|
-
*
|
|
1874
|
-
* Generic over the service-key union `TService`: bind the type emitted by
|
|
1875
|
-
* `@aranova/tracking-cli gen` for compile-time-checked `service` values.
|
|
1876
|
-
*/
|
|
1877
|
-
interface SalesClient<TService extends string = string> {
|
|
1878
|
-
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
|
|
1879
|
-
service?: TService | null;
|
|
1880
|
-
services?: Array<{
|
|
1881
|
-
service: TService;
|
|
1882
|
-
amount_cents: number;
|
|
1883
|
-
}>;
|
|
1884
|
-
currency?: SupportedCurrency;
|
|
1885
|
-
occurred_at?: string;
|
|
1886
|
-
}): Promise<Sale>;
|
|
1887
|
-
/** Keyset list with optional server sort + opt-in `total_count`. */
|
|
1888
|
-
list(query?: SaleListQueryV2): Promise<SaleCursorPage>;
|
|
1889
|
-
/**
|
|
1890
|
-
* Currency-grouped aggregations for the key's business. Additive v2 options:
|
|
1891
|
-
* calendar/custom ranges, IANA `timezone`, `granularity`, and `compare_to`.
|
|
1892
|
-
* Legacy `24h/7d/30d` keep their exact prior numbers. Secret key only.
|
|
1893
|
-
*/
|
|
1894
|
-
summary(query: SaleSummaryQueryV2): Promise<SaleSummaryV2>;
|
|
1895
|
-
get(id: string): Promise<Sale>;
|
|
1896
|
-
update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
|
|
1897
|
-
service?: TService | null;
|
|
1898
|
-
services?: Array<{
|
|
1899
|
-
service: TService;
|
|
1900
|
-
amount_cents: number;
|
|
1901
|
-
}>;
|
|
1902
|
-
}): Promise<Sale>;
|
|
1903
|
-
delete(id: string): Promise<void>;
|
|
1904
|
-
/** Phone-keyed customer rollups (sk-only). */
|
|
1905
|
-
customers: SalesCustomersClient;
|
|
1906
|
-
/** Business config (pk or sk). */
|
|
1907
|
-
business: SalesBusinessClient;
|
|
1908
|
-
}
|
|
1909
|
-
declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
|
|
1910
|
-
|
|
1911
|
-
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
1912
|
-
interface PublicServiceItem {
|
|
1913
|
-
key: string;
|
|
1914
|
-
label: string;
|
|
1915
|
-
}
|
|
1916
|
-
/**
|
|
1917
|
-
* Fetch the caller's business's active service taxonomy. Accepts a public or
|
|
1918
|
-
* secret key (the taxonomy is low-sensitivity category names). Powers the
|
|
1919
|
-
* `@aranova/tracking-cli gen` codegen.
|
|
1920
|
-
*/
|
|
1921
|
-
declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
|
|
1922
|
-
|
|
1923
|
-
/**
|
|
1924
|
-
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
1925
|
-
*
|
|
1926
|
-
* Convenience only — the wire is always integer cents. Uses float multiply +
|
|
1927
|
-
* `Math.round`, so values that aren't exactly representable in binary float
|
|
1928
|
-
* (e.g. `1.005`) can round to the neighbouring cent. If you already hold an
|
|
1929
|
-
* exact cents integer, pass it straight through and skip this helper.
|
|
1930
|
-
*/
|
|
1931
|
-
declare function toMinor(amount: number, currency: SupportedCurrency): number;
|
|
1932
|
-
/** Convert integer minor units (`25050`) to a major amount (`250.5`). */
|
|
1933
|
-
declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
1934
|
-
/**
|
|
1935
|
-
* Format integer minor units as a localized currency string (e.g. `"$250.50"`).
|
|
1936
|
-
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
1937
|
-
*/
|
|
1938
|
-
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
1939
|
-
/**
|
|
1940
|
-
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
1941
|
-
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
1942
|
-
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
1943
|
-
*/
|
|
1944
|
-
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
1945
|
-
|
|
1946
|
-
/**
|
|
1947
|
-
* Error thrown by the sales client (`createSalesClient`) on a
|
|
1948
|
-
* non-2xx response. Unlike the fire-and-forget event queue (which swallows
|
|
1949
|
-
* failures), a sale is a transaction the caller must be able to react to.
|
|
1950
|
-
*/
|
|
1951
|
-
declare class AranovaApiError extends Error {
|
|
1952
|
-
readonly status: number;
|
|
1953
|
-
readonly code: string | undefined;
|
|
1954
|
-
readonly requestId: string | undefined;
|
|
1955
|
-
constructor(message: string, options: {
|
|
1956
|
-
status: number;
|
|
1957
|
-
code?: string;
|
|
1958
|
-
requestId?: string;
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
1231
|
/**
|
|
1963
1232
|
* Props for the Google Ads tracking component.
|
|
1964
1233
|
*
|
|
@@ -2110,16 +1379,6 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
|
|
|
2110
1379
|
}
|
|
2111
1380
|
declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
|
|
2112
1381
|
|
|
2113
|
-
/** Carries `createTracking({ phone })` config to `usePhoneField`. Separate from the
|
|
2114
|
-
* tracking client context so `useTracking()`'s type is untouched.
|
|
2115
|
-
*
|
|
2116
|
-
* Caveat: this module is bundled into BOTH `@aranova/tracking-react` and
|
|
2117
|
-
* `@aranova/tracking-next`, so each package has its own context instance at
|
|
2118
|
-
* runtime. Within one installed package the provider + hook share it (correct);
|
|
2119
|
-
* mixing `createTracking` from one package with `usePhoneField` from the other
|
|
2120
|
-
* won't share config (the hook falls back to the `CA`/`national` defaults). Use a
|
|
2121
|
-
* single tracking package per app. */
|
|
2122
|
-
declare const PhoneConfigContext: react.Context<PhoneConfig | null>;
|
|
2123
1382
|
/** Resolve the effective phone config (provider value or built-in defaults). */
|
|
2124
1383
|
declare function usePhoneConfig(): {
|
|
2125
1384
|
defaultCountry: CountryCode;
|
|
@@ -2138,9 +1397,9 @@ interface PhoneInputProps {
|
|
|
2138
1397
|
value: string;
|
|
2139
1398
|
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
2140
1399
|
onBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
2141
|
-
type:
|
|
2142
|
-
inputMode:
|
|
2143
|
-
autoComplete:
|
|
1400
|
+
type: "tel";
|
|
1401
|
+
inputMode: "tel";
|
|
1402
|
+
autoComplete: "tel";
|
|
2144
1403
|
}
|
|
2145
1404
|
interface PhoneFieldApi {
|
|
2146
1405
|
/** Display value for the `<input>` (live `AsYouType` while typing). */
|
|
@@ -2156,7 +1415,7 @@ interface PhoneFieldApi {
|
|
|
2156
1415
|
}
|
|
2157
1416
|
/** Headless phone field — the client owns the markup. */
|
|
2158
1417
|
declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
|
|
2159
|
-
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
1418
|
+
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> {
|
|
2160
1419
|
country?: CountryCode;
|
|
2161
1420
|
/** Controlled display value. */
|
|
2162
1421
|
value?: string;
|
|
@@ -2177,4 +1436,4 @@ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 't
|
|
|
2177
1436
|
*/
|
|
2178
1437
|
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
2179
1438
|
|
|
2180
|
-
export {
|
|
1439
|
+
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getConsentState, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, resetConsent, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, setConsentState, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|