@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.
@@ -909,54 +909,10 @@
909
909
  * @returns decoded string
910
910
  */var fromBase64=function fromBase64(value){return new TextDecoder().decode(base64ToBytes(value));};
911
911
 
912
- 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.";
913
-
914
- 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
915
- // eslint-disable-next-line func-names
916
- 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.
917
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
918
- // @ts-ignore-next-line
919
- 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;};};/**
920
- * Utility method for JSON stringify object excluding null values & circular references
921
- *
922
- * @param {*} value input
923
- * @param {boolean} excludeNull if it should exclude nul or not
924
- * @param {function} logger optional logger methods for warning
925
- * @returns string
926
- */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;}};/**
927
- * Utility method for JSON stringify object excluding null values & circular references
928
- *
929
- * @param {*} value input value
930
- * @param {boolean} excludeNull optional flag to exclude null values
931
- * @param {string[]} excludeKeys optional array of keys to exclude
932
- * @returns string
933
- */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
934
- // Using a regular function to use `this` for the parent context
935
- return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
936
- }// `this` is the object that value is contained in, i.e., its direct parent.
937
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
938
- // @ts-ignore-next-line
939
- while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
940
- }// Check for circular references (if the value is already in the ancestors)
941
- if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
942
- ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
943
- var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
944
- // eslint-disable-next-line no-restricted-syntax
945
- for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
946
- var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
947
- if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
948
- * Recursively traverses an object similar to JSON.stringify,
949
- * sanitizing BigInts and circular references
950
- * @param value Input object
951
- * @param logger Logger instance
952
- * @returns Sanitized value
953
- */var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
954
- var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};var tempUtil=function tempUtil(){stringifyData();};
955
-
956
912
  // if yes make them null instead of omitting in overloaded cases
957
913
  /*
958
914
  * Normalise the overloaded arguments of the page call facade
959
- */var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){tempUtil();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,
915
+ */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,
960
916
  // use it as name and set category to undefined
961
917
  if(isString(category)&&!isString(name)){payload.category=undefined;payload.name=category;}// Rest of the code is just to clean up undefined values
962
918
  // and set some proper defaults
@@ -1031,6 +987,43 @@
1031
987
  * @returns ISO formatted timestamp string
1032
988
  */var getCurrentTimeFormatted=function getCurrentTimeFormatted(){return getFormattedTimestamp(new Date());};
1033
989
 
990
+ 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.";
991
+
992
+ 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
993
+ // eslint-disable-next-line func-names
994
+ 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.
995
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
996
+ // @ts-ignore-next-line
997
+ 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;};};/**
998
+ * Utility method for JSON stringify object excluding null values & circular references
999
+ *
1000
+ * @param {*} value input
1001
+ * @param {boolean} excludeNull if it should exclude nul or not
1002
+ * @param {function} logger optional logger methods for warning
1003
+ * @returns string
1004
+ */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
1005
+ // Using a regular function to use `this` for the parent context
1006
+ return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
1007
+ }// `this` is the object that value is contained in, i.e., its direct parent.
1008
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1009
+ // @ts-ignore-next-line
1010
+ while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
1011
+ }// Check for circular references (if the value is already in the ancestors)
1012
+ if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
1013
+ ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
1014
+ var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
1015
+ // eslint-disable-next-line no-restricted-syntax
1016
+ for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
1017
+ var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
1018
+ if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
1019
+ * Recursively traverses an object similar to JSON.stringify,
1020
+ * sanitizing BigInts and circular references
1021
+ * @param value Input object
1022
+ * @param logger Logger instance
1023
+ * @returns Sanitized value
1024
+ */var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
1025
+ var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};
1026
+
1034
1027
  var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
1035
1028
  * Get mutated error with issue prepended to error message
1036
1029
  * @param err Original error
@@ -1038,7 +1031,7 @@
1038
1031
  * @returns Instance of Error with message prepended with issue
1039
1032
  */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}));};
1040
1033
 
1041
- var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.12';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';
1034
+ 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';
1042
1035
 
1043
1036
  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';
1044
1037
 
@@ -4001,13 +3994,11 @@
4001
3994
  * @param dataPlaneUrl Data plane URL
4002
3995
  * @param loadOptions Additional options for loading the SDK
4003
3996
  * @returns none
4004
- */},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);var preloadedEventsArray=this.getPreloadedEvents();// Track page loaded lifecycle event if enabled
3997
+ */},{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
3998
+ // as the constructor must have already pushed the events to the global buffer
3999
+ var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
4005
4000
  this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
4006
4001
  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);}}/**
4007
- * A function to get preloaded events array from global object
4008
- * @returns preloaded events array
4009
- */// eslint-disable-next-line class-methods-use-this
4010
- },{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
4011
4002
  * A function to track page lifecycle events like page loaded and page unloaded
4012
4003
  * @param preloadedEventsArray
4013
4004
  * @param loadOptions
@@ -4030,11 +4021,11 @@
4030
4021
  this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
4031
4022
  * Trigger load event in buffer queue if exists and stores the
4032
4023
  * remaining preloaded events array in global object
4033
- */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=this.getPreloadedEvents();// Get any load method call that is buffered if any
4024
+ */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
4034
4025
  // BTW, load method is also removed from the array
4035
4026
  // So, the Analytics object can directly consume the remaining events
4036
4027
  var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
4037
- setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
4028
+ setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
4038
4029
  if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
4039
4030
  loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4040
4031
  // @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){tempUtil();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,
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.12';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';
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
 
@@ -4019,13 +4012,11 @@ if(isString(writeKey)&&writeKey){this.defaultAnalyticsKey=writeKey;}}/**
4019
4012
  * @param dataPlaneUrl Data plane URL
4020
4013
  * @param loadOptions Additional options for loading the SDK
4021
4014
  * @returns none
4022
- */},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);var preloadedEventsArray=this.getPreloadedEvents();// Track page loaded lifecycle event if enabled
4015
+ */},{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
4016
+ // as the constructor must have already pushed the events to the global buffer
4017
+ var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
4023
4018
  this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
4024
4019
  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);}}/**
4025
- * A function to get preloaded events array from global object
4026
- * @returns preloaded events array
4027
- */// eslint-disable-next-line class-methods-use-this
4028
- },{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
4029
4020
  * A function to track page lifecycle events like page loaded and page unloaded
4030
4021
  * @param preloadedEventsArray
4031
4022
  * @param loadOptions
@@ -4048,11 +4039,11 @@ state.autoTrack.enabled.value=autoTrackEnabled||pageLifecycleEnabled;if(!pageLif
4048
4039
  this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
4049
4040
  * Trigger load event in buffer queue if exists and stores the
4050
4041
  * remaining preloaded events array in global object
4051
- */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=this.getPreloadedEvents();// Get any load method call that is buffered if any
4042
+ */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
4052
4043
  // BTW, load method is also removed from the array
4053
4044
  // So, the Analytics object can directly consume the remaining events
4054
4045
  var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
4055
- setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
4046
+ setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
4056
4047
  if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
4057
4048
  loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4058
4049
  // @ts-ignore
@@ -909,54 +909,10 @@
909
909
  * @returns decoded string
910
910
  */var fromBase64=function fromBase64(value){return new TextDecoder().decode(base64ToBytes(value));};
911
911
 
912
- 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.";
913
-
914
- 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
915
- // eslint-disable-next-line func-names
916
- 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.
917
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
918
- // @ts-ignore-next-line
919
- 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;};};/**
920
- * Utility method for JSON stringify object excluding null values & circular references
921
- *
922
- * @param {*} value input
923
- * @param {boolean} excludeNull if it should exclude nul or not
924
- * @param {function} logger optional logger methods for warning
925
- * @returns string
926
- */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;}};/**
927
- * Utility method for JSON stringify object excluding null values & circular references
928
- *
929
- * @param {*} value input value
930
- * @param {boolean} excludeNull optional flag to exclude null values
931
- * @param {string[]} excludeKeys optional array of keys to exclude
932
- * @returns string
933
- */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
934
- // Using a regular function to use `this` for the parent context
935
- return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
936
- }// `this` is the object that value is contained in, i.e., its direct parent.
937
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
938
- // @ts-ignore-next-line
939
- while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
940
- }// Check for circular references (if the value is already in the ancestors)
941
- if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
942
- ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
943
- var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
944
- // eslint-disable-next-line no-restricted-syntax
945
- for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
946
- var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
947
- if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
948
- * Recursively traverses an object similar to JSON.stringify,
949
- * sanitizing BigInts and circular references
950
- * @param value Input object
951
- * @param logger Logger instance
952
- * @returns Sanitized value
953
- */var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
954
- var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};var tempUtil=function tempUtil(){stringifyData();};
955
-
956
912
  // if yes make them null instead of omitting in overloaded cases
957
913
  /*
958
914
  * Normalise the overloaded arguments of the page call facade
959
- */var pageArgumentsToCallOptions=function pageArgumentsToCallOptions(category,name,properties,options,callback){tempUtil();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,
915
+ */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,
960
916
  // use it as name and set category to undefined
961
917
  if(isString(category)&&!isString(name)){payload.category=undefined;payload.name=category;}// Rest of the code is just to clean up undefined values
962
918
  // and set some proper defaults
@@ -1031,6 +987,43 @@
1031
987
  * @returns ISO formatted timestamp string
1032
988
  */var getCurrentTimeFormatted=function getCurrentTimeFormatted(){return getFormattedTimestamp(new Date());};
1033
989
 
990
+ 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.";
991
+
992
+ 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
993
+ // eslint-disable-next-line func-names
994
+ 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.
995
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
996
+ // @ts-ignore-next-line
997
+ 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;};};/**
998
+ * Utility method for JSON stringify object excluding null values & circular references
999
+ *
1000
+ * @param {*} value input
1001
+ * @param {boolean} excludeNull if it should exclude nul or not
1002
+ * @param {function} logger optional logger methods for warning
1003
+ * @returns string
1004
+ */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
1005
+ // Using a regular function to use `this` for the parent context
1006
+ return function replacer(key,value){if(isBigInt(value)){return BIG_INT_PLACEHOLDER;// Replace BigInt values
1007
+ }// `this` is the object that value is contained in, i.e., its direct parent.
1008
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1009
+ // @ts-ignore-next-line
1010
+ while(ancestors.length>0&&ancestors[ancestors.length-1]!==this){ancestors.pop();// Remove ancestors that are no longer part of the chain
1011
+ }// Check for circular references (if the value is already in the ancestors)
1012
+ if(ancestors.includes(value)){return CIRCULAR_REFERENCE_PLACEHOLDER;}// Add current value to ancestors
1013
+ ancestors.push(value);return value;};};var _traverseWithThis=function traverseWithThis(obj,replacer){// Create a new result object or array
1014
+ var result=Array.isArray(obj)?[]:{};// Traverse object properties or array elements
1015
+ // eslint-disable-next-line no-restricted-syntax
1016
+ for(var key in obj){if(Object.hasOwnProperty.call(obj,key)){var value=obj[key];// Recursively apply the replacer and traversal
1017
+ var sanitizedValue=replacer.call(obj,key,value);// If the value is an object or array, continue traversal
1018
+ if(isObjectLiteralAndNotNull(sanitizedValue)||Array.isArray(sanitizedValue)){result[key]=_traverseWithThis(sanitizedValue,replacer);}else {result[key]=sanitizedValue;}}}return result;};/**
1019
+ * Recursively traverses an object similar to JSON.stringify,
1020
+ * sanitizing BigInts and circular references
1021
+ * @param value Input object
1022
+ * @param logger Logger instance
1023
+ * @returns Sanitized value
1024
+ */var getSanitizedValue=function getSanitizedValue(value,logger){var replacer=getReplacer();// This is needed for registering the first ancestor
1025
+ var newValue=replacer.call(value,'',value);if(isObjectLiteralAndNotNull(value)||Array.isArray(value)){return _traverseWithThis(value,replacer);}return newValue;};
1026
+
1034
1027
  var MANUAL_ERROR_IDENTIFIER='[MANUAL ERROR]';/**
1035
1028
  * Get mutated error with issue prepended to error message
1036
1029
  * @param err Original error
@@ -1038,7 +1031,7 @@
1038
1031
  * @returns Instance of Error with message prepended with issue
1039
1032
  */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}));};
1040
1033
 
1041
- var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.11.12';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';
1034
+ 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';
1042
1035
 
1043
1036
  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';
1044
1037
 
@@ -4025,13 +4018,11 @@
4025
4018
  * @param dataPlaneUrl Data plane URL
4026
4019
  * @param loadOptions Additional options for loading the SDK
4027
4020
  * @returns none
4028
- */},{key:"load",value:function load(writeKey,dataPlaneUrl,loadOptions){try{var _this$getAnalyticsIns;if(this.analyticsInstances[writeKey]){return;}this.setDefaultInstanceKey(writeKey);var preloadedEventsArray=this.getPreloadedEvents();// Track page loaded lifecycle event if enabled
4021
+ */},{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
4022
+ // as the constructor must have already pushed the events to the global buffer
4023
+ var preloadedEventsArray=getExposedGlobal(GLOBAL_PRELOAD_BUFFER);// Track page loaded lifecycle event if enabled
4029
4024
  this.trackPageLifecycleEvents(preloadedEventsArray,loadOptions);// The array will be mutated in the below method
4030
4025
  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);}}/**
4031
- * A function to get preloaded events array from global object
4032
- * @returns preloaded events array
4033
- */// eslint-disable-next-line class-methods-use-this
4034
- },{key:"getPreloadedEvents",value:function getPreloadedEvents(){return Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];}/**
4035
4026
  * A function to track page lifecycle events like page loaded and page unloaded
4036
4027
  * @param preloadedEventsArray
4037
4028
  * @param loadOptions
@@ -4054,11 +4045,11 @@
4054
4045
  this.logger.warn(PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(RSA));}}}/**
4055
4046
  * Trigger load event in buffer queue if exists and stores the
4056
4047
  * remaining preloaded events array in global object
4057
- */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=this.getPreloadedEvents();// Get any load method call that is buffered if any
4048
+ */},{key:"triggerBufferedLoadEvent",value:function triggerBufferedLoadEvent(){var preloadedEventsArray=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[];// Get any load method call that is buffered if any
4058
4049
  // BTW, load method is also removed from the array
4059
4050
  // So, the Analytics object can directly consume the remaining events
4060
4051
  var loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
4061
- setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
4052
+ setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(_toConsumableArray(preloadedEventsArray)));// Process load method if present in the buffered requests
4062
4053
  if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
4063
4054
  loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4064
4055
  // @ts-ignore