@aranova/tracking-next 0.22.4 → 0.23.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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TrackingParams, a as TrackingInstallSurface, b as TrackingEnvironment, c as TrackingClientContext, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, F as FormSubmitConfig, f as FormSubmitMetadata, C as ConsentState, g as ConsentChoiceState, h as ConsentSource, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, P as PhoneConfig, i as ParsedPhone, j as PhoneDisplayFormat } from './phone-utils-BhWfNuPS.js';
2
2
  export { k as ConsentChoice, D as DEFAULT_DECLINE_TTL_DAYS, l as DEFAULT_PHONE_COUNTRY, J as JsonValue, S as SetConsentOptions, m as TrackedField, n as TrackingInitConfig, o as formSubmitConfigSchema, p as formSubmitMetadataSchema, q as formatPhone, r as formatPhoneAsTyped, s as getConsentChoice, t as getConsentState, u as jsonValueSchema, v as onConsentChange, w as optIn, x as optOut, y as parsePhone, z as phoneField, A as resetConsent, B as setConsentState, E as toE164 } from './phone-utils-BhWfNuPS.js';
3
- import { T as TrackingConfigReference, C as ConversionConfig } from './sales-C5E4JcPP.js';
4
- export { B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, d as ConversionConfigStore, e as ConversionUserData, 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, A 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 clearStashedUserData, ab as createSalesClient, ac as fetchServices, ad as formatMoney, ae as fromMinor, af as getTrackingConfigRuntime, ag as resolveConversionConfig, ah as saleCreateSchema, ai as saleItemSchema, aj as saleServiceSchema, ak as saleUpdateSchema, al as salesRequest, am as stashUserData, an as toMinor } from './sales-C5E4JcPP.js';
3
+ import { T as TrackingConfigReference, C as ConversionConfig } from './sales-D_BTsRuM.js';
4
+ export { B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, d as ConversionConfigStore, e as ConversionUserData, 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, A 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 clearStashedUserData, ab as createSalesClient, ac as fetchServices, ad as formatMoney, ae as fromMinor, af as getTrackingConfigRuntime, ag as resolveConversionConfig, ah as resolveTrackingConfigUrl, ai as saleCreateSchema, aj as saleItemSchema, ak as saleServiceSchema, al as saleUpdateSchema, am as salesRequest, an as stashUserData, ao as toMinor } from './sales-D_BTsRuM.js';
5
5
  import { z } from 'zod';
6
6
  import * as src from 'src';
7
7
  export { A as AranovaApiError, f as formatDateInTz } from './date-BHetnL7s.js';
@@ -1710,6 +1710,13 @@ interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
1710
1710
  cdnUrl: string;
1711
1711
  baked?: ConversionConfig | null;
1712
1712
  };
1713
+ /**
1714
+ * R2-authoritative config reference — `ARANOVA_TRACKING_CONFIG` from
1715
+ * `tracking-cli gen`. Wins over `conversionConfig`. The object URL is composed
1716
+ * from `businessId` + `environment` against the production CDN; spread in a
1717
+ * `cdnBaseUrl` to read it from somewhere else, e.g.
1718
+ * `{ ...ARANOVA_TRACKING_CONFIG, cdnBaseUrl: process.env.NEXT_PUBLIC_ARANOVA_CDN_BASE_URL }`.
1719
+ */
1713
1720
  trackingConfig?: TrackingConfigReference;
1714
1721
  }
1715
1722
  interface TrackingProviderProps {
package/dist/index.js CHANGED
@@ -98,6 +98,7 @@ __export(src_exports, {
98
98
  resetConsent: () => resetConsent,
99
99
  resolveBrowserTimeZone: () => resolveBrowserTimeZone,
100
100
  resolveConversionConfig: () => resolveConversionConfig,
101
+ resolveTrackingConfigUrl: () => resolveTrackingConfigUrl,
101
102
  saleCreateSchema: () => saleCreateSchema,
102
103
  saleItemSchema: () => saleItemSchema,
103
104
  saleServiceSchema: () => saleServiceSchema,
@@ -1144,6 +1145,16 @@ function formatMoney(cents, currency, locale) {
1144
1145
  }
1145
1146
 
1146
1147
  // ../tracking-core/src/resources/tracking-config-runtime.ts
1148
+ var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
1149
+ function trackingConfigKey(businessId, environment) {
1150
+ return `tracking-config/v1/${businessId}-${environment}.json`;
1151
+ }
1152
+ function resolveTrackingConfigUrl(ref) {
1153
+ if (ref.cdnUrl) return ref.cdnUrl;
1154
+ const configured = ref.cdnBaseUrl?.trim();
1155
+ const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
1156
+ return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
1157
+ }
1147
1158
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
1148
1159
  var AUTHORITY_TTL_MS = 6e4;
1149
1160
  var MAX_QUEUE_LENGTH = 50;
@@ -1249,11 +1260,16 @@ var TrackingConfigRuntime = class {
1249
1260
  this.pageQueue = [];
1250
1261
  this.listeners = /* @__PURE__ */ new Set();
1251
1262
  this.fetchImpl = fetchImpl.bind(globalThis);
1252
- const cached = readCache2(ref.cdnUrl);
1263
+ this.url = resolveTrackingConfigUrl(ref);
1264
+ const cached = readCache2(this.url);
1253
1265
  this.current = cached?.config ?? null;
1254
1266
  this.etag = cached?.etag ?? null;
1255
1267
  this.start();
1256
1268
  }
1269
+ /** The URL this runtime actually fetches (composed or explicit). */
1270
+ configUrl() {
1271
+ return this.url;
1272
+ }
1257
1273
  /**
1258
1274
  * Explicitly start authority resolution and Google-tag bootstrap.
1259
1275
  *
@@ -1342,7 +1358,7 @@ var TrackingConfigRuntime = class {
1342
1358
  try {
1343
1359
  const headers = {};
1344
1360
  if (this.etag) headers["If-None-Match"] = this.etag;
1345
- const response = await this.fetchImpl(this.ref.cdnUrl, {
1361
+ const response = await this.fetchImpl(this.url, {
1346
1362
  method: "GET",
1347
1363
  headers,
1348
1364
  cache: "no-cache"
@@ -1384,7 +1400,7 @@ var TrackingConfigRuntime = class {
1384
1400
  this.authorityFailures = 0;
1385
1401
  this.nextAuthorityAttemptAt = 0;
1386
1402
  this.stateValue = isTombstone(config) ? "tombstone" : "active";
1387
- writeCache2(this.ref.cdnUrl, { etag, config });
1403
+ writeCache2(this.url, { etag, config });
1388
1404
  if (this.stateValue === "tombstone") {
1389
1405
  if (this.retryTimer !== null) {
1390
1406
  window.clearTimeout(this.retryTimer);
@@ -1499,7 +1515,7 @@ var TrackingConfigRuntime = class {
1499
1515
  }
1500
1516
  };
1501
1517
  function getTrackingConfigRuntime(ref, fetchImpl) {
1502
- const key = `${ref.cdnUrl}|${ref.businessId}|${ref.environment}`;
1518
+ const key = `${resolveTrackingConfigUrl(ref)}|${ref.businessId}|${ref.environment}`;
1503
1519
  const existing = runtimes.get(key);
1504
1520
  if (existing) return existing;
1505
1521
  const runtime = new TrackingConfigRuntime(ref, fetchImpl ?? globalThis.fetch);
@@ -3617,13 +3633,13 @@ function AdPlatformTracking({
3617
3633
  metaPixelId,
3618
3634
  metaPixelIds
3619
3635
  }) {
3620
- const trackingConfigKey = trackingConfig ? `${trackingConfig.cdnUrl}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
3636
+ const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
3621
3637
  (0, import_react3.useEffect)(() => {
3622
3638
  if (!trackingConfig) return;
3623
3639
  const runtime = getTrackingConfigRuntime(trackingConfig);
3624
3640
  if (standalonePageView) runtime.queuePageView();
3625
3641
  else runtime.start();
3626
- }, [trackingConfigKey, standalonePageView]);
3642
+ }, [trackingConfigKey2, standalonePageView]);
3627
3643
  const gtagAll = trackingConfig ? [] : gtagIds ? Object.values(gtagIds).filter((id) => id != null) : gtagId ? [gtagId] : [];
3628
3644
  const metaAll = metaPixelIds ? Object.values(metaPixelIds).filter((id) => id != null) : metaPixelId ? [metaPixelId] : [];
3629
3645
  if (trackingConfig || gtagAll.length > 0) registerCapability("ad_tags_google");
@@ -3676,7 +3692,7 @@ function GoogleAdsTracking(props) {
3676
3692
  var import_navigation3 = require("next/navigation");
3677
3693
 
3678
3694
  // package.json
3679
- var version = "0.22.4";
3695
+ var version = "0.23.1";
3680
3696
 
3681
3697
  // src/factory.tsx
3682
3698
  var import_react5 = require("react");
@@ -4445,6 +4461,7 @@ function useBookingForm(options = {}) {
4445
4461
  resetConsent,
4446
4462
  resolveBrowserTimeZone,
4447
4463
  resolveConversionConfig,
4464
+ resolveTrackingConfigUrl,
4448
4465
  saleCreateSchema,
4449
4466
  saleItemSchema,
4450
4467
  saleServiceSchema,