@schibsted/pulse-sdk 8.0.0-rc.15 → 8.0.0-rc.16

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.
@@ -106,6 +106,7 @@ const anonymousEvents = {
106
106
  trackerEvent: events_anonymous_node_1.anonymousTrackerEvent,
107
107
  engagementEvent: events_anonymous_node_1.anonymousEngagementEvent,
108
108
  };
109
+ const ANONYMOUS_EVENT_FORBIDDEN_FIELDS = ['session', 'actor', 'device', 'location', 'pageViewId'];
109
110
  /**
110
111
  * @typeParam T Type of event to track
111
112
  * @param name
@@ -464,11 +465,11 @@ class Tracker {
464
465
  */
465
466
  async trackAnonymous(eventType, input, options) {
466
467
  // We must create the event as soon as possible, as it defines the creationDate.
467
- const newEvent = this.createAnonymousEvent(input);
468
+ const newEvent = (0, utils_1.omit)(this.createAnonymousEvent(input), ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
468
469
  // Remote config values ----------------
469
470
  await this._applyRemoteConfigEndpoints();
470
471
  // Resolve all available properties ----------------
471
- const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveTrackGlobals()]);
472
+ const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveAnonymousTrackGlobals()]);
472
473
  let eventOutput = resolvedOutput.reduce((acc, p) => (0, utils_1.pulseMerge)(acc, p), {});
473
474
  eventOutput = this.applyAnonymousEventTypeDefaults(eventOutput, eventType);
474
475
  // Leave Events ----------------
@@ -482,6 +483,7 @@ class Tracker {
482
483
  eventInput: eventOutput,
483
484
  sdkConfig: this.state,
484
485
  });
486
+ eventOutput = (0, utils_1.omit)(eventOutput, ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
485
487
  if (options?.bookmarkKey) {
486
488
  this.bookmark.set(options.bookmarkKey, eventOutput);
487
489
  }
@@ -2307,8 +2309,9 @@ class Tracker {
2307
2309
  /**
2308
2310
  * @private
2309
2311
  */
2310
- async resolveTrackGlobals() {
2311
- return (0, utils_1.evaluateAndFlatten)({ ...this.builders });
2312
+ async resolveAnonymousTrackGlobals() {
2313
+ // Omit before evaluation so forbidden promise/function builders cannot delay or fail anonymous tracking.
2314
+ return (0, utils_1.evaluateAndFlatten)((0, utils_1.omit)(this.builders, ANONYMOUS_EVENT_FORBIDDEN_FIELDS));
2312
2315
  }
2313
2316
  /**
2314
2317
  * Send all anonymous events that are in the internal anonymous event queue.
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // This file is auto-generated by bin/generate-version.js. Do not edit manually.
5
- exports.SDK_VERSION = '8.0.0-rc.15';
5
+ exports.SDK_VERSION = '8.0.0-rc.16';
@@ -21,7 +21,7 @@ import * as config from './remoteConfig';
21
21
  import { buildAnonymousViewUIElementEvent, buildCompletedHealthActionEvent, buildEngagementAffiliateEvent, buildEngagementAudioEvent, buildEngagementFormEvent, buildEngagementHealthUIElementEvent, buildEngagementOfferEvent, buildEngagementTeaserEvent, buildEngagementTvModuleEvent, buildEngagementUIElementEvent, buildEngagementVideoAdEvent, buildEngagementVideoEvent, buildEngagementWidgetEvent, buildImpressionAdSlotEvent, buildImpressionAffiliateEvent, buildImpressionFormEvent, buildImpressionHealthUIElementEvent, buildImpressionOfferEvent, buildImpressionPlayerEvent, buildImpressionTeaserEvent, buildImpressionUIElementEvent, buildImpressionWidgetEvent, buildLeaveArticleEvent, buildLeaveAudioPageEvent, buildLeaveErrorEvent, buildLeaveFrontpageEvent, buildLeaveLandingpageEvent, buildLeaveListingEvent, buildLeaveLockedArticleEvent, buildLeaveLockedAudioPageEvent, buildLeaveLockedVideoPageEvent, buildLeavePageEvent, buildLeaveSportsPageEvent, buildLeaveVideoPageEvent, buildLeaveWeatherEvent, buildViewArticleEvent, buildViewAudioPageEvent, buildViewErrorEvent, buildViewFrontpageEvent, buildViewHealthPageEvent, buildViewLandingpageEvent, buildViewListingEvent, buildViewLockedArticleEvent, buildViewLockedAudioPageEvent, buildViewLockedVideoPageEvent, buildViewPageEvent, buildViewSportsPageEvent, buildViewTitleEvent, buildViewVideoPageEvent, buildViewWeatherEvent, } from './tpaas-builders';
22
22
  import { LeaveArticle, LeaveAudioPage, LeaveError, LeaveFrontpage, LeaveLandingpage, LeaveListing, LeaveLockedArticle, LeaveLockedAudioPage, LeaveLockedVideoPage, LeavePage, LeaveSportsPage, LeaveVideoPage, LeaveWeather, ViewArticle, ViewAudioPage, ViewError, ViewFrontpage, ViewHealthPage, ViewLandingpage, ViewListing, ViewLockedArticle, ViewLockedAudioPage, ViewLockedVideoPage, ViewPage, ViewSportsPage, ViewTitle, ViewVideoPage, ViewWeather, } from './tpaas-schemas';
23
23
  import { startProxyProviderListener } from './tracker-proxy/proxy-provider';
24
- import { evaluateAndFlatten, isBrowser, isFunction, isPromise, isString, pulseMerge, throttle } from './utils';
24
+ import { evaluateAndFlatten, isBrowser, isFunction, isPromise, isString, omit, pulseMerge, throttle } from './utils';
25
25
  import { SDK_VERSION } from './version';
26
26
  import { VisibilityObserver } from './visibility-observer';
27
27
  import warnOnce from './warnOnce';
@@ -63,6 +63,7 @@ const anonymousEvents = {
63
63
  trackerEvent: anonymousTrackerEvent,
64
64
  engagementEvent: anonymousEngagementEvent,
65
65
  };
66
+ const ANONYMOUS_EVENT_FORBIDDEN_FIELDS = ['session', 'actor', 'device', 'location', 'pageViewId'];
66
67
  /**
67
68
  * @typeParam T Type of event to track
68
69
  * @param name
@@ -421,11 +422,11 @@ export default class Tracker {
421
422
  */
422
423
  async trackAnonymous(eventType, input, options) {
423
424
  // We must create the event as soon as possible, as it defines the creationDate.
424
- const newEvent = this.createAnonymousEvent(input);
425
+ const newEvent = omit(this.createAnonymousEvent(input), ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
425
426
  // Remote config values ----------------
426
427
  await this._applyRemoteConfigEndpoints();
427
428
  // Resolve all available properties ----------------
428
- const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveTrackGlobals()]);
429
+ const resolvedOutput = await Promise.all([this.resolveTrackInput(newEvent), this.resolveAnonymousTrackGlobals()]);
429
430
  let eventOutput = resolvedOutput.reduce((acc, p) => pulseMerge(acc, p), {});
430
431
  eventOutput = this.applyAnonymousEventTypeDefaults(eventOutput, eventType);
431
432
  // Leave Events ----------------
@@ -439,6 +440,7 @@ export default class Tracker {
439
440
  eventInput: eventOutput,
440
441
  sdkConfig: this.state,
441
442
  });
443
+ eventOutput = omit(eventOutput, ANONYMOUS_EVENT_FORBIDDEN_FIELDS);
442
444
  if (options?.bookmarkKey) {
443
445
  this.bookmark.set(options.bookmarkKey, eventOutput);
444
446
  }
@@ -2264,8 +2266,9 @@ export default class Tracker {
2264
2266
  /**
2265
2267
  * @private
2266
2268
  */
2267
- async resolveTrackGlobals() {
2268
- return evaluateAndFlatten({ ...this.builders });
2269
+ async resolveAnonymousTrackGlobals() {
2270
+ // Omit before evaluation so forbidden promise/function builders cannot delay or fail anonymous tracking.
2271
+ return evaluateAndFlatten(omit(this.builders, ANONYMOUS_EVENT_FORBIDDEN_FIELDS));
2269
2272
  }
2270
2273
  /**
2271
2274
  * Send all anonymous events that are in the internal anonymous event queue.
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated by bin/generate-version.js. Do not edit manually.
2
- export const SDK_VERSION = '8.0.0-rc.15';
2
+ export const SDK_VERSION = '8.0.0-rc.16';
@@ -1334,7 +1334,7 @@ export default class Tracker {
1334
1334
  /**
1335
1335
  * @private
1336
1336
  */
1337
- private resolveTrackGlobals;
1337
+ private resolveAnonymousTrackGlobals;
1338
1338
  /**
1339
1339
  * Send all anonymous events that are in the internal anonymous event queue.
1340
1340
  *
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "8.0.0-rc.15";
1
+ export declare const SDK_VERSION = "8.0.0-rc.16";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/pulse-sdk",
3
- "version": "8.0.0-rc.15",
3
+ "version": "8.0.0-rc.16",
4
4
  "description": "Node.js / Browser Pulse SDK",
5
5
  "author": "Schibsted Data&Tech",
6
6
  "license": "UNLICENSED",