rudder-sdk-js 1.2.15 → 1.3.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.
Files changed (3) hide show
  1. package/index.d.ts +23 -0
  2. package/index.js +334 -51
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -29,6 +29,26 @@ declare module "rudder-sdk-js" {
29
29
  maxItems?: number;
30
30
  }
31
31
 
32
+ /**
33
+ * Represents the beacon queue options parameter in loadOptions type
34
+ */
35
+ interface beaconQueueOptions {
36
+ // Maximum number of events in storage
37
+ maxItems?: number;
38
+ // Time in milliseconds to flush the queue autometically
39
+ flushQueueInterval?: number;
40
+ }
41
+
42
+ /**
43
+ * Represents the beacon queue options parameter in loadOptions type
44
+ */
45
+ interface cookieConsentManager {
46
+ // OneTrust
47
+ oneTrust?: {
48
+ enabled: boolean;
49
+ };
50
+ }
51
+
32
52
  /**
33
53
  * Represents the options parameter in the load API
34
54
  */
@@ -51,6 +71,9 @@ declare module "rudder-sdk-js" {
51
71
  sendAdblockPage?: boolean;
52
72
  sendAdblockPageOptions?: apiOptions;
53
73
  clientSuppliedCallbacks?: { string: () => void };
74
+ useBeacon?: boolean; // Defaults to false
75
+ beaconQueueOptions?: beaconQueueOptions;
76
+ cookieConsentManager?: cookieConsentManager;
54
77
  }
55
78
 
56
79
  /**
package/index.js CHANGED
@@ -5464,7 +5464,12 @@
5464
5464
  "Post Affiliate Pro": "POST_AFFILIATE_PRO",
5465
5465
  postaffiliatepro: "POST_AFFILIATE_PRO",
5466
5466
  POSTAFFILIATEPRO: "POST_AFFILIATE_PRO",
5467
- POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO"
5467
+ POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO",
5468
+ LaunchDarkly: "LAUNCHDARKLY",
5469
+ Launch_Darkly: "LAUNCHDARKLY",
5470
+ LAUNCHDARKLY: "LAUNCHDARKLY",
5471
+ "Launch Darkly": "LAUNCHDARKLY",
5472
+ launchDarkly: "LAUNCHDARKLY"
5468
5473
  };
5469
5474
 
5470
5475
  // from client native integration name to server identified display name
@@ -5511,7 +5516,8 @@
5511
5516
  QUALTRICS: "Qualtrics",
5512
5517
  SENTRY: "Sentry",
5513
5518
  GOOGLE_OPTIMIZE: "GoogleOptimize",
5514
- POST_AFFILIATE_PRO: "PostAffiliatePro"
5519
+ POST_AFFILIATE_PRO: "PostAffiliatePro",
5520
+ LAUNCHDARKLY: "LaunchDarkly"
5515
5521
  };
5516
5522
 
5517
5523
  // Reserved Keywords for properties/triats
@@ -5555,7 +5561,7 @@
5555
5561
  PRODUCT_REVIEWED: "Product Reviewed"
5556
5562
  }; // Enumeration for integrations supported
5557
5563
 
5558
- var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.15";
5564
+ var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.3.0";
5559
5565
  var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
5560
5566
  var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
5561
5567
  /* module.exports = {
@@ -22872,10 +22878,17 @@
22872
22878
  js.async = async === undefined ? defaultAsyncState : async;
22873
22879
  js.type = "text/javascript";
22874
22880
  js.id = id;
22875
- var e = document.getElementsByTagName("script")[0];
22876
- logger.debug("==parent script==", e);
22877
- logger.debug("==adding script==", js);
22878
- e.parentNode.insertBefore(js, e);
22881
+ var headElmColl = document.getElementsByTagName("head");
22882
+
22883
+ if (headElmColl.length !== 0) {
22884
+ logger.debug("==adding script==", js);
22885
+ headElmColl[0].insertBefore(js, headElmColl[0].firstChild);
22886
+ } else {
22887
+ var e = document.getElementsByTagName("script")[0];
22888
+ logger.debug("==parent script==", e);
22889
+ logger.debug("==adding script==", js);
22890
+ e.parentNode.insertBefore(js, e);
22891
+ }
22879
22892
  };
22880
22893
 
22881
22894
  var AdobeAnalytics = /*#__PURE__*/function () {
@@ -27541,12 +27554,13 @@
27541
27554
  camelcase.default = default_1;
27542
27555
 
27543
27556
  var Fullstory = /*#__PURE__*/function () {
27544
- function Fullstory(config) {
27557
+ function Fullstory(config, analytics) {
27545
27558
  _classCallCheck(this, Fullstory);
27546
27559
 
27547
27560
  this.fs_org = config.fs_org;
27548
27561
  this.fs_debug_mode = config.fs_debug_mode;
27549
27562
  this.name = "FULLSTORY";
27563
+ this.analytics = analytics;
27550
27564
  }
27551
27565
 
27552
27566
  _createClass(Fullstory, [{
@@ -27632,6 +27646,85 @@
27632
27646
  return g._w[y].apply(this, arguments);
27633
27647
  };
27634
27648
  })(window, document, window._fs_namespace, "script", "user");
27649
+
27650
+ var FULLSTORY = this.analytics.loadOnlyIntegrations.FULLSTORY; // Checking if crossDomainSupport is their or not.
27651
+
27652
+ if ((FULLSTORY === null || FULLSTORY === void 0 ? void 0 : FULLSTORY.crossDomainSupport) === true) {
27653
+ // This function will check if the customer hash is available or not in localStorage
27654
+ window._fs_identity = function () {
27655
+ if (window.localStorage) {
27656
+ var tata_customer_hash = window.localStorage.tata_customer_hash;
27657
+
27658
+ if (tata_customer_hash) {
27659
+ return {
27660
+ uid: tata_customer_hash,
27661
+ displayName: tata_customer_hash
27662
+ };
27663
+ }
27664
+ } else {
27665
+ logger.debug("Unable to access locaStorage");
27666
+ }
27667
+
27668
+ return null;
27669
+ };
27670
+
27671
+ (function () {
27672
+ function fs(api) {
27673
+ if (!window._fs_namespace) {
27674
+ console.error('FullStory unavailable, window["_fs_namespace"] must be defined');
27675
+ return undefined;
27676
+ }
27677
+
27678
+ return api ? window[window._fs_namespace][api] : window[window._fs_namespace];
27679
+ }
27680
+
27681
+ function waitUntil(predicateFn, callbackFn, timeout, timeoutFn) {
27682
+ var totalTime = 0;
27683
+ var delay = 64;
27684
+
27685
+ var resultFn = function resultFn() {
27686
+ if (typeof predicateFn === "function" && predicateFn()) {
27687
+ callbackFn();
27688
+ return;
27689
+ }
27690
+
27691
+ delay = Math.min(delay * 2, 1024);
27692
+
27693
+ if (totalTime > timeout) {
27694
+ if (timeoutFn) {
27695
+ timeoutFn();
27696
+ }
27697
+ }
27698
+
27699
+ totalTime += delay;
27700
+ setTimeout(resultFn, delay);
27701
+ };
27702
+
27703
+ resultFn();
27704
+ } // Checking if timeout is provided or not.
27705
+
27706
+
27707
+ var timeout = FULLSTORY.timeout || 2000;
27708
+
27709
+ function identify() {
27710
+ if (typeof window._fs_identity === "function") {
27711
+ var userVars = window._fs_identity();
27712
+
27713
+ if (_typeof(userVars) === "object" && typeof userVars.uid === "string") {
27714
+ fs("setUserVars")(userVars);
27715
+ fs("restart")();
27716
+ } else {
27717
+ fs("log")("error", "FS.setUserVars requires an object that contains uid");
27718
+ }
27719
+ } else {
27720
+ fs("log")("error", 'window["_fs_identity"] function not found');
27721
+ }
27722
+ }
27723
+
27724
+ fs("shutdown")();
27725
+ waitUntil(window._fs_identity, identify, timeout, fs("restart"));
27726
+ })();
27727
+ }
27635
27728
  }
27636
27729
  }, {
27637
27730
  key: "page",
@@ -29280,12 +29373,16 @@
29280
29373
 
29281
29374
  this.containerID = config.containerID;
29282
29375
  this.name = "GOOGLETAGMANAGER";
29376
+ this.serverUrl = config.serverUrl;
29283
29377
  }
29284
29378
 
29285
29379
  _createClass(GoogleTagManager, [{
29286
29380
  key: "init",
29287
29381
  value: function init() {
29288
29382
  logger.debug("===in init GoogleTagManager===");
29383
+ var defaultUrl = "https://www.googletagmanager.com"; // ref: https://developers.google.com/tag-platform/tag-manager/server-side/send-data#update_the_gtmjs_source_domain
29384
+
29385
+ window.finalUrl = this.serverUrl ? this.serverUrl : defaultUrl;
29289
29386
 
29290
29387
  (function (w, d, s, l, i) {
29291
29388
  w[l] = w[l] || [];
@@ -29297,7 +29394,7 @@
29297
29394
  var j = d.createElement(s);
29298
29395
  var dl = l !== "dataLayer" ? "&l=".concat(l) : "";
29299
29396
  j.async = true;
29300
- j.src = "https://www.googletagmanager.com/gtm.js?id=".concat(i).concat(dl);
29397
+ j.src = "".concat(window.finalUrl, "/gtm.js?id=").concat(i).concat(dl);
29301
29398
  f.parentNode.insertBefore(j, f);
29302
29399
  })(window, document, "script", "dataLayer", this.containerID);
29303
29400
  }
@@ -29485,8 +29582,7 @@
29485
29582
  function Hotjar(config) {
29486
29583
  _classCallCheck(this, Hotjar);
29487
29584
 
29488
- this.siteId = config.siteID; // 1549611
29489
-
29585
+ this.siteId = config.siteID;
29490
29586
  this.name = "HOTJAR";
29491
29587
  this._ready = false;
29492
29588
  }
@@ -29494,6 +29590,7 @@
29494
29590
  _createClass(Hotjar, [{
29495
29591
  key: "init",
29496
29592
  value: function init() {
29593
+ logger.debug("===In init Hotjar===");
29497
29594
  window.hotjarSiteId = this.siteId;
29498
29595
 
29499
29596
  (function (h, o, t, j, a, r) {
@@ -29513,11 +29610,11 @@
29513
29610
  })(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv=");
29514
29611
 
29515
29612
  this._ready = true;
29516
- logger.debug("===in init Hotjar===");
29517
29613
  }
29518
29614
  }, {
29519
29615
  key: "identify",
29520
29616
  value: function identify(rudderElement) {
29617
+ logger.debug("===In Hotjar identify===");
29521
29618
  var userId = rudderElement.message.userId || rudderElement.message.anonymousId;
29522
29619
 
29523
29620
  if (!userId) {
@@ -29531,21 +29628,34 @@
29531
29628
  }, {
29532
29629
  key: "track",
29533
29630
  value: function track(rudderElement) {
29534
- logger.debug("[Hotjar] track:: method not supported");
29631
+ logger.debug("===In Hotjar track===");
29632
+ var event = rudderElement.message.event;
29633
+
29634
+ if (!event) {
29635
+ logger.error("Event name not present");
29636
+ return;
29637
+ } // event name must not exceed 750 characters and can only contain alphanumeric, underscores, and dashes.
29638
+ // Ref - https://help.hotjar.com/hc/en-us/articles/4405109971095#the-events-api-call
29639
+
29640
+
29641
+ window.hj("event", event.replace(/\s\s+/g, " ").substring(0, 750).replaceAll(" ", "_"));
29535
29642
  }
29536
29643
  }, {
29537
29644
  key: "page",
29538
- value: function page(rudderElement) {
29645
+ value: function page() {
29646
+ logger.debug("===In Hotjar page===");
29539
29647
  logger.debug("[Hotjar] page:: method not supported");
29540
29648
  }
29541
29649
  }, {
29542
29650
  key: "isLoaded",
29543
29651
  value: function isLoaded() {
29652
+ logger.debug("===In isLoaded Hotjar===");
29544
29653
  return this._ready;
29545
29654
  }
29546
29655
  }, {
29547
29656
  key: "isReady",
29548
29657
  value: function isReady() {
29658
+ logger.debug("===In isReady Hotjar===");
29549
29659
  return this._ready;
29550
29660
  }
29551
29661
  }]);
@@ -32302,7 +32412,7 @@
32302
32412
  }();
32303
32413
 
32304
32414
  var eventMapping = [{
32305
- src: ["checkout step completed", "order completed"],
32415
+ src: ["order completed"],
32306
32416
  dest: "Checkout"
32307
32417
  }, {
32308
32418
  src: ["product added"],
@@ -32671,10 +32781,11 @@
32671
32781
  this.disableCookie = config.disableCookie || false;
32672
32782
  this.propertyBlackList = [];
32673
32783
  this.xhrHeaders = {};
32784
+ this.enableLocalStoragePersistence = config.enableLocalStoragePersistence;
32674
32785
 
32675
32786
  if (config.xhrHeaders && config.xhrHeaders.length > 0) {
32676
32787
  config.xhrHeaders.forEach(function (header) {
32677
- if (header && header.key && header.value && header.key.trim() != "" && header.value.trim() != "") {
32788
+ if (header && header.key && header.value && header.key.trim() !== "" && header.value.trim() !== "") {
32678
32789
  _this.xhrHeaders[header.key] = header.value;
32679
32790
  }
32680
32791
  });
@@ -32682,7 +32793,7 @@
32682
32793
 
32683
32794
  if (config.propertyBlackList && config.propertyBlackList.length > 0) {
32684
32795
  config.propertyBlackList.forEach(function (element) {
32685
- if (element && element.property && element.property.trim() != "") {
32796
+ if (element && element.property && element.property.trim() !== "") {
32686
32797
  _this.propertyBlackList.push(element.property);
32687
32798
  }
32688
32799
  });
@@ -32717,6 +32828,7 @@
32717
32828
  e._i.push([i, s, a]);
32718
32829
  }, e.__SV = 1);
32719
32830
  }(document, window.posthog || []);
32831
+ var POSTHOG = this.analytics.loadOnlyIntegrations.POSTHOG;
32720
32832
  var configObject = {
32721
32833
  api_host: this.yourInstance,
32722
32834
  autocapture: this.autocapture,
@@ -32726,10 +32838,18 @@
32726
32838
  disable_cookie: this.disableCookie
32727
32839
  };
32728
32840
 
32841
+ if (POSTHOG && POSTHOG.loaded) {
32842
+ configObject.loaded = POSTHOG.loaded;
32843
+ }
32844
+
32729
32845
  if (this.xhrHeaders && Object.keys(this.xhrHeaders).length > 0) {
32730
32846
  configObject.xhr_headers = this.xhrHeaders;
32731
32847
  }
32732
32848
 
32849
+ if (this.enableLocalStoragePersistence) {
32850
+ configObject.persistence = "localStorage+cookie";
32851
+ }
32852
+
32733
32853
  posthog.init(this.teamApiKey, configObject);
32734
32854
  }
32735
32855
  /**
@@ -32759,7 +32879,7 @@
32759
32879
 
32760
32880
  if (unsetProperties && unsetProperties.length > 0) {
32761
32881
  unsetProperties.forEach(function (property) {
32762
- if (property && property.trim() != "") {
32882
+ if (property && property.trim() !== "") {
32763
32883
  posthog.unregister(property);
32764
32884
  }
32765
32885
  });
@@ -32791,7 +32911,7 @@
32791
32911
  posthog.capture(event, properties);
32792
32912
  }
32793
32913
  /**
32794
- *
32914
+ *
32795
32915
  *
32796
32916
  * @memberof Posthog
32797
32917
  */
@@ -34191,6 +34311,100 @@
34191
34311
  return PostAffiliatePro;
34192
34312
  }();
34193
34313
 
34314
+ var createUser = function createUser(message) {
34315
+ var user = {};
34316
+ user.key = message.userId || message.anonymousId;
34317
+ var traits = message.context.traits;
34318
+
34319
+ if (traits.anonymous !== undefined) {
34320
+ user.anonymous = traits.anonymous;
34321
+ }
34322
+
34323
+ if (traits.avatar !== undefined) user.avatar = traits.avatar;
34324
+ if (traits.country !== undefined) user.country = traits.country;
34325
+ if (traits.custom !== undefined) user.custom = traits.custom;
34326
+ if (traits.email !== undefined) user.email = traits.email;
34327
+ if (traits.firstName !== undefined) user.firstName = traits.firstName;
34328
+ if (traits.ip !== undefined) user.ip = traits.ip;
34329
+ if (traits.lastName !== undefined) user.lastName = traits.lastName;
34330
+ if (traits.name !== undefined) user.name = traits.name;
34331
+ if (traits.privateAttributeNames !== undefined) user.privateAttributeNames = traits.privateAttributeNames;
34332
+ if (traits.secondary !== undefined) user.secondary = traits.secondary;
34333
+ return user;
34334
+ };
34335
+
34336
+ var LaunchDarkly = /*#__PURE__*/function () {
34337
+ function LaunchDarkly(config) {
34338
+ _classCallCheck(this, LaunchDarkly);
34339
+
34340
+ this.name = "LaunchDarkly";
34341
+ this.clientSideId = config.clientSideId;
34342
+ }
34343
+
34344
+ _createClass(LaunchDarkly, [{
34345
+ key: "init",
34346
+ value: function init() {
34347
+ logger.debug("===in init LaunchDarkly===");
34348
+
34349
+ if (!this.clientSideId) {
34350
+ logger.error("".concat(this.name, " :: Unable to initialize destination - clientSideId is missing in config"));
34351
+ return;
34352
+ }
34353
+
34354
+ ScriptLoader(null, "https://unpkg.com/launchdarkly-js-client-sdk@2");
34355
+ }
34356
+ }, {
34357
+ key: "isLoaded",
34358
+ value: function isLoaded() {
34359
+ logger.debug("===In isLoaded LaunchDarkly===");
34360
+ return !!window.LDClient;
34361
+ }
34362
+ }, {
34363
+ key: "isReady",
34364
+ value: function isReady() {
34365
+ logger.debug("===In isReady LaunchDarkly===");
34366
+ return this.isLoaded();
34367
+ }
34368
+ }, {
34369
+ key: "identify",
34370
+ value: function identify(rudderElement) {
34371
+ var message = rudderElement.message;
34372
+ window.user = createUser(message);
34373
+
34374
+ if (window.ldclient) {
34375
+ window.ldclient.identify(window.user);
34376
+ } else {
34377
+ window.ldclient = window.LDClient.initialize(this.clientSideId, window.user);
34378
+ }
34379
+ }
34380
+ }, {
34381
+ key: "track",
34382
+ value: function track(rudderElement) {
34383
+ var _rudderElement$messag = rudderElement.message,
34384
+ event = _rudderElement$messag.event,
34385
+ properties = _rudderElement$messag.properties;
34386
+
34387
+ if (window.ldclient) {
34388
+ window.ldclient.track(event, properties);
34389
+ } else logger.error("=== In LaunchDarkly, track is not supported before identify ===");
34390
+ }
34391
+ }, {
34392
+ key: "alias",
34393
+ value: function alias(rudderElement) {
34394
+ var message = rudderElement.message;
34395
+ var newUser = {
34396
+ key: message.userId
34397
+ };
34398
+
34399
+ if (window.ldclient) {
34400
+ window.ldclient.alias(newUser, window.user);
34401
+ } else logger.error("=== In LaunchDarkly, alias is not supported before identify ===");
34402
+ }
34403
+ }]);
34404
+
34405
+ return LaunchDarkly;
34406
+ }();
34407
+
34194
34408
  // (config-plan name, native destination.name , exported integration name(this one below))
34195
34409
 
34196
34410
  var integrations = {
@@ -34237,7 +34451,8 @@
34237
34451
  TVSQUARED: TVSquared,
34238
34452
  VWO: VWO,
34239
34453
  GOOGLE_OPTIMIZE: GoogleOptimize,
34240
- POST_AFFILIATE_PRO: PostAffiliatePro
34454
+ POST_AFFILIATE_PRO: PostAffiliatePro,
34455
+ LAUNCHDARKLY: LaunchDarkly
34241
34456
  };
34242
34457
 
34243
34458
  // Application class
@@ -34247,7 +34462,7 @@
34247
34462
  this.build = "1.0.0";
34248
34463
  this.name = "RudderLabs JavaScript SDK";
34249
34464
  this.namespace = "com.rudderlabs.javascript";
34250
- this.version = "1.2.15";
34465
+ this.version = "1.3.0";
34251
34466
  });
34252
34467
 
34253
34468
  // Library information class
@@ -34255,7 +34470,7 @@
34255
34470
  _classCallCheck(this, RudderLibraryInfo);
34256
34471
 
34257
34472
  this.name = "RudderLabs JavaScript SDK";
34258
- this.version = "1.2.15";
34473
+ this.version = "1.3.0";
34259
34474
  }); // Operating System information class
34260
34475
 
34261
34476
 
@@ -36904,8 +37119,7 @@
36904
37119
  // we will not be filtering any of the destinations.
36905
37120
 
36906
37121
  if (!window.OneTrust || !window.OnetrustActiveGroups) {
36907
- logger.debug("Onetrust window objects not retrieved. Thus events are sent.");
36908
- return true;
37122
+ throw new Error("OneTrust resources are not accessible. Thus all the destinations will be loaded");
36909
37123
  } // OneTrust Cookie Compliance populates a data layer object OnetrustActiveGroups with
36910
37124
  // the cookie categories that the user has consented to.
36911
37125
  // Eg: ',C0001,C0003,'
@@ -36989,7 +37203,7 @@
36989
37203
 
36990
37204
  _createClass(CookieConsentFactory, null, [{
36991
37205
  key: "initialize",
36992
- value: function initialize(sourceConfig, cookieConsentOptions) {
37206
+ value: function initialize(cookieConsentOptions) {
36993
37207
  var _cookieConsentOptions;
36994
37208
 
36995
37209
  /**
@@ -37149,18 +37363,19 @@
37149
37363
  logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
37150
37364
 
37151
37365
  this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
37152
- var cookieConsent = undefined; // Check if cookie consent manager is being set through load options
37366
+ var cookieConsent; // Call the cookie consent factory to initialize and return the type of cookie
37367
+ // consent being set. For now we only support OneTrust.
37153
37368
 
37154
- if (Object.keys(this.cookieConsentOptions).length) {
37155
- // Call the cookie consent factory to initialise and return the type of cookie
37156
- // consent being set. For now we only support OneTrust.
37157
- cookieConsent = CookieConsentFactory.initialize(response, this.cookieConsentOptions);
37369
+ try {
37370
+ cookieConsent = CookieConsentFactory.initialize(this.cookieConsentOptions);
37371
+ } catch (e) {
37372
+ logger.error(e);
37158
37373
  } // If cookie consent object is return we filter according to consents given by user
37159
37374
  // else we do not consider any filtering for cookie consent.
37160
37375
 
37161
37376
 
37162
37377
  this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
37163
- return integrations[intg.name] != undefined && (!cookieConsent || // check if cookieconsent object is present and then do filtering
37378
+ return integrations[intg.name] != undefined && (!cookieConsent || // check if cookie consent object is present and then do filtering
37164
37379
  cookieConsent && cookieConsent.isEnabled(intg.config));
37165
37380
  });
37166
37381
  this.init(this.clientIntegrations);
@@ -37262,11 +37477,15 @@
37262
37477
  try {
37263
37478
  if (!succesfulLoadedIntersectClientSuppliedIntegrations[i].isFailed || !succesfulLoadedIntersectClientSuppliedIntegrations[i].isFailed()) {
37264
37479
  if (succesfulLoadedIntersectClientSuppliedIntegrations[i][methodName]) {
37265
- var _succesfulLoadedInter;
37480
+ var sendEvent = !object.IsEventBlackListed(event[0].message.event, succesfulLoadedIntersectClientSuppliedIntegrations[i].name); // Block the event if it is blacklisted for the device-mode destination
37481
+
37482
+ if (sendEvent) {
37483
+ var _succesfulLoadedInter;
37266
37484
 
37267
- var clonedBufferEvent = lodash_clonedeep(event);
37485
+ var clonedBufferEvent = lodash_clonedeep(event);
37268
37486
 
37269
- (_succesfulLoadedInter = succesfulLoadedIntersectClientSuppliedIntegrations[i])[methodName].apply(_succesfulLoadedInter, _toConsumableArray(clonedBufferEvent));
37487
+ (_succesfulLoadedInter = succesfulLoadedIntersectClientSuppliedIntegrations[i])[methodName].apply(_succesfulLoadedInter, _toConsumableArray(clonedBufferEvent));
37488
+ }
37270
37489
  }
37271
37490
  }
37272
37491
  } catch (error) {
@@ -37573,6 +37792,64 @@
37573
37792
  value: function trackEvent(rudderElement, options, callback) {
37574
37793
  this.processAndSendDataToDestinations("track", rudderElement, options, callback);
37575
37794
  }
37795
+ }, {
37796
+ key: "IsEventBlackListed",
37797
+ value: function IsEventBlackListed(eventName, intgName) {
37798
+ if (!eventName || !(typeof eventName === "string")) {
37799
+ return false;
37800
+ }
37801
+
37802
+ var sdkIntgName = commonNames[intgName];
37803
+ var intg = this.clientIntegrations.find(function (intg) {
37804
+ return intg.name === sdkIntgName;
37805
+ });
37806
+ var _intg$config = intg.config,
37807
+ blacklistedEvents = _intg$config.blacklistedEvents,
37808
+ whitelistedEvents = _intg$config.whitelistedEvents,
37809
+ eventFilteringOption = _intg$config.eventFilteringOption;
37810
+
37811
+ if (!eventFilteringOption) {
37812
+ return false;
37813
+ }
37814
+
37815
+ switch (eventFilteringOption) {
37816
+ // disabled filtering
37817
+ case "disable":
37818
+ return false;
37819
+ // Blacklist is choosen for filtering events
37820
+
37821
+ case "blacklistedEvents":
37822
+ var isValidBlackList = blacklistedEvents && Array.isArray(blacklistedEvents) && blacklistedEvents.every(function (x) {
37823
+ return x.eventName !== "";
37824
+ });
37825
+
37826
+ if (isValidBlackList) {
37827
+ return blacklistedEvents.find(function (eventObj) {
37828
+ return eventObj.eventName.trim().toUpperCase() === eventName.trim().toUpperCase();
37829
+ }) === undefined ? false : true;
37830
+ } else {
37831
+ return false;
37832
+ }
37833
+
37834
+ // Whitelist is choosen for filtering events
37835
+
37836
+ case "whitelistedEvents":
37837
+ var isValidWhiteList = whitelistedEvents && Array.isArray(whitelistedEvents) && whitelistedEvents.some(function (x) {
37838
+ return x.eventName !== "";
37839
+ });
37840
+
37841
+ if (isValidWhiteList) {
37842
+ return whitelistedEvents.find(function (eventObj) {
37843
+ return eventObj.eventName.trim().toUpperCase() === eventName.trim().toUpperCase();
37844
+ }) === undefined ? true : false;
37845
+ } else {
37846
+ return true;
37847
+ }
37848
+
37849
+ default:
37850
+ return false;
37851
+ }
37852
+ }
37576
37853
  /**
37577
37854
  * Process and send data to destinations along with rudder BE
37578
37855
  *
@@ -37585,6 +37862,8 @@
37585
37862
  }, {
37586
37863
  key: "processAndSendDataToDestinations",
37587
37864
  value: function processAndSendDataToDestinations(type, rudderElement, options, callback) {
37865
+ var _this3 = this;
37866
+
37588
37867
  try {
37589
37868
  if (!this.anonymousId) {
37590
37869
  this.setAnonymousId();
@@ -37626,8 +37905,12 @@
37626
37905
  succesfulLoadedIntersectClientSuppliedIntegrations.forEach(function (obj) {
37627
37906
  if (!obj.isFailed || !obj.isFailed()) {
37628
37907
  if (obj[type]) {
37629
- var clonedRudderElement = lodash_clonedeep(rudderElement);
37630
- obj[type](clonedRudderElement);
37908
+ var sendEvent = !_this3.IsEventBlackListed(rudderElement.message.event, obj.name); // Block the event if it is blacklisted for the device-mode destination
37909
+
37910
+ if (sendEvent) {
37911
+ var clonedRudderElement = lodash_clonedeep(rudderElement);
37912
+ obj[type](clonedRudderElement);
37913
+ }
37631
37914
  }
37632
37915
  }
37633
37916
  });
@@ -37822,7 +38105,7 @@
37822
38105
  }, {
37823
38106
  key: "load",
37824
38107
  value: function load(writeKey, serverUrl, options) {
37825
- var _this3 = this;
38108
+ var _this4 = this;
37826
38109
 
37827
38110
  logger.debug("inside load ");
37828
38111
  if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
@@ -37880,9 +38163,9 @@
37880
38163
  // convert to rudder recognised method names
37881
38164
  var tranformedCallbackMapping = {};
37882
38165
  Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
37883
- if (_this3.methodToCallbackMapping.hasOwnProperty(methodName)) {
37884
- if (options.clientSuppliedCallbacks[_this3.methodToCallbackMapping[methodName]]) {
37885
- tranformedCallbackMapping[methodName] = options.clientSuppliedCallbacks[_this3.methodToCallbackMapping[methodName]];
38166
+ if (_this4.methodToCallbackMapping.hasOwnProperty(methodName)) {
38167
+ if (options.clientSuppliedCallbacks[_this4.methodToCallbackMapping[methodName]]) {
38168
+ tranformedCallbackMapping[methodName] = options.clientSuppliedCallbacks[_this4.methodToCallbackMapping[methodName]];
37886
38169
  }
37887
38170
  }
37888
38171
  });
@@ -37931,7 +38214,7 @@
37931
38214
 
37932
38215
  if (res instanceof Promise) {
37933
38216
  res.then(function (res) {
37934
- return _this3.processResponse(200, res);
38217
+ return _this4.processResponse(200, res);
37935
38218
  }).catch(errorHandler);
37936
38219
  } else {
37937
38220
  this.processResponse(200, res);
@@ -37966,25 +38249,25 @@
37966
38249
  }, {
37967
38250
  key: "initializeCallbacks",
37968
38251
  value: function initializeCallbacks() {
37969
- var _this4 = this;
38252
+ var _this5 = this;
37970
38253
 
37971
38254
  Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
37972
- if (_this4.methodToCallbackMapping.hasOwnProperty(methodName)) {
37973
- _this4.on(methodName, function () {});
38255
+ if (_this5.methodToCallbackMapping.hasOwnProperty(methodName)) {
38256
+ _this5.on(methodName, function () {});
37974
38257
  }
37975
38258
  });
37976
38259
  }
37977
38260
  }, {
37978
38261
  key: "registerCallbacks",
37979
38262
  value: function registerCallbacks(calledFromLoad) {
37980
- var _this5 = this;
38263
+ var _this6 = this;
37981
38264
 
37982
38265
  if (!calledFromLoad) {
37983
38266
  Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
37984
- if (_this5.methodToCallbackMapping.hasOwnProperty(methodName)) {
38267
+ if (_this6.methodToCallbackMapping.hasOwnProperty(methodName)) {
37985
38268
  if (window.rudderanalytics) {
37986
- if (typeof window.rudderanalytics[_this5.methodToCallbackMapping[methodName]] === "function") {
37987
- _this5.clientSuppliedCallbacks[methodName] = window.rudderanalytics[_this5.methodToCallbackMapping[methodName]];
38269
+ if (typeof window.rudderanalytics[_this6.methodToCallbackMapping[methodName]] === "function") {
38270
+ _this6.clientSuppliedCallbacks[methodName] = window.rudderanalytics[_this6.methodToCallbackMapping[methodName]];
37988
38271
  }
37989
38272
  } // let callback =
37990
38273
  // ? typeof window.rudderanalytics[
@@ -38001,10 +38284,10 @@
38001
38284
  }
38002
38285
 
38003
38286
  Object.keys(this.clientSuppliedCallbacks).forEach(function (methodName) {
38004
- if (_this5.clientSuppliedCallbacks.hasOwnProperty(methodName)) {
38005
- logger.debug("registerCallbacks", methodName, _this5.clientSuppliedCallbacks[methodName]);
38287
+ if (_this6.clientSuppliedCallbacks.hasOwnProperty(methodName)) {
38288
+ logger.debug("registerCallbacks", methodName, _this6.clientSuppliedCallbacks[methodName]);
38006
38289
 
38007
- _this5.on(methodName, _this5.clientSuppliedCallbacks[methodName]);
38290
+ _this6.on(methodName, _this6.clientSuppliedCallbacks[methodName]);
38008
38291
  }
38009
38292
  });
38010
38293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "1.2.15",
3
+ "version": "1.3.0",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",