@aranova/tracking-react 0.21.0 → 0.22.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.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
3
- 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, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, C as ConsentState, g as ConsentChoiceState, h as ConsentSource, P as PhoneConfig, i as ParsedPhone, j as PhoneDisplayFormat } from './phone-utils-B2vHJkNz.mjs';
4
- 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-B2vHJkNz.mjs';
5
- import { T as TrackingConfigReference, C as ConversionConfig } from './sales-CBQJ2SBT.mjs';
6
- export { A as AranovaApiError, 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, 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, ab as clearStashedUserData, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ah as getTrackingConfigRuntime, ai as resolveConversionConfig, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ao as stashUserData, ap as toMinor } from './sales-CBQJ2SBT.mjs';
3
+ 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, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, C as ConsentState, g as ConsentChoiceState, h as ConsentSource, P as PhoneConfig, i as ParsedPhone, j as PhoneDisplayFormat } from './phone-utils-BhWfNuPS.mjs';
4
+ 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';
5
+ import { T as TrackingConfigReference, C as ConversionConfig } from './sales-BhCYJqDy.mjs';
6
+ export { A as AranovaApiError, 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, 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, ab as clearStashedUserData, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ah as getTrackingConfigRuntime, ai as resolveConversionConfig, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ao as stashUserData, ap as toMinor } from './sales-BhCYJqDy.mjs';
7
7
  import * as src from 'src';
8
8
  import { z } from 'zod';
9
9
  import { CountryCode } from 'libphonenumber-js';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent } from 'react';
3
- 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, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, C as ConsentState, g as ConsentChoiceState, h as ConsentSource, P as PhoneConfig, i as ParsedPhone, j as PhoneDisplayFormat } from './phone-utils-B2vHJkNz.js';
4
- 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-B2vHJkNz.js';
5
- import { T as TrackingConfigReference, C as ConversionConfig } from './sales-CBQJ2SBT.js';
6
- export { A as AranovaApiError, 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, 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, ab as clearStashedUserData, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ah as getTrackingConfigRuntime, ai as resolveConversionConfig, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ao as stashUserData, ap as toMinor } from './sales-CBQJ2SBT.js';
3
+ 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, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, C as ConsentState, g as ConsentChoiceState, h as ConsentSource, P as PhoneConfig, i as ParsedPhone, j as PhoneDisplayFormat } from './phone-utils-BhWfNuPS.js';
4
+ 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';
5
+ import { T as TrackingConfigReference, C as ConversionConfig } from './sales-BhCYJqDy.js';
6
+ export { A as AranovaApiError, 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, 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, ab as clearStashedUserData, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, ah as getTrackingConfigRuntime, ai as resolveConversionConfig, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ao as stashUserData, ap as toMinor } from './sales-BhCYJqDy.js';
7
7
  import * as src from 'src';
8
8
  import { z } from 'zod';
9
9
  import { CountryCode } from 'libphonenumber-js';
package/dist/index.js CHANGED
@@ -327,6 +327,43 @@ function resetConsent() {
327
327
  notifyConsentChanged(DEFAULT_CHOICE);
328
328
  }
329
329
 
330
+ // ../tracking-core/src/capabilities.ts
331
+ var TRACKING_CAPABILITIES = [
332
+ "ad_tags_google",
333
+ "ad_tags_meta",
334
+ "base_tracking",
335
+ "blog_rendering",
336
+ "calendar_read",
337
+ "calendar_write",
338
+ "consent_controls",
339
+ "conversion_goals_auto",
340
+ "conversion_goals_manual",
341
+ "cta_click_capture",
342
+ "form_capture",
343
+ "phone_click_capture",
344
+ "phone_fields"
345
+ ];
346
+ var CAPABILITY_DOM_ATTRIBUTE = "data-aranova-capability";
347
+ var registered = /* @__PURE__ */ new Set();
348
+ function registerCapability(capability) {
349
+ registered.add(capability);
350
+ }
351
+ function getRegisteredCapabilities() {
352
+ const all = new Set(registered);
353
+ for (const marker of readDomMarkers()) all.add(marker);
354
+ return Array.from(all).sort();
355
+ }
356
+ function readDomMarkers() {
357
+ if (typeof document === "undefined") return [];
358
+ const known = new Set(TRACKING_CAPABILITIES);
359
+ const found = [];
360
+ for (const node of document.querySelectorAll(`[${CAPABILITY_DOM_ATTRIBUTE}]`)) {
361
+ const value = node.getAttribute(CAPABILITY_DOM_ATTRIBUTE);
362
+ if (value && known.has(value)) found.push(value);
363
+ }
364
+ return found;
365
+ }
366
+
330
367
  // ../tracking-core/src/tracking.ts
331
368
  var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
332
369
  var TRACKING_PARAM_KEYS = [
@@ -700,7 +737,8 @@ function createTrackingClientContext(surface, input = {}) {
700
737
  page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
701
738
  referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
702
739
  environment: input.environment ?? "production",
703
- active_gtag_ids: input.activeGtagIds ?? null
740
+ active_gtag_ids: input.activeGtagIds ?? null,
741
+ capabilities: getRegisteredCapabilities()
704
742
  };
705
743
  }
706
744
  function createTrackingSessionUpsertPayload(trackingParams, input, context) {
@@ -1732,7 +1770,10 @@ function buildContext(surface, sdkVersion, packageName, environment, activeGtagI
1732
1770
  page_title: typeof document === "undefined" ? null : document.title || null,
1733
1771
  referrer: typeof document === "undefined" ? null : document.referrer || null,
1734
1772
  environment,
1735
- active_gtag_ids: activeGtagIds
1773
+ active_gtag_ids: activeGtagIds,
1774
+ // Rebuilt per flush (this runs inside the payload builder), so a client
1775
+ // constructed later on a deeper route still gets reported.
1776
+ capabilities: getRegisteredCapabilities()
1736
1777
  };
1737
1778
  }
1738
1779
  function readTrackingParams() {
@@ -2325,8 +2366,9 @@ function getEventDefinition(name) {
2325
2366
  }
2326
2367
 
2327
2368
  // ../tracking-core/src/ingest-typed.ts
2328
- function createTypedClient(raw, _registry, options = {}) {
2369
+ function createTypedClient(raw, registry, options = {}) {
2329
2370
  const debug = options.debug ?? false;
2371
+ if (registry.manual?.form_submit) registerCapability("form_capture");
2330
2372
  return {
2331
2373
  trackEvent(eventType, metadata, opts) {
2332
2374
  if (debug) {
@@ -2868,6 +2910,7 @@ function attachCtaClickCapture(client, config) {
2868
2910
  return () => {
2869
2911
  };
2870
2912
  }
2913
+ registerCapability("cta_click_capture");
2871
2914
  const selector = autoCapture.selector ?? DEFAULT_CTA_SELECTOR;
2872
2915
  function onClick(event) {
2873
2916
  const target = event.target;
@@ -2924,6 +2967,7 @@ function attachPhoneClickCapture(client, config) {
2924
2967
  return () => {
2925
2968
  };
2926
2969
  }
2970
+ registerCapability("phone_click_capture");
2927
2971
  const selector = autoCapture.selector ?? DEFAULT_TEL_SELECTOR;
2928
2972
  function onClick(event) {
2929
2973
  const target = event.target;
@@ -3040,6 +3084,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
3040
3084
  }
3041
3085
  }
3042
3086
  function createSalesClient(config) {
3087
+ if (config.firing) registerCapability("conversion_goals_manual");
3043
3088
  async function record(input) {
3044
3089
  const currency = input.currency ?? config.defaultCurrency;
3045
3090
  if (!currency) {
@@ -3335,6 +3380,7 @@ var DEFAULT_CHOICE2 = {
3335
3380
  expiresAt: null
3336
3381
  };
3337
3382
  function useCookiePreferences(options) {
3383
+ registerCapability("consent_controls");
3338
3384
  const [choice, setChoice] = (0, import_react.useState)(DEFAULT_CHOICE2);
3339
3385
  const ttlDays = options?.declineTtlDays;
3340
3386
  (0, import_react.useEffect)(() => {
@@ -3597,6 +3643,12 @@ function AdPlatformTracking({
3597
3643
  () => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
3598
3644
  [metaPixelIds]
3599
3645
  );
3646
+ if (trackingConfig || gtagId || gtagIds && Object.keys(gtagIds).length > 0) {
3647
+ registerCapability("ad_tags_google");
3648
+ }
3649
+ if (metaPixelId || metaPixelIds && Object.keys(metaPixelIds).length > 0) {
3650
+ registerCapability("ad_tags_meta");
3651
+ }
3600
3652
  (0, import_react3.useEffect)(() => {
3601
3653
  if (trackingConfig) {
3602
3654
  const runtime = getTrackingConfigRuntime(trackingConfig);
@@ -3637,7 +3689,7 @@ function GoogleAdsTracking(props) {
3637
3689
  var import_react6 = require("react");
3638
3690
 
3639
3691
  // package.json
3640
- var version = "0.21.0";
3692
+ var version = "0.22.0";
3641
3693
 
3642
3694
  // ../tracking-core/src/phone-react.tsx
3643
3695
  var import_react5 = require("react");
@@ -3661,6 +3713,7 @@ function usePhoneConfig() {
3661
3713
  };
3662
3714
  }
3663
3715
  function usePhoneField(opts = {}) {
3716
+ registerCapability("phone_fields");
3664
3717
  const cfg = usePhoneConfig();
3665
3718
  const country = opts.country ?? cfg.defaultCountry;
3666
3719
  const display = opts.display ?? cfg.display;
@@ -3746,6 +3799,8 @@ function createTracking(options) {
3746
3799
  conversionConfig,
3747
3800
  trackingConfig
3748
3801
  } = options;
3802
+ registerCapability("base_tracking");
3803
+ if (trackingConfig) registerCapability("conversion_goals_auto");
3749
3804
  if (!apiKey || !endpoint) {
3750
3805
  if (apiKey || endpoint) {
3751
3806
  console.warn(