@mparticle/web-sdk 3.24.0 → 3.25.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.
@@ -23,7 +23,7 @@ import { PARTNER_MODULE_IDS } from "./cookieSyncManager";
23
23
  import IntegrationCapture from "./integrationCapture";
24
24
  import Constants from "./constants";
25
25
  import { subscribeToRouteChange } from "./routeChangeMonitor";
26
- import type { CheckoutIntentKind, CheckoutIntentSource } from "./buttonTracking/checkoutIntent";
26
+ import type { CheckoutIntentKind, CheckoutIntentSource, PaymentFrameFamily } from "./buttonTracking/checkoutIntent";
27
27
 
28
28
  const PASSBACK_CONVERSION_TRACKING_ID = 'passbackconversiontrackingid';
29
29
  // One signal per kind (commit, wallet, checkout_step, frame and cart), so a new kind never evicts another.
@@ -85,6 +85,17 @@ export interface ICheckoutIntentSignal {
85
85
  pathname?: string;
86
86
  }
87
87
 
88
+ // What a kit receives when the shopper picks a payment method: the names of a
89
+ // payment radio's option, masked like a label, or the payment family of a
90
+ // frame the shopper moved into. It is handed over in memory only: the kit
91
+ // keeps the family it reads and nothing of the names.
92
+ export interface IPaymentPickSignal {
93
+ t: number;
94
+ pathname: string;
95
+ names?: readonly string[];
96
+ family?: PaymentFrameFamily;
97
+ }
98
+
88
99
  export interface IRoktKitSettings {
89
100
  accountId?: string;
90
101
  placementAttributesMapping?: string;
@@ -109,6 +120,8 @@ export interface IRoktKit {
109
120
  onRouteChange?: () => void;
110
121
  // Set by the kit only when it wants checkout intent signals.
111
122
  onCheckoutIntent?: (signal: ICheckoutIntentSignal) => void;
123
+ // Set by the kit only when it wants payment picks.
124
+ onPaymentPick?: (signal: IPaymentPickSignal) => void;
112
125
  launcherOptions?: Dictionary<any>;
113
126
  settings?: IRoktKitSettings;
114
127
  integrationName?: string;
@@ -315,6 +328,18 @@ export default class RoktManager {
315
328
  this.autoButtonClicksForwarded = forwarded;
316
329
  }
317
330
 
331
+ // noTargeting (which noDeviceId implies), doNotShareOrSell or Global Privacy
332
+ // Control. Unlike noFunctional, these also stop auto button and link clicks
333
+ // from being logged.
334
+ public hasTargetingOptOut(): boolean {
335
+ const options = this.launcherOptions || {};
336
+ if (options.noTargeting || options.doNotShareOrSell) {
337
+ return true;
338
+ }
339
+ const nav = typeof navigator === 'undefined' ? undefined : (navigator as Navigator & { globalPrivacyControl?: boolean });
340
+ return !!nav && nav.globalPrivacyControl === true;
341
+ }
342
+
318
343
  // Checkout intent is off unless the flag is on, and under opt-out, any Rokt
319
344
  // privacy launcher option, Global Privacy Control, or a Rokt connection that
320
345
  // does not receive auto button clicks.
@@ -328,12 +353,7 @@ export default class RoktManager {
328
353
  ) {
329
354
  return true;
330
355
  }
331
- const options = this.launcherOptions || {};
332
- if (options.noFunctional || options.noTargeting || options.doNotShareOrSell) {
333
- return true;
334
- }
335
- const nav = typeof navigator === 'undefined' ? undefined : (navigator as Navigator & { globalPrivacyControl?: boolean });
336
- return !!nav && nav.globalPrivacyControl === true;
356
+ return !!this.launcherOptions?.noFunctional || this.hasTargetingOptOut();
337
357
  }
338
358
 
339
359
  // True when the kit can wait for the shopper's confirm click: signals are not
@@ -377,6 +397,26 @@ export default class RoktManager {
377
397
  this.pendingCheckoutIntents = [];
378
398
  }
379
399
 
400
+ // Under the same gates as checkout intent. A pick made before a kit
401
+ // attaches is not kept: the shopper is still choosing, and the next pick
402
+ // replaces it.
403
+ public notifyPaymentPick(signal: IPaymentPickSignal): void {
404
+ if (this.isCheckoutIntentSuppressed()) {
405
+ return;
406
+ }
407
+
408
+ const kit = this.kit;
409
+ try {
410
+ if (kit && isFunction(kit.onPaymentPick)) {
411
+ kit.onPaymentPick(signal);
412
+ }
413
+ } catch (e) {
414
+ this.logger?.error(
415
+ `RoktManager: Error in onPaymentPick: ${getErrorMessage(e)}`
416
+ );
417
+ }
418
+ }
419
+
380
420
  // Replays recent buffered signals raised on the current page, oldest first.
381
421
  private flushCheckoutIntents(): void {
382
422
  const pending = this.pendingCheckoutIntents;
package/src/store.ts CHANGED
@@ -159,6 +159,7 @@ export interface IFeatureFlags {
159
159
  astBackgroundEvents?: boolean;
160
160
  autoLogPageView?: boolean;
161
161
  autoButtonTracking?: boolean;
162
+ autoLinkTracking?: boolean;
162
163
  }
163
164
 
164
165
  // Temporary Interface until Store can be refactored as a class
@@ -793,6 +794,7 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
793
794
  AstBackgroundEvents,
794
795
  AutoLogPageView,
795
796
  AutoButtonTracking,
797
+ AutoLinkTracking,
796
798
  } = Constants.FeatureFlags;
797
799
 
798
800
  if (!config.flags) {
@@ -815,6 +817,7 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
815
817
  flags[AstBackgroundEvents] = config.flags[AstBackgroundEvents] === 'True';
816
818
  flags[AutoLogPageView] = config.flags[AutoLogPageView] === 'True';
817
819
  flags[AutoButtonTracking] = config.flags[AutoButtonTracking] === 'True';
820
+ flags[AutoLinkTracking] = config.flags[AutoLinkTracking] === 'True';
818
821
  return flags;
819
822
  }
820
823