@rudderstack/analytics-js 3.21.0 → 3.22.1-beta.pr.2309.2d82a3e
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 +25 -0
- package/dist/npm/index.d.cts +229 -58
- package/dist/npm/index.d.mts +229 -58
- package/dist/npm/legacy/bundled/cjs/index.cjs +199 -286
- package/dist/npm/legacy/bundled/esm/index.mjs +199 -286
- package/dist/npm/legacy/bundled/umd/index.js +199 -286
- package/dist/npm/legacy/cjs/index.cjs +199 -286
- package/dist/npm/legacy/content-script/cjs/index.cjs +198 -285
- package/dist/npm/legacy/content-script/esm/index.mjs +198 -285
- package/dist/npm/legacy/content-script/umd/index.js +198 -285
- package/dist/npm/legacy/esm/index.mjs +199 -286
- package/dist/npm/legacy/umd/index.js +199 -286
- package/dist/npm/modern/bundled/cjs/index.cjs +189 -139
- package/dist/npm/modern/bundled/esm/index.mjs +189 -139
- package/dist/npm/modern/bundled/umd/index.js +189 -139
- package/dist/npm/modern/cjs/index.cjs +58 -40
- package/dist/npm/modern/content-script/cjs/index.cjs +188 -138
- package/dist/npm/modern/content-script/esm/index.mjs +188 -138
- package/dist/npm/modern/content-script/umd/index.js +188 -138
- package/dist/npm/modern/esm/index.mjs +58 -40
- package/dist/npm/modern/umd/index.js +58 -40
- package/package.json +1 -1
@@ -72,9 +72,7 @@ function _isObject(x){return Object.prototype.toString.call(x)==='[object Object
|
|
72
72
|
* @return {Boolean}
|
73
73
|
*/const _isInteger = Number.isInteger||function _isInteger(n){return n<<0===n;};
|
74
74
|
|
75
|
-
function
|
76
|
-
|
77
|
-
function _nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];}
|
75
|
+
function _nth(offset,list){var idx=offset<0?list.length+offset:offset;return list[idx];}
|
78
76
|
|
79
77
|
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':''));}
|
80
78
|
|
@@ -137,7 +135,7 @@ function _path(pathAr,obj){var val=obj;for(var i=0;i<pathAr.length;i+=1){if(val=
|
|
137
135
|
* @param {Object} l
|
138
136
|
* @param {Object} r
|
139
137
|
* @return {Object}
|
140
|
-
* @see R.mergeDeepWithKey, R.
|
138
|
+
* @see R.mergeDeepWithKey, R.mergeWith
|
141
139
|
* @example
|
142
140
|
*
|
143
141
|
* let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
|
@@ -491,17 +489,21 @@ if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){res
|
|
491
489
|
*/const getSanitizedValue=(value,logger)=>{const replacer=getReplacer();// This is needed for registering the first ancestor
|
492
490
|
const newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return traverseWithThis(value,replacer);}return newValue;};
|
493
491
|
|
494
|
-
const MANUAL_ERROR_IDENTIFIER='[SDK DISPATCHED ERROR]';const getStacktrace=err=>{const{stack,stacktrace
|
492
|
+
const MANUAL_ERROR_IDENTIFIER='[SDK DISPATCHED ERROR]';const getStacktrace=err=>{const{stack,stacktrace,'opera#sourceloc':operaSourceloc}=err;const stackString=stack??stacktrace??operaSourceloc;if(!!stackString&&typeof stackString==='string'){return stackString;}return undefined;};/**
|
495
493
|
* Get mutated error with issue prepended to error message
|
496
494
|
* @param err Original error
|
497
495
|
* @param issue Issue to prepend to error message
|
498
496
|
* @returns Instance of Error with message prepended with issue
|
499
|
-
*/const getMutatedError=(err,issue)=>{
|
497
|
+
*/const getMutatedError=(err,issue)=>{if(!isTypeOfError(err)){return new Error(`${issue}: ${stringifyWithoutCircular(err)}`);}try{// Preserve the specific error type (TypeError, ReferenceError, etc.)
|
498
|
+
const ErrorConstructor=err.constructor;const newError=new ErrorConstructor(`${issue}: ${err.message}`);// Preserve stack trace
|
499
|
+
const stack=getStacktrace(err);if(stack){newError.stack=stack;}// Preserve any other enumerable properties
|
500
|
+
Object.getOwnPropertyNames(err).forEach(key=>{if(key!=='message'&&key!=='stack'&&key!=='name'){try{newError[key]=err[key];}catch{// Ignore if property is not writable
|
501
|
+
}}});return newError;}catch{return new Error(`${issue}: ${stringifyWithoutCircular(err)}`);}};const dispatchErrorEvent=error=>{if(isTypeOfError(error)){const errStack=getStacktrace(error);if(errStack){const{stack,stacktrace,'opera#sourceloc':operaSourceloc}=error;switch(errStack){case stack:// eslint-disable-next-line no-param-reassign
|
500
502
|
error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// eslint-disable-next-line no-param-reassign
|
501
503
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
502
504
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
503
505
|
|
504
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
506
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.22.1-beta.pr.2309.2d82a3e';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';const ADBLOCK_PAGE_NAME='ad-block page request';const ADBLOCK_PAGE_PATH='/ad-blocked';const GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';const CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
|
505
507
|
|
506
508
|
const QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';const QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';const QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';const QUERY_PARAM_USER_ID_KEY='ajs_uid';const QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
|
507
509
|
|
@@ -591,7 +593,7 @@ timeoutID=globalThis.setTimeout(()=>{reject(new Error(SCRIPT_LOAD_TIMEOUT_ERROR(
|
|
591
593
|
* Load external resource of type javascript
|
592
594
|
*/loadJSFile(config){const{url,id,timeout,async,callback,extraAttributes}=config;const isFireAndForget=!isFunction(callback);jsFileLoader(url,id,timeout||this.timeout,async,extraAttributes).then(id=>{if(!isFireAndForget){callback(id);}}).catch(err=>{if(!isFireAndForget){callback(id,err);}});}}
|
593
595
|
|
594
|
-
var i=Symbol.for("preact-signals");function t(){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();}}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;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(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v;},set:function(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();}}}});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(){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;
|
596
|
+
var i=Symbol.for("preact-signals");function t(){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();}}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;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(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v;},set:function(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();}}}});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(){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();}}}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();}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;}
|
595
597
|
|
596
598
|
/**
|
597
599
|
* A buffer queue to serve as a store for any type of data
|
@@ -620,7 +622,7 @@ const SUPPORTED_STORAGE_TYPES=['localStorage','memoryStorage','cookieStorage','s
|
|
620
622
|
|
621
623
|
const SOURCE_CONFIG_RESOLUTION_ERROR=`Unable to process/parse source configuration response`;const SOURCE_DISABLED_ERROR=`The source is disabled. Please enable the source in the dashboard to send events.`;const XHR_PAYLOAD_PREP_ERROR=`Failed to prepare data for the request.`;const PLUGIN_EXT_POINT_MISSING_ERROR=`Failed to invoke plugin because the extension point name is missing.`;const PLUGIN_EXT_POINT_INVALID_ERROR=`Failed to invoke plugin because the extension point name is invalid.`;const SOURCE_CONFIG_OPTION_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`;const COMPONENT_BASE_URL_ERROR=(context,component,url)=>`${context}${LOG_CONTEXT_SEPARATOR}The base URL "${url}" for ${component} is not valid.`;// ERROR
|
622
624
|
const UNSUPPORTED_CONSENT_MANAGER_ERROR=(context,selectedConsentManager,consentManagersToPluginNameMap)=>`${context}${LOG_CONTEXT_SEPARATOR}The consent manager "${selectedConsentManager}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(consentManagersToPluginNameMap)}".`;const NON_ERROR_WARNING=(context,errStr)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring a non-error: ${errStr}.`;const BREADCRUMB_ERROR=`Failed to log breadcrumb`;const HANDLE_ERROR_FAILURE=context=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to handle the error.`;const PLUGIN_NAME_MISSING_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin name is missing.`;const PLUGIN_ALREADY_EXISTS_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" already exists.`;const PLUGIN_NOT_FOUND_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" not found.`;const PLUGIN_ENGINE_BUG_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${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.`;const PLUGIN_DEPS_ERROR=(context,pluginName,notExistDeps)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" could not be loaded because some of its dependencies "${notExistDeps}" do not exist.`;const PLUGIN_INVOCATION_ERROR=(context,extPoint,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to invoke the "${extPoint}" extension point of plugin "${pluginName}".`;const STORAGE_UNAVAILABILITY_ERROR_PREFIX=(context,storageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${storageType}" storage type is `;const SOURCE_CONFIG_FETCH_ERROR='Failed to fetch the source config';const WRITE_KEY_VALIDATION_ERROR=(context,writeKey)=>`${context}${LOG_CONTEXT_SEPARATOR}The write key "${writeKey}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`;const DATA_PLANE_URL_VALIDATION_ERROR=(context,dataPlaneUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The data plane URL "${dataPlaneUrl}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`;const INVALID_CALLBACK_FN_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The provided callback parameter is not a function.`;const XHR_DELIVERY_ERROR=(prefix,status,statusText,url,response)=>`${prefix} with status ${status} (${statusText}) for URL: ${url}. Response: ${response.trim()}`;const XHR_REQUEST_ERROR=(prefix,e,url)=>`${prefix} due to timeout or no connection (${e?e.type:''}) at the client side for URL: ${url}`;const XHR_SEND_ERROR=(prefix,url)=>`${prefix} for URL: ${url}`;const STORE_DATA_SAVE_ERROR=key=>`Failed to save the value for "${key}" to storage`;const STORE_DATA_FETCH_ERROR=key=>`Failed to retrieve or parse data for "${key}" from storage`;const DATA_SERVER_REQUEST_FAIL_ERROR=status=>`The server responded with status ${status} while setting the cookies. As a fallback, the cookies will be set client side.`;const FAILED_SETTING_COOKIE_FROM_SERVER_ERROR=key=>`The server failed to set the ${key} cookie. As a fallback, the cookies will be set client side.`;const 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
|
623
|
-
const STORAGE_TYPE_VALIDATION_WARNING=(context,storageType,defaultStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${storageType}" is not supported. Please choose one of the following supported types: "${SUPPORTED_STORAGE_TYPES}". The default type "${defaultStorageType}" will be used instead.`;const UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage encryption version "${selectedStorageEncryptionVersion}" is not supported. Please choose one of the following supported versions: "${Object.keys(storageEncryptionVersionsToPluginNameMap)}". The default version "${defaultVersion}" will be used instead.`;const STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=(context,storageEncryptionVersion,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage data migration has been disabled because the configured storage encryption version (${storageEncryptionVersion}) is not the latest (${defaultVersion}). To enable storage data migration, please update the storage encryption version to the latest version.`;const SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=(context,providedCookieDomain,currentCookieDomain)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided cookie domain (${providedCookieDomain}) does not match the current webpage's domain (${currentCookieDomain}). Hence, the cookies will be set client-side.`;const RESERVED_KEYWORD_WARNING=(context,property,parentKeyPath,reservedElements)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${property}" property defined under "${parentKeyPath}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${reservedElements}).`;const INVALID_CONTEXT_OBJECT_WARNING=logContext=>`${logContext}${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.`;const UNSUPPORTED_BEACON_API_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`;const TIMEOUT_NOT_NUMBER_WARNING=(context,timeout,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value "${timeout}" is not a number. The default timeout of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_NOT_NUMBER_WARNING=(context,cutOffDuration,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" is not a number. The default cut off duration of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=(context,cutOffDuration,timeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" ms is less than the session timeout value "${timeout}" ms. The cut off functionality will be disabled.`;const TIMEOUT_ZERO_WARNING=context=>`${context}${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.`;const TIMEOUT_NOT_RECOMMENDED_WARNING=(context,timeout,minTimeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value ${timeout} ms is less than the recommended minimum of ${minTimeout} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`;const INVALID_SESSION_ID_WARNING=(context,sessionId,minSessionIdLength)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided session ID (${sessionId}) is either invalid, not a positive integer, or not at least "${minSessionIdLength}" digits long. A new session ID will be auto-generated instead.`;const STORAGE_QUOTA_EXCEEDED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`;const STORAGE_UNAVAILABLE_WARNING=(context,entry,selectedStorageType,finalStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${selectedStorageType}" is not available for entry "${entry}". The SDK will initialize the entry with "${finalStorageType}" storage type instead.`;const CALLBACK_INVOKE_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The callback threw an exception`;const INVALID_CONFIG_URL_WARNING=(context,configUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided source config URL "${configUrl}" is invalid. Using the default source config URL instead.`;const POLYFILL_SCRIPT_LOAD_ERROR=(scriptId,url)=>`Failed to load the polyfill script with ID "${scriptId}" from URL ${url}.`;const UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=(context,selectedStrategy,defaultStrategy)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent storage strategy "${selectedStrategy}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${defaultStrategy}" will be used instead.`;const UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=(context,selectedDeliveryType,defaultDeliveryType)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent events delivery type "${selectedDeliveryType}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${defaultDeliveryType}" will be used instead.`;const DEPRECATED_PLUGIN_WARNING=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}${pluginName} plugin is deprecated. Please exclude it from the load API options.`;const generateMisconfiguredPluginsWarning=(context,configurationStatus,missingPlugins,shouldAddMissingPlugins)=>{const isSinglePlugin=missingPlugins.length===1;const pluginsString=isSinglePlugin?` '${missingPlugins[0]}' plugin was`:` ['${missingPlugins.join("', '")}'] plugins were`;const baseWarning=`${context}${LOG_CONTEXT_SEPARATOR}${configurationStatus}, but${pluginsString} not configured to load.`;if(shouldAddMissingPlugins){return `${baseWarning} So, ${isSinglePlugin?'the plugin':'those plugins'} will be loaded automatically.`;}return `${baseWarning} Ignore if this was intentional. Otherwise, consider adding ${isSinglePlugin?'it':'them'} to the 'plugins' load API option.`;};const INVALID_POLYFILL_URL_WARNING=(context,customPolyfillUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided polyfill URL "${customPolyfillUrl}" is invalid. The default polyfill URL will be used instead.`;const PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`;const UNKNOWN_PLUGINS_WARNING=(context,unknownPlugins)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring unknown plugins: ${unknownPlugins.join(', ')}.`;
|
625
|
+
const STORAGE_TYPE_VALIDATION_WARNING=(context,storageType,defaultStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${storageType}" is not supported. Please choose one of the following supported types: "${SUPPORTED_STORAGE_TYPES}". The default type "${defaultStorageType}" will be used instead.`;const UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage encryption version "${selectedStorageEncryptionVersion}" is not supported. Please choose one of the following supported versions: "${Object.keys(storageEncryptionVersionsToPluginNameMap)}". The default version "${defaultVersion}" will be used instead.`;const STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=(context,storageEncryptionVersion,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage data migration has been disabled because the configured storage encryption version (${storageEncryptionVersion}) is not the latest (${defaultVersion}). To enable storage data migration, please update the storage encryption version to the latest version.`;const SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=(context,providedCookieDomain,currentCookieDomain)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided cookie domain (${providedCookieDomain}) does not match the current webpage's domain (${currentCookieDomain}). Hence, the cookies will be set client-side.`;const RESERVED_KEYWORD_WARNING=(context,property,parentKeyPath,reservedElements)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${property}" property defined under "${parentKeyPath}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${reservedElements}).`;const INVALID_CONTEXT_OBJECT_WARNING=logContext=>`${logContext}${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.`;const UNSUPPORTED_BEACON_API_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`;const TIMEOUT_NOT_NUMBER_WARNING=(context,timeout,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value "${timeout}" is not a number. The default timeout of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_NOT_NUMBER_WARNING=(context,cutOffDuration,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" is not a number. The default cut off duration of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=(context,cutOffDuration,timeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" ms is less than the session timeout value "${timeout}" ms. The cut off functionality will be disabled.`;const TIMEOUT_ZERO_WARNING=context=>`${context}${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.`;const TIMEOUT_NOT_RECOMMENDED_WARNING=(context,timeout,minTimeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value ${timeout} ms is less than the recommended minimum of ${minTimeout} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`;const INVALID_SESSION_ID_WARNING=(context,sessionId,minSessionIdLength)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided session ID (${sessionId}) is either invalid, not a positive integer, or not at least "${minSessionIdLength}" digits long. A new session ID will be auto-generated instead.`;const STORAGE_QUOTA_EXCEEDED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`;const STORAGE_UNAVAILABLE_WARNING=(context,entry,selectedStorageType,finalStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${selectedStorageType}" is not available for entry "${entry}". The SDK will initialize the entry with "${finalStorageType}" storage type instead.`;const CALLBACK_INVOKE_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The callback threw an exception`;const INVALID_CONFIG_URL_WARNING=(context,configUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided source config URL "${configUrl}" is invalid. Using the default source config URL instead.`;const POLYFILL_SCRIPT_LOAD_ERROR=(scriptId,url)=>`Failed to load the polyfill script with ID "${scriptId}" from URL ${url}.`;const UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=(context,selectedStrategy,defaultStrategy)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent storage strategy "${selectedStrategy}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${defaultStrategy}" will be used instead.`;const UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=(context,selectedDeliveryType,defaultDeliveryType)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent events delivery type "${selectedDeliveryType}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${defaultDeliveryType}" will be used instead.`;const DEPRECATED_PLUGIN_WARNING=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}${pluginName} plugin is deprecated. Please exclude it from the load API options.`;const generateMisconfiguredPluginsWarning=(context,configurationStatus,missingPlugins,shouldAddMissingPlugins)=>{const isSinglePlugin=missingPlugins.length===1;const pluginsString=isSinglePlugin?` '${missingPlugins[0]}' plugin was`:` ['${missingPlugins.join("', '")}'] plugins were`;const baseWarning=`${context}${LOG_CONTEXT_SEPARATOR}${configurationStatus}, but${pluginsString} not configured to load.`;if(shouldAddMissingPlugins){return `${baseWarning} So, ${isSinglePlugin?'the plugin':'those plugins'} will be loaded automatically.`;}return `${baseWarning} Ignore if this was intentional. Otherwise, consider adding ${isSinglePlugin?'it':'them'} to the 'plugins' load API option.`;};const INVALID_POLYFILL_URL_WARNING=(context,customPolyfillUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided polyfill URL "${customPolyfillUrl}" is invalid. The default polyfill URL will be used instead.`;const PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`;const UNKNOWN_PLUGINS_WARNING=(context,unknownPlugins)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring unknown plugins: ${unknownPlugins.join(', ')}.`;const CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR=(context,destinationId)=>`${context}${LOG_CONTEXT_SEPARATOR}Cannot add custom integration for destination ID "${destinationId}" after the SDK is loaded.`;
|
624
626
|
|
625
627
|
const DEFAULT_INTEGRATIONS_CONFIG={All:true};
|
626
628
|
|
@@ -637,9 +639,9 @@ const CDN_INT_DIR='js-integrations';const CDN_PLUGINS_DIR='plugins';const URL_PA
|
|
637
639
|
|
638
640
|
const BUILD_TYPE='modern';const SDK_CDN_BASE_URL='https://cdn.rudderlabs.com';const CDN_ARCH_VERSION_DIR='v3';const DEFAULT_INTEGRATION_SDKS_URL=`${SDK_CDN_BASE_URL}/${CDN_ARCH_VERSION_DIR}/${BUILD_TYPE}/${CDN_INT_DIR}`;const DEFAULT_PLUGINS_URL=`${SDK_CDN_BASE_URL}/${CDN_ARCH_VERSION_DIR}/${BUILD_TYPE}/${CDN_PLUGINS_DIR}`;const DEFAULT_CONFIG_BE_URL='https://api.rudderstack.com';
|
639
641
|
|
640
|
-
const DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';const DEFAULT_DATA_PLANE_EVENTS_TRANSPORT='xhr';const ConsentManagersToPluginNameMap={iubenda:'IubendaConsentManager',oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};const StorageEncryptionVersionsToPluginNameMap={[DEFAULT_STORAGE_ENCRYPTION_VERSION]:'StorageEncryption',legacy:'StorageEncryptionLegacy'};const DataPlaneEventsTransportToPluginNameMap={[DEFAULT_DATA_PLANE_EVENTS_TRANSPORT]:'XhrQueue',beacon:'BeaconQueue'};const DEFAULT_DATA_SERVICE_ENDPOINT='rsaRequest';const METRICS_SERVICE_ENDPOINT='rsaMetrics';
|
642
|
+
const DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';const DEFAULT_DATA_PLANE_EVENTS_TRANSPORT='xhr';const ConsentManagersToPluginNameMap={iubenda:'IubendaConsentManager',oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};const StorageEncryptionVersionsToPluginNameMap={[DEFAULT_STORAGE_ENCRYPTION_VERSION]:'StorageEncryption',legacy:'StorageEncryptionLegacy'};const DataPlaneEventsTransportToPluginNameMap={[DEFAULT_DATA_PLANE_EVENTS_TRANSPORT]:'XhrQueue',beacon:'BeaconQueue'};const DEFAULT_DATA_SERVICE_ENDPOINT='rsaRequest';const METRICS_SERVICE_ENDPOINT='rsaMetrics';const CUSTOM_DEVICE_MODE_DESTINATION_DISPLAY_NAME='Custom Device Mode';
|
641
643
|
|
642
|
-
const 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:
|
644
|
+
const 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};const loadOptionsState=d$1(clone(defaultLoadOptions));
|
643
645
|
|
644
646
|
const DEFAULT_USER_SESSION_VALUES={userId:'',userTraits:{},anonymousId:'',groupId:'',groupTraits:{},initialReferrer:'',initialReferringDomain:'',sessionInfo:{},authToken:null};const SERVER_SIDE_COOKIES_DEBOUNCE_TIME=10;// milliseconds
|
645
647
|
|
@@ -651,7 +653,7 @@ const reportingState={isErrorReportingEnabled:d$1(false),isMetricsReportingEnabl
|
|
651
653
|
|
652
654
|
const sourceConfigState=d$1(undefined);
|
653
655
|
|
654
|
-
const 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)};
|
656
|
+
const 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)};
|
655
657
|
|
656
658
|
const 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)};
|
657
659
|
|
@@ -756,9 +758,9 @@ const METRICS_PAYLOAD_VERSION='1';
|
|
756
758
|
const SDK_FILE_NAME_PREFIXES=()=>['rsa'// Prefix for all the SDK scripts including plugins and module federated chunks
|
757
759
|
];const DEV_HOSTS=['www.test-host.com','localhost','127.0.0.1','[::1]'];// List of keys to exclude from the metadata
|
758
760
|
// Potential PII or sensitive data
|
759
|
-
const APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','anonymousId','config','
|
761
|
+
const APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','anonymousId','config','integration',// integration instance objects
|
760
762
|
'eventBuffer',// pre-load event buffer (may contain PII)
|
761
|
-
'traits','authToken'];const NOTIFIER_NAME='RudderStack JavaScript SDK';const SDK_GITHUB_URL='
|
763
|
+
'traits','authToken'];const NOTIFIER_NAME='RudderStack JavaScript SDK';const SDK_GITHUB_URL='git+https://github.com/rudderlabs/rudder-sdk-js.git';const SOURCE_NAME='js';const DEFAULT_ERROR_CATEGORY='sdk';
|
762
764
|
|
763
765
|
const detectAdBlockers=httpClient=>{state.capabilities.isAdBlockerDetectionInProgress.value=true;try{// Apparently, '?view=ad' is a query param that is blocked by majority of adblockers
|
764
766
|
// Use source config URL here as it is very unlikely to be blocked by adblockers
|
@@ -774,8 +776,9 @@ throw err;}};
|
|
774
776
|
|
775
777
|
const getErrInstance=(err,errorType)=>{switch(errorType){case ErrorType.UNHANDLEDEXCEPTION:{const{error}=err;return error||err;}case ErrorType.UNHANDLEDREJECTION:{return err.reason;}case ErrorType.HANDLEDEXCEPTION:default:return err;}};const createNewBreadcrumb=message=>({type:'manual',name:message,timestamp:new Date(),metaData:{}});/**
|
776
778
|
* A function to get the Bugsnag release stage for the current environment
|
777
|
-
* @
|
778
|
-
|
779
|
+
* @param getHostName Optional function to get the hostname (primarily for testing)
|
780
|
+
* @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)
|
781
|
+
*/const getReleaseStage=(getHostName=()=>window.location.hostname)=>{const host=getHostName();return !host||host&&DEV_HOSTS.includes(host)?'development':'beta';};const getAppStateForMetadata=state=>{const stateStr=stringifyWithoutCircular(state,false,APP_STATE_EXCLUDE_KEYS);return stateStr!==null?JSON.parse(stateStr):{};};const getURLWithoutQueryString=()=>{const url=globalThis.location.href.split('?');return url[0];};const getUserDetails=(source,session,lifecycle,autoTrack)=>({id:`${source.value?.id??lifecycle.writeKey.value}..${session.sessionInfo.value.id??'NA'}..${autoTrack.pageLifecycle.pageViewId.value??'NA'}`,name:source.value?.name??'NA'});const getDeviceDetails=(locale,userAgent)=>({locale:locale.value??'NA',userAgent:userAgent.value??'NA',time:new Date()});const getBugsnagErrorEvent=(exception,errorState,state,groupingHash)=>{const{context,lifecycle,session,source,reporting,autoTrack}=state;const{app,locale,userAgent,timezone,screen,library}=context;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,metaData:{app:{snippetVersion:library.value.snippetVersion},device:{...screen.value,timezone:timezone.value},// Add rest of the state groups as metadata
|
779
782
|
// so that they show up as separate tabs in the dashboard
|
780
783
|
...getAppStateForMetadata(state)},user:getUserDetails(source,session,lifecycle,autoTrack)}]};};/**
|
781
784
|
* A function to check if adblockers are active. The promise's resolve function
|
@@ -808,7 +811,7 @@ resolve(true);}}else {resolve(!ERROR_MESSAGES_TO_BE_FILTERED.some(e=>e.test(errM
|
|
808
811
|
* @returns
|
809
812
|
*/const isSDKError=exception=>{const errorOrigin=exception.stacktrace[0]?.file;if(!errorOrigin||typeof errorOrigin!=='string'){return false;}const srcFileName=errorOrigin.substring(errorOrigin.lastIndexOf('/')+1);const paths=errorOrigin.split('/');// extract the parent folder name from the error origin file path
|
810
813
|
// Ex: parentFolderName will be 'sample' for url: https://example.com/sample/file.min.js
|
811
|
-
const parentFolderName=paths[paths.length-2];return parentFolderName===CDN_INT_DIR||SDK_FILE_NAME_PREFIXES().some(prefix=>srcFileName.startsWith(prefix)&&srcFileName.endsWith('.js'));};const getErrorDeliveryPayload=(payload,state)=>{const data={version:METRICS_PAYLOAD_VERSION,message_id:generateUUID(),source:{name:SOURCE_NAME,sdk_version:state.context.app.value.version,write_key:state.lifecycle.writeKey.value,install_type:state.context.app.value.installType},errors:payload};return stringifyWithoutCircular(data);};/**
|
814
|
+
const parentFolderName=paths[paths.length-2];return parentFolderName===CDN_INT_DIR||SDK_FILE_NAME_PREFIXES().some(prefix=>srcFileName.startsWith(prefix)&&srcFileName.endsWith('.js'));};const getErrorDeliveryPayload=(payload,state,category)=>{const data={version:METRICS_PAYLOAD_VERSION,message_id:generateUUID(),source:{name:SOURCE_NAME,sdk_version:state.context.app.value.version,write_key:state.lifecycle.writeKey.value,install_type:state.context.app.value.installType,category:category??DEFAULT_ERROR_CATEGORY},errors:payload};return stringifyWithoutCircular(data);};/**
|
812
815
|
* A function to get the grouping hash value to be used for the error event.
|
813
816
|
* Grouping hash is suppressed for non-cdn installs.
|
814
817
|
* If the grouping hash is an error instance, the normalized error message is used as the grouping hash.
|
@@ -839,7 +842,8 @@ document.addEventListener('securitypolicyviolation',event=>{const blockedURL=isS
|
|
839
842
|
* @param errorInfo.customMessage - The custom message of the error
|
840
843
|
* @param errorInfo.errorType - The type of the error (handled or unhandled)
|
841
844
|
* @param errorInfo.groupingHash - The grouping hash of the error
|
842
|
-
|
845
|
+
* @param errorInfo.category - The category of the error (sdk or integrations)
|
846
|
+
*/async onError(errorInfo){try{const{error,context,customMessage,groupingHash,category}=errorInfo;const errorType=errorInfo.errorType??ErrorType.HANDLEDEXCEPTION;const errInstance=getErrInstance(error,errorType);const normalizedError=normalizeError(errInstance,this.logger);if(isUndefined(normalizedError)){return;}const customMsgVal=customMessage?`${customMessage} - `:'';const errorMsgPrefix=`${context}${LOG_CONTEXT_SEPARATOR}${customMsgVal}`;const bsException=createBugsnagException(normalizedError,errorMsgPrefix);const stacktrace=getStacktrace(normalizedError);const isSdkDispatched=stacktrace.includes(MANUAL_ERROR_IDENTIFIER);// Filter errors that are not originated in the SDK.
|
843
847
|
// In case of NPM installations, the unhandled errors from the SDK cannot be identified
|
844
848
|
// and will NOT be reported unless they occur in plugins or integrations.
|
845
849
|
if(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCEPTION){return;}if(state.reporting.isErrorReportingEnabled.value){const isAllowed=await checkIfAllowedToBeNotified(bsException,state,this.httpClient);if(isAllowed){const errorState={severity:'error',unhandled:errorType!==ErrorType.HANDLEDEXCEPTION,severityReason:{type:errorType}};// Set grouping hash only for CDN installations (as an experiment)
|
@@ -850,7 +854,7 @@ if(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCE
|
|
850
854
|
// https://docs.bugsnag.com/product/error-grouping/#user_defined
|
851
855
|
const normalizedGroupingHash=getErrorGroupingHash(groupingHash,bsException.message,state,this.logger);// Get the final payload to be sent to the metrics service
|
852
856
|
const bugsnagPayload=getBugsnagErrorEvent(bsException,errorState,state,normalizedGroupingHash);// send it to metrics service
|
853
|
-
this.httpClient.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true});}}// Log handled errors and errors dispatched by the SDK
|
857
|
+
this.httpClient.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state,category),sendRawData:true},isRawResponse:true});}}// Log handled errors and errors dispatched by the SDK
|
854
858
|
if(errorType===ErrorType.HANDLEDEXCEPTION||isSdkDispatched){this.logger.error(bsException.message);}}catch(err){// If an error occurs while handling an error, log it
|
855
859
|
this.logger.error(HANDLE_ERROR_FAILURE(ERROR_HANDLER),err);}}/**
|
856
860
|
* Add breadcrumbs to add insight of a user's journey before an error
|
@@ -872,6 +876,7 @@ if(throws){throw err;}else {this.logger.error(PLUGIN_INVOCATION_ERROR(PLUGIN_ENG
|
|
872
876
|
|
873
877
|
/**
|
874
878
|
* A function to filter and return non cloud mode destinations
|
879
|
+
* A destination is considered non cloud mode if it is not a cloud mode destination or if it is a hybrid mode destination
|
875
880
|
* @param destination
|
876
881
|
*
|
877
882
|
* @returns boolean
|
@@ -881,7 +886,14 @@ destination.config.useNativeSDK===true);const isHybridModeDestination=destinatio
|
|
881
886
|
* @param destinations
|
882
887
|
*
|
883
888
|
* @returns destinations
|
884
|
-
*/const getNonCloudDestinations=destinations=>destinations.filter(isNonCloudDestination)
|
889
|
+
*/const getNonCloudDestinations=destinations=>destinations.filter(isNonCloudDestination);/**
|
890
|
+
* A function to get the user friendly id for a destination
|
891
|
+
* Replaces all spaces with hyphens and appends the id to the display name
|
892
|
+
* @param displayName The display name of the destination
|
893
|
+
* @param id The id of the destination
|
894
|
+
*
|
895
|
+
* @returns the user friendly id
|
896
|
+
*/const getDestinationUserFriendlyId=(displayName,id)=>`${displayName.replaceAll(' ','-')}___${id}`;
|
885
897
|
|
886
898
|
/**
|
887
899
|
* List of plugin names that are loaded as dynamic imports in modern builds
|
@@ -928,7 +940,7 @@ const userIdKey='rl_user_id';const userTraitsKey='rl_trait';const anonymousUserI
|
|
928
940
|
const encryptBrowser=value=>`${ENCRYPTION_PREFIX_V3}${toBase64(value)}`;const decryptBrowser=value=>{if(value?.startsWith(ENCRYPTION_PREFIX_V3)){return fromBase64(value.substring(ENCRYPTION_PREFIX_V3.length));}return value;};
|
929
941
|
|
930
942
|
const EVENT_PAYLOAD_SIZE_BYTES_LIMIT=32*1024;// 32 KB
|
931
|
-
const RETRY_REASON_CLIENT_NETWORK='client-network';const RETRY_REASON_CLIENT_TIMEOUT='client-timeout';const DEFAULT_RETRY_REASON=RETRY_REASON_CLIENT_NETWORK;
|
943
|
+
const RETRY_REASON_CLIENT_NETWORK='client-network';const RETRY_REASON_CLIENT_TIMEOUT='client-timeout';const DEFAULT_RETRY_REASON=RETRY_REASON_CLIENT_NETWORK;const INTEGRATIONS_ERROR_CATEGORY='integrations';
|
932
944
|
|
933
945
|
const EVENT_PAYLOAD_SIZE_CHECK_FAIL_WARNING=(context,payloadSize,sizeLimit)=>`${context}${LOG_CONTEXT_SEPARATOR}The size of the event payload (${payloadSize} bytes) exceeds the maximum limit of ${sizeLimit} bytes. Events with large payloads may be dropped in the future. Please review your instrumentation to ensure that event payloads are within the size limit.`;const EVENT_PAYLOAD_SIZE_VALIDATION_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to validate event payload size. Please make sure that the event payload is within the size limit and is a valid JSON object.`;const QUEUE_UTILITIES='QueueUtilities';/**
|
934
946
|
* Utility to get the stringified event payload
|
@@ -1114,7 +1126,7 @@ const SCRIPT_LOAD_TIMEOUT_MS=10*1000;// 10 seconds
|
|
1114
1126
|
const READY_CHECK_INTERVAL_MS=100;// 100 milliseconds
|
1115
1127
|
const DEVICE_MODE_DESTINATIONS_PLUGIN='DeviceModeDestinationsPlugin';
|
1116
1128
|
|
1117
|
-
const INTEGRATION_NOT_SUPPORTED_ERROR=destDisplayName=>`Integration for destination "${destDisplayName}" is not supported.`;const INTEGRATION_SDK_LOAD_ERROR=destDisplayName=>`Failed to load integration SDK for destination "${destDisplayName}"`;const INTEGRATION_INIT_ERROR=destUserFriendlyId=>`Failed to initialize integration for destination "${destUserFriendlyId}".`;const INTEGRATIONS_DATA_ERROR=destUserFriendlyId=>`Failed to get integrations data for destination "${destUserFriendlyId}".`;const INTEGRATION_READY_TIMEOUT_ERROR=timeout=>`A timeout of ${timeout} ms occurred`;const INTEGRATION_READY_CHECK_ERROR=id=>`Failed to get the ready status from integration for destination "${id}"`;
|
1129
|
+
const INTEGRATION_NOT_SUPPORTED_ERROR=destDisplayName=>`Integration for destination "${destDisplayName}" is not supported.`;const INTEGRATION_SDK_LOAD_ERROR=destDisplayName=>`Failed to load integration SDK for destination "${destDisplayName}"`;const INTEGRATION_INIT_ERROR=destUserFriendlyId=>`Failed to initialize integration for destination "${destUserFriendlyId}".`;const INTEGRATIONS_DATA_ERROR=destUserFriendlyId=>`Failed to get integrations data for destination "${destUserFriendlyId}".`;const INTEGRATION_READY_TIMEOUT_ERROR=timeout=>`A timeout of ${timeout} ms occurred`;const INTEGRATION_READY_CHECK_ERROR=id=>`Failed to get the ready status from integration for destination "${id}"`;const CUSTOM_INTEGRATION_INVALID_DESTINATION_ID_ERROR=(context,destinationId)=>`${context}${LOG_CONTEXT_SEPARATOR}The destination ID "${destinationId}" does not correspond to a custom device mode destination.`;const CUSTOM_INTEGRATION_ALREADY_EXISTS_ERROR=(context,destinationId)=>`${context}${LOG_CONTEXT_SEPARATOR}A custom integration with destination ID "${destinationId}" was already added.`;const INVALID_CUSTOM_INTEGRATION_ERROR=(context,destinationId)=>`${context}${LOG_CONTEXT_SEPARATOR}The custom integration added for destination ID "${destinationId}" does not match the expected implementation format.`;const INTEGRATION_NOT_ADDED_TO_CUSTOM_DESTINATION_WARNING=(context,destinationId)=>`${context}${LOG_CONTEXT_SEPARATOR}No valid custom integration was added for destination ID "${destinationId}". Ignoring it.`;
|
1118
1130
|
|
1119
1131
|
const isDestIntgConfigTruthy=destIntgConfig=>!isUndefined(destIntgConfig)&&Boolean(destIntgConfig)===true;const isDestIntgConfigFalsy=destIntgConfig=>!isUndefined(destIntgConfig)&&Boolean(destIntgConfig)===false;/**
|
1120
1132
|
* Filters the destinations that should not be loaded or forwarded events to based on the integration options (load or events API)
|
@@ -1123,172 +1135,175 @@ const isDestIntgConfigTruthy=destIntgConfig=>!isUndefined(destIntgConfig)&&Boole
|
|
1123
1135
|
* @returns Destinations array filtered based on the integration options
|
1124
1136
|
*/const filterDestinations=(intgOpts,destinations)=>{const allOptVal=intgOpts.All??true;return destinations.filter(dest=>{const destDisplayName=dest.displayName;let isDestEnabled;if(allOptVal){isDestEnabled=true;if(isDestIntgConfigFalsy(intgOpts[destDisplayName])){isDestEnabled=false;}}else {isDestEnabled=false;if(isDestIntgConfigTruthy(intgOpts[destDisplayName])){isDestEnabled=true;}}return isDestEnabled;});};
|
1125
1137
|
|
1126
|
-
const ACTIVE_CAMPAIGN_DISPLAY_NAME='ActiveCampaign';const ADOBE_ANALYTICS_DISPLAY_NAME='Adobe Analytics';const ADROLL_DISPLAY_NAME='Adroll';const AM_DISPLAY_NAME='Amplitude';const APPCUES_DISPLAY_NAME='Appcues';const AXEPTIO_DISPLAY_NAME='Axeptio';const BINGADS_DISPLAY_NAME='Bing Ads';const BRAZE_DISPLAY_NAME='Braze';const BUGSNAG_DISPLAY_NAME='Bugsnag';const CHARTBEAT_DISPLAY_NAME='Chartbeat';const CLEVERTAP_DISPLAY_NAME='CleverTap';const COMMANDBAR_DISPLAY_NAME='CommandBar';const CONVERTFLOW_DISPLAY_NAME='Convertflow';const CRITEO_DISPLAY_NAME='Criteo';const CUSTOMERIO_DISPLAY_NAME='Customer IO';const DCM_FLOODLIGHT_DISPLAY_NAME='DCM Floodlight';const DRIP_DISPLAY_NAME='Drip';const ENGAGE_DISPLAY_NAME='Engage';const FACEBOOK_PIXEL_DISPLAY_NAME='Facebook Pixel';const FULLSTORY_DISPLAY_NAME='Fullstory';const GA_DISPLAY_NAME='Google Analytics';const GA360_DISPLAY_NAME='Google Analytics 360';const GA4_DISPLAY_NAME='Google Analytics 4 (GA4)';const GA4_V2_DISPLAY_NAME='Google Analytics 4 (GA4) V2';const GAINSIGHT_PX_DISPLAY_NAME='Gainsight PX';const GOOGLE_OPTIMIZE_DISPLAY_NAME='Google Optimize';const GOOGLEADS_DISPLAY_NAME='Google Ads';const GTM_DISPLAY_NAME='Google Tag Manager';const HEAP_DISPLAY_NAME='Heap.io';const HOTJAR_DISPLAY_NAME='Hotjar';const HS_DISPLAY_NAME='HubSpot';const INTERCOM_DISPLAY_NAME='Intercom';const ITERABLE_DISPLAY_NAME='Iterable';const JUNE_DISPLAY_NAME='JUNE';const KEEN_DISPLAY_NAME='Keen';const KISSMETRICS_DISPLAY_NAME='Kiss Metrics';const KLAVIYO_DISPLAY_NAME='Klaviyo';const LAUNCHDARKLY_DISPLAY_NAME='LaunchDarkly';const LEMNISK_DISPLAY_NAME='Lemnisk Marketing Automation';const LINKEDIN_INSIGHT_TAG_DISPLAY_NAME='Linkedin Insight Tag';const LIVECHAT_DISPLAY_NAME='livechat';const LOTAME_DISPLAY_NAME='Lotame';const LYTICS_DISPLAY_NAME='Lytics';const MATOMO_DISPLAY_NAME='Matomo';const MICROSOFT_CLARITY_DISPLAY_NAME='Microsoft Clarity';const MOENGAGE_DISPLAY_NAME='MoEngage';const MOUSEFLOW_DISPLAY_NAME='Mouseflow';const MP_DISPLAY_NAME='Mixpanel';const NINETAILED_DISPLAY_NAME='Ninetailed';const OLARK_DISPLAY_NAME='Olark';const OPTIMIZELY_DISPLAY_NAME='Optimizely Web';const PENDO_DISPLAY_NAME='Pendo';const PINTEREST_TAG_DISPLAY_NAME='Pinterest Tag';const PODSIGHTS_DISPLAY_NAME='Podsights';const POST_AFFILIATE_PRO_DISPLAY_NAME='Post Affiliate Pro';const POSTHOG_DISPLAY_NAME='PostHog';const PROFITWELL_DISPLAY_NAME='ProfitWell';const QUALAROO_DISPLAY_NAME='Qualaroo';const QUALTRICS_DISPLAY_NAME='Qualtrics';const QUANTUMMETRIC_DISPLAY_NAME='Quantum Metric';const QUORA_PIXEL_DISPLAY_NAME='Quora Pixel';const REDDIT_PIXEL_DISPLAY_NAME='Reddit Pixel';const REFINER_DISPLAY_NAME='Refiner';const ROCKERBOX_DISPLAY_NAME='Rockerbox';const ROLLBAR_DISPLAY_NAME='rollbar';const SATISMETER_DISPLAY_NAME='SatisMeter';const SENDINBLUE_DISPLAY_NAME='Sendinblue';const SENTRY_DISPLAY_NAME='Sentry';const SHYNET_DISPLAY_NAME='Shynet';const SNAP_PIXEL_DISPLAY_NAME='Snap Pixel';const SNAPENGAGE_DISPLAY_NAME='SnapEngage';const SPOTIFYPIXEL_DISPLAY_NAME='Spotify Pixel';const SPRIG_DISPLAY_NAME='Sprig';const TIKTOK_ADS_DISPLAY_NAME='TikTok Ads';const TVSQUARED_DISPLAY_NAME='TVSquared';const VERO_DISPLAY_NAME='Vero';const VWO_DISPLAY_NAME='VWO';const WOOPRA_DISPLAY_NAME='WOOPRA';const XPIXEL_DISPLAY_NAME='XPixel';const YANDEX_METRICA_DISPLAY_NAME='Yandex.Metrica';const USERPILOT_DISPLAY_NAME='Userpilot';
|
1138
|
+
const ACTIVE_CAMPAIGN_DISPLAY_NAME='ActiveCampaign';const ADOBE_ANALYTICS_DISPLAY_NAME='Adobe Analytics';const ADROLL_DISPLAY_NAME='Adroll';const AM_DISPLAY_NAME='Amplitude';const APPCUES_DISPLAY_NAME='Appcues';const AXEPTIO_DISPLAY_NAME='Axeptio';const BINGADS_DISPLAY_NAME='Bing Ads';const BRAZE_DISPLAY_NAME='Braze';const BUGSNAG_DISPLAY_NAME='Bugsnag';const CHARTBEAT_DISPLAY_NAME='Chartbeat';const CLEVERTAP_DISPLAY_NAME='CleverTap';const COMMANDBAR_DISPLAY_NAME='CommandBar';const CONVERTFLOW_DISPLAY_NAME='Convertflow';const CRITEO_DISPLAY_NAME='Criteo';const CUSTOMERIO_DISPLAY_NAME='Customer IO';const DCM_FLOODLIGHT_DISPLAY_NAME='DCM Floodlight';const DRIP_DISPLAY_NAME='Drip';const ENGAGE_DISPLAY_NAME='Engage';const FACEBOOK_PIXEL_DISPLAY_NAME='Facebook Pixel';const FULLSTORY_DISPLAY_NAME='Fullstory';const GA_DISPLAY_NAME='Google Analytics';const GA360_DISPLAY_NAME='Google Analytics 360';const GA4_DISPLAY_NAME='Google Analytics 4 (GA4)';const GA4_V2_DISPLAY_NAME='Google Analytics 4 (GA4) V2';const GAINSIGHT_PX_DISPLAY_NAME='Gainsight PX';const GOOGLE_OPTIMIZE_DISPLAY_NAME='Google Optimize';const GOOGLEADS_DISPLAY_NAME='Google Ads';const GTM_DISPLAY_NAME='Google Tag Manager';const HEAP_DISPLAY_NAME='Heap.io';const HOTJAR_DISPLAY_NAME='Hotjar';const HS_DISPLAY_NAME='HubSpot';const INTERCOM_DISPLAY_NAME='Intercom';const ITERABLE_DISPLAY_NAME='Iterable';const JUNE_DISPLAY_NAME='JUNE';const KEEN_DISPLAY_NAME='Keen';const KISSMETRICS_DISPLAY_NAME='Kiss Metrics';const KLAVIYO_DISPLAY_NAME='Klaviyo';const LAUNCHDARKLY_DISPLAY_NAME='LaunchDarkly';const LEMNISK_DISPLAY_NAME='Lemnisk Marketing Automation';const LINKEDIN_INSIGHT_TAG_DISPLAY_NAME='Linkedin Insight Tag';const LIVECHAT_DISPLAY_NAME='livechat';const LOTAME_DISPLAY_NAME='Lotame';const LYTICS_DISPLAY_NAME='Lytics';const MATOMO_DISPLAY_NAME='Matomo';const MICROSOFT_CLARITY_DISPLAY_NAME='Microsoft Clarity';const MOENGAGE_DISPLAY_NAME='MoEngage';const MOUSEFLOW_DISPLAY_NAME='Mouseflow';const MP_DISPLAY_NAME='Mixpanel';const NINETAILED_DISPLAY_NAME='Ninetailed';const OLARK_DISPLAY_NAME='Olark';const OPTIMIZELY_DISPLAY_NAME='Optimizely Web';const PENDO_DISPLAY_NAME='Pendo';const PINTEREST_TAG_DISPLAY_NAME='Pinterest Tag';const PODSIGHTS_DISPLAY_NAME='Podsights';const POST_AFFILIATE_PRO_DISPLAY_NAME='Post Affiliate Pro';const POSTHOG_DISPLAY_NAME='PostHog';const PROFITWELL_DISPLAY_NAME='ProfitWell';const QUALAROO_DISPLAY_NAME='Qualaroo';const QUALTRICS_DISPLAY_NAME='Qualtrics';const QUANTUMMETRIC_DISPLAY_NAME='Quantum Metric';const QUORA_PIXEL_DISPLAY_NAME='Quora Pixel';const REDDIT_PIXEL_DISPLAY_NAME='Reddit Pixel';const REFINER_DISPLAY_NAME='Refiner';const ROCKERBOX_DISPLAY_NAME='Rockerbox';const ROLLBAR_DISPLAY_NAME='rollbar';const SATISMETER_DISPLAY_NAME='SatisMeter';const SENDINBLUE_DISPLAY_NAME='Sendinblue';const SENTRY_DISPLAY_NAME='Sentry';const SHYNET_DISPLAY_NAME='Shynet';const SNAP_PIXEL_DISPLAY_NAME='Snap Pixel';const SNAPENGAGE_DISPLAY_NAME='SnapEngage';const SPOTIFYPIXEL_DISPLAY_NAME='Spotify Pixel';const SPRIG_DISPLAY_NAME='Sprig';const TIKTOK_ADS_DISPLAY_NAME='TikTok Ads';const TVSQUARED_DISPLAY_NAME='TVSquared';const VERO_DISPLAY_NAME='Vero';const VWO_DISPLAY_NAME='VWO';const WOOPRA_DISPLAY_NAME='WOOPRA';const XPIXEL_DISPLAY_NAME='XPixel';const YANDEX_METRICA_DISPLAY_NAME='Yandex.Metrica';const USERPILOT_DISPLAY_NAME='Userpilot';const COMSCORE_DISPLAY_NAME='Comscore';
|
1139
|
+
|
1140
|
+
const DIR_NAME$1h='HubSpot';
|
1127
1141
|
|
1128
|
-
const DIR_NAME$1g='
|
1142
|
+
const DIR_NAME$1g='GA';
|
1129
1143
|
|
1130
|
-
const DIR_NAME$1f='
|
1144
|
+
const DIR_NAME$1f='Hotjar';
|
1131
1145
|
|
1132
|
-
const DIR_NAME$1e='
|
1146
|
+
const DIR_NAME$1e='GoogleAds';
|
1133
1147
|
|
1134
|
-
const DIR_NAME$1d='
|
1148
|
+
const DIR_NAME$1d='VWO';
|
1135
1149
|
|
1136
|
-
const DIR_NAME$1c='
|
1150
|
+
const DIR_NAME$1c='GoogleTagManager';
|
1137
1151
|
|
1138
|
-
const DIR_NAME$1b='
|
1152
|
+
const DIR_NAME$1b='Braze';
|
1139
1153
|
|
1140
|
-
const DIR_NAME$1a='
|
1154
|
+
const DIR_NAME$1a='INTERCOM';
|
1141
1155
|
|
1142
|
-
const DIR_NAME$19='
|
1156
|
+
const DIR_NAME$19='Keen';
|
1143
1157
|
|
1144
|
-
const DIR_NAME$18='
|
1158
|
+
const DIR_NAME$18='Kissmetrics';
|
1145
1159
|
|
1146
1160
|
const DIR_NAME$17='CustomerIO';
|
1147
1161
|
|
1148
|
-
const DIR_NAME$16='
|
1162
|
+
const DIR_NAME$16='Chartbeat';
|
1149
1163
|
|
1150
1164
|
const DIR_NAME$15='FacebookPixel';
|
1151
1165
|
|
1152
|
-
const DIR_NAME$14='
|
1166
|
+
const DIR_NAME$14='Lotame';
|
1153
1167
|
|
1154
|
-
const DIR_NAME$13='
|
1168
|
+
const DIR_NAME$13='Optimizely';
|
1155
1169
|
|
1156
|
-
const DIR_NAME$12='
|
1170
|
+
const DIR_NAME$12='Bugsnag';
|
1157
1171
|
|
1158
|
-
const DIR_NAME$11='
|
1172
|
+
const DIR_NAME$11='Fullstory';
|
1159
1173
|
|
1160
|
-
const DIR_NAME$10='
|
1174
|
+
const DIR_NAME$10='TVSquared';
|
1161
1175
|
|
1162
|
-
const DIR_NAME$$='
|
1176
|
+
const DIR_NAME$$='GA4';
|
1163
1177
|
|
1164
|
-
const DIR_NAME$_='
|
1178
|
+
const DIR_NAME$_='GA4_V2';
|
1165
1179
|
|
1166
|
-
const DIR_NAME$Z='
|
1180
|
+
const DIR_NAME$Z='MoEngage';
|
1167
1181
|
|
1168
|
-
const DIR_NAME$Y='
|
1182
|
+
const DIR_NAME$Y='Amplitude';
|
1169
1183
|
|
1170
|
-
const DIR_NAME$X='
|
1184
|
+
const DIR_NAME$X='Pendo';
|
1171
1185
|
|
1172
|
-
const DIR_NAME$W='
|
1186
|
+
const DIR_NAME$W='Lytics';
|
1173
1187
|
|
1174
|
-
const DIR_NAME$V='
|
1188
|
+
const DIR_NAME$V='Appcues';
|
1175
1189
|
|
1176
|
-
const DIR_NAME$U='
|
1190
|
+
const DIR_NAME$U='Posthog';
|
1177
1191
|
|
1178
1192
|
const DIR_NAME$T='Klaviyo';
|
1179
1193
|
|
1180
|
-
const DIR_NAME$S='
|
1194
|
+
const DIR_NAME$S='Clevertap';
|
1181
1195
|
|
1182
|
-
const DIR_NAME$R='
|
1196
|
+
const DIR_NAME$R='BingAds';
|
1183
1197
|
|
1184
|
-
const DIR_NAME$Q='
|
1198
|
+
const DIR_NAME$Q='PinterestTag';
|
1185
1199
|
|
1186
|
-
const DIR_NAME$P='
|
1200
|
+
const DIR_NAME$P='AdobeAnalytics';
|
1187
1201
|
|
1188
|
-
const DIR_NAME$O='
|
1202
|
+
const DIR_NAME$O='LinkedInInsightTag';
|
1189
1203
|
|
1190
|
-
const DIR_NAME$N='
|
1204
|
+
const DIR_NAME$N='RedditPixel';
|
1191
1205
|
|
1192
|
-
const DIR_NAME$M='
|
1206
|
+
const DIR_NAME$M='Drip';
|
1193
1207
|
|
1194
|
-
const DIR_NAME$L='
|
1208
|
+
const DIR_NAME$L='Heap';
|
1195
1209
|
|
1196
|
-
const DIR_NAME$K='
|
1210
|
+
const DIR_NAME$K='Criteo';
|
1197
1211
|
|
1198
|
-
const DIR_NAME$J='
|
1212
|
+
const DIR_NAME$J='Mixpanel';
|
1199
1213
|
|
1200
|
-
const DIR_NAME$I='
|
1214
|
+
const DIR_NAME$I='Qualtrics';
|
1201
1215
|
|
1202
1216
|
const DIR_NAME$H='ProfitWell';
|
1203
1217
|
|
1204
|
-
const DIR_NAME$G='
|
1218
|
+
const DIR_NAME$G='Sentry';
|
1205
1219
|
|
1206
1220
|
const DIR_NAME$F='QuantumMetric';
|
1207
1221
|
|
1208
|
-
const DIR_NAME$E='
|
1222
|
+
const DIR_NAME$E='SnapPixel';
|
1209
1223
|
|
1210
|
-
const DIR_NAME$D='
|
1224
|
+
const DIR_NAME$D='PostAffiliatePro';
|
1211
1225
|
|
1212
|
-
const DIR_NAME$C='
|
1226
|
+
const DIR_NAME$C='GoogleOptimize';
|
1213
1227
|
|
1214
|
-
const DIR_NAME$B='
|
1228
|
+
const DIR_NAME$B='LaunchDarkly';
|
1215
1229
|
|
1216
|
-
const DIR_NAME$A='
|
1230
|
+
const DIR_NAME$A='GA360';
|
1217
1231
|
|
1218
|
-
const DIR_NAME$z='
|
1232
|
+
const DIR_NAME$z='Adroll';
|
1219
1233
|
|
1220
|
-
const DIR_NAME$y='
|
1234
|
+
const DIR_NAME$y='DCMFloodlight';
|
1221
1235
|
|
1222
|
-
const DIR_NAME$x='
|
1236
|
+
const DIR_NAME$x='Matomo';
|
1223
1237
|
|
1224
|
-
const DIR_NAME$w='
|
1238
|
+
const DIR_NAME$w='Vero';
|
1225
1239
|
|
1226
|
-
const DIR_NAME$v='
|
1240
|
+
const DIR_NAME$v='Mouseflow';
|
1227
1241
|
|
1228
|
-
const DIR_NAME$u='
|
1242
|
+
const DIR_NAME$u='Rockerbox';
|
1229
1243
|
|
1230
|
-
const DIR_NAME$t='
|
1244
|
+
const DIR_NAME$t='ConvertFlow';
|
1231
1245
|
|
1232
|
-
const DIR_NAME$s='
|
1246
|
+
const DIR_NAME$s='SnapEngage';
|
1233
1247
|
|
1234
|
-
const DIR_NAME$r='
|
1248
|
+
const DIR_NAME$r='LiveChat';
|
1235
1249
|
|
1236
|
-
const DIR_NAME$q='
|
1250
|
+
const DIR_NAME$q='Shynet';
|
1237
1251
|
|
1238
|
-
const DIR_NAME$p='
|
1252
|
+
const DIR_NAME$p='Woopra';
|
1239
1253
|
|
1240
|
-
const DIR_NAME$o='
|
1254
|
+
const DIR_NAME$o='RollBar';
|
1241
1255
|
|
1242
|
-
const DIR_NAME$n='
|
1256
|
+
const DIR_NAME$n='QuoraPixel';
|
1243
1257
|
|
1244
|
-
const DIR_NAME$m='
|
1258
|
+
const DIR_NAME$m='June';
|
1245
1259
|
|
1246
|
-
const DIR_NAME$l='
|
1260
|
+
const DIR_NAME$l='Engage';
|
1247
1261
|
|
1248
|
-
const DIR_NAME$k='
|
1262
|
+
const DIR_NAME$k='Iterable';
|
1249
1263
|
|
1250
|
-
const DIR_NAME$j='
|
1264
|
+
const DIR_NAME$j='YandexMetrica';
|
1251
1265
|
|
1252
|
-
const DIR_NAME$i='
|
1266
|
+
const DIR_NAME$i='Refiner';
|
1253
1267
|
|
1254
|
-
const DIR_NAME$h='
|
1268
|
+
const DIR_NAME$h='Qualaroo';
|
1255
1269
|
|
1256
|
-
const DIR_NAME$g='
|
1270
|
+
const DIR_NAME$g='Podsights';
|
1257
1271
|
|
1258
|
-
const DIR_NAME$f='
|
1272
|
+
const DIR_NAME$f='Axeptio';
|
1259
1273
|
|
1260
|
-
const DIR_NAME$e='
|
1274
|
+
const DIR_NAME$e='Satismeter';
|
1261
1275
|
|
1262
|
-
const DIR_NAME$d='
|
1276
|
+
const DIR_NAME$d='MicrosoftClarity';
|
1263
1277
|
|
1264
|
-
const DIR_NAME$c='
|
1278
|
+
const DIR_NAME$c='Sendinblue';
|
1265
1279
|
|
1266
|
-
const DIR_NAME$b='
|
1280
|
+
const DIR_NAME$b='Olark';
|
1267
1281
|
|
1268
|
-
const DIR_NAME$a='
|
1282
|
+
const DIR_NAME$a='Lemnisk';
|
1269
1283
|
|
1270
|
-
const DIR_NAME$9='
|
1284
|
+
const DIR_NAME$9='TiktokAds';
|
1271
1285
|
|
1272
|
-
const DIR_NAME$8='
|
1286
|
+
const DIR_NAME$8='ActiveCampaign';
|
1273
1287
|
|
1274
|
-
const DIR_NAME$7='
|
1288
|
+
const DIR_NAME$7='Sprig';
|
1275
1289
|
|
1276
|
-
const DIR_NAME$6='
|
1290
|
+
const DIR_NAME$6='SpotifyPixel';
|
1277
1291
|
|
1278
|
-
const DIR_NAME$5='
|
1292
|
+
const DIR_NAME$5='CommandBar';
|
1279
1293
|
|
1280
|
-
const DIR_NAME$4='
|
1294
|
+
const DIR_NAME$4='Ninetailed';
|
1281
1295
|
|
1282
|
-
const DIR_NAME$3='
|
1296
|
+
const DIR_NAME$3='Gainsight_PX';
|
1283
1297
|
|
1284
|
-
const DIR_NAME$2='
|
1298
|
+
const DIR_NAME$2='XPixel';
|
1285
1299
|
|
1286
|
-
const DIR_NAME$1='
|
1300
|
+
const DIR_NAME$1='Userpilot';
|
1287
1301
|
|
1288
|
-
const DIR_NAME='
|
1302
|
+
const DIR_NAME='Comscore';
|
1289
1303
|
|
1290
1304
|
// map of the destination display names to the destination directory names
|
1291
|
-
|
1305
|
+
// Import display names and directory names from analytics-js-integrations
|
1306
|
+
const destDisplayNamesToFileNamesMap={[HS_DISPLAY_NAME]:DIR_NAME$1h,[GA_DISPLAY_NAME]:DIR_NAME$1g,[HOTJAR_DISPLAY_NAME]:DIR_NAME$1f,[GOOGLEADS_DISPLAY_NAME]:DIR_NAME$1e,[VWO_DISPLAY_NAME]:DIR_NAME$1d,[GTM_DISPLAY_NAME]:DIR_NAME$1c,[BRAZE_DISPLAY_NAME]:DIR_NAME$1b,[INTERCOM_DISPLAY_NAME]:DIR_NAME$1a,[KEEN_DISPLAY_NAME]:DIR_NAME$19,[KISSMETRICS_DISPLAY_NAME]:DIR_NAME$18,[CUSTOMERIO_DISPLAY_NAME]:DIR_NAME$17,[CHARTBEAT_DISPLAY_NAME]:DIR_NAME$16,[FACEBOOK_PIXEL_DISPLAY_NAME]:DIR_NAME$15,[LOTAME_DISPLAY_NAME]:DIR_NAME$14,[OPTIMIZELY_DISPLAY_NAME]:DIR_NAME$13,[BUGSNAG_DISPLAY_NAME]:DIR_NAME$12,[FULLSTORY_DISPLAY_NAME]:DIR_NAME$11,[TVSQUARED_DISPLAY_NAME]:DIR_NAME$10,[GA4_DISPLAY_NAME]:DIR_NAME$$,[GA4_V2_DISPLAY_NAME]:DIR_NAME$_,[MOENGAGE_DISPLAY_NAME]:DIR_NAME$Z,[AM_DISPLAY_NAME]:DIR_NAME$Y,[PENDO_DISPLAY_NAME]:DIR_NAME$X,[LYTICS_DISPLAY_NAME]:DIR_NAME$W,[APPCUES_DISPLAY_NAME]:DIR_NAME$V,[POSTHOG_DISPLAY_NAME]:DIR_NAME$U,[KLAVIYO_DISPLAY_NAME]:DIR_NAME$T,[CLEVERTAP_DISPLAY_NAME]:DIR_NAME$S,[BINGADS_DISPLAY_NAME]:DIR_NAME$R,[PINTEREST_TAG_DISPLAY_NAME]:DIR_NAME$Q,[ADOBE_ANALYTICS_DISPLAY_NAME]:DIR_NAME$P,[LINKEDIN_INSIGHT_TAG_DISPLAY_NAME]:DIR_NAME$O,[REDDIT_PIXEL_DISPLAY_NAME]:DIR_NAME$N,[DRIP_DISPLAY_NAME]:DIR_NAME$M,[HEAP_DISPLAY_NAME]:DIR_NAME$L,[CRITEO_DISPLAY_NAME]:DIR_NAME$K,[MP_DISPLAY_NAME]:DIR_NAME$J,[QUALTRICS_DISPLAY_NAME]:DIR_NAME$I,[PROFITWELL_DISPLAY_NAME]:DIR_NAME$H,[SENTRY_DISPLAY_NAME]:DIR_NAME$G,[QUANTUMMETRIC_DISPLAY_NAME]:DIR_NAME$F,[SNAP_PIXEL_DISPLAY_NAME]:DIR_NAME$E,[POST_AFFILIATE_PRO_DISPLAY_NAME]:DIR_NAME$D,[GOOGLE_OPTIMIZE_DISPLAY_NAME]:DIR_NAME$C,[LAUNCHDARKLY_DISPLAY_NAME]:DIR_NAME$B,[GA360_DISPLAY_NAME]:DIR_NAME$A,[ADROLL_DISPLAY_NAME]:DIR_NAME$z,[DCM_FLOODLIGHT_DISPLAY_NAME]:DIR_NAME$y,[MATOMO_DISPLAY_NAME]:DIR_NAME$x,[VERO_DISPLAY_NAME]:DIR_NAME$w,[MOUSEFLOW_DISPLAY_NAME]:DIR_NAME$v,[ROCKERBOX_DISPLAY_NAME]:DIR_NAME$u,[CONVERTFLOW_DISPLAY_NAME]:DIR_NAME$t,[SNAPENGAGE_DISPLAY_NAME]:DIR_NAME$s,[LIVECHAT_DISPLAY_NAME]:DIR_NAME$r,[SHYNET_DISPLAY_NAME]:DIR_NAME$q,[WOOPRA_DISPLAY_NAME]:DIR_NAME$p,[ROLLBAR_DISPLAY_NAME]:DIR_NAME$o,[QUORA_PIXEL_DISPLAY_NAME]:DIR_NAME$n,[JUNE_DISPLAY_NAME]:DIR_NAME$m,[ENGAGE_DISPLAY_NAME]:DIR_NAME$l,[ITERABLE_DISPLAY_NAME]:DIR_NAME$k,[YANDEX_METRICA_DISPLAY_NAME]:DIR_NAME$j,[REFINER_DISPLAY_NAME]:DIR_NAME$i,[QUALAROO_DISPLAY_NAME]:DIR_NAME$h,[PODSIGHTS_DISPLAY_NAME]:DIR_NAME$g,[AXEPTIO_DISPLAY_NAME]:DIR_NAME$f,[SATISMETER_DISPLAY_NAME]:DIR_NAME$e,[MICROSOFT_CLARITY_DISPLAY_NAME]:DIR_NAME$d,[SENDINBLUE_DISPLAY_NAME]:DIR_NAME$c,[OLARK_DISPLAY_NAME]:DIR_NAME$b,[LEMNISK_DISPLAY_NAME]:DIR_NAME$a,[TIKTOK_ADS_DISPLAY_NAME]:DIR_NAME$9,[ACTIVE_CAMPAIGN_DISPLAY_NAME]:DIR_NAME$8,[SPRIG_DISPLAY_NAME]:DIR_NAME$7,[SPOTIFYPIXEL_DISPLAY_NAME]:DIR_NAME$6,[COMMANDBAR_DISPLAY_NAME]:DIR_NAME$5,[NINETAILED_DISPLAY_NAME]:DIR_NAME$4,[GAINSIGHT_PX_DISPLAY_NAME]:DIR_NAME$3,[XPIXEL_DISPLAY_NAME]:DIR_NAME$2,[USERPILOT_DISPLAY_NAME]:DIR_NAME$1,[COMSCORE_DISPLAY_NAME]:DIR_NAME};
|
1292
1307
|
|
1293
1308
|
/**
|
1294
1309
|
* Determines if the destination SDK code is evaluated
|
@@ -1296,31 +1311,31 @@ const destDisplayNamesToFileNamesMap={[HS_DISPLAY_NAME]:DIR_NAME$X,[GA_DISPLAY_N
|
|
1296
1311
|
* @param sdkTypeName The name of the destination SDK type
|
1297
1312
|
* @param logger Logger instance
|
1298
1313
|
* @returns true if the destination SDK code is evaluated, false otherwise
|
1299
|
-
*/const isDestinationSDKMounted=(destSDKIdentifier,sdkTypeName,logger)=>Boolean(globalThis[destSDKIdentifier]?.[sdkTypeName]?.prototype&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');const wait=time=>new Promise(resolve=>{globalThis.setTimeout(resolve,time);});const
|
1314
|
+
*/const isDestinationSDKMounted=(destSDKIdentifier,sdkTypeName,logger)=>Boolean(globalThis[destSDKIdentifier]?.[sdkTypeName]?.prototype&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');const wait=time=>new Promise(resolve=>{globalThis.setTimeout(resolve,time);});const createIntegrationInstance=(destSDKIdentifier,sdkTypeName,dest,state)=>{const analyticsInstance={loadIntegration:state.nativeDestinations.loadIntegration.value,logLevel:state.lifecycle.logLevel.value,loadOnlyIntegrations:state.consents.postConsent.value?.integrations??state.nativeDestinations.loadOnlyIntegrations.value,...state.lifecycle.safeAnalyticsInstance.value};const integration=new globalThis[destSDKIdentifier][sdkTypeName](clone(dest.config),analyticsInstance,{shouldApplyDeviceModeTransformation:dest.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:dest.propagateEventsUntransformedOnError,destinationId:dest.id});return integration;};const isDestinationReady=(dest,time=0)=>new Promise((resolve,reject)=>{if(dest.integration?.isReady()){resolve(true);}else if(time>=READY_CHECK_TIMEOUT_MS){reject(new Error(INTEGRATION_READY_TIMEOUT_ERROR(READY_CHECK_TIMEOUT_MS)));}else {const curTime=Date.now();wait(READY_CHECK_INTERVAL_MS).then(()=>{const elapsedTime=Date.now()-curTime;isDestinationReady(dest,time+elapsedTime).then(resolve).catch(err=>reject(err));});}});/**
|
1300
1315
|
* Extracts the integration config, if any, from the given destination
|
1301
1316
|
* and merges it with the current integrations config
|
1302
1317
|
* @param dest Destination object
|
1303
1318
|
* @param curDestIntgConfig Current destinations integration config
|
1304
1319
|
* @param logger Logger object
|
1305
1320
|
* @returns Combined destinations integrations config
|
1306
|
-
*/const getCumulativeIntegrationsConfig=(dest,curDestIntgConfig,errorHandler)=>{let integrationsConfig=curDestIntgConfig;if(isFunction(dest.
|
1307
|
-
if(isHybridModeDestination(initializedDestination)){state.nativeDestinations.integrationsConfig.value=getCumulativeIntegrationsConfig(initializedDestination,state.nativeDestinations.integrationsConfig.value,errorHandler);}state.nativeDestinations.initializedDestinations.value=[...state.nativeDestinations.initializedDestinations.value,initializedDestination];}).catch(err=>{state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];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=[...state.nativeDestinations.failedDestinations.value,dest];errorHandler?.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATION_INIT_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_INIT_ERROR(dest.displayName)});}};/**
|
1321
|
+
*/const getCumulativeIntegrationsConfig=(dest,curDestIntgConfig,errorHandler)=>{let integrationsConfig=curDestIntgConfig;if(isFunction(dest.integration?.getDataForIntegrationsObject)){try{integrationsConfig={...curDestIntgConfig,...getSanitizedValue(dest.integration.getDataForIntegrationsObject())};}catch(err){errorHandler?.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATIONS_DATA_ERROR(dest.userFriendlyId),groupingHash:INTEGRATIONS_DATA_ERROR(dest.displayName),category:INTEGRATIONS_ERROR_CATEGORY});}}return integrationsConfig;};const initializeDestination=(dest,state,destSDKIdentifier,sdkTypeName,errorHandler,logger)=>{try{const initializedDestination=clone(dest);let integration=initializedDestination.integration;if(isUndefined(integration)){integration=createIntegrationInstance(destSDKIdentifier,sdkTypeName,dest,state);initializedDestination.integration=integration;}integration.init?.();isDestinationReady(initializedDestination).then(()=>{// Collect the integrations data for the hybrid mode destinations
|
1322
|
+
if(isHybridModeDestination(initializedDestination)){state.nativeDestinations.integrationsConfig.value=getCumulativeIntegrationsConfig(initializedDestination,state.nativeDestinations.integrationsConfig.value,errorHandler);}state.nativeDestinations.initializedDestinations.value=[...state.nativeDestinations.initializedDestinations.value,initializedDestination];}).catch(err=>{state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];errorHandler?.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATION_READY_CHECK_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_READY_CHECK_ERROR(dest.displayName),category:INTEGRATIONS_ERROR_CATEGORY});});}catch(err){state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];errorHandler?.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage:INTEGRATION_INIT_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_INIT_ERROR(dest.displayName),category:INTEGRATIONS_ERROR_CATEGORY});}};/**
|
1308
1323
|
* Applies source configuration overrides to destinations
|
1309
1324
|
* @param destinations Array of destinations to process
|
1310
1325
|
* @param sourceConfigOverride Source configuration override options
|
1311
1326
|
* @param logger Logger instance for warnings
|
1312
1327
|
* @returns Array of destinations with overrides applied
|
1313
|
-
*/const applySourceConfigurationOverrides=(destinations,sourceConfigOverride,logger)=>{if(!sourceConfigOverride?.destinations?.length){return
|
1328
|
+
*/const applySourceConfigurationOverrides=(destinations,sourceConfigOverride,logger)=>{if(!sourceConfigOverride?.destinations?.length){return filterDisabledDestinations(destinations);}const destIds=destinations.map(dest=>dest.id);// Group overrides by destination ID to support future cloning
|
1314
1329
|
// When cloning is implemented, multiple overrides with same ID will create multiple destination instances
|
1315
1330
|
const overridesByDestId={};sourceConfigOverride.destinations.forEach(override=>{const existing=overridesByDestId[override.id]||[];existing.push(override);overridesByDestId[override.id]=existing;});// Find unmatched destination IDs and log warning
|
1316
1331
|
const unmatchedIds=Object.keys(overridesByDestId).filter(id=>!destIds.includes(id));if(unmatchedIds.length>0){logger?.warn(`${DEVICE_MODE_DESTINATIONS_PLUGIN}:: Source configuration override - Unable to identify the destinations with the following IDs: "${unmatchedIds.join(', ')}"`);}// Process overrides and apply them to destinations
|
1317
1332
|
const processedDestinations=[];destinations.forEach(dest=>{const overrides=overridesByDestId[dest.id];if(!overrides||overrides.length===0){// No override for this destination, keep original
|
1318
1333
|
processedDestinations.push(dest);return;}if(overrides.length>1){// Multiple overrides for the same destination, create clones
|
1319
|
-
overrides.forEach((override,index)=>{const overriddenDestination=applyOverrideToDestination(dest,override,`${index+1}`);overriddenDestination.cloned=true;processedDestinations.push(overriddenDestination);});}else {const overriddenDestination=applyOverrideToDestination(dest,overrides[0]);processedDestinations.push(overriddenDestination);}});return
|
1334
|
+
overrides.forEach((override,index)=>{const overriddenDestination=applyOverrideToDestination(dest,override,`${index+1}`);overriddenDestination.cloned=true;processedDestinations.push(overriddenDestination);});}else {const overriddenDestination=applyOverrideToDestination(dest,overrides[0]);processedDestinations.push(overriddenDestination);}});return filterDisabledDestinations(processedDestinations);};/**
|
1320
1335
|
* This function filters out disabled destinations from the provided array.
|
1321
1336
|
* @param destinations Array of destinations to filter
|
1322
1337
|
* @returns Filtered destinations to only include enabled ones
|
1323
|
-
*/const
|
1338
|
+
*/const filterDisabledDestinations=destinations=>destinations.filter(dest=>dest.enabled);/**
|
1324
1339
|
* Applies a single override configuration to a destination
|
1325
1340
|
* @param destination Original destination
|
1326
1341
|
* @param override Override configuration
|
@@ -1337,14 +1352,44 @@ const clonedDest=clone(destination);if(cloneId){clonedDest.id=`${destination.id}
|
|
1337
1352
|
if(isEnabledStatusChanged){clonedDest.enabled=override.enabled;// Mark as overridden
|
1338
1353
|
clonedDest.overridden=true;}// Apply config overrides if provided for enabled destination
|
1339
1354
|
if(willApplyConfig){// Override the config with the new config and remove undefined and null values
|
1340
|
-
clonedDest.config=removeUndefinedAndNullValues({...clonedDest.config,...override.config});clonedDest.overridden=true;}return clonedDest;}
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
const
|
1355
|
+
clonedDest.config=removeUndefinedAndNullValues({...clonedDest.config,...override.config});clonedDest.overridden=true;}return clonedDest;};/**
|
1356
|
+
* Validates if the destination ID and custom integration are valid
|
1357
|
+
* @param destinationId - The destination ID to validate
|
1358
|
+
* @param integration - The custom integration instance
|
1359
|
+
* @param state - Application state
|
1360
|
+
* @param logger - Logger instance
|
1361
|
+
* @returns Destination object if the integration is valid, undefined otherwise
|
1362
|
+
*/const validateCustomIntegration=(destinationId,integration,state,logger)=>{const configuredDestinations=state.nativeDestinations.configuredDestinations.value;const destination=configuredDestinations.find(dest=>dest.id===destinationId&&dest.isCustomIntegration===true);if(!destination){logger.error(CUSTOM_INTEGRATION_INVALID_DESTINATION_ID_ERROR(DEVICE_MODE_DESTINATIONS_PLUGIN,destinationId));return;}// Check if a custom integration is already added for the destination ID
|
1363
|
+
if(isDefined(destination.integration)){logger.error(CUSTOM_INTEGRATION_ALREADY_EXISTS_ERROR(DEVICE_MODE_DESTINATIONS_PLUGIN,destinationId));return;}// Check if the integration is correctly implemented
|
1364
|
+
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,destinationId));return;}return destination;};/**
|
1365
|
+
* Updates destination object with the custom integration
|
1366
|
+
* @param destination - The destination object
|
1367
|
+
* @param integration - The custom integration instance
|
1368
|
+
* @param state - Application state
|
1369
|
+
* @param logger - Logger instance
|
1370
|
+
* @returns
|
1371
|
+
*/const addIntegrationToDestination=(destination,integration,state,logger)=>{const analyticsInstance=state.lifecycle.safeAnalyticsInstance.value;// Create a new logger object for the custom integration
|
1372
|
+
// to avoid conflicts with the main logger
|
1373
|
+
const integrationLogger=clone(logger);// Set the scope to the custom integration name
|
1374
|
+
// for easy identification in the logs
|
1375
|
+
integrationLogger.setScope(destination.displayName);// Bind only the necessary methods to the new logger object
|
1376
|
+
const 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 configuration object for the custom integration
|
1377
|
+
// to pass to the init method
|
1378
|
+
const customDestinationConfig=clone(destination.config);// Create a wrapper around the custom integration APIs
|
1379
|
+
// to make them consistent with the standard device mode integrations
|
1380
|
+
destination.integration={...(integration.init&&{init:()=>integration.init(customDestinationConfig,analyticsInstance,safeLogger)}),...(integration.track&&{track:event=>integration.track(analyticsInstance,safeLogger,event)}),...(integration.page&&{page:event=>integration.page(analyticsInstance,safeLogger,event)}),...(integration.identify&&{identify:event=>integration.identify(analyticsInstance,safeLogger,event)}),...(integration.group&&{group:event=>integration.group(analyticsInstance,safeLogger,event)}),...(integration.alias&&{alias:event=>integration.alias(analyticsInstance,safeLogger,event)}),isReady:()=>integration.isReady(analyticsInstance,safeLogger)};};
|
1381
|
+
|
1382
|
+
const pluginName$b='DeviceModeDestinations';const DeviceModeDestinations=()=>({name:pluginName$b,initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName$b];},nativeDestinations:{addCustomIntegration(destinationId,integration,state,logger){const destination=validateCustomIntegration(destinationId,integration,state,logger);if(!destination){return;}addIntegrationToDestination(destination,integration,state,logger);// Refresh the state value to trigger any effects that depend on it
|
1383
|
+
state.nativeDestinations.configuredDestinations.value=[...state.nativeDestinations.configuredDestinations.value];},setActiveDestinations(state,pluginsManager,errorHandler,logger){state.nativeDestinations.loadIntegration.value=state.loadOptions.value.loadIntegration;// Filter destination that doesn't have mapping config-->Integration names
|
1384
|
+
const configSupportedDestinations=state.nativeDestinations.configuredDestinations.value.filter(configDest=>{// Filter enabled or disabled custom destinations that don't have an integration added to them
|
1385
|
+
if(configDest.isCustomIntegration&&isUndefined(configDest.integration)){if(configDest.enabled){logger?.warn(INTEGRATION_NOT_ADDED_TO_CUSTOM_DESTINATION_WARNING(DEVICE_MODE_DESTINATIONS_PLUGIN,configDest.id));}return false;}// Ensure the destination is supported by the SDK
|
1386
|
+
// or it is a custom integration
|
1387
|
+
if(configDest.isCustomIntegration||destDisplayNamesToFileNamesMap[configDest.displayName]){return true;}const errMessage=INTEGRATION_NOT_SUPPORTED_ERROR(configDest.displayName);errorHandler?.onError({error:new Error(errMessage),context:DEVICE_MODE_DESTINATIONS_PLUGIN,category:INTEGRATIONS_ERROR_CATEGORY});return false;});// Apply source configuration overrides if provided
|
1388
|
+
const 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
|
1389
|
+
const destinationsToLoad=filterDestinations(state.consents.postConsent.value?.integrations??state.nativeDestinations.loadOnlyIntegrations.value,configuredDestinations);const consentedDestinations=destinationsToLoad.filter(dest=>// if consent manager is not configured, then default to load the destination
|
1390
|
+
pluginsManager.invokeSingle(`consentManager.isDestinationConsented`,state,dest.config,errorHandler,logger)??true);// Add the distilled destinations to the active destinations list
|
1391
|
+
state.nativeDestinations.activeDestinations.value=[...state.nativeDestinations.activeDestinations.value,...consentedDestinations];},load(state,externalSrcLoader,errorHandler,logger,externalScriptOnLoad){const integrationsCDNPath=state.lifecycle.integrationsCDNPath.value;const activeDestinations=state.nativeDestinations.activeDestinations.value;activeDestinations.forEach(dest=>{const sdkName=destDisplayNamesToFileNamesMap[dest.displayName];const destSDKIdentifier=`${sdkName}_RS`;// this is the name of the object loaded on the window
|
1392
|
+
const sdkTypeName=sdkName;if(sdkTypeName&&!isDestinationSDKMounted(destSDKIdentifier,sdkTypeName)){const destSdkURL=`${integrationsCDNPath}/${sdkName}.min.js`;externalSrcLoader.loadJSFile({url:destSdkURL,id:dest.userFriendlyId,callback:externalScriptOnLoad??((id,err)=>{if(err){const customMessage=INTEGRATION_SDK_LOAD_ERROR(dest.displayName);errorHandler?.onError({error:err,context:DEVICE_MODE_DESTINATIONS_PLUGIN,customMessage,groupingHash:customMessage,category:INTEGRATIONS_ERROR_CATEGORY});state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];}else {initializeDestination(dest,state,destSDKIdentifier,sdkTypeName,errorHandler);}}),timeout:SCRIPT_LOAD_TIMEOUT_MS});}else {initializeDestination(dest,state,destSDKIdentifier,sdkTypeName,errorHandler);}});}}});
|
1348
1393
|
|
1349
1394
|
const DEFAULT_TRANSFORMATION_QUEUE_OPTIONS={minRetryDelay:500,backoffFactor:2,maxAttempts:3};const REQUEST_TIMEOUT_MS$1=10*1000;// 10 seconds
|
1350
1395
|
const QUEUE_NAME$2='rudder';const DMT_PLUGIN='DeviceModeTransformationPlugin';
|
@@ -1537,13 +1582,12 @@ return true;}catch(err){errorHandler?.onError({error:err,context:KETCH_CONSENT_M
|
|
1537
1582
|
|
1538
1583
|
const DEFAULT_QUEUE_OPTIONS={maxItems:100};const QUEUE_NAME$1='rudder_destinations_events';const NATIVE_DESTINATION_QUEUE_PLUGIN='NativeDestinationQueuePlugin';
|
1539
1584
|
|
1540
|
-
const DESTINATION_EVENT_FILTERING_WARNING=(context,eventName,destUserFriendlyId)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${eventName}" track event has been filtered for the "${destUserFriendlyId}" destination.`;const INTEGRATION_EVENT_FORWARDING_ERROR=id=>`Failed to
|
1585
|
+
const DESTINATION_EVENT_FILTERING_WARNING=(context,eventName,destUserFriendlyId)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${eventName}" track event has been filtered for the "${destUserFriendlyId}" destination.`;const INTEGRATION_EVENT_FORWARDING_ERROR=(type,id,name)=>`Failed to send "${type}" event ${name?`"${name}" `:''}to integration for destination "${id}".`;
|
1541
1586
|
|
1542
1587
|
const getNormalizedQueueOptions$1=queueOpts=>mergeDeepRight(DEFAULT_QUEUE_OPTIONS,queueOpts);const isValidEventName=eventName=>eventName&&typeof eventName==='string';const isEventDenyListed=(eventType,eventName,dest)=>{if(eventType!=='track'){return false;}const{blacklistedEvents,whitelistedEvents,eventFilteringOption}=dest.config;switch(eventFilteringOption){// Blacklist is chosen for filtering events
|
1543
1588
|
case 'blacklistedEvents':{if(!isValidEventName(eventName)){return false;}const trimmedEventName=eventName.trim();if(Array.isArray(blacklistedEvents)){return blacklistedEvents.some(eventObj=>eventObj.eventName.trim()===trimmedEventName);}return false;}// Whitelist is chosen for filtering events
|
1544
1589
|
case 'whitelistedEvents':{if(!isValidEventName(eventName)){return true;}const trimmedEventName=eventName.trim();if(Array.isArray(whitelistedEvents)){return !whitelistedEvents.some(eventObj=>eventObj.eventName.trim()===trimmedEventName);}return true;}case 'disable':default:return false;}};const sendEventToDestination=(item,dest,errorHandler,logger)=>{const methodName=item.type.toString();try{// Destinations expect the event to be wrapped under the `message` key
|
1545
|
-
|
1546
|
-
dest.instance?.[methodName]?.({message:item});}catch(err){errorHandler?.onError({error:err,context:NATIVE_DESTINATION_QUEUE_PLUGIN,customMessage:INTEGRATION_EVENT_FORWARDING_ERROR(dest.userFriendlyId),groupingHash:INTEGRATION_EVENT_FORWARDING_ERROR(dest.displayName)});}};/**
|
1590
|
+
const integrationEvent={message:item};dest.integration[methodName]?.(integrationEvent);}catch(err){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),category:INTEGRATIONS_ERROR_CATEGORY});}};/**
|
1547
1591
|
* A function to check if device mode transformation should be applied for a destination.
|
1548
1592
|
* @param dest Destination object
|
1549
1593
|
* @returns Boolean indicating whether the transformation should be applied
|
@@ -1559,7 +1603,7 @@ const pluginName$5='NativeDestinationQueue';const NativeDestinationQueue=()=>({n
|
|
1559
1603
|
* @returns IQueue instance
|
1560
1604
|
*/init(state,pluginsManager,storeManager,dmtQueue,errorHandler,logger){const finalQOpts=getNormalizedQueueOptions$1(state.loadOptions.value.destinationsQueueOptions);const writeKey=state.lifecycle.writeKey.value;const eventsQueue=new RetryQueue(// adding write key to the queue name to avoid conflicts
|
1561
1605
|
`${QUEUE_NAME$1}_${writeKey}`,finalQOpts,(rudderEvent,done)=>{const destinationsToSend=filterDestinations(rudderEvent.integrations,state.nativeDestinations.initializedDestinations.value);// list of destinations which are enable for DMT
|
1562
|
-
const destWithTransformationEnabled=[];const clonedRudderEvent=clone(rudderEvent);destinationsToSend.forEach(dest=>{try{const sendEvent=!isEventDenyListed(clonedRudderEvent.type,clonedRudderEvent.event,dest);if(!sendEvent){logger?.warn(DESTINATION_EVENT_FILTERING_WARNING(NATIVE_DESTINATION_QUEUE_PLUGIN,clonedRudderEvent.event,dest.userFriendlyId));return;}if(shouldApplyTransformation(dest)){destWithTransformationEnabled.push(dest);}else {sendEventToDestination(clonedRudderEvent,dest,errorHandler,logger);}}catch(e){errorHandler?.onError({error:e,context:NATIVE_DESTINATION_QUEUE_PLUGIN});}});if(destWithTransformationEnabled.length>0){pluginsManager.invokeSingle('transformEvent.enqueue',state,dmtQueue,clonedRudderEvent,destWithTransformationEnabled,errorHandler,logger);}// Mark success always
|
1606
|
+
const destWithTransformationEnabled=[];const clonedRudderEvent=clone(rudderEvent);destinationsToSend.forEach(dest=>{try{const sendEvent=!isEventDenyListed(clonedRudderEvent.type,clonedRudderEvent.event,dest);if(!sendEvent){logger?.warn(DESTINATION_EVENT_FILTERING_WARNING(NATIVE_DESTINATION_QUEUE_PLUGIN,clonedRudderEvent.event,dest.userFriendlyId));return;}if(shouldApplyTransformation(dest)){destWithTransformationEnabled.push(dest);}else {sendEventToDestination(clonedRudderEvent,dest,errorHandler,logger);}}catch(e){errorHandler?.onError({error:e,context:NATIVE_DESTINATION_QUEUE_PLUGIN,category:INTEGRATIONS_ERROR_CATEGORY});}});if(destWithTransformationEnabled.length>0){pluginsManager.invokeSingle('transformEvent.enqueue',state,dmtQueue,clonedRudderEvent,destWithTransformationEnabled,errorHandler,logger);}// Mark success always
|
1563
1607
|
done(null);},storeManager,MEMORY_STORAGE);// TODO: This seems to not work as expected. Need to investigate
|
1564
1608
|
// effect(() => {
|
1565
1609
|
// if (state.nativeDestinations.clientDestinationsReady.value === true) {
|
@@ -1677,7 +1721,7 @@ this.words=words;this.sigBytes=sigBytes;}}/**
|
|
1677
1721
|
* @example
|
1678
1722
|
*
|
1679
1723
|
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
1680
|
-
*/static random=
|
1724
|
+
*/static random=randomWordArray;/**
|
1681
1725
|
* Converts this word array to a string.
|
1682
1726
|
*
|
1683
1727
|
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
@@ -2748,9 +2792,8 @@ ArrayBuffer:()=>!isFunction(globalThis.Uint8Array),Set:()=>!isFunction(globalThi
|
|
2748
2792
|
|
2749
2793
|
const getScreenDetails=()=>{let screenDetails={density:0,width:0,height:0,innerWidth:0,innerHeight:0};screenDetails={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight};return screenDetails;};
|
2750
2794
|
|
2751
|
-
const isStorageQuotaExceeded=e=>{const matchingNames=['QuotaExceededError','NS_ERROR_DOM_QUOTA_REACHED'];//
|
2752
|
-
const matchingCodes=[22,1014];//
|
2753
|
-
const isQuotaExceededError=matchingNames.includes(e.name)||matchingCodes.includes(e.code);return e instanceof DOMException&&isQuotaExceededError;};// TODO: also check for SecurityErrors
|
2795
|
+
const isStorageQuotaExceeded=e=>{const matchingNames=['QuotaExceededError','NS_ERROR_DOM_QUOTA_REACHED'];// Everything except Firefox, Firefox
|
2796
|
+
const matchingCodes=[22,1014];if(e instanceof DOMException){return matchingNames.includes(e.name)||matchingCodes.includes(e.code);}return false;};// TODO: also check for SecurityErrors
|
2754
2797
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage#exceptions
|
2755
2798
|
const isStorageAvailable=(type=LOCAL_STORAGE,storageInstance,logger)=>{let storage;let testData;const msgPrefix=STORAGE_UNAVAILABILITY_ERROR_PREFIX(CAPABILITIES_MANAGER,type);let reason='unavailable';let isAccessible=true;let errObj;try{switch(type){case MEMORY_STORAGE:return true;case COOKIE_STORAGE:storage=storageInstance;testData=STORAGE_TEST_COOKIE;break;case LOCAL_STORAGE:storage=storageInstance??globalThis.localStorage;testData=STORAGE_TEST_LOCAL_STORAGE;// was STORAGE_TEST_LOCAL_STORAGE in ours and generateUUID() in segment retry one
|
2756
2799
|
break;case SESSION_STORAGE:storage=storageInstance??globalThis.sessionStorage;testData=STORAGE_TEST_SESSION_STORAGE;break;default:return false;}if(storage){storage.setItem(testData,'true');if(storage.getItem(testData)){storage.removeItem(testData);return true;}}isAccessible=false;}catch(err){isAccessible=false;errObj=err;if(isStorageQuotaExceeded(err)){reason='full';}}if(!isAccessible){logger?.warn(`${msgPrefix}${reason}.`,errObj);}// if we've have reached here, it means the storage is not available
|
@@ -2954,7 +2997,7 @@ if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}r(()=
|
|
2954
2997
|
* Transforms destinations config from source config response to Destination format
|
2955
2998
|
* @param destinations Array of destination items from config response
|
2956
2999
|
* @returns Array of transformed Destination objects
|
2957
|
-
*/const getDestinationsFromConfig=destinations=>destinations.map(destination=>({id:destination.id,displayName:destination.destinationDefinition.displayName,enabled:destination.enabled,config:destination.config,shouldApplyDeviceModeTransformation:destination.shouldApplyDeviceModeTransformation??false,propagateEventsUntransformedOnError:destination.propagateEventsUntransformedOnError??false,userFriendlyId
|
3000
|
+
*/const getDestinationsFromConfig=destinations=>destinations.map(destination=>({id:destination.id,displayName:destination.destinationDefinition.displayName,enabled:destination.enabled,config:destination.config,shouldApplyDeviceModeTransformation:destination.shouldApplyDeviceModeTransformation??false,propagateEventsUntransformedOnError:destination.propagateEventsUntransformedOnError??false,userFriendlyId:getDestinationUserFriendlyId(destination.destinationDefinition.displayName,destination.id),isCustomIntegration:destination.destinationDefinition.displayName===CUSTOM_DEVICE_MODE_DESTINATION_DISPLAY_NAME}));
|
2958
3001
|
|
2959
3002
|
/**
|
2960
3003
|
* A function that determines the base URL for the integrations or plugins SDK
|
@@ -3020,24 +3063,22 @@ const timezone=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return timezone?.[1
|
|
3020
3063
|
/**
|
3021
3064
|
* Get the referrer URL
|
3022
3065
|
* @returns The referrer URL
|
3023
|
-
*/const getReferrer=()=>document?.referrer||'$direct';/**
|
3066
|
+
*/const getReferrer=(getDocument=()=>document)=>getDocument()?.referrer||'$direct';/**
|
3024
3067
|
* To get the canonical URL of the page
|
3025
3068
|
* @returns canonical URL
|
3026
|
-
*/const getCanonicalUrl=()=>{const tags=
|
3069
|
+
*/const getCanonicalUrl=(getDocument=()=>document)=>{const docInstance=getDocument();const tags=docInstance.getElementsByTagName('link');let canonicalUrl='';for(let i=0;tags[i];i+=1){const tag=tags[i];if(tag.getAttribute('rel')==='canonical'&&!canonicalUrl){canonicalUrl=tag.getAttribute('href')??'';break;}}return canonicalUrl;};const getUserAgent=(getNavigator=()=>globalThis.navigator)=>{const navigator=getNavigator();if(isUndefined(navigator)){return null;}let{userAgent}=navigator;const{brave}=navigator;// For supporting Brave browser detection,
|
3027
3070
|
// add "Brave/<version>" to the user agent with the version value from the Chrome component
|
3028
3071
|
if(brave&&Object.getPrototypeOf(brave).isBrave){// Example:
|
3029
3072
|
// 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
|
3030
|
-
const matchedArr=userAgent.match(/(chrome)\/([\w.]+)/i);if(matchedArr){userAgent=`${userAgent} Brave/${matchedArr[2]}`;}}return userAgent;};const getLanguage=()=>{if(isUndefined(
|
3073
|
+
const matchedArr=userAgent.match(/(chrome)\/([\w.]+)/i);if(matchedArr){userAgent=`${userAgent} Brave/${matchedArr[2]}`;}}return userAgent;};const getLanguage=(getNavigator=()=>globalThis.navigator)=>{const navigator=getNavigator();if(isUndefined(navigator)){return null;}return navigator.language??navigator.browserLanguage;};/**
|
3031
3074
|
* Default page properties
|
3032
3075
|
* @returns Default page properties
|
3033
|
-
*/const getDefaultPageProperties=()=>{const canonicalUrl=getCanonicalUrl();let path=
|
3076
|
+
*/const getDefaultPageProperties=(getLocation=()=>globalThis.location,getDocument=()=>document)=>{const location=getLocation();const canonicalUrl=getCanonicalUrl(getDocument);let path=location.pathname;const{href:tabUrl}=location;let pageUrl=tabUrl;const{search}=location;// If valid canonical URL is provided use this as page URL.
|
3034
3077
|
if(canonicalUrl){try{const urlObj=new URL(canonicalUrl);// If existing, query params of canonical URL will be used instead of the location.search ones
|
3035
3078
|
if(urlObj.search===''){pageUrl=canonicalUrl+search;}else {pageUrl=canonicalUrl;}path=urlObj.pathname;}catch(err){// Do nothing
|
3036
|
-
}}const url=getUrlWithoutHash(pageUrl);const{title}=
|
3079
|
+
}}const url=getUrlWithoutHash(pageUrl);const{title}=getDocument();const referrer=getReferrer(getDocument);return {path,referrer,referring_domain:getReferringDomain(referrer),search,title,url,tab_url:tabUrl};};
|
3037
3080
|
|
3038
|
-
|
3039
|
-
// eslint-disable-next-line no-constant-condition
|
3040
|
-
const POLYFILL_URL=`https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=${Object.keys(legacyJSEngineRequiredPolyfills).join('%2C')}`;const POLYFILL_LOAD_TIMEOUT=10*1000;// 10 seconds
|
3081
|
+
const polyfillIoSdkUrl='https://polyfill-fastly.io/v3/polyfill.min.js';const POLYFILL_URL=`${polyfillIoSdkUrl}?version=3.111.0&features=${Object.keys(legacyJSEngineRequiredPolyfills).join('%2C')}`;const POLYFILL_LOAD_TIMEOUT=10*1000;// 10 seconds
|
3041
3082
|
const POLYFILL_SCRIPT_ID='rudderstackPolyfill';
|
3042
3083
|
|
3043
3084
|
class CapabilitiesManager{constructor(httpClient,errorHandler,logger){this.httpClient=httpClient;this.errorHandler=errorHandler;this.logger=logger;this.externalSrcLoader=new ExternalSrcLoader(this.logger);this.onError=this.onError.bind(this);this.onReady=this.onReady.bind(this);}init(){this.prepareBrowserCapabilities();this.attachWindowListeners();}/**
|
@@ -3449,11 +3490,11 @@ state.lifecycle.status.value='initialized';}/**
|
|
3449
3490
|
}/**
|
3450
3491
|
* Trigger onLoaded callback if any is provided in config & emit initialised event
|
3451
3492
|
*/onInitialized(){// Process any preloaded events
|
3452
|
-
this.processDataInPreloadBuffer();//
|
3493
|
+
this.processDataInPreloadBuffer();// Set lifecycle state
|
3494
|
+
r(()=>{state.lifecycle.loaded.value=true;state.lifecycle.status.value='loaded';});this.initialized=true;// Execute onLoaded callback if provided in load options
|
3453
3495
|
const onLoadedCallbackFn=state.loadOptions.value.onLoaded;// TODO: we need to avoid passing the window object to the callback function
|
3454
3496
|
// as this will prevent us from supporting multiple SDK instances in the same page
|
3455
|
-
safelyInvokeCallback(onLoadedCallbackFn,[globalThis.rudderanalytics],LOAD_API,this.logger);//
|
3456
|
-
r(()=>{state.lifecycle.loaded.value=true;state.lifecycle.status.value='loaded';});this.initialized=true;// Emit an event to use as substitute to the onLoaded callback
|
3497
|
+
safelyInvokeCallback(onLoadedCallbackFn,[globalThis.rudderanalytics],LOAD_API,this.logger);// Emit an event to use as substitute to the onLoaded callback
|
3457
3498
|
dispatchSDKEvent('RSA_Initialised');}/**
|
3458
3499
|
* Emit ready event
|
3459
3500
|
*/// eslint-disable-next-line class-methods-use-this
|
@@ -3500,7 +3541,12 @@ this.storeManager?.initializeStorageState();// Re-init user session manager
|
|
3500
3541
|
this.userSessionManager?.syncStorageDataToState();// Resume event manager to process the events to destinations
|
3501
3542
|
this.eventManager?.resume();this.loadDestinations();this.sendTrackingEvents(isBufferedInvocation);}sendTrackingEvents(isBufferedInvocation){// If isBufferedInvocation is true, then the tracking events will be added to the end of the
|
3502
3543
|
// events buffer array so that any other preload events (mainly from query string API) will be processed first.
|
3503
|
-
if(state.consents.postConsent.value.trackConsent){const trackOptions=trackArgumentsToCallOptions(CONSENT_TRACK_EVENT_NAME);if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[...state.eventBuffer.toBeProcessedArray.value,['track',trackOptions]];}else {this.track(trackOptions);}}if(state.consents.postConsent.value.sendPageEvent){const pageOptions=pageArgumentsToCallOptions();if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[...state.eventBuffer.toBeProcessedArray.value,['page',pageOptions]];}else {this.page(pageOptions);}}}setAuthToken(token){this.userSessionManager?.setAuthToken(token);}
|
3544
|
+
if(state.consents.postConsent.value.trackConsent){const trackOptions=trackArgumentsToCallOptions(CONSENT_TRACK_EVENT_NAME);if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[...state.eventBuffer.toBeProcessedArray.value,['track',trackOptions]];}else {this.track(trackOptions);}}if(state.consents.postConsent.value.sendPageEvent){const pageOptions=pageArgumentsToCallOptions();if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[...state.eventBuffer.toBeProcessedArray.value,['page',pageOptions]];}else {this.page(pageOptions);}}}setAuthToken(token){this.userSessionManager?.setAuthToken(token);}/**
|
3545
|
+
* Add a custom integration for a custom destination.
|
3546
|
+
* @param destinationId - The ID of the custom destination from the RudderStack dashboard.
|
3547
|
+
* @param integration - The custom integration object.
|
3548
|
+
* @param isBufferedInvocation - Whether the invocation is buffered.
|
3549
|
+
*/addCustomIntegration(destinationId,integration,isBufferedInvocation=false){const type='addCustomIntegration';if(isBufferedInvocation){this.errorHandler.leaveBreadcrumb(`New ${type} invocation`);this.pluginsManager?.invokeSingle('nativeDestinations.addCustomIntegration',destinationId,integration,state,this.logger);}else {if(state.lifecycle.loaded.value){this.logger.error(CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR(ANALYTICS_CORE,destinationId));return;}state.eventBuffer.toBeProcessedArray.value=[...state.eventBuffer.toBeProcessedArray.value,[type,destinationId,integration]];}}// End consumer exposed methods
|
3504
3550
|
}
|
3505
3551
|
|
3506
3552
|
/*
|
@@ -3511,14 +3557,18 @@ if(state.consents.postConsent.value.trackConsent){const trackOptions=trackArgume
|
|
3511
3557
|
*/class RudderAnalytics{// START-NO-SONAR-SCAN
|
3512
3558
|
// eslint-disable-next-line sonarjs/public-static-readonly
|
3513
3559
|
static globalSingleton=null;// END-NO-SONAR-SCAN
|
3514
|
-
analyticsInstances={};defaultAnalyticsKey='';logger=
|
3560
|
+
analyticsInstances={};defaultAnalyticsKey='';logger=defaultLogger;// Singleton with constructor bind methods
|
3515
3561
|
constructor(){try{if(RudderAnalytics.globalSingleton){// START-NO-SONAR-SCAN
|
3516
3562
|
// eslint-disable-next-line no-constructor-return
|
3517
3563
|
return RudderAnalytics.globalSingleton;// END-NO-SONAR-SCAN
|
3518
|
-
}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
|
3564
|
+
}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
|
3519
3565
|
this.triggerBufferedLoadEvent();// Assign to global "rudderanalytics" object after processing the preload buffer (if any exists)
|
3520
3566
|
// for CDN bundling IIFE exports covers this but for npm ESM and CJS bundling has to be done explicitly
|
3521
|
-
globalThis.rudderanalytics=this;}catch(error){dispatchErrorEvent(error);}}
|
3567
|
+
globalThis.rudderanalytics=this;}catch(error){dispatchErrorEvent(error);}}/**
|
3568
|
+
* Create an instance of the current instance that can be used
|
3569
|
+
* to call a subset of methods of the current instance.
|
3570
|
+
* It is typically used to expose the analytics instance to the integrations (standard and custom)
|
3571
|
+
*/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)};}static initializeGlobalResources(){// We need to initialize the error handler first to catch any unhandled errors occurring in this module as well
|
3522
3572
|
defaultErrorHandler.init();// Initialize the storage engines with default options
|
3523
3573
|
defaultCookieStorage.configure();defaultLocalStorage.configure();defaultSessionStorage.configure();defaultInMemoryStorage.configure();}/**
|
3524
3574
|
* Set instance to use if no specific writeKey is provided in methods
|
@@ -3581,6 +3631,6 @@ identify(userId,traits,options,callback){try{this.getAnalyticsInstance()?.identi
|
|
3581
3631
|
alias(to,from,options,callback){try{this.getAnalyticsInstance()?.alias(aliasArgumentsToCallOptions(getSanitizedValue(to),getSanitizedValue(from),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}/**
|
3582
3632
|
* Process group arguments and forward to page call
|
3583
3633
|
*/// These overloads should be same as AnalyticsGroupMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics
|
3584
|
-
group(groupId,traits,options,callback){try{this.getAnalyticsInstance()?.group(groupArgumentsToCallOptions(getSanitizedValue(groupId),getSanitizedValue(traits),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}reset(resetAnonymousId){try{this.getAnalyticsInstance()?.reset(getSanitizedValue(resetAnonymousId));}catch(error){dispatchErrorEvent(error);}}getAnonymousId(options){try{return this.getAnalyticsInstance()?.getAnonymousId(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);return undefined;}}setAnonymousId(anonymousId,rudderAmpLinkerParam){try{this.getAnalyticsInstance()?.setAnonymousId(getSanitizedValue(anonymousId),getSanitizedValue(rudderAmpLinkerParam));}catch(error){dispatchErrorEvent(error);}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId();}catch(error){dispatchErrorEvent(error);return undefined;}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId();}catch(error){dispatchErrorEvent(error);return undefined;}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}startSession(sessionId){try{this.getAnalyticsInstance()?.startSession(getSanitizedValue(sessionId));}catch(error){dispatchErrorEvent(error);}}endSession(){try{this.getAnalyticsInstance()?.endSession();}catch(error){dispatchErrorEvent(error);}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId();}catch(error){dispatchErrorEvent(error);return undefined;}}setAuthToken(token){try{this.getAnalyticsInstance()?.setAuthToken(getSanitizedValue(token));}catch(error){dispatchErrorEvent(error);}}consent(options){try{this.getAnalyticsInstance()?.consent(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);}}}
|
3634
|
+
group(groupId,traits,options,callback){try{this.getAnalyticsInstance()?.group(groupArgumentsToCallOptions(getSanitizedValue(groupId),getSanitizedValue(traits),getSanitizedValue(options),getSanitizedValue(callback)));}catch(error){dispatchErrorEvent(error);}}reset(resetAnonymousId){try{this.getAnalyticsInstance()?.reset(getSanitizedValue(resetAnonymousId));}catch(error){dispatchErrorEvent(error);}}getAnonymousId(options){try{return this.getAnalyticsInstance()?.getAnonymousId(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);return undefined;}}setAnonymousId(anonymousId,rudderAmpLinkerParam){try{this.getAnalyticsInstance()?.setAnonymousId(getSanitizedValue(anonymousId),getSanitizedValue(rudderAmpLinkerParam));}catch(error){dispatchErrorEvent(error);}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId();}catch(error){dispatchErrorEvent(error);return undefined;}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId();}catch(error){dispatchErrorEvent(error);return undefined;}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits();}catch(error){dispatchErrorEvent(error);return undefined;}}startSession(sessionId){try{this.getAnalyticsInstance()?.startSession(getSanitizedValue(sessionId));}catch(error){dispatchErrorEvent(error);}}endSession(){try{this.getAnalyticsInstance()?.endSession();}catch(error){dispatchErrorEvent(error);}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId();}catch(error){dispatchErrorEvent(error);return undefined;}}setAuthToken(token){try{this.getAnalyticsInstance()?.setAuthToken(getSanitizedValue(token));}catch(error){dispatchErrorEvent(error);}}consent(options){try{this.getAnalyticsInstance()?.consent(getSanitizedValue(options));}catch(error){dispatchErrorEvent(error);}}addCustomIntegration(destinationId,integration){try{this.getAnalyticsInstance()?.addCustomIntegration(getSanitizedValue(destinationId),getSanitizedValue(integration));}catch(error){dispatchErrorEvent(error);}}}
|
3585
3635
|
|
3586
3636
|
exports.RudderAnalytics = RudderAnalytics;
|