@rudderstack/analytics-js 3.17.0 → 3.18.0

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.
@@ -341,10 +341,10 @@ mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};/**
341
341
  * Normalizes a value to a boolean, with support for a default value
342
342
  * @param val Input value
343
343
  * @param defVal Default value
344
- * @returns Returns the normalized boolean value
344
+ * @returns Returns the input value if it is a boolean, otherwise returns the default value
345
345
  * @example
346
346
  * getNormalizedBooleanValue(true, false) // returns true
347
- */const getNormalizedBooleanValue=(val,defVal)=>{if(isDefined(defVal)){return isDefined(val)?val===true:defVal;}return val===true;};
347
+ */const getNormalizedBooleanValue=(val,defVal)=>typeof val==='boolean'?val:defVal;
348
348
 
349
349
  const trim=value=>value.replace(/^\s+|\s+$/gm,'');const removeLeadingPeriod=value=>value.replace(/^\.+/,'');/**
350
350
  * A function to convert values to string
@@ -495,12 +495,13 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
495
495
  error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
496
496
  error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
497
497
 
498
- const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.17.0';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';const ADBLOCK_PAGE_NAME='ad-block page request';const ADBLOCK_PAGE_PATH='/ad-blocked';const GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';const CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
498
+ const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.18.0';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const ADBLOCK_PAGE_CATEGORY='RudderJS-Initiated';const ADBLOCK_PAGE_NAME='ad-block page request';const ADBLOCK_PAGE_PATH='/ad-blocked';const GLOBAL_PRELOAD_BUFFER='preloadedEventsBuffer';const CONSENT_TRACK_EVENT_NAME='Consent Management Interaction';
499
499
 
500
500
  const QUERY_PARAM_TRAIT_PREFIX='ajs_trait_';const QUERY_PARAM_PROPERTY_PREFIX='ajs_prop_';const QUERY_PARAM_ANONYMOUS_ID_KEY='ajs_aid';const QUERY_PARAM_USER_ID_KEY='ajs_uid';const QUERY_PARAM_TRACK_EVENT_NAME_KEY='ajs_event';
501
501
 
502
502
  const DEFAULT_XHR_TIMEOUT_MS=10*1000;// 10 seconds
503
503
  const DEFAULT_COOKIE_MAX_AGE_MS=31536000*1000;// 1 year
504
+ const DEFAULT_SESSION_CUT_OFF_DURATION_MS=12*60*60*1000;// 12 hours
504
505
  const DEFAULT_SESSION_TIMEOUT_MS=30*60*1000;// 30 minutes
505
506
  const MIN_SESSION_TIMEOUT_MS=10*1000;// 10 seconds
506
507
  const DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS=10*1000;// 10 seconds
@@ -615,7 +616,7 @@ const SUPPORTED_STORAGE_TYPES=['localStorage','memoryStorage','cookieStorage','s
615
616
 
616
617
  const SOURCE_CONFIG_RESOLUTION_ERROR=`Unable to process/parse source configuration response`;const SOURCE_DISABLED_ERROR=`The source is disabled. Please enable the source in the dashboard to send events.`;const XHR_PAYLOAD_PREP_ERROR=`Failed to prepare data for the request.`;const PLUGIN_EXT_POINT_MISSING_ERROR=`Failed to invoke plugin because the extension point name is missing.`;const PLUGIN_EXT_POINT_INVALID_ERROR=`Failed to invoke plugin because the extension point name is invalid.`;const SOURCE_CONFIG_OPTION_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`;const COMPONENT_BASE_URL_ERROR=(context,component,url)=>`${context}${LOG_CONTEXT_SEPARATOR}The base URL "${url}" for ${component} is not valid.`;// ERROR
617
618
  const UNSUPPORTED_CONSENT_MANAGER_ERROR=(context,selectedConsentManager,consentManagersToPluginNameMap)=>`${context}${LOG_CONTEXT_SEPARATOR}The consent manager "${selectedConsentManager}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(consentManagersToPluginNameMap)}".`;const NON_ERROR_WARNING=(context,errStr)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring a non-error: ${errStr}.`;const BREADCRUMB_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to log breadcrumb.`;const HANDLE_ERROR_FAILURE=context=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to handle the error.`;const PLUGIN_NAME_MISSING_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin name is missing.`;const PLUGIN_ALREADY_EXISTS_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" already exists.`;const PLUGIN_NOT_FOUND_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" not found.`;const PLUGIN_ENGINE_BUG_ERROR=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`;const PLUGIN_DEPS_ERROR=(context,pluginName,notExistDeps)=>`${context}${LOG_CONTEXT_SEPARATOR}Plugin "${pluginName}" could not be loaded because some of its dependencies "${notExistDeps}" do not exist.`;const PLUGIN_INVOCATION_ERROR=(context,extPoint,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to invoke the "${extPoint}" extension point of plugin "${pluginName}".`;const STORAGE_UNAVAILABILITY_ERROR_PREFIX=(context,storageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${storageType}" storage type is `;const SOURCE_CONFIG_FETCH_ERROR='Failed to fetch the source config';const WRITE_KEY_VALIDATION_ERROR=(context,writeKey)=>`${context}${LOG_CONTEXT_SEPARATOR}The write key "${writeKey}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`;const DATA_PLANE_URL_VALIDATION_ERROR=(context,dataPlaneUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The data plane URL "${dataPlaneUrl}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`;const INVALID_CALLBACK_FN_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The provided callback parameter is not a function.`;const XHR_DELIVERY_ERROR=(prefix,status,statusText,url,response)=>`${prefix} with status ${status} (${statusText}) for URL: ${url}. Response: ${response.trim()}`;const XHR_REQUEST_ERROR=(prefix,e,url)=>`${prefix} due to timeout or no connection (${e?e.type:''}) at the client side for URL: ${url}`;const XHR_SEND_ERROR=(prefix,url)=>`${prefix} for URL: ${url}`;const STORE_DATA_SAVE_ERROR=key=>`Failed to save the value for "${key}" to storage`;const STORE_DATA_FETCH_ERROR=key=>`Failed to retrieve or parse data for "${key}" from storage`;const DATA_SERVER_REQUEST_FAIL_ERROR=status=>`The server responded with status ${status} while setting the cookies. As a fallback, the cookies will be set client side.`;const FAILED_SETTING_COOKIE_FROM_SERVER_ERROR=key=>`The server failed to set the ${key} cookie. As a fallback, the cookies will be set client side.`;const FAILED_SETTING_COOKIE_FROM_SERVER_GLOBAL_ERROR=`Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.`;// WARNING
618
- const STORAGE_TYPE_VALIDATION_WARNING=(context,storageType,defaultStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${storageType}" is not supported. Please choose one of the following supported types: "${SUPPORTED_STORAGE_TYPES}". The default type "${defaultStorageType}" will be used instead.`;const UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage encryption version "${selectedStorageEncryptionVersion}" is not supported. Please choose one of the following supported versions: "${Object.keys(storageEncryptionVersionsToPluginNameMap)}". The default version "${defaultVersion}" will be used instead.`;const STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=(context,storageEncryptionVersion,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage data migration has been disabled because the configured storage encryption version (${storageEncryptionVersion}) is not the latest (${defaultVersion}). To enable storage data migration, please update the storage encryption version to the latest version.`;const SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=(context,providedCookieDomain,currentCookieDomain)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided cookie domain (${providedCookieDomain}) does not match the current webpage's domain (${currentCookieDomain}). Hence, the cookies will be set client-side.`;const RESERVED_KEYWORD_WARNING=(context,property,parentKeyPath,reservedElements)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${property}" property defined under "${parentKeyPath}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${reservedElements}).`;const INVALID_CONTEXT_OBJECT_WARNING=logContext=>`${logContext}${LOG_CONTEXT_SEPARATOR}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`;const UNSUPPORTED_BEACON_API_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`;const TIMEOUT_NOT_NUMBER_WARNING=(context,timeout,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value "${timeout}" is not a number. The default timeout of ${defaultValue} ms will be used instead.`;const TIMEOUT_ZERO_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.`;const TIMEOUT_NOT_RECOMMENDED_WARNING=(context,timeout,minTimeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value ${timeout} ms is less than the recommended minimum of ${minTimeout} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`;const INVALID_SESSION_ID_WARNING=(context,sessionId,minSessionIdLength)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided session ID (${sessionId}) is either invalid, not a positive integer, or not at least "${minSessionIdLength}" digits long. A new session ID will be auto-generated instead.`;const STORAGE_QUOTA_EXCEEDED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`;const STORAGE_UNAVAILABLE_WARNING=(context,entry,selectedStorageType,finalStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${selectedStorageType}" is not available for entry "${entry}". The SDK will initialize the entry with "${finalStorageType}" storage type instead.`;const CALLBACK_INVOKE_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The callback threw an exception`;const INVALID_CONFIG_URL_WARNING=(context,configUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided source config URL "${configUrl}" is invalid. Using the default source config URL instead.`;const POLYFILL_SCRIPT_LOAD_ERROR=(scriptId,url)=>`Failed to load the polyfill script with ID "${scriptId}" from URL ${url}.`;const UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=(context,selectedStrategy,defaultStrategy)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent storage strategy "${selectedStrategy}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${defaultStrategy}" will be used instead.`;const UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=(context,selectedDeliveryType,defaultDeliveryType)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent events delivery type "${selectedDeliveryType}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${defaultDeliveryType}" will be used instead.`;const DEPRECATED_PLUGIN_WARNING=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}${pluginName} plugin is deprecated. Please exclude it from the load API options.`;const generateMisconfiguredPluginsWarning=(context,configurationStatus,missingPlugins,shouldAddMissingPlugins)=>{const isSinglePlugin=missingPlugins.length===1;const pluginsString=isSinglePlugin?` '${missingPlugins[0]}' plugin was`:` ['${missingPlugins.join("', '")}'] plugins were`;const baseWarning=`${context}${LOG_CONTEXT_SEPARATOR}${configurationStatus}, but${pluginsString} not configured to load.`;if(shouldAddMissingPlugins){return `${baseWarning} So, ${isSinglePlugin?'the plugin':'those plugins'} will be loaded automatically.`;}return `${baseWarning} Ignore if this was intentional. Otherwise, consider adding ${isSinglePlugin?'it':'them'} to the 'plugins' load API option.`;};const INVALID_POLYFILL_URL_WARNING=(context,customPolyfillUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided polyfill URL "${customPolyfillUrl}" is invalid. The default polyfill URL will be used instead.`;const PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`;const UNKNOWN_PLUGINS_WARNING=(context,unknownPlugins)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring unknown plugins: ${unknownPlugins.join(', ')}.`;
619
+ const STORAGE_TYPE_VALIDATION_WARNING=(context,storageType,defaultStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${storageType}" is not supported. Please choose one of the following supported types: "${SUPPORTED_STORAGE_TYPES}". The default type "${defaultStorageType}" will be used instead.`;const UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING=(context,selectedStorageEncryptionVersion,storageEncryptionVersionsToPluginNameMap,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage encryption version "${selectedStorageEncryptionVersion}" is not supported. Please choose one of the following supported versions: "${Object.keys(storageEncryptionVersionsToPluginNameMap)}". The default version "${defaultVersion}" will be used instead.`;const STORAGE_DATA_MIGRATION_OVERRIDE_WARNING=(context,storageEncryptionVersion,defaultVersion)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage data migration has been disabled because the configured storage encryption version (${storageEncryptionVersion}) is not the latest (${defaultVersion}). To enable storage data migration, please update the storage encryption version to the latest version.`;const SERVER_SIDE_COOKIE_FEATURE_OVERRIDE_WARNING=(context,providedCookieDomain,currentCookieDomain)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided cookie domain (${providedCookieDomain}) does not match the current webpage's domain (${currentCookieDomain}). Hence, the cookies will be set client-side.`;const RESERVED_KEYWORD_WARNING=(context,property,parentKeyPath,reservedElements)=>`${context}${LOG_CONTEXT_SEPARATOR}The "${property}" property defined under "${parentKeyPath}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${reservedElements}).`;const INVALID_CONTEXT_OBJECT_WARNING=logContext=>`${logContext}${LOG_CONTEXT_SEPARATOR}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`;const UNSUPPORTED_BEACON_API_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`;const TIMEOUT_NOT_NUMBER_WARNING=(context,timeout,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value "${timeout}" is not a number. The default timeout of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_NOT_NUMBER_WARNING=(context,cutOffDuration,defaultValue)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" is not a number. The default cut off duration of ${defaultValue} ms will be used instead.`;const CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING=(context,cutOffDuration,timeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session cut off duration value "${cutOffDuration}" ms is less than the session timeout value "${timeout}" ms. The cut off functionality will be disabled.`;const TIMEOUT_ZERO_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.`;const TIMEOUT_NOT_RECOMMENDED_WARNING=(context,timeout,minTimeout)=>`${context}${LOG_CONTEXT_SEPARATOR}The session timeout value ${timeout} ms is less than the recommended minimum of ${minTimeout} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`;const INVALID_SESSION_ID_WARNING=(context,sessionId,minSessionIdLength)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided session ID (${sessionId}) is either invalid, not a positive integer, or not at least "${minSessionIdLength}" digits long. A new session ID will be auto-generated instead.`;const STORAGE_QUOTA_EXCEEDED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`;const STORAGE_UNAVAILABLE_WARNING=(context,entry,selectedStorageType,finalStorageType)=>`${context}${LOG_CONTEXT_SEPARATOR}The storage type "${selectedStorageType}" is not available for entry "${entry}". The SDK will initialize the entry with "${finalStorageType}" storage type instead.`;const CALLBACK_INVOKE_ERROR=context=>`${context}${LOG_CONTEXT_SEPARATOR}The callback threw an exception`;const INVALID_CONFIG_URL_WARNING=(context,configUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided source config URL "${configUrl}" is invalid. Using the default source config URL instead.`;const POLYFILL_SCRIPT_LOAD_ERROR=(scriptId,url)=>`Failed to load the polyfill script with ID "${scriptId}" from URL ${url}.`;const UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY=(context,selectedStrategy,defaultStrategy)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent storage strategy "${selectedStrategy}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${defaultStrategy}" will be used instead.`;const UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE=(context,selectedDeliveryType,defaultDeliveryType)=>`${context}${LOG_CONTEXT_SEPARATOR}The pre-consent events delivery type "${selectedDeliveryType}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${defaultDeliveryType}" will be used instead.`;const DEPRECATED_PLUGIN_WARNING=(context,pluginName)=>`${context}${LOG_CONTEXT_SEPARATOR}${pluginName} plugin is deprecated. Please exclude it from the load API options.`;const generateMisconfiguredPluginsWarning=(context,configurationStatus,missingPlugins,shouldAddMissingPlugins)=>{const isSinglePlugin=missingPlugins.length===1;const pluginsString=isSinglePlugin?` '${missingPlugins[0]}' plugin was`:` ['${missingPlugins.join("', '")}'] plugins were`;const baseWarning=`${context}${LOG_CONTEXT_SEPARATOR}${configurationStatus}, but${pluginsString} not configured to load.`;if(shouldAddMissingPlugins){return `${baseWarning} So, ${isSinglePlugin?'the plugin':'those plugins'} will be loaded automatically.`;}return `${baseWarning} Ignore if this was intentional. Otherwise, consider adding ${isSinglePlugin?'it':'them'} to the 'plugins' load API option.`;};const INVALID_POLYFILL_URL_WARNING=(context,customPolyfillUrl)=>`${context}${LOG_CONTEXT_SEPARATOR}The provided polyfill URL "${customPolyfillUrl}" is invalid. The default polyfill URL will be used instead.`;const PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING=context=>`${context}${LOG_CONTEXT_SEPARATOR}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`;const UNKNOWN_PLUGINS_WARNING=(context,unknownPlugins)=>`${context}${LOG_CONTEXT_SEPARATOR}Ignoring unknown plugins: ${unknownPlugins.join(', ')}.`;
619
620
 
620
621
  const DEFAULT_INTEGRATIONS_CONFIG={All:true};
621
622
 
@@ -634,11 +635,11 @@ const BUILD_TYPE='modern';const SDK_CDN_BASE_URL='https://cdn.rudderlabs.com';co
634
635
 
635
636
  const DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';const DEFAULT_DATA_PLANE_EVENTS_TRANSPORT='xhr';const ConsentManagersToPluginNameMap={iubenda:'IubendaConsentManager',oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};const StorageEncryptionVersionsToPluginNameMap={[DEFAULT_STORAGE_ENCRYPTION_VERSION]:'StorageEncryption',legacy:'StorageEncryptionLegacy'};const DataPlaneEventsTransportToPluginNameMap={[DEFAULT_DATA_PLANE_EVENTS_TRANSPORT]:'XhrQueue',beacon:'BeaconQueue'};const DEFAULT_DATA_SERVICE_ENDPOINT='rsaRequest';const METRICS_SERVICE_ENDPOINT='rsaMetrics';
636
637
 
637
- const defaultLoadOptions={configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:DEFAULT_INTEGRATIONS_CONFIG,useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:true,lockPluginsVersion:true,uaChTrackLevel:'none',plugins:[],useGlobalIntegrationsConfigInEvents:false,bufferDataPlaneEventsUntilReady:false,dataPlaneEventsBufferTimeout:DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS,storage:{encryption:{version:DEFAULT_STORAGE_ENCRYPTION_VERSION},migrate:true,cookie:{}},sendAdblockPage:false,sameDomainCookiesOnly:false,secureCookie:false,sendAdblockPageOptions:{},useServerSideCookies:false};const loadOptionsState=d$1(clone(defaultLoadOptions));
638
+ const defaultLoadOptions={configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS,cutOff:{enabled:false}},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:DEFAULT_INTEGRATIONS_CONFIG,useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:true,lockPluginsVersion:true,uaChTrackLevel:'none',plugins:[],useGlobalIntegrationsConfigInEvents:false,bufferDataPlaneEventsUntilReady:false,dataPlaneEventsBufferTimeout:DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS,storage:{encryption:{version:DEFAULT_STORAGE_ENCRYPTION_VERSION},migrate:true,cookie:{}},sendAdblockPage:false,sameDomainCookiesOnly:false,secureCookie:false,sendAdblockPageOptions:{},useServerSideCookies:false};const loadOptionsState=d$1(clone(defaultLoadOptions));
638
639
 
639
640
  const DEFAULT_USER_SESSION_VALUES={userId:'',userTraits:{},anonymousId:'',groupId:'',groupTraits:{},initialReferrer:'',initialReferringDomain:'',sessionInfo:{},authToken:null};const SERVER_SIDE_COOKIES_DEBOUNCE_TIME=10;// milliseconds
640
641
 
641
- const defaultSessionConfiguration={autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS};const sessionState={userId:d$1(DEFAULT_USER_SESSION_VALUES.userId),userTraits:d$1(DEFAULT_USER_SESSION_VALUES.userTraits),anonymousId:d$1(DEFAULT_USER_SESSION_VALUES.anonymousId),groupId:d$1(DEFAULT_USER_SESSION_VALUES.groupId),groupTraits:d$1(DEFAULT_USER_SESSION_VALUES.groupTraits),initialReferrer:d$1(DEFAULT_USER_SESSION_VALUES.initialReferrer),initialReferringDomain:d$1(DEFAULT_USER_SESSION_VALUES.initialReferringDomain),sessionInfo:d$1(DEFAULT_USER_SESSION_VALUES.sessionInfo),authToken:d$1(DEFAULT_USER_SESSION_VALUES.authToken)};
642
+ const sessionState={userId:d$1(DEFAULT_USER_SESSION_VALUES.userId),userTraits:d$1(DEFAULT_USER_SESSION_VALUES.userTraits),anonymousId:d$1(DEFAULT_USER_SESSION_VALUES.anonymousId),groupId:d$1(DEFAULT_USER_SESSION_VALUES.groupId),groupTraits:d$1(DEFAULT_USER_SESSION_VALUES.groupTraits),initialReferrer:d$1(DEFAULT_USER_SESSION_VALUES.initialReferrer),initialReferringDomain:d$1(DEFAULT_USER_SESSION_VALUES.initialReferringDomain),sessionInfo:d$1(DEFAULT_USER_SESSION_VALUES.sessionInfo),authToken:d$1(DEFAULT_USER_SESSION_VALUES.authToken)};
642
643
 
643
644
  const capabilitiesState={isOnline:d$1(true),storage:{isLocalStorageAvailable:d$1(false),isCookieStorageAvailable:d$1(false),isSessionStorageAvailable:d$1(false)},isBeaconAvailable:d$1(false),isLegacyDOM:d$1(false),isUaCHAvailable:d$1(false),isCryptoAvailable:d$1(false),isIE11:d$1(false),isAdBlocked:d$1(false)};
644
645
 
@@ -758,7 +759,7 @@ const APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','ano
758
759
  const getErrInstance=(err,errorType)=>{switch(errorType){case ErrorType.UNHANDLEDEXCEPTION:{const{error}=err;return error||err;}case ErrorType.UNHANDLEDREJECTION:{return err.reason;}case ErrorType.HANDLEDEXCEPTION:default:return err;}};const createNewBreadcrumb=message=>({type:'manual',name:message,timestamp:new Date(),metaData:{}});/**
759
760
  * A function to get the Bugsnag release stage for the current environment
760
761
  * @returns 'development' if the host is empty (for file:// protocol etc.) or a dev host (localhost, 127.0.0.1, etc.), otherwise 'production' (it'll be replaced with the actual release stage during the build)
761
- */const getReleaseStage=()=>{const host=globalThis.location.hostname;return !host||host&&DEV_HOSTS.includes(host)?'development':'production';};const getAppStateForMetadata=state=>{const stateStr=stringifyWithoutCircular(state,false,APP_STATE_EXCLUDE_KEYS);return stateStr!==null?JSON.parse(stateStr):{};};const getURLWithoutQueryString=()=>{const url=globalThis.location.href.split('?');return url[0];};const getUserDetails=(source,session,lifecycle,autoTrack)=>({id:`${source.value?.id??lifecycle.writeKey.value}..${session.sessionInfo.value.id??'NA'}..${autoTrack.pageLifecycle.pageViewId.value??'NA'}`,name:source.value?.name??'NA'});const getDeviceDetails=(locale,userAgent)=>({locale:locale.value??'NA',userAgent:userAgent.value??'NA',time:new Date()});const getBugsnagErrorEvent=(exception,errorState,state)=>{const{context,lifecycle,session,source,reporting,autoTrack}=state;const{app,locale,userAgent,timezone,screen,library}=context;return {payloadVersion:'5',notifier:{name:NOTIFIER_NAME,version:app.value.version,url:SDK_GITHUB_URL},events:[{exceptions:[clone(exception)],severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:app.value.version,releaseStage:getReleaseStage(),type:app.value.installType},device:getDeviceDetails(locale,userAgent),request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(reporting.breadcrumbs.value),context:exception.message,metaData:{app:{snippetVersion:library.value.snippetVersion},device:{...screen.value,timezone:timezone.value},// Add rest of the state groups as metadata
762
+ */const getReleaseStage=()=>{const host=globalThis.location.hostname;return !host||host&&DEV_HOSTS.includes(host)?'development':'production';};const getAppStateForMetadata=state=>{const stateStr=stringifyWithoutCircular(state,false,APP_STATE_EXCLUDE_KEYS);return stateStr!==null?JSON.parse(stateStr):{};};const getURLWithoutQueryString=()=>{const url=globalThis.location.href.split('?');return url[0];};const getUserDetails=(source,session,lifecycle,autoTrack)=>({id:`${source.value?.id??lifecycle.writeKey.value}..${session.sessionInfo.value.id??'NA'}..${autoTrack.pageLifecycle.pageViewId.value??'NA'}`,name:source.value?.name??'NA'});const getDeviceDetails=(locale,userAgent)=>({locale:locale.value??'NA',userAgent:userAgent.value??'NA',time:new Date()});const getBugsnagErrorEvent=(exception,errorState,state,groupingHash)=>{const{context,lifecycle,session,source,reporting,autoTrack}=state;const{app,locale,userAgent,timezone,screen,library}=context;return {payloadVersion:'5',notifier:{name:NOTIFIER_NAME,version:app.value.version,url:SDK_GITHUB_URL},events:[{exceptions:[clone(exception)],severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:app.value.version,releaseStage:getReleaseStage(),type:app.value.installType},device:getDeviceDetails(locale,userAgent),request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(reporting.breadcrumbs.value),context:exception.message,groupingHash,metaData:{app:{snippetVersion:library.value.snippetVersion},device:{...screen.value,timezone:timezone.value},// Add rest of the state groups as metadata
762
763
  // so that they show up as separate tabs in the dashboard
763
764
  ...getAppStateForMetadata(state)},user:getUserDetails(source,session,lifecycle,autoTrack)}]};};/**
764
765
  * A function to determine whether the error should be promoted to notify or not
@@ -791,8 +792,14 @@ constructor(httpClient,logger){this.httpClient=httpClient;this.logger=logger;}/*
791
792
  */onError(error,context='',customMessage='',errorType=ErrorType.HANDLEDEXCEPTION){try{const errInstance=getErrInstance(error,errorType);const normalizedError=normalizeError(errInstance,this.logger);if(isUndefined(normalizedError)){return;}const customMsgVal=customMessage?`${customMessage} - `:'';const errorMsgPrefix=`${context}${LOG_CONTEXT_SEPARATOR}${customMsgVal}`;const bsException=createBugsnagException(normalizedError,errorMsgPrefix);const stacktrace=getStacktrace(normalizedError);const isSdkDispatched=stacktrace.includes(MANUAL_ERROR_IDENTIFIER);// Filter errors that are not originated in the SDK.
792
793
  // In case of NPM installations, the unhandled errors from the SDK cannot be identified
793
794
  // and will NOT be reported unless they occur in plugins or integrations.
794
- if(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCEPTION){return;}if(state.reporting.isErrorReportingEnabled.value&&isAllowedToBeNotified(bsException)){const errorState={severity:'error',unhandled:errorType!==ErrorType.HANDLEDEXCEPTION,severityReason:{type:errorType}};// enrich error payload
795
- const bugsnagPayload=getBugsnagErrorEvent(bsException,errorState,state);// send it to metrics service
795
+ if(!isSdkDispatched&&!isSDKError(bsException)&&errorType!==ErrorType.HANDLEDEXCEPTION){return;}if(state.reporting.isErrorReportingEnabled.value&&isAllowedToBeNotified(bsException)){const errorState={severity:'error',unhandled:errorType!==ErrorType.HANDLEDEXCEPTION,severityReason:{type:errorType}};// Set grouping hash only for CDN installations (as an experiment)
796
+ // This will allow us to group errors by the message instead of the surrounding code.
797
+ // In case of NPM installations, the default grouping by surrounding code does not make sense as each user application is different.
798
+ // References:
799
+ // https://docs.bugsnag.com/platforms/javascript/customizing-error-reports/#groupinghash
800
+ // https://docs.bugsnag.com/product/error-grouping/#user_defined
801
+ const groupingHash=state.context.app.value.installType==='cdn'?bsException.message:undefined;// Get the final payload to be sent to the metrics service
802
+ const bugsnagPayload=getBugsnagErrorEvent(bsException,errorState,state,groupingHash);// send it to metrics service
796
803
  this.httpClient.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true});}// Log handled errors and errors dispatched by the SDK
797
804
  if(errorType===ErrorType.HANDLEDEXCEPTION||isSdkDispatched){this.logger.error(bsException.message);}}catch(err){// If an error occurs while handling an error, log it
798
805
  this.logger.error(HANDLE_ERROR_FAILURE(ERROR_HANDLER),err);}}/**
@@ -1065,170 +1072,172 @@ const isDestIntgConfigTruthy=destIntgConfig=>!isUndefined(destIntgConfig)&&Boole
1065
1072
  * @returns Destinations array filtered based on the integration options
1066
1073
  */const filterDestinations=(intgOpts,destinations)=>{const allOptVal=intgOpts.All??true;return destinations.filter(dest=>{const destDisplayName=dest.displayName;let isDestEnabled;if(allOptVal){isDestEnabled=true;if(isDestIntgConfigFalsy(intgOpts[destDisplayName])){isDestEnabled=false;}}else {isDestEnabled=false;if(isDestIntgConfigTruthy(intgOpts[destDisplayName])){isDestEnabled=true;}}return isDestEnabled;});};
1067
1074
 
1068
- const ACTIVE_CAMPAIGN_DISPLAY_NAME='ActiveCampaign';const ADOBE_ANALYTICS_DISPLAY_NAME='Adobe Analytics';const ADROLL_DISPLAY_NAME='Adroll';const AM_DISPLAY_NAME='Amplitude';const APPCUES_DISPLAY_NAME='Appcues';const AXEPTIO_DISPLAY_NAME='Axeptio';const BINGADS_DISPLAY_NAME='Bing Ads';const BRAZE_DISPLAY_NAME='Braze';const BUGSNAG_DISPLAY_NAME='Bugsnag';const CHARTBEAT_DISPLAY_NAME='Chartbeat';const CLEVERTAP_DISPLAY_NAME='CleverTap';const COMMANDBAR_DISPLAY_NAME='CommandBar';const CONVERTFLOW_DISPLAY_NAME='Convertflow';const CRITEO_DISPLAY_NAME='Criteo';const CUSTOMERIO_DISPLAY_NAME='Customer IO';const DCM_FLOODLIGHT_DISPLAY_NAME='DCM Floodlight';const DRIP_DISPLAY_NAME='Drip';const ENGAGE_DISPLAY_NAME='Engage';const FACEBOOK_PIXEL_DISPLAY_NAME='Facebook Pixel';const FULLSTORY_DISPLAY_NAME='Fullstory';const GA_DISPLAY_NAME='Google Analytics';const GA360_DISPLAY_NAME='Google Analytics 360';const GA4_DISPLAY_NAME='Google Analytics 4 (GA4)';const GA4_V2_DISPLAY_NAME='Google Analytics 4 (GA4) V2';const GAINSIGHT_PX_DISPLAY_NAME='Gainsight PX';const GOOGLE_OPTIMIZE_DISPLAY_NAME='Google Optimize';const GOOGLEADS_DISPLAY_NAME='Google Ads';const GTM_DISPLAY_NAME='Google Tag Manager';const HEAP_DISPLAY_NAME='Heap.io';const HOTJAR_DISPLAY_NAME='Hotjar';const HS_DISPLAY_NAME='HubSpot';const INTERCOM_DISPLAY_NAME='Intercom';const ITERABLE_DISPLAY_NAME='Iterable';const JUNE_DISPLAY_NAME='JUNE';const KEEN_DISPLAY_NAME='Keen';const KISSMETRICS_DISPLAY_NAME='Kiss Metrics';const KLAVIYO_DISPLAY_NAME='Klaviyo';const LAUNCHDARKLY_DISPLAY_NAME='LaunchDarkly';const LEMNISK_DISPLAY_NAME='Lemnisk Marketing Automation';const LINKEDIN_INSIGHT_TAG_DISPLAY_NAME='Linkedin Insight Tag';const LIVECHAT_DISPLAY_NAME='livechat';const LOTAME_DISPLAY_NAME='Lotame';const LYTICS_DISPLAY_NAME='Lytics';const MATOMO_DISPLAY_NAME='Matomo';const MICROSOFT_CLARITY_DISPLAY_NAME='Microsoft Clarity';const MOENGAGE_DISPLAY_NAME='MoEngage';const MOUSEFLOW_DISPLAY_NAME='Mouseflow';const MP_DISPLAY_NAME='Mixpanel';const NINETAILED_DISPLAY_NAME='Ninetailed';const OLARK_DISPLAY_NAME='Olark';const OPTIMIZELY_DISPLAY_NAME='Optimizely Web';const PENDO_DISPLAY_NAME='Pendo';const PINTEREST_TAG_DISPLAY_NAME='Pinterest Tag';const PODSIGHTS_DISPLAY_NAME='Podsights';const POST_AFFILIATE_PRO_DISPLAY_NAME='Post Affiliate Pro';const POSTHOG_DISPLAY_NAME='PostHog';const PROFITWELL_DISPLAY_NAME='ProfitWell';const QUALAROO_DISPLAY_NAME='Qualaroo';const QUALTRICS_DISPLAY_NAME='Qualtrics';const QUANTUMMETRIC_DISPLAY_NAME='Quantum Metric';const QUORA_PIXEL_DISPLAY_NAME='Quora Pixel';const REDDIT_PIXEL_DISPLAY_NAME='Reddit Pixel';const REFINER_DISPLAY_NAME='Refiner';const ROCKERBOX_DISPLAY_NAME='Rockerbox';const ROLLBAR_DISPLAY_NAME='rollbar';const SATISMETER_DISPLAY_NAME='SatisMeter';const SENDINBLUE_DISPLAY_NAME='Sendinblue';const SENTRY_DISPLAY_NAME='Sentry';const SHYNET_DISPLAY_NAME='Shynet';const SNAP_PIXEL_DISPLAY_NAME='Snap Pixel';const SNAPENGAGE_DISPLAY_NAME='SnapEngage';const SPOTIFYPIXEL_DISPLAY_NAME='Spotify Pixel';const SPRIG_DISPLAY_NAME='Sprig';const TIKTOK_ADS_DISPLAY_NAME='TikTok Ads';const TVSQUARED_DISPLAY_NAME='TVSquared';const VERO_DISPLAY_NAME='Vero';const VWO_DISPLAY_NAME='VWO';const WOOPRA_DISPLAY_NAME='WOOPRA';const XPIXEL_DISPLAY_NAME='XPixel';const YANDEX_METRICA_DISPLAY_NAME='Yandex.Metrica';
1075
+ const ACTIVE_CAMPAIGN_DISPLAY_NAME='ActiveCampaign';const ADOBE_ANALYTICS_DISPLAY_NAME='Adobe Analytics';const ADROLL_DISPLAY_NAME='Adroll';const AM_DISPLAY_NAME='Amplitude';const APPCUES_DISPLAY_NAME='Appcues';const AXEPTIO_DISPLAY_NAME='Axeptio';const BINGADS_DISPLAY_NAME='Bing Ads';const BRAZE_DISPLAY_NAME='Braze';const BUGSNAG_DISPLAY_NAME='Bugsnag';const CHARTBEAT_DISPLAY_NAME='Chartbeat';const CLEVERTAP_DISPLAY_NAME='CleverTap';const COMMANDBAR_DISPLAY_NAME='CommandBar';const CONVERTFLOW_DISPLAY_NAME='Convertflow';const CRITEO_DISPLAY_NAME='Criteo';const CUSTOMERIO_DISPLAY_NAME='Customer IO';const DCM_FLOODLIGHT_DISPLAY_NAME='DCM Floodlight';const DRIP_DISPLAY_NAME='Drip';const ENGAGE_DISPLAY_NAME='Engage';const FACEBOOK_PIXEL_DISPLAY_NAME='Facebook Pixel';const FULLSTORY_DISPLAY_NAME='Fullstory';const GA_DISPLAY_NAME='Google Analytics';const GA360_DISPLAY_NAME='Google Analytics 360';const GA4_DISPLAY_NAME='Google Analytics 4 (GA4)';const GA4_V2_DISPLAY_NAME='Google Analytics 4 (GA4) V2';const GAINSIGHT_PX_DISPLAY_NAME='Gainsight PX';const GOOGLE_OPTIMIZE_DISPLAY_NAME='Google Optimize';const GOOGLEADS_DISPLAY_NAME='Google Ads';const GTM_DISPLAY_NAME='Google Tag Manager';const HEAP_DISPLAY_NAME='Heap.io';const HOTJAR_DISPLAY_NAME='Hotjar';const HS_DISPLAY_NAME='HubSpot';const INTERCOM_DISPLAY_NAME='Intercom';const ITERABLE_DISPLAY_NAME='Iterable';const JUNE_DISPLAY_NAME='JUNE';const KEEN_DISPLAY_NAME='Keen';const KISSMETRICS_DISPLAY_NAME='Kiss Metrics';const KLAVIYO_DISPLAY_NAME='Klaviyo';const LAUNCHDARKLY_DISPLAY_NAME='LaunchDarkly';const LEMNISK_DISPLAY_NAME='Lemnisk Marketing Automation';const LINKEDIN_INSIGHT_TAG_DISPLAY_NAME='Linkedin Insight Tag';const LIVECHAT_DISPLAY_NAME='livechat';const LOTAME_DISPLAY_NAME='Lotame';const LYTICS_DISPLAY_NAME='Lytics';const MATOMO_DISPLAY_NAME='Matomo';const MICROSOFT_CLARITY_DISPLAY_NAME='Microsoft Clarity';const MOENGAGE_DISPLAY_NAME='MoEngage';const MOUSEFLOW_DISPLAY_NAME='Mouseflow';const MP_DISPLAY_NAME='Mixpanel';const NINETAILED_DISPLAY_NAME='Ninetailed';const OLARK_DISPLAY_NAME='Olark';const OPTIMIZELY_DISPLAY_NAME='Optimizely Web';const PENDO_DISPLAY_NAME='Pendo';const PINTEREST_TAG_DISPLAY_NAME='Pinterest Tag';const PODSIGHTS_DISPLAY_NAME='Podsights';const POST_AFFILIATE_PRO_DISPLAY_NAME='Post Affiliate Pro';const POSTHOG_DISPLAY_NAME='PostHog';const PROFITWELL_DISPLAY_NAME='ProfitWell';const QUALAROO_DISPLAY_NAME='Qualaroo';const QUALTRICS_DISPLAY_NAME='Qualtrics';const QUANTUMMETRIC_DISPLAY_NAME='Quantum Metric';const QUORA_PIXEL_DISPLAY_NAME='Quora Pixel';const REDDIT_PIXEL_DISPLAY_NAME='Reddit Pixel';const REFINER_DISPLAY_NAME='Refiner';const ROCKERBOX_DISPLAY_NAME='Rockerbox';const ROLLBAR_DISPLAY_NAME='rollbar';const SATISMETER_DISPLAY_NAME='SatisMeter';const SENDINBLUE_DISPLAY_NAME='Sendinblue';const SENTRY_DISPLAY_NAME='Sentry';const SHYNET_DISPLAY_NAME='Shynet';const SNAP_PIXEL_DISPLAY_NAME='Snap Pixel';const SNAPENGAGE_DISPLAY_NAME='SnapEngage';const SPOTIFYPIXEL_DISPLAY_NAME='Spotify Pixel';const SPRIG_DISPLAY_NAME='Sprig';const TIKTOK_ADS_DISPLAY_NAME='TikTok Ads';const TVSQUARED_DISPLAY_NAME='TVSquared';const VERO_DISPLAY_NAME='Vero';const VWO_DISPLAY_NAME='VWO';const WOOPRA_DISPLAY_NAME='WOOPRA';const XPIXEL_DISPLAY_NAME='XPixel';const YANDEX_METRICA_DISPLAY_NAME='Yandex.Metrica';const USERPILOT_DISPLAY_NAME='Userpilot';
1069
1076
 
1070
- const DIR_NAME$1f='AdobeAnalytics';
1077
+ const DIR_NAME$1g='AdobeAnalytics';
1071
1078
 
1072
- const DIR_NAME$1e='Amplitude';
1079
+ const DIR_NAME$1f='Amplitude';
1073
1080
 
1074
- const DIR_NAME$1d='Appcues';
1081
+ const DIR_NAME$1e='Appcues';
1075
1082
 
1076
- const DIR_NAME$1c='BingAds';
1083
+ const DIR_NAME$1d='BingAds';
1077
1084
 
1078
- const DIR_NAME$1b='Braze';
1085
+ const DIR_NAME$1c='Braze';
1079
1086
 
1080
- const DIR_NAME$1a='Bugsnag';
1087
+ const DIR_NAME$1b='Bugsnag';
1081
1088
 
1082
- const DIR_NAME$19='Chartbeat';
1089
+ const DIR_NAME$1a='Chartbeat';
1083
1090
 
1084
- const DIR_NAME$18='Clevertap';
1091
+ const DIR_NAME$19='Clevertap';
1085
1092
 
1086
- const DIR_NAME$17='Criteo';
1093
+ const DIR_NAME$18='Criteo';
1087
1094
 
1088
- const DIR_NAME$16='CustomerIO';
1095
+ const DIR_NAME$17='CustomerIO';
1089
1096
 
1090
- const DIR_NAME$15='Drip';
1097
+ const DIR_NAME$16='Drip';
1091
1098
 
1092
- const DIR_NAME$14='FacebookPixel';
1099
+ const DIR_NAME$15='FacebookPixel';
1093
1100
 
1094
- const DIR_NAME$13='Fullstory';
1101
+ const DIR_NAME$14='Fullstory';
1095
1102
 
1096
- const DIR_NAME$12='GA';
1103
+ const DIR_NAME$13='GA';
1097
1104
 
1098
- const DIR_NAME$11='GA4';
1105
+ const DIR_NAME$12='GA4';
1099
1106
 
1100
- const DIR_NAME$10='GA4_V2';
1107
+ const DIR_NAME$11='GA4_V2';
1101
1108
 
1102
- const DIR_NAME$$='GoogleAds';
1109
+ const DIR_NAME$10='GoogleAds';
1103
1110
 
1104
- const DIR_NAME$_='GoogleOptimize';
1111
+ const DIR_NAME$$='GoogleOptimize';
1105
1112
 
1106
- const DIR_NAME$Z='GoogleTagManager';
1113
+ const DIR_NAME$_='GoogleTagManager';
1107
1114
 
1108
- const DIR_NAME$Y='Heap';
1115
+ const DIR_NAME$Z='Heap';
1109
1116
 
1110
- const DIR_NAME$X='Hotjar';
1117
+ const DIR_NAME$Y='Hotjar';
1111
1118
 
1112
- const DIR_NAME$W='HubSpot';
1119
+ const DIR_NAME$X='HubSpot';
1113
1120
 
1114
- const DIR_NAME$V='INTERCOM';
1121
+ const DIR_NAME$W='INTERCOM';
1115
1122
 
1116
- const DIR_NAME$U='Keen';
1123
+ const DIR_NAME$V='Keen';
1117
1124
 
1118
- const DIR_NAME$T='Kissmetrics';
1125
+ const DIR_NAME$U='Kissmetrics';
1119
1126
 
1120
- const DIR_NAME$S='Klaviyo';
1127
+ const DIR_NAME$T='Klaviyo';
1121
1128
 
1122
- const DIR_NAME$R='LaunchDarkly';
1129
+ const DIR_NAME$S='LaunchDarkly';
1123
1130
 
1124
- const DIR_NAME$Q='LinkedInInsightTag';
1131
+ const DIR_NAME$R='LinkedInInsightTag';
1125
1132
 
1126
- const DIR_NAME$P='Lotame';
1133
+ const DIR_NAME$Q='Lotame';
1127
1134
 
1128
- const DIR_NAME$O='Lytics';
1135
+ const DIR_NAME$P='Lytics';
1129
1136
 
1130
- const DIR_NAME$N='Mixpanel';
1137
+ const DIR_NAME$O='Mixpanel';
1131
1138
 
1132
- const DIR_NAME$M='MoEngage';
1139
+ const DIR_NAME$N='MoEngage';
1133
1140
 
1134
- const DIR_NAME$L='Optimizely';
1141
+ const DIR_NAME$M='Optimizely';
1135
1142
 
1136
- const DIR_NAME$K='Pendo';
1143
+ const DIR_NAME$L='Pendo';
1137
1144
 
1138
- const DIR_NAME$J='PinterestTag';
1145
+ const DIR_NAME$K='PinterestTag';
1139
1146
 
1140
- const DIR_NAME$I='PostAffiliatePro';
1147
+ const DIR_NAME$J='PostAffiliatePro';
1141
1148
 
1142
- const DIR_NAME$H='Posthog';
1149
+ const DIR_NAME$I='Posthog';
1143
1150
 
1144
- const DIR_NAME$G='ProfitWell';
1151
+ const DIR_NAME$H='ProfitWell';
1145
1152
 
1146
- const DIR_NAME$F='Qualtrics';
1153
+ const DIR_NAME$G='Qualtrics';
1147
1154
 
1148
- const DIR_NAME$E='QuantumMetric';
1155
+ const DIR_NAME$F='QuantumMetric';
1149
1156
 
1150
- const DIR_NAME$D='RedditPixel';
1157
+ const DIR_NAME$E='RedditPixel';
1151
1158
 
1152
- const DIR_NAME$C='Sentry';
1159
+ const DIR_NAME$D='Sentry';
1153
1160
 
1154
- const DIR_NAME$B='SnapPixel';
1161
+ const DIR_NAME$C='SnapPixel';
1155
1162
 
1156
- const DIR_NAME$A='TVSquared';
1163
+ const DIR_NAME$B='TVSquared';
1157
1164
 
1158
- const DIR_NAME$z='VWO';
1165
+ const DIR_NAME$A='VWO';
1159
1166
 
1160
- const DIR_NAME$y='GA360';
1167
+ const DIR_NAME$z='GA360';
1161
1168
 
1162
- const DIR_NAME$x='Adroll';
1169
+ const DIR_NAME$y='Adroll';
1163
1170
 
1164
- const DIR_NAME$w='DCMFloodlight';
1171
+ const DIR_NAME$x='DCMFloodlight';
1165
1172
 
1166
- const DIR_NAME$v='Matomo';
1173
+ const DIR_NAME$w='Matomo';
1167
1174
 
1168
- const DIR_NAME$u='Vero';
1175
+ const DIR_NAME$v='Vero';
1169
1176
 
1170
- const DIR_NAME$t='Mouseflow';
1177
+ const DIR_NAME$u='Mouseflow';
1171
1178
 
1172
- const DIR_NAME$s='Rockerbox';
1179
+ const DIR_NAME$t='Rockerbox';
1173
1180
 
1174
- const DIR_NAME$r='ConvertFlow';
1181
+ const DIR_NAME$s='ConvertFlow';
1175
1182
 
1176
- const DIR_NAME$q='SnapEngage';
1183
+ const DIR_NAME$r='SnapEngage';
1177
1184
 
1178
- const DIR_NAME$p='LiveChat';
1185
+ const DIR_NAME$q='LiveChat';
1179
1186
 
1180
- const DIR_NAME$o='Shynet';
1187
+ const DIR_NAME$p='Shynet';
1181
1188
 
1182
- const DIR_NAME$n='Woopra';
1189
+ const DIR_NAME$o='Woopra';
1183
1190
 
1184
- const DIR_NAME$m='RollBar';
1191
+ const DIR_NAME$n='RollBar';
1185
1192
 
1186
- const DIR_NAME$l='QuoraPixel';
1193
+ const DIR_NAME$m='QuoraPixel';
1187
1194
 
1188
- const DIR_NAME$k='June';
1195
+ const DIR_NAME$l='June';
1189
1196
 
1190
- const DIR_NAME$j='Engage';
1197
+ const DIR_NAME$k='Engage';
1191
1198
 
1192
- const DIR_NAME$i='Iterable';
1199
+ const DIR_NAME$j='Iterable';
1193
1200
 
1194
- const DIR_NAME$h='YandexMetrica';
1201
+ const DIR_NAME$i='YandexMetrica';
1195
1202
 
1196
- const DIR_NAME$g='Refiner';
1203
+ const DIR_NAME$h='Refiner';
1197
1204
 
1198
- const DIR_NAME$f='Qualaroo';
1205
+ const DIR_NAME$g='Qualaroo';
1199
1206
 
1200
- const DIR_NAME$e='Podsights';
1207
+ const DIR_NAME$f='Podsights';
1201
1208
 
1202
- const DIR_NAME$d='Axeptio';
1209
+ const DIR_NAME$e='Axeptio';
1203
1210
 
1204
- const DIR_NAME$c='Satismeter';
1211
+ const DIR_NAME$d='Satismeter';
1205
1212
 
1206
- const DIR_NAME$b='MicrosoftClarity';
1213
+ const DIR_NAME$c='MicrosoftClarity';
1207
1214
 
1208
- const DIR_NAME$a='Sendinblue';
1215
+ const DIR_NAME$b='Sendinblue';
1209
1216
 
1210
- const DIR_NAME$9='Olark';
1217
+ const DIR_NAME$a='Olark';
1211
1218
 
1212
- const DIR_NAME$8='Lemnisk';
1219
+ const DIR_NAME$9='Lemnisk';
1213
1220
 
1214
- const DIR_NAME$7='TiktokAds';
1221
+ const DIR_NAME$8='TiktokAds';
1215
1222
 
1216
- const DIR_NAME$6='ActiveCampaign';
1223
+ const DIR_NAME$7='ActiveCampaign';
1217
1224
 
1218
- const DIR_NAME$5='Sprig';
1225
+ const DIR_NAME$6='Sprig';
1219
1226
 
1220
- const DIR_NAME$4='SpotifyPixel';
1227
+ const DIR_NAME$5='SpotifyPixel';
1221
1228
 
1222
- const DIR_NAME$3='CommandBar';
1229
+ const DIR_NAME$4='CommandBar';
1223
1230
 
1224
- const DIR_NAME$2='Ninetailed';
1231
+ const DIR_NAME$3='Ninetailed';
1225
1232
 
1226
- const DIR_NAME$1='Gainsight_PX';
1233
+ const DIR_NAME$2='Gainsight_PX';
1227
1234
 
1228
- const DIR_NAME='XPixel';
1235
+ const DIR_NAME$1='XPixel';
1236
+
1237
+ const DIR_NAME='Userpilot';
1229
1238
 
1230
1239
  // map of the destination display names to the destination directory names
1231
- const destDisplayNamesToFileNamesMap={[HS_DISPLAY_NAME]:DIR_NAME$W,[GA_DISPLAY_NAME]:DIR_NAME$12,[HOTJAR_DISPLAY_NAME]:DIR_NAME$X,[GOOGLEADS_DISPLAY_NAME]:DIR_NAME$$,[VWO_DISPLAY_NAME]:DIR_NAME$z,[GTM_DISPLAY_NAME]:DIR_NAME$Z,[BRAZE_DISPLAY_NAME]:DIR_NAME$1b,[INTERCOM_DISPLAY_NAME]:DIR_NAME$V,[KEEN_DISPLAY_NAME]:DIR_NAME$U,[KISSMETRICS_DISPLAY_NAME]:DIR_NAME$T,[CUSTOMERIO_DISPLAY_NAME]:DIR_NAME$16,[CHARTBEAT_DISPLAY_NAME]:DIR_NAME$19,[FACEBOOK_PIXEL_DISPLAY_NAME]:DIR_NAME$14,[LOTAME_DISPLAY_NAME]:DIR_NAME$P,[OPTIMIZELY_DISPLAY_NAME]:DIR_NAME$L,[BUGSNAG_DISPLAY_NAME]:DIR_NAME$1a,[FULLSTORY_DISPLAY_NAME]:DIR_NAME$13,[TVSQUARED_DISPLAY_NAME]:DIR_NAME$A,[GA4_DISPLAY_NAME]:DIR_NAME$11,[GA4_V2_DISPLAY_NAME]:DIR_NAME$10,[MOENGAGE_DISPLAY_NAME]:DIR_NAME$M,[AM_DISPLAY_NAME]:DIR_NAME$1e,[PENDO_DISPLAY_NAME]:DIR_NAME$K,[LYTICS_DISPLAY_NAME]:DIR_NAME$O,[APPCUES_DISPLAY_NAME]:DIR_NAME$1d,[POSTHOG_DISPLAY_NAME]:DIR_NAME$H,[KLAVIYO_DISPLAY_NAME]:DIR_NAME$S,[CLEVERTAP_DISPLAY_NAME]:DIR_NAME$18,[BINGADS_DISPLAY_NAME]:DIR_NAME$1c,[PINTEREST_TAG_DISPLAY_NAME]:DIR_NAME$J,[ADOBE_ANALYTICS_DISPLAY_NAME]:DIR_NAME$1f,[LINKEDIN_INSIGHT_TAG_DISPLAY_NAME]:DIR_NAME$Q,[REDDIT_PIXEL_DISPLAY_NAME]:DIR_NAME$D,[DRIP_DISPLAY_NAME]:DIR_NAME$15,[HEAP_DISPLAY_NAME]:DIR_NAME$Y,[CRITEO_DISPLAY_NAME]:DIR_NAME$17,[MP_DISPLAY_NAME]:DIR_NAME$N,[QUALTRICS_DISPLAY_NAME]:DIR_NAME$F,[PROFITWELL_DISPLAY_NAME]:DIR_NAME$G,[SENTRY_DISPLAY_NAME]:DIR_NAME$C,[QUANTUMMETRIC_DISPLAY_NAME]:DIR_NAME$E,[SNAP_PIXEL_DISPLAY_NAME]:DIR_NAME$B,[POST_AFFILIATE_PRO_DISPLAY_NAME]:DIR_NAME$I,[GOOGLE_OPTIMIZE_DISPLAY_NAME]:DIR_NAME$_,[LAUNCHDARKLY_DISPLAY_NAME]:DIR_NAME$R,[GA360_DISPLAY_NAME]:DIR_NAME$y,[ADROLL_DISPLAY_NAME]:DIR_NAME$x,[DCM_FLOODLIGHT_DISPLAY_NAME]:DIR_NAME$w,[MATOMO_DISPLAY_NAME]:DIR_NAME$v,[VERO_DISPLAY_NAME]:DIR_NAME$u,[MOUSEFLOW_DISPLAY_NAME]:DIR_NAME$t,[ROCKERBOX_DISPLAY_NAME]:DIR_NAME$s,[CONVERTFLOW_DISPLAY_NAME]:DIR_NAME$r,[SNAPENGAGE_DISPLAY_NAME]:DIR_NAME$q,[LIVECHAT_DISPLAY_NAME]:DIR_NAME$p,[SHYNET_DISPLAY_NAME]:DIR_NAME$o,[WOOPRA_DISPLAY_NAME]:DIR_NAME$n,[ROLLBAR_DISPLAY_NAME]:DIR_NAME$m,[QUORA_PIXEL_DISPLAY_NAME]:DIR_NAME$l,[JUNE_DISPLAY_NAME]:DIR_NAME$k,[ENGAGE_DISPLAY_NAME]:DIR_NAME$j,[ITERABLE_DISPLAY_NAME]:DIR_NAME$i,[YANDEX_METRICA_DISPLAY_NAME]:DIR_NAME$h,[REFINER_DISPLAY_NAME]:DIR_NAME$g,[QUALAROO_DISPLAY_NAME]:DIR_NAME$f,[PODSIGHTS_DISPLAY_NAME]:DIR_NAME$e,[AXEPTIO_DISPLAY_NAME]:DIR_NAME$d,[SATISMETER_DISPLAY_NAME]:DIR_NAME$c,[MICROSOFT_CLARITY_DISPLAY_NAME]:DIR_NAME$b,[SENDINBLUE_DISPLAY_NAME]:DIR_NAME$a,[OLARK_DISPLAY_NAME]:DIR_NAME$9,[LEMNISK_DISPLAY_NAME]:DIR_NAME$8,[TIKTOK_ADS_DISPLAY_NAME]:DIR_NAME$7,[ACTIVE_CAMPAIGN_DISPLAY_NAME]:DIR_NAME$6,[SPRIG_DISPLAY_NAME]:DIR_NAME$5,[SPOTIFYPIXEL_DISPLAY_NAME]:DIR_NAME$4,[COMMANDBAR_DISPLAY_NAME]:DIR_NAME$3,[NINETAILED_DISPLAY_NAME]:DIR_NAME$2,[GAINSIGHT_PX_DISPLAY_NAME]:DIR_NAME$1,[XPIXEL_DISPLAY_NAME]:DIR_NAME};
1240
+ const destDisplayNamesToFileNamesMap={[HS_DISPLAY_NAME]:DIR_NAME$X,[GA_DISPLAY_NAME]:DIR_NAME$13,[HOTJAR_DISPLAY_NAME]:DIR_NAME$Y,[GOOGLEADS_DISPLAY_NAME]:DIR_NAME$10,[VWO_DISPLAY_NAME]:DIR_NAME$A,[GTM_DISPLAY_NAME]:DIR_NAME$_,[BRAZE_DISPLAY_NAME]:DIR_NAME$1c,[INTERCOM_DISPLAY_NAME]:DIR_NAME$W,[KEEN_DISPLAY_NAME]:DIR_NAME$V,[KISSMETRICS_DISPLAY_NAME]:DIR_NAME$U,[CUSTOMERIO_DISPLAY_NAME]:DIR_NAME$17,[CHARTBEAT_DISPLAY_NAME]:DIR_NAME$1a,[FACEBOOK_PIXEL_DISPLAY_NAME]:DIR_NAME$15,[LOTAME_DISPLAY_NAME]:DIR_NAME$Q,[OPTIMIZELY_DISPLAY_NAME]:DIR_NAME$M,[BUGSNAG_DISPLAY_NAME]:DIR_NAME$1b,[FULLSTORY_DISPLAY_NAME]:DIR_NAME$14,[TVSQUARED_DISPLAY_NAME]:DIR_NAME$B,[GA4_DISPLAY_NAME]:DIR_NAME$12,[GA4_V2_DISPLAY_NAME]:DIR_NAME$11,[MOENGAGE_DISPLAY_NAME]:DIR_NAME$N,[AM_DISPLAY_NAME]:DIR_NAME$1f,[PENDO_DISPLAY_NAME]:DIR_NAME$L,[LYTICS_DISPLAY_NAME]:DIR_NAME$P,[APPCUES_DISPLAY_NAME]:DIR_NAME$1e,[POSTHOG_DISPLAY_NAME]:DIR_NAME$I,[KLAVIYO_DISPLAY_NAME]:DIR_NAME$T,[CLEVERTAP_DISPLAY_NAME]:DIR_NAME$19,[BINGADS_DISPLAY_NAME]:DIR_NAME$1d,[PINTEREST_TAG_DISPLAY_NAME]:DIR_NAME$K,[ADOBE_ANALYTICS_DISPLAY_NAME]:DIR_NAME$1g,[LINKEDIN_INSIGHT_TAG_DISPLAY_NAME]:DIR_NAME$R,[REDDIT_PIXEL_DISPLAY_NAME]:DIR_NAME$E,[DRIP_DISPLAY_NAME]:DIR_NAME$16,[HEAP_DISPLAY_NAME]:DIR_NAME$Z,[CRITEO_DISPLAY_NAME]:DIR_NAME$18,[MP_DISPLAY_NAME]:DIR_NAME$O,[QUALTRICS_DISPLAY_NAME]:DIR_NAME$G,[PROFITWELL_DISPLAY_NAME]:DIR_NAME$H,[SENTRY_DISPLAY_NAME]:DIR_NAME$D,[QUANTUMMETRIC_DISPLAY_NAME]:DIR_NAME$F,[SNAP_PIXEL_DISPLAY_NAME]:DIR_NAME$C,[POST_AFFILIATE_PRO_DISPLAY_NAME]:DIR_NAME$J,[GOOGLE_OPTIMIZE_DISPLAY_NAME]:DIR_NAME$$,[LAUNCHDARKLY_DISPLAY_NAME]:DIR_NAME$S,[GA360_DISPLAY_NAME]:DIR_NAME$z,[ADROLL_DISPLAY_NAME]:DIR_NAME$y,[DCM_FLOODLIGHT_DISPLAY_NAME]:DIR_NAME$x,[MATOMO_DISPLAY_NAME]:DIR_NAME$w,[VERO_DISPLAY_NAME]:DIR_NAME$v,[MOUSEFLOW_DISPLAY_NAME]:DIR_NAME$u,[ROCKERBOX_DISPLAY_NAME]:DIR_NAME$t,[CONVERTFLOW_DISPLAY_NAME]:DIR_NAME$s,[SNAPENGAGE_DISPLAY_NAME]:DIR_NAME$r,[LIVECHAT_DISPLAY_NAME]:DIR_NAME$q,[SHYNET_DISPLAY_NAME]:DIR_NAME$p,[WOOPRA_DISPLAY_NAME]:DIR_NAME$o,[ROLLBAR_DISPLAY_NAME]:DIR_NAME$n,[QUORA_PIXEL_DISPLAY_NAME]:DIR_NAME$m,[JUNE_DISPLAY_NAME]:DIR_NAME$l,[ENGAGE_DISPLAY_NAME]:DIR_NAME$k,[ITERABLE_DISPLAY_NAME]:DIR_NAME$j,[YANDEX_METRICA_DISPLAY_NAME]:DIR_NAME$i,[REFINER_DISPLAY_NAME]:DIR_NAME$h,[QUALAROO_DISPLAY_NAME]:DIR_NAME$g,[PODSIGHTS_DISPLAY_NAME]:DIR_NAME$f,[AXEPTIO_DISPLAY_NAME]:DIR_NAME$e,[SATISMETER_DISPLAY_NAME]:DIR_NAME$d,[MICROSOFT_CLARITY_DISPLAY_NAME]:DIR_NAME$c,[SENDINBLUE_DISPLAY_NAME]:DIR_NAME$b,[OLARK_DISPLAY_NAME]:DIR_NAME$a,[LEMNISK_DISPLAY_NAME]:DIR_NAME$9,[TIKTOK_ADS_DISPLAY_NAME]:DIR_NAME$8,[ACTIVE_CAMPAIGN_DISPLAY_NAME]:DIR_NAME$7,[SPRIG_DISPLAY_NAME]:DIR_NAME$6,[SPOTIFYPIXEL_DISPLAY_NAME]:DIR_NAME$5,[COMMANDBAR_DISPLAY_NAME]:DIR_NAME$4,[NINETAILED_DISPLAY_NAME]:DIR_NAME$3,[GAINSIGHT_PX_DISPLAY_NAME]:DIR_NAME$2,[XPIXEL_DISPLAY_NAME]:DIR_NAME$1,[USERPILOT_DISPLAY_NAME]:DIR_NAME};
1232
1241
 
1233
1242
  /**
1234
1243
  * Determines if the destination SDK code is evaluated
@@ -2996,10 +3005,12 @@ const RESERVED_ELEMENTS=['id','anonymous_id','user_id','sent_at','timestamp','re
2996
3005
  * @returns boolean
2997
3006
  */const isPositiveInteger=num=>isNumber(num)&&num>=0&&Number.isInteger(num);
2998
3007
 
2999
- const MIN_SESSION_ID_LENGTH=10;/**
3000
- * A function to validate current session and return true/false depending on that
3008
+ const MIN_SESSION_ID_LENGTH=10;const isCutOffTimeExceeded=sessionInfo=>{const{cutOff}=sessionInfo;const timestamp=Date.now();return Boolean(cutOff?.enabled&&cutOff.expiresAt&&timestamp>cutOff.expiresAt);};/**
3009
+ * A function to validate whether the current auto tracking session has expired or not.
3010
+ * It checks for the current session expiry and the cut off time expiry.
3011
+ * @param sessionInfo session info
3001
3012
  * @returns boolean
3002
- */const hasSessionExpired=expiresAt=>{const timestamp=Date.now();return Boolean(!expiresAt||timestamp>expiresAt);};/**
3013
+ */const hasSessionExpired=sessionInfo=>{const isCurrentSessionExpired=Boolean(!sessionInfo.expiresAt||Date.now()>sessionInfo.expiresAt);return isCurrentSessionExpired||isCutOffTimeExceeded(sessionInfo);};/**
3003
3014
  * A function to generate session id
3004
3015
  * @returns number
3005
3016
  */const generateSessionId=()=>Date.now();/**
@@ -3007,13 +3018,13 @@ const MIN_SESSION_ID_LENGTH=10;/**
3007
3018
  * @param {number} sessionId
3008
3019
  * @param logger logger
3009
3020
  * @returns
3010
- */const isManualSessionIdValid=(sessionId,logger)=>{if(!sessionId||!isPositiveInteger(sessionId)||!hasMinLength(MIN_SESSION_ID_LENGTH,sessionId)){logger.warn(INVALID_SESSION_ID_WARNING(USER_SESSION_MANAGER,sessionId,MIN_SESSION_ID_LENGTH));return false;}return true;};/**
3021
+ */const isManualSessionIdValid=(sessionId,logger)=>{if(!sessionId||!isPositiveInteger(sessionId)||!hasMinLength(MIN_SESSION_ID_LENGTH,sessionId)){logger.warn(INVALID_SESSION_ID_WARNING(USER_SESSION_MANAGER,sessionId,MIN_SESSION_ID_LENGTH));return false;}return true;};const getCutOffExpirationTimestamp=cutOff=>{if(!cutOff?.enabled){return undefined;}return cutOff.expiresAt??(isPositiveInteger(cutOff.duration)?Date.now()+cutOff.duration:undefined);};/**
3011
3022
  * A function to generate new auto tracking session
3012
- * @param sessionTimeout current timestamp
3023
+ * @param sessionInfo session info
3013
3024
  * @returns SessionInfo
3014
- */const generateAutoTrackingSession=sessionTimeout=>{const timestamp=Date.now();const timeout=sessionTimeout||DEFAULT_SESSION_TIMEOUT_MS;return {id:timestamp,// set the current timestamp
3025
+ */const generateAutoTrackingSession=sessionInfo=>{const{timeout,cutOff}=sessionInfo;const timestamp=Date.now();return {id:timestamp,// set the current timestamp
3015
3026
  expiresAt:timestamp+timeout,// set the expiry time of the session
3016
- timeout,sessionStart:undefined,autoTrack:true};};/**
3027
+ timeout,autoTrack:true,...(cutOff&&{cutOff})};};/**
3017
3028
  * A function to generate new manual tracking session
3018
3029
  * @param id Provided sessionId
3019
3030
  * @param logger Logger module
@@ -3135,16 +3146,19 @@ class UserSessionManager{constructor(pluginsManager,storeManager,httpClient,erro
3135
3146
  * Initialize User session with values from storage
3136
3147
  */init(){this.syncStorageDataToState();// Register the effect to sync with storage
3137
3148
  this.registerEffects();}syncStorageDataToState(){this.migrateStorageIfNeeded();this.migrateDataFromPreviousStorage();// get the values from storage and set it again
3138
- this.setUserId(this.getUserId());this.setUserTraits(this.getUserTraits());this.setGroupId(this.getGroupId());this.setGroupTraits(this.getGroupTraits());const{externalAnonymousIdCookieName,anonymousIdOptions}=state.loadOptions.value;let externalAnonymousId;if(isDefinedAndNotNull(externalAnonymousIdCookieName)&&typeof externalAnonymousIdCookieName==='string'){externalAnonymousId=this.getExternalAnonymousIdByCookieName(externalAnonymousIdCookieName);}this.setAnonymousId(externalAnonymousId??this.getAnonymousId(anonymousIdOptions));this.setAuthToken(this.getAuthToken());this.setInitialReferrerInfo();this.configureSessionTracking();}configureSessionTracking(){let sessionInfo=this.getSessionInfo();if(this.isPersistenceEnabledForStorageEntry('sessionInfo')){const configuredSessionTrackingInfo=this.getConfiguredSessionTrackingInfo();const initialSessionInfo=sessionInfo??defaultSessionConfiguration;sessionInfo={...initialSessionInfo,...configuredSessionTrackingInfo,// If manualTrack is set to true in the storage, then autoTrack should be false
3139
- autoTrack:configuredSessionTrackingInfo.autoTrack&&initialSessionInfo.manualTrack!==true};// If both autoTrack and manualTrack are disabled, reset the session info to default values
3140
- if(!sessionInfo.autoTrack&&sessionInfo.manualTrack!==true){sessionInfo=DEFAULT_USER_SESSION_VALUES.sessionInfo;}}else {sessionInfo=DEFAULT_USER_SESSION_VALUES.sessionInfo;}state.session.sessionInfo.value=sessionInfo;// If auto session tracking is enabled start the session tracking
3149
+ this.setUserId(this.getUserId());this.setUserTraits(this.getUserTraits());this.setGroupId(this.getGroupId());this.setGroupTraits(this.getGroupTraits());const{externalAnonymousIdCookieName,anonymousIdOptions}=state.loadOptions.value;let externalAnonymousId;if(isDefinedAndNotNull(externalAnonymousIdCookieName)&&typeof externalAnonymousIdCookieName==='string'){externalAnonymousId=this.getExternalAnonymousIdByCookieName(externalAnonymousIdCookieName);}this.setAnonymousId(externalAnonymousId??this.getAnonymousId(anonymousIdOptions));this.setAuthToken(this.getAuthToken());this.setInitialReferrerInfo();this.configureSessionTracking();}configureSessionTracking(){let sessionInfo;if(this.isPersistenceEnabledForStorageEntry('sessionInfo')){const configuredSessionTrackingInfo=this.getConfiguredSessionTrackingInfo();const initialSessionInfo=this.getSessionInfo()??DEFAULT_USER_SESSION_VALUES.sessionInfo;// Merge the session info from the storage and the configuration
3150
+ sessionInfo={// If manualTrack is set to true in the storage, then do not enable auto tracking even if configured.
3151
+ // Once manual tracking ends (endSession is called), auto tracking will be enabled in the next SDK run.
3152
+ autoTrack:configuredSessionTrackingInfo.autoTrack&&initialSessionInfo.manualTrack!==true,timeout:configuredSessionTrackingInfo.timeout,manualTrack:initialSessionInfo.manualTrack,expiresAt:initialSessionInfo.expiresAt,id:initialSessionInfo.id,sessionStart:initialSessionInfo.sessionStart};// If both autoTrack and manualTrack are disabled, reset the session info to default values
3153
+ if(!sessionInfo.autoTrack&&sessionInfo.manualTrack!==true){sessionInfo=DEFAULT_USER_SESSION_VALUES.sessionInfo;}else if(configuredSessionTrackingInfo.cutOff?.enabled===true){sessionInfo.cutOff={enabled:true,duration:configuredSessionTrackingInfo.cutOff.duration,expiresAt:initialSessionInfo.cutOff?.expiresAt};}}else {sessionInfo=DEFAULT_USER_SESSION_VALUES.sessionInfo;}state.session.sessionInfo.value=sessionInfo;// If auto session tracking is enabled start the session tracking
3141
3154
  if(state.session.sessionInfo.value.autoTrack){this.startOrRenewAutoTracking(state.session.sessionInfo.value);}}setInitialReferrerInfo(){const persistedInitialReferrer=this.getInitialReferrer();const persistedInitialReferringDomain=this.getInitialReferringDomain();if(persistedInitialReferrer&&persistedInitialReferringDomain){this.setInitialReferrer(persistedInitialReferrer);this.setInitialReferringDomain(persistedInitialReferringDomain);}else {const initialReferrer=persistedInitialReferrer||getReferrer();this.setInitialReferrer(initialReferrer);this.setInitialReferringDomain(getReferringDomain(initialReferrer));}}isPersistenceEnabledForStorageEntry(entryName){return isStorageTypeValidForStoringData(state.storage.entries.value[entryName]?.type);}migrateDataFromPreviousStorage(){const entries=state.storage.entries.value;const storageTypesForMigration=[COOKIE_STORAGE,LOCAL_STORAGE,SESSION_STORAGE];Object.keys(entries).forEach(entry=>{const key=entry;const currentStorage=entries[key]?.type;const curStore=this.storeManager?.getStore(storageClientDataStoreNameMap[currentStorage]);if(curStore){storageTypesForMigration.forEach(storage=>{const store=this.storeManager?.getStore(storageClientDataStoreNameMap[storage]);if(store&&storage!==currentStorage){const value=store.get(COOKIE_KEYS[key]);if(isDefinedNotNullAndNotEmptyString(value)){curStore.set(COOKIE_KEYS[key],value);}store.remove(COOKIE_KEYS[key]);}});}});}migrateStorageIfNeeded(stores){if(!state.storage.migrate.value){return;}let storesToMigrate=stores??[];if(storesToMigrate.length===0){const persistentStoreNames=[CLIENT_DATA_STORE_COOKIE,CLIENT_DATA_STORE_LS,CLIENT_DATA_STORE_SESSION];persistentStoreNames.forEach(storeName=>{const store=this.storeManager?.getStore(storeName);if(store){storesToMigrate.push(store);}});}Object.keys(COOKIE_KEYS).forEach(storageKey=>{const storageEntry=COOKIE_KEYS[storageKey];storesToMigrate.forEach(store=>{const migratedVal=this.pluginsManager?.invokeSingle('storage.migrate',storageEntry,store.engine,this.errorHandler,this.logger);// Skip setting the value if it is null or undefined
3142
3155
  // as those values indicate there is no need for migration or
3143
3156
  // migration failed
3144
- if(!isNullOrUndefined(migratedVal)){store.set(storageEntry,migratedVal);}});});}getConfiguredSessionTrackingInfo(){let autoTrack=state.loadOptions.value.sessions?.autoTrack!==false;// Do not validate any further if autoTrack is disabled
3157
+ if(!isNullOrUndefined(migratedVal)){store.set(storageEntry,migratedVal);}});});}getConfiguredSessionTrackingInfo(){let autoTrack=state.loadOptions.value.sessions.autoTrack!==false;// Do not validate any further if autoTrack is disabled
3145
3158
  if(!autoTrack){return {autoTrack};}let timeout;const configuredSessionTimeout=state.loadOptions.value.sessions?.timeout;if(!isPositiveInteger(configuredSessionTimeout)){this.logger.warn(TIMEOUT_NOT_NUMBER_WARNING(USER_SESSION_MANAGER,configuredSessionTimeout,DEFAULT_SESSION_TIMEOUT_MS));timeout=DEFAULT_SESSION_TIMEOUT_MS;}else {timeout=configuredSessionTimeout;}if(timeout===0){this.logger.warn(TIMEOUT_ZERO_WARNING(USER_SESSION_MANAGER));autoTrack=false;}// In case user provides a timeout value greater than 0 but less than 10 seconds SDK will show a warning
3146
3159
  // and will proceed with it
3147
- if(timeout>0&&timeout<MIN_SESSION_TIMEOUT_MS){this.logger.warn(TIMEOUT_NOT_RECOMMENDED_WARNING(USER_SESSION_MANAGER,timeout,MIN_SESSION_TIMEOUT_MS));}return {timeout,autoTrack};}/**
3160
+ if(timeout>0&&timeout<MIN_SESSION_TIMEOUT_MS){this.logger.warn(TIMEOUT_NOT_RECOMMENDED_WARNING(USER_SESSION_MANAGER,timeout,MIN_SESSION_TIMEOUT_MS));}const cutOff=this.getCutOffInfo(timeout);return {timeout,autoTrack,cutOff};}getCutOffInfo(sessionTimeout){const cutOff=state.loadOptions.value.sessions.cutOff;let cutOffDuration;let cutOffEnabled=false;if(cutOff.enabled===true){cutOffDuration=cutOff.duration;cutOffEnabled=true;if(!isPositiveInteger(cutOffDuration)){this.logger.warn(CUT_OFF_DURATION_NOT_NUMBER_WARNING(USER_SESSION_MANAGER,cutOffDuration,DEFAULT_SESSION_CUT_OFF_DURATION_MS));// Use the default value for cut off duration
3161
+ cutOffDuration=DEFAULT_SESSION_CUT_OFF_DURATION_MS;}else if(cutOffDuration<sessionTimeout){this.logger.warn(CUT_OFF_DURATION_LESS_THAN_TIMEOUT_WARNING(USER_SESSION_MANAGER,cutOffDuration,sessionTimeout));cutOffEnabled=false;}}return {enabled:cutOffEnabled,duration:cutOffDuration};}/**
3148
3162
  * Handles error
3149
3163
  * @param error The error object
3150
3164
  */onError(error,customMessage){this.errorHandler.onError(error,USER_SESSION_MANAGER,customMessage);}/**
@@ -3214,7 +3228,7 @@ this.migrateStorageIfNeeded([store]);const storageKey=entries[sessionKey]?.key;r
3214
3228
  */getAuthToken(){return this.getEntryValue('authToken');}/**
3215
3229
  * If session is active it returns the sessionId
3216
3230
  * @returns
3217
- */getSessionId(){const sessionInfo=this.getSessionInfo()??DEFAULT_USER_SESSION_VALUES.sessionInfo;if(sessionInfo.autoTrack&&!hasSessionExpired(sessionInfo.expiresAt)||sessionInfo.manualTrack){return sessionInfo.id??null;}return null;}/**
3231
+ */getSessionId(){const sessionInfo=this.getSessionInfo()??DEFAULT_USER_SESSION_VALUES.sessionInfo;if(sessionInfo.autoTrack&&!hasSessionExpired(sessionInfo)||sessionInfo.manualTrack){return sessionInfo.id??null;}return null;}/**
3218
3232
  * A function to keep the session information up to date in the state
3219
3233
  * before using it for building event payloads.
3220
3234
  */refreshSession(){let sessionInfo=this.getSessionInfo()??DEFAULT_USER_SESSION_VALUES.sessionInfo;if(sessionInfo.autoTrack||sessionInfo.manualTrack){if(sessionInfo.autoTrack){this.startOrRenewAutoTracking(sessionInfo);sessionInfo=state.session.sessionInfo.value;}// Note that if sessionStart is false, then it's an active session.
@@ -3232,8 +3246,8 @@ this.syncValueToStorage('sessionInfo',sessionInfo);}}/**
3232
3246
  * @param resetAnonymousId
3233
3247
  * @param noNewSessionStart
3234
3248
  * @returns
3235
- */reset(resetAnonymousId,noNewSessionStart){const{session}=state;const{manualTrack,autoTrack}=session.sessionInfo.value;r(()=>{session.userId.value=DEFAULT_USER_SESSION_VALUES.userId;session.userTraits.value=DEFAULT_USER_SESSION_VALUES.userTraits;session.groupId.value=DEFAULT_USER_SESSION_VALUES.groupId;session.groupTraits.value=DEFAULT_USER_SESSION_VALUES.groupTraits;session.authToken.value=DEFAULT_USER_SESSION_VALUES.authToken;if(resetAnonymousId===true){// This will generate a new anonymous ID
3236
- this.setAnonymousId();}if(noNewSessionStart){return;}if(autoTrack){session.sessionInfo.value=DEFAULT_USER_SESSION_VALUES.sessionInfo;this.startOrRenewAutoTracking(session.sessionInfo.value);}else if(manualTrack){this.startManualTrackingInternal();}});}/**
3249
+ */reset(resetAnonymousId,noNewSessionStart){const{session}=state;const{manualTrack,autoTrack,timeout,cutOff}=session.sessionInfo.value;r(()=>{session.userId.value=DEFAULT_USER_SESSION_VALUES.userId;session.userTraits.value=DEFAULT_USER_SESSION_VALUES.userTraits;session.groupId.value=DEFAULT_USER_SESSION_VALUES.groupId;session.groupTraits.value=DEFAULT_USER_SESSION_VALUES.groupTraits;session.authToken.value=DEFAULT_USER_SESSION_VALUES.authToken;if(resetAnonymousId===true){// This will generate a new anonymous ID
3250
+ this.setAnonymousId();}if(noNewSessionStart){return;}if(autoTrack){const sessionInfo={...DEFAULT_USER_SESSION_VALUES.sessionInfo,timeout};if(cutOff){sessionInfo.cutOff={enabled:cutOff.enabled,duration:cutOff.duration};}session.sessionInfo.value=sessionInfo;this.startOrRenewAutoTracking(session.sessionInfo.value);}else if(manualTrack){this.startManualTrackingInternal();}});}/**
3237
3251
  * Set user Id
3238
3252
  * @param userId
3239
3253
  */setUserId(userId){state.session.userId.value=this.isPersistenceEnabledForStorageEntry('userId')&&userId?userId:DEFAULT_USER_SESSION_VALUES.userId;}/**
@@ -3253,8 +3267,11 @@ this.setAnonymousId();}if(noNewSessionStart){return;}if(autoTrack){session.sessi
3253
3267
  * @param {String} referringDomain
3254
3268
  */setInitialReferringDomain(referringDomain){state.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry('initialReferringDomain')&&referringDomain?referringDomain:DEFAULT_USER_SESSION_VALUES.initialReferringDomain;}/**
3255
3269
  * A function to check for existing session details and depending on that create a new session
3256
- */startOrRenewAutoTracking(sessionInfo){if(hasSessionExpired(sessionInfo.expiresAt)){state.session.sessionInfo.value=generateAutoTrackingSession(sessionInfo.timeout);}else {const timestamp=Date.now();const timeout=sessionInfo.timeout;state.session.sessionInfo.value=mergeDeepRight(sessionInfo,{expiresAt:timestamp+timeout// set the expiry time of the session
3257
- });}}/**
3270
+ */startOrRenewAutoTracking(sessionInfo){let finalSessionInfo=sessionInfo;if(hasSessionExpired(sessionInfo)){finalSessionInfo=generateAutoTrackingSession(sessionInfo);}else {const timestamp=Date.now();const timeout=sessionInfo.timeout;// Set the expiry time of the session
3271
+ finalSessionInfo.expiresAt=timestamp+timeout;}// Reset cut off expiry timestamp if it is exceeded
3272
+ if(isCutOffTimeExceeded(finalSessionInfo)){finalSessionInfo.cutOff.expiresAt=undefined;}// If cut off is active, set or retain the expiry time
3273
+ if(finalSessionInfo.cutOff){const cutOffExpiresAt=getCutOffExpirationTimestamp(finalSessionInfo.cutOff);finalSessionInfo.cutOff.expiresAt=cutOffExpiresAt;}// Update the session info in the state
3274
+ state.session.sessionInfo.value=finalSessionInfo;}/**
3258
3275
  * A function method to start a manual session
3259
3276
  * @param {number} id session identifier
3260
3277
  * @returns