@aranova/tracking-next 0.12.0 → 0.12.2
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 +58 -49
- package/dist/index.d.mts +61 -802
- package/dist/index.d.ts +61 -802
- package/dist/index.js +177 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -61
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.js +98 -0
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +98 -0
- package/dist/middleware.mjs.map +1 -1
- package/dist/{phone-utils-DZ0Ger64.d.mts → phone-utils-BVUDHwo4.d.mts} +14 -9
- package/dist/{phone-utils-DZ0Ger64.d.ts → phone-utils-BVUDHwo4.d.ts} +14 -9
- 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/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +98 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +98 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +46 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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-
|
|
2
|
-
export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as
|
|
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-BVUDHwo4.mjs';
|
|
2
|
+
export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formSubmitConfigSchema, l as formSubmitMetadataSchema, m as formatPhone, n as formatPhoneAsTyped, o as jsonValueSchema, p as parsePhone, q as phoneField, t as toE164 } from './phone-utils-BVUDHwo4.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as src from 'src';
|
|
5
|
+
export { AranovaApiError, BusinessConfig, BusinessConfigFeatures, BusinessConfigService, CompareTo, CurrencyRevenue, CustomerCurrencyDelta, CustomerCurrencyTotal, CustomerGetOptions, CustomerGetResult, CustomerKpis, CustomerKpisDeltas, CustomerKpisPrevious, CustomerListPage, CustomerListQuery, CustomerProfile, CustomerSegment, CustomerSegmentCount, CustomerSortField, CustomerSummary, CustomerSummaryQuery, DistinctCustomersByCurrency, Granularity, NAMED_RANGES, NamedRange, PublicServiceItem, SUPPORTED_CURRENCIES, Sale, SaleCursorPage, SaleFilters, SaleInput, SaleItem, SaleItemInput, SaleKeysetSortField, SaleListPage, SaleListQuery, SaleListQueryV2, SaleService, SaleServiceInput, SaleSortField, SaleSortOrder, SaleSummary, SaleSummaryPrevious, SaleSummaryQuery, SaleSummaryQueryV2, SaleSummaryV2, SaleUpdateInput, SalesBusinessClient, SalesCategoryBreakdown, SalesClient, SalesClientConfig, SalesCustomersClient, SalesServiceBreakdown, SalesTransportConfig, SalesTrendPoint, SummaryCurrencyDelta, SummaryDeltas, SummaryWindow, SupportedCurrency, TRACKING_RANGES, TrackingOverviewRange, createSalesClient, fetchServices, formatDateInTz, formatMoney, fromMinor, saleCreateSchema, saleItemSchema, saleServiceSchema, saleUpdateSchema, salesRequest, toMinor } from './sales.mjs';
|
|
5
6
|
import * as react from 'react';
|
|
6
7
|
import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
|
|
7
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -11,7 +12,7 @@ export { CountryCode } from 'libphonenumber-js';
|
|
|
11
12
|
/**
|
|
12
13
|
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
13
14
|
*/
|
|
14
|
-
type GtagConsentValue =
|
|
15
|
+
type GtagConsentValue = "granted" | "denied";
|
|
15
16
|
/**
|
|
16
17
|
* Read the persisted visitor consent state from localStorage.
|
|
17
18
|
*
|
|
@@ -128,6 +129,19 @@ type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
|
|
|
128
129
|
declare const ctaClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
129
130
|
type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
|
|
130
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Registered trigger names reported by the SDK heartbeat.
|
|
134
|
+
*/
|
|
135
|
+
declare const sdkHeartbeatTriggersSchema: z.ZodObject<{
|
|
136
|
+
automatic: z.ZodArray<z.ZodString, "many">;
|
|
137
|
+
manual: z.ZodArray<z.ZodString, "many">;
|
|
138
|
+
}, "strict", z.ZodTypeAny, {
|
|
139
|
+
automatic: string[];
|
|
140
|
+
manual: string[];
|
|
141
|
+
}, {
|
|
142
|
+
automatic: string[];
|
|
143
|
+
manual: string[];
|
|
144
|
+
}>;
|
|
131
145
|
/**
|
|
132
146
|
* Metadata for the SDK-internal `sdk_heartbeat` event.
|
|
133
147
|
*
|
|
@@ -430,6 +444,7 @@ type ScrollDepthConfig = z.infer<typeof scrollDepthConfigSchema>;
|
|
|
430
444
|
*/
|
|
431
445
|
declare const SPECIFIC_PAGE_NAMES: readonly ["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"];
|
|
432
446
|
type SpecificPageName = (typeof SPECIFIC_PAGE_NAMES)[number];
|
|
447
|
+
declare const specificPageNameSchema: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
|
|
433
448
|
/**
|
|
434
449
|
* Metadata for the automatic `specific_page_visit` event.
|
|
435
450
|
*
|
|
@@ -526,6 +541,7 @@ declare const timeOnSiteConfigSchema: z.ZodObject<{
|
|
|
526
541
|
}>;
|
|
527
542
|
type TimeOnSiteConfig = z.infer<typeof timeOnSiteConfigSchema>;
|
|
528
543
|
|
|
544
|
+
type EventKind = "automatic" | "manual";
|
|
529
545
|
declare const EVENT_REGISTRY: {
|
|
530
546
|
readonly page_view: {
|
|
531
547
|
readonly kind: "automatic";
|
|
@@ -952,13 +968,13 @@ type EventName = keyof typeof EVENT_REGISTRY;
|
|
|
952
968
|
* Automatic events are not accepted by the typed `trackEvent()` API.
|
|
953
969
|
*/
|
|
954
970
|
type AutomaticEventName = {
|
|
955
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
971
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "automatic" ? K : never;
|
|
956
972
|
}[EventName];
|
|
957
973
|
/**
|
|
958
974
|
* Event names that consumer code can fire manually after registering them.
|
|
959
975
|
*/
|
|
960
976
|
type ManualEventName = {
|
|
961
|
-
[K in EventName]: (typeof EVENT_REGISTRY)[K][
|
|
977
|
+
[K in EventName]: (typeof EVENT_REGISTRY)[K]["kind"] extends "manual" ? K : never;
|
|
962
978
|
}[EventName];
|
|
963
979
|
type MetadataByName = {
|
|
964
980
|
page_view: PageViewMetadata;
|
|
@@ -997,6 +1013,14 @@ type EventMetadata<K extends EventName> = MetadataByName[K];
|
|
|
997
1013
|
* Trigger registration config type for a specific tracking event.
|
|
998
1014
|
*/
|
|
999
1015
|
type EventConfig<K extends EventName> = ConfigByName[K];
|
|
1016
|
+
/**
|
|
1017
|
+
* Runtime list of automatic event names.
|
|
1018
|
+
*/
|
|
1019
|
+
declare const ALL_AUTOMATIC_EVENT_NAMES: readonly AutomaticEventName[];
|
|
1020
|
+
/**
|
|
1021
|
+
* Runtime list of manual event names.
|
|
1022
|
+
*/
|
|
1023
|
+
declare const ALL_MANUAL_EVENT_NAMES: readonly ManualEventName[];
|
|
1000
1024
|
/**
|
|
1001
1025
|
* Trigger registry passed to `createTracking({ triggers })`.
|
|
1002
1026
|
*
|
|
@@ -1024,18 +1048,18 @@ type EventConfig<K extends EventName> = ConfigByName[K];
|
|
|
1024
1048
|
*/
|
|
1025
1049
|
type TriggerRegistryConfig = {
|
|
1026
1050
|
automatic: {
|
|
1027
|
-
page_view: EventConfig<
|
|
1051
|
+
page_view: EventConfig<"page_view">;
|
|
1028
1052
|
} & Partial<{
|
|
1029
|
-
time_on_site: EventConfig<
|
|
1030
|
-
specific_page_visit: EventConfig<
|
|
1031
|
-
scroll_depth: EventConfig<
|
|
1032
|
-
multi_page_session: EventConfig<
|
|
1033
|
-
form_start: EventConfig<
|
|
1053
|
+
time_on_site: EventConfig<"time_on_site">;
|
|
1054
|
+
specific_page_visit: EventConfig<"specific_page_visit">;
|
|
1055
|
+
scroll_depth: EventConfig<"scroll_depth">;
|
|
1056
|
+
multi_page_session: EventConfig<"multi_page_session">;
|
|
1057
|
+
form_start: EventConfig<"form_start">;
|
|
1034
1058
|
}>;
|
|
1035
1059
|
manual?: Partial<{
|
|
1036
|
-
form_submit: EventConfig<
|
|
1037
|
-
phone_click: EventConfig<
|
|
1038
|
-
cta_click: EventConfig<
|
|
1060
|
+
form_submit: EventConfig<"form_submit">;
|
|
1061
|
+
phone_click: EventConfig<"phone_click">;
|
|
1062
|
+
cta_click: EventConfig<"cta_click">;
|
|
1039
1063
|
}>;
|
|
1040
1064
|
};
|
|
1041
1065
|
/**
|
|
@@ -1044,11 +1068,25 @@ type TriggerRegistryConfig = {
|
|
|
1044
1068
|
* Used by `TypedTrackingClient` so `trackEvent()` only accepts events the
|
|
1045
1069
|
* consumer explicitly enabled.
|
|
1046
1070
|
*/
|
|
1047
|
-
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry[
|
|
1071
|
+
type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry["manual"]>, ManualEventName>;
|
|
1048
1072
|
/**
|
|
1049
1073
|
* Automatic event names registered in a concrete trigger registry.
|
|
1050
1074
|
*/
|
|
1051
|
-
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry[
|
|
1075
|
+
type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry["automatic"], AutomaticEventName>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Discriminated union of valid manual tracking calls for a registry.
|
|
1078
|
+
*/
|
|
1079
|
+
type TrackableEvent<TRegistry extends TriggerRegistryConfig> = {
|
|
1080
|
+
[K in RegisteredManualEvents<TRegistry>]: {
|
|
1081
|
+
eventType: K;
|
|
1082
|
+
metadata: EventMetadata<K>;
|
|
1083
|
+
};
|
|
1084
|
+
}[RegisteredManualEvents<TRegistry>];
|
|
1085
|
+
declare function getEventDefinition(name: EventName): {
|
|
1086
|
+
kind: EventKind;
|
|
1087
|
+
metadataSchema: z.ZodTypeAny;
|
|
1088
|
+
configSchema: z.ZodTypeAny;
|
|
1089
|
+
};
|
|
1052
1090
|
|
|
1053
1091
|
/**
|
|
1054
1092
|
* Input accepted by the low-level stringly-typed client.
|
|
@@ -1126,775 +1164,6 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1126
1164
|
getVisitorId(): string;
|
|
1127
1165
|
}
|
|
1128
1166
|
|
|
1129
|
-
/**
|
|
1130
|
-
* Sales / Conversions wire schemas — the client-side source of truth.
|
|
1131
|
-
*
|
|
1132
|
-
* `saleCreateSchema` is mirrored by `SaleCreateSchema` in
|
|
1133
|
-
* `apps/api/src/schemas/tracking_sales.py` and enforced by the backend drift
|
|
1134
|
-
* test (the `resources` section of `events.schema.json`). Keep them in lockstep.
|
|
1135
|
-
*
|
|
1136
|
-
* Money is **integer minor units (cents)**; `quantity` is a decimal string;
|
|
1137
|
-
* `currency` is the required `SupportedCurrency` enum.
|
|
1138
|
-
*/
|
|
1139
|
-
declare const SUPPORTED_CURRENCIES: readonly ["USD", "CAD"];
|
|
1140
|
-
type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
1141
|
-
declare const TRACKING_ENVIRONMENTS: readonly ["production", "development"];
|
|
1142
|
-
declare const saleItemSchema: z.ZodObject<{
|
|
1143
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1144
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1145
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1146
|
-
quantity: z.ZodString;
|
|
1147
|
-
unit_price_cents: z.ZodNumber;
|
|
1148
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1149
|
-
}, "strict", z.ZodTypeAny, {
|
|
1150
|
-
quantity: string;
|
|
1151
|
-
unit_price_cents: number;
|
|
1152
|
-
name?: string | null | undefined;
|
|
1153
|
-
external_item_id?: string | null | undefined;
|
|
1154
|
-
category?: string | null | undefined;
|
|
1155
|
-
unit_cost_cents?: number | null | undefined;
|
|
1156
|
-
}, {
|
|
1157
|
-
quantity: string;
|
|
1158
|
-
unit_price_cents: number;
|
|
1159
|
-
name?: string | null | undefined;
|
|
1160
|
-
external_item_id?: string | null | undefined;
|
|
1161
|
-
category?: string | null | undefined;
|
|
1162
|
-
unit_cost_cents?: number | null | undefined;
|
|
1163
|
-
}>;
|
|
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<{
|
|
1175
|
-
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1176
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
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">>>;
|
|
1188
|
-
currency: z.ZodEnum<["USD", "CAD"]>;
|
|
1189
|
-
amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1190
|
-
occurred_at: z.ZodString;
|
|
1191
|
-
environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
|
|
1192
|
-
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1193
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1194
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1195
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1196
|
-
quantity: z.ZodString;
|
|
1197
|
-
unit_price_cents: z.ZodNumber;
|
|
1198
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1199
|
-
}, "strict", z.ZodTypeAny, {
|
|
1200
|
-
quantity: string;
|
|
1201
|
-
unit_price_cents: number;
|
|
1202
|
-
name?: string | null | undefined;
|
|
1203
|
-
external_item_id?: string | null | undefined;
|
|
1204
|
-
category?: string | null | undefined;
|
|
1205
|
-
unit_cost_cents?: number | null | undefined;
|
|
1206
|
-
}, {
|
|
1207
|
-
quantity: string;
|
|
1208
|
-
unit_price_cents: number;
|
|
1209
|
-
name?: string | null | undefined;
|
|
1210
|
-
external_item_id?: string | null | undefined;
|
|
1211
|
-
category?: string | null | undefined;
|
|
1212
|
-
unit_cost_cents?: number | null | undefined;
|
|
1213
|
-
}>, "many">>;
|
|
1214
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1215
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1216
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1217
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1218
|
-
}, "strict", z.ZodTypeAny, {
|
|
1219
|
-
currency: "USD" | "CAD";
|
|
1220
|
-
occurred_at: string;
|
|
1221
|
-
environment: "production" | "development";
|
|
1222
|
-
items: {
|
|
1223
|
-
quantity: string;
|
|
1224
|
-
unit_price_cents: number;
|
|
1225
|
-
name?: string | null | undefined;
|
|
1226
|
-
external_item_id?: string | null | undefined;
|
|
1227
|
-
category?: string | null | undefined;
|
|
1228
|
-
unit_cost_cents?: number | null | undefined;
|
|
1229
|
-
}[];
|
|
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;
|
|
1237
|
-
external_id?: string | null | undefined;
|
|
1238
|
-
description?: string | null | undefined;
|
|
1239
|
-
customer_name?: string | null | undefined;
|
|
1240
|
-
customer_phone?: string | null | undefined;
|
|
1241
|
-
customer_email?: string | null | undefined;
|
|
1242
|
-
}, {
|
|
1243
|
-
currency: "USD" | "CAD";
|
|
1244
|
-
occurred_at: string;
|
|
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;
|
|
1285
|
-
external_id?: string | null | undefined;
|
|
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;
|
|
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;
|
|
1302
|
-
environment?: "production" | "development" | undefined;
|
|
1303
|
-
items?: {
|
|
1304
|
-
quantity: string;
|
|
1305
|
-
unit_price_cents: number;
|
|
1306
|
-
name?: string | null | undefined;
|
|
1307
|
-
external_item_id?: string | null | undefined;
|
|
1308
|
-
category?: string | null | undefined;
|
|
1309
|
-
unit_cost_cents?: number | null | undefined;
|
|
1310
|
-
}[] | undefined;
|
|
1311
|
-
customer_name?: string | null | undefined;
|
|
1312
|
-
customer_phone?: string | null | undefined;
|
|
1313
|
-
customer_email?: string | null | undefined;
|
|
1314
|
-
}>;
|
|
1315
|
-
declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
1316
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
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">>>;
|
|
1328
|
-
currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
|
|
1329
|
-
amount_total_cents: z.ZodOptional<z.ZodNumber>;
|
|
1330
|
-
occurred_at: z.ZodOptional<z.ZodString>;
|
|
1331
|
-
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1332
|
-
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1333
|
-
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1334
|
-
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1335
|
-
quantity: z.ZodString;
|
|
1336
|
-
unit_price_cents: z.ZodNumber;
|
|
1337
|
-
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1338
|
-
}, "strict", z.ZodTypeAny, {
|
|
1339
|
-
quantity: string;
|
|
1340
|
-
unit_price_cents: number;
|
|
1341
|
-
name?: string | null | undefined;
|
|
1342
|
-
external_item_id?: string | null | undefined;
|
|
1343
|
-
category?: string | null | undefined;
|
|
1344
|
-
unit_cost_cents?: number | null | undefined;
|
|
1345
|
-
}, {
|
|
1346
|
-
quantity: string;
|
|
1347
|
-
unit_price_cents: number;
|
|
1348
|
-
name?: string | null | undefined;
|
|
1349
|
-
external_item_id?: string | null | undefined;
|
|
1350
|
-
category?: string | null | undefined;
|
|
1351
|
-
unit_cost_cents?: number | null | undefined;
|
|
1352
|
-
}>, "many">>;
|
|
1353
|
-
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1354
|
-
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1355
|
-
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1356
|
-
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1357
|
-
}, "strict", z.ZodTypeAny, {
|
|
1358
|
-
metadata?: Record<string, unknown> | null | undefined;
|
|
1359
|
-
service?: string | null | undefined;
|
|
1360
|
-
services?: {
|
|
1361
|
-
service: string;
|
|
1362
|
-
amount_cents: number;
|
|
1363
|
-
}[] | null | undefined;
|
|
1364
|
-
amount_total_cents?: number | undefined;
|
|
1365
|
-
description?: string | null | undefined;
|
|
1366
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1367
|
-
occurred_at?: string | undefined;
|
|
1368
|
-
items?: {
|
|
1369
|
-
quantity: string;
|
|
1370
|
-
unit_price_cents: number;
|
|
1371
|
-
name?: string | null | undefined;
|
|
1372
|
-
external_item_id?: string | null | undefined;
|
|
1373
|
-
category?: string | null | undefined;
|
|
1374
|
-
unit_cost_cents?: number | null | undefined;
|
|
1375
|
-
}[] | undefined;
|
|
1376
|
-
customer_name?: string | null | undefined;
|
|
1377
|
-
customer_phone?: string | null | undefined;
|
|
1378
|
-
customer_email?: string | null | undefined;
|
|
1379
|
-
}, {
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
1430
|
-
amount_total_cents?: number | undefined;
|
|
1431
|
-
description?: string | null | undefined;
|
|
1432
|
-
currency?: "USD" | "CAD" | undefined;
|
|
1433
|
-
occurred_at?: string | undefined;
|
|
1434
|
-
items?: {
|
|
1435
|
-
quantity: string;
|
|
1436
|
-
unit_price_cents: number;
|
|
1437
|
-
name?: string | null | undefined;
|
|
1438
|
-
external_item_id?: string | null | undefined;
|
|
1439
|
-
category?: string | null | undefined;
|
|
1440
|
-
unit_cost_cents?: number | null | undefined;
|
|
1441
|
-
}[] | undefined;
|
|
1442
|
-
customer_name?: string | null | undefined;
|
|
1443
|
-
customer_phone?: string | null | undefined;
|
|
1444
|
-
customer_email?: string | null | undefined;
|
|
1445
|
-
}>;
|
|
1446
|
-
type SaleItemInput = z.input<typeof saleItemSchema>;
|
|
1447
|
-
type SaleServiceInput = z.input<typeof saleServiceSchema>;
|
|
1448
|
-
type SaleInput = z.input<typeof saleCreateSchema>;
|
|
1449
|
-
type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
|
|
1450
|
-
interface SaleItem {
|
|
1451
|
-
id: string;
|
|
1452
|
-
external_item_id: string | null;
|
|
1453
|
-
name: string | null;
|
|
1454
|
-
category: string | null;
|
|
1455
|
-
quantity: string;
|
|
1456
|
-
unit_price_cents: number;
|
|
1457
|
-
unit_cost_cents: number | null;
|
|
1458
|
-
}
|
|
1459
|
-
interface SaleService {
|
|
1460
|
-
id: string;
|
|
1461
|
-
service_id: string;
|
|
1462
|
-
service_key: string;
|
|
1463
|
-
service_label: string;
|
|
1464
|
-
amount_cents: number;
|
|
1465
|
-
}
|
|
1466
|
-
interface Sale {
|
|
1467
|
-
id: string;
|
|
1468
|
-
business_id: string;
|
|
1469
|
-
business_name?: string | null;
|
|
1470
|
-
external_id: string | null;
|
|
1471
|
-
currency: SupportedCurrency;
|
|
1472
|
-
amount_total_cents: number;
|
|
1473
|
-
description: string | null;
|
|
1474
|
-
service_id: string | null;
|
|
1475
|
-
service_key?: string | null;
|
|
1476
|
-
service_label?: string | null;
|
|
1477
|
-
services: SaleService[];
|
|
1478
|
-
occurred_at: string;
|
|
1479
|
-
environment: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1480
|
-
metadata: Record<string, unknown> | null;
|
|
1481
|
-
customer_name: string | null;
|
|
1482
|
-
customer_phone: string | null;
|
|
1483
|
-
customer_email: string | null;
|
|
1484
|
-
created_at: string;
|
|
1485
|
-
updated_at: string;
|
|
1486
|
-
items: SaleItem[];
|
|
1487
|
-
}
|
|
1488
|
-
interface SaleListPage {
|
|
1489
|
-
items: Sale[];
|
|
1490
|
-
total: number;
|
|
1491
|
-
}
|
|
1492
|
-
interface SaleCursorPage {
|
|
1493
|
-
items: Sale[];
|
|
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;
|
|
1498
|
-
}
|
|
1499
|
-
type SaleSortOrder = 'asc' | 'desc';
|
|
1500
|
-
/**
|
|
1501
|
-
* Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
|
|
1502
|
-
*
|
|
1503
|
-
* `search` runs case-insensitively across `customer_name`, `customer_phone`,
|
|
1504
|
-
* `customer_email`, `description`, and `external_id` — the human-facing
|
|
1505
|
-
* columns. `service_id` is the resolved per-business service UUID (different
|
|
1506
|
-
* from the create-time `service` *key*).
|
|
1507
|
-
*/
|
|
1508
|
-
interface SaleFilters {
|
|
1509
|
-
business_id?: string;
|
|
1510
|
-
external_id?: string;
|
|
1511
|
-
service_id?: string;
|
|
1512
|
-
/** E.164 phone — the canonical customer key; filters sales for one customer. */
|
|
1513
|
-
customer_phone?: string;
|
|
1514
|
-
currency?: SupportedCurrency;
|
|
1515
|
-
environment?: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1516
|
-
since?: string;
|
|
1517
|
-
until?: string;
|
|
1518
|
-
min_amount_cents?: number;
|
|
1519
|
-
max_amount_cents?: number;
|
|
1520
|
-
search?: string;
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Full query input for `SalesClient.list()` — filters + pagination.
|
|
1524
|
-
*
|
|
1525
|
-
* Pagination is **keyset (cursor)**: `next_cursor` returned by one page is
|
|
1526
|
-
* passed back as `cursor` on the next. `null` / undefined cursor = first page.
|
|
1527
|
-
*
|
|
1528
|
-
* Ordering on this endpoint is fixed at **`occurred_at DESC, id DESC`** — the
|
|
1529
|
-
* cursor encodes a position in that index, so a different sort would
|
|
1530
|
-
* invalidate cursors mid-pagination. For ad-hoc sorted reads use the
|
|
1531
|
-
* dashboard admin endpoint, which is offset-paginated.
|
|
1532
|
-
*/
|
|
1533
|
-
interface SaleListQuery extends SaleFilters {
|
|
1534
|
-
limit?: number;
|
|
1535
|
-
cursor?: string | null;
|
|
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
|
-
}
|
|
1546
|
-
declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
|
|
1547
|
-
type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
|
|
1548
|
-
/** Query input for `SalesClient.summary()` — filters + range + options. */
|
|
1549
|
-
interface SaleSummaryQuery extends SaleFilters {
|
|
1550
|
-
range: TrackingOverviewRange;
|
|
1551
|
-
/** Include the per-category line-item breakdown (extra join; default false). */
|
|
1552
|
-
include_categories?: boolean;
|
|
1553
|
-
/** Surface soft-deleted services individually (flagged "(deleted)") instead of
|
|
1554
|
-
* rolling them into a single "Deleted services" bucket. Default false. */
|
|
1555
|
-
include_deleted_services?: boolean;
|
|
1556
|
-
/** Cap on the by-service / by-category rows (1–50, default 10). */
|
|
1557
|
-
top_n?: number;
|
|
1558
|
-
}
|
|
1559
|
-
interface CurrencyRevenue {
|
|
1560
|
-
currency: SupportedCurrency;
|
|
1561
|
-
sale_count: number;
|
|
1562
|
-
revenue_cents: number;
|
|
1563
|
-
average_order_value_cents: number;
|
|
1564
|
-
}
|
|
1565
|
-
interface SalesServiceBreakdown {
|
|
1566
|
-
service_id: string | null;
|
|
1567
|
-
service_key: string | null;
|
|
1568
|
-
/** "Unassigned" when the sale has no service. */
|
|
1569
|
-
service_label: string | null;
|
|
1570
|
-
currency: SupportedCurrency;
|
|
1571
|
-
sale_count: number;
|
|
1572
|
-
revenue_cents: number;
|
|
1573
|
-
}
|
|
1574
|
-
interface SalesCategoryBreakdown {
|
|
1575
|
-
category: string | null;
|
|
1576
|
-
currency: SupportedCurrency;
|
|
1577
|
-
/** sum(unit_price_cents * quantity) — advisory, not authoritative. */
|
|
1578
|
-
revenue_cents: number;
|
|
1579
|
-
/** Decimal string. */
|
|
1580
|
-
quantity: string;
|
|
1581
|
-
}
|
|
1582
|
-
interface SalesTrendPoint {
|
|
1583
|
-
bucket_start: string;
|
|
1584
|
-
currency: SupportedCurrency;
|
|
1585
|
-
sale_count: number;
|
|
1586
|
-
revenue_cents: number;
|
|
1587
|
-
}
|
|
1588
|
-
interface SaleSummary {
|
|
1589
|
-
range: TrackingOverviewRange;
|
|
1590
|
-
business_id: string | null;
|
|
1591
|
-
metrics: {
|
|
1592
|
-
sale_count: number;
|
|
1593
|
-
distinct_customers: number;
|
|
1594
|
-
by_currency: CurrencyRevenue[];
|
|
1595
|
-
};
|
|
1596
|
-
by_service: SalesServiceBreakdown[];
|
|
1597
|
-
by_currency: CurrencyRevenue[];
|
|
1598
|
-
by_category: SalesCategoryBreakdown[];
|
|
1599
|
-
series: SalesTrendPoint[];
|
|
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
|
-
}
|
|
1770
|
-
|
|
1771
|
-
/** Shared config for every sales HTTP helper. */
|
|
1772
|
-
interface SalesTransportConfig {
|
|
1773
|
-
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
1774
|
-
apiKey: string;
|
|
1775
|
-
/**
|
|
1776
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
1777
|
-
* The `/sales` path is appended by the helpers.
|
|
1778
|
-
*/
|
|
1779
|
-
endpoint: string;
|
|
1780
|
-
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
1781
|
-
sdkVersion?: string;
|
|
1782
|
-
packageName?: string;
|
|
1783
|
-
surface?: string;
|
|
1784
|
-
environment?: string;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
/** Config for {@link createSalesClient}. */
|
|
1788
|
-
interface SalesClientConfig extends SalesTransportConfig {
|
|
1789
|
-
/** Applied when an individual `record()` call omits `currency`. */
|
|
1790
|
-
defaultCurrency?: SupportedCurrency;
|
|
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
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* One isomorphic sales client — what a key may *do* is enforced by the backend,
|
|
1805
|
-
* not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
|
|
1806
|
-
* backend rejects reads/CRUD from it with a `403`); a **secret** key
|
|
1807
|
-
* (`aranv_sk_…`), used **server-side only**, gets full read/list/update/delete.
|
|
1808
|
-
* Never ship a secret key in a browser bundle.
|
|
1809
|
-
*
|
|
1810
|
-
* Generic over the service-key union `TService`: bind the type emitted by
|
|
1811
|
-
* `@aranova/tracking-cli gen` for compile-time-checked `service` values.
|
|
1812
|
-
*/
|
|
1813
|
-
interface SalesClient<TService extends string = string> {
|
|
1814
|
-
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
|
|
1815
|
-
service?: TService | null;
|
|
1816
|
-
services?: Array<{
|
|
1817
|
-
service: TService;
|
|
1818
|
-
amount_cents: number;
|
|
1819
|
-
}>;
|
|
1820
|
-
currency?: SupportedCurrency;
|
|
1821
|
-
occurred_at?: string;
|
|
1822
|
-
}): Promise<Sale>;
|
|
1823
|
-
/** Keyset list with optional server sort + opt-in `total_count`. */
|
|
1824
|
-
list(query?: SaleListQueryV2): Promise<SaleCursorPage>;
|
|
1825
|
-
/**
|
|
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.
|
|
1829
|
-
*/
|
|
1830
|
-
summary(query: SaleSummaryQueryV2): Promise<SaleSummaryV2>;
|
|
1831
|
-
get(id: string): Promise<Sale>;
|
|
1832
|
-
update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
|
|
1833
|
-
service?: TService | null;
|
|
1834
|
-
services?: Array<{
|
|
1835
|
-
service: TService;
|
|
1836
|
-
amount_cents: number;
|
|
1837
|
-
}>;
|
|
1838
|
-
}): Promise<Sale>;
|
|
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;
|
|
1844
|
-
}
|
|
1845
|
-
declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
|
|
1846
|
-
|
|
1847
|
-
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
1848
|
-
interface PublicServiceItem {
|
|
1849
|
-
key: string;
|
|
1850
|
-
label: string;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* Fetch the caller's business's active service taxonomy. Accepts a public or
|
|
1854
|
-
* secret key (the taxonomy is low-sensitivity category names). Powers the
|
|
1855
|
-
* `@aranova/tracking-cli gen` codegen.
|
|
1856
|
-
*/
|
|
1857
|
-
declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
|
|
1858
|
-
|
|
1859
|
-
/**
|
|
1860
|
-
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
1861
|
-
*
|
|
1862
|
-
* Convenience only — the wire is always integer cents. Uses float multiply +
|
|
1863
|
-
* `Math.round`, so values that aren't exactly representable in binary float
|
|
1864
|
-
* (e.g. `1.005`) can round to the neighbouring cent. If you already hold an
|
|
1865
|
-
* exact cents integer, pass it straight through and skip this helper.
|
|
1866
|
-
*/
|
|
1867
|
-
declare function toMinor(amount: number, currency: SupportedCurrency): number;
|
|
1868
|
-
/** Convert integer minor units (`25050`) to a major amount (`250.5`). */
|
|
1869
|
-
declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
1870
|
-
/**
|
|
1871
|
-
* Format integer minor units as a localized currency string (e.g. `"$250.50"`).
|
|
1872
|
-
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
1873
|
-
*/
|
|
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;
|
|
1881
|
-
|
|
1882
|
-
/**
|
|
1883
|
-
* Error thrown by the sales client (`createSalesClient`) on a
|
|
1884
|
-
* non-2xx response. Unlike the fire-and-forget event queue (which swallows
|
|
1885
|
-
* failures), a sale is a transaction the caller must be able to react to.
|
|
1886
|
-
*/
|
|
1887
|
-
declare class AranovaApiError extends Error {
|
|
1888
|
-
readonly status: number;
|
|
1889
|
-
readonly code: string | undefined;
|
|
1890
|
-
readonly requestId: string | undefined;
|
|
1891
|
-
constructor(message: string, options: {
|
|
1892
|
-
status: number;
|
|
1893
|
-
code?: string;
|
|
1894
|
-
requestId?: string;
|
|
1895
|
-
});
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
1167
|
/**
|
|
1899
1168
|
* Default non-blocking consent banner.
|
|
1900
1169
|
*
|
|
@@ -1948,11 +1217,11 @@ interface ConsentBannerProps {
|
|
|
1948
1217
|
onAccept?: () => void;
|
|
1949
1218
|
onDecline?: () => void;
|
|
1950
1219
|
/** Where the banner docks. Default: `"bottom"`. */
|
|
1951
|
-
position?:
|
|
1220
|
+
position?: "top" | "bottom";
|
|
1952
1221
|
/**
|
|
1953
1222
|
* Visual theme. `"auto"` follows `prefers-color-scheme`. Default: `"light"`.
|
|
1954
1223
|
*/
|
|
1955
|
-
theme?:
|
|
1224
|
+
theme?: "light" | "dark" | "auto";
|
|
1956
1225
|
/** Class added to the outer wrapper for additional styling hooks. */
|
|
1957
1226
|
className?: string;
|
|
1958
1227
|
/** Inline style overrides applied to the outer wrapper after the defaults. */
|
|
@@ -2108,16 +1377,6 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
|
|
|
2108
1377
|
*/
|
|
2109
1378
|
declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
|
|
2110
1379
|
|
|
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
1380
|
/** Resolve the effective phone config (provider value or built-in defaults). */
|
|
2122
1381
|
declare function usePhoneConfig(): {
|
|
2123
1382
|
defaultCountry: CountryCode;
|
|
@@ -2136,9 +1395,9 @@ interface PhoneInputProps {
|
|
|
2136
1395
|
value: string;
|
|
2137
1396
|
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
2138
1397
|
onBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
2139
|
-
type:
|
|
2140
|
-
inputMode:
|
|
2141
|
-
autoComplete:
|
|
1398
|
+
type: "tel";
|
|
1399
|
+
inputMode: "tel";
|
|
1400
|
+
autoComplete: "tel";
|
|
2142
1401
|
}
|
|
2143
1402
|
interface PhoneFieldApi {
|
|
2144
1403
|
/** Display value for the `<input>` (live `AsYouType` while typing). */
|
|
@@ -2154,7 +1413,7 @@ interface PhoneFieldApi {
|
|
|
2154
1413
|
}
|
|
2155
1414
|
/** Headless phone field — the client owns the markup. */
|
|
2156
1415
|
declare function usePhoneField(opts?: UsePhoneFieldOptions): PhoneFieldApi;
|
|
2157
|
-
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
1416
|
+
interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> {
|
|
2158
1417
|
country?: CountryCode;
|
|
2159
1418
|
/** Controlled display value. */
|
|
2160
1419
|
value?: string;
|
|
@@ -2175,4 +1434,4 @@ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 't
|
|
|
2175
1434
|
*/
|
|
2176
1435
|
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
2177
1436
|
|
|
2178
|
-
export {
|
|
1437
|
+
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getConsentState, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, resetConsent, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, setConsentState, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|