@aranova/tracking-next 0.14.1 → 0.15.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.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { C as ConsentState, a as TrackingInstallSurface, b as TrackingEnvironment, c as TrackingClientContext, T as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, F as FormSubmitConfig, f as FormSubmitMetadata, G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, P as PhoneConfig, g as ParsedPhone, h as PhoneDisplayFormat } from './phone-utils-CcU5mwzc.js';
2
- export { D as DEFAULT_PHONE_COUNTRY, J as JsonValue, i as TrackedField, j as TrackingInitConfig, k as formSubmitConfigSchema, l as formSubmitMetadataSchema, m as formatPhone, n as formatPhoneAsTyped, o as jsonValueSchema, p as parsePhone, q as phoneField, t as toE164 } from './phone-utils-CcU5mwzc.js';
3
- import { C as ConversionConfig } from './sales-7w7-Ud60.js';
4
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, d as ConversionConfigStore, 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, T as SaleSummaryQuery, U as SaleSummaryQueryV2, V as SaleSummaryV2, W as SaleUpdateInput, X as SalesBusinessClient, Y as SalesCategoryBreakdown, Z as SalesClient, _ as SalesClientConfig, $ as SalesCustomersClient, a0 as SalesServiceBreakdown, a1 as SalesTransportConfig, a2 as SalesTrendPoint, a3 as SummaryCurrencyDelta, a4 as SummaryDeltas, a5 as SummaryWindow, a6 as SupportedCurrency, a7 as TRACKING_RANGES, a8 as TrackingOverviewRange, a9 as createSalesClient, aa as fetchServices, ab as formatDateInTz, ac as formatMoney, ad as fromMinor, ae as resolveConversionConfig, af as saleCreateSchema, ag as saleItemSchema, ah as saleServiceSchema, ai as saleUpdateSchema, aj as salesRequest, ak as toMinor } from './sales-7w7-Ud60.js';
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-DlAQK-gU.js';
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-DlAQK-gU.js';
3
+ import { C as ConversionConfig } from './sales-Bq7H-Vym.js';
4
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, d as ConversionConfigStore, 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, T as SaleSummaryQuery, U as SaleSummaryQueryV2, V as SaleSummaryV2, W as SaleUpdateInput, X as SalesBusinessClient, Y as SalesCategoryBreakdown, Z as SalesClient, _ as SalesClientConfig, $ as SalesCustomersClient, a0 as SalesServiceBreakdown, a1 as SalesTransportConfig, a2 as SalesTrendPoint, a3 as SummaryCurrencyDelta, a4 as SummaryDeltas, a5 as SummaryWindow, a6 as SupportedCurrency, a7 as TRACKING_RANGES, a8 as TrackingOverviewRange, a9 as createSalesClient, aa as fetchServices, ab as formatDateInTz, ac as formatMoney, ad as fromMinor, ae as resolveConversionConfig, af as saleCreateSchema, ag as saleItemSchema, ah as saleServiceSchema, ai as saleUpdateSchema, aj as salesRequest, ak as toMinor } from './sales-Bq7H-Vym.js';
5
5
  import { z } from 'zod';
6
6
  import * as src from 'src';
7
7
  import * as react from 'react';
@@ -11,37 +11,17 @@ import { CountryCode } from 'libphonenumber-js';
11
11
  export { CountryCode } from 'libphonenumber-js';
12
12
 
13
13
  /**
14
- * Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
15
- */
16
- type GtagConsentValue = "granted" | "denied";
17
- /**
18
- * Read the persisted visitor consent state from localStorage.
19
- *
20
- * Returns `pending` when called during SSR or before the visitor has made a
21
- * choice.
22
- */
23
- declare function getConsentState(): ConsentState;
24
- /**
25
- * Persist a visitor consent choice and update Google Consent Mode when gtag is
26
- * loaded.
14
+ * Attribution query/cookie keys captured by the SDK.
27
15
  */
28
- declare function setConsentState(state: GtagConsentValue): void;
16
+ declare const TRACKING_PARAM_KEYS: readonly ["gclid", "fbclid", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
17
+ type TrackingParamKey = (typeof TRACKING_PARAM_KEYS)[number];
29
18
  /**
30
- * Clear the stored consent choice so the banner re-appears on next render.
31
- *
32
- * Power a "Cookie preferences" link in a footer so visitors can change their
33
- * mind without losing access to your site:
34
- *
35
- * ```tsx
36
- * const { reset } = useConsent();
37
- * <button onClick={reset}>Cookie preferences</button>
38
- * ```
19
+ * Capture tracking params from a URL, persist them to first-party cookies, and
20
+ * return the current cookie-backed attribution state.
39
21
  *
40
- * Does NOT push an `update` to gtag — there's nothing to update because the
41
- * visitor hasn't chosen anything yet. The next `setConsentState()` call will
42
- * sync gtag once they re-choose.
22
+ * Defaults to `window.location.href` in the browser.
43
23
  */
44
- declare function resetConsent(): void;
24
+ declare function captureTrackingParamsFromLocation(url?: string, maxAgeSeconds?: number): TrackingParams;
45
25
 
46
26
  interface TrackingContextInput {
47
27
  packageName?: string | null;
@@ -63,6 +43,12 @@ interface TrackingSessionInput {
63
43
  firstPage?: string | null;
64
44
  sessionId: string;
65
45
  visitorId?: string | null;
46
+ /**
47
+ * Landing attribution override (ADR-016). When omitted, the session's
48
+ * persisted landing record is used (captured from the current URL if the
49
+ * session has none yet).
50
+ */
51
+ landingParams?: Partial<Record<TrackingParamKey, string>>;
66
52
  }
67
53
  /**
68
54
  * Build runtime context attached to tracking sessions and events.
@@ -1109,18 +1095,6 @@ interface TrackingClient {
1109
1095
  destroy: () => void;
1110
1096
  }
1111
1097
 
1112
- /**
1113
- * Attribution query/cookie keys captured by the SDK.
1114
- */
1115
- declare const TRACKING_PARAM_KEYS: readonly ["gclid", "fbclid", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
1116
- /**
1117
- * Capture tracking params from a URL, persist them to first-party cookies, and
1118
- * return the current cookie-backed attribution state.
1119
- *
1120
- * Defaults to `window.location.href` in the browser.
1121
- */
1122
- declare function captureTrackingParamsFromLocation(url?: string, maxAgeSeconds?: number): TrackingParams;
1123
-
1124
1098
  interface TypedTrackEventOptions {
1125
1099
  /**
1126
1100
  * Override the page URL associated with this event.
@@ -1166,37 +1140,14 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
1166
1140
  }
1167
1141
 
1168
1142
  /**
1169
- * Default non-blocking consent banner.
1170
- *
1171
- * Renders only while consent is `pending`; collapses to `null` once the
1172
- * visitor has chosen.
1173
- *
1174
- * **Styling is intentionally self-contained** — inline styles, zero CSS
1175
- * dependencies, no Tailwind required at the consumer. The Tailwind-based
1176
- * banner shipped before 0.9.1 rendered as transparent in any consumer that
1177
- * didn't configure their content array to scan
1178
- * `node_modules/@aranova/tracking-next/dist/**`; this version sidesteps that
1179
- * class of bug entirely.
1180
- *
1181
- * For a fully bespoke banner, skip this component and use {@link useConsent}
1182
- * directly to drive your own UI.
1183
- *
1184
- * @example
1185
- * // Drop-in default
1186
- * <ConsentBanner />
1143
+ * Legacy opt-in-era consent banner.
1187
1144
  *
1188
- * @example
1189
- * // Customized
1190
- * <ConsentBanner
1191
- * message="We use cookies to learn which ads drive bookings."
1192
- * acceptLabel="Sounds good"
1193
- * declineLabel="No thanks"
1194
- * policyHref="/privacy"
1195
- * policyLabel="Privacy policy"
1196
- * theme="dark"
1197
- * onAccept={() => track('consent_accepted')}
1198
- * onDecline={() => track('consent_declined')}
1199
- * />
1145
+ * @deprecated PERMANENTLY INERT since consent v2 (opt-out model): it renders
1146
+ * only while consent is `pending`, and the effective state is never `pending`
1147
+ * anymore, so this component always returns `null`. Tracking is on by default;
1148
+ * replace the banner with a footer "cookie preferences" control built on
1149
+ * {@link useCookiePreferences} (see the package README). Kept exported so
1150
+ * existing integrations keep compiling; scheduled for removal.
1200
1151
  */
1201
1152
  interface ConsentBannerProps {
1202
1153
  /** Body text. Defaults to the standard cookies-for-ad-performance message. */
@@ -1228,6 +1179,12 @@ interface ConsentBannerProps {
1228
1179
  /** Inline style overrides applied to the outer wrapper after the defaults. */
1229
1180
  style?: CSSProperties;
1230
1181
  }
1182
+ /**
1183
+ * @deprecated Permanently inert since consent v2 — always renders `null`
1184
+ * because the effective consent state is never `pending`. Use a footer
1185
+ * control built on {@link useCookiePreferences} instead. See
1186
+ * {@link ConsentBannerProps} for details.
1187
+ */
1231
1188
  declare function ConsentBanner({ message, title, acceptLabel, declineLabel, policyHref, policyLabel, onAccept, onDecline, position, theme, className, style, }?: ConsentBannerProps): ReactNode;
1232
1189
 
1233
1190
  /**
@@ -1242,38 +1199,69 @@ declare function useGclid(): string | null;
1242
1199
  * Values are loaded after mount, so the initial render returns all `null`s.
1243
1200
  */
1244
1201
  declare function useTrackingParams(): TrackingParams;
1202
+ /** Options for {@link useCookiePreferences}. */
1203
+ interface UseCookiePreferencesOptions {
1204
+ /** Days an explicit decline is honored. Defaults to 90. */
1205
+ declineTtlDays?: number;
1206
+ }
1245
1207
  /**
1246
- * Read the current visitor consent state and update when another tab changes
1247
- * the stored value.
1248
- *
1249
- * Prefer {@link useConsent} for new code — it returns the same state plus
1250
- * the `accept` / `decline` / `reset` actions a custom consent UI needs.
1251
- * `useConsentState` is kept as a convenience for callers that only need to
1252
- * read.
1208
+ * The headless cookie-preferences surface returned by
1209
+ * {@link useCookiePreferences}.
1253
1210
  */
1254
- declare function useConsentState(): ConsentState;
1211
+ interface UseCookiePreferencesResult {
1212
+ /** Effective consent — `granted` unless an unexpired explicit decline exists. */
1213
+ state: ConsentChoiceState;
1214
+ /** `default` = no valid explicit choice stored; `explicit` = visitor chose. */
1215
+ source: ConsentSource;
1216
+ /** True when the visitor has made no (valid, unexpired) explicit choice. */
1217
+ isDefault: boolean;
1218
+ isGranted: boolean;
1219
+ isDenied: boolean;
1220
+ /** ISO timestamp of the explicit choice; null for the default state. */
1221
+ updatedAt: string | null;
1222
+ /** ISO expiry of an unexpired decline; null otherwise. */
1223
+ expiresAt: string | null;
1224
+ /** Explicitly opt out of ad tracking (honored for 90 days by default). */
1225
+ optOut: () => void;
1226
+ /** Explicitly opt in (never expires). */
1227
+ optIn: () => void;
1228
+ /** Clear the explicit choice — back to default-granted. */
1229
+ reset: () => void;
1230
+ }
1255
1231
  /**
1256
- * The headless consent surface — state + actions in one hook.
1232
+ * Headless cookie-preferences hook for the opt-out consent model (consent v2).
1257
1233
  *
1258
- * Build a fully-custom banner without losing the gtag-sync, localStorage
1259
- * persistence, or cross-tab propagation:
1234
+ * Tracking is ON by default; this hook is how each client site wires its own
1235
+ * footer "Cookie preferences" control (button, dialog, toggle — the packages
1236
+ * ship no consent UI). State stays in sync with actions from other components
1237
+ * in the same tab (via `onConsentChange`) and other tabs (via `storage`
1238
+ * events).
1260
1239
  *
1261
1240
  * ```tsx
1262
- * const { state, accept, decline, reset, isPending } = useConsent();
1263
- *
1264
- * if (!isPending) {
1265
- * return <button onClick={reset}>Cookie preferences</button>;
1241
+ * function CookiePreferences() {
1242
+ * const { isDenied, optOut, optIn } = useCookiePreferences();
1243
+ * return isDenied ? (
1244
+ * <button onClick={optIn}>Enable ad measurement</button>
1245
+ * ) : (
1246
+ * <button onClick={optOut}>Opt out of ad measurement</button>
1247
+ * );
1266
1248
  * }
1267
- * return (
1268
- * <MyBannerStyling>
1269
- * <button onClick={decline}>No thanks</button>
1270
- * <button onClick={accept}>Sure</button>
1271
- * </MyBannerStyling>
1272
- * );
1273
1249
  * ```
1250
+ */
1251
+ declare function useCookiePreferences(options?: UseCookiePreferencesOptions): UseCookiePreferencesResult;
1252
+ /**
1253
+ * Read the current visitor consent state.
1274
1254
  *
1275
- * The boolean helpers (`isPending` / `isGranted` / `isDenied`) are equivalent
1276
- * to comparing `state` directly — they're there for readability at call sites.
1255
+ * @deprecated Since consent v2 (opt-out model) the state is never `pending`.
1256
+ * Use {@link useCookiePreferences} — it exposes the effective state plus
1257
+ * `source` so you can tell a default grant from an explicit one.
1258
+ */
1259
+ declare function useConsentState(): ConsentState;
1260
+ /**
1261
+ * Result shape of the deprecated {@link useConsent} hook.
1262
+ *
1263
+ * @deprecated Use {@link UseCookiePreferencesResult} via
1264
+ * {@link useCookiePreferences}. `isPending` is always `false` since consent v2.
1277
1265
  */
1278
1266
  interface UseConsentResult {
1279
1267
  state: ConsentState;
@@ -1284,6 +1272,14 @@ interface UseConsentResult {
1284
1272
  decline: () => void;
1285
1273
  reset: () => void;
1286
1274
  }
1275
+ /**
1276
+ * Legacy opt-in-era consent hook.
1277
+ *
1278
+ * @deprecated Since consent v2 tracking defaults ON (opt-out model): the state
1279
+ * is never `pending`, so banner UIs gated on `isPending` never render. Use
1280
+ * {@link useCookiePreferences} for footer "cookie preferences" controls.
1281
+ * `accept` / `decline` still work and map to `optIn` / `optOut`.
1282
+ */
1287
1283
  declare function useConsent(): UseConsentResult;
1288
1284
 
1289
1285
  /**
@@ -1470,4 +1466,4 @@ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "t
1470
1466
  */
1471
1467
  declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
1472
1468
 
1473
- export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getConsentState, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, resetConsent, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, setConsentState, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
1469
+ export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentChoiceState, ConsentSource, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UseCookiePreferencesOptions, type UseCookiePreferencesResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useCookiePreferences, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };