rudder-sdk-js 1.2.9 → 1.2.14

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 +353 -99
  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
 
@@ -5469,6 +5454,11 @@
5469
5454
  quantumMetric: "QUANTUMMETRIC",
5470
5455
  quantummetric: "QUANTUMMETRIC",
5471
5456
  Quantum_Metric: "QUANTUMMETRIC",
5457
+ "Google Optimize": "GOOGLE_OPTIMIZE",
5458
+ GOOGLE_OPTIMIZE: "GOOGLE_OPTIMIZE",
5459
+ GoogleOptimize: "GOOGLE_OPTIMIZE",
5460
+ Googleoptimize: "GOOGLE_OPTIMIZE",
5461
+ GOOGLEOPTIMIZE: "GOOGLE_OPTIMIZE",
5472
5462
  PostAffiliatePro: "POST_AFFILIATE_PRO",
5473
5463
  Post_affiliate_pro: "POST_AFFILIATE_PRO",
5474
5464
  "Post Affiliate Pro": "POST_AFFILIATE_PRO",
@@ -5520,6 +5510,7 @@
5520
5510
  MP: "Mixpanel",
5521
5511
  QUALTRICS: "Qualtrics",
5522
5512
  SENTRY: "Sentry",
5513
+ GOOGLE_OPTIMIZE: "GoogleOptimize",
5523
5514
  POST_AFFILIATE_PRO: "PostAffiliatePro"
5524
5515
  };
5525
5516
 
@@ -5564,7 +5555,7 @@
5564
5555
  PRODUCT_REVIEWED: "Product Reviewed"
5565
5556
  }; // Enumeration for integrations supported
5566
5557
 
5567
- var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.9";
5558
+ var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.14";
5568
5559
  var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
5569
5560
  var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
5570
5561
  /* module.exports = {
@@ -22867,12 +22858,14 @@
22867
22858
  };
22868
22859
 
22869
22860
  /* eslint-disable no-use-before-define */
22861
+ var defaultAsyncState = true;
22870
22862
 
22871
22863
  var ScriptLoader = function ScriptLoader(id, src) {
22864
+ var async = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultAsyncState;
22872
22865
  logger.debug("in script loader=== ".concat(id));
22873
22866
  var js = document.createElement("script");
22874
22867
  js.src = src;
22875
- js.async = true;
22868
+ js.async = async === undefined ? defaultAsyncState : async;
22876
22869
  js.type = "text/javascript";
22877
22870
  js.id = id;
22878
22871
  var e = document.getElementsByTagName("script")[0];
@@ -23716,7 +23709,7 @@
23716
23709
  return Appcues;
23717
23710
  }();
23718
23711
 
23719
- var BingAds = function BingAds(config) {
23712
+ var BingAds = /*#__PURE__*/_createClass(function BingAds(config) {
23720
23713
  var _this = this;
23721
23714
 
23722
23715
  _classCallCheck(this, BingAds);
@@ -23796,7 +23789,7 @@
23796
23789
 
23797
23790
  this.tagID = config.tagID;
23798
23791
  this.name = "BINGADS";
23799
- };
23792
+ });
23800
23793
 
23801
23794
  /*
23802
23795
  E-commerce support required for logPurchase support & other e-commerce events as track with productId changed
@@ -26974,8 +26967,13 @@
26974
26967
  }
26975
26968
  }, {
26976
26969
  key: "page",
26977
- value: function page() {
26978
- window.fbq("track", "PageView");
26970
+ value: function page(rudderElement) {
26971
+ var _rudderElement$messag = rudderElement.message,
26972
+ properties = _rudderElement$messag.properties,
26973
+ messageId = _rudderElement$messag.messageId;
26974
+ window.fbq("track", "PageView", properties, {
26975
+ eventID: messageId
26976
+ });
26979
26977
  }
26980
26978
  }, {
26981
26979
  key: "identify",
@@ -26991,10 +26989,10 @@
26991
26989
  var _this = this;
26992
26990
 
26993
26991
  var self = this;
26994
- var _rudderElement$messag = rudderElement.message,
26995
- event = _rudderElement$messag.event,
26996
- properties = _rudderElement$messag.properties,
26997
- messageId = _rudderElement$messag.messageId;
26992
+ var _rudderElement$messag2 = rudderElement.message,
26993
+ event = _rudderElement$messag2.event,
26994
+ properties = _rudderElement$messag2.properties,
26995
+ messageId = _rudderElement$messag2.messageId;
26998
26996
  var revValue;
26999
26997
  var currVal;
27000
26998
 
@@ -27305,25 +27303,25 @@
27305
27303
  }
27306
27304
  /**
27307
27305
  * Get the Facebook Content Type
27308
- *
27306
+ *
27309
27307
  * Can be `product`, `destination`, `flight` or `hotel`.
27310
- *
27308
+ *
27311
27309
  * This can be overridden within the message
27312
27310
  * `options.integrations.FACEBOOK_PIXEL.contentType`, or alternatively you can
27313
27311
  * set the "Map Categories to Facebook Content Types" setting within
27314
27312
  * RudderStack config and then set the corresponding commerce category in
27315
27313
  * `track()` properties.
27316
- *
27314
+ *
27317
27315
  * https://www.facebook.com/business/help/606577526529702?id=1205376682832142
27318
27316
  */
27319
27317
 
27320
27318
  }, {
27321
27319
  key: "getContentType",
27322
27320
  value: function getContentType(rudderElement, defaultValue) {
27323
- var _rudderElement$messag2, _rudderElement$messag3;
27321
+ var _rudderElement$messag3, _rudderElement$messag4;
27324
27322
 
27325
27323
  // Get the message-specific override if it exists in the options parameter of `track()`
27326
- 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;
27324
+ 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;
27327
27325
  if (contentTypeMessageOverride) return [contentTypeMessageOverride]; // Otherwise check if there is a replacement set for all Facebook Pixel
27328
27326
  // track calls of this category
27329
27327
 
@@ -29107,6 +29105,7 @@
29107
29105
  this.pageLoadConversions = config.pageLoadConversions;
29108
29106
  this.clickEventConversions = config.clickEventConversions;
29109
29107
  this.defaultPageConversion = config.defaultPageConversion;
29108
+ this.dynamicRemarketing = config.dynamicRemarketing;
29110
29109
  this.sendPageView = config.sendPageView || true;
29111
29110
  this.conversionLinker = config.conversionLinker || true;
29112
29111
  this.disableAdPersonalization = config.disableAdPersonalization || false;
@@ -29151,44 +29150,85 @@
29151
29150
  }
29152
29151
  }, {
29153
29152
  key: "identify",
29154
- value: function identify(rudderElement) {
29153
+ value: function identify() {
29155
29154
  logger.debug("[GoogleAds] identify:: method not supported");
29156
29155
  } // https://developers.google.com/gtagjs/reference/event
29157
29156
 
29158
29157
  }, {
29159
29158
  key: "track",
29160
29159
  value: function track(rudderElement) {
29161
- logger.debug("in GoogleAdsAnalyticsManager track");
29162
- var conversionData = this.getConversionData(this.clickEventConversions, rudderElement.message.event);
29160
+ logger.debug("in GoogleAdsAnalyticsManager track"); // Dynamic remarketing disabled
29163
29161
 
29164
- if (conversionData.conversionLabel) {
29165
- var conversionLabel = conversionData.conversionLabel;
29166
- var eventName = conversionData.eventName;
29167
- var sendToValue = "".concat(this.conversionId, "/").concat(conversionLabel);
29168
- var properties = {};
29162
+ if (!this.dynamicRemarketing) {
29163
+ var conversionData = this.getConversionData(this.clickEventConversions, rudderElement.message.event);
29164
+
29165
+ if (conversionData.conversionLabel) {
29166
+ var conversionLabel = conversionData.conversionLabel;
29167
+ var eventName = conversionData.eventName;
29168
+ var sendToValue = "".concat(this.conversionId, "/").concat(conversionLabel);
29169
+ var properties = {};
29170
+
29171
+ if (rudderElement.message.properties) {
29172
+ properties.value = rudderElement.message.properties.revenue;
29173
+ properties.currency = rudderElement.message.properties.currency;
29174
+ properties.transaction_id = rudderElement.message.properties.order_id;
29175
+ }
29176
+
29177
+ properties.send_to = sendToValue;
29178
+ properties = removeUndefinedAndNullValues(properties);
29179
+ window.gtag("event", eventName, properties);
29180
+ }
29181
+ } else {
29182
+ var event = rudderElement.message.event;
29183
+
29184
+ if (!event) {
29185
+ logger.error("Event name not present");
29186
+ return;
29187
+ }
29188
+
29189
+ var payload = {};
29190
+ var _sendToValue = this.conversionId;
29169
29191
 
29170
29192
  if (rudderElement.message.properties) {
29171
- properties.value = rudderElement.message.properties.revenue;
29172
- properties.currency = rudderElement.message.properties.currency;
29173
- properties.transaction_id = rudderElement.message.properties.order_id;
29193
+ payload = rudderElement.message.properties;
29174
29194
  }
29175
29195
 
29176
- properties.send_to = sendToValue;
29177
- window.gtag("event", eventName, properties);
29196
+ payload.send_to = _sendToValue;
29197
+ window.gtag("event", event, payload);
29178
29198
  }
29179
29199
  }
29180
29200
  }, {
29181
29201
  key: "page",
29182
29202
  value: function page(rudderElement) {
29183
- logger.debug("in GoogleAdsAnalyticsManager page");
29184
- var conversionData = this.getConversionData(this.pageLoadConversions, rudderElement.message.name);
29185
-
29186
- if (conversionData.conversionLabel) {
29187
- var conversionLabel = conversionData.conversionLabel;
29188
- var eventName = conversionData.eventName;
29189
- window.gtag("event", eventName, {
29190
- send_to: "".concat(this.conversionId, "/").concat(conversionLabel)
29191
- });
29203
+ logger.debug("in GoogleAdsAnalyticsManager page"); // Dynamic re-marketing is disabled
29204
+
29205
+ if (!this.dynamicRemarketing) {
29206
+ var conversionData = this.getConversionData(this.pageLoadConversions, rudderElement.message.name);
29207
+
29208
+ if (conversionData.conversionLabel) {
29209
+ var conversionLabel = conversionData.conversionLabel;
29210
+ var eventName = conversionData.eventName;
29211
+ window.gtag("event", eventName, {
29212
+ send_to: "".concat(this.conversionId, "/").concat(conversionLabel)
29213
+ });
29214
+ }
29215
+ } else {
29216
+ var event = rudderElement.message.name;
29217
+
29218
+ if (!event) {
29219
+ logger.error("Event name not present");
29220
+ return;
29221
+ }
29222
+
29223
+ var payload = {};
29224
+ var sendToValue = this.conversionId;
29225
+
29226
+ if (rudderElement.message.properties) {
29227
+ payload = rudderElement.message.properties;
29228
+ }
29229
+
29230
+ payload.send_to = sendToValue;
29231
+ window.gtag("event", event, payload);
29192
29232
  }
29193
29233
  }
29194
29234
  }, {
@@ -29788,7 +29828,10 @@
29788
29828
  var properties = message.properties ? Object.keys(message.properties) : null;
29789
29829
  properties.forEach(function (property) {
29790
29830
  var value = message.properties[property];
29791
- rawPayload[property] = value;
29831
+
29832
+ if (value && _typeof(value) !== "object" && !Array.isArray(value)) {
29833
+ rawPayload[property] = value;
29834
+ }
29792
29835
  });
29793
29836
 
29794
29837
  if (message.event) {
@@ -30446,6 +30489,102 @@
30446
30489
  return Kissmetrics;
30447
30490
  }();
30448
30491
 
30492
+ /* eslint-disable no-param-reassign */
30493
+
30494
+ var itemsPayload = function itemsPayload(item) {
30495
+ var itemObj = {};
30496
+ itemObj.ProductID = item.product_id;
30497
+ itemObj.SKU = item.sku;
30498
+ itemObj.ProductName = item.name;
30499
+ itemObj.Quantity = item.quantity;
30500
+ itemObj.ItemPrice = item.price;
30501
+ itemObj.RowTotal = item.total;
30502
+ itemObj.ProductURL = item.url;
30503
+ itemObj.ImageURL = item.image_url;
30504
+ itemObj.ProductCategories = item.categories;
30505
+ return itemObj;
30506
+ };
30507
+
30508
+ var ecommEventPayload = function ecommEventPayload(event, message) {
30509
+ var payload = {};
30510
+
30511
+ switch (event) {
30512
+ case "Viewed Product":
30513
+ {
30514
+ payload.ProductName = getValue(message, "properties.name");
30515
+ payload.ProductID = getValue(message, "properties.product_id");
30516
+ payload.SKU = getValue(message, "properties.sku");
30517
+ payload.ImageURL = getValue(message, "properties.image_url");
30518
+ payload.URL = getValue(message, "properties.url");
30519
+ payload.Brand = getValue(message, "properties.brand");
30520
+ payload.Price = getValue(message, "properties.price");
30521
+ payload.CompareAtPrice = getValue(message, "properties.compare_at_price");
30522
+ payload.Categories = getValue(message, "properties.categories");
30523
+ break;
30524
+ }
30525
+
30526
+ case "Added to Cart":
30527
+ {
30528
+ payload.$value = getValue(message, "properties.value");
30529
+ payload.AddedItemProductName = getValue(message, "properties.name");
30530
+ payload.AddedItemProductID = getValue(message, "properties.product_id");
30531
+ payload.AddedItemSKU = getValue(message, "properties.sku");
30532
+ payload.AddedItemImageURL = getValue(message, "properties.image_url");
30533
+ payload.AddedItemURL = getValue(message, "properties.url");
30534
+ payload.AddedItemPrice = getValue(message, "properties.price");
30535
+ payload.AddedItemQuantity = getValue(message, "properties.quantity");
30536
+ payload.AddedItemCategories = getValue(message, "properties.categories");
30537
+ payload.ItemNames = getValue(message, "properties.item_names");
30538
+ payload.CheckoutURL = getValue(message, "properties.checkout_url");
30539
+
30540
+ if (message.properties.items && Array.isArray(message.properties.items)) {
30541
+ var itemArr = [];
30542
+ message.properties.items.forEach(function (element) {
30543
+ var item = itemsPayload(element);
30544
+ item = removeUndefinedAndNullValues(item);
30545
+
30546
+ if (isNotEmpty(item)) {
30547
+ itemArr.push(item);
30548
+ }
30549
+ });
30550
+ payload.Items = itemArr;
30551
+ }
30552
+
30553
+ break;
30554
+ }
30555
+
30556
+ case "Started Checkout":
30557
+ {
30558
+ payload.$event_id = getValue(message, "properties.order_id");
30559
+ payload.$value = getValue(message, "properties.value");
30560
+ payload.Categories = getValue(message, "properties.categories");
30561
+ payload.CheckoutURL = getValue(message, "properties.checkout_url");
30562
+ payload.ItemNames = getValue(message, "item_names");
30563
+
30564
+ if (message.properties.items && Array.isArray(message.properties.items)) {
30565
+ var _itemArr = [];
30566
+ message.properties.items.forEach(function (element) {
30567
+ var item = itemsPayload(element);
30568
+ item = removeUndefinedAndNullValues(item);
30569
+
30570
+ if (isNotEmpty(item)) {
30571
+ _itemArr.push(item);
30572
+ }
30573
+ });
30574
+ payload.Items = _itemArr;
30575
+ }
30576
+
30577
+ break;
30578
+ }
30579
+ }
30580
+
30581
+ if (payload) {
30582
+ payload = removeUndefinedAndNullValues(payload);
30583
+ }
30584
+
30585
+ return payload;
30586
+ };
30587
+
30449
30588
  var Klaviyo = /*#__PURE__*/function () {
30450
30589
  function Klaviyo(config) {
30451
30590
  _classCallCheck(this, Klaviyo);
@@ -30457,6 +30596,14 @@
30457
30596
  this.name = "KLAVIYO";
30458
30597
  this.keysToExtract = ["context.traits"];
30459
30598
  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"];
30599
+ 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"];
30600
+ this.ecomEvents = ["product viewed", "product clicked", "product added", "checkout started"];
30601
+ this.eventNameMapping = {
30602
+ "product viewed": "Viewed Product",
30603
+ "product clicked": "Viewed Product",
30604
+ "product added": "Added to Cart",
30605
+ "checkout started": "Started Checkout"
30606
+ };
30460
30607
  }
30461
30608
 
30462
30609
  _createClass(Klaviyo, [{
@@ -30535,14 +30682,33 @@
30535
30682
  var message = rudderElement.message;
30536
30683
 
30537
30684
  if (message.properties) {
30538
- var propsPayload = message.properties;
30685
+ // ecomm events
30686
+ var event = getValue(message, "event");
30687
+ event = event ? event.trim().toLowerCase() : event;
30688
+
30689
+ if (this.ecomEvents.includes(event)) {
30690
+ var payload = ecommEventPayload(this.eventNameMapping[event], message);
30691
+ var eventName = this.eventNameMapping[event];
30692
+ var customProperties = {};
30693
+ customProperties = extractCustomFields(message, customProperties, ["properties"], this.ecomExclusionKeys);
30694
+
30695
+ if (isNotEmpty(customProperties)) {
30696
+ payload = _objectSpread2(_objectSpread2({}, payload), customProperties);
30697
+ }
30539
30698
 
30540
- if (propsPayload.revenue) {
30541
- propsPayload.$value = propsPayload.revenue;
30542
- delete propsPayload.revenue;
30543
- }
30699
+ if (isNotEmpty(payload)) {
30700
+ window._learnq.push(["track", eventName, payload]);
30701
+ }
30702
+ } else {
30703
+ var propsPayload = message.properties;
30704
+
30705
+ if (propsPayload.revenue) {
30706
+ propsPayload.$value = propsPayload.revenue;
30707
+ delete propsPayload.revenue;
30708
+ }
30544
30709
 
30545
- window._learnq.push(["track", message.event, propsPayload]);
30710
+ window._learnq.push(["track", message.event, propsPayload]);
30711
+ }
30546
30712
  } else window._learnq.push(["track", message.event]);
30547
30713
  }
30548
30714
  }, {
@@ -33209,7 +33375,7 @@
33209
33375
  return payload;
33210
33376
  };
33211
33377
 
33212
- var ecommEventPayload = function ecommEventPayload(event, message) {
33378
+ var ecommEventPayload$1 = function ecommEventPayload(event, message) {
33213
33379
  var payload = {
33214
33380
  price: getValue(message, "properties.price"),
33215
33381
  currency: getValue(message, "properties.currency"),
@@ -33468,31 +33634,31 @@
33468
33634
 
33469
33635
  switch (event.toLowerCase().trim()) {
33470
33636
  case "order completed":
33471
- sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload(event, message));
33637
+ sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload$1(event, message));
33472
33638
  break;
33473
33639
 
33474
33640
  case "checkout started":
33475
- sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload(event, message));
33641
+ sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload$1(event, message));
33476
33642
  break;
33477
33643
 
33478
33644
  case "product added":
33479
- sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload(event, message));
33645
+ sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload$1(event, message));
33480
33646
  break;
33481
33647
 
33482
33648
  case "payment info entered":
33483
- sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload(event, message));
33649
+ sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload$1(event, message));
33484
33650
  break;
33485
33651
 
33486
33652
  case "promotion clicked":
33487
- sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload(event, message));
33653
+ sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload$1(event, message));
33488
33654
  break;
33489
33655
 
33490
33656
  case "promotion viewed":
33491
- sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload(event, message));
33657
+ sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload$1(event, message));
33492
33658
  break;
33493
33659
 
33494
33660
  case "product added to wishlist":
33495
- sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload(event, message));
33661
+ sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload$1(event, message));
33496
33662
  break;
33497
33663
 
33498
33664
  default:
@@ -33532,6 +33698,10 @@
33532
33698
  };
33533
33699
 
33534
33700
  this.page = function () {
33701
+ window._tvq.push([function () {
33702
+ this.deleteCustomVariable(5, "page");
33703
+ }]);
33704
+
33535
33705
  window._tvq.push(["trackPageView"]);
33536
33706
  };
33537
33707
 
@@ -33627,6 +33797,10 @@
33627
33797
  }]);
33628
33798
 
33629
33799
  window._tvq.push(["trackPageView"]);
33800
+ } else {
33801
+ window._tvq.push([function () {
33802
+ this.deleteCustomVariable(5, "page");
33803
+ }]);
33630
33804
  }
33631
33805
  }
33632
33806
  }]);
@@ -33794,6 +33968,75 @@
33794
33968
  return VWO;
33795
33969
  }();
33796
33970
 
33971
+ var GoogleOptimize = /*#__PURE__*/function () {
33972
+ function GoogleOptimize(config) {
33973
+ _classCallCheck(this, GoogleOptimize);
33974
+
33975
+ this.name = "GOOGLE_OPTIMIZE";
33976
+ this.ga = config.ga;
33977
+ this.trackingId = config.trackingId;
33978
+ this.containerId = config.containerId;
33979
+ this.async = config.async;
33980
+ this.aflicker = config.aflicker;
33981
+ }
33982
+
33983
+ _createClass(GoogleOptimize, [{
33984
+ key: "init",
33985
+ value: function init() {
33986
+ logger.debug("===in init Google Optimize===");
33987
+
33988
+ if (!this.containerId) {
33989
+ return;
33990
+ } // load optimize script first
33991
+
33992
+
33993
+ ScriptLoader("Google Optimize", "https://www.googleoptimize.com/optimize.js?id=".concat(this.containerId), this.async);
33994
+
33995
+ if (this.ga) {
33996
+ var gtag = function gtag() {
33997
+ dataLayer.push(arguments);
33998
+ };
33999
+
34000
+ if (!this.trackingId) {
34001
+ return;
34002
+ }
34003
+
34004
+ ScriptLoader("Google Tag Manager", "https://www.googletagmanager.com/gtag/js?id=".concat(this.trackingId));
34005
+ window.dataLayer = window.dataLayer || [];
34006
+ gtag("js", new Date());
34007
+ gtag("config", "".concat(this.trackingId));
34008
+ } // anti flicker snippet contains insertBefore since it needs to be executed before any other script
34009
+ // link -> https://support.google.com/optimize/answer/7100284?hl=en&ref_topic=6197443
34010
+
34011
+
34012
+ if (this.aflicker) {
34013
+ var flick = document.createElement("style");
34014
+ flick.innerHTML = ".async-hide { opacity: 0 !important}";
34015
+ var js = document.createElement("script");
34016
+ js.innerHTML = "(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;})(window,document.documentElement,'async-hide','dataLayer',4000,{'".concat(this.containerId, "':true});");
34017
+ var e = document.getElementsByTagName("script")[0];
34018
+ e.parentNode.insertBefore(flick, e); // style tag in anti flicker snippet should be before the a-flicker script as per docs
34019
+
34020
+ e.parentNode.insertBefore(js, e);
34021
+ }
34022
+ }
34023
+ }, {
34024
+ key: "isLoaded",
34025
+ value: function isLoaded() {
34026
+ logger.debug("=== in isLoaded Google Optimize===");
34027
+ return !!window.dataLayer;
34028
+ }
34029
+ }, {
34030
+ key: "isReady",
34031
+ value: function isReady() {
34032
+ logger.debug("=== in isReady Google Optimize===");
34033
+ return !!window.dataLayer;
34034
+ }
34035
+ }]);
34036
+
34037
+ return GoogleOptimize;
34038
+ }();
34039
+
33797
34040
  // This function helps to populate the sale object
33798
34041
  var updateSaleObject = function updateSaleObject(sale, properties) {
33799
34042
  if (properties.total) sale.setTotalCost(properties.total);
@@ -33989,37 +34232,38 @@
33989
34232
  SNAP_PIXEL: SnapPixel,
33990
34233
  TVSQUARED: TVSquared,
33991
34234
  VWO: VWO,
34235
+ GOOGLE_OPTIMIZE: GoogleOptimize,
33992
34236
  POST_AFFILIATE_PRO: PostAffiliatePro
33993
34237
  };
33994
34238
 
33995
34239
  // Application class
33996
- var RudderApp = function RudderApp() {
34240
+ var RudderApp = /*#__PURE__*/_createClass(function RudderApp() {
33997
34241
  _classCallCheck(this, RudderApp);
33998
34242
 
33999
34243
  this.build = "1.0.0";
34000
34244
  this.name = "RudderLabs JavaScript SDK";
34001
34245
  this.namespace = "com.rudderlabs.javascript";
34002
- this.version = "1.2.9";
34003
- };
34246
+ this.version = "1.2.14";
34247
+ });
34004
34248
 
34005
34249
  // Library information class
34006
- var RudderLibraryInfo = function RudderLibraryInfo() {
34250
+ var RudderLibraryInfo = /*#__PURE__*/_createClass(function RudderLibraryInfo() {
34007
34251
  _classCallCheck(this, RudderLibraryInfo);
34008
34252
 
34009
34253
  this.name = "RudderLabs JavaScript SDK";
34010
- this.version = "1.2.9";
34011
- }; // Operating System information class
34254
+ this.version = "1.2.14";
34255
+ }); // Operating System information class
34012
34256
 
34013
34257
 
34014
- var RudderOSInfo = function RudderOSInfo() {
34258
+ var RudderOSInfo = /*#__PURE__*/_createClass(function RudderOSInfo() {
34015
34259
  _classCallCheck(this, RudderOSInfo);
34016
34260
 
34017
34261
  this.name = "";
34018
34262
  this.version = "";
34019
- }; // Screen information class
34263
+ }); // Screen information class
34020
34264
 
34021
34265
 
34022
- var RudderScreenInfo = function RudderScreenInfo() {
34266
+ var RudderScreenInfo = /*#__PURE__*/_createClass(function RudderScreenInfo() {
34023
34267
  _classCallCheck(this, RudderScreenInfo);
34024
34268
 
34025
34269
  this.density = 0;
@@ -34027,9 +34271,9 @@
34027
34271
  this.height = 0;
34028
34272
  this.innerWidth = 0;
34029
34273
  this.innerHeight = 0;
34030
- }; // Device information class
34274
+ }); // Device information class
34031
34275
 
34032
- var RudderContext = function RudderContext() {
34276
+ var RudderContext = /*#__PURE__*/_createClass(function RudderContext() {
34033
34277
  _classCallCheck(this, RudderContext);
34034
34278
 
34035
34279
  this.app = new RudderApp();
@@ -34067,7 +34311,7 @@
34067
34311
  this.screen = screen;
34068
34312
  this.device = null;
34069
34313
  this.network = null;
34070
- };
34314
+ });
34071
34315
 
34072
34316
  var RudderMessage = /*#__PURE__*/function () {
34073
34317
  function RudderMessage() {
@@ -35697,12 +35941,12 @@
35697
35941
  var lib$2 = Queue;
35698
35942
 
35699
35943
  // Payload class, contains batch of Elements
35700
- var RudderPayload = function RudderPayload() {
35944
+ var RudderPayload = /*#__PURE__*/_createClass(function RudderPayload() {
35701
35945
  _classCallCheck(this, RudderPayload);
35702
35946
 
35703
35947
  this.batch = null;
35704
35948
  this.writeKey = null;
35705
- };
35949
+ });
35706
35950
 
35707
35951
  var queueOptions = {
35708
35952
  maxRetryDelay: 360000,
@@ -37333,16 +37577,26 @@
37333
37577
  throw Error("failed to initialize");
37334
37578
  }
37335
37579
 
37580
+ var storageOptions = {};
37581
+
37336
37582
  if (options && options.logLevel) {
37337
37583
  logger.setLogLevel(options.logLevel);
37338
37584
  }
37339
37585
 
37340
37586
  if (options && options.setCookieDomain) {
37341
- this.storage.options({
37587
+ storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
37342
37588
  domain: options.setCookieDomain
37343
37589
  });
37344
37590
  }
37345
37591
 
37592
+ if (options && options.secureCookie) {
37593
+ storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
37594
+ secure: options.secureCookie
37595
+ });
37596
+ }
37597
+
37598
+ this.storage.options(storageOptions);
37599
+
37346
37600
  if (options && options.integrations) {
37347
37601
  _extends(this.loadOnlyIntegrations, options.integrations);
37348
37602
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "1.2.9",
3
+ "version": "1.2.14",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",