@rudderstack/analytics-js 3.34.3 → 3.35.1
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 +38 -0
- package/dist/npm/index.d.cts +5 -2
- package/dist/npm/index.d.mts +5 -2
- package/dist/npm/legacy/bundled/cjs/index.cjs +94 -48
- package/dist/npm/legacy/bundled/esm/index.mjs +94 -48
- package/dist/npm/legacy/bundled/umd/index.js +94 -48
- package/dist/npm/legacy/cjs/index.cjs +94 -48
- package/dist/npm/legacy/content-script/cjs/index.cjs +92 -47
- package/dist/npm/legacy/content-script/esm/index.mjs +92 -47
- package/dist/npm/legacy/content-script/umd/index.js +92 -47
- package/dist/npm/legacy/esm/index.mjs +94 -48
- package/dist/npm/legacy/lite/cjs/index.cjs +94 -48
- package/dist/npm/legacy/lite/esm/index.mjs +94 -48
- package/dist/npm/legacy/lite/umd/index.js +94 -48
- package/dist/npm/legacy/umd/index.js +94 -48
- package/dist/npm/modern/bundled/cjs/index.cjs +398 -310
- package/dist/npm/modern/bundled/esm/index.mjs +398 -310
- package/dist/npm/modern/bundled/umd/index.js +398 -310
- package/dist/npm/modern/cjs/index.cjs +295 -212
- package/dist/npm/modern/content-script/cjs/index.cjs +398 -310
- package/dist/npm/modern/content-script/esm/index.mjs +398 -310
- package/dist/npm/modern/content-script/umd/index.js +398 -310
- package/dist/npm/modern/esm/index.mjs +295 -212
- package/dist/npm/modern/lite/cjs/index.cjs +369 -281
- package/dist/npm/modern/lite/esm/index.mjs +369 -281
- package/dist/npm/modern/lite/umd/index.js +369 -281
- package/dist/npm/modern/umd/index.js +295 -212
- package/package.json +1 -1
|
@@ -911,7 +911,7 @@ Object.getOwnPropertyNames(err).forEach(function(key){if(key!=='message'&&key!==
|
|
|
911
911
|
}}});return newError;}catch(_unused2){return new Error("".concat(issue,": ").concat(stringifyWithoutCircular(err)));}};var dispatchErrorEvent=function dispatchErrorEvent(error){if(isTypeOfError(error)){var errStack=getStacktrace(error);if(errStack){// eslint-disable-next-line no-param-reassign
|
|
912
912
|
error.stack="".concat(errStack,"\n").concat(MANUAL_ERROR_IDENTIFIER);}}globalThis.dispatchEvent(new ErrorEvent('error',{error:error,bubbles:true,cancelable:true,composed:true}));};
|
|
913
913
|
|
|
914
|
-
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.
|
|
914
|
+
var APP_NAME='RudderLabs JavaScript SDK';var APP_VERSION='3.35.1';var APP_NAMESPACE='com.rudderlabs.javascript';var MODULE_TYPE='npm';var BUILD_VARIANT='legacy-content-script';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';
|
|
915
915
|
|
|
916
916
|
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';
|
|
917
917
|
|
|
@@ -1031,7 +1031,7 @@ var SUPPORTED_STORAGE_TYPES=['localStorage','memoryStorage','cookieStorage','ses
|
|
|
1031
1031
|
|
|
1032
1032
|
var SOURCE_CONFIG_RESOLUTION_ERROR="Unable to process/parse source configuration response";var SOURCE_DISABLED_ERROR="The source is disabled. Please enable the source in the dashboard to send events.";var XHR_PAYLOAD_PREP_ERROR="Failed to prepare data for the request.";var PLUGIN_EXT_POINT_MISSING_ERROR="Failed to invoke plugin because the extension point name is missing.";var PLUGIN_EXT_POINT_INVALID_ERROR="Failed to invoke plugin because the extension point name is invalid.";var SOURCE_CONFIG_OPTION_ERROR=function SOURCE_CONFIG_OPTION_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"getSourceConfig\" load API option must be a function that returns valid source configuration data.");};var COMPONENT_BASE_URL_ERROR=function COMPONENT_BASE_URL_ERROR(context,component,url){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The base URL \"").concat(url,"\" for ").concat(component," is not valid.");};// ERROR
|
|
1033
1033
|
var UNSUPPORTED_CONSENT_MANAGER_ERROR=function UNSUPPORTED_CONSENT_MANAGER_ERROR(context,selectedConsentManager,consentManagersToPluginNameMap){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The consent manager \"").concat(selectedConsentManager,"\" is not supported. Please choose one of the following supported consent managers: \"").concat(Object.keys(consentManagersToPluginNameMap),"\".");};var NON_ERROR_WARNING=function NON_ERROR_WARNING(context,errStr){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring a non-error: ").concat(errStr,".");};var BREADCRUMB_ERROR="Failed to log breadcrumb";var HANDLE_ERROR_FAILURE=function HANDLE_ERROR_FAILURE(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to handle the error.");};var PLUGIN_NAME_MISSING_ERROR=function PLUGIN_NAME_MISSING_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin name is missing.");};var PLUGIN_ALREADY_EXISTS_ERROR=function PLUGIN_ALREADY_EXISTS_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" already exists.");};var PLUGIN_NOT_FOUND_ERROR=function PLUGIN_NOT_FOUND_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" not found.");};var PLUGIN_ENGINE_BUG_ERROR=function PLUGIN_ENGINE_BUG_ERROR(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.");};var PLUGIN_DEPS_ERROR=function PLUGIN_DEPS_ERROR(context,pluginName,notExistDeps){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Plugin \"").concat(pluginName,"\" could not be loaded because some of its dependencies \"").concat(notExistDeps,"\" do not exist.");};var PLUGIN_INVOCATION_ERROR=function PLUGIN_INVOCATION_ERROR(context,extPoint,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to invoke the \"").concat(extPoint,"\" extension point of plugin \"").concat(pluginName,"\".");};var SOURCE_CONFIG_FETCH_ERROR='Failed to fetch the source config';var WRITE_KEY_VALIDATION_ERROR=function WRITE_KEY_VALIDATION_ERROR(context,writeKey){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The write key \"").concat(writeKey,"\" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.");};var DATA_PLANE_URL_VALIDATION_ERROR=function DATA_PLANE_URL_VALIDATION_ERROR(context,dataPlaneUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The data plane URL \"").concat(dataPlaneUrl,"\" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.");};var INVALID_CALLBACK_FN_ERROR=function INVALID_CALLBACK_FN_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided callback parameter is not a function.");};var XHR_DELIVERY_ERROR=function XHR_DELIVERY_ERROR(prefix,status,statusText,url,response){return "".concat(prefix," with status ").concat(status," (").concat(statusText,") for URL: ").concat(url,". Response: ").concat(response.trim());};var XHR_REQUEST_ERROR=function XHR_REQUEST_ERROR(prefix,e,url){return "".concat(prefix," due to timeout or no connection (").concat(e?e.type:'',") at the client side for URL: ").concat(url);};var XHR_SEND_ERROR=function XHR_SEND_ERROR(prefix,url){return "".concat(prefix," for URL: ").concat(url);};var STORE_DATA_SAVE_ERROR=function STORE_DATA_SAVE_ERROR(key){return "Failed to save the value for \"".concat(key,"\" to storage");};var STORE_DATA_FETCH_ERROR=function STORE_DATA_FETCH_ERROR(key){return "Failed to retrieve or parse data for \"".concat(key,"\" from storage");};var DATA_SERVER_URL_INVALID_ERROR=function DATA_SERVER_URL_INVALID_ERROR(context,url){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The server side cookies functionality is disabled as the provided data server URL, \"").concat(url,"\" is invalid.");};var DATA_SERVER_REQUEST_FAIL_ERROR=function DATA_SERVER_REQUEST_FAIL_ERROR(status){return "The server responded with status ".concat(status," while setting the cookies. As a fallback, the cookies will be set client side.");};var FAILED_SETTING_COOKIE_FROM_SERVER_ERROR=function FAILED_SETTING_COOKIE_FROM_SERVER_ERROR(key){return "The server failed to set the ".concat(key," cookie. As a fallback, the cookies will be set client side.");};var FAILED_SETTING_COOKIE_FROM_SERVER_GLOBAL_ERROR="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.";var COLLAPSED_COOKIE_BATCH_ERROR=function COLLAPSED_COOKIE_BATCH_ERROR(missingCookies,batchSize){return "The server did not set ".concat(missingCookies.length," of the ").concat(batchSize," cookies sent in one request: ").concat(missingCookies.join(', '),". A fallback to set them client side was attempted. Check that the data service and any proxy preserve every \"Set-Cookie\" header, and that the cookie domain and SameSite/Secure attributes are valid.");};// WARNING
|
|
1034
|
-
var STORAGE_TYPE_VALIDATION_WARNING=function STORAGE_TYPE_VALIDATION_WARNING(context,storageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default storage type will be used instead.");};var UNSUPPORTED_STORAGE_ENTRY_TYPE_WARNING=function UNSUPPORTED_STORAGE_ENTRY_TYPE_WARNING(context,entry,storageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" configured for the entry \"").concat(entry,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default storage type will be used instead.");};var UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=function UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage encryption version \"").concat(selectedStorageEncryptionVersion,"\" is not supported. Please choose one of the following supported versions: \"").concat(Object.keys(storageEncryptionVersionsToPluginNameMap),"\". The default version \"").concat(defaultVersion,"\" will be used instead.");};var STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=function STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(context,storageEncryptionVersion,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage data migration has been disabled because the configured storage encryption version (").concat(storageEncryptionVersion,") is not the latest (").concat(defaultVersion,"). To enable storage data migration, please update the storage encryption version to the latest version.");};var SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_ERROR=function SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_ERROR(context,providedCookieDomain,currentCookieDomain){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided cookie domain (").concat(providedCookieDomain,") does not match the current webpage's domain (").concat(currentCookieDomain,"). Hence, the cookies will be set client-side.");};var SERVER_SIDE_COOKIE_DATA_SERVICE_HOST_ERROR=function SERVER_SIDE_COOKIE_DATA_SERVICE_HOST_ERROR(context,dataServiceHost,webpageHost){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The data service host (").concat(dataServiceHost,") cannot set cookies for the current webpage (").concat(webpageHost,"). Hence, the cookies will be set client-side instead of server-side.");};var RESERVED_KEYWORD_WARNING=function RESERVED_KEYWORD_WARNING(context,property,parentKeyPath,reservedElements){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(property,"\" property defined under \"").concat(parentKeyPath,"\" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (").concat(reservedElements,").");};var RESERVED_CUSTOM_CONTEXT_KEY_WARNING=function RESERVED_CUSTOM_CONTEXT_KEY_WARNING(logContext,property){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"The top-level custom context property \"").concat(property,"\" is reserved and was ignored.");};var INVALID_CONTEXT_OBJECT_WARNING=function INVALID_CONTEXT_OBJECT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Please make sure that the \"context\" property in the event API's \"options\" argument is a valid object literal with key-value pairs.");};var INVALID_CUSTOM_CONTEXT_WARNING=function INVALID_CUSTOM_CONTEXT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Invalid custom context. Use a plain object without prototype pollution keys.");};var UNSUPPORTED_BEACON_API_WARNING=function UNSUPPORTED_BEACON_API_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The Beacon API is not supported by your browser. The events will be sent using XHR instead.");};var TIMEOUT_NOT_NUMBER_WARNING=function TIMEOUT_NOT_NUMBER_WARNING(context,timeout,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value \"").concat(timeout,"\" is not a number. The default timeout of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_NOT_NUMBER_WARNING=function CUT_OFF_DURATION_NOT_NUMBER_WARNING(context,cutOffDuration,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" is not a number. The default cut off duration of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=function CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING(context,cutOffDuration,timeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" ms is less than the session timeout value \"").concat(timeout,"\" ms. The cut off functionality will be disabled.");};var TIMEOUT_ZERO_WARNING=function TIMEOUT_ZERO_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.");};var TIMEOUT_NOT_RECOMMENDED_WARNING=function TIMEOUT_NOT_RECOMMENDED_WARNING(context,timeout,minTimeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value ").concat(timeout," ms is less than the recommended minimum of ").concat(minTimeout," ms. Please consider increasing the timeout value to ensure optimal performance and reliability.");};var INVALID_SESSION_ID_WARNING=function INVALID_SESSION_ID_WARNING(context,sessionId,minSessionIdLength){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided session ID (").concat(sessionId,") is either invalid, not a positive integer, or not at least \"").concat(minSessionIdLength,"\" digits long. A new session ID will be auto-generated instead.");};var STORAGE_QUOTA_EXCEEDED_WARNING=function STORAGE_QUOTA_EXCEEDED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.");};var STORAGE_UNAVAILABLE_WARNING=function STORAGE_UNAVAILABLE_WARNING(context,entry,selectedStorageType,finalStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(selectedStorageType,"\" is not available for entry \"").concat(entry,"\". The SDK will initialize the entry with \"").concat(finalStorageType,"\" storage type instead.");};var CALLBACK_INVOKE_ERROR=function CALLBACK_INVOKE_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The callback threw an exception");};var INVALID_CONFIG_URL_WARNING=function INVALID_CONFIG_URL_WARNING(context,configUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided source config URL \"").concat(configUrl,"\" is invalid. Using the default source config URL instead.");};var POLYFILL_SCRIPT_LOAD_ERROR=function POLYFILL_SCRIPT_LOAD_ERROR(scriptId,url){return "Failed to load the polyfill script with ID \"".concat(scriptId,"\" from URL ").concat(url,".");};var UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=function UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY(context,selectedStrategy,defaultStrategy){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy \"").concat(selectedStrategy,"\" is not supported. Please choose one of the following supported strategies: \"none, session, anonymousId\". The default strategy \"").concat(defaultStrategy,"\" will be used instead.");};var DEPRECATED_PRE_CONSENT_STORAGE_STRATEGY=function DEPRECATED_PRE_CONSENT_STORAGE_STRATEGY(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy option is deprecated. Please enable \"storage\" in the pre-consent options and use the \"storage\" load API option instead.");};var UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=function UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE(context,selectedDeliveryType,defaultDeliveryType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent events delivery type \"").concat(selectedDeliveryType,"\" is not supported. Please choose one of the following supported types: \"immediate, buffer\". The default type \"").concat(defaultDeliveryType,"\" will be used instead.");};var DEPRECATED_PLUGIN_WARNING=function DEPRECATED_PLUGIN_WARNING(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(pluginName," plugin is deprecated. Please exclude it from the load API options.");};var generateMisconfiguredPluginsWarning=function generateMisconfiguredPluginsWarning(context,configurationStatus,missingPlugins,shouldAddMissingPlugins){var isSinglePlugin=missingPlugins.length===1;var pluginsString=isSinglePlugin?" '".concat(missingPlugins[0],"' plugin was"):" ['".concat(missingPlugins.join("', '"),"'] plugins were");var baseWarning="".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(configurationStatus,", but").concat(pluginsString," not configured to load.");if(shouldAddMissingPlugins){return "".concat(baseWarning," So, ").concat(isSinglePlugin?'the plugin':'those plugins'," will be loaded automatically.");}return "".concat(baseWarning," Ignore if this was intentional. Otherwise, consider adding ").concat(isSinglePlugin?'it':'them'," to the 'plugins' load API option.");};var INVALID_POLYFILL_URL_WARNING=function INVALID_POLYFILL_URL_WARNING(context,customPolyfillUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided polyfill URL \"").concat(customPolyfillUrl,"\" is invalid. The default polyfill URL will be used instead.");};var PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=function PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Page Unloaded event can only be tracked when the Beacon transport is active. Please enable \"useBeacon\" load API option.");};var UNKNOWN_PLUGINS_WARNING=function UNKNOWN_PLUGINS_WARNING(context,unknownPlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring unknown plugins: ").concat(unknownPlugins.join(', '),".");};var REMOTE_PLUGIN_LOAD_ERROR=function REMOTE_PLUGIN_LOAD_ERROR(context,pluginName,reason){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to load plugin \"").concat(pluginName,"\" - ").concat(reason);};var UNAVAILABLE_PLUGINS_ERROR=function UNAVAILABLE_PLUGINS_ERROR(context,unavailablePlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to load the following unavailable local plugins: ").concat(unavailablePlugins.join(', '),". Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.");};var CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR=function CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR(context,destinationId){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Cannot add custom integration for destination ID \"").concat(destinationId,"\" after the SDK is loaded.");};
|
|
1034
|
+
var STORAGE_TYPE_VALIDATION_WARNING=function STORAGE_TYPE_VALIDATION_WARNING(context,storageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default storage type will be used instead.");};var UNSUPPORTED_STORAGE_ENTRY_TYPE_WARNING=function UNSUPPORTED_STORAGE_ENTRY_TYPE_WARNING(context,entry,storageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(storageType,"\" configured for the entry \"").concat(entry,"\" is not supported. Please choose one of the following supported types: \"").concat(SUPPORTED_STORAGE_TYPES,"\". The default storage type will be used instead.");};var UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=function UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage encryption version \"").concat(selectedStorageEncryptionVersion,"\" is not supported. Please choose one of the following supported versions: \"").concat(Object.keys(storageEncryptionVersionsToPluginNameMap),"\". The default version \"").concat(defaultVersion,"\" will be used instead.");};var STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=function STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(context,storageEncryptionVersion,defaultVersion){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage data migration has been disabled because the configured storage encryption version (").concat(storageEncryptionVersion,") is not the latest (").concat(defaultVersion,"). To enable storage data migration, please update the storage encryption version to the latest version.");};var SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_ERROR=function SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_ERROR(context,providedCookieDomain,currentCookieDomain){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided cookie domain (").concat(providedCookieDomain,") does not match the current webpage's domain (").concat(currentCookieDomain,"). Hence, the cookies will be set client-side.");};var SERVER_SIDE_COOKIE_DATA_SERVICE_HOST_ERROR=function SERVER_SIDE_COOKIE_DATA_SERVICE_HOST_ERROR(context,dataServiceHost,webpageHost){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The data service host (").concat(dataServiceHost,") cannot set cookies for the current webpage (").concat(webpageHost,"). Hence, the cookies will be set client-side instead of server-side.");};var RESERVED_KEYWORD_WARNING=function RESERVED_KEYWORD_WARNING(context,property,parentKeyPath,reservedElements){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The \"").concat(property,"\" property defined under \"").concat(parentKeyPath,"\" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (").concat(reservedElements,").");};var RESERVED_CUSTOM_CONTEXT_KEY_WARNING=function RESERVED_CUSTOM_CONTEXT_KEY_WARNING(logContext,property){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"The top-level custom context property \"").concat(property,"\" is reserved and was ignored.");};var INVALID_CONTEXT_OBJECT_WARNING=function INVALID_CONTEXT_OBJECT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Please make sure that the \"context\" property in the event API's \"options\" argument is a valid object literal with key-value pairs.");};var INVALID_CUSTOM_CONTEXT_WARNING=function INVALID_CUSTOM_CONTEXT_WARNING(logContext){return "".concat(logContext).concat(LOG_CONTEXT_SEPARATOR,"Invalid custom context. Use a plain object without prototype pollution keys.");};var UNSUPPORTED_BEACON_API_WARNING=function UNSUPPORTED_BEACON_API_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The Beacon API is not supported by your browser. The events will be sent using XHR instead.");};var TIMEOUT_NOT_NUMBER_WARNING=function TIMEOUT_NOT_NUMBER_WARNING(context,timeout,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value \"").concat(timeout,"\" is not a number. The default timeout of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_NOT_NUMBER_WARNING=function CUT_OFF_DURATION_NOT_NUMBER_WARNING(context,cutOffDuration,defaultValue){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" is not a number. The default cut off duration of ").concat(defaultValue," ms will be used instead.");};var CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=function CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING(context,cutOffDuration,timeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session cut off duration value \"").concat(cutOffDuration,"\" ms is less than the session timeout value \"").concat(timeout,"\" ms. The cut off functionality will be disabled.");};var TIMEOUT_ZERO_WARNING=function TIMEOUT_ZERO_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.");};var TIMEOUT_NOT_RECOMMENDED_WARNING=function TIMEOUT_NOT_RECOMMENDED_WARNING(context,timeout,minTimeout){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The session timeout value ").concat(timeout," ms is less than the recommended minimum of ").concat(minTimeout," ms. Please consider increasing the timeout value to ensure optimal performance and reliability.");};var INVALID_SESSION_ID_WARNING=function INVALID_SESSION_ID_WARNING(context,sessionId,minSessionIdLength){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided session ID (").concat(sessionId,") is either invalid, not a positive integer, or not at least \"").concat(minSessionIdLength,"\" digits long. A new session ID will be auto-generated instead.");};var STORAGE_QUOTA_EXCEEDED_WARNING=function STORAGE_QUOTA_EXCEEDED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.");};var STORAGE_UNAVAILABLE_WARNING=function STORAGE_UNAVAILABLE_WARNING(context,entry,selectedStorageType,finalStorageType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The storage type \"").concat(selectedStorageType,"\" is not available for entry \"").concat(entry,"\". The SDK will initialize the entry with \"").concat(finalStorageType,"\" storage type instead.");};var CALLBACK_INVOKE_ERROR=function CALLBACK_INVOKE_ERROR(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The callback threw an exception");};var INVALID_CONFIG_URL_WARNING=function INVALID_CONFIG_URL_WARNING(context,configUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided source config URL \"").concat(configUrl,"\" is invalid. Using the default source config URL instead.");};var POLYFILL_SCRIPT_LOAD_ERROR=function POLYFILL_SCRIPT_LOAD_ERROR(scriptId,url){return "Failed to load the polyfill script with ID \"".concat(scriptId,"\" from URL ").concat(url,".");};var POLYFILL_VERIFICATION_ERROR=function POLYFILL_VERIFICATION_ERROR(missingFeatures){return "Failed to apply the polyfills for the following features: ".concat(missingFeatures.join(', '),".");};var UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=function UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY(context,selectedStrategy,defaultStrategy){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy \"").concat(selectedStrategy,"\" is not supported. Please choose one of the following supported strategies: \"none, session, anonymousId\". The default strategy \"").concat(defaultStrategy,"\" will be used instead.");};var DEPRECATED_PRE_CONSENT_STORAGE_STRATEGY=function DEPRECATED_PRE_CONSENT_STORAGE_STRATEGY(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent storage strategy option is deprecated. Please enable \"storage\" in the pre-consent options and use the \"storage\" load API option instead.");};var UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=function UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE(context,selectedDeliveryType,defaultDeliveryType){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The pre-consent events delivery type \"").concat(selectedDeliveryType,"\" is not supported. Please choose one of the following supported types: \"immediate, buffer\". The default type \"").concat(defaultDeliveryType,"\" will be used instead.");};var DEPRECATED_PLUGIN_WARNING=function DEPRECATED_PLUGIN_WARNING(context,pluginName){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(pluginName," plugin is deprecated. Please exclude it from the load API options.");};var generateMisconfiguredPluginsWarning=function generateMisconfiguredPluginsWarning(context,configurationStatus,missingPlugins,shouldAddMissingPlugins){var isSinglePlugin=missingPlugins.length===1;var pluginsString=isSinglePlugin?" '".concat(missingPlugins[0],"' plugin was"):" ['".concat(missingPlugins.join("', '"),"'] plugins were");var baseWarning="".concat(context).concat(LOG_CONTEXT_SEPARATOR).concat(configurationStatus,", but").concat(pluginsString," not configured to load.");if(shouldAddMissingPlugins){return "".concat(baseWarning," So, ").concat(isSinglePlugin?'the plugin':'those plugins'," will be loaded automatically.");}return "".concat(baseWarning," Ignore if this was intentional. Otherwise, consider adding ").concat(isSinglePlugin?'it':'them'," to the 'plugins' load API option.");};var INVALID_POLYFILL_URL_WARNING=function INVALID_POLYFILL_URL_WARNING(context,customPolyfillUrl){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"The provided polyfill URL \"").concat(customPolyfillUrl,"\" is invalid. The default polyfill URL will be used instead.");};var PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=function PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING(context){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Page Unloaded event can only be tracked when the Beacon transport is active. Please enable \"useBeacon\" load API option.");};var UNKNOWN_PLUGINS_WARNING=function UNKNOWN_PLUGINS_WARNING(context,unknownPlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Ignoring unknown plugins: ").concat(unknownPlugins.join(', '),".");};var REMOTE_PLUGIN_LOAD_ERROR=function REMOTE_PLUGIN_LOAD_ERROR(context,pluginName,reason){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to load plugin \"").concat(pluginName,"\" - ").concat(reason);};var NO_PLUGIN_FACTORY_EXPORTED_REASON='the module exported no plugin factory';var UNAVAILABLE_PLUGINS_ERROR=function UNAVAILABLE_PLUGINS_ERROR(context,unavailablePlugins){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to load the following unavailable local plugins: ").concat(unavailablePlugins.join(', '),". Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.");};var CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR=function CUSTOM_INTEGRATION_CANNOT_BE_ADDED_ERROR(context,destinationId){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Cannot add custom integration for destination ID \"").concat(destinationId,"\" after the SDK is loaded.");};
|
|
1035
1035
|
|
|
1036
1036
|
var DEFAULT_INTEGRATIONS_CONFIG={All:true};
|
|
1037
1037
|
|
|
@@ -1046,7 +1046,9 @@ var CDN_INT_DIR='js-integrations';var CDN_PLUGINS_DIR='plugins';var URL_PATTERN=
|
|
|
1046
1046
|
'(\\#[-a-zA-Z\\d_]*)?$')// fragment locator
|
|
1047
1047
|
;
|
|
1048
1048
|
|
|
1049
|
-
var BUILD_TYPE='legacy';var SDK_CDN_BASE_URL='https://cdn.rudderlabs.com';var CDN_ARCH_VERSION_DIR='v3';var DEFAULT_INTEGRATION_SDKS_URL="".concat(SDK_CDN_BASE_URL,"/").concat(CDN_ARCH_VERSION_DIR,"/").concat(BUILD_TYPE,"/").concat(CDN_INT_DIR);var DEFAULT_PLUGINS_URL="".concat(SDK_CDN_BASE_URL,"/").concat(CDN_ARCH_VERSION_DIR,"/").concat(BUILD_TYPE,"/").concat(CDN_PLUGINS_DIR);var DEFAULT_CONFIG_BE_URL='https://api.rudderstack.com'
|
|
1049
|
+
var BUILD_TYPE='legacy';var SDK_CDN_BASE_URL='https://cdn.rudderlabs.com';var CDN_ARCH_VERSION_DIR='v3';var DEFAULT_INTEGRATION_SDKS_URL="".concat(SDK_CDN_BASE_URL,"/").concat(CDN_ARCH_VERSION_DIR,"/").concat(BUILD_TYPE,"/").concat(CDN_INT_DIR);var DEFAULT_PLUGINS_URL="".concat(SDK_CDN_BASE_URL,"/").concat(CDN_ARCH_VERSION_DIR,"/").concat(BUILD_TYPE,"/").concat(CDN_PLUGINS_DIR);var DEFAULT_CONFIG_BE_URL='https://api.rudderstack.com';// Mirrors remotePluginsExportsFilename in rollup.config.mjs, which builds the URL
|
|
1050
|
+
// the generated federation code requests at runtime.
|
|
1051
|
+
var REMOTE_PLUGINS_ENTRY_FILE='rsa-plugins.js';
|
|
1050
1052
|
|
|
1051
1053
|
var DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';var DEFAULT_DATA_PLANE_EVENTS_TRANSPORT='xhr';var ConsentManagersToPluginNameMap={iubenda:'IubendaConsentManager',oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};var StorageEncryptionVersionsToPluginNameMap=_defineProperty(_defineProperty({},DEFAULT_STORAGE_ENCRYPTION_VERSION,'StorageEncryption'),"legacy",'StorageEncryptionLegacy');var DataPlaneEventsTransportToPluginNameMap=_defineProperty(_defineProperty({},DEFAULT_DATA_PLANE_EVENTS_TRANSPORT,'XhrQueue'),"beacon",'BeaconQueue');var DEFAULT_DATA_SERVICE_ENDPOINT='rsaRequest';var METRICS_SERVICE_ENDPOINT='rsaMetrics';var CUSTOM_DEVICE_MODE_DESTINATION_DISPLAY_NAME='Custom Device Mode';
|
|
1052
1054
|
|
|
@@ -1091,7 +1093,9 @@ var autoTrackState={enabled:y(false),pageLifecycle:{enabled:y(false),pageViewId:
|
|
|
1091
1093
|
|
|
1092
1094
|
var defaultStateValues={capabilities:capabilitiesState,consents:consentsState,context:contextState,customContext:customContextState,eventBuffer:eventBufferState,lifecycle:lifecycleState,loadOptions:loadOptionsState,metrics:metricsState,nativeDestinations:nativeDestinationsState,plugins:pluginsState,reporting:reportingState,session:sessionState,source:sourceConfigState,storage:storageState,serverCookies:serverSideCookiesState,dataPlaneEvents:dataPlaneEventsState,autoTrack:autoTrackState};var state=_objectSpread2({},clone(defaultStateValues));
|
|
1093
1095
|
|
|
1094
|
-
var CHROME_STACK_LINE_RE=/^\s*at /;var SAFARI_NATIVE_RE=/^(eval@)?(\[native code])?$/;var
|
|
1096
|
+
var CHROME_STACK_LINE_RE=/^\s*at /;var SAFARI_NATIVE_RE=/^(eval@)?(\[native code])?$/;var DIGITS_RE=/^\d+$/;function extractLocation(urlLike){if(!(urlLike!==null&&urlLike!==void 0&&urlLike.includes(':'))){return [urlLike||undefined,undefined,undefined];}var normalizedUrlLike=urlLike.startsWith('(')&&urlLike.endsWith(')')?urlLike.slice(1,-1):urlLike;// Take up to two trailing all-digit segments as line and column; whatever is left,
|
|
1097
|
+
// colons included, is the file. A url keeps its scheme because "//host" is not digits.
|
|
1098
|
+
var segments=normalizedUrlLike.split(':');var location=[];while(segments.length>1&&location.length<2&&DIGITS_RE.test(segments[segments.length-1])){location.unshift(Number(segments.pop()));}return [segments.join(':')||undefined,location[0],location[1]];}function parseV8Line(line){if(!CHROME_STACK_LINE_RE.test(line)){return null;}if(line.includes('(eval ')){line=line.replace(/eval code/g,'eval').replace(/\(eval at [^()]*/g,'').replace(/,.*/,'');}var sanitized=line.replace(/^\s+/,'').replace(/\(eval code/g,'(').replace(/^.*?\s+/,'');var parenLoc=/ (\(.+\)$)/.exec(sanitized);var withoutLoc=parenLoc?sanitized.replace(parenLoc[0],''):sanitized;var _extractLocation=extractLocation(parenLoc?parenLoc[1]:sanitized),_extractLocation2=_slicedToArray(_extractLocation,3),rawFile=_extractLocation2[0],lineNumber=_extractLocation2[1],columnNumber=_extractLocation2[2];var functionName=parenLoc&&withoutLoc||undefined;var fileName=rawFile==='eval'||rawFile==='<anonymous>'?undefined:rawFile;return {functionName:functionName,fileName:fileName,lineNumber:lineNumber,columnNumber:columnNumber};}function parseFFSafariLine(line){if(SAFARI_NATIVE_RE.test(line)){return null;}if(line.includes(' > eval')){line=line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,':$1');}if(!line.includes('@')&&!line.includes(':')){return {functionName:line,fileName:undefined,lineNumber:undefined,columnNumber:undefined};}var atIndex=line.lastIndexOf('@');var functionName=atIndex>0?line.slice(0,atIndex):undefined;var _extractLocation3=extractLocation(line.slice(atIndex+1)),_extractLocation4=_slicedToArray(_extractLocation3,3),fileName=_extractLocation4[0],lineNumber=_extractLocation4[1],columnNumber=_extractLocation4[2];return {functionName:functionName,fileName:fileName,lineNumber:lineNumber,columnNumber:columnNumber};}/**
|
|
1095
1099
|
* Parses an Error object's stack trace into structured frames.
|
|
1096
1100
|
* Supports V8/Chromium (Chrome, Edge, Node) and SpiderMonkey/WebKit (Firefox, Safari) formats.
|
|
1097
1101
|
* Throws if the error has no stack property.
|
|
@@ -1215,7 +1219,9 @@ resolve(true);}}else {resolve(!ERROR_MESSAGES_TO_BE_FILTERED.some(function(e){re
|
|
|
1215
1219
|
* A function to get the directory name from a file path.
|
|
1216
1220
|
* @param {string} filePath The file path
|
|
1217
1221
|
* @returns The directory name or undefined if the file path is invalid
|
|
1218
|
-
*/var getDirectoryName=function getDirectoryName(filePath){if(!filePath){return undefined;}var paths=filePath.split('/')
|
|
1222
|
+
*/var getDirectoryName=function getDirectoryName(filePath){if(!filePath){return undefined;}var paths=filePath.split('/');// Not `.at(-2)`: Array.prototype.at is neither transpiled nor polyfilled
|
|
1223
|
+
return paths[paths.length-2];// NOSONAR
|
|
1224
|
+
};/**
|
|
1219
1225
|
* A function to get the top stack path from the exception.
|
|
1220
1226
|
* @param {Exception} exception The exception object
|
|
1221
1227
|
* @returns The top stack path or undefined if the exception is invalid
|
|
@@ -1305,7 +1311,8 @@ destination.config.useNativeSDK===true);};var isHybridModeDestination=function i
|
|
|
1305
1311
|
* @param id The id of the destination
|
|
1306
1312
|
*
|
|
1307
1313
|
* @returns the user friendly id
|
|
1308
|
-
*/var getDestinationUserFriendlyId=function getDestinationUserFriendlyId(displayName,id){return
|
|
1314
|
+
*/var getDestinationUserFriendlyId=function getDestinationUserFriendlyId(displayName,id){return(// displayName comes from the source config response, so it is not guaranteed to be a string
|
|
1315
|
+
"".concat(String(displayName!==null&&displayName!==void 0?displayName:'').replace(/ /g,'-'),"___").concat(id));};
|
|
1309
1316
|
|
|
1310
1317
|
/**
|
|
1311
1318
|
* List of plugin names that are loaded as dynamic imports in modern builds
|
|
@@ -1418,13 +1425,15 @@ var runningQueueIdsByName=new Map();var RetryQueue=/*#__PURE__*/function(){/**
|
|
|
1418
1425
|
* Constructs a RetryQueue backed by localStorage
|
|
1419
1426
|
*
|
|
1420
1427
|
* @param {String} name The name of the queue. Will be used to find abandoned queues and retry their items
|
|
1421
|
-
* @param {QueueOpts} [options] Optional argument to override `maxItems`, `maxAttempts`, `minRetryDelay
|
|
1428
|
+
* @param {QueueOpts} [options] Optional argument to override `maxItems`, `maxAttempts`, `minRetryDelay`, `maxRetryDelay`, `backoffFactor` and `backoffJitter`.
|
|
1422
1429
|
* @param {QueueProcessCallback} queueProcessCb The function to call in order to process an item added to the queue
|
|
1423
1430
|
* @param {IStoreManager} storeManager The store manager instance to use
|
|
1424
1431
|
* @param {StorageType} [storageType] The storage type to use. Defaults to LOCAL_STORAGE
|
|
1425
1432
|
* @param {ILogger} [logger] The logger to use
|
|
1426
1433
|
* @param {QueueBatchItemsSizeCalculatorCallback} [queueBatchItemsSizeCalculatorCb] The callback to use to calculate the size of items in the batch queue
|
|
1427
|
-
*/function RetryQueue(name,options,queueProcessCb,storeManager){var _options$timerScaleFa;var storageType=arguments.length>4&&arguments[4]!==undefined?arguments[4]:LOCAL_STORAGE;var logger=arguments.length>5?arguments[5]:undefined;var queueBatchItemsSizeCalculatorCb=arguments.length>6?arguments[6]:undefined;_classCallCheck(this,RetryQueue);this.storeManager=storeManager;this.logger=logger;this.name=name;this.id=generateUUID();this.processQueueCb=queueProcessCb;this.batchSizeCalcCb=queueBatchItemsSizeCalculatorCb;this.maxItems=options.maxItems||DEFAULT_MAX_ITEMS;this.maxAttempts=options.maxAttempts
|
|
1434
|
+
*/function RetryQueue(name,options,queueProcessCb,storeManager){var _options$maxAttempts,_options$backoffJitte,_options$timerScaleFa;var storageType=arguments.length>4&&arguments[4]!==undefined?arguments[4]:LOCAL_STORAGE;var logger=arguments.length>5?arguments[5]:undefined;var queueBatchItemsSizeCalculatorCb=arguments.length>6?arguments[6]:undefined;_classCallCheck(this,RetryQueue);this.storeManager=storeManager;this.logger=logger;this.name=name;this.id=generateUUID();this.processQueueCb=queueProcessCb;this.batchSizeCalcCb=queueBatchItemsSizeCalculatorCb;this.maxItems=options.maxItems||DEFAULT_MAX_ITEMS;this.maxAttempts=(_options$maxAttempts=options.maxAttempts)!==null&&_options$maxAttempts!==void 0?_options$maxAttempts:DEFAULT_MAX_RETRY_ATTEMPTS;this.batch={enabled:false};this.configureBatchMode(options);// `??` keeps an explicit 0 but also keeps NaN, which would make every delay NaN
|
|
1435
|
+
var jitter=(_options$backoffJitte=options.backoffJitter)!==null&&_options$backoffJitte!==void 0?_options$backoffJitte:DEFAULT_BACKOFF_JITTER;this.backoff={minRetryDelay:options.minRetryDelay||DEFAULT_MIN_RETRY_DELAY_MS,maxRetryDelay:options.maxRetryDelay||DEFAULT_MAX_RETRY_DELAY_MS,factor:options.backoffFactor||DEFAULT_BACKOFF_FACTOR,// Clamp so delays stay positive and within maxRetryDelay
|
|
1436
|
+
jitter:Number.isNaN(jitter)?DEFAULT_BACKOFF_JITTER:Math.min(Math.max(jitter,0),1)};// Limit the timer scale factor to the minimum value
|
|
1428
1437
|
var timerScaleFactor=Math.max((_options$timerScaleFa=options.timerScaleFactor)!==null&&_options$timerScaleFa!==void 0?_options$timerScaleFa:MIN_TIMER_SCALE_FACTOR,MIN_TIMER_SCALE_FACTOR);// Limit the timer scale factor to the maximum value
|
|
1429
1438
|
timerScaleFactor=Math.min(timerScaleFactor,MAX_TIMER_SCALE_FACTOR);// painstakingly tuned. that's why they're not "easily" configurable
|
|
1430
1439
|
this.timeouts={ackTimer:Math.round(timerScaleFactor*DEFAULT_ACK_TIMER_MS),reclaimTimer:Math.round(timerScaleFactor*DEFAULT_RECLAIM_TIMER_MS),reclaimTimeout:Math.round(timerScaleFactor*DEFAULT_RECLAIM_TIMEOUT_MS),reclaimWait:Math.round(timerScaleFactor*DEFAULT_RECLAIM_WAIT_MS)};this.schedule=new Schedule();this.processId='0';// Set up our empty queues
|
|
@@ -1452,7 +1461,9 @@ this.scheduleFlushBatch();}}/**
|
|
|
1452
1461
|
*
|
|
1453
1462
|
* @param {Number} attemptNumber The attemptNumber (1 for first retry)
|
|
1454
1463
|
* @return {Number} The delay in milliseconds to wait before attempting a retry
|
|
1455
|
-
*/},{key:"getDelay",value:function getDelay(attemptNumber){
|
|
1464
|
+
*/},{key:"getDelay",value:function getDelay(attemptNumber){// Cap leaves headroom for +jitter so the jittered delay never exceeds maxRetryDelay
|
|
1465
|
+
var cap=Math.floor(this.backoff.maxRetryDelay/(1+this.backoff.jitter));var ms=Math.min(// First retry waits the base delay
|
|
1466
|
+
Number((this.backoff.minRetryDelay*Math.pow(this.backoff.factor,attemptNumber-1)).toPrecision(1)),cap);if(this.backoff.jitter){var rand=Math.random();var deviation=Math.floor(rand*this.backoff.jitter*ms);if(Math.floor(rand*10)<5){ms-=deviation;}else {ms+=deviation;}}return Math.min(ms,this.backoff.maxRetryDelay);}},{key:"enqueue",value:function enqueue(entry){var curEntry;if(this.batch.enabled&&entry.type===SINGLE_QUEUE_ITEM_TYPE){curEntry=this.handleNewItemForBatch(entry);}else {curEntry=entry;}// when batching is enabled, `curEntry` could be `undefined` if the batch criteria is not met
|
|
1456
1467
|
if(curEntry){this.pushToMainQueue(curEntry);}}/**
|
|
1457
1468
|
* Handles a new item added to the retry queue when batching is enabled
|
|
1458
1469
|
* @param entry New item added to the retry queue
|
|
@@ -1535,8 +1546,8 @@ done(null);}else {// Note: We're not removing the item from the queue as we want
|
|
|
1535
1546
|
logger===null||logger===void 0||logger.warn("".concat(BEACON_QUEUE_SEND_ERROR(BEACON_QUEUE_PLUGIN,url)," The event(s) will be retried as the current page is being unloaded."));}}else {// Remove the item from queue as the request was successful
|
|
1536
1547
|
done(null);}}catch(err){errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:BEACON_QUEUE_PLUGIN,customMessage:BEACON_QUEUE_DELIVERY_ERROR(url)});// Remove the item from queue
|
|
1537
1548
|
done(null);}};var eventsQueue=new RetryQueue("".concat(QUEUE_NAME$3,"_").concat(writeKey),{batch:{enabled:true,flushInterval:finalQOpts.flushQueueInterval,maxSize:MAX_BATCH_PAYLOAD_SIZE_BYTES,// set the hard limit
|
|
1538
|
-
maxItems:finalQOpts.maxItems}},queueProcessCallback,storeManager,getStorageTypeForEventsPersistence(logger),logger,function(itemData){var currentTime=getCurrentTimeFormatted();var events=itemData.map(function(queueItemData){return queueItemData.event;});// type casting to Blob as we know that the event has already been validated prior to enqueue
|
|
1539
|
-
return getBatchDeliveryPayload$1(events,currentTime,logger).size;});return eventsQueue;},/**
|
|
1549
|
+
maxItems:finalQOpts.maxItems}},queueProcessCallback,storeManager,getStorageTypeForEventsPersistence(logger),logger,function(itemData){var _getBatchDeliveryPayl;var currentTime=getCurrentTimeFormatted();var events=itemData.map(function(queueItemData){return queueItemData.event;});// type casting to Blob as we know that the event has already been validated prior to enqueue
|
|
1550
|
+
return (_getBatchDeliveryPayl=getBatchDeliveryPayload$1(events,currentTime,logger))===null||_getBatchDeliveryPayl===void 0?void 0:_getBatchDeliveryPayl.size;});return eventsQueue;},/**
|
|
1540
1551
|
* Add event to the queue for delivery
|
|
1541
1552
|
* @param state Application state
|
|
1542
1553
|
* @param eventsQueue IQueue instance
|
|
@@ -3145,7 +3156,8 @@ decryptedVal=decryptBrowser(decryptedVal);// If the decrypted value is the same
|
|
|
3145
3156
|
if(decryptedVal===currentVal){break;}// storejs that is used in localstorage engine already deserializes json strings but swallows errors
|
|
3146
3157
|
currentVal=JSON.parse(decryptedVal);}return currentVal;}catch(err){var customMessage=STORAGE_MIGRATION_ERROR(key);errorHandler===null||errorHandler===void 0||errorHandler.onError({error:err,context:STORAGE_MIGRATOR_PLUGIN,customMessage:customMessage,groupingHash:customMessage});return null;}}}};};
|
|
3147
3158
|
|
|
3148
|
-
var DEFAULT_RETRY_QUEUE_OPTIONS={maxRetryDelay:
|
|
3159
|
+
var DEFAULT_RETRY_QUEUE_OPTIONS={maxRetryDelay:540000,minRetryDelay:1000,backoffFactor:2,backoffJitter:0.2,maxAttempts:30,// ~3h of retries at these delays
|
|
3160
|
+
maxItems:100};var REQUEST_TIMEOUT_MS=30*1000;// 30 seconds
|
|
3149
3161
|
var DATA_PLANE_API_VERSION='v1';var QUEUE_NAME='rudder';var XHR_QUEUE_PLUGIN='XhrQueuePlugin';
|
|
3150
3162
|
|
|
3151
3163
|
var EVENT_DELIVERY_FAILURE_ERROR_PREFIX=function EVENT_DELIVERY_FAILURE_ERROR_PREFIX(context,originalErrorMsg){return "".concat(context).concat(LOG_CONTEXT_SEPARATOR,"Failed to deliver event(s). Cause: ").concat(originalErrorMsg,".");};
|
|
@@ -3227,15 +3239,16 @@ var availablePlugins=[].concat(_toConsumableArray(Object.keys(pluginsInventory))
|
|
|
3227
3239
|
* Register plugins that are direct imports to PluginEngine
|
|
3228
3240
|
*/},{key:"registerLocalPlugins",value:function registerLocalPlugins(){var _this2=this;var unavailablePlugins=[];Object.entries(pluginsInventory).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),pluginName=_ref2[0],localPlugin=_ref2[1];if(state.plugins.activePlugins.value.includes(pluginName)){if(isFunction(localPlugin)){_this2.register([localPlugin()]);}else {unavailablePlugins.push(pluginName);}}});if(unavailablePlugins.length>0){state.plugins.failedPlugins.value=[].concat(_toConsumableArray(state.plugins.failedPlugins.value),unavailablePlugins);this.logger.error(UNAVAILABLE_PLUGINS_ERROR(PLUGINS_MANAGER,unavailablePlugins));}}/**
|
|
3229
3241
|
* Register plugins that are dynamic imports to PluginEngine
|
|
3230
|
-
*/},{key:"registerRemotePlugins",value:function registerRemotePlugins(){var _this3=this;var remotePluginsList=remotePluginsInventory(state.plugins.activePlugins.value);var loadFailures=[];// Kept separate from state.plugins.failedPlugins, which also collects
|
|
3242
|
+
*/},{key:"registerRemotePlugins",value:function registerRemotePlugins(){var _this3=this;var remotePluginsList=remotePluginsInventory(state.plugins.activePlugins.value);var pluginsCDNPath=state.lifecycle.pluginsCDNPath.value;var remoteEntryUrl="".concat(pluginsCDNPath,"/").concat(REMOTE_PLUGINS_ENTRY_FILE);var loadFailures=[];// Kept separate from state.plugins.failedPlugins, which also collects
|
|
3231
3243
|
// unknown plugins from setActivePlugins, unavailable local plugins from
|
|
3232
3244
|
// registerLocalPlugins and registration failures from register(). Reporting
|
|
3233
3245
|
// the global list would attribute those to this remote load incident.
|
|
3234
|
-
var failedRemotePlugins=[];return Promise.all(Object.keys(remotePluginsList).map(/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(remotePluginKey){return _regenerator().w(function(_context){while(1)switch(_context.n){case 0:_context.n=1;return remotePluginsList[remotePluginKey]().then(function(remotePluginModule){
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3246
|
+
var failedRemotePlugins=[];return Promise.all(Object.keys(remotePluginsList).map(/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(remotePluginKey){return _regenerator().w(function(_context){while(1)switch(_context.n){case 0:_context.n=1;return remotePluginsList[remotePluginKey]().then(function(remotePluginModule){// An intercepted chunk can parse yet export nothing; calling the
|
|
3247
|
+
// undefined factory blind reports a per-build minified name.
|
|
3248
|
+
var pluginFactory=remotePluginModule===null||remotePluginModule===void 0?void 0:remotePluginModule.default;if(!isFunction(pluginFactory)){throw new Error(NO_PLUGIN_FACTORY_EXPORTED_REASON);}_this3.register([pluginFactory()]);}).catch(function(err){var _message;// TODO: add retry here if dynamic import fails
|
|
3249
|
+
failedRemotePlugins.push(remotePluginKey);state.plugins.failedPlugins.value=[].concat(_toConsumableArray(state.plugins.failedPlugins.value),[remotePluginKey]);// A rejection is not guaranteed to be an Error, so without the
|
|
3250
|
+
// fallback the log reads "- undefined".
|
|
3251
|
+
var reason=(_message=err===null||err===void 0?void 0:err.message)!==null&&_message!==void 0?_message:String(err);_this3.logger.error(REMOTE_PLUGIN_LOAD_ERROR(PLUGINS_MANAGER,remotePluginKey,reason));loadFailures.push(err);});case 1:return _context.a(2);}},_callee);}));return function(_x){return _ref3.apply(this,arguments);};}())).then(function(){// A failed remote entry rejects every plugin import at once, so the
|
|
3239
3252
|
// fan-out is one incident and gets one report, raised only after every
|
|
3240
3253
|
// import has settled so it names all of them.
|
|
3241
3254
|
//
|
|
@@ -3243,7 +3256,9 @@ failedRemotePlugins.push(remotePluginKey);state.plugins.failedPlugins.value=[].c
|
|
|
3243
3256
|
// deliberate: a dynamic import has no timeout of its own, and holding a
|
|
3244
3257
|
// timer open to salvage a partial report would spend page resources on
|
|
3245
3258
|
// error reporting, which is the lowest priority thing the SDK does.
|
|
3246
|
-
if(failedRemotePlugins.length===0){return;}
|
|
3259
|
+
if(failedRemotePlugins.length===0){return;}_this3.onError(loadFailures[0],"Failed to load plugins: ".concat(failedRemotePlugins.join(', ')),// Grouping on the message split one bug across two dozen groups: the
|
|
3260
|
+
// federation runtime names its own local, renamed by the host bundler per build.
|
|
3261
|
+
remoteEntryUrl);}).catch(function(err){_this3.onError(err);});}/**
|
|
3247
3262
|
* Extension point invoke that allows multiple plugins to be registered to it with error handling
|
|
3248
3263
|
*/},{key:"invokeMultiple",value:function invokeMultiple(extPoint){try{var _this$engine;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}return (_this$engine=this.engine).invokeMultiple.apply(_this$engine,[extPoint].concat(args));}catch(e){this.onError(e,extPoint);return [];}}/**
|
|
3249
3264
|
* Extension point invoke that allows a single plugin to be registered to it with error handling
|
|
@@ -3353,7 +3368,7 @@ state.storage.cookie.value={maxage:cookieStorageOptions.maxage,path:cookieStorag
|
|
|
3353
3368
|
*/return _createClass(Store,[{key:"createValidKey",value:function createValidKey(key){var name=this.name,id=this.id,validKeys=this.validKeys,noKeyValidation=this.noKeyValidation,noCompoundKey=this.noCompoundKey;if(noKeyValidation){return noCompoundKey?key:[name,id,key].join('.');}// validate and return undefined if invalid key
|
|
3354
3369
|
var compoundKey;Object.values(validKeys).forEach(function(validKeyName){if(validKeyName===key){compoundKey=noCompoundKey?key:[name,id,key].join('.');}});return compoundKey;}/**
|
|
3355
3370
|
* Switch to inMemoryEngine, bringing any existing data with.
|
|
3356
|
-
*/},{key:"swapQueueStoreToInMemoryEngine",value:function swapQueueStoreToInMemoryEngine(){var _this=this;var validKeys=this.validKeys,noCompoundKey=this.noCompoundKey;var inMemoryStorage=getStorageEngine(MEMORY_STORAGE)
|
|
3371
|
+
*/},{key:"swapQueueStoreToInMemoryEngine",value:function swapQueueStoreToInMemoryEngine(){var _this=this;var validKeys=this.validKeys,noCompoundKey=this.noCompoundKey,durableEngine=this.engine;var inMemoryStorage=getStorageEngine(MEMORY_STORAGE);// grab existing data, but only for this page's queue instance, not all
|
|
3357
3372
|
// better to keep other queues in localstorage to be flushed later
|
|
3358
3373
|
// than to pull them into memory and remove them from durable storage
|
|
3359
3374
|
var existingEntries=Object.values(validKeys).map(function(storeKey){return [storeKey,_this.get(storeKey)];});// Client data stores keep their durable copy. Dropping rl_user_id and the
|
|
@@ -3374,8 +3389,18 @@ this.engine.setItem(validKey,this.encrypt(stringifyWithoutCircular(value,false,[
|
|
|
3374
3389
|
this.swapQueueStoreToInMemoryEngine();// and save it there
|
|
3375
3390
|
this.set(key,value);}else {var customMessage=STORE_DATA_SAVE_ERROR(key);this.onError(err,customMessage,customMessage);}}}/**
|
|
3376
3391
|
* Get by Key.
|
|
3377
|
-
*/},{key:"get",value:function get(key){var validKey=this.createValidKey(key);var decryptedValue;try{if(!validKey){return null;}
|
|
3378
|
-
return JSON.parse(decryptedValue);}catch(err){
|
|
3392
|
+
*/},{key:"get",value:function get(key){var validKey=this.createValidKey(key);var storedValue;var decryptedValue;var isRetrieved=false;try{if(!validKey){return null;}storedValue=this.engine.getItem(validKey);decryptedValue=this.decrypt(storedValue);if(isNullOrUndefined(decryptedValue)||decryptedValue===''){return null;}isRetrieved=true;// storejs that is used in localstorage engine already deserializes json strings but swallows errors
|
|
3393
|
+
return JSON.parse(decryptedValue);}catch(err){// Both encryption plugins, and `crypto` with no decrypt extension point registered, return
|
|
3394
|
+
// an unrecognised format untouched, so an unchanged value may still be readable; keep it.
|
|
3395
|
+
var isDecrypted=!this.isEncrypted||decryptedValue!==storedValue;// Drop a parse failure so a later read is a clean miss instead of the same error on every
|
|
3396
|
+
// poll, and only while the entry still holds what was read. Web Storage has no conditional
|
|
3397
|
+
// delete, so that narrows rather than closes the window in which another tab's write is
|
|
3398
|
+
// dropped; the cost there is a restarted reclaim handshake, since queued events are written
|
|
3399
|
+
// only by the context that owns the store. The compare is serialized because storejs
|
|
3400
|
+
// deserializes on every read, and uses `JSON.stringify` because `stringifyWithoutCircular`
|
|
3401
|
+
// returns null on failure, which would make two unserializable values compare equal.
|
|
3402
|
+
try{if(isRetrieved&&isDecrypted&&JSON.stringify(this.engine.getItem(validKey))===JSON.stringify(storedValue)){this.remove(key);}}catch(_unused2){// The engine can refuse the re-read or the removal; a later read retries.
|
|
3403
|
+
}var encryptionPluginName=state.storage.encryptionPluginName.value;// Skip error reporting only when the encryption plugin is configured but failed to load
|
|
3379
3404
|
var shouldReportError=!encryptionPluginName||!state.plugins.failedPlugins.value.includes(encryptionPluginName);if(shouldReportError){var customMessage=STORE_DATA_FETCH_ERROR(key);this.onError(err,customMessage,customMessage);}return null;}}/**
|
|
3380
3405
|
* Remove by Key.
|
|
3381
3406
|
*/},{key:"remove",value:function remove(key){var validKey=this.createValidKey(key);if(validKey){this.engine.removeItem(validKey);}}/**
|
|
@@ -3386,7 +3411,7 @@ var shouldReportError=!encryptionPluginName||!state.plugins.failedPlugins.value.
|
|
|
3386
3411
|
* Encrypt value
|
|
3387
3412
|
*/},{key:"encrypt",value:function encrypt(value){return this.crypto(value,'encrypt');}/**
|
|
3388
3413
|
* Extension point to use with encryption plugins
|
|
3389
|
-
*/},{key:"crypto",value:function crypto(value,mode){var noEncryption=!this.isEncrypted||!value||typeof value!=='string'||trim(value)==='';if(noEncryption){return value;}var extensionPointName="storage.".concat(mode);var formattedValue=this.pluginsManager?this.pluginsManager.invokeSingle(extensionPointName,value):value;return
|
|
3414
|
+
*/},{key:"crypto",value:function crypto(value,mode){var noEncryption=!this.isEncrypted||!value||typeof value!=='string'||trim(value)==='';if(noEncryption){return value;}var extensionPointName="storage.".concat(mode);var formattedValue=this.pluginsManager?this.pluginsManager.invokeSingle(extensionPointName,value):value;return formattedValue===undefined?value:formattedValue!==null&&formattedValue!==void 0?formattedValue:'';}/**
|
|
3390
3415
|
* Handle errors
|
|
3391
3416
|
*/},{key:"onError",value:function onError(error,customMessage,groupingHash){this.errorHandler.onError({error:error,context:"Store ".concat(this.id),customMessage:customMessage,groupingHash:groupingHash});}}]);}();
|
|
3392
3417
|
|
|
@@ -3646,10 +3671,11 @@ var getUserAgentClientHint=function getUserAgentClientHint(callback){var level=a
|
|
|
3646
3671
|
|
|
3647
3672
|
var isDatasetAvailable=function isDatasetAvailable(){var testElement=globalThis.document.createElement('div');testElement.setAttribute('data-a-b','c');return testElement.dataset?testElement.dataset.aB==='c':false;};var legacyJSEngineRequiredPolyfills={// Ideally, we should separate the checks for URL and URLSearchParams but
|
|
3648
3673
|
// the polyfill service serves them under the same feature name, "URL".
|
|
3649
|
-
URL:function URL(){return !isFunction(globalThis.URL)||!isFunction(globalThis.URLSearchParams);},Promise:function Promise(){return !isFunction(globalThis.Promise);},'Number.isNaN':function NumberIsNaN(){return !isFunction(globalThis.Number.isNaN);},'Number.isInteger':function NumberIsInteger(){return !isFunction(globalThis.Number.isInteger);},'Array.from':function ArrayFrom(){return !isFunction(globalThis.Array.from);},'Array.prototype.find':function ArrayPrototypeFind(){return !isFunction(globalThis.Array.prototype.find);},'Array.prototype.includes':function ArrayPrototypeIncludes(){return !isFunction(globalThis.Array.prototype.includes);},'String.prototype.endsWith':function StringPrototypeEndsWith(){return !isFunction(globalThis.String.prototype.endsWith);},'String.prototype.startsWith':function StringPrototypeStartsWith(){return !isFunction(globalThis.String.prototype.startsWith);},'String.prototype.includes':function StringPrototypeIncludes(){return !isFunction(globalThis.String.prototype.includes);},'String.prototype.replaceAll':function StringPrototypeReplaceAll(){return !isFunction(globalThis.String.prototype.replaceAll);},'String.fromCodePoint':function StringFromCodePoint(){return !isFunction(globalThis.String.fromCodePoint);},'Object.entries':function ObjectEntries(){return !isFunction(globalThis.Object.entries);},'Object.values':function ObjectValues(){return !isFunction(globalThis.Object.values);}
|
|
3674
|
+
URL:function URL(){return !isFunction(globalThis.URL)||!isFunction(globalThis.URLSearchParams);},Promise:function Promise(){return !isFunction(globalThis.Promise);},'Number.isNaN':function NumberIsNaN(){return !isFunction(globalThis.Number.isNaN);},'Number.isInteger':function NumberIsInteger(){return !isFunction(globalThis.Number.isInteger);},'Array.from':function ArrayFrom(){return !isFunction(globalThis.Array.from);},'Array.prototype.find':function ArrayPrototypeFind(){return !isFunction(globalThis.Array.prototype.find);},'Array.prototype.includes':function ArrayPrototypeIncludes(){return !isFunction(globalThis.Array.prototype.includes);},'String.prototype.endsWith':function StringPrototypeEndsWith(){return !isFunction(globalThis.String.prototype.endsWith);},'String.prototype.startsWith':function StringPrototypeStartsWith(){return !isFunction(globalThis.String.prototype.startsWith);},'String.prototype.includes':function StringPrototypeIncludes(){return !isFunction(globalThis.String.prototype.includes);},'String.prototype.replaceAll':function StringPrototypeReplaceAll(){return !isFunction(globalThis.String.prototype.replaceAll);},'String.fromCodePoint':function StringFromCodePoint(){return !isFunction(globalThis.String.fromCodePoint);},'Object.entries':function ObjectEntries(){return !isFunction(globalThis.Object.entries);},'Object.values':function ObjectValues(){return !isFunction(globalThis.Object.values);},// Not used in this package, but the device mode integrations need them
|
|
3675
|
+
'Object.assign':function ObjectAssign(){return !isFunction(globalThis.Object.assign);},'Object.fromEntries':function ObjectFromEntries(){return !isFunction(globalThis.Object.fromEntries);},'Element.prototype.dataset':function ElementPrototypeDataset(){return !isDatasetAvailable();},// Ideally, we should separate the checks for TextEncoder and TextDecoder but
|
|
3650
3676
|
// the polyfill service serves them under the same feature name, "TextEncoder".
|
|
3651
|
-
TextEncoder:function TextEncoder(){return !isFunction(globalThis.TextEncoder)||!isFunction(globalThis.TextDecoder);},
|
|
3652
|
-
ArrayBuffer:function ArrayBuffer(){return !isFunction(globalThis.Uint8Array);},Set:function Set(){return !isFunction(globalThis.Set);},atob:function atob(){return !isFunction(globalThis.atob);}};var isLegacyJSEngine=function isLegacyJSEngine(){var requiredCapabilitiesList=Object.keys(legacyJSEngineRequiredPolyfills);var needsPolyfill=false;/* eslint-disable-next-line unicorn/no-for-loop */for(var i=0;i<requiredCapabilitiesList.length;i++){var isCapabilityMissing=legacyJSEngineRequiredPolyfills[requiredCapabilitiesList[i]];if(isFunction(isCapabilityMissing)&&isCapabilityMissing()){needsPolyfill=true;break;}}return needsPolyfill;};
|
|
3677
|
+
TextEncoder:function TextEncoder(){return !isFunction(globalThis.TextEncoder)||!isFunction(globalThis.TextDecoder);},CustomEvent:function CustomEvent(){return !isFunction(globalThis.CustomEvent);},// Note, the polyfill service serves both ArrayBuffer and Uint8Array under the same feature name, "ArrayBuffer".
|
|
3678
|
+
ArrayBuffer:function ArrayBuffer(){return !isFunction(globalThis.Uint8Array);},Set:function Set(){return !isFunction(globalThis.Set);},Map:function Map(){return !isFunction(globalThis.Map);},atob:function atob(){return !isFunction(globalThis.atob);}};var isLegacyJSEngine=function isLegacyJSEngine(){var requiredCapabilitiesList=Object.keys(legacyJSEngineRequiredPolyfills);var needsPolyfill=false;/* eslint-disable-next-line unicorn/no-for-loop */for(var i=0;i<requiredCapabilitiesList.length;i++){var isCapabilityMissing=legacyJSEngineRequiredPolyfills[requiredCapabilitiesList[i]];if(isFunction(isCapabilityMissing)&&isCapabilityMissing()){needsPolyfill=true;break;}}return needsPolyfill;};
|
|
3653
3679
|
|
|
3654
3680
|
var POLYFILL_URL='';var POLYFILL_LOAD_TIMEOUT=10*1000;// 10 seconds
|
|
3655
3681
|
var POLYFILL_SCRIPT_ID='rudderstackPolyfill';
|
|
@@ -3680,10 +3706,19 @@ state.capabilities.isBeaconAvailable.value=hasBeacon();state.capabilities.isUaCH
|
|
|
3680
3706
|
state.context.userAgent.value=getUserAgent();state.context.locale.value=getLanguage();state.context.screen.value=getScreenDetails();state.context.timezone.value=getTimezone();if(hasUAClientHints()){getUserAgentClientHint(function(uach){state.context['ua-ch'].value=uach;},state.loadOptions.value.uaChTrackLevel);}});// Ad blocker detection
|
|
3681
3707
|
j(function(){if(state.loadOptions.value.sendAdblockPage===true&&state.lifecycle.sourceConfigUrl.value!==undefined){detectAdBlockers(_this.httpClient);}});}/**
|
|
3682
3708
|
* Detect if polyfills are required and then load script from polyfill URL
|
|
3683
|
-
*/},{key:"prepareBrowserCapabilities",value:function prepareBrowserCapabilities(){var _this2=this
|
|
3709
|
+
*/},{key:"prepareBrowserCapabilities",value:function prepareBrowserCapabilities(){var _this2=this;// The snippet only hands the modern build to engines that ship every polyfill-list API the
|
|
3710
|
+
state.capabilities.isLegacyDOM.value=isLegacyJSEngine();var customPolyfillUrl=state.loadOptions.value.polyfillURL;var polyfillUrl=POLYFILL_URL;if(isDefinedAndNotNull(customPolyfillUrl)){if(isValidURL(customPolyfillUrl)){polyfillUrl=customPolyfillUrl;}else {this.logger.warn(INVALID_POLYFILL_URL_WARNING(CAPABILITIES_MANAGER,customPolyfillUrl));}}var shouldLoadPolyfill=state.loadOptions.value.polyfillIfRequired&&state.capabilities.isLegacyDOM.value&&isValidURL(polyfillUrl);if(shouldLoadPolyfill){var isDefaultPolyfillService=polyfillUrl!==state.loadOptions.value.polyfillURL;// write key specific callback
|
|
3684
3711
|
// NOTE: we're not putting this into RudderStackGlobals as providing the property path to the callback function in the polyfill URL is not possible
|
|
3685
|
-
var polyfillCallbackName="RS_polyfillCallback_".concat(state.lifecycle.writeKey.value)
|
|
3686
|
-
|
|
3712
|
+
var polyfillCallbackName="RS_polyfillCallback_".concat(state.lifecycle.writeKey.value);// A timed out script stays in the DOM, so a late response can still fire the
|
|
3713
|
+
// callback. Settle once, and drop the handler on failure as well as success.
|
|
3714
|
+
var isPolyfillLoadSettled=false;var installedPolyfillCallback;var settlePolyfillLoad=function settlePolyfillLoad(onSettled){// Only remove our own handler: the name is keyed by write key alone, so the
|
|
3715
|
+
// global may belong to the page or to another in-flight load.
|
|
3716
|
+
if(installedPolyfillCallback&&globalThis[polyfillCallbackName]===installedPolyfillCallback){delete globalThis[polyfillCallbackName];}if(isPolyfillLoadSettled){return;}isPolyfillLoadSettled=true;onSettled();};if(isDefaultPolyfillService){installedPolyfillCallback=function installedPolyfillCallback(){settlePolyfillLoad(function(){return _this2.onPolyfillLoaded();});};globalThis[polyfillCallbackName]=installedPolyfillCallback;polyfillUrl="".concat(polyfillUrl,"&callback=").concat(polyfillCallbackName);}this.externalSrcLoader.loadJSFile({url:polyfillUrl,id:POLYFILL_SCRIPT_ID,async:true,timeout:POLYFILL_LOAD_TIMEOUT,callback:function callback(scriptId,err){if(!scriptId||err){// Report and stop: the SDK misbehaves on an engine still missing these.
|
|
3717
|
+
settlePolyfillLoad(function(){_this2.onError(new Error(POLYFILL_SCRIPT_LOAD_ERROR(POLYFILL_SCRIPT_ID,polyfillUrl)));});}else if(!isDefaultPolyfillService){settlePolyfillLoad(function(){return _this2.onPolyfillLoaded();});}}});}else {this.onReady();}}/**
|
|
3718
|
+
* Report the features that the polyfill script did not apply and then set the
|
|
3719
|
+
* lifecycle status to next phase
|
|
3720
|
+
*/},{key:"onPolyfillLoaded",value:function onPolyfillLoaded(){// Guarded too so the detection list is dropped from the modern bundle
|
|
3721
|
+
if(isLegacyJSEngine()){var missingFeatures=Object.keys(legacyJSEngineRequiredPolyfills).filter(function(feature){var isFeatureMissing=legacyJSEngineRequiredPolyfills[feature];return isFunction(isFeatureMissing)&&isFeatureMissing();});this.onError(new Error(POLYFILL_VERIFICATION_ERROR(missingFeatures)));}this.onReady();}/**
|
|
3687
3722
|
* Attach listeners to window to observe event that update capabilities state values
|
|
3688
3723
|
*/},{key:"attachWindowListeners",value:function attachWindowListeners(){globalThis.addEventListener('offline',function(){state.capabilities.isOnline.value=false;});globalThis.addEventListener('online',function(){state.capabilities.isOnline.value=true;});globalThis.addEventListener('resize',debounce(function(){state.context.screen.value=getScreenDetails();},this));}/**
|
|
3689
3724
|
* Set the lifecycle status to next phase
|
|
@@ -3691,7 +3726,7 @@ delete globalThis[polyfillCallbackName];};globalThis[polyfillCallbackName]=polyf
|
|
|
3691
3726
|
},{key:"onReady",value:function onReady(){this.detectBrowserCapabilities();state.lifecycle.status.value='browserCapabilitiesReady';}/**
|
|
3692
3727
|
* Handles error
|
|
3693
3728
|
* @param error The error object
|
|
3694
|
-
*/},{key:"onError",value:function onError(error,groupingHash){this.errorHandler.onError({error:error,context:CAPABILITIES_MANAGER,groupingHash:groupingHash});}}]);}();
|
|
3729
|
+
*/},{key:"onError",value:function onError(error,groupingHash){void this.errorHandler.onError({error:error,context:CAPABILITIES_MANAGER,groupingHash:groupingHash});}}]);}();
|
|
3695
3730
|
|
|
3696
3731
|
var CHANNEL='web';// These are the top-level elements in the standard RudderStack event spec
|
|
3697
3732
|
var TOP_LEVEL_ELEMENTS=['integrations','anonymousId','originalTimestamp'];// Reserved elements in the context of standard RudderStack event spec
|
|
@@ -4123,18 +4158,18 @@ var _excluded=["context"];/*
|
|
|
4123
4158
|
* Analytics class with lifecycle based on state ad user triggered events
|
|
4124
4159
|
*/var Analytics=/*#__PURE__*/function(){/**
|
|
4125
4160
|
* Initialize services and components or use default ones if singletons
|
|
4126
|
-
*/function Analytics(){_classCallCheck(this,Analytics);this.preloadBuffer=new BufferQueue();this.initialized=false;this.errorHandler=defaultErrorHandler;this.logger=defaultLogger;this.customContextStore=new CustomContextStore(state.customContext,this.logger);this.externalSrcLoader=new ExternalSrcLoader(this.logger);this.httpClient=defaultHttpClient;this.httpClient.init(this.errorHandler);this.capabilitiesManager=new CapabilitiesManager(this.httpClient,this.errorHandler,this.logger);}/**
|
|
4161
|
+
*/function Analytics(){_classCallCheck(this,Analytics);this.preloadBuffer=new BufferQueue();this.initialized=false;this.isDrainingBuffer=false;this.errorHandler=defaultErrorHandler;this.logger=defaultLogger;this.customContextStore=new CustomContextStore(state.customContext,this.logger);this.externalSrcLoader=new ExternalSrcLoader(this.logger);this.httpClient=defaultHttpClient;this.httpClient.init(this.errorHandler);this.capabilitiesManager=new CapabilitiesManager(this.httpClient,this.errorHandler,this.logger);}/**
|
|
4127
4162
|
* Start application lifecycle if not already started
|
|
4128
4163
|
*/return _createClass(Analytics,[{key:"load",value:function load(writeKey,dataPlaneUrl){var _state$loadOptions$va;var loadOptions=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(state.lifecycle.status.value){return;}if(!isWriteKeyValid(writeKey)){this.logger.error(WRITE_KEY_VALIDATION_ERROR(ANALYTICS_CORE,writeKey));return;}if(!isDataPlaneUrlValid(dataPlaneUrl)){this.logger.error(DATA_PLANE_URL_VALIDATION_ERROR(ANALYTICS_CORE,dataPlaneUrl));return;}var customContext=loadOptions.context,loadOptionsWithoutContext=_objectWithoutProperties(loadOptions,_excluded);var sanitizedLoadOptions=getSanitizedValue(loadOptionsWithoutContext);if(customContext!==undefined){this.customContextStore.set(customContext);}// Set initial state values
|
|
4129
4164
|
n(function(){state.lifecycle.writeKey.value=clone(writeKey);state.lifecycle.dataPlaneUrl.value=clone(dataPlaneUrl);state.loadOptions.value=normalizeLoadOptions(state.loadOptions.value,sanitizedLoadOptions);state.lifecycle.status.value='mounted';});// set log level as early as possible
|
|
4130
4165
|
this.logger.setMinLogLevel((_state$loadOptions$va=state.loadOptions.value.logLevel)!==null&&_state$loadOptions$va!==void 0?_state$loadOptions$va:POST_LOAD_LOG_LEVEL);// Expose state to global objects
|
|
4131
4166
|
setExposedGlobal('state',state,writeKey);// Configure initial config of any services or components here
|
|
4132
4167
|
// State application lifecycle
|
|
4133
|
-
this.startLifecycle();}},{key:"setCustomContext",value:function setCustomContext(context){if(
|
|
4168
|
+
this.startLifecycle();}},{key:"setCustomContext",value:function setCustomContext(context){var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['setCustomContext',context]]);return;}this.customContextStore.set(context);}},{key:"getCustomContext",value:function getCustomContext(){return this.customContextStore.get();}},{key:"clearCustomContext",value:function clearCustomContext(){var isBufferedInvocation=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['clearCustomContext']]);return;}this.customContextStore.clear();}// Start lifecycle methods
|
|
4134
4169
|
/**
|
|
4135
4170
|
* Orchestrate the lifecycle of the application phases/status
|
|
4136
|
-
*/},{key:"startLifecycle",value:function startLifecycle(){var _this=this;j(function(){try{switch(state.lifecycle.status.value){case 'mounted':_this.onMounted();break;case 'browserCapabilitiesReady':_this.onBrowserCapabilitiesReady();break;case 'configured':_this.onConfigured();break;case 'pluginsLoading':break;case 'pluginsReady':_this.onPluginsReady();break;case 'initialized':_this.onInitialized();break;case 'loaded':_this.onLoaded();break;case 'destinationsLoading':break;case 'destinationsReady':_this.onDestinationsReady();break;case 'ready':_this.onReady();break;case 'readyExecuted':default:break;}}catch(err){var issue='Failed to load the SDK';_this.errorHandler.onError({error:err,context:ANALYTICS_CORE,customMessage:issue,groupingHash:issue});}});}},{key:"onBrowserCapabilitiesReady",value:function onBrowserCapabilitiesReady(){// initialize the preloaded events enqueuing
|
|
4137
|
-
retrievePreloadBufferEvents(this);this.prepareInternalServices();this.loadConfig();}},{key:"onLoaded",value:function onLoaded(){
|
|
4171
|
+
*/},{key:"startLifecycle",value:function startLifecycle(){var _this=this;j(function(){try{switch(state.lifecycle.status.value){case 'mounted':_this.onMounted();break;case 'browserCapabilitiesReady':_this.onBrowserCapabilitiesReady();break;case 'configured':_this.onConfigured();break;case 'pluginsLoading':break;case 'pluginsReady':_this.onPluginsReady();break;case 'initialized':_this.onInitialized();break;case 'loaded':_this.onLoaded();break;case 'destinationsLoading':break;case 'destinationsReady':_this.onDestinationsReady();break;case 'ready':_this.onReady();break;case 'readyExecuted':default:break;}}catch(err){var issue='Failed to load the SDK';void _this.errorHandler.onError({error:err,context:ANALYTICS_CORE,customMessage:issue,groupingHash:issue});}});}},{key:"onBrowserCapabilitiesReady",value:function onBrowserCapabilitiesReady(){// initialize the preloaded events enqueuing
|
|
4172
|
+
retrievePreloadBufferEvents(this);this.prepareInternalServices();this.loadConfig();}},{key:"onLoaded",value:function onLoaded(){// Short-circuit the life cycle and move to the ready state if pre-consent behavior is enabled
|
|
4138
4173
|
if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value='ready';}else {this.loadDestinations();}}/**
|
|
4139
4174
|
* Load browser polyfill if required
|
|
4140
4175
|
*/},{key:"onMounted",value:function onMounted(){this.capabilitiesManager.init();}/**
|
|
@@ -4155,9 +4190,12 @@ state.lifecycle.status.value='initialized';}/**
|
|
|
4155
4190
|
// registerCustomPlugins(state.loadOptions.value.customPlugins);
|
|
4156
4191
|
}/**
|
|
4157
4192
|
* Trigger onLoaded callback if any is provided in config & emit initialised event
|
|
4158
|
-
*/},{key:"onInitialized",value:function onInitialized(){//
|
|
4159
|
-
|
|
4160
|
-
|
|
4193
|
+
*/},{key:"onInitialized",value:function onInitialized(){// Preloaded calls were made before the ones buffered while initializing, so queue them first.
|
|
4194
|
+
// Exception: they stay behind any consent call made while initializing, so that consent still
|
|
4195
|
+
// applies to them as it always has (see SDK-5623)
|
|
4196
|
+
var callsDuringInitialization=state.eventBuffer.toBeProcessedArray.value;state.eventBuffer.toBeProcessedArray.value=[];this.processDataInPreloadBuffer();var lastConsentIndex=callsDuringInitialization.map(function(_ref){var _ref2=_slicedToArray(_ref,1),type=_ref2[0];return type;}).lastIndexOf('consent');state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(callsDuringInitialization.slice(0,lastConsentIndex+1)),_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),_toConsumableArray(callsDuringInitialization.slice(lastConsentIndex+1)));// Set lifecycle state
|
|
4197
|
+
n(function(){state.lifecycle.loaded.value=true;state.lifecycle.status.value='loaded';});this.initialized=true;// Calls made while draining (e.g., from event callbacks) are queued behind the buffered ones
|
|
4198
|
+
this.isDrainingBuffer=true;try{this.processBufferedEvents();}finally{this.isDrainingBuffer=false;}// Execute onLoaded callback if provided in load options
|
|
4161
4199
|
var onLoadedCallbackFn=state.loadOptions.value.onLoaded;// TODO: we need to avoid passing the window object to the callback function
|
|
4162
4200
|
// as this will prevent us from supporting multiple SDK instances in the same page
|
|
4163
4201
|
safelyInvokeCallback(onLoadedCallbackFn,[globalThis.rudderanalytics],LOAD_API,this.logger);// Emit an event to use as substitute to the onLoaded callback
|
|
@@ -4170,7 +4208,11 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
4170
4208
|
*/},{key:"processBufferedEvents",value:function processBufferedEvents(){// This logic has been intentionally implemented without a simple
|
|
4171
4209
|
// for-loop as the individual events that are processed may
|
|
4172
4210
|
// add more events to the buffer (this is needed for the consent API)
|
|
4173
|
-
var bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){var bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){
|
|
4211
|
+
var bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){var bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){// A failing call must not stop the rest of the buffer or the load notifications
|
|
4212
|
+
try{this.processBufferedEvent(bufferedEvent);}catch(err){var issue='Failed to process a buffered API call';void this.errorHandler.onError({error:err,context:ANALYTICS_CORE,customMessage:issue,groupingHash:issue});}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}},{key:"processBufferedEvent",value:function processBufferedEvent(bufferedEvent){switch(bufferedEvent[0]){case 'setCustomContext':this.setCustomContext(bufferedEvent[1],true);break;case 'clearCustomContext':this.clearCustomContext(true);break;case 'ready':this.ready(bufferedEvent[1],true);break;case 'page':this.page(bufferedEvent[1],true,bufferedEvent[2]);break;case 'track':this.track(bufferedEvent[1],true,bufferedEvent[2]);break;case 'identify':this.identify(bufferedEvent[1],true,bufferedEvent[2]);break;case 'alias':this.alias(bufferedEvent[1],true,bufferedEvent[2]);break;case 'group':this.group(bufferedEvent[1],true,bufferedEvent[2]);break;case 'reset':this.reset(bufferedEvent[1],true);break;case 'setAnonymousId':this.setAnonymousId(bufferedEvent[1],bufferedEvent[2],true);break;case 'startSession':this.startSession(bufferedEvent[1],true);break;case 'endSession':this.endSession(true);break;case 'consent':this.consent(bufferedEvent[1],true);break;case 'addCustomIntegration':this.addCustomIntegration(bufferedEvent[1],bufferedEvent[2],true);break;default:{var unsupportedEvent=bufferedEvent;return unsupportedEvent;}}}/**
|
|
4213
|
+
* Whether an API call must be queued instead of executed now: either the SDK is not loaded yet,
|
|
4214
|
+
* or the buffer is being drained and this call was not replayed from it
|
|
4215
|
+
*/},{key:"shouldBuffer",value:function shouldBuffer(isBufferedInvocation){return !state.lifecycle.loaded.value||this.isDrainingBuffer&&!isBufferedInvocation;}},{key:"getInvocationContext",value:function getInvocationContext(preservedCustomContext){var _ref3;if(preservedCustomContext===undefined){return this.customContextStore.get();}var preparedContext=prepareCustomContextUpdate(preservedCustomContext,this.logger);return (_ref3=preparedContext)!==null&&_ref3!==void 0?_ref3:{};}/**
|
|
4174
4216
|
* Load device mode destinations
|
|
4175
4217
|
*/},{key:"loadDestinations",value:function loadDestinations(){var _this$pluginsManager4,_this$pluginsManager5;// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
4176
4218
|
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
@@ -4183,28 +4225,31 @@ j(function(){var areAllDestinationsReady=state.nativeDestinations.initializedDes
|
|
|
4183
4225
|
// Mark the ready status if not already done
|
|
4184
4226
|
if(state.lifecycle.status.value!=='ready'){n(function(){state.lifecycle.status.value='ready';});}}// End lifecycle methods
|
|
4185
4227
|
// Start consumer exposed methods
|
|
4186
|
-
},{key:"ready",value:function ready(callback){var type='ready';if(
|
|
4228
|
+
},{key:"ready",value:function ready(callback){var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var type='ready';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,callback]]);return;}this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));if(!isFunction(callback)){this.logger.error(INVALID_CALLBACK_FN_ERROR(READY_API));return;}/**
|
|
4187
4229
|
* If destinations are loaded or no integration is available for loading
|
|
4188
4230
|
* execute the callback immediately else push the callbacks to a queue that
|
|
4189
4231
|
* will be executed after loading completes
|
|
4190
|
-
*/if(state.lifecycle.status.value==='readyExecuted'){safelyInvokeCallback(callback,[],READY_API,this.logger);}else {state.eventBuffer.readyCallbacksArray.value=[].concat(_toConsumableArray(state.eventBuffer.readyCallbacksArray.value),[callback]);}}},{key:"page",value:function page(payload){var _this$eventManager2;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='page';if(
|
|
4232
|
+
*/if(state.lifecycle.status.value==='readyExecuted'){safelyInvokeCallback(callback,[],READY_API,this.logger);}else {state.eventBuffer.readyCallbacksArray.value=[].concat(_toConsumableArray(state.eventBuffer.readyCallbacksArray.value),[callback]);}}},{key:"page",value:function page(payload){var _this$eventManager2;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='page';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,payload]]);return;}var invocationContext=this.getInvocationContext(preservedCustomContext);this.errorHandler.leaveBreadcrumb("New ".concat(type," event"));state.metrics.triggered.value+=1;(_this$eventManager2=this.eventManager)===null||_this$eventManager2===void 0||_this$eventManager2.addEvent({type:'page',category:payload.category,name:payload.name,properties:payload.properties,options:payload.options,callback:payload.callback},invocationContext);// TODO: Maybe we should alter the behavior to send the ad-block page event even if the SDK is still loaded. It'll be pushed into the to be processed queue.
|
|
4191
4233
|
// Send automatic ad blocked page event if ad-blockers are detected on the page
|
|
4192
4234
|
// Check page category to avoid infinite loop
|
|
4193
4235
|
if(state.capabilities.isAdBlocked.value===true&&payload.category!==ADBLOCK_PAGE_CATEGORY){this.page(pageArgumentsToCallOptions(ADBLOCK_PAGE_CATEGORY,ADBLOCK_PAGE_NAME,{// 'title' is intentionally omitted as it does not make sense
|
|
4194
4236
|
// in v3 implementation
|
|
4195
|
-
path:ADBLOCK_PAGE_PATH},state.loadOptions.value.sendAdblockPageOptions),isBufferedInvocation,invocationContext);}}},{key:"track",value:function track(payload){var _this$eventManager3;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='track';if(
|
|
4196
|
-
|
|
4197
|
-
if(!isNull(payload.
|
|
4198
|
-
if(!
|
|
4237
|
+
path:ADBLOCK_PAGE_PATH},state.loadOptions.value.sendAdblockPageOptions),isBufferedInvocation,invocationContext);}}},{key:"track",value:function track(payload){var _this$eventManager3;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='track';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,payload]]);return;}var invocationContext=this.getInvocationContext(preservedCustomContext);this.errorHandler.leaveBreadcrumb("New ".concat(type," event - ").concat(payload.name));state.metrics.triggered.value+=1;(_this$eventManager3=this.eventManager)===null||_this$eventManager3===void 0||_this$eventManager3.addEvent({type:type,name:payload.name||undefined,properties:payload.properties,options:payload.options,callback:payload.callback},invocationContext);}},{key:"identify",value:function identify(payload){var _this$userSessionMana3,_this$eventManager4;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='identify';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,payload]]);return;}var invocationContext=this.getInvocationContext(preservedCustomContext);this.errorHandler.leaveBreadcrumb("New ".concat(type," event"));state.metrics.triggered.value+=1;var shouldResetSession=Boolean(payload.userId&&state.session.userId.value&&payload.userId!==state.session.userId.value);if(shouldResetSession){// Part of this identify call, so it must not be deferred behind other buffered calls
|
|
4238
|
+
this.reset(undefined,true);}// `null` value indicates that previous user ID needs to be retained
|
|
4239
|
+
if(!isNull(payload.userId)){var _this$userSessionMana2;(_this$userSessionMana2=this.userSessionManager)===null||_this$userSessionMana2===void 0||_this$userSessionMana2.setUserId(payload.userId);}(_this$userSessionMana3=this.userSessionManager)===null||_this$userSessionMana3===void 0||_this$userSessionMana3.setUserTraits(payload.traits);(_this$eventManager4=this.eventManager)===null||_this$eventManager4===void 0||_this$eventManager4.addEvent({type:type,userId:payload.userId,traits:payload.traits,options:payload.options,callback:payload.callback},invocationContext);}},{key:"alias",value:function alias(payload){var _payload$from,_this$userSessionMana4,_this$eventManager5;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='alias';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,payload]]);return;}var invocationContext=this.getInvocationContext(preservedCustomContext);this.errorHandler.leaveBreadcrumb("New ".concat(type," event"));state.metrics.triggered.value+=1;var previousId=(_payload$from=payload.from)!==null&&_payload$from!==void 0?_payload$from:this.getUserId()||((_this$userSessionMana4=this.userSessionManager)===null||_this$userSessionMana4===void 0?void 0:_this$userSessionMana4.getAnonymousId());(_this$eventManager5=this.eventManager)===null||_this$eventManager5===void 0||_this$eventManager5.addEvent({type:type,to:payload.to,from:previousId,options:payload.options,callback:payload.callback},invocationContext);}},{key:"group",value:function group(payload){var _this$userSessionMana6,_this$eventManager6;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var preservedCustomContext=arguments.length>2?arguments[2]:undefined;var type='group';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,payload]]);return;}var invocationContext=this.getInvocationContext(preservedCustomContext);this.errorHandler.leaveBreadcrumb("New ".concat(type," event"));state.metrics.triggered.value+=1;// `null` value indicates that previous group ID needs to be retained
|
|
4240
|
+
if(!isNull(payload.groupId)){var _this$userSessionMana5;(_this$userSessionMana5=this.userSessionManager)===null||_this$userSessionMana5===void 0||_this$userSessionMana5.setGroupId(payload.groupId);}(_this$userSessionMana6=this.userSessionManager)===null||_this$userSessionMana6===void 0||_this$userSessionMana6.setGroupTraits(payload.traits);(_this$eventManager6=this.eventManager)===null||_this$eventManager6===void 0||_this$eventManager6.addEvent({type:type,groupId:payload.groupId,traits:payload.traits,options:payload.options,callback:payload.callback},invocationContext);}},{key:"reset",value:function reset(options){var _this$userSessionMana7;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var type='reset';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,options]]);return;}this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));(_this$userSessionMana7=this.userSessionManager)===null||_this$userSessionMana7===void 0||_this$userSessionMana7.reset(options);}},{key:"getAnonymousId",value:function getAnonymousId(options){var _this$userSessionMana8;return (_this$userSessionMana8=this.userSessionManager)===null||_this$userSessionMana8===void 0?void 0:_this$userSessionMana8.getAnonymousId(options);}},{key:"setAnonymousId",value:function setAnonymousId(anonymousId,rudderAmpLinkerParam){var _this$userSessionMana9;var isBufferedInvocation=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var type='setAnonymousId';// Buffering is needed as setting the anonymous ID may require invoking the GoogleLinker plugin
|
|
4241
|
+
if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,anonymousId,rudderAmpLinkerParam]]);return;}this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));(_this$userSessionMana9=this.userSessionManager)===null||_this$userSessionMana9===void 0||_this$userSessionMana9.setAnonymousId(anonymousId,rudderAmpLinkerParam);}// eslint-disable-next-line class-methods-use-this
|
|
4199
4242
|
},{key:"getUserId",value:function getUserId(){return state.session.userId.value;}// eslint-disable-next-line class-methods-use-this
|
|
4200
4243
|
},{key:"getUserTraits",value:function getUserTraits(){return state.session.userTraits.value;}// eslint-disable-next-line class-methods-use-this
|
|
4201
4244
|
},{key:"getGroupId",value:function getGroupId(){return state.session.groupId.value;}// eslint-disable-next-line class-methods-use-this
|
|
4202
|
-
},{key:"getGroupTraits",value:function getGroupTraits(){return state.session.groupTraits.value;}},{key:"startSession",value:function startSession(sessionId){var _this$userSessionMana0;var type='startSession';if(
|
|
4203
|
-
},{key:"getSessionId",value:function getSessionId(){var _this$userSessionMana10;var sessionId=(_this$userSessionMana10=this.userSessionManager)===null||_this$userSessionMana10===void 0?void 0:_this$userSessionMana10.getSessionId();return sessionId!==null&&sessionId!==void 0?sessionId:null;}},{key:"consent",value:function consent(options){var _this4=this,_this$storeManager2,_this$userSessionMana11,_this$eventManager7;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var type='consent';if(
|
|
4245
|
+
},{key:"getGroupTraits",value:function getGroupTraits(){return state.session.groupTraits.value;}},{key:"startSession",value:function startSession(sessionId){var _this$userSessionMana0;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var type='startSession';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,sessionId]]);return;}this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));(_this$userSessionMana0=this.userSessionManager)===null||_this$userSessionMana0===void 0||_this$userSessionMana0.start(sessionId);}},{key:"endSession",value:function endSession(){var _this$userSessionMana1;var isBufferedInvocation=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var type='endSession';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type]]);return;}this.errorHandler.leaveBreadcrumb("New ".concat(type," invocation"));(_this$userSessionMana1=this.userSessionManager)===null||_this$userSessionMana1===void 0||_this$userSessionMana1.end();}// eslint-disable-next-line class-methods-use-this
|
|
4246
|
+
},{key:"getSessionId",value:function getSessionId(){var _this$userSessionMana10;var sessionId=(_this$userSessionMana10=this.userSessionManager)===null||_this$userSessionMana10===void 0?void 0:_this$userSessionMana10.getSessionId();return sessionId!==null&&sessionId!==void 0?sessionId:null;}},{key:"consent",value:function consent(options){var _this4=this,_this$storeManager2,_this$userSessionMana11,_this$eventManager7;var isBufferedInvocation=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var type='consent';if(this.shouldBuffer(isBufferedInvocation)){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[[type,options]]);return;}this.errorHandler.leaveBreadcrumb("New consent invocation");n(function(){state.consents.preConsent.value=_objectSpread2(_objectSpread2({},state.consents.preConsent.value),{},{enabled:false});state.consents.postConsent.value=getValidPostConsentOptions(options,_this4.logger);var _getConsentManagement=getConsentManagementData(state.consents.postConsent.value.consentManagement,_this4.logger),initialized=_getConsentManagement.initialized,consentsData=_getConsentManagement.consentsData;state.consents.initialized.value=initialized;state.consents.data.value=consentsData;});// Update consents data in state
|
|
4204
4247
|
if(state.consents.enabled.value&&!state.consents.initialized.value){var _this$pluginsManager6;(_this$pluginsManager6=this.pluginsManager)===null||_this$pluginsManager6===void 0||_this$pluginsManager6.invokeSingle("consentManager.updateConsentsInfo",state,this.storeManager,this.logger);}// Re-init store manager
|
|
4205
4248
|
(_this$storeManager2=this.storeManager)===null||_this$storeManager2===void 0||_this$storeManager2.initializeStorageState();// Re-init user session manager
|
|
4206
4249
|
(_this$userSessionMana11=this.userSessionManager)===null||_this$userSessionMana11===void 0||_this$userSessionMana11.syncStorageDataToState();// Resume event manager to process the events to destinations
|
|
4207
|
-
(_this$eventManager7=this.eventManager)===null||_this$eventManager7===void 0||_this$eventManager7.resume()
|
|
4250
|
+
(_this$eventManager7=this.eventManager)===null||_this$eventManager7===void 0||_this$eventManager7.resume();// While replaying, defer to the 'loaded' lifecycle handler so that custom integrations
|
|
4251
|
+
// added later in the buffer are registered before destinations are loaded
|
|
4252
|
+
if(!this.isDrainingBuffer){this.loadDestinations();}this.sendTrackingEvents(isBufferedInvocation);}},{key:"sendTrackingEvents",value:function sendTrackingEvents(isBufferedInvocation){// If isBufferedInvocation is true, then the tracking events will be added to the end of the
|
|
4208
4253
|
// events buffer array so that any other preload events (mainly from query string API) will be processed first.
|
|
4209
4254
|
if(state.consents.postConsent.value.trackConsent){var trackOptions=trackArgumentsToCallOptions(CONSENT_TRACK_EVENT_NAME);if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['track',trackOptions,this.customContextStore.get()]]);}else {this.track(trackOptions);}}if(state.consents.postConsent.value.sendPageEvent){var pageOptions=pageArgumentsToCallOptions();if(isBufferedInvocation){state.eventBuffer.toBeProcessedArray.value=[].concat(_toConsumableArray(state.eventBuffer.toBeProcessedArray.value),[['page',pageOptions,this.customContextStore.get()]]);}else {this.page(pageOptions);}}}},{key:"setAuthToken",value:function setAuthToken(token){var _this$userSessionMana12;(_this$userSessionMana12=this.userSessionManager)===null||_this$userSessionMana12===void 0||_this$userSessionMana12.setAuthToken(token);}/**
|
|
4210
4255
|
* Add a custom integration for a custom destination.
|