@aranova/tracking-next 0.22.3 → 0.22.4

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.mts 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.mjs';
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.mjs';
3
- import { T as TrackingConfigReference, C as ConversionConfig } from './sales-ChA6g-GJ.mjs';
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-ChA6g-GJ.mjs';
3
+ import { T as TrackingConfigReference, C as ConversionConfig } from './sales-B4_KmZP1.mjs';
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-B4_KmZP1.mjs';
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.mjs';
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-PttMfkw0.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-PttMfkw0.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';
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';
package/dist/index.js CHANGED
@@ -1146,6 +1146,9 @@ function formatMoney(cents, currency, locale) {
1146
1146
  // ../tracking-core/src/resources/tracking-config-runtime.ts
1147
1147
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
1148
1148
  var AUTHORITY_TTL_MS = 6e4;
1149
+ var MAX_QUEUE_LENGTH = 50;
1150
+ var RETRY_BASE_MS = 5e3;
1151
+ var RETRY_MAX_MS = 5 * 6e4;
1149
1152
  var runtimes = /* @__PURE__ */ new Map();
1150
1153
  var configuredIds = /* @__PURE__ */ new Set();
1151
1154
  var scriptLoad = null;
@@ -1153,6 +1156,10 @@ var jsInitialized = false;
1153
1156
  function cacheKey2(url) {
1154
1157
  return `${CACHE_PREFIX2}${url}`;
1155
1158
  }
1159
+ function pushBounded(queue, item) {
1160
+ queue.push(item);
1161
+ if (queue.length > MAX_QUEUE_LENGTH) queue.splice(0, queue.length - MAX_QUEUE_LENGTH);
1162
+ }
1156
1163
  function readCache2(url) {
1157
1164
  if (typeof window === "undefined") return null;
1158
1165
  try {
@@ -1233,6 +1240,10 @@ var TrackingConfigRuntime = class {
1233
1240
  this.flushRequested = false;
1234
1241
  this.retryTimer = null;
1235
1242
  this.started = false;
1243
+ /** Consecutive failed authority attempts — drives the revalidate backoff. */
1244
+ this.authorityFailures = 0;
1245
+ /** Epoch ms before which `ensureAuthority` must not issue another request. */
1246
+ this.nextAuthorityAttemptAt = 0;
1236
1247
  this.conversionQueue = [];
1237
1248
  this.automaticQueue = [];
1238
1249
  this.pageQueue = [];
@@ -1271,6 +1282,15 @@ var TrackingConfigRuntime = class {
1271
1282
  }
1272
1283
  __unsafeExpireAuthorityForTests() {
1273
1284
  this.confirmedAt = Number.NEGATIVE_INFINITY;
1285
+ this.nextAuthorityAttemptAt = 0;
1286
+ }
1287
+ /** Queue depths — asserted by tests to pin the bound. */
1288
+ __queueDepthsForTests() {
1289
+ return {
1290
+ conversions: this.conversionQueue.length,
1291
+ automatic: this.automaticQueue.length,
1292
+ pages: this.pageQueue.length
1293
+ };
1274
1294
  }
1275
1295
  subscribe(listener) {
1276
1296
  this.listeners.add(listener);
@@ -1280,10 +1300,12 @@ var TrackingConfigRuntime = class {
1280
1300
  if (this.stateValue !== "unconfirmed" && Date.now() - this.confirmedAt < AUTHORITY_TTL_MS) {
1281
1301
  return true;
1282
1302
  }
1303
+ if (Date.now() < this.nextAuthorityAttemptAt) return false;
1283
1304
  await this.revalidateAuthority();
1284
1305
  return this.stateValue !== "unconfirmed" && Date.now() - this.confirmedAt < AUTHORITY_TTL_MS;
1285
1306
  }
1286
1307
  async revalidate() {
1308
+ this.nextAuthorityAttemptAt = 0;
1287
1309
  await this.revalidateAuthority();
1288
1310
  await this.flush();
1289
1311
  }
@@ -1297,15 +1319,20 @@ var TrackingConfigRuntime = class {
1297
1319
  }
1298
1320
  queuePageView(snapshot = pageViewSnapshot()) {
1299
1321
  if (!snapshot) return;
1300
- this.pageQueue.push(snapshot);
1322
+ pushBounded(this.pageQueue, snapshot);
1301
1323
  void this.flush();
1302
1324
  }
1303
1325
  fireConversion(key, options) {
1304
- this.conversionQueue.push({ key, ...options });
1326
+ pushBounded(this.conversionQueue, { key, ...options });
1305
1327
  void this.flush();
1306
1328
  }
1307
1329
  queueAutomaticEvent(eventType, metadata, transactionPath, transactionScope) {
1308
- this.automaticQueue.push({ eventType, metadata, transactionPath, transactionScope });
1330
+ pushBounded(this.automaticQueue, {
1331
+ eventType,
1332
+ metadata,
1333
+ transactionPath,
1334
+ transactionScope
1335
+ });
1309
1336
  void this.flush();
1310
1337
  }
1311
1338
  listGoals() {
@@ -1345,12 +1372,17 @@ var TrackingConfigRuntime = class {
1345
1372
  expireAuthority() {
1346
1373
  this.authorityGeneration += 1;
1347
1374
  if (this.stateValue !== "unconfirmed") this.stateValue = "unconfirmed";
1375
+ this.authorityFailures += 1;
1376
+ const delay = Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** (this.authorityFailures - 1));
1377
+ this.nextAuthorityAttemptAt = Date.now() + delay;
1348
1378
  }
1349
1379
  confirm(config, etag) {
1350
1380
  this.authorityGeneration += 1;
1351
1381
  this.current = config;
1352
1382
  this.etag = etag;
1353
1383
  this.confirmedAt = Date.now();
1384
+ this.authorityFailures = 0;
1385
+ this.nextAuthorityAttemptAt = 0;
1354
1386
  this.stateValue = isTombstone(config) ? "tombstone" : "active";
1355
1387
  writeCache2(this.ref.cdnUrl, { etag, config });
1356
1388
  if (this.stateValue === "tombstone") {
@@ -1431,7 +1463,7 @@ var TrackingConfigRuntime = class {
1431
1463
  for (const goal of config.goals) {
1432
1464
  if (goal.kind !== "event" || !goal.firing) continue;
1433
1465
  if (!automaticThresholdMet(goal, event.eventType, event.metadata)) continue;
1434
- this.conversionQueue.push({
1466
+ pushBounded(this.conversionQueue, {
1435
1467
  key: goal.key,
1436
1468
  transactionId: getAutomaticTransactionId(
1437
1469
  event.transactionScope,
@@ -3644,7 +3676,7 @@ function GoogleAdsTracking(props) {
3644
3676
  var import_navigation3 = require("next/navigation");
3645
3677
 
3646
3678
  // package.json
3647
- var version = "0.22.3";
3679
+ var version = "0.22.4";
3648
3680
 
3649
3681
  // src/factory.tsx
3650
3682
  var import_react5 = require("react");