rudder-sdk-js 1.2.14 → 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.
- package/index.js +374 -126
- package/package.json +1 -1
package/index.js
CHANGED
@@ -5555,7 +5555,7 @@
|
|
5555
5555
|
PRODUCT_REVIEWED: "Product Reviewed"
|
5556
5556
|
}; // Enumeration for integrations supported
|
5557
5557
|
|
5558
|
-
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.15";
|
5559
5559
|
var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
|
5560
5560
|
var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
|
5561
5561
|
/* module.exports = {
|
@@ -11507,6 +11507,10 @@
|
|
11507
11507
|
if (Store.enabled) {
|
11508
11508
|
this.storage = Store;
|
11509
11509
|
}
|
11510
|
+
|
11511
|
+
if (!this.storage) {
|
11512
|
+
throw Error("Could not initialize the SDK :: no storage is available");
|
11513
|
+
}
|
11510
11514
|
}
|
11511
11515
|
|
11512
11516
|
_createClass(Storage, [{
|
@@ -34243,7 +34247,7 @@
|
|
34243
34247
|
this.build = "1.0.0";
|
34244
34248
|
this.name = "RudderLabs JavaScript SDK";
|
34245
34249
|
this.namespace = "com.rudderlabs.javascript";
|
34246
|
-
this.version = "1.2.
|
34250
|
+
this.version = "1.2.15";
|
34247
34251
|
});
|
34248
34252
|
|
34249
34253
|
// Library information class
|
@@ -34251,7 +34255,7 @@
|
|
34251
34255
|
_classCallCheck(this, RudderLibraryInfo);
|
34252
34256
|
|
34253
34257
|
this.name = "RudderLabs JavaScript SDK";
|
34254
|
-
this.version = "1.2.
|
34258
|
+
this.version = "1.2.15";
|
34255
34259
|
}); // Operating System information class
|
34256
34260
|
|
34257
34261
|
|
@@ -35940,14 +35944,6 @@
|
|
35940
35944
|
|
35941
35945
|
var lib$2 = Queue;
|
35942
35946
|
|
35943
|
-
// Payload class, contains batch of Elements
|
35944
|
-
var RudderPayload = /*#__PURE__*/_createClass(function RudderPayload() {
|
35945
|
-
_classCallCheck(this, RudderPayload);
|
35946
|
-
|
35947
|
-
this.batch = null;
|
35948
|
-
this.writeKey = null;
|
35949
|
-
});
|
35950
|
-
|
35951
35947
|
var queueOptions = {
|
35952
35948
|
maxRetryDelay: 360000,
|
35953
35949
|
minRetryDelay: 1000,
|
@@ -35955,34 +35951,21 @@
|
|
35955
35951
|
maxAttempts: 10,
|
35956
35952
|
maxItems: 100
|
35957
35953
|
};
|
35958
|
-
var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
|
35959
|
-
|
35960
|
-
/**
|
35961
|
-
*
|
35962
|
-
* @class EventRepository responsible for adding events into
|
35963
|
-
* flush queue and sending data to rudder backend
|
35964
|
-
* in batch and maintains order of the event.
|
35965
|
-
*/
|
35966
35954
|
|
35967
|
-
var
|
35968
|
-
|
35969
|
-
|
35970
|
-
* @memberof EventRepository
|
35971
|
-
*/
|
35972
|
-
function EventRepository(options) {
|
35973
|
-
_classCallCheck(this, EventRepository);
|
35955
|
+
var XHRQueue = /*#__PURE__*/function () {
|
35956
|
+
function XHRQueue() {
|
35957
|
+
_classCallCheck(this, XHRQueue);
|
35974
35958
|
|
35975
|
-
this.eventsBuffer = [];
|
35976
|
-
this.writeKey = "";
|
35977
35959
|
this.url = "";
|
35978
|
-
this.
|
35979
|
-
this.batchSize = 0; // previous implementation
|
35980
|
-
// setInterval(this.preaparePayloadAndFlush, FLUSH_INTERVAL_DEFAULT, this);
|
35960
|
+
this.writeKey = "";
|
35981
35961
|
}
|
35982
35962
|
|
35983
|
-
_createClass(
|
35984
|
-
key: "
|
35985
|
-
value: function
|
35963
|
+
_createClass(XHRQueue, [{
|
35964
|
+
key: "init",
|
35965
|
+
value: function init(writeKey, url, options) {
|
35966
|
+
this.url = url;
|
35967
|
+
this.writeKey = writeKey;
|
35968
|
+
|
35986
35969
|
if (options) {
|
35987
35970
|
// TODO: add checks for value - has to be +ve?
|
35988
35971
|
_extends(queueOptions, options);
|
@@ -35991,79 +35974,20 @@
|
|
35991
35974
|
this.payloadQueue = new lib$2("rudder", queueOptions, function (item, done) {
|
35992
35975
|
// apply sentAt at flush time and reset on each retry
|
35993
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
|
35994
35978
|
|
35995
|
-
|
35979
|
+
this.processQueueElement(item.url, item.headers, item.message, 10 * 1000, // eslint-disable-next-line consistent-return
|
35980
|
+
function (err, res) {
|
35996
35981
|
if (err) {
|
35997
35982
|
return done(err);
|
35998
35983
|
}
|
35999
35984
|
|
36000
35985
|
done(null, res);
|
36001
35986
|
});
|
36002
|
-
}); // start queue
|
35987
|
+
}.bind(this)); // start queue
|
36003
35988
|
|
36004
35989
|
this.payloadQueue.start();
|
36005
35990
|
}
|
36006
|
-
/**
|
36007
|
-
*
|
36008
|
-
*
|
36009
|
-
* @param {EventRepository} repo
|
36010
|
-
* @returns
|
36011
|
-
* @memberof EventRepository
|
36012
|
-
*/
|
36013
|
-
|
36014
|
-
}, {
|
36015
|
-
key: "preaparePayloadAndFlush",
|
36016
|
-
value: function preaparePayloadAndFlush(repo) {
|
36017
|
-
// construct payload
|
36018
|
-
logger.debug("==== in preaparePayloadAndFlush with state: ".concat(repo.state));
|
36019
|
-
logger.debug(repo.eventsBuffer);
|
36020
|
-
|
36021
|
-
if (repo.eventsBuffer.length == 0 || repo.state === "PROCESSING") {
|
36022
|
-
return;
|
36023
|
-
}
|
36024
|
-
|
36025
|
-
var eventsPayload = repo.eventsBuffer;
|
36026
|
-
var payload = new RudderPayload();
|
36027
|
-
payload.batch = eventsPayload;
|
36028
|
-
payload.writeKey = repo.writeKey;
|
36029
|
-
payload.sentAt = getCurrentTimeFormatted(); // add sentAt to individual events as well
|
36030
|
-
|
36031
|
-
payload.batch.forEach(function (event) {
|
36032
|
-
event.sentAt = payload.sentAt;
|
36033
|
-
});
|
36034
|
-
repo.batchSize = repo.eventsBuffer.length; // server-side integration, XHR is node module
|
36035
|
-
|
36036
|
-
if (true) {
|
36037
|
-
var xhr = new XMLHttpRequest();
|
36038
|
-
} else {
|
36039
|
-
var xhr;
|
36040
|
-
}
|
36041
|
-
|
36042
|
-
logger.debug("==== in flush sending to Rudder BE ====");
|
36043
|
-
logger.debug(JSON.stringify(payload, replacer));
|
36044
|
-
xhr.open("POST", repo.url, true);
|
36045
|
-
xhr.setRequestHeader("Content-Type", "application/json");
|
36046
|
-
|
36047
|
-
{
|
36048
|
-
xhr.setRequestHeader("Authorization", "Basic ".concat(btoa("".concat(payload.writeKey, ":"))));
|
36049
|
-
} // register call back to reset event buffer on successfull POST
|
36050
|
-
|
36051
|
-
|
36052
|
-
xhr.onreadystatechange = function () {
|
36053
|
-
if (xhr.readyState === 4 && xhr.status === 200) {
|
36054
|
-
logger.debug("====== request processed successfully: ".concat(xhr.status));
|
36055
|
-
repo.eventsBuffer = repo.eventsBuffer.slice(repo.batchSize);
|
36056
|
-
logger.debug(repo.eventsBuffer.length);
|
36057
|
-
} else if (xhr.readyState === 4 && xhr.status !== 200) {
|
36058
|
-
handleError(new Error("request failed with status: ".concat(xhr.status, " for url: ").concat(repo.url)));
|
36059
|
-
}
|
36060
|
-
|
36061
|
-
repo.state = "READY";
|
36062
|
-
};
|
36063
|
-
|
36064
|
-
xhr.send(JSON.stringify(payload, replacer));
|
36065
|
-
repo.state = "PROCESSING";
|
36066
|
-
}
|
36067
35991
|
/**
|
36068
35992
|
* the queue item proceesor
|
36069
35993
|
* @param {*} url to send requests to
|
@@ -36105,6 +36029,216 @@
|
|
36105
36029
|
queueFn(error);
|
36106
36030
|
}
|
36107
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
|
+
}
|
36108
36242
|
/**
|
36109
36243
|
*
|
36110
36244
|
*
|
@@ -36116,34 +36250,22 @@
|
|
36116
36250
|
key: "enqueue",
|
36117
36251
|
value: function enqueue(rudderElement, type) {
|
36118
36252
|
var message = rudderElement.getElementContent();
|
36119
|
-
var headers = {
|
36120
|
-
"Content-Type": "application/json",
|
36121
|
-
Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
|
36122
|
-
AnonymousId: btoa(message.anonymousId)
|
36123
|
-
};
|
36124
36253
|
message.originalTimestamp = getCurrentTimeFormatted();
|
36125
36254
|
message.sentAt = getCurrentTimeFormatted(); // add this, will get modified when actually being sent
|
36126
36255
|
// check message size, if greater log an error
|
36127
36256
|
|
36128
36257
|
if (JSON.stringify(message).length > MESSAGE_LENGTH) {
|
36129
36258
|
logger.error("[EventRepository] enqueue:: message length greater 32 Kb ", message);
|
36130
|
-
}
|
36131
|
-
|
36132
|
-
|
36133
|
-
var url = this.url.slice(-1) == "/" ? this.url.slice(0, -1) : this.url; // add items to the queue
|
36259
|
+
}
|
36134
36260
|
|
36135
|
-
this.
|
36136
|
-
url: "".concat(url, "/v1/").concat(type),
|
36137
|
-
headers: headers,
|
36138
|
-
message: message
|
36139
|
-
});
|
36261
|
+
this.queue.enqueue(message, type);
|
36140
36262
|
}
|
36141
36263
|
}]);
|
36142
36264
|
|
36143
36265
|
return EventRepository;
|
36144
36266
|
}();
|
36145
36267
|
|
36146
|
-
var eventRepository = new EventRepository();
|
36268
|
+
var eventRepository = new EventRepository(); // eslint-disable-next-line import/prefer-default-export
|
36147
36269
|
|
36148
36270
|
function addDomEventHandlers(rudderanalytics) {
|
36149
36271
|
var handler = function handler(e) {
|
@@ -36770,6 +36892,131 @@
|
|
36770
36892
|
return Math.floor(Date.now() / 60000);
|
36771
36893
|
}
|
36772
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
|
+
|
36773
37020
|
var queryDefaults = {
|
36774
37021
|
trait: "ajs_trait_",
|
36775
37022
|
prop: "ajs_prop_"
|
@@ -36829,6 +37076,7 @@
|
|
36829
37076
|
};
|
36830
37077
|
this.loaded = false;
|
36831
37078
|
this.loadIntegration = true;
|
37079
|
+
this.cookieConsentOptions = {};
|
36832
37080
|
}
|
36833
37081
|
/**
|
36834
37082
|
* initialize the user after load config
|
@@ -36900,10 +37148,20 @@
|
|
36900
37148
|
}, this);
|
36901
37149
|
logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
|
36902
37150
|
|
36903
|
-
this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
|
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
|
+
|
36904
37161
|
|
36905
37162
|
this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
|
36906
|
-
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));
|
36907
37165
|
});
|
36908
37166
|
this.init(this.clientIntegrations);
|
36909
37167
|
} catch (error) {
|
@@ -37567,6 +37825,7 @@
|
|
37567
37825
|
var _this3 = this;
|
37568
37826
|
|
37569
37827
|
logger.debug("inside load ");
|
37828
|
+
if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
|
37570
37829
|
if (this.loaded) return;
|
37571
37830
|
var configUrl = CONFIG_URL;
|
37572
37831
|
|
@@ -37633,22 +37892,11 @@
|
|
37633
37892
|
this.registerCallbacks(true);
|
37634
37893
|
}
|
37635
37894
|
|
37636
|
-
if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) == "object") {
|
37637
|
-
this.eventRepository.startQueue(options.queueOptions);
|
37638
|
-
} else {
|
37639
|
-
this.eventRepository.startQueue({});
|
37640
|
-
}
|
37641
|
-
|
37642
37895
|
if (options && options.loadIntegration != undefined) {
|
37643
37896
|
this.loadIntegration = !!options.loadIntegration;
|
37644
37897
|
}
|
37645
37898
|
|
37646
|
-
this.eventRepository.writeKey
|
37647
|
-
|
37648
|
-
if (serverUrl) {
|
37649
|
-
this.eventRepository.url = serverUrl;
|
37650
|
-
}
|
37651
|
-
|
37899
|
+
this.eventRepository.initialize(writeKey, serverUrl, options);
|
37652
37900
|
this.initializeUser();
|
37653
37901
|
this.setInitialPageProperties();
|
37654
37902
|
this.loaded = true;
|