@rudderstack/analytics-js 3.20.1 → 3.21.0-beta.pr.2309.bb541e7
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/CHANGELOG.md +12 -0
- package/dist/npm/index.d.cts +161 -2
- package/dist/npm/index.d.mts +161 -2
- package/dist/npm/legacy/bundled/cjs/index.cjs +133 -205
- package/dist/npm/legacy/bundled/esm/index.mjs +133 -205
- package/dist/npm/legacy/bundled/umd/index.js +133 -205
- package/dist/npm/legacy/cjs/index.cjs +133 -205
- package/dist/npm/legacy/content-script/cjs/index.cjs +133 -205
- package/dist/npm/legacy/content-script/esm/index.mjs +133 -205
- package/dist/npm/legacy/content-script/umd/index.js +133 -205
- package/dist/npm/legacy/esm/index.mjs +133 -205
- package/dist/npm/legacy/umd/index.js +133 -205
- package/dist/npm/modern/bundled/cjs/index.cjs +125 -61
- package/dist/npm/modern/bundled/esm/index.mjs +125 -61
- package/dist/npm/modern/bundled/umd/index.js +125 -61
- package/dist/npm/modern/cjs/index.cjs +84 -45
- package/dist/npm/modern/content-script/cjs/index.cjs +125 -61
- package/dist/npm/modern/content-script/esm/index.mjs +125 -61
- package/dist/npm/modern/content-script/umd/index.js +125 -61
- package/dist/npm/modern/esm/index.mjs +84 -45
- package/dist/npm/modern/umd/index.js +84 -45
- package/package.json +1 -1
@@ -1,6 +1,3 @@
|
|
1
|
-
function _OverloadYield(e, d) {
|
2
|
-
this.v = e, this.k = d;
|
3
|
-
}
|
4
1
|
function _arrayLikeToArray(r, a) {
|
5
2
|
(null == a || a > r.length) && (a = r.length);
|
6
3
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
@@ -247,7 +244,7 @@ function _regenerator() {
|
|
247
244
|
i = p[t],
|
248
245
|
d = G.p,
|
249
246
|
l = i[2];
|
250
|
-
r > 3 ? (o = l === n) && (
|
247
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
251
248
|
}
|
252
249
|
if (o || r > 1) return a;
|
253
250
|
throw y = true, n;
|
@@ -301,45 +298,6 @@ function _regenerator() {
|
|
301
298
|
};
|
302
299
|
})();
|
303
300
|
}
|
304
|
-
function _regeneratorAsync(n, e, r, t, o) {
|
305
|
-
var a = _regeneratorAsyncGen(n, e, r, t, o);
|
306
|
-
return a.next().then(function (n) {
|
307
|
-
return n.done ? n.value : a.next();
|
308
|
-
});
|
309
|
-
}
|
310
|
-
function _regeneratorAsyncGen(r, e, t, o, n) {
|
311
|
-
return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
|
312
|
-
}
|
313
|
-
function _regeneratorAsyncIterator(t, e) {
|
314
|
-
function n(r, o, i, f) {
|
315
|
-
try {
|
316
|
-
var c = t[r](o),
|
317
|
-
u = c.value;
|
318
|
-
return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
|
319
|
-
n("next", t, i, f);
|
320
|
-
}, function (t) {
|
321
|
-
n("throw", t, i, f);
|
322
|
-
}) : e.resolve(u).then(function (t) {
|
323
|
-
c.value = t, i(c);
|
324
|
-
}, function (t) {
|
325
|
-
return n("throw", t, i, f);
|
326
|
-
});
|
327
|
-
} catch (t) {
|
328
|
-
f(t);
|
329
|
-
}
|
330
|
-
}
|
331
|
-
var r;
|
332
|
-
this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
333
|
-
return this;
|
334
|
-
})), _regeneratorDefine(this, "_invoke", function (t, o, i) {
|
335
|
-
function f() {
|
336
|
-
return new e(function (e, r) {
|
337
|
-
n(t, i, e, r);
|
338
|
-
});
|
339
|
-
}
|
340
|
-
return r = r ? r.then(f, f) : f();
|
341
|
-
}, true);
|
342
|
-
}
|
343
301
|
function _regeneratorDefine(e, r, n, t) {
|
344
302
|
var i = Object.defineProperty;
|
345
303
|
try {
|
@@ -363,32 +321,6 @@ function _regeneratorDefine(e, r, n, t) {
|
|
363
321
|
}
|
364
322
|
}, _regeneratorDefine(e, r, n, t);
|
365
323
|
}
|
366
|
-
function _regeneratorKeys(e) {
|
367
|
-
var n = Object(e),
|
368
|
-
r = [];
|
369
|
-
for (var t in n) r.unshift(t);
|
370
|
-
return function e() {
|
371
|
-
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = false, e;
|
372
|
-
return e.done = true, e;
|
373
|
-
};
|
374
|
-
}
|
375
|
-
function _regeneratorValues(e) {
|
376
|
-
if (null != e) {
|
377
|
-
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
378
|
-
r = 0;
|
379
|
-
if (t) return t.call(e);
|
380
|
-
if ("function" == typeof e.next) return e;
|
381
|
-
if (!isNaN(e.length)) return {
|
382
|
-
next: function () {
|
383
|
-
return e && r >= e.length && (e = void 0), {
|
384
|
-
value: e && e[r++],
|
385
|
-
done: !e
|
386
|
-
};
|
387
|
-
}
|
388
|
-
};
|
389
|
-
}
|
390
|
-
throw new TypeError(typeof e + " is not iterable");
|
391
|
-
}
|
392
324
|
function _setPrototypeOf(t, e) {
|
393
325
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
394
326
|
return t.__proto__ = e, t;
|
@@ -440,74 +372,6 @@ function _unsupportedIterableToArray(r, a) {
|
|
440
372
|
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
441
373
|
}
|
442
374
|
}
|
443
|
-
function _regeneratorRuntime() {
|
444
|
-
|
445
|
-
var r = _regenerator(),
|
446
|
-
e = r.m(_regeneratorRuntime),
|
447
|
-
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
448
|
-
function n(r) {
|
449
|
-
var e = "function" == typeof r && r.constructor;
|
450
|
-
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
451
|
-
}
|
452
|
-
var o = {
|
453
|
-
throw: 1,
|
454
|
-
return: 2,
|
455
|
-
break: 3,
|
456
|
-
continue: 3
|
457
|
-
};
|
458
|
-
function a(r) {
|
459
|
-
var e, t;
|
460
|
-
return function (n) {
|
461
|
-
e || (e = {
|
462
|
-
stop: function () {
|
463
|
-
return t(n.a, 2);
|
464
|
-
},
|
465
|
-
catch: function () {
|
466
|
-
return n.v;
|
467
|
-
},
|
468
|
-
abrupt: function (r, e) {
|
469
|
-
return t(n.a, o[r], e);
|
470
|
-
},
|
471
|
-
delegateYield: function (r, o, a) {
|
472
|
-
return e.resultName = o, t(n.d, _regeneratorValues(r), a);
|
473
|
-
},
|
474
|
-
finish: function (r) {
|
475
|
-
return t(n.f, r);
|
476
|
-
}
|
477
|
-
}, t = function (r, t, o) {
|
478
|
-
n.p = e.prev, n.n = e.next;
|
479
|
-
try {
|
480
|
-
return r(t, o);
|
481
|
-
} finally {
|
482
|
-
e.next = n.n;
|
483
|
-
}
|
484
|
-
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
485
|
-
try {
|
486
|
-
return r.call(this, e);
|
487
|
-
} finally {
|
488
|
-
n.p = e.prev, n.n = e.next;
|
489
|
-
}
|
490
|
-
};
|
491
|
-
}
|
492
|
-
return (_regeneratorRuntime = function () {
|
493
|
-
return {
|
494
|
-
wrap: function (e, t, n, o) {
|
495
|
-
return r.w(a(e), t, n, o && o.reverse());
|
496
|
-
},
|
497
|
-
isGeneratorFunction: n,
|
498
|
-
mark: r.m,
|
499
|
-
awrap: function (r, e) {
|
500
|
-
return new _OverloadYield(r, e);
|
501
|
-
},
|
502
|
-
AsyncIterator: _regeneratorAsyncIterator,
|
503
|
-
async: function (r, e, t, o, u) {
|
504
|
-
return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
|
505
|
-
},
|
506
|
-
keys: _regeneratorKeys,
|
507
|
-
values: _regeneratorValues
|
508
|
-
};
|
509
|
-
})();
|
510
|
-
}
|
511
375
|
|
512
376
|
function _isPlaceholder(a){return a!=null&&_typeof(a)==='object'&&a['@@functional/placeholder']===true;}
|
513
377
|
|
@@ -579,9 +443,7 @@ function _isObject(x){return Object.prototype.toString.call(x)==='[object Object
|
|
579
443
|
* @return {Boolean}
|
580
444
|
*/var _isInteger = Number.isInteger||function _isInteger(n){return n<<0===n;};
|
581
445
|
|
582
|
-
function
|
583
|
-
|
584
|
-
function _nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];}
|
446
|
+
function _nth(offset,list){var idx=offset<0?list.length+offset:offset;return list[idx];}
|
585
447
|
|
586
448
|
function _cloneRegExp(pattern){return new RegExp(pattern.source,pattern.flags?pattern.flags:(pattern.global?'g':'')+(pattern.ignoreCase?'i':'')+(pattern.multiline?'m':'')+(pattern.sticky?'y':'')+(pattern.unicode?'u':'')+(pattern.dotAll?'s':''));}
|
587
449
|
|
@@ -644,7 +506,7 @@ function _path(pathAr,obj){var val=obj;for(var i=0;i<pathAr.length;i+=1){if(val=
|
|
644
506
|
* @param {Object} l
|
645
507
|
* @param {Object} r
|
646
508
|
* @return {Object}
|
647
|
-
* @see R.mergeDeepWithKey, R.
|
509
|
+
* @see R.mergeDeepWithKey, R.mergeWith
|
648
510
|
* @example
|
649
511
|
*
|
650
512
|
* let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
|
@@ -1008,7 +870,7 @@ error.stack="".concat(stack,"\n").concat(MANUAL_ERROR_IDENTIFIER);break;case sta
|
|
1008
870
|
error.stacktrace="".concat(stacktrace,"\n").concat(MANUAL_ERROR_IDENTIFIER);break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
1009
871
|
error['opera#sourceloc']="".concat(operaSourceloc,"\n").concat(MANUAL_ERROR_IDENTIFIER);break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error:error,bubbles:true,cancelable:true,composed:true}));};
|
1010
872
|
|
1011
|
-
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.
|
873
|
+
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.21.0-beta.pr.2309.bb541e7';var APP_NAMESPACE='com.rudderlabs.javascript';var MODULE_TYPE='npm';var ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';var ADBLOCK_PAGE_NAME='ad-block page request';var ADBLOCK_PAGE_PATH='/ad-blocked';var GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';var CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
|
1012
874
|
|
1013
875
|
var QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';var QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';var QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';var QUERY_PARAM_USER_ID_KEY='ajs_uid';var QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
|
1014
876
|
|
@@ -1098,7 +960,7 @@ timeoutID=globalThis.setTimeout(function(){reject(new Error(SCRIPT_LOAD_TIMEOUT_
|
|
1098
960
|
* Load external resource of type javascript
|
1099
961
|
*/return _createClass(ExternalSrcLoader,[{key:"loadJSFile",value:function loadJSFile(config){var url=config.url,id=config.id,timeout=config.timeout,async=config.async,callback=config.callback,extraAttributes=config.extraAttributes;var isFireAndForget=!isFunction(callback);jsFileLoader(url,id,timeout||this.timeout,async,extraAttributes).then(function(id){if(!isFireAndForget){callback(id);}}).catch(function(err){if(!isFireAndForget){callback(id,err);}});}}]);}();
|
1100
962
|
|
1101
|
-
var i$2=Symbol.for("preact-signals");function t$1(){if(!(s>1)){var i,t=false;while(void 0!==h){var r=h;h=void 0;f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&c(r))try{r.c();}catch(r){if(!t){i=r;t=true;}}r=o;}}f=0;s--;if(t)throw i;}else s--;}function r(i){if(s>0)return i();s++;try{return i();}finally{t$1();}}var o=void 0;function n(i){var t=o;o=void 0;try{return i();}finally{o=t;}}var h=void 0,s=0,f=0,v=0;function e(i){if(void 0!==o){var t=i.n;if(void 0===t||t.t!==o){t={i:0,S:i,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t};if(void 0!==o.s)o.s.n=t;o.s=t;i.n=t;if(32&o.f)i.S(t);return t;}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=o.s;t.n=void 0;o.s.n=t;o.s=t;}return t;}}}function u(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;}u.prototype.brand=i$2;u.prototype.h=function(){return true;};u.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else n(function(){var i;null==(i=t.W)||i.call(t);});}};u.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,o=i.x;if(void 0!==r){r.x=o;i.e=void 0;}if(void 0!==o){o.e=r;i.x=void 0;}if(i===this.t){this.t=o;if(void 0===o)n(function(){var i;null==(i=t.Z)||i.call(t);});}}};u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=o;o=void 0;try{i(r);}finally{o=n;}});};u.prototype.valueOf=function(){return this.value;};u.prototype.toString=function(){return this.value+"";};u.prototype.toJSON=function(){return this.value;};u.prototype.peek=function(){var i=o;o=void 0;try{return this.value;}finally{o=i;}};Object.defineProperty(u.prototype,"value",{get:function get(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v;},set:function set(i){if(i!==this.v){if(f>100)throw new Error("Cycle detected");this.v=i;this.i++;v++;s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N();}finally{t$1();}}}});function d$1(i,t){return new u(i,t);}function c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return true;return false;}function a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break;}}}function l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o;}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o;}i.s=r;}function y(i,t){u.call(this,void 0);this.x=i;this.s=void 0;this.g=v-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;}y.prototype=new u();y.prototype.h=function(){this.f&=-3;if(1&this.f)return false;if(32==(36&this.f))return true;this.f&=-5;if(this.g===v)return true;this.g=v;this.f|=1;if(this.i>0&&!c(this)){this.f&=-2;return true;}var i=o;try{a(this);o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++;}}catch(i){this.v=i;this.f|=16;this.i++;}o=i;l(this);this.f&=-2;return true;};y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t);}u.prototype.S.call(this,i);};y.prototype.U=function(i){if(void 0!==this.t){u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t);}}};y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N();}};Object.defineProperty(y.prototype,"value",{get:function get(){if(1&this.f)throw new Error("Cycle detected");var i=e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v;}});function _(i){var r=i.u;i.u=void 0;if("function"==typeof r){s++;var n=o;o=void 0;try{r();}catch(t){i.f&=-2;i.f|=8;
|
963
|
+
var i$2=Symbol.for("preact-signals");function t$1(){if(!(s>1)){var i,t=false;while(void 0!==h){var r=h;h=void 0;f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&c(r))try{r.c();}catch(r){if(!t){i=r;t=true;}}r=o;}}f=0;s--;if(t)throw i;}else s--;}function r(i){if(s>0)return i();s++;try{return i();}finally{t$1();}}var o=void 0;function n(i){var t=o;o=void 0;try{return i();}finally{o=t;}}var h=void 0,s=0,f=0,v=0;function e(i){if(void 0!==o){var t=i.n;if(void 0===t||t.t!==o){t={i:0,S:i,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t};if(void 0!==o.s)o.s.n=t;o.s=t;i.n=t;if(32&o.f)i.S(t);return t;}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=o.s;t.n=void 0;o.s.n=t;o.s=t;}return t;}}}function u(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;}u.prototype.brand=i$2;u.prototype.h=function(){return true;};u.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else n(function(){var i;null==(i=t.W)||i.call(t);});}};u.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,o=i.x;if(void 0!==r){r.x=o;i.e=void 0;}if(void 0!==o){o.e=r;i.x=void 0;}if(i===this.t){this.t=o;if(void 0===o)n(function(){var i;null==(i=t.Z)||i.call(t);});}}};u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=o;o=void 0;try{i(r);}finally{o=n;}});};u.prototype.valueOf=function(){return this.value;};u.prototype.toString=function(){return this.value+"";};u.prototype.toJSON=function(){return this.value;};u.prototype.peek=function(){var i=o;o=void 0;try{return this.value;}finally{o=i;}};Object.defineProperty(u.prototype,"value",{get:function get(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v;},set:function set(i){if(i!==this.v){if(f>100)throw new Error("Cycle detected");this.v=i;this.i++;v++;s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N();}finally{t$1();}}}});function d$1(i,t){return new u(i,t);}function c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return true;return false;}function a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break;}}}function l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o;}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o;}i.s=r;}function y(i,t){u.call(this,void 0);this.x=i;this.s=void 0;this.g=v-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;}y.prototype=new u();y.prototype.h=function(){this.f&=-3;if(1&this.f)return false;if(32==(36&this.f))return true;this.f&=-5;if(this.g===v)return true;this.g=v;this.f|=1;if(this.i>0&&!c(this)){this.f&=-2;return true;}var i=o;try{a(this);o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++;}}catch(i){this.v=i;this.f|=16;this.i++;}o=i;l(this);this.f&=-2;return true;};y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t);}u.prototype.S.call(this,i);};y.prototype.U=function(i){if(void 0!==this.t){u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t);}}};y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N();}};Object.defineProperty(y.prototype,"value",{get:function get(){if(1&this.f)throw new Error("Cycle detected");var i=e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v;}});function _(i){var r=i.u;i.u=void 0;if("function"==typeof r){s++;var n=o;o=void 0;try{r();}catch(t){i.f&=-2;i.f|=8;b(i);throw t;}finally{o=n;t$1();}}}function b(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i);}function g(i){if(o!==this)throw new Error("Out-of-order effect");l(this);o=i;this.f&=-2;if(8&this.f)b(this);t$1();}function p(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;}p.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t;}finally{i();}};p.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;_(this);a(this);s++;var i=o;o=this;return g.bind(this,i);};p.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=h;h=this;}};p.prototype.d=function(){this.f|=8;if(!(1&this.f))b(this);};p.prototype.dispose=function(){this.d();};function E(i){var t=new p(i);try{t.c();}catch(i){t.d();throw i;}var r=t.d.bind(t);r[Symbol.dispose]=r;return r;}
|
1102
964
|
|
1103
965
|
/**
|
1104
966
|
* A buffer queue to serve as a store for any type of data
|
@@ -1127,7 +989,7 @@ var SUPPORTED_STORAGE_TYPES=['localStorage','memoryStorage','cookieStorage','ses
|
|
1127
989
|
|
1128
990
|
var SOURCE_CONFIG_RESOLUTION_ERROR="Unable to process/parse source configuration response";var SOURCE_DISABLED_ERROR="The source is disabled. Please enable the source in the dashboard to send events.";var XHR_PAYLOAD_PREP_ERROR="Failed to prepare data for the request.";var PLUGIN_EXT_POINT_MISSING_ERROR="Failed to invoke plugin because the extension point name is missing.";var PLUGIN_EXT_POINT_INVALID_ERROR="Failed to invoke plugin because the extension point name is invalid.";var SOURCE_CONFIG_OPTION_ERROR=function SOURCE_CONFIG_OPTION_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"getSourceConfig\" load API option must be a function that returns valid source configuration data.");};var COMPONENT_BASE_URL_ERROR=function COMPONENT_BASE_URL_ERROR(context,component,url){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The base URL \"").concat(url,"\" for ").concat(component," is not valid.");};// ERROR
|
1129
991
|
var UNSUPPORTED_CONSENT_MANAGER_ERROR=function UNSUPPORTED_CONSENT_MANAGER_ERROR(context,selectedConsentManager,consentManagersToPluginNameMap){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The consent manager \"").concat(selectedConsentManager,"\" is not supported. Please choose one of the following supported consent managers: \"").concat(Object.keys(consentManagersToPluginNameMap),"\".");};var NON_ERROR_WARNING=function NON_ERROR_WARNING(context,errStr){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring a non-error: ").concat(errStr,".");};var BREADCRUMB_ERROR="Failed to log breadcrumb";var HANDLE_ERROR_FAILURE=function HANDLE_ERROR_FAILURE(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to handle the error.");};var PLUGIN_NAME_MISSING_ERROR=function PLUGIN_NAME_MISSING_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin name is missing.");};var PLUGIN_ALREADY_EXISTS_ERROR=function PLUGIN_ALREADY_EXISTS_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" already exists.");};var PLUGIN_NOT_FOUND_ERROR=function PLUGIN_NOT_FOUND_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" not found.");};var PLUGIN_ENGINE_BUG_ERROR=function PLUGIN_ENGINE_BUG_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.");};var PLUGIN_DEPS_ERROR=function PLUGIN_DEPS_ERROR(context,pluginName,notExistDeps){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" could not be loaded because some of its dependencies \"").concat(notExistDeps,"\" do not exist.");};var PLUGIN_INVOCATION_ERROR=function PLUGIN_INVOCATION_ERROR(context,extPoint,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to invoke the \"").concat(extPoint,"\" extension point of plugin \"").concat(pluginName,"\".");};var STORAGE_UNAVAILABILITY_ERROR_PREFIX=function STORAGE_UNAVAILABILITY_ERROR_PREFIX(context,storageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(storageType,"\" storage type is ");};var SOURCE_CONFIG_FETCH_ERROR='Failed to fetch the source config';var WRITE_KEY_VALIDATION_ERROR=function WRITE_KEY_VALIDATION_ERROR(context,writeKey){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The write key \"").concat(writeKey,"\" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.");};var DATA_PLANE_URL_VALIDATION_ERROR=function DATA_PLANE_URL_VALIDATION_ERROR(context,dataPlaneUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The data plane URL \"").concat(dataPlaneUrl,"\" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.");};var INVALID_CALLBACK_FN_ERROR=function INVALID_CALLBACK_FN_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided callback parameter is not a function.");};var XHR_DELIVERY_ERROR=function XHR_DELIVERY_ERROR(prefix,status,statusText,url,response){return "".concat(prefix," with status ").concat(status," (").concat(statusText,") for URL: ").concat(url,". Response: ").concat(response.trim());};var XHR_REQUEST_ERROR=function XHR_REQUEST_ERROR(prefix,e,url){return "".concat(prefix," due to timeout or no connection (").concat(e?e.type:'',") at the client side for URL: ").concat(url);};var XHR_SEND_ERROR=function XHR_SEND_ERROR(prefix,url){return "".concat(prefix," for URL: ").concat(url);};var STORE_DATA_SAVE_ERROR=function STORE_DATA_SAVE_ERROR(key){return "Failed to save the value for \"".concat(key,"\" to storage");};var STORE_DATA_FETCH_ERROR=function STORE_DATA_FETCH_ERROR(key){return "Failed to retrieve or parse data for \"".concat(key,"\" from storage");};var DATA_SERVER_REQUEST_FAIL_ERROR=function DATA_SERVER_REQUEST_FAIL_ERROR(status){return "The server responded with status ".concat(status," while setting the cookies. As a fallback, the cookies will be set client side.");};var FAILED_SETTING_COOKIE_FROM_SERVER_ERROR=function FAILED_SETTING_COOKIE_FROM_SERVER_ERROR(key){return "The server failed to set the ".concat(key," cookie. As a fallback, the cookies will be set client side.");};var FAILED_SETTING_COOKIE_FROM_SERVER_GLOBAL_ERROR="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.";// WARNING
|
1130
|
-
var STORAGE_TYPE_VALIDATION_WARNING=function STORAGE_TYPE_VALIDATION_WARNING(context,storageType,defaultStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default type \"").concat(defaultStorageType,"\" will be used instead.");};var UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=function UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage encryption version \"").concat(selectedStorageEncryptionVersion,"\" is not supported. Please choose one of the following supported versions: \"").concat(Object.keys(storageEncryptionVersionsToPluginNameMap),"\". The default version \"").concat(defaultVersion,"\" will be used instead.");};var STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=function STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(context,storageEncryptionVersion,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage data migration has been disabled because the configured storage encryption version (").concat(storageEncryptionVersion,") is not the latest (").concat(defaultVersion,"). To enable storage data migration, please update the storage encryption version to the latest version.");};var SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=function SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING(context,providedCookieDomain,currentCookieDomain){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided cookie domain (").concat(providedCookieDomain,") does not match the current webpage's domain (").concat(currentCookieDomain,"). Hence, the cookies will be set client-side.");};var RESERVED_KEYWORD_WARNING=function RESERVED_KEYWORD_WARNING(context,property,parentKeyPath,reservedElements){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(property,"\" property defined under \"").concat(parentKeyPath,"\" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (").concat(reservedElements,").");};var INVALID_CONTEXT_OBJECT_WARNING=function INVALID_CONTEXT_OBJECT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Please make sure that the \"context\" property in the event API's \"options\" argument is a valid object literal with key-value pairs.");};var UNSUPPORTED_BEACON_API_WARNING=function UNSUPPORTED_BEACON_API_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The Beacon API is not supported by your browser. The events will be sent using XHR instead.");};var TIMEOUT_NOT_NUMBER_WARNING=function TIMEOUT_NOT_NUMBER_WARNING(context,timeout,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value \"").concat(timeout,"\" is not a number. The default timeout of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_NOT_NUMBER_WARNING=function CUT_OFF_DURATION_NOT_NUMBER_WARNING(context,cutOffDuration,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" is not a number. The default cut off duration of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=function CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING(context,cutOffDuration,timeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" ms is less than the session timeout value \"").concat(timeout,"\" ms. The cut off functionality will be disabled.");};var TIMEOUT_ZERO_WARNING=function TIMEOUT_ZERO_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.");};var TIMEOUT_NOT_RECOMMENDED_WARNING=function TIMEOUT_NOT_RECOMMENDED_WARNING(context,timeout,minTimeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value ").concat(timeout," ms is less than the recommended minimum of ").concat(minTimeout," ms. Please consider increasing the timeout value to ensure optimal performance and reliability.");};var INVALID_SESSION_ID_WARNING=function INVALID_SESSION_ID_WARNING(context,sessionId,minSessionIdLength){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided session ID (").concat(sessionId,") is either invalid, not a positive integer, or not at least \"").concat(minSessionIdLength,"\" digits long. A new session ID will be auto-generated instead.");};var STORAGE_QUOTA_EXCEEDED_WARNING=function STORAGE_QUOTA_EXCEEDED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.");};var STORAGE_UNAVAILABLE_WARNING=function STORAGE_UNAVAILABLE_WARNING(context,entry,selectedStorageType,finalStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(selectedStorageType,"\" is not available for entry \"").concat(entry,"\". The SDK will initialize the entry with \"").concat(finalStorageType,"\" storage type instead.");};var CALLBACK_INVOKE_ERROR=function CALLBACK_INVOKE_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The callback threw an exception");};var INVALID_CONFIG_URL_WARNING=function INVALID_CONFIG_URL_WARNING(context,configUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided source config URL \"").concat(configUrl,"\" is invalid. Using the default source config URL instead.");};var POLYFILL_SCRIPT_LOAD_ERROR=function POLYFILL_SCRIPT_LOAD_ERROR(scriptId,url){return "Failed to load the polyfill script with ID \"".concat(scriptId,"\" from URL ").concat(url,".");};var UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=function UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY(context,selectedStrategy,defaultStrategy){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy \"").concat(selectedStrategy,"\" is not supported. Please choose one of the following supported strategies: \"none, session, anonymousId\". The default strategy \"").concat(defaultStrategy,"\" will be used instead.");};var UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=function UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE(context,selectedDeliveryType,defaultDeliveryType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent events delivery type \"").concat(selectedDeliveryType,"\" is not supported. Please choose one of the following supported types: \"immediate, buffer\". The default type \"").concat(defaultDeliveryType,"\" will be used instead.");};var DEPRECATED_PLUGIN_WARNING=function DEPRECATED_PLUGIN_WARNING(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(pluginName," plugin is deprecated. Please exclude it from the load API options.");};var generateMisconfiguredPluginsWarning=function generateMisconfiguredPluginsWarning(context,configurationStatus,missingPlugins,shouldAddMissingPlugins){var isSinglePlugin=missingPlugins.length===1;var pluginsString=isSinglePlugin?" '".concat(missingPlugins[0],"' plugin was"):" ['".concat(missingPlugins.join("', '"),"'] plugins were");var baseWarning="".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(configurationStatus,", but").concat(pluginsString," not configured to load.");if(shouldAddMissingPlugins){return "".concat(baseWarning," So, ").concat(isSinglePlugin?'the plugin':'those plugins'," will be loaded automatically.");}return "".concat(baseWarning," Ignore if this was intentional. Otherwise, consider adding ").concat(isSinglePlugin?'it':'them'," to the 'plugins' load API option.");};var INVALID_POLYFILL_URL_WARNING=function INVALID_POLYFILL_URL_WARNING(context,customPolyfillUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided polyfill URL \"").concat(customPolyfillUrl,"\" is invalid. The default polyfill URL will be used instead.");};var PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=function PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Page Unloaded event can only be tracked when the Beacon transport is active. Please enable \"useBeacon\" load API option.");};var UNKNOWN_PLUGINS_WARNING=function UNKNOWN_PLUGINS_WARNING(context,unknownPlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring unknown plugins: ").concat(unknownPlugins.join(', '),".");};
|
992
|
+
var STORAGE_TYPE_VALIDATION_WARNING=function STORAGE_TYPE_VALIDATION_WARNING(context,storageType,defaultStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default type \"").concat(defaultStorageType,"\" will be used instead.");};var UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=function UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage encryption version \"").concat(selectedStorageEncryptionVersion,"\" is not supported. Please choose one of the following supported versions: \"").concat(Object.keys(storageEncryptionVersionsToPluginNameMap),"\". The default version \"").concat(defaultVersion,"\" will be used instead.");};var STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=function STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(context,storageEncryptionVersion,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage data migration has been disabled because the configured storage encryption version (").concat(storageEncryptionVersion,") is not the latest (").concat(defaultVersion,"). To enable storage data migration, please update the storage encryption version to the latest version.");};var SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=function SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING(context,providedCookieDomain,currentCookieDomain){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided cookie domain (").concat(providedCookieDomain,") does not match the current webpage's domain (").concat(currentCookieDomain,"). Hence, the cookies will be set client-side.");};var RESERVED_KEYWORD_WARNING=function RESERVED_KEYWORD_WARNING(context,property,parentKeyPath,reservedElements){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(property,"\" property defined under \"").concat(parentKeyPath,"\" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (").concat(reservedElements,").");};var INVALID_CONTEXT_OBJECT_WARNING=function INVALID_CONTEXT_OBJECT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Please make sure that the \"context\" property in the event API's \"options\" argument is a valid object literal with key-value pairs.");};var UNSUPPORTED_BEACON_API_WARNING=function UNSUPPORTED_BEACON_API_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The Beacon API is not supported by your browser. The events will be sent using XHR instead.");};var TIMEOUT_NOT_NUMBER_WARNING=function TIMEOUT_NOT_NUMBER_WARNING(context,timeout,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value \"").concat(timeout,"\" is not a number. The default timeout of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_NOT_NUMBER_WARNING=function CUT_OFF_DURATION_NOT_NUMBER_WARNING(context,cutOffDuration,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" is not a number. The default cut off duration of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=function CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING(context,cutOffDuration,timeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" ms is less than the session timeout value \"").concat(timeout,"\" ms. The cut off functionality will be disabled.");};var TIMEOUT_ZERO_WARNING=function TIMEOUT_ZERO_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.");};var TIMEOUT_NOT_RECOMMENDED_WARNING=function TIMEOUT_NOT_RECOMMENDED_WARNING(context,timeout,minTimeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value ").concat(timeout," ms is less than the recommended minimum of ").concat(minTimeout," ms. Please consider increasing the timeout value to ensure optimal performance and reliability.");};var INVALID_SESSION_ID_WARNING=function INVALID_SESSION_ID_WARNING(context,sessionId,minSessionIdLength){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided session ID (").concat(sessionId,") is either invalid, not a positive integer, or not at least \"").concat(minSessionIdLength,"\" digits long. A new session ID will be auto-generated instead.");};var STORAGE_QUOTA_EXCEEDED_WARNING=function STORAGE_QUOTA_EXCEEDED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.");};var STORAGE_UNAVAILABLE_WARNING=function STORAGE_UNAVAILABLE_WARNING(context,entry,selectedStorageType,finalStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(selectedStorageType,"\" is not available for entry \"").concat(entry,"\". The SDK will initialize the entry with \"").concat(finalStorageType,"\" storage type instead.");};var CALLBACK_INVOKE_ERROR=function CALLBACK_INVOKE_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The callback threw an exception");};var INVALID_CONFIG_URL_WARNING=function INVALID_CONFIG_URL_WARNING(context,configUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided source config URL \"").concat(configUrl,"\" is invalid. Using the default source config URL instead.");};var POLYFILL_SCRIPT_LOAD_ERROR=function POLYFILL_SCRIPT_LOAD_ERROR(scriptId,url){return "Failed to load the polyfill script with ID \"".concat(scriptId,"\" from URL ").concat(url,".");};var UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=function UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY(context,selectedStrategy,defaultStrategy){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy \"").concat(selectedStrategy,"\" is not supported. Please choose one of the following supported strategies: \"none, session, anonymousId\". The default strategy \"").concat(defaultStrategy,"\" will be used instead.");};var UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=function UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE(context,selectedDeliveryType,defaultDeliveryType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent events delivery type \"").concat(selectedDeliveryType,"\" is not supported. Please choose one of the following supported types: \"immediate, buffer\". The default type \"").concat(defaultDeliveryType,"\" will be used instead.");};var DEPRECATED_PLUGIN_WARNING=function DEPRECATED_PLUGIN_WARNING(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(pluginName," plugin is deprecated. Please exclude it from the load API options.");};var generateMisconfiguredPluginsWarning=function generateMisconfiguredPluginsWarning(context,configurationStatus,missingPlugins,shouldAddMissingPlugins){var isSinglePlugin=missingPlugins.length===1;var pluginsString=isSinglePlugin?" '".concat(missingPlugins[0],"' plugin was"):" ['".concat(missingPlugins.join("', '"),"'] plugins were");var baseWarning="".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(configurationStatus,", but").concat(pluginsString," not configured to load.");if(shouldAddMissingPlugins){return "".concat(baseWarning," So, ").concat(isSinglePlugin?'the plugin':'those plugins'," will be loaded automatically.");}return "".concat(baseWarning," Ignore if this was intentional. Otherwise, consider adding ").concat(isSinglePlugin?'it':'them'," to the 'plugins' load API option.");};var INVALID_POLYFILL_URL_WARNING=function INVALID_POLYFILL_URL_WARNING(context,customPolyfillUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided polyfill URL \"").concat(customPolyfillUrl,"\" is invalid. The default polyfill URL will be used instead.");};var PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=function PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Page Unloaded event can only be tracked when the Beacon transport is active. Please enable \"useBeacon\" load API option.");};var UNKNOWN_PLUGINS_WARNING=function UNKNOWN_PLUGINS_WARNING(context,unknownPlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring unknown plugins: ").concat(unknownPlugins.join(', '),".");};var CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR=function CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR(context,name){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Cannot add custom integration \"").concat(name,"\" after the SDK is loaded.");};
|
1131
993
|
|
1132
994
|
var DEFAULT_INTEGRATIONS_CONFIG={All:true};
|
1133
995
|
|
@@ -1146,19 +1008,19 @@ var BUILD_TYPE='legacy';var SDK_CDN_BASE_URL='https://cdn.rudderlabs.com';var CD
|
|
1146
1008
|
|
1147
1009
|
var DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';var DEFAULT_DATA_PLANE_EVENTS_TRANSPORT='xhr';var ConsentManagersToPluginNameMap={iubenda:'IubendaConsentManager',oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};var StorageEncryptionVersionsToPluginNameMap=_defineProperty(_defineProperty({},DEFAULT_STORAGE_ENCRYPTION_VERSION,'StorageEncryption'),"legacy",'StorageEncryptionLegacy');var DataPlaneEventsTransportToPluginNameMap=_defineProperty(_defineProperty({},DEFAULT_DATA_PLANE_EVENTS_TRANSPORT,'XhrQueue'),"beacon",'BeaconQueue');var DEFAULT_DATA_SERVICE_ENDPOINT='rsaRequest';var METRICS_SERVICE_ENDPOINT='rsaMetrics';
|
1148
1010
|
|
1149
|
-
var defaultLoadOptions={configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS,cutOff:{enabled:false}},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:DEFAULT_INTEGRATIONS_CONFIG,useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:
|
1011
|
+
var defaultLoadOptions={configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS,cutOff:{enabled:false}},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:DEFAULT_INTEGRATIONS_CONFIG,useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:false,lockPluginsVersion:false,uaChTrackLevel:'none',plugins:[],useGlobalIntegrationsConfigInEvents:false,bufferDataPlaneEventsUntilReady:false,dataPlaneEventsBufferTimeout:DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS,storage:{encryption:{version:DEFAULT_STORAGE_ENCRYPTION_VERSION},migrate:true,cookie:{}},sendAdblockPage:false,sameDomainCookiesOnly:false,secureCookie:false,sendAdblockPageOptions:{},useServerSideCookies:false};var loadOptionsState=d$1(clone(defaultLoadOptions));
|
1150
1012
|
|
1151
1013
|
var DEFAULT_USER_SESSION_VALUES={userId:'',userTraits:{},anonymousId:'',groupId:'',groupTraits:{},initialReferrer:'',initialReferringDomain:'',sessionInfo:{},authToken:null};var SERVER_SIDE_COOKIES_DEBOUNCE_TIME=10;// milliseconds
|
1152
1014
|
|
1153
1015
|
var sessionState={userId:d$1(DEFAULT_USER_SESSION_VALUES.userId),userTraits:d$1(DEFAULT_USER_SESSION_VALUES.userTraits),anonymousId:d$1(DEFAULT_USER_SESSION_VALUES.anonymousId),groupId:d$1(DEFAULT_USER_SESSION_VALUES.groupId),groupTraits:d$1(DEFAULT_USER_SESSION_VALUES.groupTraits),initialReferrer:d$1(DEFAULT_USER_SESSION_VALUES.initialReferrer),initialReferringDomain:d$1(DEFAULT_USER_SESSION_VALUES.initialReferringDomain),sessionInfo:d$1(DEFAULT_USER_SESSION_VALUES.sessionInfo),authToken:d$1(DEFAULT_USER_SESSION_VALUES.authToken)};
|
1154
1016
|
|
1155
|
-
var capabilitiesState={isOnline:d$1(true),storage:{isLocalStorageAvailable:d$1(false),isCookieStorageAvailable:d$1(false),isSessionStorageAvailable:d$1(false)},isBeaconAvailable:d$1(false),isLegacyDOM:d$1(false),isUaCHAvailable:d$1(false),isCryptoAvailable:d$1(false),isIE11:d$1(false),
|
1017
|
+
var capabilitiesState={isOnline:d$1(true),storage:{isLocalStorageAvailable:d$1(false),isCookieStorageAvailable:d$1(false),isSessionStorageAvailable:d$1(false)},isBeaconAvailable:d$1(false),isLegacyDOM:d$1(false),isUaCHAvailable:d$1(false),isCryptoAvailable:d$1(false),isIE11:d$1(false),isAdBlockerDetectionInProgress:d$1(false),isAdBlocked:d$1(undefined),cspBlockedURLs:d$1([])};
|
1156
1018
|
|
1157
1019
|
var reportingState={isErrorReportingEnabled:d$1(false),isMetricsReportingEnabled:d$1(false),breadcrumbs:d$1([])};
|
1158
1020
|
|
1159
1021
|
var sourceConfigState=d$1(undefined);
|
1160
1022
|
|
1161
|
-
var lifecycleState={activeDataplaneUrl:d$1(undefined),integrationsCDNPath:d$1(DEFAULT_INTEGRATION_SDKS_URL),pluginsCDNPath:d$1(DEFAULT_PLUGINS_URL),sourceConfigUrl:d$1(undefined),status:d$1(undefined),initialized:d$1(false),logLevel:d$1(POST_LOAD_LOG_LEVEL),loaded:d$1(false),readyCallbacks:d$1([]),writeKey:d$1(undefined),dataPlaneUrl:d$1(undefined)};
|
1023
|
+
var lifecycleState={activeDataplaneUrl:d$1(undefined),integrationsCDNPath:d$1(DEFAULT_INTEGRATION_SDKS_URL),pluginsCDNPath:d$1(DEFAULT_PLUGINS_URL),sourceConfigUrl:d$1(undefined),status:d$1(undefined),initialized:d$1(false),logLevel:d$1(POST_LOAD_LOG_LEVEL),loaded:d$1(false),readyCallbacks:d$1([]),writeKey:d$1(undefined),dataPlaneUrl:d$1(undefined),safeAnalyticsInstance:d$1(undefined)};
|
1162
1024
|
|
1163
1025
|
var consentsState={enabled:d$1(false),initialized:d$1(false),data:d$1({}),activeConsentManagerPluginName:d$1(undefined),preConsent:d$1({enabled:false}),postConsent:d$1({}),resolutionStrategy:d$1('and'),provider:d$1(undefined),metadata:d$1(undefined)};
|
1164
1026
|
|
@@ -1229,7 +1091,7 @@ try{if(JSON.stringify(f)==='{}')return accum;return accum.concat(f);}catch(_unus
|
|
1229
1091
|
* Utility to parse XHR JSON response
|
1230
1092
|
*/var responseTextToJson=function responseTextToJson(responseText,onError){try{return JSON.parse(responseText||'');}catch(err){var error=getMutatedError(err,'Failed to parse response data');onError(error);}return undefined;};
|
1231
1093
|
|
1232
|
-
var FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';var PLUGINS_LOAD_FAILURE_MESSAGES=[/Failed to fetch dynamically imported module: .*/];var INTEGRATIONS_LOAD_FAILURE_MESSAGES=[/
|
1094
|
+
var FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';var PLUGINS_LOAD_FAILURE_MESSAGES=[/Failed to fetch dynamically imported module: .*/];var INTEGRATIONS_LOAD_FAILURE_MESSAGES=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/];var ERROR_MESSAGES_TO_BE_FILTERED=[new RegExp("".concat(FAILED_REQUEST_ERR_MSG_PREFIX,".*")),/A script with the id .* is already loaded\./];var SCRIPT_LOAD_FAILURE_MESSAGES=[].concat(PLUGINS_LOAD_FAILURE_MESSAGES,INTEGRATIONS_LOAD_FAILURE_MESSAGES);
|
1233
1095
|
|
1234
1096
|
var DEFAULT_XHR_REQUEST_OPTIONS={headers:{Accept:'application/json','Content-Type':'application/json;charset=UTF-8'},method:'GET'};/**
|
1235
1097
|
* Utility to create request configuration based on default options
|
@@ -1247,7 +1109,7 @@ xhr.timeout=timeout;Object.keys(options.headers).forEach(function(headerName){if
|
|
1247
1109
|
* Service to handle data communication with APIs
|
1248
1110
|
*/var HttpClient=/*#__PURE__*/function(){function HttpClient(logger){_classCallCheck(this,HttpClient);this.logger=logger;this.onError=this.onError.bind(this);}return _createClass(HttpClient,[{key:"init",value:function init(errorHandler){this.errorHandler=errorHandler;}/**
|
1249
1111
|
* Implement requests in a blocking way
|
1250
|
-
*/},{key:"getData",value:(function(){var _getData=_asyncToGenerator(/*#__PURE__*/
|
1112
|
+
*/},{key:"getData",value:(function(){var _getData=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config){var url,options,timeout,isRawResponse,data,_t;return _regenerator().w(function(_context){while(1)switch(_context.n){case 0:url=config.url,options=config.options,timeout=config.timeout,isRawResponse=config.isRawResponse;_context.p=1;_context.n=2;return xhrRequest(createXhrRequestOptions(url,options,this.basicAuthHeader),timeout,this.logger);case 2:data=_context.v;return _context.a(2,{data:isRawResponse?data.response:responseTextToJson(data.response,this.onError),details:data});case 3:_context.p=3;_t=_context.v;return _context.a(2,{data:undefined,details:_t});}},_callee,this,[[1,3]]);}));function getData(_x){return _getData.apply(this,arguments);}return getData;}()/**
|
1251
1113
|
* Implement requests in a non-blocking way
|
1252
1114
|
*/)},{key:"getAsyncData",value:function getAsyncData(config){var _this=this;var callback=config.callback,url=config.url,options=config.options,timeout=config.timeout,isRawResponse=config.isRawResponse;var isFireAndForget=!isFunction(callback);xhrRequest(createXhrRequestOptions(url,options,this.basicAuthHeader),timeout,this.logger).then(function(data){if(!isFireAndForget){callback(isRawResponse?data.response:responseTextToJson(data.response,_this.onError),data);}}).catch(function(data){if(!isFireAndForget){callback(undefined,data);}});}/**
|
1253
1115
|
* Handle errors
|
@@ -1267,16 +1129,48 @@ var APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','anony
|
|
1267
1129
|
'eventBuffer',// pre-load event buffer (may contain PII)
|
1268
1130
|
'traits','authToken'];var NOTIFIER_NAME='RudderStack JavaScript SDK';var SDK_GITHUB_URL='__REPOSITORY_URL__';var SOURCE_NAME='js';
|
1269
1131
|
|
1132
|
+
var detectAdBlockers=function detectAdBlockers(httpClient){state.capabilities.isAdBlockerDetectionInProgress.value=true;try{// Apparently, '?view=ad' is a query param that is blocked by majority of adblockers
|
1133
|
+
// Use source config URL here as it is very unlikely to be blocked by adblockers
|
1134
|
+
// Only the extra query param should make it vulnerable to adblockers
|
1135
|
+
// This will work even if the users proxies it.
|
1136
|
+
// The edge case where this doesn't work is when HEAD method is not allowed by the server (user's)
|
1137
|
+
var baseUrl=new URL(state.lifecycle.sourceConfigUrl.value);var url="".concat(baseUrl.origin).concat(baseUrl.pathname,"?view=ad");httpClient.getAsyncData({url:url,options:{// We actually don't need the response from the request, so we are using HEAD
|
1138
|
+
method:'HEAD',headers:{'Content-Type':undefined}},isRawResponse:true,callback:function callback(result,details){var _details$xhr;state.capabilities.isAdBlockerDetectionInProgress.value=false;// not ad blocked if the request is successful or it is not internally redirected on the client side
|
1139
|
+
// Often adblockers instead of blocking the request, they redirect it to an internal URL
|
1140
|
+
state.capabilities.isAdBlocked.value=(details===null||details===void 0?void 0:details.error)!==undefined||(details===null||details===void 0||(_details$xhr=details.xhr)===null||_details$xhr===void 0?void 0:_details$xhr.responseURL)!==url;}});}catch(err){// Reset the flag to prevent blocking future detection attempts
|
1141
|
+
state.capabilities.isAdBlockerDetectionInProgress.value=false;// Re-throw the error to be handled by the caller
|
1142
|
+
throw err;}};
|
1143
|
+
|
1270
1144
|
var getErrInstance=function getErrInstance(err,errorType){switch(errorType){case ErrorType.UNHANDLEDEXCEPTION:{var _ref=err,error=_ref.error;return error||err;}case ErrorType.UNHANDLEDREJECTION:{return err.reason;}case ErrorType.HANDLEDEXCEPTION:default:return err;}};var createNewBreadcrumb=function createNewBreadcrumb(message){return {type:'manual',name:message,timestamp:new Date(),metaData:{}};};/**
|
1271
1145
|
* A function to get the Bugsnag release stage for the current environment
|
1272
|
-
* @
|
1273
|
-
|
1274
|
-
|
1275
|
-
*
|
1276
|
-
*
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1146
|
+
* @param getHostName Optional function to get the hostname (primarily for testing)
|
1147
|
+
* @returns 'development' if the host is empty (for file:// protocol etc.) or a dev host (localhost, 127.0.0.1, etc.), otherwise 'beta' (it'll be replaced with the actual release stage during the build)
|
1148
|
+
*/var getReleaseStage=function getReleaseStage(){var getHostName=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return window.location.hostname;};var host=getHostName();return !host||host&&DEV_HOSTS.includes(host)?'development':'beta';};var getAppStateForMetadata=function getAppStateForMetadata(state){var stateStr=stringifyWithoutCircular(state,false,APP_STATE_EXCLUDE_KEYS);return stateStr!==null?JSON.parse(stateStr):{};};var getURLWithoutQueryString=function getURLWithoutQueryString(){var url=globalThis.location.href.split('?');return url[0];};var getUserDetails=function getUserDetails(source,session,lifecycle,autoTrack){var _source$value$id,_source$value,_session$sessionInfo$,_autoTrack$pageLifecy,_source$value$name,_source$value2;return {id:"".concat((_source$value$id=(_source$value=source.value)===null||_source$value===void 0?void 0:_source$value.id)!==null&&_source$value$id!==void 0?_source$value$id:lifecycle.writeKey.value,"..").concat((_session$sessionInfo$=session.sessionInfo.value.id)!==null&&_session$sessionInfo$!==void 0?_session$sessionInfo$:'NA',"..").concat((_autoTrack$pageLifecy=autoTrack.pageLifecycle.pageViewId.value)!==null&&_autoTrack$pageLifecy!==void 0?_autoTrack$pageLifecy:'NA'),name:(_source$value$name=(_source$value2=source.value)===null||_source$value2===void 0?void 0:_source$value2.name)!==null&&_source$value$name!==void 0?_source$value$name:'NA'};};var getDeviceDetails=function getDeviceDetails(locale,userAgent){var _locale$value,_userAgent$value;return {locale:(_locale$value=locale.value)!==null&&_locale$value!==void 0?_locale$value:'NA',userAgent:(_userAgent$value=userAgent.value)!==null&&_userAgent$value!==void 0?_userAgent$value:'NA',time:new Date()};};var getBugsnagErrorEvent=function getBugsnagErrorEvent(exception,errorState,state,groupingHash){var context=state.context,lifecycle=state.lifecycle,session=state.session,source=state.source,reporting=state.reporting,autoTrack=state.autoTrack;var app=context.app,locale=context.locale,userAgent=context.userAgent,timezone=context.timezone,screen=context.screen,library=context.library;return {payloadVersion:'5',notifier:{name:NOTIFIER_NAME,version:app.value.version,url:SDK_GITHUB_URL},events:[{exceptions:[clone(exception)],severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:app.value.version,releaseStage:getReleaseStage(),type:app.value.installType},device:getDeviceDetails(locale,userAgent),request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(reporting.breadcrumbs.value),context:exception.message,groupingHash:groupingHash,metaData:_objectSpread2({app:{snippetVersion:library.value.snippetVersion},device:_objectSpread2(_objectSpread2({},screen.value),{},{timezone:timezone.value})},getAppStateForMetadata(state)),user:getUserDetails(source,session,lifecycle,autoTrack)}]};};/**
|
1149
|
+
* A function to check if adblockers are active. The promise's resolve function
|
1150
|
+
* is invoked with true if adblockers are not detected and false otherwise.
|
1151
|
+
* @param {ApplicationState} state The application state
|
1152
|
+
* @param {IHttpClient} httpClient The HTTP client instance
|
1153
|
+
* @param {Function} resolve The promise's resolve function
|
1154
|
+
*/var checkIfAdBlockersAreActive=function checkIfAdBlockersAreActive(state,httpClient,resolve){// Initiate ad blocker detection if not done previously and not already in progress.
|
1155
|
+
if(isUndefined(state.capabilities.isAdBlocked.value)){if(state.capabilities.isAdBlockerDetectionInProgress.value===false){detectAdBlockers(httpClient);}// Wait for the detection to complete.
|
1156
|
+
var detectionDisposer=E(function(){if(isDefined(state.capabilities.isAdBlocked.value)){// If ad blocker is not detected, notify.
|
1157
|
+
resolve(state.capabilities.isAdBlocked.value===false);// Cleanup the effect.
|
1158
|
+
detectionDisposer();}});}else {// If ad blocker is not detected, notify.
|
1159
|
+
resolve(state.capabilities.isAdBlocked.value===false);}};/**
|
1160
|
+
* A function to determine whether the error should be promoted to notify or not.
|
1161
|
+
* For plugin and integration errors from RS CDN, if it is due to CSP blocked URLs or AdBlockers,
|
1162
|
+
* it will not be promoted to notify.
|
1163
|
+
* If it is due to other reasons, it will be promoted to notify.
|
1164
|
+
* @param {Error} exception The error object
|
1165
|
+
* @param {ApplicationState} state The application state
|
1166
|
+
* @param {IHttpClient} httpClient The HTTP client instance
|
1167
|
+
* @returns A promise that resolves to a boolean indicating whether the error should be promoted to notify or not
|
1168
|
+
*/var checkIfAllowedToBeNotified=function checkIfAllowedToBeNotified(exception,state,httpClient){var errMsg=exception.message;return new Promise(function(resolve){// Filter out script load failures that are not from the RS CDN.
|
1169
|
+
if(SCRIPT_LOAD_FAILURE_MESSAGES.some(function(regex){return regex.test(errMsg);})){var _exec;var extractedURL=(_exec=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(errMsg))===null||_exec===void 0?void 0:_exec[0];if(isString(extractedURL)){if(extractedURL.startsWith(SDK_CDN_BASE_URL)){// Filter out errors that are from CSP blocked URLs.
|
1170
|
+
if(state.capabilities.cspBlockedURLs.value.includes(extractedURL)){resolve(false);}else {// Filter out errors if adblockers are detected.
|
1171
|
+
checkIfAdBlockersAreActive(state,httpClient,resolve);}}else {// Filter out errors that are not from the RS CDN.
|
1172
|
+
resolve(false);}}else {// Allow the error to be notified if no URL could be extracted from the error message
|
1173
|
+
resolve(true);}}else {resolve(!ERROR_MESSAGES_TO_BE_FILTERED.some(function(e){return e.test(errMsg);}));}});};/**
|
1280
1174
|
* A function to determine if the error is from Rudder SDK
|
1281
1175
|
* @param {Error} exception
|
1282
1176
|
* @returns
|
@@ -1303,7 +1197,9 @@ function ErrorHandler(httpClient,logger){_classCallCheck(this,ErrorHandler);_def
|
|
1303
1197
|
* This method should be called once after construction.
|
1304
1198
|
*/return _createClass(ErrorHandler,[{key:"init",value:function init(){if(this.initialized){return;}this.attachErrorListeners();this.initialized=true;}/**
|
1305
1199
|
* Attach error listeners to the global window object
|
1306
|
-
*/},{key:"attachErrorListeners",value:function attachErrorListeners(){var _this=this;globalThis.addEventListener('error',function(event){_this.onError({error:event,context:ERROR_HANDLER,errorType:ErrorType.UNHANDLEDEXCEPTION});});globalThis.addEventListener('unhandledrejection',function(event){_this.onError({error:event,context:ERROR_HANDLER,errorType:ErrorType.UNHANDLEDREJECTION});})
|
1200
|
+
*/},{key:"attachErrorListeners",value:function attachErrorListeners(){var _this=this;globalThis.addEventListener('error',function(event){_this.onError({error:event,context:ERROR_HANDLER,errorType:ErrorType.UNHANDLEDEXCEPTION});});globalThis.addEventListener('unhandledrejection',function(event){_this.onError({error:event,context:ERROR_HANDLER,errorType:ErrorType.UNHANDLEDREJECTION});});// Listen to CSP violations and add the blocked URL to the state
|
1201
|
+
// if those URLs are from RS CDN.
|
1202
|
+
document.addEventListener('securitypolicyviolation',function(event){var blockedURL=isString(event.blockedURI)?event.blockedURI:'';if(event.disposition==='enforce'&&blockedURL.startsWith(SDK_CDN_BASE_URL)&&!state.capabilities.cspBlockedURLs.value.includes(blockedURL)){state.capabilities.cspBlockedURLs.value=[].concat(_toConsumableArray(state.capabilities.cspBlockedURLs.value),[blockedURL]);}});}/**
|
1307
1203
|
* Handle errors
|
1308
1204
|
* @param errorInfo - The error information
|
1309
1205
|
* @param errorInfo.error - The error to handle
|
@@ -1311,25 +1207,25 @@ function ErrorHandler(httpClient,logger){_classCallCheck(this,ErrorHandler);_def
|
|
1311
1207
|
* @param errorInfo.customMessage - The custom message of the error
|
1312
1208
|
* @param errorInfo.errorType - The type of the error (handled or unhandled)
|
1313
1209
|
* @param errorInfo.groupingHash - The grouping hash of the error
|
1314
|
-
*/},{key:"onError",value:function
|
1210
|
+
*/},{key:"onError",value:(function(){var _onError=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(errorInfo){var _errorInfo$errorType,error,context,customMessage,groupingHash,errorType,errInstance,normalizedError,customMsgVal,errorMsgPrefix,bsException,stacktrace,isSdkDispatched,isAllowed,errorState,normalizedGroupingHash,bugsnagPayload,_t;return _regenerator().w(function(_context){while(1)switch(_context.n){case 0:_context.p=0;error=errorInfo.error,context=errorInfo.context,customMessage=errorInfo.customMessage,groupingHash=errorInfo.groupingHash;errorType=(_errorInfo$errorType=errorInfo.errorType)!==null&&_errorInfo$errorType!==void 0?_errorInfo$errorType:ErrorType.HANDLEDEXCEPTION;errInstance=getErrInstance(error,errorType);normalizedError=normalizeError(errInstance,this.logger);if(!isUndefined(normalizedError)){_context.n=1;break;}return _context.a(2);case 1:customMsgVal=customMessage?"".concat(customMessage," - "):'';errorMsgPrefix="".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(customMsgVal);bsException=createBugsnagException(normalizedError,errorMsgPrefix);stacktrace=getStacktrace(normalizedError);isSdkDispatched=stacktrace.includes(MANUAL_ERROR_IDENTIFIER);// Filter errors that are not originated in the SDK.
|
1315
1211
|
// In case of NPM installations, the unhandled errors from the SDK cannot be identified
|
1316
1212
|
// and will NOT be reported unless they occur in plugins or integrations.
|
1317
|
-
if(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCEPTION){return;
|
1213
|
+
if(!(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCEPTION)){_context.n=2;break;}return _context.a(2);case 2:if(!state.reporting.isErrorReportingEnabled.value){_context.n=4;break;}_context.n=3;return checkIfAllowedToBeNotified(bsException,state,this.httpClient);case 3:isAllowed=_context.v;if(isAllowed){errorState={severity:'error',unhandled:errorType!==ErrorType.HANDLEDEXCEPTION,severityReason:{type:errorType}};// Set grouping hash only for CDN installations (as an experiment)
|
1318
1214
|
// This will allow us to group errors by the message instead of the surrounding code.
|
1319
1215
|
// In case of NPM installations, the default grouping by surrounding code does not make sense as each user application is different.
|
1320
1216
|
// References:
|
1321
1217
|
// https://docs.bugsnag.com/platforms/javascript/customizing-error-reports/#groupinghash
|
1322
1218
|
// https://docs.bugsnag.com/product/error-grouping/#user_defined
|
1323
|
-
|
1324
|
-
|
1325
|
-
this.httpClient.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true});}
|
1326
|
-
if(errorType===ErrorType.HANDLEDEXCEPTION||isSdkDispatched){this.logger.error(bsException.message);}
|
1327
|
-
this.logger.error(HANDLE_ERROR_FAILURE(ERROR_HANDLER),
|
1219
|
+
normalizedGroupingHash=getErrorGroupingHash(groupingHash,bsException.message,state,this.logger);// Get the final payload to be sent to the metrics service
|
1220
|
+
bugsnagPayload=getBugsnagErrorEvent(bsException,errorState,state,normalizedGroupingHash);// send it to metrics service
|
1221
|
+
this.httpClient.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true});}case 4:// Log handled errors and errors dispatched by the SDK
|
1222
|
+
if(errorType===ErrorType.HANDLEDEXCEPTION||isSdkDispatched){this.logger.error(bsException.message);}_context.n=6;break;case 5:_context.p=5;_t=_context.v;// If an error occurs while handling an error, log it
|
1223
|
+
this.logger.error(HANDLE_ERROR_FAILURE(ERROR_HANDLER),_t);case 6:return _context.a(2);}},_callee,this,[[0,5]]);}));function onError(_x){return _onError.apply(this,arguments);}return onError;}()/**
|
1328
1224
|
* Add breadcrumbs to add insight of a user's journey before an error
|
1329
1225
|
* occurred and send to external error monitoring service via a plugin
|
1330
1226
|
*
|
1331
1227
|
* @param {string} breadcrumb breadcrumbs message
|
1332
|
-
*/},{key:"leaveBreadcrumb",value:function leaveBreadcrumb(breadcrumb){try{state.reporting.breadcrumbs.value=[].concat(_toConsumableArray(state.reporting.breadcrumbs.value),[createNewBreadcrumb(breadcrumb)]);}catch(err){this.onError({error:err,context:ERROR_HANDLER,customMessage:BREADCRUMB_ERROR,groupingHash:BREADCRUMB_ERROR});}}}]);}();// Note: Remember to call defaultErrorHandler.init() before using it
|
1228
|
+
*/)},{key:"leaveBreadcrumb",value:function leaveBreadcrumb(breadcrumb){try{state.reporting.breadcrumbs.value=[].concat(_toConsumableArray(state.reporting.breadcrumbs.value),[createNewBreadcrumb(breadcrumb)]);}catch(err){this.onError({error:err,context:ERROR_HANDLER,customMessage:BREADCRUMB_ERROR,groupingHash:BREADCRUMB_ERROR});}}}]);}();// Note: Remember to call defaultErrorHandler.init() before using it
|
1333
1229
|
var defaultErrorHandler=new ErrorHandler(defaultHttpClient,defaultLogger);
|
1334
1230
|
|
1335
1231
|
// to next or return the value if it is the last one instead of an array per
|
@@ -1344,6 +1240,7 @@ if(throws){throw err;}else {_this2.logger.error(PLUGIN_INVOCATION_ERROR(PLUGIN_E
|
|
1344
1240
|
|
1345
1241
|
/**
|
1346
1242
|
* A function to filter and return non cloud mode destinations
|
1243
|
+
* A destination is considered non cloud mode if it is not a cloud mode destination or if it is a hybrid mode destination
|
1347
1244
|
* @param destination
|
1348
1245
|
*
|
1349
1246
|
* @returns boolean
|
@@ -1353,7 +1250,14 @@ destination.config.useNativeSDK===true);};var isHybridModeDestination=function i
|
|
1353
1250
|
* @param destinations
|
1354
1251
|
*
|
1355
1252
|
* @returns destinations
|
1356
|
-
*/var getNonCloudDestinations=function getNonCloudDestinations(destinations){return destinations.filter(isNonCloudDestination);}
|
1253
|
+
*/var getNonCloudDestinations=function getNonCloudDestinations(destinations){return destinations.filter(isNonCloudDestination);};/**
|
1254
|
+
* A function to get the user friendly id for a destination
|
1255
|
+
* Replaces all spaces with hyphens and appends the id to the display name
|
1256
|
+
* @param displayName The display name of the destination
|
1257
|
+
* @param id The id of the destination
|
1258
|
+
*
|
1259
|
+
* @returns the user friendly id
|
1260
|
+
*/var getDestinationUserFriendlyId=function getDestinationUserFriendlyId(displayName,id){return "".concat(displayName.replaceAll(' ','-'),"___").concat(id);};
|
1357
1261
|
|
1358
1262
|
/**
|
1359
1263
|
* List of plugin names that are loaded as dynamic imports in modern builds
|
@@ -1586,7 +1490,7 @@ var SCRIPT_LOAD_TIMEOUT_MS=10*1000;// 10 seconds
|
|
1586
1490
|
var READY_CHECK_INTERVAL_MS=100;// 100 milliseconds
|
1587
1491
|
var DEVICE_MODE_DESTINATIONS_PLUGIN='DeviceModeDestinationsPlugin';
|
1588
1492
|
|
1589
|
-
var INTEGRATION_NOT_SUPPORTED_ERROR=function INTEGRATION_NOT_SUPPORTED_ERROR(destDisplayName){return "Integration for destination \"".concat(destDisplayName,"\" is not supported.");};var INTEGRATION_SDK_LOAD_ERROR=function INTEGRATION_SDK_LOAD_ERROR(destDisplayName){return "Failed to load integration SDK for destination \"".concat(destDisplayName,"\"");};var INTEGRATION_INIT_ERROR=function INTEGRATION_INIT_ERROR(destUserFriendlyId){return "Failed to initialize integration for destination \"".concat(destUserFriendlyId,"\".");};var INTEGRATIONS_DATA_ERROR=function INTEGRATIONS_DATA_ERROR(destUserFriendlyId){return "Failed to get integrations data for destination \"".concat(destUserFriendlyId,"\".");};var INTEGRATION_READY_TIMEOUT_ERROR=function INTEGRATION_READY_TIMEOUT_ERROR(timeout){return "A timeout of ".concat(timeout," ms occurred");};var INTEGRATION_READY_CHECK_ERROR=function INTEGRATION_READY_CHECK_ERROR(id){return "Failed to get the ready status from integration for destination \"".concat(id,"\"");};
|
1493
|
+
var INTEGRATION_NOT_SUPPORTED_ERROR=function INTEGRATION_NOT_SUPPORTED_ERROR(destDisplayName){return "Integration for destination \"".concat(destDisplayName,"\" is not supported.");};var INTEGRATION_SDK_LOAD_ERROR=function INTEGRATION_SDK_LOAD_ERROR(destDisplayName){return "Failed to load integration SDK for destination \"".concat(destDisplayName,"\"");};var INTEGRATION_INIT_ERROR=function INTEGRATION_INIT_ERROR(destUserFriendlyId){return "Failed to initialize integration for destination \"".concat(destUserFriendlyId,"\".");};var INTEGRATIONS_DATA_ERROR=function INTEGRATIONS_DATA_ERROR(destUserFriendlyId){return "Failed to get integrations data for destination \"".concat(destUserFriendlyId,"\".");};var INTEGRATION_READY_TIMEOUT_ERROR=function INTEGRATION_READY_TIMEOUT_ERROR(timeout){return "A timeout of ".concat(timeout," ms occurred");};var INTEGRATION_READY_CHECK_ERROR=function INTEGRATION_READY_CHECK_ERROR(id){return "Failed to get the ready status from integration for destination \"".concat(id,"\"");};var CUSTOM_INTEGRATION_INVALID_NAME_ERROR=function CUSTOM_INTEGRATION_INVALID_NAME_ERROR(context,name){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Custom integration name must be a non-empty string: \"").concat(name,"\".");};var CUSTOM_INTEGRATION_ALREADY_EXISTS_ERROR=function CUSTOM_INTEGRATION_ALREADY_EXISTS_ERROR(context,name){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"An integration with name \"").concat(name,"\" already exists.");};var INVALID_CUSTOM_INTEGRATION_ERROR=function INVALID_CUSTOM_INTEGRATION_ERROR(context,name){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The custom integration \"").concat(name,"\" does not match the expected format.");};
|
1590
1494
|
|
1591
1495
|
var isDestIntgConfigTruthy=function isDestIntgConfigTruthy(destIntgConfig){return !isUndefined(destIntgConfig)&&Boolean(destIntgConfig)===true;};var isDestIntgConfigFalsy=function isDestIntgConfigFalsy(destIntgConfig){return !isUndefined(destIntgConfig)&&Boolean(destIntgConfig)===false;};/**
|
1592
1496
|
* Filters the destinations that should not be loaded or forwarded events to based on the integration options (load or events API)
|
@@ -1774,31 +1678,31 @@ var destDisplayNamesToFileNamesMap=(_destDisplayNamesToFi={},_defineProperty(_de
|
|
1774
1678
|
* @param sdkTypeName The name of the destination SDK type
|
1775
1679
|
* @param logger Logger instance
|
1776
1680
|
* @returns true if the destination SDK code is evaluated, false otherwise
|
1777
|
-
*/var isDestinationSDKMounted=function isDestinationSDKMounted(destSDKIdentifier,sdkTypeName,logger){var _destSDKIdentifier;return Boolean(((_destSDKIdentifier=globalThis[destSDKIdentifier])===null||_destSDKIdentifier===void 0||(_destSDKIdentifier=_destSDKIdentifier[sdkTypeName])===null||_destSDKIdentifier===void 0?void 0:_destSDKIdentifier.prototype)&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');};var wait=function wait(time){return new Promise(function(resolve){globalThis.setTimeout(resolve,time);});};var
|
1681
|
+
*/var isDestinationSDKMounted=function isDestinationSDKMounted(destSDKIdentifier,sdkTypeName,logger){var _destSDKIdentifier;return Boolean(((_destSDKIdentifier=globalThis[destSDKIdentifier])===null||_destSDKIdentifier===void 0||(_destSDKIdentifier=_destSDKIdentifier[sdkTypeName])===null||_destSDKIdentifier===void 0?void 0:_destSDKIdentifier.prototype)&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');};var wait=function wait(time){return new Promise(function(resolve){globalThis.setTimeout(resolve,time);});};var createIntegrationInstance=function createIntegrationInstance(destSDKIdentifier,sdkTypeName,dest,state){var _state$consents$postC,_state$consents$postC2;var analyticsInstance=_objectSpread2({loadIntegration:state.nativeDestinations.loadIntegration.value,logLevel:state.lifecycle.logLevel.value,loadOnlyIntegrations:(_state$consents$postC=(_state$consents$postC2=state.consents.postConsent.value)===null||_state$consents$postC2===void 0?void 0:_state$consents$postC2.integrations)!==null&&_state$consents$postC!==void 0?_state$consents$postC:state.nativeDestinations.loadOnlyIntegrations.value},state.lifecycle.safeAnalyticsInstance.value);var integration=new globalThis[destSDKIdentifier][sdkTypeName](clone(dest.config),analyticsInstance,{shouldApplyDeviceModeTransformation:dest.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:dest.propagateEventsUntransformedOnError,destinationId:dest.id});return integration;};var _isDestinationReady=function isDestinationReady(dest){var time=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return new Promise(function(resolve,reject){var _dest$integration;if((_dest$integration=dest.integration)!==null&&_dest$integration!==void 0&&_dest$integration.isReady()){resolve(true);}else if(time>=READY_CHECK_TIMEOUT_MS){reject(new Error(INTEGRATION_READY_TIMEOUT_ERROR(READY_CHECK_TIMEOUT_MS)));}else {var curTime=Date.now();wait(READY_CHECK_INTERVAL_MS).then(function(){var elapsedTime=Date.now()-curTime;_isDestinationReady(dest,time+elapsedTime).then(resolve).catch(function(err){return reject(err);});});}});};/**
|
1778
1682
|
* Extracts the integration config, if any, from the given destination
|
1779
1683
|
* and merges it with the current integrations config
|
1780
1684
|
* @param dest Destination object
|
1781
1685
|
* @param curDestIntgConfig Current destinations integration config
|
1782
1686
|
* @param logger Logger object
|
1783
1687
|
* @returns Combined destinations integrations config
|
1784
|
-
*/var getCumulativeIntegrationsConfig=function getCumulativeIntegrationsConfig(dest,curDestIntgConfig,errorHandler){var _dest$
|
1688
|
+
*/var getCumulativeIntegrationsConfig=function getCumulativeIntegrationsConfig(dest,curDestIntgConfig,errorHandler){var _dest$integration2;var integrationsConfig=curDestIntgConfig;if(isFunction((_dest$integration2=dest.integration)===null||_dest$integration2===void 0?void 0:_dest$integration2.getDataForIntegrationsObject)){try{integrationsConfig=_objectSpread2(_objectSpread2({},curDestIntgConfig),getSanitizedValue(dest.integration.getDataForIntegrationsObject()));}catch(err){errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATIONS_DATA_ERROR(dest.userFriendlyId),groupingHash:INTEGRATIONS_DATA_ERROR(dest.displayName)});}}return integrationsConfig;};var initializeDestination=function initializeDestination(dest,state,destSDKIdentifier,sdkTypeName,errorHandler,logger){try{var _integration$init,_integration;var initializedDestination=clone(dest);var integration=initializedDestination.integration;if(isUndefined(integration)){integration=createIntegrationInstance(destSDKIdentifier,sdkTypeName,dest,state);initializedDestination.integration=integration;}(_integration$init=(_integration=integration).init)===null||_integration$init===void 0||_integration$init.call(_integration);_isDestinationReady(initializedDestination).then(function(){// Collect the integrations data for the hybrid mode destinations
|
1785
1689
|
if(isHybridModeDestination(initializedDestination)){state.nativeDestinations.integrationsConfig.value=getCumulativeIntegrationsConfig(initializedDestination,state.nativeDestinations.integrationsConfig.value,errorHandler);}state.nativeDestinations.initializedDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.initializedDestinations.value),[initializedDestination]);}).catch(function(err){state.nativeDestinations.failedDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.failedDestinations.value),[dest]);errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATION_READY_CHECK_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_READY_CHECK_ERROR(dest.displayName)});});}catch(err){state.nativeDestinations.failedDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.failedDestinations.value),[dest]);errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATION_INIT_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_INIT_ERROR(dest.displayName)});}};/**
|
1786
1690
|
* Applies source configuration overrides to destinations
|
1787
1691
|
* @param destinations Array of destinations to process
|
1788
1692
|
* @param sourceConfigOverride Source configuration override options
|
1789
1693
|
* @param logger Logger instance for warnings
|
1790
1694
|
* @returns Array of destinations with overrides applied
|
1791
|
-
*/var applySourceConfigurationOverrides=function applySourceConfigurationOverrides(destinations,sourceConfigOverride,logger){var _sourceConfigOverride;if(!(sourceConfigOverride!==null&&sourceConfigOverride!==void 0&&(_sourceConfigOverride=sourceConfigOverride.destinations)!==null&&_sourceConfigOverride!==void 0&&_sourceConfigOverride.length)){return
|
1695
|
+
*/var applySourceConfigurationOverrides=function applySourceConfigurationOverrides(destinations,sourceConfigOverride,logger){var _sourceConfigOverride;if(!(sourceConfigOverride!==null&&sourceConfigOverride!==void 0&&(_sourceConfigOverride=sourceConfigOverride.destinations)!==null&&_sourceConfigOverride!==void 0&&_sourceConfigOverride.length)){return filterDisabledDestinations(destinations);}var destIds=destinations.map(function(dest){return dest.id;});// Group overrides by destination ID to support future cloning
|
1792
1696
|
// When cloning is implemented, multiple overrides with same ID will create multiple destination instances
|
1793
1697
|
var overridesByDestId={};sourceConfigOverride.destinations.forEach(function(override){var existing=overridesByDestId[override.id]||[];existing.push(override);overridesByDestId[override.id]=existing;});// Find unmatched destination IDs and log warning
|
1794
1698
|
var unmatchedIds=Object.keys(overridesByDestId).filter(function(id){return !destIds.includes(id);});if(unmatchedIds.length>0){logger===null||logger===void 0||logger.warn("".concat(DEVICE_MODE_DESTINATIONS_PLUGIN,":: Source configuration override - Unable to identify the destinations with the following IDs: \"").concat(unmatchedIds.join(', '),"\""));}// Process overrides and apply them to destinations
|
1795
1699
|
var processedDestinations=[];destinations.forEach(function(dest){var overrides=overridesByDestId[dest.id];if(!overrides||overrides.length===0){// No override for this destination, keep original
|
1796
1700
|
processedDestinations.push(dest);return;}if(overrides.length>1){// Multiple overrides for the same destination, create clones
|
1797
|
-
overrides.forEach(function(override,index){var overriddenDestination=applyOverrideToDestination(dest,override,"".concat(index+1));overriddenDestination.cloned=true;processedDestinations.push(overriddenDestination);});}else {var overriddenDestination=applyOverrideToDestination(dest,overrides[0]);processedDestinations.push(overriddenDestination);}});return
|
1701
|
+
overrides.forEach(function(override,index){var overriddenDestination=applyOverrideToDestination(dest,override,"".concat(index+1));overriddenDestination.cloned=true;processedDestinations.push(overriddenDestination);});}else {var overriddenDestination=applyOverrideToDestination(dest,overrides[0]);processedDestinations.push(overriddenDestination);}});return filterDisabledDestinations(processedDestinations);};/**
|
1798
1702
|
* This function filters out disabled destinations from the provided array.
|
1799
1703
|
* @param destinations Array of destinations to filter
|
1800
1704
|
* @returns Filtered destinations to only include enabled ones
|
1801
|
-
*/var
|
1705
|
+
*/var filterDisabledDestinations=function filterDisabledDestinations(destinations){return destinations.filter(function(dest){return dest.enabled;});};/**
|
1802
1706
|
* Applies a single override configuration to a destination
|
1803
1707
|
* @param destination Original destination
|
1804
1708
|
* @param override Override configuration
|
@@ -1815,13 +1719,39 @@ var clonedDest=clone(destination);if(cloneId){clonedDest.id="".concat(destinatio
|
|
1815
1719
|
if(isEnabledStatusChanged){clonedDest.enabled=override.enabled;// Mark as overridden
|
1816
1720
|
clonedDest.overridden=true;}// Apply config overrides if provided for enabled destination
|
1817
1721
|
if(willApplyConfig){// Override the config with the new config and remove undefined and null values
|
1818
|
-
clonedDest.config=_removeUndefinedAndNullValues(_objectSpread2(_objectSpread2({},clonedDest.config),override.config));clonedDest.overridden=true;}return clonedDest;}
|
1819
|
-
|
1820
|
-
|
1722
|
+
clonedDest.config=_removeUndefinedAndNullValues(_objectSpread2(_objectSpread2({},clonedDest.config),override.config));clonedDest.overridden=true;}return clonedDest;};/**
|
1723
|
+
* Validates if a custom integration name is unique and not conflicting with existing destinations
|
1724
|
+
* @param name - The integration name to validate
|
1725
|
+
* @param integration - The custom integration instance
|
1726
|
+
* @param state - Application state
|
1727
|
+
* @param logger - Logger instance
|
1728
|
+
* @returns boolean indicating if the name is valid
|
1729
|
+
*/var validateCustomIntegration=function validateCustomIntegration(name,integration,state,logger){if(!isString(name)||name.trim().length===0){logger.error(CUSTOM_INTEGRATION_INVALID_NAME_ERROR(DEVICE_MODE_DESTINATIONS_PLUGIN,name));return false;}// Check against existing configured destinations
|
1730
|
+
var activeDestinations=state.nativeDestinations.activeDestinations.value||[];if(isDefined(destDisplayNamesToFileNamesMap[name])||activeDestinations.some(function(dest){return dest.displayName===name;})){logger.error(CUSTOM_INTEGRATION_ALREADY_EXISTS_ERROR(DEVICE_MODE_DESTINATIONS_PLUGIN,name));return false;}// Check if the integration is correctly implemented
|
1731
|
+
if(isNullOrUndefined(integration)||!isFunction(integration.isReady)||isDefined(integration.init)&&!isFunction(integration.init)||isDefined(integration.track)&&!isFunction(integration.track)||isDefined(integration.page)&&!isFunction(integration.page)||isDefined(integration.identify)&&!isFunction(integration.identify)||isDefined(integration.group)&&!isFunction(integration.group)||isDefined(integration.alias)&&!isFunction(integration.alias)){logger.error(INVALID_CUSTOM_INTEGRATION_ERROR(DEVICE_MODE_DESTINATIONS_PLUGIN,name));return false;}return true;};/**
|
1732
|
+
* Creates a Destination instance for a custom integration
|
1733
|
+
* @param name - The name of the custom integration
|
1734
|
+
* @param integration - The custom integration instance
|
1735
|
+
* @returns Destination instance configured for the custom integration
|
1736
|
+
*/var createCustomIntegrationDestination=function createCustomIntegrationDestination(name,integration,state,logger){// Generate unique ID for the custom integration
|
1737
|
+
var uniqueId="custom_".concat(generateUUID());var analyticsInstance=state.lifecycle.safeAnalyticsInstance.value;// Create a new logger object for the custom integration
|
1738
|
+
// to avoid conflicts with the main logger
|
1739
|
+
var integrationLogger=clone(logger);// Set the scope to the custom integration name
|
1740
|
+
// for easy identification in the logs
|
1741
|
+
integrationLogger.setScope(name);// Bind only the necessary methods to the new logger object
|
1742
|
+
var safeLogger={log:integrationLogger.log.bind(integrationLogger),info:integrationLogger.info.bind(integrationLogger),debug:integrationLogger.debug.bind(integrationLogger),warn:integrationLogger.warn.bind(integrationLogger),error:integrationLogger.error.bind(integrationLogger),setMinLogLevel:integrationLogger.setMinLogLevel.bind(integrationLogger)};// Create a destination object for the custom integration
|
1743
|
+
// similar to the standard device mode integrations
|
1744
|
+
var destination={id:uniqueId,displayName:name,userFriendlyId:getDestinationUserFriendlyId(name,uniqueId),shouldApplyDeviceModeTransformation:false,propagateEventsUntransformedOnError:false,config:{blacklistedEvents:[],whitelistedEvents:[],eventFilteringOption:'disable',connectionMode:'device',useNativeSDKToSend:true},enabled:true,isCustomIntegration:true,// Create a wrapper around the custom integration APIs
|
1745
|
+
// to make them consistent with the standard device mode integrations
|
1746
|
+
integration:_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({},integration.init&&{init:function init(){return integration.init(analyticsInstance,safeLogger);}}),integration.track&&{track:function track(event){return integration.track(analyticsInstance,safeLogger,event);}}),integration.page&&{page:function page(event){return integration.page(analyticsInstance,safeLogger,event);}}),integration.identify&&{identify:function identify(event){return integration.identify(analyticsInstance,safeLogger,event);}}),integration.group&&{group:function group(event){return integration.group(analyticsInstance,safeLogger,event);}}),integration.alias&&{alias:function alias(event){return integration.alias(analyticsInstance,safeLogger,event);}}),{},{isReady:function isReady(){return integration.isReady(analyticsInstance,safeLogger);}})};return destination;};
|
1747
|
+
|
1748
|
+
var pluginName$b='DeviceModeDestinations';var DeviceModeDestinations=function DeviceModeDestinations(){return {name:pluginName$b,initialize:function initialize(state){state.plugins.loadedPlugins.value=[].concat(_toConsumableArray(state.plugins.loadedPlugins.value),[pluginName$b]);},nativeDestinations:{addCustomIntegration:function addCustomIntegration(name,integration,state,logger){if(!validateCustomIntegration(name,integration,state,logger)){return;}var destination=createCustomIntegrationDestination(name,integration,state,logger);// Add them to the state
|
1749
|
+
state.nativeDestinations.activeDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.activeDestinations.value),[destination]);},setActiveDestinations:function setActiveDestinations(state,pluginsManager,errorHandler,logger){var _state$consents$postC,_state$consents$postC2;state.nativeDestinations.loadIntegration.value=state.loadOptions.value.loadIntegration;// Filter destination that doesn't have mapping config-->Integration names
|
1821
1750
|
var configSupportedDestinations=state.nativeDestinations.configuredDestinations.value.filter(function(configDest){if(destDisplayNamesToFileNamesMap[configDest.displayName]){return true;}var errMessage=INTEGRATION_NOT_SUPPORTED_ERROR(configDest.displayName);errorHandler===null||errorHandler===void 0||errorHandler.onError({error:new Error(errMessage),context:DEVICE_MODE_DESTINATIONS_PLUGIN});return false;});// Apply source configuration overrides if provided
|
1822
|
-
var
|
1823
|
-
var destinationsToLoad=filterDestinations((_state$consents$postC=(_state$consents$postC2=state.consents.postConsent.value)===null||_state$consents$postC2===void 0?void 0:_state$consents$postC2.integrations)!==null&&_state$consents$postC!==void 0?_state$consents$postC:state.nativeDestinations.loadOnlyIntegrations.value,
|
1824
|
-
(_pluginsManager$invok=pluginsManager.invokeSingle("consentManager.isDestinationConsented",state,dest.config,errorHandler,logger))!==null&&_pluginsManager$invok!==void 0?_pluginsManager$invok:true);})
|
1751
|
+
var configuredDestinations=state.loadOptions.value.sourceConfigurationOverride?applySourceConfigurationOverrides(configSupportedDestinations,state.loadOptions.value.sourceConfigurationOverride,logger):filterDisabledDestinations(configSupportedDestinations);// Filter destinations that are disabled through load or consent API options
|
1752
|
+
var destinationsToLoad=filterDestinations((_state$consents$postC=(_state$consents$postC2=state.consents.postConsent.value)===null||_state$consents$postC2===void 0?void 0:_state$consents$postC2.integrations)!==null&&_state$consents$postC!==void 0?_state$consents$postC:state.nativeDestinations.loadOnlyIntegrations.value,configuredDestinations);var consentedDestinations=destinationsToLoad.filter(function(dest){var _pluginsManager$invok;return(// if consent manager is not configured, then default to load the destination
|
1753
|
+
(_pluginsManager$invok=pluginsManager.invokeSingle("consentManager.isDestinationConsented",state,dest.config,errorHandler,logger))!==null&&_pluginsManager$invok!==void 0?_pluginsManager$invok:true);});// Add the distilled destinations to the active destinations list
|
1754
|
+
state.nativeDestinations.activeDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.activeDestinations.value),_toConsumableArray(consentedDestinations));},load:function load(state,externalSrcLoader,errorHandler,logger,externalScriptOnLoad){var integrationsCDNPath=state.lifecycle.integrationsCDNPath.value;var activeDestinations=state.nativeDestinations.activeDestinations.value;activeDestinations.forEach(function(dest){var sdkName=destDisplayNamesToFileNamesMap[dest.displayName];var destSDKIdentifier="".concat(sdkName,"_RS");// this is the name of the object loaded on the window
|
1825
1755
|
var sdkTypeName=sdkName;if(sdkTypeName&&!isDestinationSDKMounted(destSDKIdentifier,sdkTypeName)){var destSdkURL="".concat(integrationsCDNPath,"/").concat(sdkName,".min.js");externalSrcLoader.loadJSFile({url:destSdkURL,id:dest.userFriendlyId,callback:externalScriptOnLoad!==null&&externalScriptOnLoad!==void 0?externalScriptOnLoad:function(id,err){if(err){var customMessage=INTEGRATION_SDK_LOAD_ERROR(dest.displayName);errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:customMessage,groupingHash:customMessage});state.nativeDestinations.failedDestinations.value=[].concat(_toConsumableArray(state.nativeDestinations.failedDestinations.value),[dest]);}else {initializeDestination(dest,state,destSDKIdentifier,sdkTypeName,errorHandler);}},timeout:SCRIPT_LOAD_TIMEOUT_MS});}else {initializeDestination(dest,state,destSDKIdentifier,sdkTypeName,errorHandler);}});}}};};
|
1826
1756
|
|
1827
1757
|
var DEFAULT_TRANSFORMATION_QUEUE_OPTIONS={minRetryDelay:500,backoffFactor:2,maxAttempts:3};var REQUEST_TIMEOUT_MS$1=10*1000;// 10 seconds
|
@@ -2015,13 +1945,12 @@ return true;}catch(err){errorHandler===null||errorHandler===void 0||errorHandler
|
|
2015
1945
|
|
2016
1946
|
var DEFAULT_QUEUE_OPTIONS={maxItems:100};var QUEUE_NAME$1='rudder_destinations_events';var NATIVE_DESTINATION_QUEUE_PLUGIN='NativeDestinationQueuePlugin';
|
2017
1947
|
|
2018
|
-
var DESTINATION_EVENT_FILTERING_WARNING=function DESTINATION_EVENT_FILTERING_WARNING(context,eventName,destUserFriendlyId){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(eventName,"\" track event has been filtered for the \"").concat(destUserFriendlyId,"\" destination.");};var INTEGRATION_EVENT_FORWARDING_ERROR=function INTEGRATION_EVENT_FORWARDING_ERROR(id){return "Failed to
|
1948
|
+
var DESTINATION_EVENT_FILTERING_WARNING=function DESTINATION_EVENT_FILTERING_WARNING(context,eventName,destUserFriendlyId){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(eventName,"\" track event has been filtered for the \"").concat(destUserFriendlyId,"\" destination.");};var INTEGRATION_EVENT_FORWARDING_ERROR=function INTEGRATION_EVENT_FORWARDING_ERROR(type,id,name){return "Failed to send \"".concat(type,"\" event ").concat(name?"\"".concat(name,"\" "):'',"to integration for destination \"").concat(id,"\".");};
|
2019
1949
|
|
2020
1950
|
var getNormalizedQueueOptions$1=function getNormalizedQueueOptions(queueOpts){return mergeDeepRight(DEFAULT_QUEUE_OPTIONS,queueOpts);};var isValidEventName=function isValidEventName(eventName){return eventName&&typeof eventName==='string';};var isEventDenyListed=function isEventDenyListed(eventType,eventName,dest){if(eventType!=='track'){return false;}var _dest$config=dest.config,blacklistedEvents=_dest$config.blacklistedEvents,whitelistedEvents=_dest$config.whitelistedEvents,eventFilteringOption=_dest$config.eventFilteringOption;switch(eventFilteringOption){// Blacklist is chosen for filtering events
|
2021
1951
|
case 'blacklistedEvents':{if(!isValidEventName(eventName)){return false;}var trimmedEventName=eventName.trim();if(Array.isArray(blacklistedEvents)){return blacklistedEvents.some(function(eventObj){return eventObj.eventName.trim()===trimmedEventName;});}return false;}// Whitelist is chosen for filtering events
|
2022
|
-
case 'whitelistedEvents':{if(!isValidEventName(eventName)){return true;}var _trimmedEventName=eventName.trim();if(Array.isArray(whitelistedEvents)){return !whitelistedEvents.some(function(eventObj){return eventObj.eventName.trim()===_trimmedEventName;});}return true;}case 'disable':default:return false;}};var sendEventToDestination=function sendEventToDestination(item,dest,errorHandler,logger){var methodName=item.type.toString();try{var
|
2023
|
-
|
2024
|
-
(_dest$instance=dest.instance)===null||_dest$instance===void 0||(_dest$instance$method=_dest$instance[methodName])===null||_dest$instance$method===void 0||_dest$instance$method.call(_dest$instance,{message:item});}catch(err){errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:NATIVE_DESTINATION_QUEUE_PLUGIN,customMessage:INTEGRATION_EVENT_FORWARDING_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_EVENT_FORWARDING_ERROR(dest.displayName)});}};/**
|
1952
|
+
case 'whitelistedEvents':{if(!isValidEventName(eventName)){return true;}var _trimmedEventName=eventName.trim();if(Array.isArray(whitelistedEvents)){return !whitelistedEvents.some(function(eventObj){return eventObj.eventName.trim()===_trimmedEventName;});}return true;}case 'disable':default:return false;}};var sendEventToDestination=function sendEventToDestination(item,dest,errorHandler,logger){var methodName=item.type.toString();try{var _ref,_ref2;// Destinations expect the event to be wrapped under the `message` key
|
1953
|
+
var integrationEvent={message:item};(_ref=(_ref2=dest.integration)[methodName])===null||_ref===void 0||_ref.call(_ref2,integrationEvent);}catch(err){errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:NATIVE_DESTINATION_QUEUE_PLUGIN,customMessage:INTEGRATION_EVENT_FORWARDING_ERROR(methodName,dest.userFriendlyId,item.event),groupingHash:INTEGRATION_EVENT_FORWARDING_ERROR(methodName,dest.displayName,item.event)});}};/**
|
2025
1954
|
* A function to check if device mode transformation should be applied for a destination.
|
2026
1955
|
* @param dest Destination object
|
2027
1956
|
* @returns Boolean indicating whether the transformation should be applied
|
@@ -3181,8 +3110,8 @@ var availablePlugins=[].concat(_toConsumableArray(Object.keys(pluginsInventory))
|
|
3181
3110
|
* Register plugins that are direct imports to PluginEngine
|
3182
3111
|
*/},{key:"registerLocalPlugins",value:function registerLocalPlugins(){var _this2=this;Object.values(pluginsInventory).forEach(function(localPlugin){if(isFunction(localPlugin)&&state.plugins.activePlugins.value.includes(localPlugin().name)){_this2.register([localPlugin()]);}});}/**
|
3183
3112
|
* Register plugins that are dynamic imports to PluginEngine
|
3184
|
-
*/},{key:"registerRemotePlugins",value:function registerRemotePlugins(){var _this3=this;var remotePluginsList=remotePluginsInventory(state.plugins.activePlugins.value);Promise.all(Object.keys(remotePluginsList).map(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/
|
3185
|
-
state.plugins.failedPlugins.value=[].concat(_toConsumableArray(state.plugins.failedPlugins.value),[remotePluginKey]);_this3.onError(err,"Failed to load plugin \"".concat(remotePluginKey,"\""),err);});case
|
3113
|
+
*/},{key:"registerRemotePlugins",value:function registerRemotePlugins(){var _this3=this;var remotePluginsList=remotePluginsInventory(state.plugins.activePlugins.value);Promise.all(Object.keys(remotePluginsList).map(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(remotePluginKey){return _regenerator().w(function(_context){while(1)switch(_context.n){case 0:_context.n=1;return remotePluginsList[remotePluginKey]().then(function(remotePluginModule){return _this3.register([remotePluginModule.default()]);}).catch(function(err){// TODO: add retry here if dynamic import fails
|
3114
|
+
state.plugins.failedPlugins.value=[].concat(_toConsumableArray(state.plugins.failedPlugins.value),[remotePluginKey]);_this3.onError(err,"Failed to load plugin \"".concat(remotePluginKey,"\""),err);});case 1:return _context.a(2);}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}())).catch(function(err){_this3.onError(err);});}/**
|
3186
3115
|
* Extension point invoke that allows multiple plugins to be registered to it with error handling
|
3187
3116
|
*/},{key:"invokeMultiple",value:function invokeMultiple(extPoint){try{var _this$engine;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}return (_this$engine=this.engine).invokeMultiple.apply(_this$engine,[extPoint].concat(args));}catch(e){this.onError(e,extPoint);return [];}}/**
|
3188
3117
|
* Extension point invoke that allows a single plugin to be registered to it with error handling
|
@@ -3238,16 +3167,6 @@ if(key===undefined){var ret={};this.forEach(function(key,val){return ret[key]=va
|
|
3238
3167
|
var storeExports = requireStore();
|
3239
3168
|
var store = /*@__PURE__*/getDefaultExportFromCjs(storeExports);
|
3240
3169
|
|
3241
|
-
var detectAdBlockers=function detectAdBlockers(httpClient){// Apparently, '?view=ad' is a query param that is blocked by majority of adblockers
|
3242
|
-
// Use source config URL here as it is very unlikely to be blocked by adblockers
|
3243
|
-
// Only the extra query param should make it vulnerable to adblockers
|
3244
|
-
// This will work even if the users proxies it.
|
3245
|
-
// The edge case where this doesn't work is when HEAD method is not allowed by the server (user's)
|
3246
|
-
var baseUrl=new URL(state.lifecycle.sourceConfigUrl.value);var url="".concat(baseUrl.origin).concat(baseUrl.pathname,"?view=ad");httpClient.getAsyncData({url:url,options:{// We actually don't need the response from the request, so we are using HEAD
|
3247
|
-
method:'HEAD',headers:{'Content-Type':undefined}},isRawResponse:true,callback:function callback(result,details){var _details$xhr;// not ad blocked if the request is successful or it is not internally redirected on the client side
|
3248
|
-
// Often adblockers instead of blocking the request, they redirect it to an internal URL
|
3249
|
-
state.capabilities.isAdBlocked.value=(details===null||details===void 0?void 0:details.error)!==undefined||(details===null||details===void 0||(_details$xhr=details.xhr)===null||_details$xhr===void 0?void 0:_details$xhr.responseURL)!==url;}});};
|
3250
|
-
|
3251
3170
|
var hasCrypto=function hasCrypto(){return !isNullOrUndefined(globalThis.crypto)&&isFunction(globalThis.crypto.getRandomValues);};// eslint-disable-next-line compat/compat -- We are checking for the existence of navigator.userAgentData
|
3252
3171
|
var hasUAClientHints=function hasUAClientHints(){return !isNullOrUndefined(globalThis.navigator.userAgentData);};var hasBeacon=function hasBeacon(){return !isNullOrUndefined(globalThis.navigator.sendBeacon)&&isFunction(globalThis.navigator.sendBeacon);};var isIE11=function isIE11(){return Boolean(globalThis.navigator.userAgent.match(/Trident.*rv:11\./));};
|
3253
3172
|
|
@@ -3468,7 +3387,7 @@ if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}r(fun
|
|
3468
3387
|
* Transforms destinations config from source config response to Destination format
|
3469
3388
|
* @param destinations Array of destination items from config response
|
3470
3389
|
* @returns Array of transformed Destination objects
|
3471
|
-
*/var getDestinationsFromConfig=function getDestinationsFromConfig(destinations){return destinations.map(function(destination){var _destination$shouldAp,_destination$propagat;return {id:destination.id,displayName:destination.destinationDefinition.displayName,enabled:destination.enabled,config:destination.config,shouldApplyDeviceModeTransformation:(_destination$shouldAp=destination.shouldApplyDeviceModeTransformation)!==null&&_destination$shouldAp!==void 0?_destination$shouldAp:false,propagateEventsUntransformedOnError:(_destination$propagat=destination.propagateEventsUntransformedOnError)!==null&&_destination$propagat!==void 0?_destination$propagat:false,userFriendlyId:
|
3390
|
+
*/var getDestinationsFromConfig=function getDestinationsFromConfig(destinations){return destinations.map(function(destination){var _destination$shouldAp,_destination$propagat;return {id:destination.id,displayName:destination.destinationDefinition.displayName,enabled:destination.enabled,config:destination.config,shouldApplyDeviceModeTransformation:(_destination$shouldAp=destination.shouldApplyDeviceModeTransformation)!==null&&_destination$shouldAp!==void 0?_destination$shouldAp:false,propagateEventsUntransformedOnError:(_destination$propagat=destination.propagateEventsUntransformedOnError)!==null&&_destination$propagat!==void 0?_destination$propagat:false,userFriendlyId:getDestinationUserFriendlyId(destination.destinationDefinition.displayName,destination.id)};});};
|
3472
3391
|
|
3473
3392
|
/**
|
3474
3393
|
* A function that determines the base URL for the integrations or plugins SDK
|
@@ -3534,20 +3453,20 @@ var timezone=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return timezone!==nul
|
|
3534
3453
|
/**
|
3535
3454
|
* Get the referrer URL
|
3536
3455
|
* @returns The referrer URL
|
3537
|
-
*/var getReferrer=function getReferrer(){var
|
3456
|
+
*/var getReferrer=function getReferrer(){var _getDocument;var getDocument=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return document;};return ((_getDocument=getDocument())===null||_getDocument===void 0?void 0:_getDocument.referrer)||'$direct';};/**
|
3538
3457
|
* To get the canonical URL of the page
|
3539
3458
|
* @returns canonical URL
|
3540
|
-
*/var getCanonicalUrl=function getCanonicalUrl(){var tags=
|
3459
|
+
*/var getCanonicalUrl=function getCanonicalUrl(){var getDocument=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return document;};var docInstance=getDocument();var tags=docInstance.getElementsByTagName('link');var canonicalUrl='';for(var i=0;tags[i];i+=1){var tag=tags[i];if(tag.getAttribute('rel')==='canonical'&&!canonicalUrl){var _tag$getAttribute;canonicalUrl=(_tag$getAttribute=tag.getAttribute('href'))!==null&&_tag$getAttribute!==void 0?_tag$getAttribute:'';break;}}return canonicalUrl;};var getUserAgent=function getUserAgent(){var getNavigator=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return globalThis.navigator;};var navigator=getNavigator();if(isUndefined(navigator)){return null;}var userAgent=navigator.userAgent;var _ref=navigator,brave=_ref.brave;// For supporting Brave browser detection,
|
3541
3460
|
// add "Brave/<version>" to the user agent with the version value from the Chrome component
|
3542
3461
|
if(brave&&Object.getPrototypeOf(brave).isBrave){// Example:
|
3543
3462
|
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36
|
3544
|
-
var matchedArr=userAgent.match(/(chrome)\/([\w.]+)/i);if(matchedArr){userAgent="".concat(userAgent," Brave/").concat(matchedArr[2]);}}return userAgent;};var getLanguage=function getLanguage(){var
|
3463
|
+
var matchedArr=userAgent.match(/(chrome)\/([\w.]+)/i);if(matchedArr){userAgent="".concat(userAgent," Brave/").concat(matchedArr[2]);}}return userAgent;};var getLanguage=function getLanguage(){var _navigator$language;var getNavigator=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return globalThis.navigator;};var navigator=getNavigator();if(isUndefined(navigator)){return null;}return (_navigator$language=navigator.language)!==null&&_navigator$language!==void 0?_navigator$language:navigator.browserLanguage;};/**
|
3545
3464
|
* Default page properties
|
3546
3465
|
* @returns Default page properties
|
3547
|
-
*/var getDefaultPageProperties=function getDefaultPageProperties(){var canonicalUrl=getCanonicalUrl();var path=
|
3466
|
+
*/var getDefaultPageProperties=function getDefaultPageProperties(){var getLocation=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return globalThis.location;};var getDocument=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){return document;};var location=getLocation();var canonicalUrl=getCanonicalUrl(getDocument);var path=location.pathname;var tabUrl=location.href;var pageUrl=tabUrl;var search=location.search;// If valid canonical URL is provided use this as page URL.
|
3548
3467
|
if(canonicalUrl){try{var urlObj=new URL(canonicalUrl);// If existing, query params of canonical URL will be used instead of the location.search ones
|
3549
3468
|
if(urlObj.search===''){pageUrl=canonicalUrl+search;}else {pageUrl=canonicalUrl;}path=urlObj.pathname;}catch(err){// Do nothing
|
3550
|
-
}}var url=getUrlWithoutHash(pageUrl);var
|
3469
|
+
}}var url=getUrlWithoutHash(pageUrl);var _getDocument2=getDocument(),title=_getDocument2.title;var referrer=getReferrer(getDocument);return {path:path,referrer:referrer,referring_domain:getReferringDomain(referrer),search:search,title:title,url:url,tab_url:tabUrl};};
|
3551
3470
|
|
3552
3471
|
// @ts-expect-error we're dynamically filling this value during build
|
3553
3472
|
// eslint-disable-next-line no-constant-condition
|
@@ -4012,7 +3931,12 @@ if(state.consents.enabled.value&&!state.consents.initialized.value){var _this$pl
|
|
4012
3931
|
(_this$userSessionMana11=this.userSessionManager)===null||_this$userSessionMana11===void 0||_this$userSessionMana11.syncStorageDataToState();// Resume event manager to process the events to destinations
|
4013
3932
|
(_this$eventManager7=this.eventManager)===null||_this$eventManager7===void 0||_this$eventManager7.resume();this.loadDestinations();this.sendTrackingEvents(isBufferedInvocation);}},{key:"sendTrackingEvents",value:function sendTrackingEvents(isBufferedInvocation){// If isBufferedInvocation is true, then the tracking events will be added to the end of the
|
4014
3933
|
// events buffer array so that any other preload events (mainly from query string API) will be processed first.
|
4015
|
-
if(state.consents.postConsent.value.trackConsent){var trackOptions=trackArgumentsToCallOptions(CONSENT_TRACK_EVENT_NAME);if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['track',trackOptions]]);}else {this.track(trackOptions);}}if(state.consents.postConsent.value.sendPageEvent){var pageOptions=pageArgumentsToCallOptions();if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['page',pageOptions]]);}else {this.page(pageOptions);}}}},{key:"setAuthToken",value:function setAuthToken(token){var _this$userSessionMana12;(_this$userSessionMana12=this.userSessionManager)===null||_this$userSessionMana12===void 0||_this$userSessionMana12.setAuthToken(token);}
|
3934
|
+
if(state.consents.postConsent.value.trackConsent){var trackOptions=trackArgumentsToCallOptions(CONSENT_TRACK_EVENT_NAME);if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['track',trackOptions]]);}else {this.track(trackOptions);}}if(state.consents.postConsent.value.sendPageEvent){var pageOptions=pageArgumentsToCallOptions();if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['page',pageOptions]]);}else {this.page(pageOptions);}}}},{key:"setAuthToken",value:function setAuthToken(token){var _this$userSessionMana12;(_this$userSessionMana12=this.userSessionManager)===null||_this$userSessionMana12===void 0||_this$userSessionMana12.setAuthToken(token);}/**
|
3935
|
+
* Add a custom integration to the SDK.
|
3936
|
+
* @param name - The name of the custom integration.
|
3937
|
+
* @param integration - The custom integration object.
|
3938
|
+
* @param isBufferedInvocation - Whether the invocation is buffered.
|
3939
|
+
*/},{key:"addCustomIntegration",value:function addCustomIntegration(name,integration){var isBufferedInvocation=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var type='addCustomIntegration';if(isBufferedInvocation){var _this$pluginsManager7;this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));(_this$pluginsManager7=this.pluginsManager)===null||_this$pluginsManager7===void 0||_this$pluginsManager7.invokeSingle('nativeDestinations.addCustomIntegration',name,integration,state,this.logger);}else {if(state.lifecycle.loaded.value){this.logger.error(CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR(ANALYTICS_CORE,name));return;}state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,name,integration]]);}}// End consumer exposed methods
|
4016
3940
|
}]);}();
|
4017
3941
|
|
4018
3942
|
/*
|
@@ -4025,10 +3949,14 @@ function RudderAnalytics(){_classCallCheck(this,RudderAnalytics);// END-NO-SONAR
|
|
4025
3949
|
_defineProperty(this,"analyticsInstances",{});_defineProperty(this,"defaultAnalyticsKey",'');_defineProperty(this,"logger",defaultLogger);try{if(RudderAnalytics.globalSingleton){// START-NO-SONAR-SCAN
|
4026
3950
|
// eslint-disable-next-line no-constructor-return
|
4027
3951
|
return RudderAnalytics.globalSingleton;// END-NO-SONAR-SCAN
|
4028
|
-
}RudderAnalytics.initializeGlobalResources();this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this);this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this);this.load=this.load.bind(this);this.ready=this.ready.bind(this);this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this);this.page=this.page.bind(this);this.track=this.track.bind(this);this.identify=this.identify.bind(this);this.alias=this.alias.bind(this);this.group=this.group.bind(this);this.reset=this.reset.bind(this);this.getAnonymousId=this.getAnonymousId.bind(this);this.setAnonymousId=this.setAnonymousId.bind(this);this.getUserId=this.getUserId.bind(this);this.getUserTraits=this.getUserTraits.bind(this);this.getGroupId=this.getGroupId.bind(this);this.getGroupTraits=this.getGroupTraits.bind(this);this.startSession=this.startSession.bind(this);this.endSession=this.endSession.bind(this);this.getSessionId=this.getSessionId.bind(this);this.setAuthToken=this.setAuthToken.bind(this);this.consent=this.consent.bind(this);RudderAnalytics.globalSingleton=this;state.autoTrack.pageLifecycle.pageViewId.value=generateUUID();state.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now();// start loading if a load event was buffered or wait for explicit load call
|
3952
|
+
}RudderAnalytics.initializeGlobalResources();this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this);this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this);this.load=this.load.bind(this);this.ready=this.ready.bind(this);this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this);this.page=this.page.bind(this);this.track=this.track.bind(this);this.identify=this.identify.bind(this);this.alias=this.alias.bind(this);this.group=this.group.bind(this);this.reset=this.reset.bind(this);this.getAnonymousId=this.getAnonymousId.bind(this);this.setAnonymousId=this.setAnonymousId.bind(this);this.getUserId=this.getUserId.bind(this);this.getUserTraits=this.getUserTraits.bind(this);this.getGroupId=this.getGroupId.bind(this);this.getGroupTraits=this.getGroupTraits.bind(this);this.startSession=this.startSession.bind(this);this.endSession=this.endSession.bind(this);this.getSessionId=this.getSessionId.bind(this);this.setAuthToken=this.setAuthToken.bind(this);this.consent=this.consent.bind(this);this.addCustomIntegration=this.addCustomIntegration.bind(this);this.createSafeAnalyticsInstance();RudderAnalytics.globalSingleton=this;state.autoTrack.pageLifecycle.pageViewId.value=generateUUID();state.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now();// start loading if a load event was buffered or wait for explicit load call
|
4029
3953
|
this.triggerBufferedLoadEvent();// Assign to global "rudderanalytics" object after processing the preload buffer (if any exists)
|
4030
3954
|
// for CDN bundling IIFE exports covers this but for npm ESM and CJS bundling has to be done explicitly
|
4031
|
-
globalThis.rudderanalytics=this;}catch(error){dispatchErrorEvent(error);}}
|
3955
|
+
globalThis.rudderanalytics=this;}catch(error){dispatchErrorEvent(error);}}/**
|
3956
|
+
* Create an instance of the current instance that can be used
|
3957
|
+
* to call a subset of methods of the current instance.
|
3958
|
+
* It is typically used to expose the analytics instance to the integrations (standard and custom)
|
3959
|
+
*/return _createClass(RudderAnalytics,[{key:"createSafeAnalyticsInstance",value:function createSafeAnalyticsInstance(){state.lifecycle.safeAnalyticsInstance.value={page:this.page.bind(this),track:this.track.bind(this),identify:this.identify.bind(this),alias:this.alias.bind(this),group:this.group.bind(this),getAnonymousId:this.getAnonymousId.bind(this),getUserId:this.getUserId.bind(this),getUserTraits:this.getUserTraits.bind(this),getGroupId:this.getGroupId.bind(this),getGroupTraits:this.getGroupTraits.bind(this),getSessionId:this.getSessionId.bind(this)};}},{key:"setDefaultInstanceKey",value:/**
|
4032
3960
|
* Set instance to use if no specific writeKey is provided in methods
|
4033
3961
|
* automatically for the first created instance
|
4034
3962
|
* TODO: to support multiple analytics instances in the near future
|
@@ -4089,7 +4017,7 @@ this.load.apply(null,loadEvent);}}/**
|
|
4089
4017
|
},{key:"alias",value:function alias(to,from,options,callback){try{var _this$getAnalyticsIns6;(_this$getAnalyticsIns6=this.getAnalyticsInstance())===null||_this$getAnalyticsIns6===void 0||_this$getAnalyticsIns6.alias(aliasArgumentsToCallOptions(getSanitizedValue(to),getSanitizedValue(from),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}/**
|
4090
4018
|
* Process group arguments and forward to page call
|
4091
4019
|
*/// These overloads should be same as AnalyticsGroupMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics
|
4092
|
-
},{key:"group",value:function group(groupId,traits,options,callback){try{var _this$getAnalyticsIns7;(_this$getAnalyticsIns7=this.getAnalyticsInstance())===null||_this$getAnalyticsIns7===void 0||_this$getAnalyticsIns7.group(groupArgumentsToCallOptions(getSanitizedValue(groupId),getSanitizedValue(traits),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}},{key:"reset",value:function reset(resetAnonymousId){try{var _this$getAnalyticsIns8;(_this$getAnalyticsIns8=this.getAnalyticsInstance())===null||_this$getAnalyticsIns8===void 0||_this$getAnalyticsIns8.reset(getSanitizedValue(resetAnonymousId));}catch(error){dispatchErrorEvent(error);}}},{key:"getAnonymousId",value:function getAnonymousId(options){try{var _this$getAnalyticsIns9;return (_this$getAnalyticsIns9=this.getAnalyticsInstance())===null||_this$getAnalyticsIns9===void 0?void 0:_this$getAnalyticsIns9.getAnonymousId(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"setAnonymousId",value:function setAnonymousId(anonymousId,rudderAmpLinkerParam){try{var _this$getAnalyticsIns0;(_this$getAnalyticsIns0=this.getAnalyticsInstance())===null||_this$getAnalyticsIns0===void 0||_this$getAnalyticsIns0.setAnonymousId(getSanitizedValue(anonymousId),getSanitizedValue(rudderAmpLinkerParam));}catch(error){dispatchErrorEvent(error);}}},{key:"getUserId",value:function getUserId(){try{var _this$getAnalyticsIns1;return (_this$getAnalyticsIns1=this.getAnalyticsInstance())===null||_this$getAnalyticsIns1===void 0?void 0:_this$getAnalyticsIns1.getUserId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getUserTraits",value:function getUserTraits(){try{var _this$getAnalyticsIns10;return (_this$getAnalyticsIns10=this.getAnalyticsInstance())===null||_this$getAnalyticsIns10===void 0?void 0:_this$getAnalyticsIns10.getUserTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getGroupId",value:function getGroupId(){try{var _this$getAnalyticsIns11;return (_this$getAnalyticsIns11=this.getAnalyticsInstance())===null||_this$getAnalyticsIns11===void 0?void 0:_this$getAnalyticsIns11.getGroupId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getGroupTraits",value:function getGroupTraits(){try{var _this$getAnalyticsIns12;return (_this$getAnalyticsIns12=this.getAnalyticsInstance())===null||_this$getAnalyticsIns12===void 0?void 0:_this$getAnalyticsIns12.getGroupTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"startSession",value:function startSession(sessionId){try{var _this$getAnalyticsIns13;(_this$getAnalyticsIns13=this.getAnalyticsInstance())===null||_this$getAnalyticsIns13===void 0||_this$getAnalyticsIns13.startSession(getSanitizedValue(sessionId));}catch(error){dispatchErrorEvent(error);}}},{key:"endSession",value:function endSession(){try{var _this$getAnalyticsIns14;(_this$getAnalyticsIns14=this.getAnalyticsInstance())===null||_this$getAnalyticsIns14===void 0||_this$getAnalyticsIns14.endSession();}catch(error){dispatchErrorEvent(error);}}},{key:"getSessionId",value:function getSessionId(){try{var _this$getAnalyticsIns15;return (_this$getAnalyticsIns15=this.getAnalyticsInstance())===null||_this$getAnalyticsIns15===void 0?void 0:_this$getAnalyticsIns15.getSessionId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"setAuthToken",value:function setAuthToken(token){try{var _this$getAnalyticsIns16;(_this$getAnalyticsIns16=this.getAnalyticsInstance())===null||_this$getAnalyticsIns16===void 0||_this$getAnalyticsIns16.setAuthToken(getSanitizedValue(token));}catch(error){dispatchErrorEvent(error);}}},{key:"consent",value:function consent(options){try{var _this$getAnalyticsIns17;(_this$getAnalyticsIns17=this.getAnalyticsInstance())===null||_this$getAnalyticsIns17===void 0||_this$getAnalyticsIns17.consent(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);}}}],[{key:"initializeGlobalResources",value:function initializeGlobalResources(){// We need to initialize the error handler first to catch any unhandled errors occurring in this module as well
|
4020
|
+
},{key:"group",value:function group(groupId,traits,options,callback){try{var _this$getAnalyticsIns7;(_this$getAnalyticsIns7=this.getAnalyticsInstance())===null||_this$getAnalyticsIns7===void 0||_this$getAnalyticsIns7.group(groupArgumentsToCallOptions(getSanitizedValue(groupId),getSanitizedValue(traits),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}},{key:"reset",value:function reset(resetAnonymousId){try{var _this$getAnalyticsIns8;(_this$getAnalyticsIns8=this.getAnalyticsInstance())===null||_this$getAnalyticsIns8===void 0||_this$getAnalyticsIns8.reset(getSanitizedValue(resetAnonymousId));}catch(error){dispatchErrorEvent(error);}}},{key:"getAnonymousId",value:function getAnonymousId(options){try{var _this$getAnalyticsIns9;return (_this$getAnalyticsIns9=this.getAnalyticsInstance())===null||_this$getAnalyticsIns9===void 0?void 0:_this$getAnalyticsIns9.getAnonymousId(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"setAnonymousId",value:function setAnonymousId(anonymousId,rudderAmpLinkerParam){try{var _this$getAnalyticsIns0;(_this$getAnalyticsIns0=this.getAnalyticsInstance())===null||_this$getAnalyticsIns0===void 0||_this$getAnalyticsIns0.setAnonymousId(getSanitizedValue(anonymousId),getSanitizedValue(rudderAmpLinkerParam));}catch(error){dispatchErrorEvent(error);}}},{key:"getUserId",value:function getUserId(){try{var _this$getAnalyticsIns1;return (_this$getAnalyticsIns1=this.getAnalyticsInstance())===null||_this$getAnalyticsIns1===void 0?void 0:_this$getAnalyticsIns1.getUserId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getUserTraits",value:function getUserTraits(){try{var _this$getAnalyticsIns10;return (_this$getAnalyticsIns10=this.getAnalyticsInstance())===null||_this$getAnalyticsIns10===void 0?void 0:_this$getAnalyticsIns10.getUserTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getGroupId",value:function getGroupId(){try{var _this$getAnalyticsIns11;return (_this$getAnalyticsIns11=this.getAnalyticsInstance())===null||_this$getAnalyticsIns11===void 0?void 0:_this$getAnalyticsIns11.getGroupId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"getGroupTraits",value:function getGroupTraits(){try{var _this$getAnalyticsIns12;return (_this$getAnalyticsIns12=this.getAnalyticsInstance())===null||_this$getAnalyticsIns12===void 0?void 0:_this$getAnalyticsIns12.getGroupTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"startSession",value:function startSession(sessionId){try{var _this$getAnalyticsIns13;(_this$getAnalyticsIns13=this.getAnalyticsInstance())===null||_this$getAnalyticsIns13===void 0||_this$getAnalyticsIns13.startSession(getSanitizedValue(sessionId));}catch(error){dispatchErrorEvent(error);}}},{key:"endSession",value:function endSession(){try{var _this$getAnalyticsIns14;(_this$getAnalyticsIns14=this.getAnalyticsInstance())===null||_this$getAnalyticsIns14===void 0||_this$getAnalyticsIns14.endSession();}catch(error){dispatchErrorEvent(error);}}},{key:"getSessionId",value:function getSessionId(){try{var _this$getAnalyticsIns15;return (_this$getAnalyticsIns15=this.getAnalyticsInstance())===null||_this$getAnalyticsIns15===void 0?void 0:_this$getAnalyticsIns15.getSessionId();}catch(error){dispatchErrorEvent(error);return undefined;}}},{key:"setAuthToken",value:function setAuthToken(token){try{var _this$getAnalyticsIns16;(_this$getAnalyticsIns16=this.getAnalyticsInstance())===null||_this$getAnalyticsIns16===void 0||_this$getAnalyticsIns16.setAuthToken(getSanitizedValue(token));}catch(error){dispatchErrorEvent(error);}}},{key:"consent",value:function consent(options){try{var _this$getAnalyticsIns17;(_this$getAnalyticsIns17=this.getAnalyticsInstance())===null||_this$getAnalyticsIns17===void 0||_this$getAnalyticsIns17.consent(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);}}},{key:"addCustomIntegration",value:function addCustomIntegration(name,integration){try{var _this$getAnalyticsIns18;(_this$getAnalyticsIns18=this.getAnalyticsInstance())===null||_this$getAnalyticsIns18===void 0||_this$getAnalyticsIns18.addCustomIntegration(getSanitizedValue(name),getSanitizedValue(integration));}catch(error){dispatchErrorEvent(error);}}}],[{key:"initializeGlobalResources",value:function initializeGlobalResources(){// We need to initialize the error handler first to catch any unhandled errors occurring in this module as well
|
4093
4021
|
defaultErrorHandler.init();// Initialize the storage engines with default options
|
4094
4022
|
defaultCookieStorage.configure();defaultLocalStorage.configure();defaultSessionStorage.configure();defaultInMemoryStorage.configure();}}]);}();// START-NO-SONAR-SCAN
|
4095
4023
|
// eslint-disable-next-line sonarjs/public-static-readonly
|