@aranova/tracking-react 0.14.2 → 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/README.md +20 -46
- package/dist/index.d.mts +97 -99
- package/dist/index.d.ts +97 -99
- package/dist/index.js +223 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +217 -82
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-Dyk0F14_.d.mts → phone-utils-DlAQK-gU.d.mts} +127 -6
- package/dist/{phone-utils-Dyk0F14_.d.ts → phone-utils-DlAQK-gU.d.ts} +127 -6
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/phone.js +0 -73
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +0 -73
- package/dist/phone.mjs.map +1 -1
- package/dist/sales.js +33 -29
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +33 -29
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -180,11 +180,17 @@ interface TrackedField {
|
|
|
180
180
|
declare function phoneField(name: string, raw: string, country?: CountryCode): TrackedField;
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* Visitor consent state
|
|
183
|
+
* Visitor consent state as reported by `getConsentState()`.
|
|
184
184
|
*
|
|
185
|
-
* -
|
|
186
|
-
*
|
|
187
|
-
*
|
|
185
|
+
* Consent v2 is an opt-out model: the effective state is `granted` unless the
|
|
186
|
+
* visitor stored an explicit, unexpired decline.
|
|
187
|
+
*
|
|
188
|
+
* - `granted`: default, or an explicit opt-in.
|
|
189
|
+
* - `denied`: explicit opt-out, honored for 90 days.
|
|
190
|
+
* - `pending`: NEVER returned since consent v2 (the opt-in-era "no choice yet"
|
|
191
|
+
* value). Retained in the union only so pre-v2 call sites keep compiling;
|
|
192
|
+
* any `pending` branch is dead code. Use `getConsentChoice().source ===
|
|
193
|
+
* "default"` to detect "no explicit choice".
|
|
188
194
|
*/
|
|
189
195
|
type ConsentState = "granted" | "denied" | "pending";
|
|
190
196
|
/**
|
|
@@ -296,6 +302,22 @@ interface TrackingSessionUpsertPayload {
|
|
|
296
302
|
utm_campaign: string | null;
|
|
297
303
|
utm_term: string | null;
|
|
298
304
|
utm_content: string | null;
|
|
305
|
+
/**
|
|
306
|
+
* Landing attribution (ADR-016): params present in THIS session's landing
|
|
307
|
+
* URL, unlike the cookie-backed fields above which carry for 90 days and may
|
|
308
|
+
* be inherited from an earlier session's click. The backend treats key
|
|
309
|
+
* PRESENCE as "landing explicitly known" (nulls mean a param-less landing);
|
|
310
|
+
* when the landing is NOT observable — SSR, or SDKs predating these fields —
|
|
311
|
+
* the keys are omitted and the backend falls back to parsing first_page.
|
|
312
|
+
* Build via `buildLandingPayloadFields()`, which enforces this contract.
|
|
313
|
+
*/
|
|
314
|
+
landing_gclid?: string | null;
|
|
315
|
+
landing_fbclid?: string | null;
|
|
316
|
+
landing_utm_source?: string | null;
|
|
317
|
+
landing_utm_medium?: string | null;
|
|
318
|
+
landing_utm_campaign?: string | null;
|
|
319
|
+
landing_utm_term?: string | null;
|
|
320
|
+
landing_utm_content?: string | null;
|
|
299
321
|
first_page: string | null;
|
|
300
322
|
consent_state: Record<string, unknown> | null;
|
|
301
323
|
context: TrackingClientContext;
|
|
@@ -344,7 +366,11 @@ interface TrackingInitConfig {
|
|
|
344
366
|
environment?: TrackingEnvironment;
|
|
345
367
|
/** Whether to capture attribution params from `window.location`. Defaults to true. */
|
|
346
368
|
autoCaptureTrackingParams?: boolean;
|
|
347
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated No-op since consent v2 (opt-out model). The packages no longer
|
|
371
|
+
* ship a consent banner; wire a footer control to
|
|
372
|
+
* `window.AranovaTracking.optOut()` / `optIn()` instead.
|
|
373
|
+
*/
|
|
348
374
|
renderConsentBanner?: boolean;
|
|
349
375
|
/** Attribution cookie max age in seconds. Defaults to 90 days. */
|
|
350
376
|
cookieMaxAgeSeconds?: number;
|
|
@@ -365,9 +391,104 @@ declare global {
|
|
|
365
391
|
getTrackingParams: () => TrackingParams;
|
|
366
392
|
getConsentState: () => ConsentState;
|
|
367
393
|
setConsentState: (state: "granted" | "denied") => void;
|
|
394
|
+
getConsentChoice: () => ConsentChoice;
|
|
395
|
+
optIn: () => void;
|
|
396
|
+
optOut: (options?: SetConsentOptions) => void;
|
|
397
|
+
resetConsent: () => void;
|
|
368
398
|
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
369
399
|
};
|
|
370
400
|
}
|
|
371
401
|
}
|
|
372
402
|
|
|
373
|
-
|
|
403
|
+
/**
|
|
404
|
+
* How long an explicit decline is honored before the visitor reverts to the
|
|
405
|
+
* default-granted state. Explicit grants never expire.
|
|
406
|
+
*/
|
|
407
|
+
declare const DEFAULT_DECLINE_TTL_DAYS = 90;
|
|
408
|
+
/**
|
|
409
|
+
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
410
|
+
*/
|
|
411
|
+
type GtagConsentValue = "granted" | "denied";
|
|
412
|
+
/** Effective consent state — the opt-out model has no "pending". */
|
|
413
|
+
type ConsentChoiceState = "granted" | "denied";
|
|
414
|
+
/**
|
|
415
|
+
* Where the effective state came from: `explicit` when the visitor made a
|
|
416
|
+
* stored, still-valid choice; `default` otherwise (no choice, expired decline,
|
|
417
|
+
* storage blocked, SSR).
|
|
418
|
+
*/
|
|
419
|
+
type ConsentSource = "default" | "explicit";
|
|
420
|
+
/**
|
|
421
|
+
* The effective consent decision plus its provenance.
|
|
422
|
+
*/
|
|
423
|
+
interface ConsentChoice {
|
|
424
|
+
state: ConsentChoiceState;
|
|
425
|
+
source: ConsentSource;
|
|
426
|
+
/** ISO timestamp of the explicit choice; null for the default state. */
|
|
427
|
+
updatedAt: string | null;
|
|
428
|
+
/** ISO expiry of an unexpired decline; null for grants and the default state. */
|
|
429
|
+
expiresAt: string | null;
|
|
430
|
+
}
|
|
431
|
+
/** Options for explicit consent writes. */
|
|
432
|
+
interface SetConsentOptions {
|
|
433
|
+
/** Days an explicit decline is honored. Defaults to {@link DEFAULT_DECLINE_TTL_DAYS}. */
|
|
434
|
+
declineTtlDays?: number;
|
|
435
|
+
}
|
|
436
|
+
type ConsentChangeListener = (choice: ConsentChoice) => void;
|
|
437
|
+
/**
|
|
438
|
+
* Subscribe to consent changes (opt-in, opt-out, reset) made in THIS tab.
|
|
439
|
+
* Cross-tab changes surface via the browser's `storage` event instead.
|
|
440
|
+
* Returns an unsubscribe function.
|
|
441
|
+
*/
|
|
442
|
+
declare function onConsentChange(listener: ConsentChangeListener): () => void;
|
|
443
|
+
/**
|
|
444
|
+
* Resolve the visitor's effective consent (opt-out model).
|
|
445
|
+
*
|
|
446
|
+
* Default is GRANTED. Only a stored, unexpired explicit decline yields
|
|
447
|
+
* `denied`. SSR, blocked storage, and expired declines all resolve to the
|
|
448
|
+
* default. A legacy decline stored by the opt-in-era SDK (no expiry key) stays
|
|
449
|
+
* denied and gets a fresh 90-day expiry backfilled, keeping this reader
|
|
450
|
+
* consistent with the inline scripts (which treat a missing expiry as denied).
|
|
451
|
+
*/
|
|
452
|
+
declare function getConsentChoice(): ConsentChoice;
|
|
453
|
+
/**
|
|
454
|
+
* Read the visitor's effective consent state.
|
|
455
|
+
*
|
|
456
|
+
* Opt-out model: returns `granted` unless a stored, unexpired explicit decline
|
|
457
|
+
* exists. Never returns `pending` — that value survives in {@link ConsentState}
|
|
458
|
+
* only so pre-v2 call sites keep compiling.
|
|
459
|
+
*/
|
|
460
|
+
declare function getConsentState(): ConsentState;
|
|
461
|
+
/**
|
|
462
|
+
* Persist an explicit visitor consent choice and push it live to Google
|
|
463
|
+
* Consent Mode and the Meta Pixel.
|
|
464
|
+
*
|
|
465
|
+
* Declines expire after {@link DEFAULT_DECLINE_TTL_DAYS} days (override via
|
|
466
|
+
* `options.declineTtlDays`); grants never expire.
|
|
467
|
+
*/
|
|
468
|
+
declare function setConsentState(state: GtagConsentValue, options?: SetConsentOptions): void;
|
|
469
|
+
/**
|
|
470
|
+
* Explicitly opt the visitor in to ad tracking (never expires).
|
|
471
|
+
*/
|
|
472
|
+
declare function optIn(): void;
|
|
473
|
+
/**
|
|
474
|
+
* Explicitly opt the visitor out of ad tracking for
|
|
475
|
+
* {@link DEFAULT_DECLINE_TTL_DAYS} days (override via `options.declineTtlDays`).
|
|
476
|
+
*
|
|
477
|
+
* This is the primitive a client site's footer "cookie preferences" control
|
|
478
|
+
* should call — the packages ship no consent UI of their own.
|
|
479
|
+
*/
|
|
480
|
+
declare function optOut(options?: SetConsentOptions): void;
|
|
481
|
+
/**
|
|
482
|
+
* Clear the stored explicit choice, returning the visitor to the
|
|
483
|
+
* default-granted state, and push that state live to gtag + Meta.
|
|
484
|
+
*
|
|
485
|
+
* Power a "Cookie preferences" reset in a footer:
|
|
486
|
+
*
|
|
487
|
+
* ```tsx
|
|
488
|
+
* const { reset } = useCookiePreferences();
|
|
489
|
+
* <button onClick={reset}>Reset cookie preferences</button>
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
declare function resetConsent(): void;
|
|
493
|
+
|
|
494
|
+
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 };
|
|
@@ -180,11 +180,17 @@ interface TrackedField {
|
|
|
180
180
|
declare function phoneField(name: string, raw: string, country?: CountryCode): TrackedField;
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* Visitor consent state
|
|
183
|
+
* Visitor consent state as reported by `getConsentState()`.
|
|
184
184
|
*
|
|
185
|
-
* -
|
|
186
|
-
*
|
|
187
|
-
*
|
|
185
|
+
* Consent v2 is an opt-out model: the effective state is `granted` unless the
|
|
186
|
+
* visitor stored an explicit, unexpired decline.
|
|
187
|
+
*
|
|
188
|
+
* - `granted`: default, or an explicit opt-in.
|
|
189
|
+
* - `denied`: explicit opt-out, honored for 90 days.
|
|
190
|
+
* - `pending`: NEVER returned since consent v2 (the opt-in-era "no choice yet"
|
|
191
|
+
* value). Retained in the union only so pre-v2 call sites keep compiling;
|
|
192
|
+
* any `pending` branch is dead code. Use `getConsentChoice().source ===
|
|
193
|
+
* "default"` to detect "no explicit choice".
|
|
188
194
|
*/
|
|
189
195
|
type ConsentState = "granted" | "denied" | "pending";
|
|
190
196
|
/**
|
|
@@ -296,6 +302,22 @@ interface TrackingSessionUpsertPayload {
|
|
|
296
302
|
utm_campaign: string | null;
|
|
297
303
|
utm_term: string | null;
|
|
298
304
|
utm_content: string | null;
|
|
305
|
+
/**
|
|
306
|
+
* Landing attribution (ADR-016): params present in THIS session's landing
|
|
307
|
+
* URL, unlike the cookie-backed fields above which carry for 90 days and may
|
|
308
|
+
* be inherited from an earlier session's click. The backend treats key
|
|
309
|
+
* PRESENCE as "landing explicitly known" (nulls mean a param-less landing);
|
|
310
|
+
* when the landing is NOT observable — SSR, or SDKs predating these fields —
|
|
311
|
+
* the keys are omitted and the backend falls back to parsing first_page.
|
|
312
|
+
* Build via `buildLandingPayloadFields()`, which enforces this contract.
|
|
313
|
+
*/
|
|
314
|
+
landing_gclid?: string | null;
|
|
315
|
+
landing_fbclid?: string | null;
|
|
316
|
+
landing_utm_source?: string | null;
|
|
317
|
+
landing_utm_medium?: string | null;
|
|
318
|
+
landing_utm_campaign?: string | null;
|
|
319
|
+
landing_utm_term?: string | null;
|
|
320
|
+
landing_utm_content?: string | null;
|
|
299
321
|
first_page: string | null;
|
|
300
322
|
consent_state: Record<string, unknown> | null;
|
|
301
323
|
context: TrackingClientContext;
|
|
@@ -344,7 +366,11 @@ interface TrackingInitConfig {
|
|
|
344
366
|
environment?: TrackingEnvironment;
|
|
345
367
|
/** Whether to capture attribution params from `window.location`. Defaults to true. */
|
|
346
368
|
autoCaptureTrackingParams?: boolean;
|
|
347
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated No-op since consent v2 (opt-out model). The packages no longer
|
|
371
|
+
* ship a consent banner; wire a footer control to
|
|
372
|
+
* `window.AranovaTracking.optOut()` / `optIn()` instead.
|
|
373
|
+
*/
|
|
348
374
|
renderConsentBanner?: boolean;
|
|
349
375
|
/** Attribution cookie max age in seconds. Defaults to 90 days. */
|
|
350
376
|
cookieMaxAgeSeconds?: number;
|
|
@@ -365,9 +391,104 @@ declare global {
|
|
|
365
391
|
getTrackingParams: () => TrackingParams;
|
|
366
392
|
getConsentState: () => ConsentState;
|
|
367
393
|
setConsentState: (state: "granted" | "denied") => void;
|
|
394
|
+
getConsentChoice: () => ConsentChoice;
|
|
395
|
+
optIn: () => void;
|
|
396
|
+
optOut: (options?: SetConsentOptions) => void;
|
|
397
|
+
resetConsent: () => void;
|
|
368
398
|
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
369
399
|
};
|
|
370
400
|
}
|
|
371
401
|
}
|
|
372
402
|
|
|
373
|
-
|
|
403
|
+
/**
|
|
404
|
+
* How long an explicit decline is honored before the visitor reverts to the
|
|
405
|
+
* default-granted state. Explicit grants never expire.
|
|
406
|
+
*/
|
|
407
|
+
declare const DEFAULT_DECLINE_TTL_DAYS = 90;
|
|
408
|
+
/**
|
|
409
|
+
* Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
|
|
410
|
+
*/
|
|
411
|
+
type GtagConsentValue = "granted" | "denied";
|
|
412
|
+
/** Effective consent state — the opt-out model has no "pending". */
|
|
413
|
+
type ConsentChoiceState = "granted" | "denied";
|
|
414
|
+
/**
|
|
415
|
+
* Where the effective state came from: `explicit` when the visitor made a
|
|
416
|
+
* stored, still-valid choice; `default` otherwise (no choice, expired decline,
|
|
417
|
+
* storage blocked, SSR).
|
|
418
|
+
*/
|
|
419
|
+
type ConsentSource = "default" | "explicit";
|
|
420
|
+
/**
|
|
421
|
+
* The effective consent decision plus its provenance.
|
|
422
|
+
*/
|
|
423
|
+
interface ConsentChoice {
|
|
424
|
+
state: ConsentChoiceState;
|
|
425
|
+
source: ConsentSource;
|
|
426
|
+
/** ISO timestamp of the explicit choice; null for the default state. */
|
|
427
|
+
updatedAt: string | null;
|
|
428
|
+
/** ISO expiry of an unexpired decline; null for grants and the default state. */
|
|
429
|
+
expiresAt: string | null;
|
|
430
|
+
}
|
|
431
|
+
/** Options for explicit consent writes. */
|
|
432
|
+
interface SetConsentOptions {
|
|
433
|
+
/** Days an explicit decline is honored. Defaults to {@link DEFAULT_DECLINE_TTL_DAYS}. */
|
|
434
|
+
declineTtlDays?: number;
|
|
435
|
+
}
|
|
436
|
+
type ConsentChangeListener = (choice: ConsentChoice) => void;
|
|
437
|
+
/**
|
|
438
|
+
* Subscribe to consent changes (opt-in, opt-out, reset) made in THIS tab.
|
|
439
|
+
* Cross-tab changes surface via the browser's `storage` event instead.
|
|
440
|
+
* Returns an unsubscribe function.
|
|
441
|
+
*/
|
|
442
|
+
declare function onConsentChange(listener: ConsentChangeListener): () => void;
|
|
443
|
+
/**
|
|
444
|
+
* Resolve the visitor's effective consent (opt-out model).
|
|
445
|
+
*
|
|
446
|
+
* Default is GRANTED. Only a stored, unexpired explicit decline yields
|
|
447
|
+
* `denied`. SSR, blocked storage, and expired declines all resolve to the
|
|
448
|
+
* default. A legacy decline stored by the opt-in-era SDK (no expiry key) stays
|
|
449
|
+
* denied and gets a fresh 90-day expiry backfilled, keeping this reader
|
|
450
|
+
* consistent with the inline scripts (which treat a missing expiry as denied).
|
|
451
|
+
*/
|
|
452
|
+
declare function getConsentChoice(): ConsentChoice;
|
|
453
|
+
/**
|
|
454
|
+
* Read the visitor's effective consent state.
|
|
455
|
+
*
|
|
456
|
+
* Opt-out model: returns `granted` unless a stored, unexpired explicit decline
|
|
457
|
+
* exists. Never returns `pending` — that value survives in {@link ConsentState}
|
|
458
|
+
* only so pre-v2 call sites keep compiling.
|
|
459
|
+
*/
|
|
460
|
+
declare function getConsentState(): ConsentState;
|
|
461
|
+
/**
|
|
462
|
+
* Persist an explicit visitor consent choice and push it live to Google
|
|
463
|
+
* Consent Mode and the Meta Pixel.
|
|
464
|
+
*
|
|
465
|
+
* Declines expire after {@link DEFAULT_DECLINE_TTL_DAYS} days (override via
|
|
466
|
+
* `options.declineTtlDays`); grants never expire.
|
|
467
|
+
*/
|
|
468
|
+
declare function setConsentState(state: GtagConsentValue, options?: SetConsentOptions): void;
|
|
469
|
+
/**
|
|
470
|
+
* Explicitly opt the visitor in to ad tracking (never expires).
|
|
471
|
+
*/
|
|
472
|
+
declare function optIn(): void;
|
|
473
|
+
/**
|
|
474
|
+
* Explicitly opt the visitor out of ad tracking for
|
|
475
|
+
* {@link DEFAULT_DECLINE_TTL_DAYS} days (override via `options.declineTtlDays`).
|
|
476
|
+
*
|
|
477
|
+
* This is the primitive a client site's footer "cookie preferences" control
|
|
478
|
+
* should call — the packages ship no consent UI of their own.
|
|
479
|
+
*/
|
|
480
|
+
declare function optOut(options?: SetConsentOptions): void;
|
|
481
|
+
/**
|
|
482
|
+
* Clear the stored explicit choice, returning the visitor to the
|
|
483
|
+
* default-granted state, and push that state live to gtag + Meta.
|
|
484
|
+
*
|
|
485
|
+
* Power a "Cookie preferences" reset in a footer:
|
|
486
|
+
*
|
|
487
|
+
* ```tsx
|
|
488
|
+
* const { reset } = useCookiePreferences();
|
|
489
|
+
* <button onClick={reset}>Reset cookie preferences</button>
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
declare function resetConsent(): void;
|
|
493
|
+
|
|
494
|
+
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 };
|
package/dist/phone.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
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-DlAQK-gU.mjs';
|
|
2
2
|
export { CountryCode } from 'libphonenumber-js';
|
|
3
3
|
import 'zod';
|
package/dist/phone.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
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-DlAQK-gU.js';
|
|
2
2
|
export { CountryCode } from 'libphonenumber-js';
|
|
3
3
|
import 'zod';
|
package/dist/phone.js
CHANGED
|
@@ -29,79 +29,6 @@ __export(phone_utils_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(phone_utils_exports);
|
|
31
31
|
|
|
32
|
-
// ../tracking-core/src/consent.ts
|
|
33
|
-
var CONSENT_STATE_KEY = "consent_state";
|
|
34
|
-
var grantedListeners = /* @__PURE__ */ new Set();
|
|
35
|
-
function onConsentGranted(listener) {
|
|
36
|
-
grantedListeners.add(listener);
|
|
37
|
-
return () => {
|
|
38
|
-
grantedListeners.delete(listener);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function getConsentState() {
|
|
42
|
-
if (typeof window === "undefined") return "pending";
|
|
43
|
-
try {
|
|
44
|
-
const storedState = window.localStorage.getItem(CONSENT_STATE_KEY);
|
|
45
|
-
if (storedState === "granted" || storedState === "denied") return storedState;
|
|
46
|
-
} catch {
|
|
47
|
-
}
|
|
48
|
-
return "pending";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ../tracking-core/src/gtag.ts
|
|
52
|
-
var SEND_TO_RE = /^AW-[A-Za-z0-9]+\/[A-Za-z0-9_-]+$/;
|
|
53
|
-
function isValidSendTo(sendTo) {
|
|
54
|
-
return SEND_TO_RE.test(sendTo);
|
|
55
|
-
}
|
|
56
|
-
function fireGtagConversion(input) {
|
|
57
|
-
if (typeof window === "undefined" || typeof window.gtag !== "function") return false;
|
|
58
|
-
if (!isValidSendTo(input.sendTo)) return false;
|
|
59
|
-
const params = { send_to: input.sendTo };
|
|
60
|
-
if (input.value != null) params.value = input.value;
|
|
61
|
-
if (input.currency) params.currency = input.currency;
|
|
62
|
-
if (input.transactionId) params.transaction_id = input.transactionId;
|
|
63
|
-
try {
|
|
64
|
-
window.gtag("event", "conversion", params);
|
|
65
|
-
return true;
|
|
66
|
-
} catch {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ../tracking-core/src/resources/conversion-firing.ts
|
|
72
|
-
var DEDUP_PREFIX = "_aranova_conv_";
|
|
73
|
-
var pendingQueue = [];
|
|
74
|
-
function dedupKey(input) {
|
|
75
|
-
return `${DEDUP_PREFIX}${input.transactionId ?? ""}:${input.sendTo}`;
|
|
76
|
-
}
|
|
77
|
-
function alreadyFired(input) {
|
|
78
|
-
if (!input.transactionId || typeof window === "undefined") return false;
|
|
79
|
-
try {
|
|
80
|
-
return window.sessionStorage.getItem(dedupKey(input)) !== null;
|
|
81
|
-
} catch {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function markFired(input) {
|
|
86
|
-
if (!input.transactionId || typeof window === "undefined") return;
|
|
87
|
-
try {
|
|
88
|
-
window.sessionStorage.setItem(dedupKey(input), "1");
|
|
89
|
-
} catch {
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function fireOnce(input) {
|
|
93
|
-
if (alreadyFired(input)) return;
|
|
94
|
-
if (fireGtagConversion(input)) markFired(input);
|
|
95
|
-
}
|
|
96
|
-
function flushPendingConversions() {
|
|
97
|
-
if (getConsentState() !== "granted") return;
|
|
98
|
-
while (pendingQueue.length > 0) {
|
|
99
|
-
const input = pendingQueue.shift();
|
|
100
|
-
if (input) fireOnce(input);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (typeof window !== "undefined") onConsentGranted(flushPendingConversions);
|
|
104
|
-
|
|
105
32
|
// ../tracking-core/src/session.ts
|
|
106
33
|
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
107
34
|
|