rudder-sdk-js 1.2.20 → 1.3.0
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 +102 -25
- package/package.json +1 -1
package/index.js
CHANGED
@@ -5561,7 +5561,7 @@
|
|
5561
5561
|
PRODUCT_REVIEWED: "Product Reviewed"
|
5562
5562
|
}; // Enumeration for integrations supported
|
5563
5563
|
|
5564
|
-
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.
|
5564
|
+
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.3.0";
|
5565
5565
|
var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
|
5566
5566
|
var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
|
5567
5567
|
/* module.exports = {
|
@@ -29373,12 +29373,16 @@
|
|
29373
29373
|
|
29374
29374
|
this.containerID = config.containerID;
|
29375
29375
|
this.name = "GOOGLETAGMANAGER";
|
29376
|
+
this.serverUrl = config.serverUrl;
|
29376
29377
|
}
|
29377
29378
|
|
29378
29379
|
_createClass(GoogleTagManager, [{
|
29379
29380
|
key: "init",
|
29380
29381
|
value: function init() {
|
29381
29382
|
logger.debug("===in init GoogleTagManager===");
|
29383
|
+
var defaultUrl = "https://www.googletagmanager.com"; // ref: https://developers.google.com/tag-platform/tag-manager/server-side/send-data#update_the_gtmjs_source_domain
|
29384
|
+
|
29385
|
+
window.finalUrl = this.serverUrl ? this.serverUrl : defaultUrl;
|
29382
29386
|
|
29383
29387
|
(function (w, d, s, l, i) {
|
29384
29388
|
w[l] = w[l] || [];
|
@@ -29390,7 +29394,7 @@
|
|
29390
29394
|
var j = d.createElement(s);
|
29391
29395
|
var dl = l !== "dataLayer" ? "&l=".concat(l) : "";
|
29392
29396
|
j.async = true;
|
29393
|
-
j.src = "
|
29397
|
+
j.src = "".concat(window.finalUrl, "/gtm.js?id=").concat(i).concat(dl);
|
29394
29398
|
f.parentNode.insertBefore(j, f);
|
29395
29399
|
})(window, document, "script", "dataLayer", this.containerID);
|
29396
29400
|
}
|
@@ -32408,7 +32412,7 @@
|
|
32408
32412
|
}();
|
32409
32413
|
|
32410
32414
|
var eventMapping = [{
|
32411
|
-
src: ["
|
32415
|
+
src: ["order completed"],
|
32412
32416
|
dest: "Checkout"
|
32413
32417
|
}, {
|
32414
32418
|
src: ["product added"],
|
@@ -32824,6 +32828,7 @@
|
|
32824
32828
|
e._i.push([i, s, a]);
|
32825
32829
|
}, e.__SV = 1);
|
32826
32830
|
}(document, window.posthog || []);
|
32831
|
+
var POSTHOG = this.analytics.loadOnlyIntegrations.POSTHOG;
|
32827
32832
|
var configObject = {
|
32828
32833
|
api_host: this.yourInstance,
|
32829
32834
|
autocapture: this.autocapture,
|
@@ -32833,6 +32838,10 @@
|
|
32833
32838
|
disable_cookie: this.disableCookie
|
32834
32839
|
};
|
32835
32840
|
|
32841
|
+
if (POSTHOG && POSTHOG.loaded) {
|
32842
|
+
configObject.loaded = POSTHOG.loaded;
|
32843
|
+
}
|
32844
|
+
|
32836
32845
|
if (this.xhrHeaders && Object.keys(this.xhrHeaders).length > 0) {
|
32837
32846
|
configObject.xhr_headers = this.xhrHeaders;
|
32838
32847
|
}
|
@@ -34453,7 +34462,7 @@
|
|
34453
34462
|
this.build = "1.0.0";
|
34454
34463
|
this.name = "RudderLabs JavaScript SDK";
|
34455
34464
|
this.namespace = "com.rudderlabs.javascript";
|
34456
|
-
this.version = "1.
|
34465
|
+
this.version = "1.3.0";
|
34457
34466
|
});
|
34458
34467
|
|
34459
34468
|
// Library information class
|
@@ -34461,7 +34470,7 @@
|
|
34461
34470
|
_classCallCheck(this, RudderLibraryInfo);
|
34462
34471
|
|
34463
34472
|
this.name = "RudderLabs JavaScript SDK";
|
34464
|
-
this.version = "1.
|
34473
|
+
this.version = "1.3.0";
|
34465
34474
|
}); // Operating System information class
|
34466
34475
|
|
34467
34476
|
|
@@ -37468,11 +37477,15 @@
|
|
37468
37477
|
try {
|
37469
37478
|
if (!succesfulLoadedIntersectClientSuppliedIntegrations[i].isFailed || !succesfulLoadedIntersectClientSuppliedIntegrations[i].isFailed()) {
|
37470
37479
|
if (succesfulLoadedIntersectClientSuppliedIntegrations[i][methodName]) {
|
37471
|
-
var
|
37480
|
+
var sendEvent = !object.IsEventBlackListed(event[0].message.event, succesfulLoadedIntersectClientSuppliedIntegrations[i].name); // Block the event if it is blacklisted for the device-mode destination
|
37481
|
+
|
37482
|
+
if (sendEvent) {
|
37483
|
+
var _succesfulLoadedInter;
|
37472
37484
|
|
37473
|
-
|
37485
|
+
var clonedBufferEvent = lodash_clonedeep(event);
|
37474
37486
|
|
37475
|
-
|
37487
|
+
(_succesfulLoadedInter = succesfulLoadedIntersectClientSuppliedIntegrations[i])[methodName].apply(_succesfulLoadedInter, _toConsumableArray(clonedBufferEvent));
|
37488
|
+
}
|
37476
37489
|
}
|
37477
37490
|
}
|
37478
37491
|
} catch (error) {
|
@@ -37779,6 +37792,64 @@
|
|
37779
37792
|
value: function trackEvent(rudderElement, options, callback) {
|
37780
37793
|
this.processAndSendDataToDestinations("track", rudderElement, options, callback);
|
37781
37794
|
}
|
37795
|
+
}, {
|
37796
|
+
key: "IsEventBlackListed",
|
37797
|
+
value: function IsEventBlackListed(eventName, intgName) {
|
37798
|
+
if (!eventName || !(typeof eventName === "string")) {
|
37799
|
+
return false;
|
37800
|
+
}
|
37801
|
+
|
37802
|
+
var sdkIntgName = commonNames[intgName];
|
37803
|
+
var intg = this.clientIntegrations.find(function (intg) {
|
37804
|
+
return intg.name === sdkIntgName;
|
37805
|
+
});
|
37806
|
+
var _intg$config = intg.config,
|
37807
|
+
blacklistedEvents = _intg$config.blacklistedEvents,
|
37808
|
+
whitelistedEvents = _intg$config.whitelistedEvents,
|
37809
|
+
eventFilteringOption = _intg$config.eventFilteringOption;
|
37810
|
+
|
37811
|
+
if (!eventFilteringOption) {
|
37812
|
+
return false;
|
37813
|
+
}
|
37814
|
+
|
37815
|
+
switch (eventFilteringOption) {
|
37816
|
+
// disabled filtering
|
37817
|
+
case "disable":
|
37818
|
+
return false;
|
37819
|
+
// Blacklist is choosen for filtering events
|
37820
|
+
|
37821
|
+
case "blacklistedEvents":
|
37822
|
+
var isValidBlackList = blacklistedEvents && Array.isArray(blacklistedEvents) && blacklistedEvents.every(function (x) {
|
37823
|
+
return x.eventName !== "";
|
37824
|
+
});
|
37825
|
+
|
37826
|
+
if (isValidBlackList) {
|
37827
|
+
return blacklistedEvents.find(function (eventObj) {
|
37828
|
+
return eventObj.eventName.trim().toUpperCase() === eventName.trim().toUpperCase();
|
37829
|
+
}) === undefined ? false : true;
|
37830
|
+
} else {
|
37831
|
+
return false;
|
37832
|
+
}
|
37833
|
+
|
37834
|
+
// Whitelist is choosen for filtering events
|
37835
|
+
|
37836
|
+
case "whitelistedEvents":
|
37837
|
+
var isValidWhiteList = whitelistedEvents && Array.isArray(whitelistedEvents) && whitelistedEvents.some(function (x) {
|
37838
|
+
return x.eventName !== "";
|
37839
|
+
});
|
37840
|
+
|
37841
|
+
if (isValidWhiteList) {
|
37842
|
+
return whitelistedEvents.find(function (eventObj) {
|
37843
|
+
return eventObj.eventName.trim().toUpperCase() === eventName.trim().toUpperCase();
|
37844
|
+
}) === undefined ? true : false;
|
37845
|
+
} else {
|
37846
|
+
return true;
|
37847
|
+
}
|
37848
|
+
|
37849
|
+
default:
|
37850
|
+
return false;
|
37851
|
+
}
|
37852
|
+
}
|
37782
37853
|
/**
|
37783
37854
|
* Process and send data to destinations along with rudder BE
|
37784
37855
|
*
|
@@ -37791,6 +37862,8 @@
|
|
37791
37862
|
}, {
|
37792
37863
|
key: "processAndSendDataToDestinations",
|
37793
37864
|
value: function processAndSendDataToDestinations(type, rudderElement, options, callback) {
|
37865
|
+
var _this3 = this;
|
37866
|
+
|
37794
37867
|
try {
|
37795
37868
|
if (!this.anonymousId) {
|
37796
37869
|
this.setAnonymousId();
|
@@ -37832,8 +37905,12 @@
|
|
37832
37905
|
succesfulLoadedIntersectClientSuppliedIntegrations.forEach(function (obj) {
|
37833
37906
|
if (!obj.isFailed || !obj.isFailed()) {
|
37834
37907
|
if (obj[type]) {
|
37835
|
-
var
|
37836
|
-
|
37908
|
+
var sendEvent = !_this3.IsEventBlackListed(rudderElement.message.event, obj.name); // Block the event if it is blacklisted for the device-mode destination
|
37909
|
+
|
37910
|
+
if (sendEvent) {
|
37911
|
+
var clonedRudderElement = lodash_clonedeep(rudderElement);
|
37912
|
+
obj[type](clonedRudderElement);
|
37913
|
+
}
|
37837
37914
|
}
|
37838
37915
|
}
|
37839
37916
|
});
|
@@ -38028,7 +38105,7 @@
|
|
38028
38105
|
}, {
|
38029
38106
|
key: "load",
|
38030
38107
|
value: function load(writeKey, serverUrl, options) {
|
38031
|
-
var
|
38108
|
+
var _this4 = this;
|
38032
38109
|
|
38033
38110
|
logger.debug("inside load ");
|
38034
38111
|
if (options && options.cookieConsentManager) this.cookieConsentOptions = lodash_clonedeep(options.cookieConsentManager);
|
@@ -38086,9 +38163,9 @@
|
|
38086
38163
|
// convert to rudder recognised method names
|
38087
38164
|
var tranformedCallbackMapping = {};
|
38088
38165
|
Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
|
38089
|
-
if (
|
38090
|
-
if (options.clientSuppliedCallbacks[
|
38091
|
-
tranformedCallbackMapping[methodName] = options.clientSuppliedCallbacks[
|
38166
|
+
if (_this4.methodToCallbackMapping.hasOwnProperty(methodName)) {
|
38167
|
+
if (options.clientSuppliedCallbacks[_this4.methodToCallbackMapping[methodName]]) {
|
38168
|
+
tranformedCallbackMapping[methodName] = options.clientSuppliedCallbacks[_this4.methodToCallbackMapping[methodName]];
|
38092
38169
|
}
|
38093
38170
|
}
|
38094
38171
|
});
|
@@ -38137,7 +38214,7 @@
|
|
38137
38214
|
|
38138
38215
|
if (res instanceof Promise) {
|
38139
38216
|
res.then(function (res) {
|
38140
|
-
return
|
38217
|
+
return _this4.processResponse(200, res);
|
38141
38218
|
}).catch(errorHandler);
|
38142
38219
|
} else {
|
38143
38220
|
this.processResponse(200, res);
|
@@ -38172,25 +38249,25 @@
|
|
38172
38249
|
}, {
|
38173
38250
|
key: "initializeCallbacks",
|
38174
38251
|
value: function initializeCallbacks() {
|
38175
|
-
var
|
38252
|
+
var _this5 = this;
|
38176
38253
|
|
38177
38254
|
Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
|
38178
|
-
if (
|
38179
|
-
|
38255
|
+
if (_this5.methodToCallbackMapping.hasOwnProperty(methodName)) {
|
38256
|
+
_this5.on(methodName, function () {});
|
38180
38257
|
}
|
38181
38258
|
});
|
38182
38259
|
}
|
38183
38260
|
}, {
|
38184
38261
|
key: "registerCallbacks",
|
38185
38262
|
value: function registerCallbacks(calledFromLoad) {
|
38186
|
-
var
|
38263
|
+
var _this6 = this;
|
38187
38264
|
|
38188
38265
|
if (!calledFromLoad) {
|
38189
38266
|
Object.keys(this.methodToCallbackMapping).forEach(function (methodName) {
|
38190
|
-
if (
|
38267
|
+
if (_this6.methodToCallbackMapping.hasOwnProperty(methodName)) {
|
38191
38268
|
if (window.rudderanalytics) {
|
38192
|
-
if (typeof window.rudderanalytics[
|
38193
|
-
|
38269
|
+
if (typeof window.rudderanalytics[_this6.methodToCallbackMapping[methodName]] === "function") {
|
38270
|
+
_this6.clientSuppliedCallbacks[methodName] = window.rudderanalytics[_this6.methodToCallbackMapping[methodName]];
|
38194
38271
|
}
|
38195
38272
|
} // let callback =
|
38196
38273
|
// ? typeof window.rudderanalytics[
|
@@ -38207,10 +38284,10 @@
|
|
38207
38284
|
}
|
38208
38285
|
|
38209
38286
|
Object.keys(this.clientSuppliedCallbacks).forEach(function (methodName) {
|
38210
|
-
if (
|
38211
|
-
logger.debug("registerCallbacks", methodName,
|
38287
|
+
if (_this6.clientSuppliedCallbacks.hasOwnProperty(methodName)) {
|
38288
|
+
logger.debug("registerCallbacks", methodName, _this6.clientSuppliedCallbacks[methodName]);
|
38212
38289
|
|
38213
|
-
|
38290
|
+
_this6.on(methodName, _this6.clientSuppliedCallbacks[methodName]);
|
38214
38291
|
}
|
38215
38292
|
});
|
38216
38293
|
}
|