@aranova/tracking-react 0.17.3 → 0.18.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 +40 -21
- package/dist/index.d.mts +171 -14
- package/dist/index.d.ts +171 -14
- package/dist/index.js +428 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +425 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-DlAQK-gU.d.mts → phone-utils-CVCzW04Z.d.mts} +7 -4
- package/dist/{phone-utils-DlAQK-gU.d.ts → phone-utils-CVCzW04Z.d.ts} +7 -4
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/phone.js +82 -0
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +82 -0
- package/dist/phone.mjs.map +1 -1
- package/dist/{sales-C3jFBx08.d.mts → sales-QqKh6_iy.d.mts} +55 -2
- package/dist/{sales-C3jFBx08.d.ts → sales-QqKh6_iy.d.ts} +55 -2
- package/dist/sales.d.mts +1 -1
- package/dist/sales.d.ts +1 -1
- package/dist/sales.js +16 -0
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +16 -0
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ interface ConversionConfig {
|
|
|
30
30
|
business_id?: string;
|
|
31
31
|
customer_id?: string | null;
|
|
32
32
|
environment?: string;
|
|
33
|
+
google_tracking_state: "active" | "disabled";
|
|
33
34
|
gtag_ids: Record<string, string>;
|
|
34
35
|
meta_pixel_ids: Record<string, string>;
|
|
35
36
|
/** LEGACY: sale-goals only (for pre-unified-goal readers). */
|
|
@@ -78,6 +79,54 @@ interface ResolveConversionConfigOptions {
|
|
|
78
79
|
*/
|
|
79
80
|
declare function resolveConversionConfig(options: ResolveConversionConfigOptions): ConversionConfigStore;
|
|
80
81
|
|
|
82
|
+
interface TrackingConfigReference {
|
|
83
|
+
cdnUrl: string;
|
|
84
|
+
businessId: string;
|
|
85
|
+
environment: "production" | "test";
|
|
86
|
+
}
|
|
87
|
+
type RuntimeState = "unconfirmed" | "active" | "tombstone";
|
|
88
|
+
interface QueuedConversion {
|
|
89
|
+
key: string;
|
|
90
|
+
value?: number | null;
|
|
91
|
+
currency?: string | null;
|
|
92
|
+
transactionId?: string | null;
|
|
93
|
+
}
|
|
94
|
+
type TrackingConfigConversionOptions = Omit<QueuedConversion, "key">;
|
|
95
|
+
interface QueuedPageView {
|
|
96
|
+
href: string;
|
|
97
|
+
title: string | null;
|
|
98
|
+
referrer: string | null;
|
|
99
|
+
}
|
|
100
|
+
declare class TrackingConfigRuntime {
|
|
101
|
+
readonly ref: TrackingConfigReference;
|
|
102
|
+
private readonly fetchImpl;
|
|
103
|
+
private current;
|
|
104
|
+
private etag;
|
|
105
|
+
private stateValue;
|
|
106
|
+
private confirmedAt;
|
|
107
|
+
private inFlight;
|
|
108
|
+
private readonly conversionQueue;
|
|
109
|
+
private readonly automaticQueue;
|
|
110
|
+
private readonly pageQueue;
|
|
111
|
+
private readonly listeners;
|
|
112
|
+
constructor(ref: TrackingConfigReference, fetchImpl?: typeof fetch);
|
|
113
|
+
state(): RuntimeState;
|
|
114
|
+
config(): ConversionConfig | null;
|
|
115
|
+
__unsafeExpireAuthorityForTests(): void;
|
|
116
|
+
subscribe(listener: () => void): () => void;
|
|
117
|
+
ensureAuthority(): Promise<boolean>;
|
|
118
|
+
revalidate(): Promise<void>;
|
|
119
|
+
queuePageView(snapshot?: QueuedPageView | null): void;
|
|
120
|
+
fireConversion(key: string, options?: TrackingConfigConversionOptions): void;
|
|
121
|
+
queueAutomaticEvent(eventType: string, metadata: Record<string, unknown>, transactionPath: string): void;
|
|
122
|
+
listGoals(): ConversionGoal[];
|
|
123
|
+
private revalidateNow;
|
|
124
|
+
private expireAuthority;
|
|
125
|
+
private confirm;
|
|
126
|
+
private flush;
|
|
127
|
+
}
|
|
128
|
+
declare function getTrackingConfigRuntime(ref: TrackingConfigReference, fetchImpl?: typeof fetch): TrackingConfigRuntime;
|
|
129
|
+
|
|
81
130
|
/**
|
|
82
131
|
* Sales / Conversions wire schemas — the client-side source of truth.
|
|
83
132
|
*
|
|
@@ -443,6 +492,10 @@ interface Sale {
|
|
|
443
492
|
customer_name: string | null;
|
|
444
493
|
customer_phone: string | null;
|
|
445
494
|
customer_email: string | null;
|
|
495
|
+
/** CASL consent attestation stored on the sale; SMS send paths gate on it server-side. */
|
|
496
|
+
sms_consent: boolean;
|
|
497
|
+
/** Server timestamp for when the consent attestation was recorded. */
|
|
498
|
+
sms_consent_granted_at: string | null;
|
|
446
499
|
created_at: string;
|
|
447
500
|
updated_at: string;
|
|
448
501
|
items: SaleItem[];
|
|
@@ -768,7 +821,7 @@ interface SalesClientConfig extends SalesTransportConfig {
|
|
|
768
821
|
* the resolved config. Consent-gated + de-duped; no-ops server-side. Wire it from
|
|
769
822
|
* `resolveConversionConfig(...)`.
|
|
770
823
|
*/
|
|
771
|
-
firing?: Pick<ConversionConfigStore, "getFiring"
|
|
824
|
+
firing?: Pick<ConversionConfigStore, "getFiring"> | TrackingConfigRuntime;
|
|
772
825
|
}
|
|
773
826
|
/** Phone-keyed customer rollups (sk-only; a public key gets a `403`). */
|
|
774
827
|
interface SalesCustomersClient {
|
|
@@ -903,4 +956,4 @@ interface PublicServiceItem {
|
|
|
903
956
|
*/
|
|
904
957
|
declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
|
|
905
958
|
|
|
906
|
-
export { type
|
|
959
|
+
export { type SalesClientConfig as $, AranovaApiError as A, type BusinessConfig as B, type ConversionConfig as C, type DistinctCustomersByCurrency as D, type SaleItemInput as E, type SaleKeysetSortField as F, type Granularity as G, type SaleListPage as H, type SaleListQuery as I, type SaleListQueryV2 as J, type SaleService as K, type SaleServiceInput as L, type SaleSortField as M, NAMED_RANGES as N, type SaleSortOrder as O, type PublicServiceItem as P, type SaleSummary as Q, type SaleSummaryPrevious as R, SUPPORTED_CURRENCIES as S, type TrackingConfigReference as T, type SaleSummaryQuery as U, type SaleSummaryQueryV2 as V, type SaleSummaryV2 as W, type SaleUpdateInput as X, type SalesBusinessClient as Y, type SalesCategoryBreakdown as Z, type SalesClient as _, type BusinessConfigFeatures as a, type SalesCustomersClient as a0, type SalesServiceBreakdown as a1, type SalesTransportConfig as a2, type SalesTrendPoint as a3, type SummaryCurrencyDelta as a4, type SummaryDeltas as a5, type SummaryWindow as a6, type SupportedCurrency as a7, TRACKING_RANGES as a8, type TrackingOverviewRange as a9, createSalesClient as aa, fetchServices as ab, formatDateInTz as ac, formatMoney as ad, fromMinor as ae, getTrackingConfigRuntime as af, resolveConversionConfig as ag, saleCreateSchema as ah, saleItemSchema as ai, saleServiceSchema as aj, saleUpdateSchema as ak, salesRequest as al, toMinor as am, type BusinessConfigService as b, type CompareTo as c, type ConversionConfigStore as d, type CurrencyRevenue as e, type CustomerCurrencyDelta as f, type CustomerCurrencyTotal as g, type CustomerGetOptions as h, type CustomerGetResult as i, type CustomerKpis as j, type CustomerKpisDeltas as k, type CustomerKpisPrevious as l, type CustomerListPage as m, type CustomerListQuery as n, type CustomerProfile as o, type CustomerSegment as p, type CustomerSegmentCount as q, type CustomerSortField as r, type CustomerSummary as s, type CustomerSummaryQuery as t, type NamedRange as u, type Sale as v, type SaleCursorPage as w, type SaleFilters as x, type SaleInput as y, type SaleItem as z };
|
package/dist/sales.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, e as CurrencyRevenue, f as CustomerCurrencyDelta, g as CustomerCurrencyTotal, h as CustomerGetOptions, i as CustomerGetResult, j as CustomerKpis, k as CustomerKpisDeltas, l as CustomerKpisPrevious, m as CustomerListPage, n as CustomerListQuery, o as CustomerProfile, p as CustomerSegment, q as CustomerSegmentCount, r as CustomerSortField, s as CustomerSummary, t as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, u as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, v as Sale, w as SaleCursorPage, x as SaleFilters, y as SaleInput, z as SaleItem, E as SaleItemInput, F as SaleKeysetSortField, H as SaleListPage, I as SaleListQuery, J as SaleListQueryV2, K as SaleService, L as SaleServiceInput, M as SaleSortField, O as SaleSortOrder, Q as SaleSummary, R as SaleSummaryPrevious,
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, e as CurrencyRevenue, f as CustomerCurrencyDelta, g as CustomerCurrencyTotal, h as CustomerGetOptions, i as CustomerGetResult, j as CustomerKpis, k as CustomerKpisDeltas, l as CustomerKpisPrevious, m as CustomerListPage, n as CustomerListQuery, o as CustomerProfile, p as CustomerSegment, q as CustomerSegmentCount, r as CustomerSortField, s as CustomerSummary, t as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, u as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, v as Sale, w as SaleCursorPage, x as SaleFilters, y as SaleInput, z as SaleItem, E as SaleItemInput, F as SaleKeysetSortField, H as SaleListPage, I as SaleListQuery, J as SaleListQueryV2, K as SaleService, L as SaleServiceInput, M as SaleSortField, O as SaleSortOrder, Q as SaleSummary, R as SaleSummaryPrevious, U as SaleSummaryQuery, V as SaleSummaryQueryV2, W as SaleSummaryV2, X as SaleUpdateInput, Y as SalesBusinessClient, Z as SalesCategoryBreakdown, _ as SalesClient, $ as SalesClientConfig, a0 as SalesCustomersClient, a1 as SalesServiceBreakdown, a2 as SalesTransportConfig, a3 as SalesTrendPoint, a4 as SummaryCurrencyDelta, a5 as SummaryDeltas, a6 as SummaryWindow, a7 as SupportedCurrency, a8 as TRACKING_RANGES, a9 as TrackingOverviewRange, aa as createSalesClient, ab as fetchServices, ac as formatDateInTz, ad as formatMoney, ae as fromMinor, ah as saleCreateSchema, ai as saleItemSchema, aj as saleServiceSchema, ak as saleUpdateSchema, al as salesRequest, am as toMinor } from './sales-QqKh6_iy.mjs';
|
|
2
2
|
import 'zod';
|
package/dist/sales.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, e as CurrencyRevenue, f as CustomerCurrencyDelta, g as CustomerCurrencyTotal, h as CustomerGetOptions, i as CustomerGetResult, j as CustomerKpis, k as CustomerKpisDeltas, l as CustomerKpisPrevious, m as CustomerListPage, n as CustomerListQuery, o as CustomerProfile, p as CustomerSegment, q as CustomerSegmentCount, r as CustomerSortField, s as CustomerSummary, t as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, u as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, v as Sale, w as SaleCursorPage, x as SaleFilters, y as SaleInput, z as SaleItem, E as SaleItemInput, F as SaleKeysetSortField, H as SaleListPage, I as SaleListQuery, J as SaleListQueryV2, K as SaleService, L as SaleServiceInput, M as SaleSortField, O as SaleSortOrder, Q as SaleSummary, R as SaleSummaryPrevious,
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, e as CurrencyRevenue, f as CustomerCurrencyDelta, g as CustomerCurrencyTotal, h as CustomerGetOptions, i as CustomerGetResult, j as CustomerKpis, k as CustomerKpisDeltas, l as CustomerKpisPrevious, m as CustomerListPage, n as CustomerListQuery, o as CustomerProfile, p as CustomerSegment, q as CustomerSegmentCount, r as CustomerSortField, s as CustomerSummary, t as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, u as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, v as Sale, w as SaleCursorPage, x as SaleFilters, y as SaleInput, z as SaleItem, E as SaleItemInput, F as SaleKeysetSortField, H as SaleListPage, I as SaleListQuery, J as SaleListQueryV2, K as SaleService, L as SaleServiceInput, M as SaleSortField, O as SaleSortOrder, Q as SaleSummary, R as SaleSummaryPrevious, U as SaleSummaryQuery, V as SaleSummaryQueryV2, W as SaleSummaryV2, X as SaleUpdateInput, Y as SalesBusinessClient, Z as SalesCategoryBreakdown, _ as SalesClient, $ as SalesClientConfig, a0 as SalesCustomersClient, a1 as SalesServiceBreakdown, a2 as SalesTransportConfig, a3 as SalesTrendPoint, a4 as SummaryCurrencyDelta, a5 as SummaryDeltas, a6 as SummaryWindow, a7 as SupportedCurrency, a8 as TRACKING_RANGES, a9 as TrackingOverviewRange, aa as createSalesClient, ab as fetchServices, ac as formatDateInTz, ad as formatMoney, ae as fromMinor, ah as saleCreateSchema, ai as saleItemSchema, aj as saleServiceSchema, ak as saleUpdateSchema, al as salesRequest, am as toMinor } from './sales-QqKh6_iy.js';
|
|
2
2
|
import 'zod';
|
package/dist/sales.js
CHANGED
|
@@ -248,6 +248,14 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
|
248
248
|
const txnBase = input.external_id ?? sale.id;
|
|
249
249
|
for (const item of recorded) {
|
|
250
250
|
if (!item.service) continue;
|
|
251
|
+
if ("fireConversion" in firing) {
|
|
252
|
+
firing.fireConversion(item.service, {
|
|
253
|
+
value: item.amount_cents != null ? fromMinor(item.amount_cents, currency) : void 0,
|
|
254
|
+
currency,
|
|
255
|
+
transactionId: `${txnBase}:${item.service}`
|
|
256
|
+
});
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
251
259
|
const config = firing.getFiring(item.service);
|
|
252
260
|
if (!config) continue;
|
|
253
261
|
const cents = item.amount_cents ?? config.value_cents ?? null;
|
|
@@ -290,6 +298,14 @@ function createSalesClient(config) {
|
|
|
290
298
|
// recordSale is the intent-revealing alias — same behavior, clearer call site.
|
|
291
299
|
recordSale: record,
|
|
292
300
|
trackConversion(key, options) {
|
|
301
|
+
if (config.firing && "fireConversion" in config.firing) {
|
|
302
|
+
config.firing.fireConversion(key, {
|
|
303
|
+
value: options?.value ?? void 0,
|
|
304
|
+
currency: options?.currency ?? config.defaultCurrency ?? void 0,
|
|
305
|
+
transactionId: options?.transactionId ?? null
|
|
306
|
+
});
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
293
309
|
const firing = config.firing?.getFiring(key);
|
|
294
310
|
if (!firing) return;
|
|
295
311
|
const currency = firing.currency ?? options?.currency ?? config.defaultCurrency ?? null;
|