@aranova/tracking-react 0.24.1 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -521,4 +521,4 @@ declare function optOut(options?: SetConsentOptions): void;
521
521
  */
522
522
  declare function resetConsent(): void;
523
523
 
524
- export { resetConsent as A, setConsentState as B, type ConsentState as C, DEFAULT_DECLINE_TTL_DAYS as D, toE164 as E, type FormSubmitConfig as F, type GtagEnvironmentMap as G, type JsonValue as J, type MetaPixelEnvironmentMap as M, type PhoneConfig as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type FormSubmitMetadata as f, type ConsentChoiceState as g, type ConsentSource as h, type ParsedPhone as i, type PhoneDisplayFormat as j, type ConsentChoice as k, DEFAULT_PHONE_COUNTRY as l, type TrackedField as m, type TrackingInitConfig as n, formSubmitConfigSchema as o, formSubmitMetadataSchema as p, formatPhone as q, formatPhoneAsTyped as r, getConsentChoice as s, getConsentState as t, jsonValueSchema as u, onConsentChange as v, optIn as w, optOut as x, parsePhone as y, phoneField as z };
524
+ export { resetConsent as A, setConsentState as B, type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, toE164 as E, type FormSubmitConfig as F, type GtagEnvironmentMap as G, type JsonValue as J, type MetaPixelEnvironmentMap as M, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, type FormSubmitMetadata as j, type PhoneConfig as k, type PhoneDisplayFormat as l, type TrackedField as m, type TrackingInitConfig as n, formSubmitConfigSchema as o, formSubmitMetadataSchema as p, formatPhone as q, formatPhoneAsTyped as r, getConsentChoice as s, getConsentState as t, jsonValueSchema as u, onConsentChange as v, optIn as w, optOut as x, parsePhone as y, phoneField as z };
@@ -521,4 +521,4 @@ declare function optOut(options?: SetConsentOptions): void;
521
521
  */
522
522
  declare function resetConsent(): void;
523
523
 
524
- export { resetConsent as A, setConsentState as B, type ConsentState as C, DEFAULT_DECLINE_TTL_DAYS as D, toE164 as E, type FormSubmitConfig as F, type GtagEnvironmentMap as G, type JsonValue as J, type MetaPixelEnvironmentMap as M, type PhoneConfig as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type FormSubmitMetadata as f, type ConsentChoiceState as g, type ConsentSource as h, type ParsedPhone as i, type PhoneDisplayFormat as j, type ConsentChoice as k, DEFAULT_PHONE_COUNTRY as l, type TrackedField as m, type TrackingInitConfig as n, formSubmitConfigSchema as o, formSubmitMetadataSchema as p, formatPhone as q, formatPhoneAsTyped as r, getConsentChoice as s, getConsentState as t, jsonValueSchema as u, onConsentChange as v, optIn as w, optOut as x, parsePhone as y, phoneField as z };
524
+ export { resetConsent as A, setConsentState as B, type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, toE164 as E, type FormSubmitConfig as F, type GtagEnvironmentMap as G, type JsonValue as J, type MetaPixelEnvironmentMap as M, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, type FormSubmitMetadata as j, type PhoneConfig as k, type PhoneDisplayFormat as l, type TrackedField as m, type TrackingInitConfig as n, formSubmitConfigSchema as o, formSubmitMetadataSchema as p, formatPhone as q, formatPhoneAsTyped as r, getConsentChoice as s, getConsentState as t, jsonValueSchema as u, onConsentChange as v, optIn as w, optOut as x, parsePhone as y, phoneField as z };
package/dist/phone.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-B6TYgiYT.mjs';
1
+ export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, k as PhoneConfig, l as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-BVzSNBf1.mjs';
2
2
  export { CountryCode } from 'libphonenumber-js';
3
3
  import 'zod';
package/dist/phone.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-B6TYgiYT.js';
1
+ export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, k as PhoneConfig, l as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-BVzSNBf1.js';
2
2
  export { CountryCode } from 'libphonenumber-js';
3
3
  import 'zod';
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { a as ConversionConfigStore, c as TrackingConfigRuntime } from './tracking-config-runtime-BnUlS_Ae.js';
2
3
  import { CountryCode } from 'libphonenumber-js';
3
4
 
4
5
  /** Raw identifiers a caller may hand us (normalized before use). */
@@ -11,195 +12,6 @@ declare function stashUserData(data: ConversionUserData, country?: CountryCode):
11
12
  /** Drop everything (consent denial, tests). */
12
13
  declare function clearStashedUserData(): void;
13
14
 
14
- interface ServiceFiring {
15
- send_to: string;
16
- /** Action's configured default value (cents); the SDK fires it only when a sale has no amount. */
17
- value_cents?: number | null;
18
- currency?: string | null;
19
- }
20
- /** Serializable on-page trigger (owned by tracking-core/src/events/trigger-spec.ts). The shape
21
- * varies by `event_type`; only the parameter for that type is set. */
22
- interface ConfigTriggerSpec {
23
- event_type: string;
24
- threshold_percent?: number;
25
- threshold_seconds?: number;
26
- page_threshold?: number;
27
- page_name?: string;
28
- }
29
- /** One unified conversion goal: a revenue `sale` or an on-page `event`. */
30
- interface ConversionGoal {
31
- key: string;
32
- label?: string;
33
- kind: "sale" | "event";
34
- /** Structured fire-when for event-goals; null for sales. */
35
- trigger: ConfigTriggerSpec | null;
36
- firing: ServiceFiring | null;
37
- }
38
- interface ConversionConfig {
39
- schema_version: number;
40
- config_version: number;
41
- business_id?: string;
42
- customer_id?: string | null;
43
- environment?: string;
44
- google_tracking_state: "active" | "disabled";
45
- gtag_ids: Record<string, string>;
46
- meta_pixel_ids: Record<string, string>;
47
- /** LEGACY: sale-goals only (for pre-unified-goal readers). */
48
- services: Array<{
49
- key: string;
50
- label?: string;
51
- firing: ServiceFiring | null;
52
- }>;
53
- /** Unified goal list (sales + on-page events). Superset of `services`. */
54
- goals: ConversionGoal[];
55
- }
56
- interface ConversionConfigStore {
57
- /** Firing config for a goal/service key, or null when it doesn't fire on-site. */
58
- getFiring(key: string): ServiceFiring | null;
59
- /** The full goal for a key, or null when unknown. */
60
- getGoal(key: string): ConversionGoal | null;
61
- /** Every adopted goal (sales + events). */
62
- listGoals(): ConversionGoal[];
63
- /** The currently adopted config (baked / cached fallback until the fetch lands). */
64
- current(): ConversionConfig | null;
65
- /** True once a config is adopted (seeded synchronously from cache/baked, or fetched). */
66
- isReady(): boolean;
67
- /**
68
- * Run `listener` when a config first becomes available — immediately if already
69
- * ready, otherwise on the first adopt. Lets auto-fire replay automatic events that
70
- * occurred before the async CDN fetch resolved. Returns an unsubscribe fn.
71
- */
72
- onResolve(listener: () => void): () => void;
73
- /** Force a background revalidate against the CDN object. */
74
- revalidate(): Promise<void>;
75
- }
76
- interface ResolveConversionConfigOptions {
77
- /** Full URL of the per-business CDN object. */
78
- cdnUrl: string;
79
- /** Offline-correct fallback (e.g. the CLI-baked snapshot). */
80
- baked?: ConversionConfig | null;
81
- /** Injectable for tests / non-global-fetch runtimes. */
82
- fetchImpl?: typeof fetch;
83
- }
84
- /**
85
- * Resolve the config with stale-while-revalidate: seed synchronously from the
86
- * sessionStorage cache (or the baked fallback), then conditionally re-fetch the CDN object
87
- * with `If-None-Match`. A fetched object is adopted only if its `config_version` is strictly
88
- * greater than what's cached, so a reordered edge copy can't downgrade fresher state.
89
- * Non-blocking and browser-only; a failed fetch leaves the seed in place.
90
- */
91
- declare function resolveConversionConfig(options: ResolveConversionConfigOptions): ConversionConfigStore;
92
-
93
- /**
94
- * Where a business's published tracking config lives.
95
- *
96
- * `businessId` + `environment` are the stable identity; the ORIGIN it is fetched
97
- * from is deployment-specific (production CDN vs. a local object store), which is
98
- * why `cdnBaseUrl` exists. Codegen bakes only the identity, so one committed
99
- * generated file works in every environment and only an env var changes.
100
- *
101
- * `cdnUrl` remains supported and WINS when present — every client repo generated
102
- * before `cdnBaseUrl` passes one, and those must keep working untouched.
103
- */
104
- interface TrackingConfigReference {
105
- /**
106
- * Fully-resolved object URL. Optional: omit it and pass `cdnBaseUrl` (or rely
107
- * on the production default) to have it composed from the identity below.
108
- */
109
- cdnUrl?: string;
110
- /**
111
- * Origin (optionally with a path prefix) the config object is served from, e.g.
112
- * `https://demos.aranova.io` in production or
113
- * `http://localhost:9100/aranova-demos` against a local MinIO. Ignored when
114
- * `cdnUrl` is set; blank or omitted falls back to {@link DEFAULT_CDN_BASE_URL}.
115
- * `tracking-cli gen` wires this to an env var so retargeting is config, not code.
116
- */
117
- cdnBaseUrl?: string;
118
- businessId: string;
119
- environment: "production" | "test";
120
- }
121
- /**
122
- * The URL a reference resolves to. An explicit `cdnUrl` wins (back-compat);
123
- * otherwise compose from `cdnBaseUrl` (or the production default).
124
- *
125
- * A blank/whitespace `cdnBaseUrl` is treated as UNSET rather than composed: the
126
- * generated module reads it from an env var, and a var that is present-but-empty
127
- * (a stray `NEXT_PUBLIC_ARANOVA_CDN_BASE_URL=` line) would otherwise produce
128
- * `/tracking-config/...` — a same-origin request to the client's own site.
129
- */
130
- declare function resolveTrackingConfigUrl(ref: TrackingConfigReference): string;
131
- type RuntimeState = "unconfirmed" | "active" | "tombstone";
132
- interface QueuedConversion {
133
- key: string;
134
- value?: number | null;
135
- currency?: string | null;
136
- transactionId?: string | null;
137
- }
138
- type TrackingConfigConversionOptions = Omit<QueuedConversion, "key">;
139
- interface QueuedPageView {
140
- href: string;
141
- title: string | null;
142
- referrer: string | null;
143
- }
144
- declare class TrackingConfigRuntime {
145
- readonly ref: TrackingConfigReference;
146
- private readonly fetchImpl;
147
- /** Resolved config URL — see the constructor for why it is computed once. */
148
- private readonly url;
149
- private current;
150
- private etag;
151
- private stateValue;
152
- private confirmedAt;
153
- private authorityGeneration;
154
- private inFlight;
155
- private flushInFlight;
156
- private flushRequested;
157
- private retryTimer;
158
- private started;
159
- /** Consecutive failed authority attempts — drives the revalidate backoff. */
160
- private authorityFailures;
161
- /** Epoch ms before which `ensureAuthority` must not issue another request. */
162
- private nextAuthorityAttemptAt;
163
- private readonly conversionQueue;
164
- private readonly automaticQueue;
165
- private readonly pageQueue;
166
- private readonly listeners;
167
- constructor(ref: TrackingConfigReference, fetchImpl?: typeof fetch);
168
- /** The URL this runtime actually fetches (composed or explicit). */
169
- configUrl(): string;
170
- /**
171
- * Explicitly start authority resolution and Google-tag bootstrap.
172
- *
173
- * Idempotent so framework effects can call it after hydration without
174
- * depending on constructor timing.
175
- */
176
- start(): void;
177
- state(): RuntimeState;
178
- config(): ConversionConfig | null;
179
- __unsafeExpireAuthorityForTests(): void;
180
- /** Queue depths — asserted by tests to pin the bound. */
181
- __queueDepthsForTests(): {
182
- conversions: number;
183
- automatic: number;
184
- pages: number;
185
- };
186
- subscribe(listener: () => void): () => void;
187
- ensureAuthority(): Promise<boolean>;
188
- revalidate(): Promise<void>;
189
- private revalidateAuthority;
190
- queuePageView(snapshot?: QueuedPageView | null): void;
191
- fireConversion(key: string, options?: TrackingConfigConversionOptions): void;
192
- queueAutomaticEvent(eventType: string, metadata: Record<string, unknown>, transactionPath: string, transactionScope: string): void;
193
- listGoals(): ConversionGoal[];
194
- private revalidateNow;
195
- private expireAuthority;
196
- private confirm;
197
- private flush;
198
- private scheduleRetry;
199
- private flushNow;
200
- }
201
- declare function getTrackingConfigRuntime(ref: TrackingConfigReference, fetchImpl?: typeof fetch): TrackingConfigRuntime;
202
-
203
15
  /**
204
16
  * Sales / Conversions wire schemas — the client-side source of truth.
205
17
  *
@@ -1046,4 +858,4 @@ interface PublicServiceItem {
1046
858
  */
1047
859
  declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
1048
860
 
1049
- export { type SalesClient as $, AranovaApiError as A, type BusinessConfig as B, type ConversionConfig as C, type DistinctCustomersByCurrency as D, type SaleItem as E, type SaleItemInput as F, type Granularity as G, type SaleKeysetSortField as H, type SaleListPage as I, type SaleListQuery as J, type SaleListQueryV2 as K, type SaleService as L, type SaleServiceInput as M, NAMED_RANGES as N, type SaleSortField as O, type PublicServiceItem as P, type SaleSortOrder as Q, type SaleSummary as R, SUPPORTED_CURRENCIES as S, type TrackingConfigReference as T, type SaleSummaryPrevious as U, type SaleSummaryQuery as V, type SaleSummaryQueryV2 as W, type SaleSummaryV2 as X, type SaleUpdateInput as Y, type SalesBusinessClient as Z, type SalesCategoryBreakdown as _, type BusinessConfigFeatures as a, type SalesClientConfig as a0, type SalesCustomersClient as a1, type SalesServiceBreakdown as a2, type SalesTransportConfig as a3, type SalesTrendPoint as a4, type SummaryCurrencyDelta as a5, type SummaryDeltas as a6, type SummaryWindow as a7, type SupportedCurrency as a8, TRACKING_RANGES as a9, type TrackingOverviewRange as aa, clearStashedUserData as ab, createSalesClient as ac, fetchServices as ad, formatDateInTz as ae, formatMoney as af, fromMinor as ag, getTrackingConfigRuntime as ah, resolveConversionConfig as ai, resolveTrackingConfigUrl as aj, saleCreateSchema as ak, saleItemSchema as al, saleServiceSchema as am, saleUpdateSchema as an, salesRequest as ao, stashUserData as ap, toMinor as aq, type BusinessConfigService as b, type CompareTo as c, type ConversionConfigStore as d, type ConversionUserData as e, type CurrencyRevenue as f, type CustomerCurrencyDelta as g, type CustomerCurrencyTotal as h, type CustomerGetOptions as i, type CustomerGetResult as j, type CustomerKpis as k, type CustomerKpisDeltas as l, type CustomerKpisPrevious as m, type CustomerListPage as n, type CustomerListQuery as o, type CustomerProfile as p, type CustomerSegment as q, type CustomerSegmentCount as r, type CustomerSortField as s, type CustomerSummary as t, type CustomerSummaryQuery as u, type NamedRange as v, type Sale as w, type SaleCursorPage as x, type SaleFilters as y, type SaleInput as z };
861
+ export { type SalesServiceBreakdown as $, AranovaApiError as A, type BusinessConfig as B, type CompareTo as C, type DistinctCustomersByCurrency as D, type SaleKeysetSortField as E, type SaleListPage as F, type Granularity as G, type SaleListQuery as H, type SaleListQueryV2 as I, type SaleService as J, type SaleServiceInput as K, type SaleSortField as L, type SaleSortOrder as M, NAMED_RANGES as N, type SaleSummary as O, type PublicServiceItem as P, type SaleSummaryPrevious as Q, type SaleSummaryQuery as R, SUPPORTED_CURRENCIES as S, type SaleSummaryQueryV2 as T, type SaleSummaryV2 as U, type SaleUpdateInput as V, type SalesBusinessClient as W, type SalesCategoryBreakdown as X, type SalesClient as Y, type SalesClientConfig as Z, type SalesCustomersClient as _, type BusinessConfigFeatures as a, type SalesTransportConfig as a0, type SalesTrendPoint as a1, type SummaryCurrencyDelta as a2, type SummaryDeltas as a3, type SummaryWindow as a4, type SupportedCurrency as a5, TRACKING_RANGES as a6, type TrackingOverviewRange as a7, clearStashedUserData as a8, createSalesClient as a9, fetchServices as aa, formatDateInTz as ab, formatMoney as ac, fromMinor as ad, saleCreateSchema as ae, saleItemSchema as af, saleServiceSchema as ag, saleUpdateSchema as ah, salesRequest as ai, stashUserData as aj, toMinor as ak, type BusinessConfigService as b, type ConversionUserData as c, type CurrencyRevenue as d, type CustomerCurrencyDelta as e, type CustomerCurrencyTotal as f, type CustomerGetOptions as g, type CustomerGetResult as h, type CustomerKpis as i, type CustomerKpisDeltas as j, type CustomerKpisPrevious as k, type CustomerListPage as l, type CustomerListQuery as m, type CustomerProfile as n, type CustomerSegment as o, type CustomerSegmentCount as p, type CustomerSortField as q, type CustomerSummary as r, type CustomerSummaryQuery as s, type NamedRange as t, type Sale as u, type SaleCursorPage as v, type SaleFilters as w, type SaleInput as x, type SaleItem as y, type SaleItemInput as z };
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { a as ConversionConfigStore, c as TrackingConfigRuntime } from './tracking-config-runtime-BnUlS_Ae.mjs';
2
3
  import { CountryCode } from 'libphonenumber-js';
3
4
 
4
5
  /** Raw identifiers a caller may hand us (normalized before use). */
@@ -11,195 +12,6 @@ declare function stashUserData(data: ConversionUserData, country?: CountryCode):
11
12
  /** Drop everything (consent denial, tests). */
12
13
  declare function clearStashedUserData(): void;
13
14
 
14
- interface ServiceFiring {
15
- send_to: string;
16
- /** Action's configured default value (cents); the SDK fires it only when a sale has no amount. */
17
- value_cents?: number | null;
18
- currency?: string | null;
19
- }
20
- /** Serializable on-page trigger (owned by tracking-core/src/events/trigger-spec.ts). The shape
21
- * varies by `event_type`; only the parameter for that type is set. */
22
- interface ConfigTriggerSpec {
23
- event_type: string;
24
- threshold_percent?: number;
25
- threshold_seconds?: number;
26
- page_threshold?: number;
27
- page_name?: string;
28
- }
29
- /** One unified conversion goal: a revenue `sale` or an on-page `event`. */
30
- interface ConversionGoal {
31
- key: string;
32
- label?: string;
33
- kind: "sale" | "event";
34
- /** Structured fire-when for event-goals; null for sales. */
35
- trigger: ConfigTriggerSpec | null;
36
- firing: ServiceFiring | null;
37
- }
38
- interface ConversionConfig {
39
- schema_version: number;
40
- config_version: number;
41
- business_id?: string;
42
- customer_id?: string | null;
43
- environment?: string;
44
- google_tracking_state: "active" | "disabled";
45
- gtag_ids: Record<string, string>;
46
- meta_pixel_ids: Record<string, string>;
47
- /** LEGACY: sale-goals only (for pre-unified-goal readers). */
48
- services: Array<{
49
- key: string;
50
- label?: string;
51
- firing: ServiceFiring | null;
52
- }>;
53
- /** Unified goal list (sales + on-page events). Superset of `services`. */
54
- goals: ConversionGoal[];
55
- }
56
- interface ConversionConfigStore {
57
- /** Firing config for a goal/service key, or null when it doesn't fire on-site. */
58
- getFiring(key: string): ServiceFiring | null;
59
- /** The full goal for a key, or null when unknown. */
60
- getGoal(key: string): ConversionGoal | null;
61
- /** Every adopted goal (sales + events). */
62
- listGoals(): ConversionGoal[];
63
- /** The currently adopted config (baked / cached fallback until the fetch lands). */
64
- current(): ConversionConfig | null;
65
- /** True once a config is adopted (seeded synchronously from cache/baked, or fetched). */
66
- isReady(): boolean;
67
- /**
68
- * Run `listener` when a config first becomes available — immediately if already
69
- * ready, otherwise on the first adopt. Lets auto-fire replay automatic events that
70
- * occurred before the async CDN fetch resolved. Returns an unsubscribe fn.
71
- */
72
- onResolve(listener: () => void): () => void;
73
- /** Force a background revalidate against the CDN object. */
74
- revalidate(): Promise<void>;
75
- }
76
- interface ResolveConversionConfigOptions {
77
- /** Full URL of the per-business CDN object. */
78
- cdnUrl: string;
79
- /** Offline-correct fallback (e.g. the CLI-baked snapshot). */
80
- baked?: ConversionConfig | null;
81
- /** Injectable for tests / non-global-fetch runtimes. */
82
- fetchImpl?: typeof fetch;
83
- }
84
- /**
85
- * Resolve the config with stale-while-revalidate: seed synchronously from the
86
- * sessionStorage cache (or the baked fallback), then conditionally re-fetch the CDN object
87
- * with `If-None-Match`. A fetched object is adopted only if its `config_version` is strictly
88
- * greater than what's cached, so a reordered edge copy can't downgrade fresher state.
89
- * Non-blocking and browser-only; a failed fetch leaves the seed in place.
90
- */
91
- declare function resolveConversionConfig(options: ResolveConversionConfigOptions): ConversionConfigStore;
92
-
93
- /**
94
- * Where a business's published tracking config lives.
95
- *
96
- * `businessId` + `environment` are the stable identity; the ORIGIN it is fetched
97
- * from is deployment-specific (production CDN vs. a local object store), which is
98
- * why `cdnBaseUrl` exists. Codegen bakes only the identity, so one committed
99
- * generated file works in every environment and only an env var changes.
100
- *
101
- * `cdnUrl` remains supported and WINS when present — every client repo generated
102
- * before `cdnBaseUrl` passes one, and those must keep working untouched.
103
- */
104
- interface TrackingConfigReference {
105
- /**
106
- * Fully-resolved object URL. Optional: omit it and pass `cdnBaseUrl` (or rely
107
- * on the production default) to have it composed from the identity below.
108
- */
109
- cdnUrl?: string;
110
- /**
111
- * Origin (optionally with a path prefix) the config object is served from, e.g.
112
- * `https://demos.aranova.io` in production or
113
- * `http://localhost:9100/aranova-demos` against a local MinIO. Ignored when
114
- * `cdnUrl` is set; blank or omitted falls back to {@link DEFAULT_CDN_BASE_URL}.
115
- * `tracking-cli gen` wires this to an env var so retargeting is config, not code.
116
- */
117
- cdnBaseUrl?: string;
118
- businessId: string;
119
- environment: "production" | "test";
120
- }
121
- /**
122
- * The URL a reference resolves to. An explicit `cdnUrl` wins (back-compat);
123
- * otherwise compose from `cdnBaseUrl` (or the production default).
124
- *
125
- * A blank/whitespace `cdnBaseUrl` is treated as UNSET rather than composed: the
126
- * generated module reads it from an env var, and a var that is present-but-empty
127
- * (a stray `NEXT_PUBLIC_ARANOVA_CDN_BASE_URL=` line) would otherwise produce
128
- * `/tracking-config/...` — a same-origin request to the client's own site.
129
- */
130
- declare function resolveTrackingConfigUrl(ref: TrackingConfigReference): string;
131
- type RuntimeState = "unconfirmed" | "active" | "tombstone";
132
- interface QueuedConversion {
133
- key: string;
134
- value?: number | null;
135
- currency?: string | null;
136
- transactionId?: string | null;
137
- }
138
- type TrackingConfigConversionOptions = Omit<QueuedConversion, "key">;
139
- interface QueuedPageView {
140
- href: string;
141
- title: string | null;
142
- referrer: string | null;
143
- }
144
- declare class TrackingConfigRuntime {
145
- readonly ref: TrackingConfigReference;
146
- private readonly fetchImpl;
147
- /** Resolved config URL — see the constructor for why it is computed once. */
148
- private readonly url;
149
- private current;
150
- private etag;
151
- private stateValue;
152
- private confirmedAt;
153
- private authorityGeneration;
154
- private inFlight;
155
- private flushInFlight;
156
- private flushRequested;
157
- private retryTimer;
158
- private started;
159
- /** Consecutive failed authority attempts — drives the revalidate backoff. */
160
- private authorityFailures;
161
- /** Epoch ms before which `ensureAuthority` must not issue another request. */
162
- private nextAuthorityAttemptAt;
163
- private readonly conversionQueue;
164
- private readonly automaticQueue;
165
- private readonly pageQueue;
166
- private readonly listeners;
167
- constructor(ref: TrackingConfigReference, fetchImpl?: typeof fetch);
168
- /** The URL this runtime actually fetches (composed or explicit). */
169
- configUrl(): string;
170
- /**
171
- * Explicitly start authority resolution and Google-tag bootstrap.
172
- *
173
- * Idempotent so framework effects can call it after hydration without
174
- * depending on constructor timing.
175
- */
176
- start(): void;
177
- state(): RuntimeState;
178
- config(): ConversionConfig | null;
179
- __unsafeExpireAuthorityForTests(): void;
180
- /** Queue depths — asserted by tests to pin the bound. */
181
- __queueDepthsForTests(): {
182
- conversions: number;
183
- automatic: number;
184
- pages: number;
185
- };
186
- subscribe(listener: () => void): () => void;
187
- ensureAuthority(): Promise<boolean>;
188
- revalidate(): Promise<void>;
189
- private revalidateAuthority;
190
- queuePageView(snapshot?: QueuedPageView | null): void;
191
- fireConversion(key: string, options?: TrackingConfigConversionOptions): void;
192
- queueAutomaticEvent(eventType: string, metadata: Record<string, unknown>, transactionPath: string, transactionScope: string): void;
193
- listGoals(): ConversionGoal[];
194
- private revalidateNow;
195
- private expireAuthority;
196
- private confirm;
197
- private flush;
198
- private scheduleRetry;
199
- private flushNow;
200
- }
201
- declare function getTrackingConfigRuntime(ref: TrackingConfigReference, fetchImpl?: typeof fetch): TrackingConfigRuntime;
202
-
203
15
  /**
204
16
  * Sales / Conversions wire schemas — the client-side source of truth.
205
17
  *
@@ -1046,4 +858,4 @@ interface PublicServiceItem {
1046
858
  */
1047
859
  declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
1048
860
 
1049
- export { type SalesClient as $, AranovaApiError as A, type BusinessConfig as B, type ConversionConfig as C, type DistinctCustomersByCurrency as D, type SaleItem as E, type SaleItemInput as F, type Granularity as G, type SaleKeysetSortField as H, type SaleListPage as I, type SaleListQuery as J, type SaleListQueryV2 as K, type SaleService as L, type SaleServiceInput as M, NAMED_RANGES as N, type SaleSortField as O, type PublicServiceItem as P, type SaleSortOrder as Q, type SaleSummary as R, SUPPORTED_CURRENCIES as S, type TrackingConfigReference as T, type SaleSummaryPrevious as U, type SaleSummaryQuery as V, type SaleSummaryQueryV2 as W, type SaleSummaryV2 as X, type SaleUpdateInput as Y, type SalesBusinessClient as Z, type SalesCategoryBreakdown as _, type BusinessConfigFeatures as a, type SalesClientConfig as a0, type SalesCustomersClient as a1, type SalesServiceBreakdown as a2, type SalesTransportConfig as a3, type SalesTrendPoint as a4, type SummaryCurrencyDelta as a5, type SummaryDeltas as a6, type SummaryWindow as a7, type SupportedCurrency as a8, TRACKING_RANGES as a9, type TrackingOverviewRange as aa, clearStashedUserData as ab, createSalesClient as ac, fetchServices as ad, formatDateInTz as ae, formatMoney as af, fromMinor as ag, getTrackingConfigRuntime as ah, resolveConversionConfig as ai, resolveTrackingConfigUrl as aj, saleCreateSchema as ak, saleItemSchema as al, saleServiceSchema as am, saleUpdateSchema as an, salesRequest as ao, stashUserData as ap, toMinor as aq, type BusinessConfigService as b, type CompareTo as c, type ConversionConfigStore as d, type ConversionUserData as e, type CurrencyRevenue as f, type CustomerCurrencyDelta as g, type CustomerCurrencyTotal as h, type CustomerGetOptions as i, type CustomerGetResult as j, type CustomerKpis as k, type CustomerKpisDeltas as l, type CustomerKpisPrevious as m, type CustomerListPage as n, type CustomerListQuery as o, type CustomerProfile as p, type CustomerSegment as q, type CustomerSegmentCount as r, type CustomerSortField as s, type CustomerSummary as t, type CustomerSummaryQuery as u, type NamedRange as v, type Sale as w, type SaleCursorPage as x, type SaleFilters as y, type SaleInput as z };
861
+ export { type SalesServiceBreakdown as $, AranovaApiError as A, type BusinessConfig as B, type CompareTo as C, type DistinctCustomersByCurrency as D, type SaleKeysetSortField as E, type SaleListPage as F, type Granularity as G, type SaleListQuery as H, type SaleListQueryV2 as I, type SaleService as J, type SaleServiceInput as K, type SaleSortField as L, type SaleSortOrder as M, NAMED_RANGES as N, type SaleSummary as O, type PublicServiceItem as P, type SaleSummaryPrevious as Q, type SaleSummaryQuery as R, SUPPORTED_CURRENCIES as S, type SaleSummaryQueryV2 as T, type SaleSummaryV2 as U, type SaleUpdateInput as V, type SalesBusinessClient as W, type SalesCategoryBreakdown as X, type SalesClient as Y, type SalesClientConfig as Z, type SalesCustomersClient as _, type BusinessConfigFeatures as a, type SalesTransportConfig as a0, type SalesTrendPoint as a1, type SummaryCurrencyDelta as a2, type SummaryDeltas as a3, type SummaryWindow as a4, type SupportedCurrency as a5, TRACKING_RANGES as a6, type TrackingOverviewRange as a7, clearStashedUserData as a8, createSalesClient as a9, fetchServices as aa, formatDateInTz as ab, formatMoney as ac, fromMinor as ad, saleCreateSchema as ae, saleItemSchema as af, saleServiceSchema as ag, saleUpdateSchema as ah, salesRequest as ai, stashUserData as aj, toMinor as ak, type BusinessConfigService as b, type ConversionUserData as c, type CurrencyRevenue as d, type CustomerCurrencyDelta as e, type CustomerCurrencyTotal as f, type CustomerGetOptions as g, type CustomerGetResult as h, type CustomerKpis as i, type CustomerKpisDeltas as j, type CustomerKpisPrevious as k, type CustomerListPage as l, type CustomerListQuery as m, type CustomerProfile as n, type CustomerSegment as o, type CustomerSegmentCount as p, type CustomerSortField as q, type CustomerSummary as r, type CustomerSummaryQuery as s, type NamedRange as t, type Sale as u, type SaleCursorPage as v, type SaleFilters as w, type SaleInput as x, type SaleItem as y, type SaleItemInput as z };
package/dist/sales.d.mts CHANGED
@@ -1,3 +1,4 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ak as saleCreateSchema, al as saleItemSchema, am as saleServiceSchema, an as saleUpdateSchema, ao as salesRequest, aq as toMinor } from './sales-BwWnvl8L.mjs';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, u as Sale, v as SaleCursorPage, w as SaleFilters, x as SaleInput, y as SaleItem, z as SaleItemInput, E as SaleKeysetSortField, F as SaleListPage, H as SaleListQuery, I as SaleListQueryV2, J as SaleService, K as SaleServiceInput, L as SaleSortField, M as SaleSortOrder, O as SaleSummary, Q as SaleSummaryPrevious, R as SaleSummaryQuery, T as SaleSummaryQueryV2, U as SaleSummaryV2, V as SaleUpdateInput, W as SalesBusinessClient, X as SalesCategoryBreakdown, Y as SalesClient, Z as SalesClientConfig, _ as SalesCustomersClient, $ as SalesServiceBreakdown, a0 as SalesTransportConfig, a1 as SalesTrendPoint, a2 as SummaryCurrencyDelta, a3 as SummaryDeltas, a4 as SummaryWindow, a5 as SupportedCurrency, a6 as TRACKING_RANGES, a7 as TrackingOverviewRange, a9 as createSalesClient, aa as fetchServices, ab as formatDateInTz, ac as formatMoney, ad as fromMinor, ae as saleCreateSchema, af as saleItemSchema, ag as saleServiceSchema, ah as saleUpdateSchema, ai as salesRequest, ak as toMinor } from './sales-C3B0BOBQ.mjs';
2
2
  import 'zod';
3
+ import './tracking-config-runtime-BnUlS_Ae.mjs';
3
4
  import 'libphonenumber-js';
package/dist/sales.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ak as saleCreateSchema, al as saleItemSchema, am as saleServiceSchema, an as saleUpdateSchema, ao as salesRequest, aq as toMinor } from './sales-BwWnvl8L.js';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, u as Sale, v as SaleCursorPage, w as SaleFilters, x as SaleInput, y as SaleItem, z as SaleItemInput, E as SaleKeysetSortField, F as SaleListPage, H as SaleListQuery, I as SaleListQueryV2, J as SaleService, K as SaleServiceInput, L as SaleSortField, M as SaleSortOrder, O as SaleSummary, Q as SaleSummaryPrevious, R as SaleSummaryQuery, T as SaleSummaryQueryV2, U as SaleSummaryV2, V as SaleUpdateInput, W as SalesBusinessClient, X as SalesCategoryBreakdown, Y as SalesClient, Z as SalesClientConfig, _ as SalesCustomersClient, $ as SalesServiceBreakdown, a0 as SalesTransportConfig, a1 as SalesTrendPoint, a2 as SummaryCurrencyDelta, a3 as SummaryDeltas, a4 as SummaryWindow, a5 as SupportedCurrency, a6 as TRACKING_RANGES, a7 as TrackingOverviewRange, a9 as createSalesClient, aa as fetchServices, ab as formatDateInTz, ac as formatMoney, ad as fromMinor, ae as saleCreateSchema, af as saleItemSchema, ag as saleServiceSchema, ah as saleUpdateSchema, ai as salesRequest, ak as toMinor } from './sales-BIij04IG.js';
2
2
  import 'zod';
3
+ import './tracking-config-runtime-BnUlS_Ae.js';
3
4
  import 'libphonenumber-js';