rudder-sdk-js 1.2.10 → 1.2.15

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 +2 -0
  2. package/index.js +635 -219
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -39,6 +39,8 @@ declare module "rudder-sdk-js" {
39
39
  queueOptions?: queueOptions;
40
40
  // Defaults to true
41
41
  loadIntegration?: boolean;
42
+ // Defaults to false
43
+ secureCookie?: boolean;
42
44
  logLevel?: string;
43
45
  getSourceConfig?: () =>
44
46
  | string
package/index.js CHANGED
@@ -9,14 +9,9 @@
9
9
 
10
10
  if (Object.getOwnPropertySymbols) {
11
11
  var symbols = Object.getOwnPropertySymbols(object);
12
-
13
- if (enumerableOnly) {
14
- symbols = symbols.filter(function (sym) {
15
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
16
- });
17
- }
18
-
19
- keys.push.apply(keys, symbols);
12
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
13
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
14
+ })), keys.push.apply(keys, symbols);
20
15
  }
21
16
 
22
17
  return keys;
@@ -24,19 +19,12 @@
24
19
 
25
20
  function _objectSpread2(target) {
26
21
  for (var i = 1; i < arguments.length; i++) {
27
- var source = arguments[i] != null ? arguments[i] : {};
28
-
29
- if (i % 2) {
30
- ownKeys(Object(source), true).forEach(function (key) {
31
- _defineProperty(target, key, source[key]);
32
- });
33
- } else if (Object.getOwnPropertyDescriptors) {
34
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
35
- } else {
36
- ownKeys(Object(source)).forEach(function (key) {
37
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
38
- });
39
- }
22
+ var source = null != arguments[i] ? arguments[i] : {};
23
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
24
+ _defineProperty(target, key, source[key]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
26
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
27
+ });
40
28
  }
41
29
 
42
30
  return target;
@@ -45,17 +33,11 @@
45
33
  function _typeof(obj) {
46
34
  "@babel/helpers - typeof";
47
35
 
48
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
49
- _typeof = function (obj) {
50
- return typeof obj;
51
- };
52
- } else {
53
- _typeof = function (obj) {
54
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
55
- };
56
- }
57
-
58
- return _typeof(obj);
36
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
37
+ return typeof obj;
38
+ } : function (obj) {
39
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
40
+ }, _typeof(obj);
59
41
  }
60
42
 
61
43
  function _classCallCheck(instance, Constructor) {
@@ -77,6 +59,9 @@
77
59
  function _createClass(Constructor, protoProps, staticProps) {
78
60
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
79
61
  if (staticProps) _defineProperties(Constructor, staticProps);
62
+ Object.defineProperty(Constructor, "prototype", {
63
+ writable: false
64
+ });
80
65
  return Constructor;
81
66
  }
82
67
 
@@ -5570,7 +5555,7 @@
5570
5555
  PRODUCT_REVIEWED: "Product Reviewed"
5571
5556
  }; // Enumeration for integrations supported
5572
5557
 
5573
- var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.10";
5558
+ var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.15";
5574
5559
  var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
5575
5560
  var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
5576
5561
  /* module.exports = {
@@ -11522,6 +11507,10 @@
11522
11507
  if (Store.enabled) {
11523
11508
  this.storage = Store;
11524
11509
  }
11510
+
11511
+ if (!this.storage) {
11512
+ throw Error("Could not initialize the SDK :: no storage is available");
11513
+ }
11525
11514
  }
11526
11515
 
11527
11516
  _createClass(Storage, [{
@@ -23724,7 +23713,7 @@
23724
23713
  return Appcues;
23725
23714
  }();
23726
23715
 
23727
- var BingAds = function BingAds(config) {
23716
+ var BingAds = /*#__PURE__*/_createClass(function BingAds(config) {
23728
23717
  var _this = this;
23729
23718
 
23730
23719
  _classCallCheck(this, BingAds);
@@ -23804,7 +23793,7 @@
23804
23793
 
23805
23794
  this.tagID = config.tagID;
23806
23795
  this.name = "BINGADS";
23807
- };
23796
+ });
23808
23797
 
23809
23798
  /*
23810
23799
  E-commerce support required for logPurchase support & other e-commerce events as track with productId changed
@@ -26982,8 +26971,13 @@
26982
26971
  }
26983
26972
  }, {
26984
26973
  key: "page",
26985
- value: function page() {
26986
- window.fbq("track", "PageView");
26974
+ value: function page(rudderElement) {
26975
+ var _rudderElement$messag = rudderElement.message,
26976
+ properties = _rudderElement$messag.properties,
26977
+ messageId = _rudderElement$messag.messageId;
26978
+ window.fbq("track", "PageView", properties, {
26979
+ eventID: messageId
26980
+ });
26987
26981
  }
26988
26982
  }, {
26989
26983
  key: "identify",
@@ -26999,10 +26993,10 @@
26999
26993
  var _this = this;
27000
26994
 
27001
26995
  var self = this;
27002
- var _rudderElement$messag = rudderElement.message,
27003
- event = _rudderElement$messag.event,
27004
- properties = _rudderElement$messag.properties,
27005
- messageId = _rudderElement$messag.messageId;
26996
+ var _rudderElement$messag2 = rudderElement.message,
26997
+ event = _rudderElement$messag2.event,
26998
+ properties = _rudderElement$messag2.properties,
26999
+ messageId = _rudderElement$messag2.messageId;
27006
27000
  var revValue;
27007
27001
  var currVal;
27008
27002
 
@@ -27313,25 +27307,25 @@
27313
27307
  }
27314
27308
  /**
27315
27309
  * Get the Facebook Content Type
27316
- *
27310
+ *
27317
27311
  * Can be `product`, `destination`, `flight` or `hotel`.
27318
- *
27312
+ *
27319
27313
  * This can be overridden within the message
27320
27314
  * `options.integrations.FACEBOOK_PIXEL.contentType`, or alternatively you can
27321
27315
  * set the "Map Categories to Facebook Content Types" setting within
27322
27316
  * RudderStack config and then set the corresponding commerce category in
27323
27317
  * `track()` properties.
27324
- *
27318
+ *
27325
27319
  * https://www.facebook.com/business/help/606577526529702?id=1205376682832142
27326
27320
  */
27327
27321
 
27328
27322
  }, {
27329
27323
  key: "getContentType",
27330
27324
  value: function getContentType(rudderElement, defaultValue) {
27331
- var _rudderElement$messag2, _rudderElement$messag3;
27325
+ var _rudderElement$messag3, _rudderElement$messag4;
27332
27326
 
27333
27327
  // Get the message-specific override if it exists in the options parameter of `track()`
27334
- var contentTypeMessageOverride = (_rudderElement$messag2 = rudderElement.message.integrations) === null || _rudderElement$messag2 === void 0 ? void 0 : (_rudderElement$messag3 = _rudderElement$messag2.FACEBOOK_PIXEL) === null || _rudderElement$messag3 === void 0 ? void 0 : _rudderElement$messag3.contentType;
27328
+ var contentTypeMessageOverride = (_rudderElement$messag3 = rudderElement.message.integrations) === null || _rudderElement$messag3 === void 0 ? void 0 : (_rudderElement$messag4 = _rudderElement$messag3.FACEBOOK_PIXEL) === null || _rudderElement$messag4 === void 0 ? void 0 : _rudderElement$messag4.contentType;
27335
27329
  if (contentTypeMessageOverride) return [contentTypeMessageOverride]; // Otherwise check if there is a replacement set for all Facebook Pixel
27336
27330
  // track calls of this category
27337
27331
 
@@ -29115,6 +29109,7 @@
29115
29109
  this.pageLoadConversions = config.pageLoadConversions;
29116
29110
  this.clickEventConversions = config.clickEventConversions;
29117
29111
  this.defaultPageConversion = config.defaultPageConversion;
29112
+ this.dynamicRemarketing = config.dynamicRemarketing;
29118
29113
  this.sendPageView = config.sendPageView || true;
29119
29114
  this.conversionLinker = config.conversionLinker || true;
29120
29115
  this.disableAdPersonalization = config.disableAdPersonalization || false;
@@ -29159,44 +29154,85 @@
29159
29154
  }
29160
29155
  }, {
29161
29156
  key: "identify",
29162
- value: function identify(rudderElement) {
29157
+ value: function identify() {
29163
29158
  logger.debug("[GoogleAds] identify:: method not supported");
29164
29159
  } // https://developers.google.com/gtagjs/reference/event
29165
29160
 
29166
29161
  }, {
29167
29162
  key: "track",
29168
29163
  value: function track(rudderElement) {
29169
- logger.debug("in GoogleAdsAnalyticsManager track");
29170
- var conversionData = this.getConversionData(this.clickEventConversions, rudderElement.message.event);
29164
+ logger.debug("in GoogleAdsAnalyticsManager track"); // Dynamic remarketing disabled
29171
29165
 
29172
- if (conversionData.conversionLabel) {
29173
- var conversionLabel = conversionData.conversionLabel;
29174
- var eventName = conversionData.eventName;
29175
- var sendToValue = "".concat(this.conversionId, "/").concat(conversionLabel);
29176
- var properties = {};
29166
+ if (!this.dynamicRemarketing) {
29167
+ var conversionData = this.getConversionData(this.clickEventConversions, rudderElement.message.event);
29168
+
29169
+ if (conversionData.conversionLabel) {
29170
+ var conversionLabel = conversionData.conversionLabel;
29171
+ var eventName = conversionData.eventName;
29172
+ var sendToValue = "".concat(this.conversionId, "/").concat(conversionLabel);
29173
+ var properties = {};
29174
+
29175
+ if (rudderElement.message.properties) {
29176
+ properties.value = rudderElement.message.properties.revenue;
29177
+ properties.currency = rudderElement.message.properties.currency;
29178
+ properties.transaction_id = rudderElement.message.properties.order_id;
29179
+ }
29180
+
29181
+ properties.send_to = sendToValue;
29182
+ properties = removeUndefinedAndNullValues(properties);
29183
+ window.gtag("event", eventName, properties);
29184
+ }
29185
+ } else {
29186
+ var event = rudderElement.message.event;
29187
+
29188
+ if (!event) {
29189
+ logger.error("Event name not present");
29190
+ return;
29191
+ }
29192
+
29193
+ var payload = {};
29194
+ var _sendToValue = this.conversionId;
29177
29195
 
29178
29196
  if (rudderElement.message.properties) {
29179
- properties.value = rudderElement.message.properties.revenue;
29180
- properties.currency = rudderElement.message.properties.currency;
29181
- properties.transaction_id = rudderElement.message.properties.order_id;
29197
+ payload = rudderElement.message.properties;
29182
29198
  }
29183
29199
 
29184
- properties.send_to = sendToValue;
29185
- window.gtag("event", eventName, properties);
29200
+ payload.send_to = _sendToValue;
29201
+ window.gtag("event", event, payload);
29186
29202
  }
29187
29203
  }
29188
29204
  }, {
29189
29205
  key: "page",
29190
29206
  value: function page(rudderElement) {
29191
- logger.debug("in GoogleAdsAnalyticsManager page");
29192
- var conversionData = this.getConversionData(this.pageLoadConversions, rudderElement.message.name);
29193
-
29194
- if (conversionData.conversionLabel) {
29195
- var conversionLabel = conversionData.conversionLabel;
29196
- var eventName = conversionData.eventName;
29197
- window.gtag("event", eventName, {
29198
- send_to: "".concat(this.conversionId, "/").concat(conversionLabel)
29199
- });
29207
+ logger.debug("in GoogleAdsAnalyticsManager page"); // Dynamic re-marketing is disabled
29208
+
29209
+ if (!this.dynamicRemarketing) {
29210
+ var conversionData = this.getConversionData(this.pageLoadConversions, rudderElement.message.name);
29211
+
29212
+ if (conversionData.conversionLabel) {
29213
+ var conversionLabel = conversionData.conversionLabel;
29214
+ var eventName = conversionData.eventName;
29215
+ window.gtag("event", eventName, {
29216
+ send_to: "".concat(this.conversionId, "/").concat(conversionLabel)
29217
+ });
29218
+ }
29219
+ } else {
29220
+ var event = rudderElement.message.name;
29221
+
29222
+ if (!event) {
29223
+ logger.error("Event name not present");
29224
+ return;
29225
+ }
29226
+
29227
+ var payload = {};
29228
+ var sendToValue = this.conversionId;
29229
+
29230
+ if (rudderElement.message.properties) {
29231
+ payload = rudderElement.message.properties;
29232
+ }
29233
+
29234
+ payload.send_to = sendToValue;
29235
+ window.gtag("event", event, payload);
29200
29236
  }
29201
29237
  }
29202
29238
  }, {
@@ -29796,7 +29832,10 @@
29796
29832
  var properties = message.properties ? Object.keys(message.properties) : null;
29797
29833
  properties.forEach(function (property) {
29798
29834
  var value = message.properties[property];
29799
- rawPayload[property] = value;
29835
+
29836
+ if (value && _typeof(value) !== "object" && !Array.isArray(value)) {
29837
+ rawPayload[property] = value;
29838
+ }
29800
29839
  });
29801
29840
 
29802
29841
  if (message.event) {
@@ -30454,6 +30493,102 @@
30454
30493
  return Kissmetrics;
30455
30494
  }();
30456
30495
 
30496
+ /* eslint-disable no-param-reassign */
30497
+
30498
+ var itemsPayload = function itemsPayload(item) {
30499
+ var itemObj = {};
30500
+ itemObj.ProductID = item.product_id;
30501
+ itemObj.SKU = item.sku;
30502
+ itemObj.ProductName = item.name;
30503
+ itemObj.Quantity = item.quantity;
30504
+ itemObj.ItemPrice = item.price;
30505
+ itemObj.RowTotal = item.total;
30506
+ itemObj.ProductURL = item.url;
30507
+ itemObj.ImageURL = item.image_url;
30508
+ itemObj.ProductCategories = item.categories;
30509
+ return itemObj;
30510
+ };
30511
+
30512
+ var ecommEventPayload = function ecommEventPayload(event, message) {
30513
+ var payload = {};
30514
+
30515
+ switch (event) {
30516
+ case "Viewed Product":
30517
+ {
30518
+ payload.ProductName = getValue(message, "properties.name");
30519
+ payload.ProductID = getValue(message, "properties.product_id");
30520
+ payload.SKU = getValue(message, "properties.sku");
30521
+ payload.ImageURL = getValue(message, "properties.image_url");
30522
+ payload.URL = getValue(message, "properties.url");
30523
+ payload.Brand = getValue(message, "properties.brand");
30524
+ payload.Price = getValue(message, "properties.price");
30525
+ payload.CompareAtPrice = getValue(message, "properties.compare_at_price");
30526
+ payload.Categories = getValue(message, "properties.categories");
30527
+ break;
30528
+ }
30529
+
30530
+ case "Added to Cart":
30531
+ {
30532
+ payload.$value = getValue(message, "properties.value");
30533
+ payload.AddedItemProductName = getValue(message, "properties.name");
30534
+ payload.AddedItemProductID = getValue(message, "properties.product_id");
30535
+ payload.AddedItemSKU = getValue(message, "properties.sku");
30536
+ payload.AddedItemImageURL = getValue(message, "properties.image_url");
30537
+ payload.AddedItemURL = getValue(message, "properties.url");
30538
+ payload.AddedItemPrice = getValue(message, "properties.price");
30539
+ payload.AddedItemQuantity = getValue(message, "properties.quantity");
30540
+ payload.AddedItemCategories = getValue(message, "properties.categories");
30541
+ payload.ItemNames = getValue(message, "properties.item_names");
30542
+ payload.CheckoutURL = getValue(message, "properties.checkout_url");
30543
+
30544
+ if (message.properties.items && Array.isArray(message.properties.items)) {
30545
+ var itemArr = [];
30546
+ message.properties.items.forEach(function (element) {
30547
+ var item = itemsPayload(element);
30548
+ item = removeUndefinedAndNullValues(item);
30549
+
30550
+ if (isNotEmpty(item)) {
30551
+ itemArr.push(item);
30552
+ }
30553
+ });
30554
+ payload.Items = itemArr;
30555
+ }
30556
+
30557
+ break;
30558
+ }
30559
+
30560
+ case "Started Checkout":
30561
+ {
30562
+ payload.$event_id = getValue(message, "properties.order_id");
30563
+ payload.$value = getValue(message, "properties.value");
30564
+ payload.Categories = getValue(message, "properties.categories");
30565
+ payload.CheckoutURL = getValue(message, "properties.checkout_url");
30566
+ payload.ItemNames = getValue(message, "item_names");
30567
+
30568
+ if (message.properties.items && Array.isArray(message.properties.items)) {
30569
+ var _itemArr = [];
30570
+ message.properties.items.forEach(function (element) {
30571
+ var item = itemsPayload(element);
30572
+ item = removeUndefinedAndNullValues(item);
30573
+
30574
+ if (isNotEmpty(item)) {
30575
+ _itemArr.push(item);
30576
+ }
30577
+ });
30578
+ payload.Items = _itemArr;
30579
+ }
30580
+
30581
+ break;
30582
+ }
30583
+ }
30584
+
30585
+ if (payload) {
30586
+ payload = removeUndefinedAndNullValues(payload);
30587
+ }
30588
+
30589
+ return payload;
30590
+ };
30591
+
30457
30592
  var Klaviyo = /*#__PURE__*/function () {
30458
30593
  function Klaviyo(config) {
30459
30594
  _classCallCheck(this, Klaviyo);
@@ -30465,6 +30600,14 @@
30465
30600
  this.name = "KLAVIYO";
30466
30601
  this.keysToExtract = ["context.traits"];
30467
30602
  this.exclusionKeys = ["email", "E-mail", "Email", "firstName", "firstname", "first_name", "lastName", "lastname", "last_name", "phone", "Phone", "title", "organization", "city", "City", "region", "country", "Country", "zip", "image", "timezone", "anonymousId", "userId", "properties"];
30603
+ this.ecomExclusionKeys = ["name", "product_id", "sku", "image_url", "url", "brand", "price", "compare_at_price", "quantity", "categories", "products", "product_names", "order_id", "value", "checkout_url", "item_names", "items", "checkout_url"];
30604
+ this.ecomEvents = ["product viewed", "product clicked", "product added", "checkout started"];
30605
+ this.eventNameMapping = {
30606
+ "product viewed": "Viewed Product",
30607
+ "product clicked": "Viewed Product",
30608
+ "product added": "Added to Cart",
30609
+ "checkout started": "Started Checkout"
30610
+ };
30468
30611
  }
30469
30612
 
30470
30613
  _createClass(Klaviyo, [{
@@ -30543,14 +30686,33 @@
30543
30686
  var message = rudderElement.message;
30544
30687
 
30545
30688
  if (message.properties) {
30546
- var propsPayload = message.properties;
30689
+ // ecomm events
30690
+ var event = getValue(message, "event");
30691
+ event = event ? event.trim().toLowerCase() : event;
30692
+
30693
+ if (this.ecomEvents.includes(event)) {
30694
+ var payload = ecommEventPayload(this.eventNameMapping[event], message);
30695
+ var eventName = this.eventNameMapping[event];
30696
+ var customProperties = {};
30697
+ customProperties = extractCustomFields(message, customProperties, ["properties"], this.ecomExclusionKeys);
30698
+
30699
+ if (isNotEmpty(customProperties)) {
30700
+ payload = _objectSpread2(_objectSpread2({}, payload), customProperties);
30701
+ }
30547
30702
 
30548
- if (propsPayload.revenue) {
30549
- propsPayload.$value = propsPayload.revenue;
30550
- delete propsPayload.revenue;
30551
- }
30703
+ if (isNotEmpty(payload)) {
30704
+ window._learnq.push(["track", eventName, payload]);
30705
+ }
30706
+ } else {
30707
+ var propsPayload = message.properties;
30708
+
30709
+ if (propsPayload.revenue) {
30710
+ propsPayload.$value = propsPayload.revenue;
30711
+ delete propsPayload.revenue;
30712
+ }
30552
30713
 
30553
- window._learnq.push(["track", message.event, propsPayload]);
30714
+ window._learnq.push(["track", message.event, propsPayload]);
30715
+ }
30554
30716
  } else window._learnq.push(["track", message.event]);
30555
30717
  }
30556
30718
  }, {
@@ -33217,7 +33379,7 @@
33217
33379
  return payload;
33218
33380
  };
33219
33381
 
33220
- var ecommEventPayload = function ecommEventPayload(event, message) {
33382
+ var ecommEventPayload$1 = function ecommEventPayload(event, message) {
33221
33383
  var payload = {
33222
33384
  price: getValue(message, "properties.price"),
33223
33385
  currency: getValue(message, "properties.currency"),
@@ -33476,31 +33638,31 @@
33476
33638
 
33477
33639
  switch (event.toLowerCase().trim()) {
33478
33640
  case "order completed":
33479
- sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload(event, message));
33641
+ sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload$1(event, message));
33480
33642
  break;
33481
33643
 
33482
33644
  case "checkout started":
33483
- sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload(event, message));
33645
+ sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload$1(event, message));
33484
33646
  break;
33485
33647
 
33486
33648
  case "product added":
33487
- sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload(event, message));
33649
+ sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload$1(event, message));
33488
33650
  break;
33489
33651
 
33490
33652
  case "payment info entered":
33491
- sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload(event, message));
33653
+ sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload$1(event, message));
33492
33654
  break;
33493
33655
 
33494
33656
  case "promotion clicked":
33495
- sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload(event, message));
33657
+ sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload$1(event, message));
33496
33658
  break;
33497
33659
 
33498
33660
  case "promotion viewed":
33499
- sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload(event, message));
33661
+ sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload$1(event, message));
33500
33662
  break;
33501
33663
 
33502
33664
  case "product added to wishlist":
33503
- sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload(event, message));
33665
+ sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload$1(event, message));
33504
33666
  break;
33505
33667
 
33506
33668
  default:
@@ -34079,33 +34241,33 @@
34079
34241
  };
34080
34242
 
34081
34243
  // Application class
34082
- var RudderApp = function RudderApp() {
34244
+ var RudderApp = /*#__PURE__*/_createClass(function RudderApp() {
34083
34245
  _classCallCheck(this, RudderApp);
34084
34246
 
34085
34247
  this.build = "1.0.0";
34086
34248
  this.name = "RudderLabs JavaScript SDK";
34087
34249
  this.namespace = "com.rudderlabs.javascript";
34088
- this.version = "1.2.10";
34089
- };
34250
+ this.version = "1.2.15";
34251
+ });
34090
34252
 
34091
34253
  // Library information class
34092
- var RudderLibraryInfo = function RudderLibraryInfo() {
34254
+ var RudderLibraryInfo = /*#__PURE__*/_createClass(function RudderLibraryInfo() {
34093
34255
  _classCallCheck(this, RudderLibraryInfo);
34094
34256
 
34095
34257
  this.name = "RudderLabs JavaScript SDK";
34096
- this.version = "1.2.10";
34097
- }; // Operating System information class
34258
+ this.version = "1.2.15";
34259
+ }); // Operating System information class
34098
34260
 
34099
34261
 
34100
- var RudderOSInfo = function RudderOSInfo() {
34262
+ var RudderOSInfo = /*#__PURE__*/_createClass(function RudderOSInfo() {
34101
34263
  _classCallCheck(this, RudderOSInfo);
34102
34264
 
34103
34265
  this.name = "";
34104
34266
  this.version = "";
34105
- }; // Screen information class
34267
+ }); // Screen information class
34106
34268
 
34107
34269
 
34108
- var RudderScreenInfo = function RudderScreenInfo() {
34270
+ var RudderScreenInfo = /*#__PURE__*/_createClass(function RudderScreenInfo() {
34109
34271
  _classCallCheck(this, RudderScreenInfo);
34110
34272
 
34111
34273
  this.density = 0;
@@ -34113,9 +34275,9 @@
34113
34275
  this.height = 0;
34114
34276
  this.innerWidth = 0;
34115
34277
  this.innerHeight = 0;
34116
- }; // Device information class
34278
+ }); // Device information class
34117
34279
 
34118
- var RudderContext = function RudderContext() {
34280
+ var RudderContext = /*#__PURE__*/_createClass(function RudderContext() {
34119
34281
  _classCallCheck(this, RudderContext);
34120
34282
 
34121
34283
  this.app = new RudderApp();
@@ -34153,7 +34315,7 @@
34153
34315
  this.screen = screen;
34154
34316
  this.device = null;
34155
34317
  this.network = null;
34156
- };
34318
+ });
34157
34319
 
34158
34320
  var RudderMessage = /*#__PURE__*/function () {
34159
34321
  function RudderMessage() {
@@ -35782,14 +35944,6 @@
35782
35944
 
35783
35945
  var lib$2 = Queue;
35784
35946
 
35785
- // Payload class, contains batch of Elements
35786
- var RudderPayload = function RudderPayload() {
35787
- _classCallCheck(this, RudderPayload);
35788
-
35789
- this.batch = null;
35790
- this.writeKey = null;
35791
- };
35792
-
35793
35947
  var queueOptions = {
35794
35948
  maxRetryDelay: 360000,
35795
35949
  minRetryDelay: 1000,
@@ -35797,34 +35951,21 @@
35797
35951
  maxAttempts: 10,
35798
35952
  maxItems: 100
35799
35953
  };
35800
- var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
35801
35954
 
35802
- /**
35803
- *
35804
- * @class EventRepository responsible for adding events into
35805
- * flush queue and sending data to rudder backend
35806
- * in batch and maintains order of the event.
35807
- */
35808
-
35809
- var EventRepository = /*#__PURE__*/function () {
35810
- /**
35811
- *Creates an instance of EventRepository.
35812
- * @memberof EventRepository
35813
- */
35814
- function EventRepository(options) {
35815
- _classCallCheck(this, EventRepository);
35955
+ var XHRQueue = /*#__PURE__*/function () {
35956
+ function XHRQueue() {
35957
+ _classCallCheck(this, XHRQueue);
35816
35958
 
35817
- this.eventsBuffer = [];
35818
- this.writeKey = "";
35819
35959
  this.url = "";
35820
- this.state = "READY";
35821
- this.batchSize = 0; // previous implementation
35822
- // setInterval(this.preaparePayloadAndFlush, FLUSH_INTERVAL_DEFAULT, this);
35960
+ this.writeKey = "";
35823
35961
  }
35824
35962
 
35825
- _createClass(EventRepository, [{
35826
- key: "startQueue",
35827
- value: function startQueue(options) {
35963
+ _createClass(XHRQueue, [{
35964
+ key: "init",
35965
+ value: function init(writeKey, url, options) {
35966
+ this.url = url;
35967
+ this.writeKey = writeKey;
35968
+
35828
35969
  if (options) {
35829
35970
  // TODO: add checks for value - has to be +ve?
35830
35971
  _extends(queueOptions, options);
@@ -35833,79 +35974,20 @@
35833
35974
  this.payloadQueue = new lib$2("rudder", queueOptions, function (item, done) {
35834
35975
  // apply sentAt at flush time and reset on each retry
35835
35976
  item.message.sentAt = getCurrentTimeFormatted(); // send this item for processing, with a callback to enable queue to get the done status
35977
+ // eslint-disable-next-line no-use-before-define
35836
35978
 
35837
- eventRepository.processQueueElement(item.url, item.headers, item.message, 10 * 1000, function (err, res) {
35979
+ this.processQueueElement(item.url, item.headers, item.message, 10 * 1000, // eslint-disable-next-line consistent-return
35980
+ function (err, res) {
35838
35981
  if (err) {
35839
35982
  return done(err);
35840
35983
  }
35841
35984
 
35842
35985
  done(null, res);
35843
35986
  });
35844
- }); // start queue
35987
+ }.bind(this)); // start queue
35845
35988
 
35846
35989
  this.payloadQueue.start();
35847
35990
  }
35848
- /**
35849
- *
35850
- *
35851
- * @param {EventRepository} repo
35852
- * @returns
35853
- * @memberof EventRepository
35854
- */
35855
-
35856
- }, {
35857
- key: "preaparePayloadAndFlush",
35858
- value: function preaparePayloadAndFlush(repo) {
35859
- // construct payload
35860
- logger.debug("==== in preaparePayloadAndFlush with state: ".concat(repo.state));
35861
- logger.debug(repo.eventsBuffer);
35862
-
35863
- if (repo.eventsBuffer.length == 0 || repo.state === "PROCESSING") {
35864
- return;
35865
- }
35866
-
35867
- var eventsPayload = repo.eventsBuffer;
35868
- var payload = new RudderPayload();
35869
- payload.batch = eventsPayload;
35870
- payload.writeKey = repo.writeKey;
35871
- payload.sentAt = getCurrentTimeFormatted(); // add sentAt to individual events as well
35872
-
35873
- payload.batch.forEach(function (event) {
35874
- event.sentAt = payload.sentAt;
35875
- });
35876
- repo.batchSize = repo.eventsBuffer.length; // server-side integration, XHR is node module
35877
-
35878
- if (true) {
35879
- var xhr = new XMLHttpRequest();
35880
- } else {
35881
- var xhr;
35882
- }
35883
-
35884
- logger.debug("==== in flush sending to Rudder BE ====");
35885
- logger.debug(JSON.stringify(payload, replacer));
35886
- xhr.open("POST", repo.url, true);
35887
- xhr.setRequestHeader("Content-Type", "application/json");
35888
-
35889
- {
35890
- xhr.setRequestHeader("Authorization", "Basic ".concat(btoa("".concat(payload.writeKey, ":"))));
35891
- } // register call back to reset event buffer on successfull POST
35892
-
35893
-
35894
- xhr.onreadystatechange = function () {
35895
- if (xhr.readyState === 4 && xhr.status === 200) {
35896
- logger.debug("====== request processed successfully: ".concat(xhr.status));
35897
- repo.eventsBuffer = repo.eventsBuffer.slice(repo.batchSize);
35898
- logger.debug(repo.eventsBuffer.length);
35899
- } else if (xhr.readyState === 4 && xhr.status !== 200) {
35900
- handleError(new Error("request failed with status: ".concat(xhr.status, " for url: ").concat(repo.url)));
35901
- }
35902
-
35903
- repo.state = "READY";
35904
- };
35905
-
35906
- xhr.send(JSON.stringify(payload, replacer));
35907
- repo.state = "PROCESSING";
35908
- }
35909
35991
  /**
35910
35992
  * the queue item proceesor
35911
35993
  * @param {*} url to send requests to
@@ -35947,6 +36029,216 @@
35947
36029
  queueFn(error);
35948
36030
  }
35949
36031
  }
36032
+ }, {
36033
+ key: "enqueue",
36034
+ value: function enqueue(message, type) {
36035
+ var headers = {
36036
+ "Content-Type": "application/json",
36037
+ Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
36038
+ AnonymousId: btoa(message.anonymousId)
36039
+ }; // add items to the queue
36040
+
36041
+ this.payloadQueue.addItem({
36042
+ url: "".concat(this.url, "/v1/").concat(type),
36043
+ headers: headers,
36044
+ message: message
36045
+ });
36046
+ }
36047
+ }]);
36048
+
36049
+ return XHRQueue;
36050
+ }();
36051
+
36052
+ var defaults$3 = {
36053
+ queue: "queue",
36054
+ maxPayloadSize: 64 * 1000
36055
+ };
36056
+
36057
+ var BeaconQueue = /*#__PURE__*/function () {
36058
+ function BeaconQueue() {
36059
+ _classCallCheck(this, BeaconQueue);
36060
+
36061
+ this.storage = Store;
36062
+ this.maxItems = 10;
36063
+ this.flushQueueTimeOut = undefined;
36064
+ this.timeOutActive = false;
36065
+ this.flushQueueTimeOutInterval = 1000 * 60 * 10; // 10 mins
36066
+
36067
+ this.url = "";
36068
+ this.writekey = "";
36069
+ this.queueName = "".concat(defaults$3.queue, ".").concat(Date.now());
36070
+ }
36071
+
36072
+ _createClass(BeaconQueue, [{
36073
+ key: "sendQueueDataForBeacon",
36074
+ value: function sendQueueDataForBeacon() {
36075
+ this.sendDataFromQueueAndDestroyQueue();
36076
+ }
36077
+ }, {
36078
+ key: "init",
36079
+ value: function init(writekey, url, options) {
36080
+ this.url = url;
36081
+ this.writekey = writekey;
36082
+ if (options.maxItems) this.maxItems = options.maxItems;
36083
+ if (options.flushQueueInterval) this.flushQueueTimeOutInterval = options.flushQueueInterval;
36084
+ var sendQueueData = this.sendQueueDataForBeacon.bind(this);
36085
+ window.addEventListener("unload", sendQueueData);
36086
+ }
36087
+ }, {
36088
+ key: "getQueue",
36089
+ value: function getQueue() {
36090
+ return this.storage.get(this.queueName);
36091
+ }
36092
+ }, {
36093
+ key: "setQueue",
36094
+ value: function setQueue(value) {
36095
+ this.storage.set(this.queueName, value);
36096
+ }
36097
+ /**
36098
+ *
36099
+ * Utility method for excluding null and empty values in JSON
36100
+ * @param {*} _key
36101
+ * @param {*} value
36102
+ * @returns
36103
+ */
36104
+
36105
+ }, {
36106
+ key: "replacer",
36107
+ value: function replacer(_key, value) {
36108
+ if (value === null || value === undefined) {
36109
+ return undefined;
36110
+ }
36111
+
36112
+ return value;
36113
+ }
36114
+ }, {
36115
+ key: "enqueue",
36116
+ value: function enqueue(message) {
36117
+ var queue = this.getQueue() || [];
36118
+ queue = queue.slice(-(this.maxItems - 1));
36119
+ queue.push(message);
36120
+ var batch = queue.slice(0);
36121
+ var data = {
36122
+ batch: batch
36123
+ };
36124
+ var dataToSend = JSON.stringify(data, this.replacer);
36125
+
36126
+ if (dataToSend.length > defaults$3.maxPayloadSize) {
36127
+ batch = queue.slice(0, queue.length - 1);
36128
+ this.flushQueue(batch);
36129
+ queue = this.getQueue();
36130
+ queue.push(message);
36131
+ }
36132
+
36133
+ this.setQueue(queue);
36134
+ this.setTimer();
36135
+
36136
+ if (queue.length === this.maxItems) {
36137
+ this.flushQueue(batch);
36138
+ }
36139
+ }
36140
+ }, {
36141
+ key: "sendDataFromQueueAndDestroyQueue",
36142
+ value: function sendDataFromQueueAndDestroyQueue() {
36143
+ this.sendDataFromQueue();
36144
+ this.storage.remove(this.queueName);
36145
+ }
36146
+ }, {
36147
+ key: "sendDataFromQueue",
36148
+ value: function sendDataFromQueue() {
36149
+ var queue = this.getQueue();
36150
+
36151
+ if (queue && queue.length > 0) {
36152
+ var batch = queue.slice(0, queue.length);
36153
+ this.flushQueue(batch);
36154
+ }
36155
+ }
36156
+ }, {
36157
+ key: "flushQueue",
36158
+ value: function flushQueue(batch) {
36159
+ batch.map(function (event) {
36160
+ event.sentAt = new Date().toISOString();
36161
+ });
36162
+ var data = {
36163
+ batch: batch
36164
+ };
36165
+ var payload = JSON.stringify(data, this.replacer);
36166
+ var blob = new Blob([payload], {
36167
+ type: "application/json"
36168
+ });
36169
+ var isPushed = navigator.sendBeacon("".concat(this.url, "?writeKey=").concat(this.writekey), blob);
36170
+
36171
+ if (!isPushed) {
36172
+ logger.debug("Unable to send data");
36173
+ }
36174
+
36175
+ this.setQueue([]);
36176
+ this.clearTimer();
36177
+ }
36178
+ }, {
36179
+ key: "setTimer",
36180
+ value: function setTimer() {
36181
+ if (!this.timeOutActive) {
36182
+ this.flushQueueTimeOut = setTimeout(this.sendDataFromQueue.bind(this), this.flushQueueTimeOutInterval);
36183
+ this.timeOutActive = true;
36184
+ }
36185
+ }
36186
+ }, {
36187
+ key: "clearTimer",
36188
+ value: function clearTimer() {
36189
+ if (this.timeOutActive) {
36190
+ clearTimeout(this.flushQueueTimeOut);
36191
+ this.timeOutActive = false;
36192
+ }
36193
+ }
36194
+ }]);
36195
+
36196
+ return BeaconQueue;
36197
+ }();
36198
+
36199
+ var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
36200
+
36201
+ /**
36202
+ *
36203
+ * @class EventRepository responsible for adding events into
36204
+ * flush queue and sending data to rudder backend
36205
+ * in batch and maintains order of the event.
36206
+ */
36207
+
36208
+ var EventRepository = /*#__PURE__*/function () {
36209
+ /**
36210
+ *Creates an instance of EventRepository.
36211
+ * @memberof EventRepository
36212
+ */
36213
+ function EventRepository() {
36214
+ _classCallCheck(this, EventRepository);
36215
+
36216
+ this.queue = undefined;
36217
+ }
36218
+
36219
+ _createClass(EventRepository, [{
36220
+ key: "initialize",
36221
+ value: function initialize(writeKey, url, options) {
36222
+ var queueOptions = {};
36223
+ var targetUrl = url.slice(-1) === "/" ? url.slice(0, -1) : url;
36224
+
36225
+ if (options && options.useBeacon) {
36226
+ if (options && options.beaconQueueOptions && options.beaconQueueOptions != null && _typeof(options.beaconQueueOptions) === "object") {
36227
+ queueOptions = options.beaconQueueOptions;
36228
+ }
36229
+
36230
+ targetUrl = "".concat(targetUrl, "/beacon/v1/batch");
36231
+ this.queue = new BeaconQueue();
36232
+ } else {
36233
+ if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) === "object") {
36234
+ queueOptions = options.queueOptions;
36235
+ }
36236
+
36237
+ this.queue = new XHRQueue();
36238
+ }
36239
+
36240
+ this.queue.init(writeKey, targetUrl, queueOptions);
36241
+ }
35950
36242
  /**
35951
36243
  *
35952
36244
  *
@@ -35958,34 +36250,22 @@
35958
36250
  key: "enqueue",
35959
36251
  value: function enqueue(rudderElement, type) {
35960
36252
  var message = rudderElement.getElementContent();
35961
- var headers = {
35962
- "Content-Type": "application/json",
35963
- Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
35964
- AnonymousId: btoa(message.anonymousId)
35965
- };
35966
36253
  message.originalTimestamp = getCurrentTimeFormatted();
35967
36254
  message.sentAt = getCurrentTimeFormatted(); // add this, will get modified when actually being sent
35968
36255
  // check message size, if greater log an error
35969
36256
 
35970
36257
  if (JSON.stringify(message).length > MESSAGE_LENGTH) {
35971
36258
  logger.error("[EventRepository] enqueue:: message length greater 32 Kb ", message);
35972
- } // modify the url for event specific endpoints
35973
-
35974
-
35975
- var url = this.url.slice(-1) == "/" ? this.url.slice(0, -1) : this.url; // add items to the queue
36259
+ }
35976
36260
 
35977
- this.payloadQueue.addItem({
35978
- url: "".concat(url, "/v1/").concat(type),
35979
- headers: headers,
35980
- message: message
35981
- });
36261
+ this.queue.enqueue(message, type);
35982
36262
  }
35983
36263
  }]);
35984
36264
 
35985
36265
  return EventRepository;
35986
36266
  }();
35987
36267
 
35988
- var eventRepository = new EventRepository();
36268
+ var eventRepository = new EventRepository(); // eslint-disable-next-line import/prefer-default-export
35989
36269
 
35990
36270
  function addDomEventHandlers(rudderanalytics) {
35991
36271
  var handler = function handler(e) {
@@ -36612,6 +36892,131 @@
36612
36892
  return Math.floor(Date.now() / 60000);
36613
36893
  }
36614
36894
 
36895
+ /* eslint-disable class-methods-use-this */
36896
+
36897
+ var OneTrust = /*#__PURE__*/function () {
36898
+ function OneTrust(sourceConfig) {
36899
+ var _this = this;
36900
+
36901
+ _classCallCheck(this, OneTrust);
36902
+
36903
+ this.sourceConfig = sourceConfig; // If user does not load onetrust sdk before loading rudderstack sdk
36904
+ // we will not be filtering any of the destinations.
36905
+
36906
+ if (!window.OneTrust || !window.OnetrustActiveGroups) {
36907
+ logger.debug("Onetrust window objects not retrieved. Thus events are sent.");
36908
+ return true;
36909
+ } // OneTrust Cookie Compliance populates a data layer object OnetrustActiveGroups with
36910
+ // the cookie categories that the user has consented to.
36911
+ // Eg: ',C0001,C0003,'
36912
+ // We split it and save it as an array.
36913
+
36914
+
36915
+ var userSetConsentGroupIds = window.OnetrustActiveGroups.split(","); // Ids user has consented
36916
+ // Get information about the cookie script - data includes, consent models, cookies in preference centre, etc.
36917
+ // We get the groups(cookie categorization), user has created in one trust account.
36918
+
36919
+ var oneTrustAllGroupsInfo = window.OneTrust.GetDomainData().Groups;
36920
+ this.userSetConsentGroupNames = []; // Get the names of the cookies consented by the user in the browser.
36921
+
36922
+ oneTrustAllGroupsInfo.forEach(function (group) {
36923
+ var CustomGroupId = group.CustomGroupId,
36924
+ GroupName = group.GroupName;
36925
+
36926
+ if (userSetConsentGroupIds.includes(CustomGroupId)) {
36927
+ _this.userSetConsentGroupNames.push(GroupName.toUpperCase().trim());
36928
+ }
36929
+ });
36930
+ }
36931
+
36932
+ _createClass(OneTrust, [{
36933
+ key: "isEnabled",
36934
+ value: function isEnabled(destConfig) {
36935
+ var _this2 = this;
36936
+
36937
+ try {
36938
+ /**
36939
+ * Structure of onetrust consent group destination config.
36940
+ *
36941
+ * "oneTrustConsentGroup": [
36942
+ {
36943
+ "oneTrustConsentGroup": "Performance Cookies"
36944
+ },
36945
+ {
36946
+ "oneTrustConsentGroup": "Functional Cookies"
36947
+ },
36948
+ {
36949
+ "oneTrustConsentGroup": ""
36950
+ }
36951
+ ]
36952
+ *
36953
+ */
36954
+ var oneTrustCookieCategories = destConfig.oneTrustCookieCategories; // mapping of the destination with the consent group name
36955
+ // If the destination do not have this mapping events will be sent.
36956
+
36957
+ if (!oneTrustCookieCategories) {
36958
+ return true;
36959
+ } // Change the structure of oneTrustConsentGroup as an array and filter values if empty string
36960
+ // Eg:
36961
+ // ["Performance Cookies", "Functional Cookies"]
36962
+
36963
+
36964
+ var oneTrustConsentGroupArr = oneTrustCookieCategories.map(function (c) {
36965
+ return c.oneTrustCookieCategory;
36966
+ }).filter(function (n) {
36967
+ return n;
36968
+ });
36969
+ var containsAllConsent = true; // Check if all the destination's mapped cookie categories are consented by the user in the browser.
36970
+
36971
+ containsAllConsent = oneTrustConsentGroupArr.every(function (element) {
36972
+ return _this2.userSetConsentGroupNames.includes(element.toUpperCase().trim());
36973
+ });
36974
+ return containsAllConsent;
36975
+ } catch (e) {
36976
+ logger.error("Error during onetrust cookie consent management ".concat(e));
36977
+ return true;
36978
+ }
36979
+ }
36980
+ }]);
36981
+
36982
+ return OneTrust;
36983
+ }();
36984
+
36985
+ var CookieConsentFactory = /*#__PURE__*/function () {
36986
+ function CookieConsentFactory() {
36987
+ _classCallCheck(this, CookieConsentFactory);
36988
+ }
36989
+
36990
+ _createClass(CookieConsentFactory, null, [{
36991
+ key: "initialize",
36992
+ value: function initialize(sourceConfig, cookieConsentOptions) {
36993
+ var _cookieConsentOptions;
36994
+
36995
+ /**
36996
+ *
36997
+ * check which type of cookie consent manager needs to be called if enabled
36998
+ * for now we have only OneTrust.
36999
+ * But if new cookie consent manager options are implemented,
37000
+ * we need to make sure only one of them is enabled by the user in the
37001
+ * load options
37002
+ *
37003
+ */
37004
+ if (cookieConsentOptions !== null && cookieConsentOptions !== void 0 && (_cookieConsentOptions = cookieConsentOptions.oneTrust) !== null && _cookieConsentOptions !== void 0 && _cookieConsentOptions.enabled) {
37005
+ // This is P1. When we have an ui in source side to turn on/off of cookie consent
37006
+ // if (sourceConfig &&
37007
+ // sourceConfig.cookieConsentManager &&
37008
+ // sourceConfig.cookieConsentManager.oneTrust &&
37009
+ // sourceConfig.cookieConsentManager.oneTrustenabled) {
37010
+ return new OneTrust(); // }
37011
+ }
37012
+
37013
+ return null;
37014
+ }
37015
+ }]);
37016
+
37017
+ return CookieConsentFactory;
37018
+ }();
37019
+
36615
37020
  var queryDefaults = {
36616
37021
  trait: "ajs_trait_",
36617
37022
  prop: "ajs_prop_"
@@ -36671,6 +37076,7 @@
36671
37076
  };
36672
37077
  this.loaded = false;
36673
37078
  this.loadIntegration = true;
37079
+ this.cookieConsentOptions = {};
36674
37080
  }
36675
37081
  /**
36676
37082
  * initialize the user after load config
@@ -36742,10 +37148,20 @@
36742
37148
  }, this);
36743
37149
  logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
36744
37150
 
36745
- this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations); // remove from the list which don't have support yet in SDK
37151
+ this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
37152
+ var cookieConsent = undefined; // Check if cookie consent manager is being set through load options
37153
+
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);
37158
+ } // If cookie consent object is return we filter according to consents given by user
37159
+ // else we do not consider any filtering for cookie consent.
37160
+
36746
37161
 
36747
37162
  this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
36748
- return integrations[intg.name] != undefined;
37163
+ return integrations[intg.name] != undefined && (!cookieConsent || // check if cookieconsent object is present and then do filtering
37164
+ cookieConsent && cookieConsent.isEnabled(intg.config));
36749
37165
  });
36750
37166
  this.init(this.clientIntegrations);
36751
37167
  } catch (error) {
@@ -37409,6 +37825,7 @@
37409
37825
  var _this3 = this;
37410
37826
 
37411
37827
  logger.debug("inside load ");
37828
+ if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
37412
37829
  if (this.loaded) return;
37413
37830
  var configUrl = CONFIG_URL;
37414
37831
 
@@ -37419,16 +37836,26 @@
37419
37836
  throw Error("failed to initialize");
37420
37837
  }
37421
37838
 
37839
+ var storageOptions = {};
37840
+
37422
37841
  if (options && options.logLevel) {
37423
37842
  logger.setLogLevel(options.logLevel);
37424
37843
  }
37425
37844
 
37426
37845
  if (options && options.setCookieDomain) {
37427
- this.storage.options({
37846
+ storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
37428
37847
  domain: options.setCookieDomain
37429
37848
  });
37430
37849
  }
37431
37850
 
37851
+ if (options && options.secureCookie) {
37852
+ storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
37853
+ secure: options.secureCookie
37854
+ });
37855
+ }
37856
+
37857
+ this.storage.options(storageOptions);
37858
+
37432
37859
  if (options && options.integrations) {
37433
37860
  _extends(this.loadOnlyIntegrations, options.integrations);
37434
37861
 
@@ -37465,22 +37892,11 @@
37465
37892
  this.registerCallbacks(true);
37466
37893
  }
37467
37894
 
37468
- if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) == "object") {
37469
- this.eventRepository.startQueue(options.queueOptions);
37470
- } else {
37471
- this.eventRepository.startQueue({});
37472
- }
37473
-
37474
37895
  if (options && options.loadIntegration != undefined) {
37475
37896
  this.loadIntegration = !!options.loadIntegration;
37476
37897
  }
37477
37898
 
37478
- this.eventRepository.writeKey = writeKey;
37479
-
37480
- if (serverUrl) {
37481
- this.eventRepository.url = serverUrl;
37482
- }
37483
-
37899
+ this.eventRepository.initialize(writeKey, serverUrl, options);
37484
37900
  this.initializeUser();
37485
37901
  this.setInitialPageProperties();
37486
37902
  this.loaded = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "1.2.10",
3
+ "version": "1.2.15",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",