rudder-sdk-js 1.2.14 → 1.2.20
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 +23 -0
- package/index.js +597 -143
- package/package.json +1 -1
package/index.d.ts
CHANGED
@@ -29,6 +29,26 @@ declare module "rudder-sdk-js" {
|
|
29
29
|
maxItems?: number;
|
30
30
|
}
|
31
31
|
|
32
|
+
/**
|
33
|
+
* Represents the beacon queue options parameter in loadOptions type
|
34
|
+
*/
|
35
|
+
interface beaconQueueOptions {
|
36
|
+
// Maximum number of events in storage
|
37
|
+
maxItems?: number;
|
38
|
+
// Time in milliseconds to flush the queue autometically
|
39
|
+
flushQueueInterval?: number;
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Represents the beacon queue options parameter in loadOptions type
|
44
|
+
*/
|
45
|
+
interface cookieConsentManager {
|
46
|
+
// OneTrust
|
47
|
+
oneTrust?: {
|
48
|
+
enabled: boolean;
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
32
52
|
/**
|
33
53
|
* Represents the options parameter in the load API
|
34
54
|
*/
|
@@ -51,6 +71,9 @@ declare module "rudder-sdk-js" {
|
|
51
71
|
sendAdblockPage?: boolean;
|
52
72
|
sendAdblockPageOptions?: apiOptions;
|
53
73
|
clientSuppliedCallbacks?: { string: () => void };
|
74
|
+
useBeacon?: boolean; // Defaults to false
|
75
|
+
beaconQueueOptions?: beaconQueueOptions;
|
76
|
+
cookieConsentManager?: cookieConsentManager;
|
54
77
|
}
|
55
78
|
|
56
79
|
/**
|
package/index.js
CHANGED
@@ -5464,7 +5464,12 @@
|
|
5464
5464
|
"Post Affiliate Pro": "POST_AFFILIATE_PRO",
|
5465
5465
|
postaffiliatepro: "POST_AFFILIATE_PRO",
|
5466
5466
|
POSTAFFILIATEPRO: "POST_AFFILIATE_PRO",
|
5467
|
-
POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO"
|
5467
|
+
POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO",
|
5468
|
+
LaunchDarkly: "LAUNCHDARKLY",
|
5469
|
+
Launch_Darkly: "LAUNCHDARKLY",
|
5470
|
+
LAUNCHDARKLY: "LAUNCHDARKLY",
|
5471
|
+
"Launch Darkly": "LAUNCHDARKLY",
|
5472
|
+
launchDarkly: "LAUNCHDARKLY"
|
5468
5473
|
};
|
5469
5474
|
|
5470
5475
|
// from client native integration name to server identified display name
|
@@ -5511,7 +5516,8 @@
|
|
5511
5516
|
QUALTRICS: "Qualtrics",
|
5512
5517
|
SENTRY: "Sentry",
|
5513
5518
|
GOOGLE_OPTIMIZE: "GoogleOptimize",
|
5514
|
-
POST_AFFILIATE_PRO: "PostAffiliatePro"
|
5519
|
+
POST_AFFILIATE_PRO: "PostAffiliatePro",
|
5520
|
+
LAUNCHDARKLY: "LaunchDarkly"
|
5515
5521
|
};
|
5516
5522
|
|
5517
5523
|
// Reserved Keywords for properties/triats
|
@@ -5555,7 +5561,7 @@
|
|
5555
5561
|
PRODUCT_REVIEWED: "Product Reviewed"
|
5556
5562
|
}; // Enumeration for integrations supported
|
5557
5563
|
|
5558
|
-
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.
|
5564
|
+
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.20";
|
5559
5565
|
var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
|
5560
5566
|
var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
|
5561
5567
|
/* module.exports = {
|
@@ -11507,6 +11513,10 @@
|
|
11507
11513
|
if (Store.enabled) {
|
11508
11514
|
this.storage = Store;
|
11509
11515
|
}
|
11516
|
+
|
11517
|
+
if (!this.storage) {
|
11518
|
+
throw Error("Could not initialize the SDK :: no storage is available");
|
11519
|
+
}
|
11510
11520
|
}
|
11511
11521
|
|
11512
11522
|
_createClass(Storage, [{
|
@@ -22868,10 +22878,17 @@
|
|
22868
22878
|
js.async = async === undefined ? defaultAsyncState : async;
|
22869
22879
|
js.type = "text/javascript";
|
22870
22880
|
js.id = id;
|
22871
|
-
var
|
22872
|
-
|
22873
|
-
|
22874
|
-
|
22881
|
+
var headElmColl = document.getElementsByTagName("head");
|
22882
|
+
|
22883
|
+
if (headElmColl.length !== 0) {
|
22884
|
+
logger.debug("==adding script==", js);
|
22885
|
+
headElmColl[0].insertBefore(js, headElmColl[0].firstChild);
|
22886
|
+
} else {
|
22887
|
+
var e = document.getElementsByTagName("script")[0];
|
22888
|
+
logger.debug("==parent script==", e);
|
22889
|
+
logger.debug("==adding script==", js);
|
22890
|
+
e.parentNode.insertBefore(js, e);
|
22891
|
+
}
|
22875
22892
|
};
|
22876
22893
|
|
22877
22894
|
var AdobeAnalytics = /*#__PURE__*/function () {
|
@@ -27537,12 +27554,13 @@
|
|
27537
27554
|
camelcase.default = default_1;
|
27538
27555
|
|
27539
27556
|
var Fullstory = /*#__PURE__*/function () {
|
27540
|
-
function Fullstory(config) {
|
27557
|
+
function Fullstory(config, analytics) {
|
27541
27558
|
_classCallCheck(this, Fullstory);
|
27542
27559
|
|
27543
27560
|
this.fs_org = config.fs_org;
|
27544
27561
|
this.fs_debug_mode = config.fs_debug_mode;
|
27545
27562
|
this.name = "FULLSTORY";
|
27563
|
+
this.analytics = analytics;
|
27546
27564
|
}
|
27547
27565
|
|
27548
27566
|
_createClass(Fullstory, [{
|
@@ -27628,6 +27646,85 @@
|
|
27628
27646
|
return g._w[y].apply(this, arguments);
|
27629
27647
|
};
|
27630
27648
|
})(window, document, window._fs_namespace, "script", "user");
|
27649
|
+
|
27650
|
+
var FULLSTORY = this.analytics.loadOnlyIntegrations.FULLSTORY; // Checking if crossDomainSupport is their or not.
|
27651
|
+
|
27652
|
+
if ((FULLSTORY === null || FULLSTORY === void 0 ? void 0 : FULLSTORY.crossDomainSupport) === true) {
|
27653
|
+
// This function will check if the customer hash is available or not in localStorage
|
27654
|
+
window._fs_identity = function () {
|
27655
|
+
if (window.localStorage) {
|
27656
|
+
var tata_customer_hash = window.localStorage.tata_customer_hash;
|
27657
|
+
|
27658
|
+
if (tata_customer_hash) {
|
27659
|
+
return {
|
27660
|
+
uid: tata_customer_hash,
|
27661
|
+
displayName: tata_customer_hash
|
27662
|
+
};
|
27663
|
+
}
|
27664
|
+
} else {
|
27665
|
+
logger.debug("Unable to access locaStorage");
|
27666
|
+
}
|
27667
|
+
|
27668
|
+
return null;
|
27669
|
+
};
|
27670
|
+
|
27671
|
+
(function () {
|
27672
|
+
function fs(api) {
|
27673
|
+
if (!window._fs_namespace) {
|
27674
|
+
console.error('FullStory unavailable, window["_fs_namespace"] must be defined');
|
27675
|
+
return undefined;
|
27676
|
+
}
|
27677
|
+
|
27678
|
+
return api ? window[window._fs_namespace][api] : window[window._fs_namespace];
|
27679
|
+
}
|
27680
|
+
|
27681
|
+
function waitUntil(predicateFn, callbackFn, timeout, timeoutFn) {
|
27682
|
+
var totalTime = 0;
|
27683
|
+
var delay = 64;
|
27684
|
+
|
27685
|
+
var resultFn = function resultFn() {
|
27686
|
+
if (typeof predicateFn === "function" && predicateFn()) {
|
27687
|
+
callbackFn();
|
27688
|
+
return;
|
27689
|
+
}
|
27690
|
+
|
27691
|
+
delay = Math.min(delay * 2, 1024);
|
27692
|
+
|
27693
|
+
if (totalTime > timeout) {
|
27694
|
+
if (timeoutFn) {
|
27695
|
+
timeoutFn();
|
27696
|
+
}
|
27697
|
+
}
|
27698
|
+
|
27699
|
+
totalTime += delay;
|
27700
|
+
setTimeout(resultFn, delay);
|
27701
|
+
};
|
27702
|
+
|
27703
|
+
resultFn();
|
27704
|
+
} // Checking if timeout is provided or not.
|
27705
|
+
|
27706
|
+
|
27707
|
+
var timeout = FULLSTORY.timeout || 2000;
|
27708
|
+
|
27709
|
+
function identify() {
|
27710
|
+
if (typeof window._fs_identity === "function") {
|
27711
|
+
var userVars = window._fs_identity();
|
27712
|
+
|
27713
|
+
if (_typeof(userVars) === "object" && typeof userVars.uid === "string") {
|
27714
|
+
fs("setUserVars")(userVars);
|
27715
|
+
fs("restart")();
|
27716
|
+
} else {
|
27717
|
+
fs("log")("error", "FS.setUserVars requires an object that contains uid");
|
27718
|
+
}
|
27719
|
+
} else {
|
27720
|
+
fs("log")("error", 'window["_fs_identity"] function not found');
|
27721
|
+
}
|
27722
|
+
}
|
27723
|
+
|
27724
|
+
fs("shutdown")();
|
27725
|
+
waitUntil(window._fs_identity, identify, timeout, fs("restart"));
|
27726
|
+
})();
|
27727
|
+
}
|
27631
27728
|
}
|
27632
27729
|
}, {
|
27633
27730
|
key: "page",
|
@@ -29481,8 +29578,7 @@
|
|
29481
29578
|
function Hotjar(config) {
|
29482
29579
|
_classCallCheck(this, Hotjar);
|
29483
29580
|
|
29484
|
-
this.siteId = config.siteID;
|
29485
|
-
|
29581
|
+
this.siteId = config.siteID;
|
29486
29582
|
this.name = "HOTJAR";
|
29487
29583
|
this._ready = false;
|
29488
29584
|
}
|
@@ -29490,6 +29586,7 @@
|
|
29490
29586
|
_createClass(Hotjar, [{
|
29491
29587
|
key: "init",
|
29492
29588
|
value: function init() {
|
29589
|
+
logger.debug("===In init Hotjar===");
|
29493
29590
|
window.hotjarSiteId = this.siteId;
|
29494
29591
|
|
29495
29592
|
(function (h, o, t, j, a, r) {
|
@@ -29509,11 +29606,11 @@
|
|
29509
29606
|
})(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv=");
|
29510
29607
|
|
29511
29608
|
this._ready = true;
|
29512
|
-
logger.debug("===in init Hotjar===");
|
29513
29609
|
}
|
29514
29610
|
}, {
|
29515
29611
|
key: "identify",
|
29516
29612
|
value: function identify(rudderElement) {
|
29613
|
+
logger.debug("===In Hotjar identify===");
|
29517
29614
|
var userId = rudderElement.message.userId || rudderElement.message.anonymousId;
|
29518
29615
|
|
29519
29616
|
if (!userId) {
|
@@ -29527,21 +29624,34 @@
|
|
29527
29624
|
}, {
|
29528
29625
|
key: "track",
|
29529
29626
|
value: function track(rudderElement) {
|
29530
|
-
logger.debug("
|
29627
|
+
logger.debug("===In Hotjar track===");
|
29628
|
+
var event = rudderElement.message.event;
|
29629
|
+
|
29630
|
+
if (!event) {
|
29631
|
+
logger.error("Event name not present");
|
29632
|
+
return;
|
29633
|
+
} // event name must not exceed 750 characters and can only contain alphanumeric, underscores, and dashes.
|
29634
|
+
// Ref - https://help.hotjar.com/hc/en-us/articles/4405109971095#the-events-api-call
|
29635
|
+
|
29636
|
+
|
29637
|
+
window.hj("event", event.replace(/\s\s+/g, " ").substring(0, 750).replaceAll(" ", "_"));
|
29531
29638
|
}
|
29532
29639
|
}, {
|
29533
29640
|
key: "page",
|
29534
|
-
value: function page(
|
29641
|
+
value: function page() {
|
29642
|
+
logger.debug("===In Hotjar page===");
|
29535
29643
|
logger.debug("[Hotjar] page:: method not supported");
|
29536
29644
|
}
|
29537
29645
|
}, {
|
29538
29646
|
key: "isLoaded",
|
29539
29647
|
value: function isLoaded() {
|
29648
|
+
logger.debug("===In isLoaded Hotjar===");
|
29540
29649
|
return this._ready;
|
29541
29650
|
}
|
29542
29651
|
}, {
|
29543
29652
|
key: "isReady",
|
29544
29653
|
value: function isReady() {
|
29654
|
+
logger.debug("===In isReady Hotjar===");
|
29545
29655
|
return this._ready;
|
29546
29656
|
}
|
29547
29657
|
}]);
|
@@ -32667,10 +32777,11 @@
|
|
32667
32777
|
this.disableCookie = config.disableCookie || false;
|
32668
32778
|
this.propertyBlackList = [];
|
32669
32779
|
this.xhrHeaders = {};
|
32780
|
+
this.enableLocalStoragePersistence = config.enableLocalStoragePersistence;
|
32670
32781
|
|
32671
32782
|
if (config.xhrHeaders && config.xhrHeaders.length > 0) {
|
32672
32783
|
config.xhrHeaders.forEach(function (header) {
|
32673
|
-
if (header && header.key && header.value && header.key.trim()
|
32784
|
+
if (header && header.key && header.value && header.key.trim() !== "" && header.value.trim() !== "") {
|
32674
32785
|
_this.xhrHeaders[header.key] = header.value;
|
32675
32786
|
}
|
32676
32787
|
});
|
@@ -32678,7 +32789,7 @@
|
|
32678
32789
|
|
32679
32790
|
if (config.propertyBlackList && config.propertyBlackList.length > 0) {
|
32680
32791
|
config.propertyBlackList.forEach(function (element) {
|
32681
|
-
if (element && element.property && element.property.trim()
|
32792
|
+
if (element && element.property && element.property.trim() !== "") {
|
32682
32793
|
_this.propertyBlackList.push(element.property);
|
32683
32794
|
}
|
32684
32795
|
});
|
@@ -32726,6 +32837,10 @@
|
|
32726
32837
|
configObject.xhr_headers = this.xhrHeaders;
|
32727
32838
|
}
|
32728
32839
|
|
32840
|
+
if (this.enableLocalStoragePersistence) {
|
32841
|
+
configObject.persistence = "localStorage+cookie";
|
32842
|
+
}
|
32843
|
+
|
32729
32844
|
posthog.init(this.teamApiKey, configObject);
|
32730
32845
|
}
|
32731
32846
|
/**
|
@@ -32755,7 +32870,7 @@
|
|
32755
32870
|
|
32756
32871
|
if (unsetProperties && unsetProperties.length > 0) {
|
32757
32872
|
unsetProperties.forEach(function (property) {
|
32758
|
-
if (property && property.trim()
|
32873
|
+
if (property && property.trim() !== "") {
|
32759
32874
|
posthog.unregister(property);
|
32760
32875
|
}
|
32761
32876
|
});
|
@@ -32787,7 +32902,7 @@
|
|
32787
32902
|
posthog.capture(event, properties);
|
32788
32903
|
}
|
32789
32904
|
/**
|
32790
|
-
*
|
32905
|
+
*
|
32791
32906
|
*
|
32792
32907
|
* @memberof Posthog
|
32793
32908
|
*/
|
@@ -34187,6 +34302,100 @@
|
|
34187
34302
|
return PostAffiliatePro;
|
34188
34303
|
}();
|
34189
34304
|
|
34305
|
+
var createUser = function createUser(message) {
|
34306
|
+
var user = {};
|
34307
|
+
user.key = message.userId || message.anonymousId;
|
34308
|
+
var traits = message.context.traits;
|
34309
|
+
|
34310
|
+
if (traits.anonymous !== undefined) {
|
34311
|
+
user.anonymous = traits.anonymous;
|
34312
|
+
}
|
34313
|
+
|
34314
|
+
if (traits.avatar !== undefined) user.avatar = traits.avatar;
|
34315
|
+
if (traits.country !== undefined) user.country = traits.country;
|
34316
|
+
if (traits.custom !== undefined) user.custom = traits.custom;
|
34317
|
+
if (traits.email !== undefined) user.email = traits.email;
|
34318
|
+
if (traits.firstName !== undefined) user.firstName = traits.firstName;
|
34319
|
+
if (traits.ip !== undefined) user.ip = traits.ip;
|
34320
|
+
if (traits.lastName !== undefined) user.lastName = traits.lastName;
|
34321
|
+
if (traits.name !== undefined) user.name = traits.name;
|
34322
|
+
if (traits.privateAttributeNames !== undefined) user.privateAttributeNames = traits.privateAttributeNames;
|
34323
|
+
if (traits.secondary !== undefined) user.secondary = traits.secondary;
|
34324
|
+
return user;
|
34325
|
+
};
|
34326
|
+
|
34327
|
+
var LaunchDarkly = /*#__PURE__*/function () {
|
34328
|
+
function LaunchDarkly(config) {
|
34329
|
+
_classCallCheck(this, LaunchDarkly);
|
34330
|
+
|
34331
|
+
this.name = "LaunchDarkly";
|
34332
|
+
this.clientSideId = config.clientSideId;
|
34333
|
+
}
|
34334
|
+
|
34335
|
+
_createClass(LaunchDarkly, [{
|
34336
|
+
key: "init",
|
34337
|
+
value: function init() {
|
34338
|
+
logger.debug("===in init LaunchDarkly===");
|
34339
|
+
|
34340
|
+
if (!this.clientSideId) {
|
34341
|
+
logger.error("".concat(this.name, " :: Unable to initialize destination - clientSideId is missing in config"));
|
34342
|
+
return;
|
34343
|
+
}
|
34344
|
+
|
34345
|
+
ScriptLoader(null, "https://unpkg.com/launchdarkly-js-client-sdk@2");
|
34346
|
+
}
|
34347
|
+
}, {
|
34348
|
+
key: "isLoaded",
|
34349
|
+
value: function isLoaded() {
|
34350
|
+
logger.debug("===In isLoaded LaunchDarkly===");
|
34351
|
+
return !!window.LDClient;
|
34352
|
+
}
|
34353
|
+
}, {
|
34354
|
+
key: "isReady",
|
34355
|
+
value: function isReady() {
|
34356
|
+
logger.debug("===In isReady LaunchDarkly===");
|
34357
|
+
return this.isLoaded();
|
34358
|
+
}
|
34359
|
+
}, {
|
34360
|
+
key: "identify",
|
34361
|
+
value: function identify(rudderElement) {
|
34362
|
+
var message = rudderElement.message;
|
34363
|
+
window.user = createUser(message);
|
34364
|
+
|
34365
|
+
if (window.ldclient) {
|
34366
|
+
window.ldclient.identify(window.user);
|
34367
|
+
} else {
|
34368
|
+
window.ldclient = window.LDClient.initialize(this.clientSideId, window.user);
|
34369
|
+
}
|
34370
|
+
}
|
34371
|
+
}, {
|
34372
|
+
key: "track",
|
34373
|
+
value: function track(rudderElement) {
|
34374
|
+
var _rudderElement$messag = rudderElement.message,
|
34375
|
+
event = _rudderElement$messag.event,
|
34376
|
+
properties = _rudderElement$messag.properties;
|
34377
|
+
|
34378
|
+
if (window.ldclient) {
|
34379
|
+
window.ldclient.track(event, properties);
|
34380
|
+
} else logger.error("=== In LaunchDarkly, track is not supported before identify ===");
|
34381
|
+
}
|
34382
|
+
}, {
|
34383
|
+
key: "alias",
|
34384
|
+
value: function alias(rudderElement) {
|
34385
|
+
var message = rudderElement.message;
|
34386
|
+
var newUser = {
|
34387
|
+
key: message.userId
|
34388
|
+
};
|
34389
|
+
|
34390
|
+
if (window.ldclient) {
|
34391
|
+
window.ldclient.alias(newUser, window.user);
|
34392
|
+
} else logger.error("=== In LaunchDarkly, alias is not supported before identify ===");
|
34393
|
+
}
|
34394
|
+
}]);
|
34395
|
+
|
34396
|
+
return LaunchDarkly;
|
34397
|
+
}();
|
34398
|
+
|
34190
34399
|
// (config-plan name, native destination.name , exported integration name(this one below))
|
34191
34400
|
|
34192
34401
|
var integrations = {
|
@@ -34233,7 +34442,8 @@
|
|
34233
34442
|
TVSQUARED: TVSquared,
|
34234
34443
|
VWO: VWO,
|
34235
34444
|
GOOGLE_OPTIMIZE: GoogleOptimize,
|
34236
|
-
POST_AFFILIATE_PRO: PostAffiliatePro
|
34445
|
+
POST_AFFILIATE_PRO: PostAffiliatePro,
|
34446
|
+
LAUNCHDARKLY: LaunchDarkly
|
34237
34447
|
};
|
34238
34448
|
|
34239
34449
|
// Application class
|
@@ -34243,7 +34453,7 @@
|
|
34243
34453
|
this.build = "1.0.0";
|
34244
34454
|
this.name = "RudderLabs JavaScript SDK";
|
34245
34455
|
this.namespace = "com.rudderlabs.javascript";
|
34246
|
-
this.version = "1.2.
|
34456
|
+
this.version = "1.2.20";
|
34247
34457
|
});
|
34248
34458
|
|
34249
34459
|
// Library information class
|
@@ -34251,7 +34461,7 @@
|
|
34251
34461
|
_classCallCheck(this, RudderLibraryInfo);
|
34252
34462
|
|
34253
34463
|
this.name = "RudderLabs JavaScript SDK";
|
34254
|
-
this.version = "1.2.
|
34464
|
+
this.version = "1.2.20";
|
34255
34465
|
}); // Operating System information class
|
34256
34466
|
|
34257
34467
|
|
@@ -35940,14 +36150,6 @@
|
|
35940
36150
|
|
35941
36151
|
var lib$2 = Queue;
|
35942
36152
|
|
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
36153
|
var queueOptions = {
|
35952
36154
|
maxRetryDelay: 360000,
|
35953
36155
|
minRetryDelay: 1000,
|
@@ -35955,34 +36157,21 @@
|
|
35955
36157
|
maxAttempts: 10,
|
35956
36158
|
maxItems: 100
|
35957
36159
|
};
|
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
36160
|
|
35967
|
-
var
|
35968
|
-
|
35969
|
-
|
35970
|
-
* @memberof EventRepository
|
35971
|
-
*/
|
35972
|
-
function EventRepository(options) {
|
35973
|
-
_classCallCheck(this, EventRepository);
|
36161
|
+
var XHRQueue = /*#__PURE__*/function () {
|
36162
|
+
function XHRQueue() {
|
36163
|
+
_classCallCheck(this, XHRQueue);
|
35974
36164
|
|
35975
|
-
this.eventsBuffer = [];
|
35976
|
-
this.writeKey = "";
|
35977
36165
|
this.url = "";
|
35978
|
-
this.
|
35979
|
-
this.batchSize = 0; // previous implementation
|
35980
|
-
// setInterval(this.preaparePayloadAndFlush, FLUSH_INTERVAL_DEFAULT, this);
|
36166
|
+
this.writeKey = "";
|
35981
36167
|
}
|
35982
36168
|
|
35983
|
-
_createClass(
|
35984
|
-
key: "
|
35985
|
-
value: function
|
36169
|
+
_createClass(XHRQueue, [{
|
36170
|
+
key: "init",
|
36171
|
+
value: function init(writeKey, url, options) {
|
36172
|
+
this.url = url;
|
36173
|
+
this.writeKey = writeKey;
|
36174
|
+
|
35986
36175
|
if (options) {
|
35987
36176
|
// TODO: add checks for value - has to be +ve?
|
35988
36177
|
_extends(queueOptions, options);
|
@@ -35991,79 +36180,20 @@
|
|
35991
36180
|
this.payloadQueue = new lib$2("rudder", queueOptions, function (item, done) {
|
35992
36181
|
// apply sentAt at flush time and reset on each retry
|
35993
36182
|
item.message.sentAt = getCurrentTimeFormatted(); // send this item for processing, with a callback to enable queue to get the done status
|
36183
|
+
// eslint-disable-next-line no-use-before-define
|
35994
36184
|
|
35995
|
-
|
36185
|
+
this.processQueueElement(item.url, item.headers, item.message, 10 * 1000, // eslint-disable-next-line consistent-return
|
36186
|
+
function (err, res) {
|
35996
36187
|
if (err) {
|
35997
36188
|
return done(err);
|
35998
36189
|
}
|
35999
36190
|
|
36000
36191
|
done(null, res);
|
36001
36192
|
});
|
36002
|
-
}); // start queue
|
36193
|
+
}.bind(this)); // start queue
|
36003
36194
|
|
36004
36195
|
this.payloadQueue.start();
|
36005
36196
|
}
|
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
36197
|
/**
|
36068
36198
|
* the queue item proceesor
|
36069
36199
|
* @param {*} url to send requests to
|
@@ -36105,6 +36235,216 @@
|
|
36105
36235
|
queueFn(error);
|
36106
36236
|
}
|
36107
36237
|
}
|
36238
|
+
}, {
|
36239
|
+
key: "enqueue",
|
36240
|
+
value: function enqueue(message, type) {
|
36241
|
+
var headers = {
|
36242
|
+
"Content-Type": "application/json",
|
36243
|
+
Authorization: "Basic ".concat(btoa("".concat(this.writeKey, ":"))),
|
36244
|
+
AnonymousId: btoa(message.anonymousId)
|
36245
|
+
}; // add items to the queue
|
36246
|
+
|
36247
|
+
this.payloadQueue.addItem({
|
36248
|
+
url: "".concat(this.url, "/v1/").concat(type),
|
36249
|
+
headers: headers,
|
36250
|
+
message: message
|
36251
|
+
});
|
36252
|
+
}
|
36253
|
+
}]);
|
36254
|
+
|
36255
|
+
return XHRQueue;
|
36256
|
+
}();
|
36257
|
+
|
36258
|
+
var defaults$3 = {
|
36259
|
+
queue: "queue",
|
36260
|
+
maxPayloadSize: 64 * 1000
|
36261
|
+
};
|
36262
|
+
|
36263
|
+
var BeaconQueue = /*#__PURE__*/function () {
|
36264
|
+
function BeaconQueue() {
|
36265
|
+
_classCallCheck(this, BeaconQueue);
|
36266
|
+
|
36267
|
+
this.storage = Store;
|
36268
|
+
this.maxItems = 10;
|
36269
|
+
this.flushQueueTimeOut = undefined;
|
36270
|
+
this.timeOutActive = false;
|
36271
|
+
this.flushQueueTimeOutInterval = 1000 * 60 * 10; // 10 mins
|
36272
|
+
|
36273
|
+
this.url = "";
|
36274
|
+
this.writekey = "";
|
36275
|
+
this.queueName = "".concat(defaults$3.queue, ".").concat(Date.now());
|
36276
|
+
}
|
36277
|
+
|
36278
|
+
_createClass(BeaconQueue, [{
|
36279
|
+
key: "sendQueueDataForBeacon",
|
36280
|
+
value: function sendQueueDataForBeacon() {
|
36281
|
+
this.sendDataFromQueueAndDestroyQueue();
|
36282
|
+
}
|
36283
|
+
}, {
|
36284
|
+
key: "init",
|
36285
|
+
value: function init(writekey, url, options) {
|
36286
|
+
this.url = url;
|
36287
|
+
this.writekey = writekey;
|
36288
|
+
if (options.maxItems) this.maxItems = options.maxItems;
|
36289
|
+
if (options.flushQueueInterval) this.flushQueueTimeOutInterval = options.flushQueueInterval;
|
36290
|
+
var sendQueueData = this.sendQueueDataForBeacon.bind(this);
|
36291
|
+
window.addEventListener("unload", sendQueueData);
|
36292
|
+
}
|
36293
|
+
}, {
|
36294
|
+
key: "getQueue",
|
36295
|
+
value: function getQueue() {
|
36296
|
+
return this.storage.get(this.queueName);
|
36297
|
+
}
|
36298
|
+
}, {
|
36299
|
+
key: "setQueue",
|
36300
|
+
value: function setQueue(value) {
|
36301
|
+
this.storage.set(this.queueName, value);
|
36302
|
+
}
|
36303
|
+
/**
|
36304
|
+
*
|
36305
|
+
* Utility method for excluding null and empty values in JSON
|
36306
|
+
* @param {*} _key
|
36307
|
+
* @param {*} value
|
36308
|
+
* @returns
|
36309
|
+
*/
|
36310
|
+
|
36311
|
+
}, {
|
36312
|
+
key: "replacer",
|
36313
|
+
value: function replacer(_key, value) {
|
36314
|
+
if (value === null || value === undefined) {
|
36315
|
+
return undefined;
|
36316
|
+
}
|
36317
|
+
|
36318
|
+
return value;
|
36319
|
+
}
|
36320
|
+
}, {
|
36321
|
+
key: "enqueue",
|
36322
|
+
value: function enqueue(message) {
|
36323
|
+
var queue = this.getQueue() || [];
|
36324
|
+
queue = queue.slice(-(this.maxItems - 1));
|
36325
|
+
queue.push(message);
|
36326
|
+
var batch = queue.slice(0);
|
36327
|
+
var data = {
|
36328
|
+
batch: batch
|
36329
|
+
};
|
36330
|
+
var dataToSend = JSON.stringify(data, this.replacer);
|
36331
|
+
|
36332
|
+
if (dataToSend.length > defaults$3.maxPayloadSize) {
|
36333
|
+
batch = queue.slice(0, queue.length - 1);
|
36334
|
+
this.flushQueue(batch);
|
36335
|
+
queue = this.getQueue();
|
36336
|
+
queue.push(message);
|
36337
|
+
}
|
36338
|
+
|
36339
|
+
this.setQueue(queue);
|
36340
|
+
this.setTimer();
|
36341
|
+
|
36342
|
+
if (queue.length === this.maxItems) {
|
36343
|
+
this.flushQueue(batch);
|
36344
|
+
}
|
36345
|
+
}
|
36346
|
+
}, {
|
36347
|
+
key: "sendDataFromQueueAndDestroyQueue",
|
36348
|
+
value: function sendDataFromQueueAndDestroyQueue() {
|
36349
|
+
this.sendDataFromQueue();
|
36350
|
+
this.storage.remove(this.queueName);
|
36351
|
+
}
|
36352
|
+
}, {
|
36353
|
+
key: "sendDataFromQueue",
|
36354
|
+
value: function sendDataFromQueue() {
|
36355
|
+
var queue = this.getQueue();
|
36356
|
+
|
36357
|
+
if (queue && queue.length > 0) {
|
36358
|
+
var batch = queue.slice(0, queue.length);
|
36359
|
+
this.flushQueue(batch);
|
36360
|
+
}
|
36361
|
+
}
|
36362
|
+
}, {
|
36363
|
+
key: "flushQueue",
|
36364
|
+
value: function flushQueue(batch) {
|
36365
|
+
batch.map(function (event) {
|
36366
|
+
event.sentAt = new Date().toISOString();
|
36367
|
+
});
|
36368
|
+
var data = {
|
36369
|
+
batch: batch
|
36370
|
+
};
|
36371
|
+
var payload = JSON.stringify(data, this.replacer);
|
36372
|
+
var blob = new Blob([payload], {
|
36373
|
+
type: "application/json"
|
36374
|
+
});
|
36375
|
+
var isPushed = navigator.sendBeacon("".concat(this.url, "?writeKey=").concat(this.writekey), blob);
|
36376
|
+
|
36377
|
+
if (!isPushed) {
|
36378
|
+
logger.debug("Unable to send data");
|
36379
|
+
}
|
36380
|
+
|
36381
|
+
this.setQueue([]);
|
36382
|
+
this.clearTimer();
|
36383
|
+
}
|
36384
|
+
}, {
|
36385
|
+
key: "setTimer",
|
36386
|
+
value: function setTimer() {
|
36387
|
+
if (!this.timeOutActive) {
|
36388
|
+
this.flushQueueTimeOut = setTimeout(this.sendDataFromQueue.bind(this), this.flushQueueTimeOutInterval);
|
36389
|
+
this.timeOutActive = true;
|
36390
|
+
}
|
36391
|
+
}
|
36392
|
+
}, {
|
36393
|
+
key: "clearTimer",
|
36394
|
+
value: function clearTimer() {
|
36395
|
+
if (this.timeOutActive) {
|
36396
|
+
clearTimeout(this.flushQueueTimeOut);
|
36397
|
+
this.timeOutActive = false;
|
36398
|
+
}
|
36399
|
+
}
|
36400
|
+
}]);
|
36401
|
+
|
36402
|
+
return BeaconQueue;
|
36403
|
+
}();
|
36404
|
+
|
36405
|
+
var MESSAGE_LENGTH = 32 * 1000; // ~32 Kb
|
36406
|
+
|
36407
|
+
/**
|
36408
|
+
*
|
36409
|
+
* @class EventRepository responsible for adding events into
|
36410
|
+
* flush queue and sending data to rudder backend
|
36411
|
+
* in batch and maintains order of the event.
|
36412
|
+
*/
|
36413
|
+
|
36414
|
+
var EventRepository = /*#__PURE__*/function () {
|
36415
|
+
/**
|
36416
|
+
*Creates an instance of EventRepository.
|
36417
|
+
* @memberof EventRepository
|
36418
|
+
*/
|
36419
|
+
function EventRepository() {
|
36420
|
+
_classCallCheck(this, EventRepository);
|
36421
|
+
|
36422
|
+
this.queue = undefined;
|
36423
|
+
}
|
36424
|
+
|
36425
|
+
_createClass(EventRepository, [{
|
36426
|
+
key: "initialize",
|
36427
|
+
value: function initialize(writeKey, url, options) {
|
36428
|
+
var queueOptions = {};
|
36429
|
+
var targetUrl = url.slice(-1) === "/" ? url.slice(0, -1) : url;
|
36430
|
+
|
36431
|
+
if (options && options.useBeacon) {
|
36432
|
+
if (options && options.beaconQueueOptions && options.beaconQueueOptions != null && _typeof(options.beaconQueueOptions) === "object") {
|
36433
|
+
queueOptions = options.beaconQueueOptions;
|
36434
|
+
}
|
36435
|
+
|
36436
|
+
targetUrl = "".concat(targetUrl, "/beacon/v1/batch");
|
36437
|
+
this.queue = new BeaconQueue();
|
36438
|
+
} else {
|
36439
|
+
if (options && options.queueOptions && options.queueOptions != null && _typeof(options.queueOptions) === "object") {
|
36440
|
+
queueOptions = options.queueOptions;
|
36441
|
+
}
|
36442
|
+
|
36443
|
+
this.queue = new XHRQueue();
|
36444
|
+
}
|
36445
|
+
|
36446
|
+
this.queue.init(writeKey, targetUrl, queueOptions);
|
36447
|
+
}
|
36108
36448
|
/**
|
36109
36449
|
*
|
36110
36450
|
*
|
@@ -36116,34 +36456,22 @@
|
|
36116
36456
|
key: "enqueue",
|
36117
36457
|
value: function enqueue(rudderElement, type) {
|
36118
36458
|
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
36459
|
message.originalTimestamp = getCurrentTimeFormatted();
|
36125
36460
|
message.sentAt = getCurrentTimeFormatted(); // add this, will get modified when actually being sent
|
36126
36461
|
// check message size, if greater log an error
|
36127
36462
|
|
36128
36463
|
if (JSON.stringify(message).length > MESSAGE_LENGTH) {
|
36129
36464
|
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
|
36465
|
+
}
|
36134
36466
|
|
36135
|
-
this.
|
36136
|
-
url: "".concat(url, "/v1/").concat(type),
|
36137
|
-
headers: headers,
|
36138
|
-
message: message
|
36139
|
-
});
|
36467
|
+
this.queue.enqueue(message, type);
|
36140
36468
|
}
|
36141
36469
|
}]);
|
36142
36470
|
|
36143
36471
|
return EventRepository;
|
36144
36472
|
}();
|
36145
36473
|
|
36146
|
-
var eventRepository = new EventRepository();
|
36474
|
+
var eventRepository = new EventRepository(); // eslint-disable-next-line import/prefer-default-export
|
36147
36475
|
|
36148
36476
|
function addDomEventHandlers(rudderanalytics) {
|
36149
36477
|
var handler = function handler(e) {
|
@@ -36770,6 +37098,130 @@
|
|
36770
37098
|
return Math.floor(Date.now() / 60000);
|
36771
37099
|
}
|
36772
37100
|
|
37101
|
+
/* eslint-disable class-methods-use-this */
|
37102
|
+
|
37103
|
+
var OneTrust = /*#__PURE__*/function () {
|
37104
|
+
function OneTrust(sourceConfig) {
|
37105
|
+
var _this = this;
|
37106
|
+
|
37107
|
+
_classCallCheck(this, OneTrust);
|
37108
|
+
|
37109
|
+
this.sourceConfig = sourceConfig; // If user does not load onetrust sdk before loading rudderstack sdk
|
37110
|
+
// we will not be filtering any of the destinations.
|
37111
|
+
|
37112
|
+
if (!window.OneTrust || !window.OnetrustActiveGroups) {
|
37113
|
+
throw new Error("OneTrust resources are not accessible. Thus all the destinations will be loaded");
|
37114
|
+
} // OneTrust Cookie Compliance populates a data layer object OnetrustActiveGroups with
|
37115
|
+
// the cookie categories that the user has consented to.
|
37116
|
+
// Eg: ',C0001,C0003,'
|
37117
|
+
// We split it and save it as an array.
|
37118
|
+
|
37119
|
+
|
37120
|
+
var userSetConsentGroupIds = window.OnetrustActiveGroups.split(","); // Ids user has consented
|
37121
|
+
// Get information about the cookie script - data includes, consent models, cookies in preference centre, etc.
|
37122
|
+
// We get the groups(cookie categorization), user has created in one trust account.
|
37123
|
+
|
37124
|
+
var oneTrustAllGroupsInfo = window.OneTrust.GetDomainData().Groups;
|
37125
|
+
this.userSetConsentGroupNames = []; // Get the names of the cookies consented by the user in the browser.
|
37126
|
+
|
37127
|
+
oneTrustAllGroupsInfo.forEach(function (group) {
|
37128
|
+
var CustomGroupId = group.CustomGroupId,
|
37129
|
+
GroupName = group.GroupName;
|
37130
|
+
|
37131
|
+
if (userSetConsentGroupIds.includes(CustomGroupId)) {
|
37132
|
+
_this.userSetConsentGroupNames.push(GroupName.toUpperCase().trim());
|
37133
|
+
}
|
37134
|
+
});
|
37135
|
+
}
|
37136
|
+
|
37137
|
+
_createClass(OneTrust, [{
|
37138
|
+
key: "isEnabled",
|
37139
|
+
value: function isEnabled(destConfig) {
|
37140
|
+
var _this2 = this;
|
37141
|
+
|
37142
|
+
try {
|
37143
|
+
/**
|
37144
|
+
* Structure of onetrust consent group destination config.
|
37145
|
+
*
|
37146
|
+
* "oneTrustConsentGroup": [
|
37147
|
+
{
|
37148
|
+
"oneTrustConsentGroup": "Performance Cookies"
|
37149
|
+
},
|
37150
|
+
{
|
37151
|
+
"oneTrustConsentGroup": "Functional Cookies"
|
37152
|
+
},
|
37153
|
+
{
|
37154
|
+
"oneTrustConsentGroup": ""
|
37155
|
+
}
|
37156
|
+
]
|
37157
|
+
*
|
37158
|
+
*/
|
37159
|
+
var oneTrustCookieCategories = destConfig.oneTrustCookieCategories; // mapping of the destination with the consent group name
|
37160
|
+
// If the destination do not have this mapping events will be sent.
|
37161
|
+
|
37162
|
+
if (!oneTrustCookieCategories) {
|
37163
|
+
return true;
|
37164
|
+
} // Change the structure of oneTrustConsentGroup as an array and filter values if empty string
|
37165
|
+
// Eg:
|
37166
|
+
// ["Performance Cookies", "Functional Cookies"]
|
37167
|
+
|
37168
|
+
|
37169
|
+
var oneTrustConsentGroupArr = oneTrustCookieCategories.map(function (c) {
|
37170
|
+
return c.oneTrustCookieCategory;
|
37171
|
+
}).filter(function (n) {
|
37172
|
+
return n;
|
37173
|
+
});
|
37174
|
+
var containsAllConsent = true; // Check if all the destination's mapped cookie categories are consented by the user in the browser.
|
37175
|
+
|
37176
|
+
containsAllConsent = oneTrustConsentGroupArr.every(function (element) {
|
37177
|
+
return _this2.userSetConsentGroupNames.includes(element.toUpperCase().trim());
|
37178
|
+
});
|
37179
|
+
return containsAllConsent;
|
37180
|
+
} catch (e) {
|
37181
|
+
logger.error("Error during onetrust cookie consent management ".concat(e));
|
37182
|
+
return true;
|
37183
|
+
}
|
37184
|
+
}
|
37185
|
+
}]);
|
37186
|
+
|
37187
|
+
return OneTrust;
|
37188
|
+
}();
|
37189
|
+
|
37190
|
+
var CookieConsentFactory = /*#__PURE__*/function () {
|
37191
|
+
function CookieConsentFactory() {
|
37192
|
+
_classCallCheck(this, CookieConsentFactory);
|
37193
|
+
}
|
37194
|
+
|
37195
|
+
_createClass(CookieConsentFactory, null, [{
|
37196
|
+
key: "initialize",
|
37197
|
+
value: function initialize(cookieConsentOptions) {
|
37198
|
+
var _cookieConsentOptions;
|
37199
|
+
|
37200
|
+
/**
|
37201
|
+
*
|
37202
|
+
* check which type of cookie consent manager needs to be called if enabled
|
37203
|
+
* for now we have only OneTrust.
|
37204
|
+
* But if new cookie consent manager options are implemented,
|
37205
|
+
* we need to make sure only one of them is enabled by the user in the
|
37206
|
+
* load options
|
37207
|
+
*
|
37208
|
+
*/
|
37209
|
+
if (cookieConsentOptions !== null && cookieConsentOptions !== void 0 && (_cookieConsentOptions = cookieConsentOptions.oneTrust) !== null && _cookieConsentOptions !== void 0 && _cookieConsentOptions.enabled) {
|
37210
|
+
// This is P1. When we have an ui in source side to turn on/off of cookie consent
|
37211
|
+
// if (sourceConfig &&
|
37212
|
+
// sourceConfig.cookieConsentManager &&
|
37213
|
+
// sourceConfig.cookieConsentManager.oneTrust &&
|
37214
|
+
// sourceConfig.cookieConsentManager.oneTrustenabled) {
|
37215
|
+
return new OneTrust(); // }
|
37216
|
+
}
|
37217
|
+
|
37218
|
+
return null;
|
37219
|
+
}
|
37220
|
+
}]);
|
37221
|
+
|
37222
|
+
return CookieConsentFactory;
|
37223
|
+
}();
|
37224
|
+
|
36773
37225
|
var queryDefaults = {
|
36774
37226
|
trait: "ajs_trait_",
|
36775
37227
|
prop: "ajs_prop_"
|
@@ -36829,6 +37281,7 @@
|
|
36829
37281
|
};
|
36830
37282
|
this.loaded = false;
|
36831
37283
|
this.loadIntegration = true;
|
37284
|
+
this.cookieConsentOptions = {};
|
36832
37285
|
}
|
36833
37286
|
/**
|
36834
37287
|
* initialize the user after load config
|
@@ -36900,10 +37353,21 @@
|
|
36900
37353
|
}, this);
|
36901
37354
|
logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
|
36902
37355
|
|
36903
|
-
this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
|
37356
|
+
this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
|
37357
|
+
var cookieConsent; // Call the cookie consent factory to initialize and return the type of cookie
|
37358
|
+
// consent being set. For now we only support OneTrust.
|
37359
|
+
|
37360
|
+
try {
|
37361
|
+
cookieConsent = CookieConsentFactory.initialize(this.cookieConsentOptions);
|
37362
|
+
} catch (e) {
|
37363
|
+
logger.error(e);
|
37364
|
+
} // If cookie consent object is return we filter according to consents given by user
|
37365
|
+
// else we do not consider any filtering for cookie consent.
|
37366
|
+
|
36904
37367
|
|
36905
37368
|
this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
|
36906
|
-
return integrations[intg.name] != undefined
|
37369
|
+
return integrations[intg.name] != undefined && (!cookieConsent || // check if cookie consent object is present and then do filtering
|
37370
|
+
cookieConsent && cookieConsent.isEnabled(intg.config));
|
36907
37371
|
});
|
36908
37372
|
this.init(this.clientIntegrations);
|
36909
37373
|
} catch (error) {
|
@@ -37567,6 +38031,7 @@
|
|
37567
38031
|
var _this3 = this;
|
37568
38032
|
|
37569
38033
|
logger.debug("inside load ");
|
38034
|
+
if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
|
37570
38035
|
if (this.loaded) return;
|
37571
38036
|
var configUrl = CONFIG_URL;
|
37572
38037
|
|
@@ -37633,22 +38098,11 @@
|
|
37633
38098
|
this.registerCallbacks(true);
|
37634
38099
|
}
|
37635
38100
|
|
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
38101
|
if (options && options.loadIntegration != undefined) {
|
37643
38102
|
this.loadIntegration = !!options.loadIntegration;
|
37644
38103
|
}
|
37645
38104
|
|
37646
|
-
this.eventRepository.writeKey
|
37647
|
-
|
37648
|
-
if (serverUrl) {
|
37649
|
-
this.eventRepository.url = serverUrl;
|
37650
|
-
}
|
37651
|
-
|
38105
|
+
this.eventRepository.initialize(writeKey, serverUrl, options);
|
37652
38106
|
this.initializeUser();
|
37653
38107
|
this.setInitialPageProperties();
|
37654
38108
|
this.loaded = true;
|