@rudderstack/analytics-js 3.11.12 → 3.11.14
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 +17 -0
- package/dist/npm/index.d.cts +0 -5
- package/dist/npm/index.d.mts +0 -5
- package/dist/npm/legacy/bundled/cjs/index.cjs +44 -53
- package/dist/npm/legacy/bundled/esm/index.mjs +44 -53
- package/dist/npm/legacy/bundled/umd/index.js +44 -53
- package/dist/npm/legacy/cjs/index.cjs +44 -53
- package/dist/npm/legacy/content-script/cjs/index.cjs +44 -53
- package/dist/npm/legacy/content-script/esm/index.mjs +44 -53
- package/dist/npm/legacy/content-script/umd/index.js +44 -53
- package/dist/npm/legacy/esm/index.mjs +44 -53
- package/dist/npm/legacy/umd/index.js +44 -53
- package/dist/npm/modern/bundled/cjs/index.cjs +44 -53
- package/dist/npm/modern/bundled/esm/index.mjs +44 -53
- package/dist/npm/modern/bundled/umd/index.js +44 -53
- package/dist/npm/modern/cjs/index.cjs +44 -53
- package/dist/npm/modern/content-script/cjs/index.cjs +44 -53
- package/dist/npm/modern/content-script/esm/index.mjs +44 -53
- package/dist/npm/modern/content-script/umd/index.js +44 -53
- package/dist/npm/modern/esm/index.mjs +44 -53
- package/dist/npm/modern/umd/index.js +44 -53
- package/package.json +1 -1
@@ -905,54 +905,10 @@ var trim=function trim(value){return value.replace(/^\s+|\s+$/gm,'');};var remov
|
|
905
905
|
* @returns decoded string
|
906
906
|
*/var fromBase64=function fromBase64(value){return new TextDecoder().decode(base64ToBytes(value));};
|
907
907
|
|
908
|
-
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
909
|
-
|
910
|
-
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
911
|
-
// eslint-disable-next-line func-names
|
912
|
-
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
913
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
914
|
-
// @ts-ignore-next-line
|
915
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
916
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
917
|
-
*
|
918
|
-
* @param {*} value input
|
919
|
-
* @param {boolean} excludeNull if it should exclude nul or not
|
920
|
-
* @param {function} logger optional logger methods for warning
|
921
|
-
* @returns string
|
922
|
-
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};/**
|
923
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
924
|
-
*
|
925
|
-
* @param {*} value input value
|
926
|
-
* @param {boolean} excludeNull optional flag to exclude null values
|
927
|
-
* @param {string[]} excludeKeys optional array of keys to exclude
|
928
|
-
* @returns string
|
929
|
-
*/var stringifyData=function stringifyData(value){var excludeNull=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var excludeKeys=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];return JSON.stringify(value,function(key,value){if(excludeNull&&isNull(value)||excludeKeys.includes(key)){return undefined;}return value;});};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
930
|
-
// Using a regular function to use `this` for the parent context
|
931
|
-
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
932
|
-
}// `this` is the object that value is contained in, i.e., its direct parent.
|
933
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
934
|
-
// @ts-ignore-next-line
|
935
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
936
|
-
}// Check for circular references (if the value is already in the ancestors)
|
937
|
-
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
938
|
-
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
939
|
-
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
940
|
-
// eslint-disable-next-line no-restricted-syntax
|
941
|
-
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
942
|
-
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
943
|
-
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
944
|
-
* Recursively traverses an object similar to JSON.stringify,
|
945
|
-
* sanitizing BigInts and circular references
|
946
|
-
* @param value Input object
|
947
|
-
* @param logger Logger instance
|
948
|
-
* @returns Sanitized value
|
949
|
-
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
950
|
-
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};var tempUtil=function tempUtil(){stringifyData();};
|
951
|
-
|
952
908
|
// if yes make them null instead of omitting in overloaded cases
|
953
909
|
/*
|
954
910
|
* Normalise the overloaded arguments of the page call facade
|
955
|
-
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){
|
911
|
+
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){var payload={category:category,name:name,properties:properties,options:options,callback:undefined};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.category=category;payload.name=name;payload.properties=properties;payload.options=undefined;payload.callback=options;}if(isFunction(properties)){payload.category=category;payload.name=name;payload.properties=undefined;payload.options=undefined;payload.callback=properties;}if(isFunction(name)){payload.category=category;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=name;}if(isFunction(category)){payload.category=undefined;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=category;}if(isObjectLiteralAndNotNull(category)){payload.name=undefined;payload.category=undefined;payload.properties=category;if(!isFunction(name)){payload.options=name;}else {payload.options=undefined;}}else if(isObjectLiteralAndNotNull(name)){payload.name=undefined;payload.properties=name;if(!isFunction(properties)){payload.options=properties;}else {payload.options=undefined;}}// if the category argument alone is provided b/w category and name,
|
956
912
|
// use it as name and set category to undefined
|
957
913
|
if(isString(category)&&!isString(name)){payload.category=undefined;payload.name=category;}// Rest of the code is just to clean up undefined values
|
958
914
|
// and set some proper defaults
|
@@ -1027,6 +983,43 @@ var getFormattedTimestamp=function getFormattedTimestamp(date){return date.toISO
|
|
1027
983
|
* @returns ISO formatted timestamp string
|
1028
984
|
*/var getCurrentTimeFormatted=function getCurrentTimeFormatted(){return getFormattedTimestamp(new Date());};
|
1029
985
|
|
986
|
+
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
987
|
+
|
988
|
+
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
989
|
+
// eslint-disable-next-line func-names
|
990
|
+
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
991
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
992
|
+
// @ts-ignore-next-line
|
993
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
994
|
+
* Utility method for JSON stringify object excluding null values & circular references
|
995
|
+
*
|
996
|
+
* @param {*} value input
|
997
|
+
* @param {boolean} excludeNull if it should exclude nul or not
|
998
|
+
* @param {function} logger optional logger methods for warning
|
999
|
+
* @returns string
|
1000
|
+
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
1001
|
+
// Using a regular function to use `this` for the parent context
|
1002
|
+
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
1003
|
+
}// `this` is the object that value is contained in, i.e., its direct parent.
|
1004
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
1005
|
+
// @ts-ignore-next-line
|
1006
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
1007
|
+
}// Check for circular references (if the value is already in the ancestors)
|
1008
|
+
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
1009
|
+
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
1010
|
+
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
1011
|
+
// eslint-disable-next-line no-restricted-syntax
|
1012
|
+
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
1013
|
+
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
1014
|
+
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
1015
|
+
* Recursively traverses an object similar to JSON.stringify,
|
1016
|
+
* sanitizing BigInts and circular references
|
1017
|
+
* @param value Input object
|
1018
|
+
* @param logger Logger instance
|
1019
|
+
* @returns Sanitized value
|
1020
|
+
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
1021
|
+
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};
|
1022
|
+
|
1030
1023
|
var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
1031
1024
|
* Get mutated error with issue prepended to error message
|
1032
1025
|
* @param err Original error
|
@@ -1034,7 +1027,7 @@ var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
|
1034
1027
|
* @returns Instance of Error with message prepended with issue
|
1035
1028
|
*/var getMutatedError=function getMutatedError(err,issue){var finalError=err;if(!isTypeOfError(err)){finalError=new Error("".concat(issue,": ").concat(stringifyWithoutCircular(err)));}else {finalError.message="".concat(issue,": ").concat(err.message);}return finalError;};var dispatchErrorEvent=function dispatchErrorEvent(error){if(isTypeOfError(error)){var _error$stack;error.stack="".concat((_error$stack=error.stack)!==null&&_error$stack!==void 0?_error$stack:'',"\n").concat(MANUAL_ERROR_IDENTIFIER);}globalThis.dispatchEvent(new ErrorEvent('error',{error:error}));};
|
1036
1029
|
|
1037
|
-
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.
|
1030
|
+
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.14';var APP_NAMESPACE='com.rudderlabs.javascript';var MODULE_TYPE='npm';var ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';var ADBLOCK_PAGE_NAME='ad-block page request';var ADBLOCK_PAGE_PATH='/ad-blocked';var GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';var CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
|
1038
1031
|
|
1039
1032
|
var QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';var QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';var QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';var QUERY_PARAM_USER_ID_KEY='ajs_uid';var QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
|
1040
1033
|
|
@@ -4021,13 +4014,11 @@ if(isString(writeKey)&&writeKey){this.defaultAnalyticsKey=writeKey;}}/**
|
|
4021
4014
|
* @param dataPlaneUrl Data plane URL
|
4022
4015
|
* @param loadOptions Additional options for loading the SDK
|
4023
4016
|
* @returns none
|
4024
|
-
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey)
|
4017
|
+
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);// Get the preloaded events array from global buffer instead of window.rudderanalytics
|
4018
|
+
// as the constructor must have already pushed the events to the global buffer
|
4019
|
+
var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
|
4025
4020
|
this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
|
4026
4021
|
promotePreloadedConsentEventsToTop(preloadedEventsArray);setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));this.analyticsInstances[writeKey]=new Analytics();(_this$getAnalyticsIns=this.getAnalyticsInstance(writeKey))===null||_this$getAnalyticsIns===void 0||_this$getAnalyticsIns.load(writeKey,dataPlaneUrl,getSanitizedValue(loadOptions));}catch(error){dispatchErrorEvent(error);}}/**
|
4027
|
-
* A function to get preloaded events array from global object
|
4028
|
-
* @returns preloaded events array
|
4029
|
-
*/// eslint-disable-next-line class-methods-use-this
|
4030
|
-
},{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
|
4031
4022
|
* A function to track page lifecycle events like page loaded and page unloaded
|
4032
4023
|
* @param preloadedEventsArray
|
4033
4024
|
* @param loadOptions
|
@@ -4050,11 +4041,11 @@ state.autoTrack.enabled.value=autoTrackEnabled||pageLifecycleEnabled;if(!pageLif
|
|
4050
4041
|
this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
|
4051
4042
|
* Trigger load event in buffer queue if exists and stores the
|
4052
4043
|
* remaining preloaded events array in global object
|
4053
|
-
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=
|
4044
|
+
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
|
4054
4045
|
// BTW, load method is also removed from the array
|
4055
4046
|
// So, the Analytics object can directly consume the remaining events
|
4056
4047
|
var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
|
4057
|
-
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
|
4048
|
+
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
|
4058
4049
|
if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
|
4059
4050
|
loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
4060
4051
|
// @ts-ignore
|
@@ -905,54 +905,10 @@ var trim=function trim(value){return value.replace(/^\s+|\s+$/gm,'');};var remov
|
|
905
905
|
* @returns decoded string
|
906
906
|
*/var fromBase64=function fromBase64(value){return new TextDecoder().decode(base64ToBytes(value));};
|
907
907
|
|
908
|
-
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
909
|
-
|
910
|
-
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
911
|
-
// eslint-disable-next-line func-names
|
912
|
-
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
913
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
914
|
-
// @ts-ignore-next-line
|
915
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
916
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
917
|
-
*
|
918
|
-
* @param {*} value input
|
919
|
-
* @param {boolean} excludeNull if it should exclude nul or not
|
920
|
-
* @param {function} logger optional logger methods for warning
|
921
|
-
* @returns string
|
922
|
-
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};/**
|
923
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
924
|
-
*
|
925
|
-
* @param {*} value input value
|
926
|
-
* @param {boolean} excludeNull optional flag to exclude null values
|
927
|
-
* @param {string[]} excludeKeys optional array of keys to exclude
|
928
|
-
* @returns string
|
929
|
-
*/var stringifyData=function stringifyData(value){var excludeNull=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var excludeKeys=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];return JSON.stringify(value,function(key,value){if(excludeNull&&isNull(value)||excludeKeys.includes(key)){return undefined;}return value;});};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
930
|
-
// Using a regular function to use `this` for the parent context
|
931
|
-
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
932
|
-
}// `this` is the object that value is contained in, i.e., its direct parent.
|
933
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
934
|
-
// @ts-ignore-next-line
|
935
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
936
|
-
}// Check for circular references (if the value is already in the ancestors)
|
937
|
-
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
938
|
-
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
939
|
-
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
940
|
-
// eslint-disable-next-line no-restricted-syntax
|
941
|
-
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
942
|
-
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
943
|
-
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
944
|
-
* Recursively traverses an object similar to JSON.stringify,
|
945
|
-
* sanitizing BigInts and circular references
|
946
|
-
* @param value Input object
|
947
|
-
* @param logger Logger instance
|
948
|
-
* @returns Sanitized value
|
949
|
-
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
950
|
-
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};var tempUtil=function tempUtil(){stringifyData();};
|
951
|
-
|
952
908
|
// if yes make them null instead of omitting in overloaded cases
|
953
909
|
/*
|
954
910
|
* Normalise the overloaded arguments of the page call facade
|
955
|
-
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){
|
911
|
+
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){var payload={category:category,name:name,properties:properties,options:options,callback:undefined};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.category=category;payload.name=name;payload.properties=properties;payload.options=undefined;payload.callback=options;}if(isFunction(properties)){payload.category=category;payload.name=name;payload.properties=undefined;payload.options=undefined;payload.callback=properties;}if(isFunction(name)){payload.category=category;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=name;}if(isFunction(category)){payload.category=undefined;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=category;}if(isObjectLiteralAndNotNull(category)){payload.name=undefined;payload.category=undefined;payload.properties=category;if(!isFunction(name)){payload.options=name;}else {payload.options=undefined;}}else if(isObjectLiteralAndNotNull(name)){payload.name=undefined;payload.properties=name;if(!isFunction(properties)){payload.options=properties;}else {payload.options=undefined;}}// if the category argument alone is provided b/w category and name,
|
956
912
|
// use it as name and set category to undefined
|
957
913
|
if(isString(category)&&!isString(name)){payload.category=undefined;payload.name=category;}// Rest of the code is just to clean up undefined values
|
958
914
|
// and set some proper defaults
|
@@ -1027,6 +983,43 @@ var getFormattedTimestamp=function getFormattedTimestamp(date){return date.toISO
|
|
1027
983
|
* @returns ISO formatted timestamp string
|
1028
984
|
*/var getCurrentTimeFormatted=function getCurrentTimeFormatted(){return getFormattedTimestamp(new Date());};
|
1029
985
|
|
986
|
+
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
987
|
+
|
988
|
+
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
989
|
+
// eslint-disable-next-line func-names
|
990
|
+
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
991
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
992
|
+
// @ts-ignore-next-line
|
993
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
994
|
+
* Utility method for JSON stringify object excluding null values & circular references
|
995
|
+
*
|
996
|
+
* @param {*} value input
|
997
|
+
* @param {boolean} excludeNull if it should exclude nul or not
|
998
|
+
* @param {function} logger optional logger methods for warning
|
999
|
+
* @returns string
|
1000
|
+
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
1001
|
+
// Using a regular function to use `this` for the parent context
|
1002
|
+
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
1003
|
+
}// `this` is the object that value is contained in, i.e., its direct parent.
|
1004
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
1005
|
+
// @ts-ignore-next-line
|
1006
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
1007
|
+
}// Check for circular references (if the value is already in the ancestors)
|
1008
|
+
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
1009
|
+
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
1010
|
+
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
1011
|
+
// eslint-disable-next-line no-restricted-syntax
|
1012
|
+
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
1013
|
+
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
1014
|
+
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
1015
|
+
* Recursively traverses an object similar to JSON.stringify,
|
1016
|
+
* sanitizing BigInts and circular references
|
1017
|
+
* @param value Input object
|
1018
|
+
* @param logger Logger instance
|
1019
|
+
* @returns Sanitized value
|
1020
|
+
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
1021
|
+
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};
|
1022
|
+
|
1030
1023
|
var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
1031
1024
|
* Get mutated error with issue prepended to error message
|
1032
1025
|
* @param err Original error
|
@@ -1034,7 +1027,7 @@ var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
|
1034
1027
|
* @returns Instance of Error with message prepended with issue
|
1035
1028
|
*/var getMutatedError=function getMutatedError(err,issue){var finalError=err;if(!isTypeOfError(err)){finalError=new Error("".concat(issue,": ").concat(stringifyWithoutCircular(err)));}else {finalError.message="".concat(issue,": ").concat(err.message);}return finalError;};var dispatchErrorEvent=function dispatchErrorEvent(error){if(isTypeOfError(error)){var _error$stack;error.stack="".concat((_error$stack=error.stack)!==null&&_error$stack!==void 0?_error$stack:'',"\n").concat(MANUAL_ERROR_IDENTIFIER);}globalThis.dispatchEvent(new ErrorEvent('error',{error:error}));};
|
1036
1029
|
|
1037
|
-
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.
|
1030
|
+
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.14';var APP_NAMESPACE='com.rudderlabs.javascript';var MODULE_TYPE='npm';var ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';var ADBLOCK_PAGE_NAME='ad-block page request';var ADBLOCK_PAGE_PATH='/ad-blocked';var GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';var CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
|
1038
1031
|
|
1039
1032
|
var QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';var QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';var QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';var QUERY_PARAM_USER_ID_KEY='ajs_uid';var QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
|
1040
1033
|
|
@@ -3997,13 +3990,11 @@ if(isString(writeKey)&&writeKey){this.defaultAnalyticsKey=writeKey;}}/**
|
|
3997
3990
|
* @param dataPlaneUrl Data plane URL
|
3998
3991
|
* @param loadOptions Additional options for loading the SDK
|
3999
3992
|
* @returns none
|
4000
|
-
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey)
|
3993
|
+
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);// Get the preloaded events array from global buffer instead of window.rudderanalytics
|
3994
|
+
// as the constructor must have already pushed the events to the global buffer
|
3995
|
+
var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
|
4001
3996
|
this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
|
4002
3997
|
promotePreloadedConsentEventsToTop(preloadedEventsArray);setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));this.analyticsInstances[writeKey]=new Analytics();(_this$getAnalyticsIns=this.getAnalyticsInstance(writeKey))===null||_this$getAnalyticsIns===void 0||_this$getAnalyticsIns.load(writeKey,dataPlaneUrl,getSanitizedValue(loadOptions));}catch(error){dispatchErrorEvent(error);}}/**
|
4003
|
-
* A function to get preloaded events array from global object
|
4004
|
-
* @returns preloaded events array
|
4005
|
-
*/// eslint-disable-next-line class-methods-use-this
|
4006
|
-
},{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
|
4007
3998
|
* A function to track page lifecycle events like page loaded and page unloaded
|
4008
3999
|
* @param preloadedEventsArray
|
4009
4000
|
* @param loadOptions
|
@@ -4026,11 +4017,11 @@ state.autoTrack.enabled.value=autoTrackEnabled||pageLifecycleEnabled;if(!pageLif
|
|
4026
4017
|
this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
|
4027
4018
|
* Trigger load event in buffer queue if exists and stores the
|
4028
4019
|
* remaining preloaded events array in global object
|
4029
|
-
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=
|
4020
|
+
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
|
4030
4021
|
// BTW, load method is also removed from the array
|
4031
4022
|
// So, the Analytics object can directly consume the remaining events
|
4032
4023
|
var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
|
4033
|
-
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
|
4024
|
+
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
|
4034
4025
|
if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
|
4035
4026
|
loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
4036
4027
|
// @ts-ignore
|
@@ -903,54 +903,10 @@ var trim=function trim(value){return value.replace(/^\s+|\s+$/gm,'');};var remov
|
|
903
903
|
* @returns decoded string
|
904
904
|
*/var fromBase64=function fromBase64(value){return new TextDecoder().decode(base64ToBytes(value));};
|
905
905
|
|
906
|
-
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
907
|
-
|
908
|
-
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
909
|
-
// eslint-disable-next-line func-names
|
910
|
-
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
911
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
912
|
-
// @ts-ignore-next-line
|
913
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
914
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
915
|
-
*
|
916
|
-
* @param {*} value input
|
917
|
-
* @param {boolean} excludeNull if it should exclude nul or not
|
918
|
-
* @param {function} logger optional logger methods for warning
|
919
|
-
* @returns string
|
920
|
-
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};/**
|
921
|
-
* Utility method for JSON stringify object excluding null values & circular references
|
922
|
-
*
|
923
|
-
* @param {*} value input value
|
924
|
-
* @param {boolean} excludeNull optional flag to exclude null values
|
925
|
-
* @param {string[]} excludeKeys optional array of keys to exclude
|
926
|
-
* @returns string
|
927
|
-
*/var stringifyData=function stringifyData(value){var excludeNull=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var excludeKeys=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];return JSON.stringify(value,function(key,value){if(excludeNull&&isNull(value)||excludeKeys.includes(key)){return undefined;}return value;});};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
928
|
-
// Using a regular function to use `this` for the parent context
|
929
|
-
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
930
|
-
}// `this` is the object that value is contained in, i.e., its direct parent.
|
931
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
932
|
-
// @ts-ignore-next-line
|
933
|
-
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
934
|
-
}// Check for circular references (if the value is already in the ancestors)
|
935
|
-
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
936
|
-
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
937
|
-
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
938
|
-
// eslint-disable-next-line no-restricted-syntax
|
939
|
-
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
940
|
-
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
941
|
-
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
942
|
-
* Recursively traverses an object similar to JSON.stringify,
|
943
|
-
* sanitizing BigInts and circular references
|
944
|
-
* @param value Input object
|
945
|
-
* @param logger Logger instance
|
946
|
-
* @returns Sanitized value
|
947
|
-
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
948
|
-
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};var tempUtil=function tempUtil(){stringifyData();};
|
949
|
-
|
950
906
|
// if yes make them null instead of omitting in overloaded cases
|
951
907
|
/*
|
952
908
|
* Normalise the overloaded arguments of the page call facade
|
953
|
-
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){
|
909
|
+
*/var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){var payload={category:category,name:name,properties:properties,options:options,callback:undefined};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.category=category;payload.name=name;payload.properties=properties;payload.options=undefined;payload.callback=options;}if(isFunction(properties)){payload.category=category;payload.name=name;payload.properties=undefined;payload.options=undefined;payload.callback=properties;}if(isFunction(name)){payload.category=category;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=name;}if(isFunction(category)){payload.category=undefined;payload.name=undefined;payload.properties=undefined;payload.options=undefined;payload.callback=category;}if(isObjectLiteralAndNotNull(category)){payload.name=undefined;payload.category=undefined;payload.properties=category;if(!isFunction(name)){payload.options=name;}else {payload.options=undefined;}}else if(isObjectLiteralAndNotNull(name)){payload.name=undefined;payload.properties=name;if(!isFunction(properties)){payload.options=properties;}else {payload.options=undefined;}}// if the category argument alone is provided b/w category and name,
|
954
910
|
// use it as name and set category to undefined
|
955
911
|
if(isString(category)&&!isString(name)){payload.category=undefined;payload.name=category;}// Rest of the code is just to clean up undefined values
|
956
912
|
// and set some proper defaults
|
@@ -1025,6 +981,43 @@ var getFormattedTimestamp=function getFormattedTimestamp(date){return date.toISO
|
|
1025
981
|
* @returns ISO formatted timestamp string
|
1026
982
|
*/var getCurrentTimeFormatted=function getCurrentTimeFormatted(){return getFormattedTimestamp(new Date());};
|
1027
983
|
|
984
|
+
var LOG_CONTEXT_SEPARATOR=':: ';var SCRIPT_ALREADY_EXISTS_ERROR=function SCRIPT_ALREADY_EXISTS_ERROR(id){return "A script with the id \"".concat(id,"\" is already loaded. Skipping the loading of this script to prevent conflicts.");};var SCRIPT_LOAD_ERROR=function SCRIPT_LOAD_ERROR(id,url){return "Failed to load the script with the id \"".concat(id,"\" from URL \"").concat(url,"\".");};var SCRIPT_LOAD_TIMEOUT_ERROR=function SCRIPT_LOAD_TIMEOUT_ERROR(id,url,timeout){return "A timeout of ".concat(timeout," ms occurred while trying to load the script with id \"").concat(id,"\" from URL \"").concat(url,"\".");};var CIRCULAR_REFERENCE_WARNING=function CIRCULAR_REFERENCE_WARNING(context,key){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"A circular reference has been detected in the object and the property \"").concat(key,"\" has been dropped from the output.");};var JSON_STRINGIFY_WARNING="Failed to convert the value to a JSON string.";
|
985
|
+
|
986
|
+
var JSON_STRINGIFY='JSONStringify';var BIG_INT_PLACEHOLDER='[BigInt]';var CIRCULAR_REFERENCE_PLACEHOLDER='[Circular Reference]';var getCircularReplacer=function getCircularReplacer(excludeNull,excludeKeys,logger){var ancestors=[];// Here we do not want to use arrow function to use "this" in function context
|
987
|
+
// eslint-disable-next-line func-names
|
988
|
+
return function(key,value){if(excludeKeys!==null&&excludeKeys!==void 0&&excludeKeys.includes(key)){return undefined;}if(excludeNull&&isNullOrUndefined(value)){return undefined;}if(_typeof(value)!=='object'||isNull(value)){return value;}// `this` is the object that value is contained in, i.e., its direct parent.
|
989
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
990
|
+
// @ts-ignore-next-line
|
991
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();}if(ancestors.includes(value)){logger===null||logger===void 0||logger.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY,key));return CIRCULAR_REFERENCE_PLACEHOLDER;}ancestors.push(value);return value;};};/**
|
992
|
+
* Utility method for JSON stringify object excluding null values & circular references
|
993
|
+
*
|
994
|
+
* @param {*} value input
|
995
|
+
* @param {boolean} excludeNull if it should exclude nul or not
|
996
|
+
* @param {function} logger optional logger methods for warning
|
997
|
+
* @returns string
|
998
|
+
*/var stringifyWithoutCircular=function stringifyWithoutCircular(value,excludeNull,excludeKeys,logger){try{return JSON.stringify(value,getCircularReplacer(excludeNull,excludeKeys,logger));}catch(err){logger===null||logger===void 0||logger.warn(JSON_STRINGIFY_WARNING,err);return null;}};var getReplacer=function getReplacer(logger){var ancestors=[];// Array to track ancestor objects
|
999
|
+
// Using a regular function to use `this` for the parent context
|
1000
|
+
return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
|
1001
|
+
}// `this` is the object that value is contained in, i.e., its direct parent.
|
1002
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
1003
|
+
// @ts-ignore-next-line
|
1004
|
+
while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
|
1005
|
+
}// Check for circular references (if the value is already in the ancestors)
|
1006
|
+
if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
|
1007
|
+
ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
|
1008
|
+
var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
|
1009
|
+
// eslint-disable-next-line no-restricted-syntax
|
1010
|
+
for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
|
1011
|
+
var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
|
1012
|
+
if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
|
1013
|
+
* Recursively traverses an object similar to JSON.stringify,
|
1014
|
+
* sanitizing BigInts and circular references
|
1015
|
+
* @param value Input object
|
1016
|
+
* @param logger Logger instance
|
1017
|
+
* @returns Sanitized value
|
1018
|
+
*/var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
|
1019
|
+
var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};
|
1020
|
+
|
1028
1021
|
var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
1029
1022
|
* Get mutated error with issue prepended to error message
|
1030
1023
|
* @param err Original error
|
@@ -1032,7 +1025,7 @@ var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
|
|
1032
1025
|
* @returns Instance of Error with message prepended with issue
|
1033
1026
|
*/var getMutatedError=function getMutatedError(err,issue){var finalError=err;if(!isTypeOfError(err)){finalError=new Error("".concat(issue,": ").concat(stringifyWithoutCircular(err)));}else {finalError.message="".concat(issue,": ").concat(err.message);}return finalError;};var dispatchErrorEvent=function dispatchErrorEvent(error){if(isTypeOfError(error)){var _error$stack;error.stack="".concat((_error$stack=error.stack)!==null&&_error$stack!==void 0?_error$stack:'',"\n").concat(MANUAL_ERROR_IDENTIFIER);}globalThis.dispatchEvent(new ErrorEvent('error',{error:error}));};
|
1034
1027
|
|
1035
|
-
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.
|
1028
|
+
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.14';var APP_NAMESPACE='com.rudderlabs.javascript';var MODULE_TYPE='npm';var ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';var ADBLOCK_PAGE_NAME='ad-block page request';var ADBLOCK_PAGE_PATH='/ad-blocked';var GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';var CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
|
1036
1029
|
|
1037
1030
|
var QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';var QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';var QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';var QUERY_PARAM_USER_ID_KEY='ajs_uid';var QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
|
1038
1031
|
|
@@ -3995,13 +3988,11 @@ if(isString(writeKey)&&writeKey){this.defaultAnalyticsKey=writeKey;}}/**
|
|
3995
3988
|
* @param dataPlaneUrl Data plane URL
|
3996
3989
|
* @param loadOptions Additional options for loading the SDK
|
3997
3990
|
* @returns none
|
3998
|
-
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey)
|
3991
|
+
*/},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);// Get the preloaded events array from global buffer instead of window.rudderanalytics
|
3992
|
+
// as the constructor must have already pushed the events to the global buffer
|
3993
|
+
var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
|
3999
3994
|
this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
|
4000
3995
|
promotePreloadedConsentEventsToTop(preloadedEventsArray);setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));this.analyticsInstances[writeKey]=new Analytics();(_this$getAnalyticsIns=this.getAnalyticsInstance(writeKey))===null||_this$getAnalyticsIns===void 0||_this$getAnalyticsIns.load(writeKey,dataPlaneUrl,getSanitizedValue(loadOptions));}catch(error){dispatchErrorEvent(error);}}/**
|
4001
|
-
* A function to get preloaded events array from global object
|
4002
|
-
* @returns preloaded events array
|
4003
|
-
*/// eslint-disable-next-line class-methods-use-this
|
4004
|
-
},{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
|
4005
3996
|
* A function to track page lifecycle events like page loaded and page unloaded
|
4006
3997
|
* @param preloadedEventsArray
|
4007
3998
|
* @param loadOptions
|
@@ -4024,11 +4015,11 @@ state.autoTrack.enabled.value=autoTrackEnabled||pageLifecycleEnabled;if(!pageLif
|
|
4024
4015
|
this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
|
4025
4016
|
* Trigger load event in buffer queue if exists and stores the
|
4026
4017
|
* remaining preloaded events array in global object
|
4027
|
-
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=
|
4018
|
+
*/},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
|
4028
4019
|
// BTW, load method is also removed from the array
|
4029
4020
|
// So, the Analytics object can directly consume the remaining events
|
4030
4021
|
var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
|
4031
|
-
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
|
4022
|
+
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
|
4032
4023
|
if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
|
4033
4024
|
loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
4034
4025
|
// @ts-ignore
|