rudder-sdk-js 1.2.11 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +644 -224
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
@@ -9,14 +9,9 @@
|
|
9
9
|
|
10
10
|
if (Object.getOwnPropertySymbols) {
|
11
11
|
var symbols = Object.getOwnPropertySymbols(object);
|
12
|
-
|
13
|
-
|
14
|
-
|
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]
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
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.
|
5558
|
+
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.16";
|
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
|
-
|
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$
|
27003
|
-
event = _rudderElement$
|
27004
|
-
properties = _rudderElement$
|
27005
|
-
messageId = _rudderElement$
|
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$
|
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$
|
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(
|
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 (
|
29173
|
-
var
|
29174
|
-
|
29175
|
-
|
29176
|
-
|
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
|
-
|
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
|
-
|
29185
|
-
window.gtag("event",
|
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
|
-
|
29193
|
-
|
29194
|
-
|
29195
|
-
|
29196
|
-
|
29197
|
-
|
29198
|
-
|
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
|
}, {
|
@@ -30457,6 +30493,102 @@
|
|
30457
30493
|
return Kissmetrics;
|
30458
30494
|
}();
|
30459
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
|
+
|
30460
30592
|
var Klaviyo = /*#__PURE__*/function () {
|
30461
30593
|
function Klaviyo(config) {
|
30462
30594
|
_classCallCheck(this, Klaviyo);
|
@@ -30468,6 +30600,14 @@
|
|
30468
30600
|
this.name = "KLAVIYO";
|
30469
30601
|
this.keysToExtract = ["context.traits"];
|
30470
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
|
+
};
|
30471
30611
|
}
|
30472
30612
|
|
30473
30613
|
_createClass(Klaviyo, [{
|
@@ -30546,14 +30686,33 @@
|
|
30546
30686
|
var message = rudderElement.message;
|
30547
30687
|
|
30548
30688
|
if (message.properties) {
|
30549
|
-
|
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
|
+
}
|
30550
30702
|
|
30551
|
-
|
30552
|
-
|
30553
|
-
|
30554
|
-
}
|
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
|
+
}
|
30555
30713
|
|
30556
|
-
|
30714
|
+
window._learnq.push(["track", message.event, propsPayload]);
|
30715
|
+
}
|
30557
30716
|
} else window._learnq.push(["track", message.event]);
|
30558
30717
|
}
|
30559
30718
|
}, {
|
@@ -32512,10 +32671,11 @@
|
|
32512
32671
|
this.disableCookie = config.disableCookie || false;
|
32513
32672
|
this.propertyBlackList = [];
|
32514
32673
|
this.xhrHeaders = {};
|
32674
|
+
this.enableLocalStoragePersistence = config.enableLocalStoragePersistence;
|
32515
32675
|
|
32516
32676
|
if (config.xhrHeaders && config.xhrHeaders.length > 0) {
|
32517
32677
|
config.xhrHeaders.forEach(function (header) {
|
32518
|
-
if (header && header.key && header.value && header.key.trim()
|
32678
|
+
if (header && header.key && header.value && header.key.trim() !== "" && header.value.trim() !== "") {
|
32519
32679
|
_this.xhrHeaders[header.key] = header.value;
|
32520
32680
|
}
|
32521
32681
|
});
|
@@ -32523,7 +32683,7 @@
|
|
32523
32683
|
|
32524
32684
|
if (config.propertyBlackList && config.propertyBlackList.length > 0) {
|
32525
32685
|
config.propertyBlackList.forEach(function (element) {
|
32526
|
-
if (element && element.property && element.property.trim()
|
32686
|
+
if (element && element.property && element.property.trim() !== "") {
|
32527
32687
|
_this.propertyBlackList.push(element.property);
|
32528
32688
|
}
|
32529
32689
|
});
|
@@ -32571,6 +32731,10 @@
|
|
32571
32731
|
configObject.xhr_headers = this.xhrHeaders;
|
32572
32732
|
}
|
32573
32733
|
|
32734
|
+
if (this.enableLocalStoragePersistence) {
|
32735
|
+
configObject.persistence = "localStorage+cookie";
|
32736
|
+
}
|
32737
|
+
|
32574
32738
|
posthog.init(this.teamApiKey, configObject);
|
32575
32739
|
}
|
32576
32740
|
/**
|
@@ -32600,7 +32764,7 @@
|
|
32600
32764
|
|
32601
32765
|
if (unsetProperties && unsetProperties.length > 0) {
|
32602
32766
|
unsetProperties.forEach(function (property) {
|
32603
|
-
if (property && property.trim()
|
32767
|
+
if (property && property.trim() !== "") {
|
32604
32768
|
posthog.unregister(property);
|
32605
32769
|
}
|
32606
32770
|
});
|
@@ -32632,7 +32796,7 @@
|
|
32632
32796
|
posthog.capture(event, properties);
|
32633
32797
|
}
|
32634
32798
|
/**
|
32635
|
-
*
|
32799
|
+
*
|
32636
32800
|
*
|
32637
32801
|
* @memberof Posthog
|
32638
32802
|
*/
|
@@ -33220,7 +33384,7 @@
|
|
33220
33384
|
return payload;
|
33221
33385
|
};
|
33222
33386
|
|
33223
|
-
var ecommEventPayload = function ecommEventPayload(event, message) {
|
33387
|
+
var ecommEventPayload$1 = function ecommEventPayload(event, message) {
|
33224
33388
|
var payload = {
|
33225
33389
|
price: getValue(message, "properties.price"),
|
33226
33390
|
currency: getValue(message, "properties.currency"),
|
@@ -33479,31 +33643,31 @@
|
|
33479
33643
|
|
33480
33644
|
switch (event.toLowerCase().trim()) {
|
33481
33645
|
case "order completed":
|
33482
|
-
sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload(event, message));
|
33646
|
+
sendEvent(this.ecomEvents.PURCHASE, ecommEventPayload$1(event, message));
|
33483
33647
|
break;
|
33484
33648
|
|
33485
33649
|
case "checkout started":
|
33486
|
-
sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload(event, message));
|
33650
|
+
sendEvent(this.ecomEvents.START_CHECKOUT, ecommEventPayload$1(event, message));
|
33487
33651
|
break;
|
33488
33652
|
|
33489
33653
|
case "product added":
|
33490
|
-
sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload(event, message));
|
33654
|
+
sendEvent(this.ecomEvents.ADD_CART, ecommEventPayload$1(event, message));
|
33491
33655
|
break;
|
33492
33656
|
|
33493
33657
|
case "payment info entered":
|
33494
|
-
sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload(event, message));
|
33658
|
+
sendEvent(this.ecomEvents.ADD_BILLING, ecommEventPayload$1(event, message));
|
33495
33659
|
break;
|
33496
33660
|
|
33497
33661
|
case "promotion clicked":
|
33498
|
-
sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload(event, message));
|
33662
|
+
sendEvent(this.ecomEvents.AD_CLICK, ecommEventPayload$1(event, message));
|
33499
33663
|
break;
|
33500
33664
|
|
33501
33665
|
case "promotion viewed":
|
33502
|
-
sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload(event, message));
|
33666
|
+
sendEvent(this.ecomEvents.AD_VIEW, ecommEventPayload$1(event, message));
|
33503
33667
|
break;
|
33504
33668
|
|
33505
33669
|
case "product added to wishlist":
|
33506
|
-
sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload(event, message));
|
33670
|
+
sendEvent(this.ecomEvents.ADD_TO_WISHLIST, ecommEventPayload$1(event, message));
|
33507
33671
|
break;
|
33508
33672
|
|
33509
33673
|
default:
|
@@ -34082,33 +34246,33 @@
|
|
34082
34246
|
};
|
34083
34247
|
|
34084
34248
|
// Application class
|
34085
|
-
var RudderApp = function RudderApp() {
|
34249
|
+
var RudderApp = /*#__PURE__*/_createClass(function RudderApp() {
|
34086
34250
|
_classCallCheck(this, RudderApp);
|
34087
34251
|
|
34088
34252
|
this.build = "1.0.0";
|
34089
34253
|
this.name = "RudderLabs JavaScript SDK";
|
34090
34254
|
this.namespace = "com.rudderlabs.javascript";
|
34091
|
-
this.version = "1.2.
|
34092
|
-
};
|
34255
|
+
this.version = "1.2.16";
|
34256
|
+
});
|
34093
34257
|
|
34094
34258
|
// Library information class
|
34095
|
-
var RudderLibraryInfo = function RudderLibraryInfo() {
|
34259
|
+
var RudderLibraryInfo = /*#__PURE__*/_createClass(function RudderLibraryInfo() {
|
34096
34260
|
_classCallCheck(this, RudderLibraryInfo);
|
34097
34261
|
|
34098
34262
|
this.name = "RudderLabs JavaScript SDK";
|
34099
|
-
this.version = "1.2.
|
34100
|
-
}; // Operating System information class
|
34263
|
+
this.version = "1.2.16";
|
34264
|
+
}); // Operating System information class
|
34101
34265
|
|
34102
34266
|
|
34103
|
-
var RudderOSInfo = function RudderOSInfo() {
|
34267
|
+
var RudderOSInfo = /*#__PURE__*/_createClass(function RudderOSInfo() {
|
34104
34268
|
_classCallCheck(this, RudderOSInfo);
|
34105
34269
|
|
34106
34270
|
this.name = "";
|
34107
34271
|
this.version = "";
|
34108
|
-
}; // Screen information class
|
34272
|
+
}); // Screen information class
|
34109
34273
|
|
34110
34274
|
|
34111
|
-
var RudderScreenInfo = function RudderScreenInfo() {
|
34275
|
+
var RudderScreenInfo = /*#__PURE__*/_createClass(function RudderScreenInfo() {
|
34112
34276
|
_classCallCheck(this, RudderScreenInfo);
|
34113
34277
|
|
34114
34278
|
this.density = 0;
|
@@ -34116,9 +34280,9 @@
|
|
34116
34280
|
this.height = 0;
|
34117
34281
|
this.innerWidth = 0;
|
34118
34282
|
this.innerHeight = 0;
|
34119
|
-
}; // Device information class
|
34283
|
+
}); // Device information class
|
34120
34284
|
|
34121
|
-
var RudderContext = function RudderContext() {
|
34285
|
+
var RudderContext = /*#__PURE__*/_createClass(function RudderContext() {
|
34122
34286
|
_classCallCheck(this, RudderContext);
|
34123
34287
|
|
34124
34288
|
this.app = new RudderApp();
|
@@ -34156,7 +34320,7 @@
|
|
34156
34320
|
this.screen = screen;
|
34157
34321
|
this.device = null;
|
34158
34322
|
this.network = null;
|
34159
|
-
};
|
34323
|
+
});
|
34160
34324
|
|
34161
34325
|
var RudderMessage = /*#__PURE__*/function () {
|
34162
34326
|
function RudderMessage() {
|
@@ -35785,14 +35949,6 @@
|
|
35785
35949
|
|
35786
35950
|
var lib$2 = Queue;
|
35787
35951
|
|
35788
|
-
// Payload class, contains batch of Elements
|
35789
|
-
var RudderPayload = function RudderPayload() {
|
35790
|
-
_classCallCheck(this, RudderPayload);
|
35791
|
-
|
35792
|
-
this.batch = null;
|
35793
|
-
this.writeKey = null;
|
35794
|
-
};
|
35795
|
-
|
35796
35952
|
var queueOptions = {
|
35797
35953
|
maxRetryDelay: 360000,
|
35798
35954
|
minRetryDelay: 1000,
|
@@ -35800,34 +35956,21 @@
|
|
35800
35956
|
maxAttempts: 10,
|
35801
35957
|
maxItems: 100
|
35802
35958
|
};
|
35803
|
-
var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
|
35804
35959
|
|
35805
|
-
|
35806
|
-
|
35807
|
-
|
35808
|
-
* flush queue and sending data to rudder backend
|
35809
|
-
* in batch and maintains order of the event.
|
35810
|
-
*/
|
35960
|
+
var XHRQueue = /*#__PURE__*/function () {
|
35961
|
+
function XHRQueue() {
|
35962
|
+
_classCallCheck(this, XHRQueue);
|
35811
35963
|
|
35812
|
-
var EventRepository = /*#__PURE__*/function () {
|
35813
|
-
/**
|
35814
|
-
*Creates an instance of EventRepository.
|
35815
|
-
* @memberof EventRepository
|
35816
|
-
*/
|
35817
|
-
function EventRepository(options) {
|
35818
|
-
_classCallCheck(this, EventRepository);
|
35819
|
-
|
35820
|
-
this.eventsBuffer = [];
|
35821
|
-
this.writeKey = "";
|
35822
35964
|
this.url = "";
|
35823
|
-
this.
|
35824
|
-
this.batchSize = 0; // previous implementation
|
35825
|
-
// setInterval(this.preaparePayloadAndFlush, FLUSH_INTERVAL_DEFAULT, this);
|
35965
|
+
this.writeKey = "";
|
35826
35966
|
}
|
35827
35967
|
|
35828
|
-
_createClass(
|
35829
|
-
key: "
|
35830
|
-
value: function
|
35968
|
+
_createClass(XHRQueue, [{
|
35969
|
+
key: "init",
|
35970
|
+
value: function init(writeKey, url, options) {
|
35971
|
+
this.url = url;
|
35972
|
+
this.writeKey = writeKey;
|
35973
|
+
|
35831
35974
|
if (options) {
|
35832
35975
|
// TODO: add checks for value - has to be +ve?
|
35833
35976
|
_extends(queueOptions, options);
|
@@ -35836,79 +35979,20 @@
|
|
35836
35979
|
this.payloadQueue = new lib$2("rudder", queueOptions, function (item, done) {
|
35837
35980
|
// apply sentAt at flush time and reset on each retry
|
35838
35981
|
item.message.sentAt = getCurrentTimeFormatted(); // send this item for processing, with a callback to enable queue to get the done status
|
35982
|
+
// eslint-disable-next-line no-use-before-define
|
35839
35983
|
|
35840
|
-
|
35984
|
+
this.processQueueElement(item.url, item.headers, item.message, 10 * 1000, // eslint-disable-next-line consistent-return
|
35985
|
+
function (err, res) {
|
35841
35986
|
if (err) {
|
35842
35987
|
return done(err);
|
35843
35988
|
}
|
35844
35989
|
|
35845
35990
|
done(null, res);
|
35846
35991
|
});
|
35847
|
-
}); // start queue
|
35992
|
+
}.bind(this)); // start queue
|
35848
35993
|
|
35849
35994
|
this.payloadQueue.start();
|
35850
35995
|
}
|
35851
|
-
/**
|
35852
|
-
*
|
35853
|
-
*
|
35854
|
-
* @param {EventRepository} repo
|
35855
|
-
* @returns
|
35856
|
-
* @memberof EventRepository
|
35857
|
-
*/
|
35858
|
-
|
35859
|
-
}, {
|
35860
|
-
key: "preaparePayloadAndFlush",
|
35861
|
-
value: function preaparePayloadAndFlush(repo) {
|
35862
|
-
// construct payload
|
35863
|
-
logger.debug("==== in preaparePayloadAndFlush with state: ".concat(repo.state));
|
35864
|
-
logger.debug(repo.eventsBuffer);
|
35865
|
-
|
35866
|
-
if (repo.eventsBuffer.length == 0 || repo.state === "PROCESSING") {
|
35867
|
-
return;
|
35868
|
-
}
|
35869
|
-
|
35870
|
-
var eventsPayload = repo.eventsBuffer;
|
35871
|
-
var payload = new RudderPayload();
|
35872
|
-
payload.batch = eventsPayload;
|
35873
|
-
payload.writeKey = repo.writeKey;
|
35874
|
-
payload.sentAt = getCurrentTimeFormatted(); // add sentAt to individual events as well
|
35875
|
-
|
35876
|
-
payload.batch.forEach(function (event) {
|
35877
|
-
event.sentAt = payload.sentAt;
|
35878
|
-
});
|
35879
|
-
repo.batchSize = repo.eventsBuffer.length; // server-side integration, XHR is node module
|
35880
|
-
|
35881
|
-
if (true) {
|
35882
|
-
var xhr = new XMLHttpRequest();
|
35883
|
-
} else {
|
35884
|
-
var xhr;
|
35885
|
-
}
|
35886
|
-
|
35887
|
-
logger.debug("==== in flush sending to Rudder BE ====");
|
35888
|
-
logger.debug(JSON.stringify(payload, replacer));
|
35889
|
-
xhr.open("POST", repo.url, true);
|
35890
|
-
xhr.setRequestHeader("Content-Type", "application/json");
|
35891
|
-
|
35892
|
-
{
|
35893
|
-
xhr.setRequestHeader("Authorization", "Basic ".concat(btoa("".concat(payload.writeKey, ":"))));
|
35894
|
-
} // register call back to reset event buffer on successfull POST
|
35895
|
-
|
35896
|
-
|
35897
|
-
xhr.onreadystatechange = function () {
|
35898
|
-
if (xhr.readyState === 4 && xhr.status === 200) {
|
35899
|
-
logger.debug("====== request processed successfully: ".concat(xhr.status));
|
35900
|
-
repo.eventsBuffer = repo.eventsBuffer.slice(repo.batchSize);
|
35901
|
-
logger.debug(repo.eventsBuffer.length);
|
35902
|
-
} else if (xhr.readyState === 4 && xhr.status !== 200) {
|
35903
|
-
handleError(new Error("request failed with status: ".concat(xhr.status, " for url: ").concat(repo.url)));
|
35904
|
-
}
|
35905
|
-
|
35906
|
-
repo.state = "READY";
|
35907
|
-
};
|
35908
|
-
|
35909
|
-
xhr.send(JSON.stringify(payload, replacer));
|
35910
|
-
repo.state = "PROCESSING";
|
35911
|
-
}
|
35912
35996
|
/**
|
35913
35997
|
* the queue item proceesor
|
35914
35998
|
* @param {*} url to send requests to
|
@@ -35950,6 +36034,216 @@
|
|
35950
36034
|
queueFn(error);
|
35951
36035
|
}
|
35952
36036
|
}
|
36037
|
+
}, {
|
36038
|
+
key: "enqueue",
|
36039
|
+
value: function enqueue(message, type) {
|
36040
|
+
var headers = {
|
36041
|
+
"Content-Type": "application/json",
|
36042
|
+
Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
|
36043
|
+
AnonymousId: btoa(message.anonymousId)
|
36044
|
+
}; // add items to the queue
|
36045
|
+
|
36046
|
+
this.payloadQueue.addItem({
|
36047
|
+
url: "".concat(this.url, "/v1/").concat(type),
|
36048
|
+
headers: headers,
|
36049
|
+
message: message
|
36050
|
+
});
|
36051
|
+
}
|
36052
|
+
}]);
|
36053
|
+
|
36054
|
+
return XHRQueue;
|
36055
|
+
}();
|
36056
|
+
|
36057
|
+
var defaults$3 = {
|
36058
|
+
queue: "queue",
|
36059
|
+
maxPayloadSize: 64 * 1000
|
36060
|
+
};
|
36061
|
+
|
36062
|
+
var BeaconQueue = /*#__PURE__*/function () {
|
36063
|
+
function BeaconQueue() {
|
36064
|
+
_classCallCheck(this, BeaconQueue);
|
36065
|
+
|
36066
|
+
this.storage = Store;
|
36067
|
+
this.maxItems = 10;
|
36068
|
+
this.flushQueueTimeOut = undefined;
|
36069
|
+
this.timeOutActive = false;
|
36070
|
+
this.flushQueueTimeOutInterval = 1000 * 60 * 10; // 10 mins
|
36071
|
+
|
36072
|
+
this.url = "";
|
36073
|
+
this.writekey = "";
|
36074
|
+
this.queueName = "".concat(defaults$3.queue, ".").concat(Date.now());
|
36075
|
+
}
|
36076
|
+
|
36077
|
+
_createClass(BeaconQueue, [{
|
36078
|
+
key: "sendQueueDataForBeacon",
|
36079
|
+
value: function sendQueueDataForBeacon() {
|
36080
|
+
this.sendDataFromQueueAndDestroyQueue();
|
36081
|
+
}
|
36082
|
+
}, {
|
36083
|
+
key: "init",
|
36084
|
+
value: function init(writekey, url, options) {
|
36085
|
+
this.url = url;
|
36086
|
+
this.writekey = writekey;
|
36087
|
+
if (options.maxItems) this.maxItems = options.maxItems;
|
36088
|
+
if (options.flushQueueInterval) this.flushQueueTimeOutInterval = options.flushQueueInterval;
|
36089
|
+
var sendQueueData = this.sendQueueDataForBeacon.bind(this);
|
36090
|
+
window.addEventListener("unload", sendQueueData);
|
36091
|
+
}
|
36092
|
+
}, {
|
36093
|
+
key: "getQueue",
|
36094
|
+
value: function getQueue() {
|
36095
|
+
return this.storage.get(this.queueName);
|
36096
|
+
}
|
36097
|
+
}, {
|
36098
|
+
key: "setQueue",
|
36099
|
+
value: function setQueue(value) {
|
36100
|
+
this.storage.set(this.queueName, value);
|
36101
|
+
}
|
36102
|
+
/**
|
36103
|
+
*
|
36104
|
+
* Utility method for excluding null and empty values in JSON
|
36105
|
+
* @param {*} _key
|
36106
|
+
* @param {*} value
|
36107
|
+
* @returns
|
36108
|
+
*/
|
36109
|
+
|
36110
|
+
}, {
|
36111
|
+
key: "replacer",
|
36112
|
+
value: function replacer(_key, value) {
|
36113
|
+
if (value === null || value === undefined) {
|
36114
|
+
return undefined;
|
36115
|
+
}
|
36116
|
+
|
36117
|
+
return value;
|
36118
|
+
}
|
36119
|
+
}, {
|
36120
|
+
key: "enqueue",
|
36121
|
+
value: function enqueue(message) {
|
36122
|
+
var queue = this.getQueue() || [];
|
36123
|
+
queue = queue.slice(-(this.maxItems - 1));
|
36124
|
+
queue.push(message);
|
36125
|
+
var batch = queue.slice(0);
|
36126
|
+
var data = {
|
36127
|
+
batch: batch
|
36128
|
+
};
|
36129
|
+
var dataToSend = JSON.stringify(data, this.replacer);
|
36130
|
+
|
36131
|
+
if (dataToSend.length > defaults$3.maxPayloadSize) {
|
36132
|
+
batch = queue.slice(0, queue.length - 1);
|
36133
|
+
this.flushQueue(batch);
|
36134
|
+
queue = this.getQueue();
|
36135
|
+
queue.push(message);
|
36136
|
+
}
|
36137
|
+
|
36138
|
+
this.setQueue(queue);
|
36139
|
+
this.setTimer();
|
36140
|
+
|
36141
|
+
if (queue.length === this.maxItems) {
|
36142
|
+
this.flushQueue(batch);
|
36143
|
+
}
|
36144
|
+
}
|
36145
|
+
}, {
|
36146
|
+
key: "sendDataFromQueueAndDestroyQueue",
|
36147
|
+
value: function sendDataFromQueueAndDestroyQueue() {
|
36148
|
+
this.sendDataFromQueue();
|
36149
|
+
this.storage.remove(this.queueName);
|
36150
|
+
}
|
36151
|
+
}, {
|
36152
|
+
key: "sendDataFromQueue",
|
36153
|
+
value: function sendDataFromQueue() {
|
36154
|
+
var queue = this.getQueue();
|
36155
|
+
|
36156
|
+
if (queue && queue.length > 0) {
|
36157
|
+
var batch = queue.slice(0, queue.length);
|
36158
|
+
this.flushQueue(batch);
|
36159
|
+
}
|
36160
|
+
}
|
36161
|
+
}, {
|
36162
|
+
key: "flushQueue",
|
36163
|
+
value: function flushQueue(batch) {
|
36164
|
+
batch.map(function (event) {
|
36165
|
+
event.sentAt = new Date().toISOString();
|
36166
|
+
});
|
36167
|
+
var data = {
|
36168
|
+
batch: batch
|
36169
|
+
};
|
36170
|
+
var payload = JSON.stringify(data, this.replacer);
|
36171
|
+
var blob = new Blob([payload], {
|
36172
|
+
type: "application/json"
|
36173
|
+
});
|
36174
|
+
var isPushed = navigator.sendBeacon("".concat(this.url, "?writeKey=").concat(this.writekey), blob);
|
36175
|
+
|
36176
|
+
if (!isPushed) {
|
36177
|
+
logger.debug("Unable to send data");
|
36178
|
+
}
|
36179
|
+
|
36180
|
+
this.setQueue([]);
|
36181
|
+
this.clearTimer();
|
36182
|
+
}
|
36183
|
+
}, {
|
36184
|
+
key: "setTimer",
|
36185
|
+
value: function setTimer() {
|
36186
|
+
if (!this.timeOutActive) {
|
36187
|
+
this.flushQueueTimeOut = setTimeout(this.sendDataFromQueue.bind(this), this.flushQueueTimeOutInterval);
|
36188
|
+
this.timeOutActive = true;
|
36189
|
+
}
|
36190
|
+
}
|
36191
|
+
}, {
|
36192
|
+
key: "clearTimer",
|
36193
|
+
value: function clearTimer() {
|
36194
|
+
if (this.timeOutActive) {
|
36195
|
+
clearTimeout(this.flushQueueTimeOut);
|
36196
|
+
this.timeOutActive = false;
|
36197
|
+
}
|
36198
|
+
}
|
36199
|
+
}]);
|
36200
|
+
|
36201
|
+
return BeaconQueue;
|
36202
|
+
}();
|
36203
|
+
|
36204
|
+
var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
|
36205
|
+
|
36206
|
+
/**
|
36207
|
+
*
|
36208
|
+
* @class EventRepository responsible for adding events into
|
36209
|
+
* flush queue and sending data to rudder backend
|
36210
|
+
* in batch and maintains order of the event.
|
36211
|
+
*/
|
36212
|
+
|
36213
|
+
var EventRepository = /*#__PURE__*/function () {
|
36214
|
+
/**
|
36215
|
+
*Creates an instance of EventRepository.
|
36216
|
+
* @memberof EventRepository
|
36217
|
+
*/
|
36218
|
+
function EventRepository() {
|
36219
|
+
_classCallCheck(this, EventRepository);
|
36220
|
+
|
36221
|
+
this.queue = undefined;
|
36222
|
+
}
|
36223
|
+
|
36224
|
+
_createClass(EventRepository, [{
|
36225
|
+
key: "initialize",
|
36226
|
+
value: function initialize(writeKey, url, options) {
|
36227
|
+
var queueOptions = {};
|
36228
|
+
var targetUrl = url.slice(-1) === "/" ? url.slice(0, -1) : url;
|
36229
|
+
|
36230
|
+
if (options && options.useBeacon) {
|
36231
|
+
if (options && options.beaconQueueOptions && options.beaconQueueOptions != null && _typeof(options.beaconQueueOptions) === "object") {
|
36232
|
+
queueOptions = options.beaconQueueOptions;
|
36233
|
+
}
|
36234
|
+
|
36235
|
+
targetUrl = "".concat(targetUrl, "/beacon/v1/batch");
|
36236
|
+
this.queue = new BeaconQueue();
|
36237
|
+
} else {
|
36238
|
+
if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) === "object") {
|
36239
|
+
queueOptions = options.queueOptions;
|
36240
|
+
}
|
36241
|
+
|
36242
|
+
this.queue = new XHRQueue();
|
36243
|
+
}
|
36244
|
+
|
36245
|
+
this.queue.init(writeKey, targetUrl, queueOptions);
|
36246
|
+
}
|
35953
36247
|
/**
|
35954
36248
|
*
|
35955
36249
|
*
|
@@ -35961,34 +36255,22 @@
|
|
35961
36255
|
key: "enqueue",
|
35962
36256
|
value: function enqueue(rudderElement, type) {
|
35963
36257
|
var message = rudderElement.getElementContent();
|
35964
|
-
var headers = {
|
35965
|
-
"Content-Type": "application/json",
|
35966
|
-
Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
|
35967
|
-
AnonymousId: btoa(message.anonymousId)
|
35968
|
-
};
|
35969
36258
|
message.originalTimestamp = getCurrentTimeFormatted();
|
35970
36259
|
message.sentAt = getCurrentTimeFormatted(); // add this, will get modified when actually being sent
|
35971
36260
|
// check message size, if greater log an error
|
35972
36261
|
|
35973
36262
|
if (JSON.stringify(message).length > MESSAGE_LENGTH) {
|
35974
36263
|
logger.error("[EventRepository] enqueue:: message length greater 32 Kb ", message);
|
35975
|
-
}
|
35976
|
-
|
35977
|
-
|
35978
|
-
var url = this.url.slice(-1) == "/" ? this.url.slice(0, -1) : this.url; // add items to the queue
|
36264
|
+
}
|
35979
36265
|
|
35980
|
-
this.
|
35981
|
-
url: "".concat(url, "/v1/").concat(type),
|
35982
|
-
headers: headers,
|
35983
|
-
message: message
|
35984
|
-
});
|
36266
|
+
this.queue.enqueue(message, type);
|
35985
36267
|
}
|
35986
36268
|
}]);
|
35987
36269
|
|
35988
36270
|
return EventRepository;
|
35989
36271
|
}();
|
35990
36272
|
|
35991
|
-
var eventRepository = new EventRepository();
|
36273
|
+
var eventRepository = new EventRepository(); // eslint-disable-next-line import/prefer-default-export
|
35992
36274
|
|
35993
36275
|
function addDomEventHandlers(rudderanalytics) {
|
35994
36276
|
var handler = function handler(e) {
|
@@ -36615,6 +36897,130 @@
|
|
36615
36897
|
return Math.floor(Date.now() / 60000);
|
36616
36898
|
}
|
36617
36899
|
|
36900
|
+
/* eslint-disable class-methods-use-this */
|
36901
|
+
|
36902
|
+
var OneTrust = /*#__PURE__*/function () {
|
36903
|
+
function OneTrust(sourceConfig) {
|
36904
|
+
var _this = this;
|
36905
|
+
|
36906
|
+
_classCallCheck(this, OneTrust);
|
36907
|
+
|
36908
|
+
this.sourceConfig = sourceConfig; // If user does not load onetrust sdk before loading rudderstack sdk
|
36909
|
+
// we will not be filtering any of the destinations.
|
36910
|
+
|
36911
|
+
if (!window.OneTrust || !window.OnetrustActiveGroups) {
|
36912
|
+
throw new Error("OneTrust resources are not accessible. Thus all the destinations will be loaded");
|
36913
|
+
} // OneTrust Cookie Compliance populates a data layer object OnetrustActiveGroups with
|
36914
|
+
// the cookie categories that the user has consented to.
|
36915
|
+
// Eg: ',C0001,C0003,'
|
36916
|
+
// We split it and save it as an array.
|
36917
|
+
|
36918
|
+
|
36919
|
+
var userSetConsentGroupIds = window.OnetrustActiveGroups.split(","); // Ids user has consented
|
36920
|
+
// Get information about the cookie script - data includes, consent models, cookies in preference centre, etc.
|
36921
|
+
// We get the groups(cookie categorization), user has created in one trust account.
|
36922
|
+
|
36923
|
+
var oneTrustAllGroupsInfo = window.OneTrust.GetDomainData().Groups;
|
36924
|
+
this.userSetConsentGroupNames = []; // Get the names of the cookies consented by the user in the browser.
|
36925
|
+
|
36926
|
+
oneTrustAllGroupsInfo.forEach(function (group) {
|
36927
|
+
var CustomGroupId = group.CustomGroupId,
|
36928
|
+
GroupName = group.GroupName;
|
36929
|
+
|
36930
|
+
if (userSetConsentGroupIds.includes(CustomGroupId)) {
|
36931
|
+
_this.userSetConsentGroupNames.push(GroupName.toUpperCase().trim());
|
36932
|
+
}
|
36933
|
+
});
|
36934
|
+
}
|
36935
|
+
|
36936
|
+
_createClass(OneTrust, [{
|
36937
|
+
key: "isEnabled",
|
36938
|
+
value: function isEnabled(destConfig) {
|
36939
|
+
var _this2 = this;
|
36940
|
+
|
36941
|
+
try {
|
36942
|
+
/**
|
36943
|
+
* Structure of onetrust consent group destination config.
|
36944
|
+
*
|
36945
|
+
* "oneTrustConsentGroup": [
|
36946
|
+
{
|
36947
|
+
"oneTrustConsentGroup": "Performance Cookies"
|
36948
|
+
},
|
36949
|
+
{
|
36950
|
+
"oneTrustConsentGroup": "Functional Cookies"
|
36951
|
+
},
|
36952
|
+
{
|
36953
|
+
"oneTrustConsentGroup": ""
|
36954
|
+
}
|
36955
|
+
]
|
36956
|
+
*
|
36957
|
+
*/
|
36958
|
+
var oneTrustCookieCategories = destConfig.oneTrustCookieCategories; // mapping of the destination with the consent group name
|
36959
|
+
// If the destination do not have this mapping events will be sent.
|
36960
|
+
|
36961
|
+
if (!oneTrustCookieCategories) {
|
36962
|
+
return true;
|
36963
|
+
} // Change the structure of oneTrustConsentGroup as an array and filter values if empty string
|
36964
|
+
// Eg:
|
36965
|
+
// ["Performance Cookies", "Functional Cookies"]
|
36966
|
+
|
36967
|
+
|
36968
|
+
var oneTrustConsentGroupArr = oneTrustCookieCategories.map(function (c) {
|
36969
|
+
return c.oneTrustCookieCategory;
|
36970
|
+
}).filter(function (n) {
|
36971
|
+
return n;
|
36972
|
+
});
|
36973
|
+
var containsAllConsent = true; // Check if all the destination's mapped cookie categories are consented by the user in the browser.
|
36974
|
+
|
36975
|
+
containsAllConsent = oneTrustConsentGroupArr.every(function (element) {
|
36976
|
+
return _this2.userSetConsentGroupNames.includes(element.toUpperCase().trim());
|
36977
|
+
});
|
36978
|
+
return containsAllConsent;
|
36979
|
+
} catch (e) {
|
36980
|
+
logger.error("Error during onetrust cookie consent management ".concat(e));
|
36981
|
+
return true;
|
36982
|
+
}
|
36983
|
+
}
|
36984
|
+
}]);
|
36985
|
+
|
36986
|
+
return OneTrust;
|
36987
|
+
}();
|
36988
|
+
|
36989
|
+
var CookieConsentFactory = /*#__PURE__*/function () {
|
36990
|
+
function CookieConsentFactory() {
|
36991
|
+
_classCallCheck(this, CookieConsentFactory);
|
36992
|
+
}
|
36993
|
+
|
36994
|
+
_createClass(CookieConsentFactory, null, [{
|
36995
|
+
key: "initialize",
|
36996
|
+
value: function initialize(cookieConsentOptions) {
|
36997
|
+
var _cookieConsentOptions;
|
36998
|
+
|
36999
|
+
/**
|
37000
|
+
*
|
37001
|
+
* check which type of cookie consent manager needs to be called if enabled
|
37002
|
+
* for now we have only OneTrust.
|
37003
|
+
* But if new cookie consent manager options are implemented,
|
37004
|
+
* we need to make sure only one of them is enabled by the user in the
|
37005
|
+
* load options
|
37006
|
+
*
|
37007
|
+
*/
|
37008
|
+
if (cookieConsentOptions !== null && cookieConsentOptions !== void 0 && (_cookieConsentOptions = cookieConsentOptions.oneTrust) !== null && _cookieConsentOptions !== void 0 && _cookieConsentOptions.enabled) {
|
37009
|
+
// This is P1. When we have an ui in source side to turn on/off of cookie consent
|
37010
|
+
// if (sourceConfig &&
|
37011
|
+
// sourceConfig.cookieConsentManager &&
|
37012
|
+
// sourceConfig.cookieConsentManager.oneTrust &&
|
37013
|
+
// sourceConfig.cookieConsentManager.oneTrustenabled) {
|
37014
|
+
return new OneTrust(); // }
|
37015
|
+
}
|
37016
|
+
|
37017
|
+
return null;
|
37018
|
+
}
|
37019
|
+
}]);
|
37020
|
+
|
37021
|
+
return CookieConsentFactory;
|
37022
|
+
}();
|
37023
|
+
|
36618
37024
|
var queryDefaults = {
|
36619
37025
|
trait: "ajs_trait_",
|
36620
37026
|
prop: "ajs_prop_"
|
@@ -36674,6 +37080,7 @@
|
|
36674
37080
|
};
|
36675
37081
|
this.loaded = false;
|
36676
37082
|
this.loadIntegration = true;
|
37083
|
+
this.cookieConsentOptions = {};
|
36677
37084
|
}
|
36678
37085
|
/**
|
36679
37086
|
* initialize the user after load config
|
@@ -36745,11 +37152,24 @@
|
|
36745
37152
|
}, this);
|
36746
37153
|
logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
|
36747
37154
|
|
36748
|
-
this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations); //
|
37155
|
+
this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations); // Check if cookie consent manager is being set through load options
|
37156
|
+
|
37157
|
+
if (Object.keys(this.cookieConsentOptions).length) {
|
37158
|
+
// Call the cookie consent factory to initialise and return the type of cookie
|
37159
|
+
// consent being set. For now we only support OneTrust.
|
37160
|
+
try {
|
37161
|
+
var cookieConsent = CookieConsentFactory.initialize(this.cookieConsentOptions); // If cookie consent object is return we filter according to consents given by user
|
37162
|
+
// else we do not consider any filtering for cookie consent.
|
37163
|
+
|
37164
|
+
this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
|
37165
|
+
return integrations[intg.name] != undefined && (!cookieConsent || // check if cookieconsent object is present and then do filtering
|
37166
|
+
cookieConsent && cookieConsent.isEnabled(intg.config));
|
37167
|
+
});
|
37168
|
+
} catch (e) {
|
37169
|
+
logger.error(e);
|
37170
|
+
}
|
37171
|
+
}
|
36749
37172
|
|
36750
|
-
this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
|
36751
|
-
return integrations[intg.name] != undefined;
|
36752
|
-
});
|
36753
37173
|
this.init(this.clientIntegrations);
|
36754
37174
|
} catch (error) {
|
36755
37175
|
handleError(error);
|
@@ -37412,6 +37832,7 @@
|
|
37412
37832
|
var _this3 = this;
|
37413
37833
|
|
37414
37834
|
logger.debug("inside load ");
|
37835
|
+
if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
|
37415
37836
|
if (this.loaded) return;
|
37416
37837
|
var configUrl = CONFIG_URL;
|
37417
37838
|
|
@@ -37422,16 +37843,26 @@
|
|
37422
37843
|
throw Error("failed to initialize");
|
37423
37844
|
}
|
37424
37845
|
|
37846
|
+
var storageOptions = {};
|
37847
|
+
|
37425
37848
|
if (options && options.logLevel) {
|
37426
37849
|
logger.setLogLevel(options.logLevel);
|
37427
37850
|
}
|
37428
37851
|
|
37429
37852
|
if (options && options.setCookieDomain) {
|
37430
|
-
|
37853
|
+
storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
|
37431
37854
|
domain: options.setCookieDomain
|
37432
37855
|
});
|
37433
37856
|
}
|
37434
37857
|
|
37858
|
+
if (options && options.secureCookie) {
|
37859
|
+
storageOptions = _objectSpread2(_objectSpread2({}, storageOptions), {}, {
|
37860
|
+
secure: options.secureCookie
|
37861
|
+
});
|
37862
|
+
}
|
37863
|
+
|
37864
|
+
this.storage.options(storageOptions);
|
37865
|
+
|
37435
37866
|
if (options && options.integrations) {
|
37436
37867
|
_extends(this.loadOnlyIntegrations, options.integrations);
|
37437
37868
|
|
@@ -37468,22 +37899,11 @@
|
|
37468
37899
|
this.registerCallbacks(true);
|
37469
37900
|
}
|
37470
37901
|
|
37471
|
-
if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) == "object") {
|
37472
|
-
this.eventRepository.startQueue(options.queueOptions);
|
37473
|
-
} else {
|
37474
|
-
this.eventRepository.startQueue({});
|
37475
|
-
}
|
37476
|
-
|
37477
37902
|
if (options && options.loadIntegration != undefined) {
|
37478
37903
|
this.loadIntegration = !!options.loadIntegration;
|
37479
37904
|
}
|
37480
37905
|
|
37481
|
-
this.eventRepository.writeKey
|
37482
|
-
|
37483
|
-
if (serverUrl) {
|
37484
|
-
this.eventRepository.url = serverUrl;
|
37485
|
-
}
|
37486
|
-
|
37906
|
+
this.eventRepository.initialize(writeKey, serverUrl, options);
|
37487
37907
|
this.initializeUser();
|
37488
37908
|
this.setInitialPageProperties();
|
37489
37909
|
this.loaded = true;
|