@rudderstack/analytics-js 3.7.5 → 3.7.7

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.
@@ -370,7 +370,7 @@ payload.groupId=tryStringify(payload.groupId);if(isObjectLiteralAndNotNull(paylo
370
370
 
371
371
  const CAPABILITIES_MANAGER='CapabilitiesManager';const CONFIG_MANAGER='ConfigManager';const EVENT_MANAGER='EventManager';const PLUGINS_MANAGER='PluginsManager';const USER_SESSION_MANAGER='UserSessionManager';const ERROR_HANDLER='ErrorHandler';const PLUGIN_ENGINE='PluginEngine';const STORE_MANAGER='StoreManager';const READY_API='readyApi';const EVENT_REPOSITORY='EventRepository';const EXTERNAL_SRC_LOADER='ExternalSrcLoader';const HTTP_CLIENT='HttpClient';const RS_APP='RudderStackApplication';const ANALYTICS_CORE='AnalyticsCore';
372
372
 
373
- const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.7.5';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';
373
+ const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.7.7';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';
374
374
 
375
375
  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';
376
376
 
@@ -575,35 +575,14 @@ processRawPlugins(callback){callback(this.plugins);this.cache={};}invoke(extPoin
575
575
  extensionPointName=extensionPointName.replace(/(^!|!$)/g,'');if(!extensionPointName){throw new Error(PLUGIN_EXT_POINT_INVALID_ERROR);}const extensionPointNameParts=extensionPointName.split('.');extensionPointNameParts.pop();const pluginMethodPath=extensionPointNameParts.join('.');const pluginsToInvoke=allowMultiple?this.getPlugins(extensionPointName):[this.getPlugins(extensionPointName)[0]];return pluginsToInvoke.map(plugin=>{const method=getValueByPath(plugin,extensionPointName);if(!isFunction(method)||noCall){return method;}try{return method.apply(getValueByPath(plugin,pluginMethodPath),args);}catch(err){// When a plugin failed, doesn't break the app
576
576
  if(throws){throw err;}else {this.logger?.error(PLUGIN_INVOCATION_ERROR(PLUGIN_ENGINE,extensionPointName,plugin.name),err);}}return null;});}invokeSingle(extPoint,...args){return this.invoke(extPoint,false,...args)[0];}invokeMultiple(extPoint,...args){return this.invoke(extPoint,true,...args);}}const defaultPluginEngine=new PluginEngine({throws:true},defaultLogger);
577
577
 
578
- const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const UNHANDLEDEXCEPTION_FOR_NON_ERROR_OBJECT='unhandledException handler received a non-error';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX,UNHANDLEDEXCEPTION_FOR_NON_ERROR_OBJECT];
578
+ const LOAD_ORIGIN='RS_JS_SDK';
579
579
 
580
580
  /**
581
581
  * Utility method to normalise errors
582
582
  */const processError=error=>{let errorMessage;try{if(isString(error)){errorMessage=error;}else if(error instanceof Error){errorMessage=error.message;}else if(error instanceof ErrorEvent){errorMessage=error.message;}else {errorMessage=error.message?error.message:stringifyWithoutCircular(error);}}catch(e){errorMessage=`Unknown error: ${e.message}`;}return errorMessage;};const getNormalizedErrorForUnhandledError=error=>{try{if(error instanceof Error||error instanceof ErrorEvent||error instanceof PromiseRejectionEvent&&error.reason){return error;}// TODO: remove this block once all device mode integrations start using the v3 script loader module (TS)
583
- // if (error instanceof Event) {
584
- // const eventTarget = error.target as ErrorTarget;
585
- // // Discard all the non-script loading errors
586
- // if (eventTarget && eventTarget.localName !== 'script') {
587
- // return undefined;
588
- // }
589
- // // Discard script errors that are not originated at SDK or from native SDKs
590
- // if (
591
- // eventTarget?.dataset &&
592
- // (eventTarget.dataset.loader !== LOAD_ORIGIN ||
593
- // eventTarget.dataset.isnonnativesdk !== 'true')
594
- // ) {
595
- // return undefined;
596
- // }
597
- // const errorMessage = `Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`;
598
- // return Object.create(error, {
599
- // message: { value: errorMessage },
600
- // });
601
- // }
602
- return undefined;}catch(e){return e;}};/**
603
- * A function to determine whether the error should be promoted to notify or not
604
- * @param {Error} error
605
- * @returns
606
- */const isAllowedToBeNotified=error=>{if((error instanceof Error||error instanceof ErrorEvent)&&error.message){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>error.message.includes(e));}if(error instanceof PromiseRejectionEvent&&typeof error.reason==='string'){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>error.reason.includes(e));}return true;};
583
+ if(error instanceof Event){const eventTarget=error.target;// Discard all the non-script loading errors
584
+ if(eventTarget&&eventTarget.localName!=='script'){return undefined;}// Discard script errors that are not originated at SDK or from native SDKs
585
+ if(eventTarget?.dataset&&(eventTarget.dataset.loader!==LOAD_ORIGIN||eventTarget.dataset.isnonnativesdk!=='true')){return undefined;}const errorMessage=`Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`;return Object.create(error,{message:{value:errorMessage}});}return error;}catch(e){return e;}};
607
586
 
608
587
  /**
609
588
  * A service to handle errors
@@ -624,7 +603,7 @@ breadcrumb,this.logger,state);}catch(err){this.onError(err,ERROR_HANDLER,'errorR
624
603
  * Send handled errors to external error monitoring service via a plugin
625
604
  *
626
605
  * @param {Error} error Error instance from handled error
627
- */notifyError(error,errorState){if(this.pluginEngine&&this.httpClient&&isAllowedToBeNotified(error)){try{this.pluginEngine.invokeSingle('errorReporting.notify',this.pluginEngine,// deprecated parameter
606
+ */notifyError(error,errorState){if(this.pluginEngine&&this.httpClient){try{this.pluginEngine.invokeSingle('errorReporting.notify',this.pluginEngine,// deprecated parameter
628
607
  this.errReportingClient,// deprecated parameter
629
608
  error,state,this.logger,this.httpClient,errorState);}catch(err){// Not calling onError here as we don't want to go into infinite loop
630
609
  this.logger?.error(NOTIFY_FAILURE_ERROR(ERROR_HANDLER),err);}}}}const defaultErrorHandler=new ErrorHandler(defaultLogger,defaultPluginEngine);
@@ -913,37 +892,39 @@ if(!cmpConfig?.consents){return true;}const configuredConsents=cmpConfig.consent
913
892
  // the configured resolution strategy
914
893
  const matchPredicate=consent=>allowedConsentIds.includes(consent);switch(resolutionStrategy){case'or':return configuredConsents.some(matchPredicate)||configuredConsents.length===0;case'and':default:return configuredConsents.every(matchPredicate);}}catch(err){errorHandler?.onError(err,CUSTOM_CONSENT_MANAGER_PLUGIN,DESTINATION_CONSENT_STATUS_ERROR$2);return true;}}}});
915
894
 
916
- const DIR_NAME$1d='AdobeAnalytics';const DISPLAY_NAME$1d='Adobe Analytics';
895
+ const DIR_NAME$1e='AdobeAnalytics';const DISPLAY_NAME$1e='Adobe Analytics';
896
+
897
+ const DIR_NAME$1d='Amplitude';const DISPLAY_NAME$1d='Amplitude';
917
898
 
918
- const DIR_NAME$1c='Amplitude';const DISPLAY_NAME$1c='Amplitude';
899
+ const DIR_NAME$1c='Appcues';const DISPLAY_NAME$1c='Appcues';
919
900
 
920
- const DIR_NAME$1b='Appcues';const DISPLAY_NAME$1b='Appcues';
901
+ const DIR_NAME$1b='BingAds';const DISPLAY_NAME$1b='Bing Ads';
921
902
 
922
- const DIR_NAME$1a='BingAds';const DISPLAY_NAME$1a='Bing Ads';
903
+ const DIR_NAME$1a='Braze';const DISPLAY_NAME$1a='Braze';
923
904
 
924
- const DIR_NAME$19='Braze';const DISPLAY_NAME$19='Braze';
905
+ const DIR_NAME$19='Bugsnag';const DISPLAY_NAME$19='Bugsnag';
925
906
 
926
- const DIR_NAME$18='Bugsnag';const DISPLAY_NAME$18='Bugsnag';
907
+ const DIR_NAME$18='Chartbeat';const DISPLAY_NAME$18='Chartbeat';
927
908
 
928
- const DIR_NAME$17='Chartbeat';const DISPLAY_NAME$17='Chartbeat';
909
+ const DIR_NAME$17='Clevertap';const DISPLAY_NAME$17='CleverTap';
929
910
 
930
- const DIR_NAME$16='Clevertap';const DISPLAY_NAME$16='CleverTap';
911
+ const DIR_NAME$16='Comscore';const DISPLAY_NAME$16='Comscore';
931
912
 
932
- const DIR_NAME$15='Comscore';const DISPLAY_NAME$15='Comscore';
913
+ const DIR_NAME$15='Criteo';const DISPLAY_NAME$15='Criteo';
933
914
 
934
- const DIR_NAME$14='Criteo';const DISPLAY_NAME$14='Criteo';
915
+ const DIR_NAME$14='CustomerIO';const DISPLAY_NAME$14='Customer IO';
935
916
 
936
- const DIR_NAME$13='CustomerIO';const DISPLAY_NAME$13='Customer IO';
917
+ const DIR_NAME$13='Drip';const DISPLAY_NAME$13='Drip';
937
918
 
938
- const DIR_NAME$12='Drip';const DISPLAY_NAME$12='Drip';
919
+ const DIR_NAME$12='FacebookPixel';const DISPLAY_NAME$12='Facebook Pixel';
939
920
 
940
- const DIR_NAME$11='FacebookPixel';const DISPLAY_NAME$11='Facebook Pixel';
921
+ const DIR_NAME$11='Fullstory';const DISPLAY_NAME$11='Fullstory';
941
922
 
942
- const DIR_NAME$10='Fullstory';const DISPLAY_NAME$10='Fullstory';
923
+ const DIR_NAME$10='GA';const DISPLAY_NAME$10='Google Analytics';
943
924
 
944
- const DIR_NAME$$='GA';const DISPLAY_NAME$$='Google Analytics';
925
+ const DIR_NAME$$='GA4';const DISPLAY_NAME$$='Google Analytics 4 (GA4)';
945
926
 
946
- const DIR_NAME$_='GA4';const DISPLAY_NAME$_='Google Analytics 4 (GA4)';
927
+ const DIR_NAME$_='GA4_V2';const DISPLAY_NAME$_='Google Analytics 4 (GA4) V2';
947
928
 
948
929
  const DIR_NAME$Z='GoogleAds';const DISPLAY_NAME$Z='Google Ads';
949
930
 
@@ -1070,7 +1051,7 @@ const DIR_NAME$1='CommandBar';const DISPLAY_NAME$1='CommandBar';
1070
1051
  const DIR_NAME='Ninetailed';const DISPLAY_NAME='Ninetailed';
1071
1052
 
1072
1053
  // map of the destination display names to the destination directory names
1073
- const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$U]:DIR_NAME$U,[DISPLAY_NAME$$]:DIR_NAME$$,[DISPLAY_NAME$V]:DIR_NAME$V,[DISPLAY_NAME$Z]:DIR_NAME$Z,[DISPLAY_NAME$x]:DIR_NAME$x,[DISPLAY_NAME$X]:DIR_NAME$X,[DISPLAY_NAME$19]:DIR_NAME$19,[DISPLAY_NAME$T]:DIR_NAME$T,[DISPLAY_NAME$S]:DIR_NAME$S,[DISPLAY_NAME$R]:DIR_NAME$R,[DISPLAY_NAME$13]:DIR_NAME$13,[DISPLAY_NAME$17]:DIR_NAME$17,[DISPLAY_NAME$15]:DIR_NAME$15,[DISPLAY_NAME$11]:DIR_NAME$11,[DISPLAY_NAME$N]:DIR_NAME$N,[DISPLAY_NAME$J]:DIR_NAME$J,[DISPLAY_NAME$18]:DIR_NAME$18,[DISPLAY_NAME$10]:DIR_NAME$10,[DISPLAY_NAME$y]:DIR_NAME$y,[DISPLAY_NAME$_]:DIR_NAME$_,[DISPLAY_NAME$K]:DIR_NAME$K,[DISPLAY_NAME$1c]:DIR_NAME$1c,[DISPLAY_NAME$I]:DIR_NAME$I,[DISPLAY_NAME$M]:DIR_NAME$M,[DISPLAY_NAME$1b]:DIR_NAME$1b,[DISPLAY_NAME$F]:DIR_NAME$F,[DISPLAY_NAME$Q]:DIR_NAME$Q,[DISPLAY_NAME$16]:DIR_NAME$16,[DISPLAY_NAME$1a]:DIR_NAME$1a,[DISPLAY_NAME$H]:DIR_NAME$H,[DISPLAY_NAME$1d]:DIR_NAME$1d,[DISPLAY_NAME$O]:DIR_NAME$O,[DISPLAY_NAME$B]:DIR_NAME$B,[DISPLAY_NAME$12]:DIR_NAME$12,[DISPLAY_NAME$W]:DIR_NAME$W,[DISPLAY_NAME$14]:DIR_NAME$14,[DISPLAY_NAME$L]:DIR_NAME$L,[DISPLAY_NAME$D]:DIR_NAME$D,[DISPLAY_NAME$E]:DIR_NAME$E,[DISPLAY_NAME$A]:DIR_NAME$A,[DISPLAY_NAME$C]:DIR_NAME$C,[DISPLAY_NAME$z]:DIR_NAME$z,[DISPLAY_NAME$G]:DIR_NAME$G,[DISPLAY_NAME$Y]:DIR_NAME$Y,[DISPLAY_NAME$P]:DIR_NAME$P,[DISPLAY_NAME$w]:DIR_NAME$w,[DISPLAY_NAME$v]:DIR_NAME$v,[DISPLAY_NAME$u]:DIR_NAME$u,[DISPLAY_NAME$t]:DIR_NAME$t,[DISPLAY_NAME$s]:DIR_NAME$s,[DISPLAY_NAME$r]:DIR_NAME$r,[DISPLAY_NAME$q]:DIR_NAME$q,[DISPLAY_NAME$p]:DIR_NAME$p,[DISPLAY_NAME$o]:DIR_NAME$o,[DISPLAY_NAME$n]:DIR_NAME$n,[DISPLAY_NAME$m]:DIR_NAME$m,[DISPLAY_NAME$l]:DIR_NAME$l,[DISPLAY_NAME$k]:DIR_NAME$k,[DISPLAY_NAME$j]:DIR_NAME$j,[DISPLAY_NAME$i]:DIR_NAME$i,[DISPLAY_NAME$h]:DIR_NAME$h,[DISPLAY_NAME$g]:DIR_NAME$g,[DISPLAY_NAME$f]:DIR_NAME$f,[DISPLAY_NAME$e]:DIR_NAME$e,[DISPLAY_NAME$d]:DIR_NAME$d,[DISPLAY_NAME$c]:DIR_NAME$c,[DISPLAY_NAME$b]:DIR_NAME$b,[DISPLAY_NAME$a]:DIR_NAME$a,[DISPLAY_NAME$9]:DIR_NAME$9,[DISPLAY_NAME$8]:DIR_NAME$8,[DISPLAY_NAME$7]:DIR_NAME$7,[DISPLAY_NAME$6]:DIR_NAME$6,[DISPLAY_NAME$5]:DIR_NAME$5,[DISPLAY_NAME$4]:DIR_NAME$4,[DISPLAY_NAME$3]:DIR_NAME$3,[DISPLAY_NAME$2]:DIR_NAME$2,[DISPLAY_NAME$1]:DIR_NAME$1,[DISPLAY_NAME]:DIR_NAME};
1054
+ const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$U]:DIR_NAME$U,[DISPLAY_NAME$10]:DIR_NAME$10,[DISPLAY_NAME$V]:DIR_NAME$V,[DISPLAY_NAME$Z]:DIR_NAME$Z,[DISPLAY_NAME$x]:DIR_NAME$x,[DISPLAY_NAME$X]:DIR_NAME$X,[DISPLAY_NAME$1a]:DIR_NAME$1a,[DISPLAY_NAME$T]:DIR_NAME$T,[DISPLAY_NAME$S]:DIR_NAME$S,[DISPLAY_NAME$R]:DIR_NAME$R,[DISPLAY_NAME$14]:DIR_NAME$14,[DISPLAY_NAME$18]:DIR_NAME$18,[DISPLAY_NAME$16]:DIR_NAME$16,[DISPLAY_NAME$12]:DIR_NAME$12,[DISPLAY_NAME$N]:DIR_NAME$N,[DISPLAY_NAME$J]:DIR_NAME$J,[DISPLAY_NAME$19]:DIR_NAME$19,[DISPLAY_NAME$11]:DIR_NAME$11,[DISPLAY_NAME$y]:DIR_NAME$y,[DISPLAY_NAME$$]:DIR_NAME$$,[DISPLAY_NAME$_]:DIR_NAME$_,[DISPLAY_NAME$K]:DIR_NAME$K,[DISPLAY_NAME$1d]:DIR_NAME$1d,[DISPLAY_NAME$I]:DIR_NAME$I,[DISPLAY_NAME$M]:DIR_NAME$M,[DISPLAY_NAME$1c]:DIR_NAME$1c,[DISPLAY_NAME$F]:DIR_NAME$F,[DISPLAY_NAME$Q]:DIR_NAME$Q,[DISPLAY_NAME$17]:DIR_NAME$17,[DISPLAY_NAME$1b]:DIR_NAME$1b,[DISPLAY_NAME$H]:DIR_NAME$H,[DISPLAY_NAME$1e]:DIR_NAME$1e,[DISPLAY_NAME$O]:DIR_NAME$O,[DISPLAY_NAME$B]:DIR_NAME$B,[DISPLAY_NAME$13]:DIR_NAME$13,[DISPLAY_NAME$W]:DIR_NAME$W,[DISPLAY_NAME$15]:DIR_NAME$15,[DISPLAY_NAME$L]:DIR_NAME$L,[DISPLAY_NAME$D]:DIR_NAME$D,[DISPLAY_NAME$E]:DIR_NAME$E,[DISPLAY_NAME$A]:DIR_NAME$A,[DISPLAY_NAME$C]:DIR_NAME$C,[DISPLAY_NAME$z]:DIR_NAME$z,[DISPLAY_NAME$G]:DIR_NAME$G,[DISPLAY_NAME$Y]:DIR_NAME$Y,[DISPLAY_NAME$P]:DIR_NAME$P,[DISPLAY_NAME$w]:DIR_NAME$w,[DISPLAY_NAME$v]:DIR_NAME$v,[DISPLAY_NAME$u]:DIR_NAME$u,[DISPLAY_NAME$t]:DIR_NAME$t,[DISPLAY_NAME$s]:DIR_NAME$s,[DISPLAY_NAME$r]:DIR_NAME$r,[DISPLAY_NAME$q]:DIR_NAME$q,[DISPLAY_NAME$p]:DIR_NAME$p,[DISPLAY_NAME$o]:DIR_NAME$o,[DISPLAY_NAME$n]:DIR_NAME$n,[DISPLAY_NAME$m]:DIR_NAME$m,[DISPLAY_NAME$l]:DIR_NAME$l,[DISPLAY_NAME$k]:DIR_NAME$k,[DISPLAY_NAME$j]:DIR_NAME$j,[DISPLAY_NAME$i]:DIR_NAME$i,[DISPLAY_NAME$h]:DIR_NAME$h,[DISPLAY_NAME$g]:DIR_NAME$g,[DISPLAY_NAME$f]:DIR_NAME$f,[DISPLAY_NAME$e]:DIR_NAME$e,[DISPLAY_NAME$d]:DIR_NAME$d,[DISPLAY_NAME$c]:DIR_NAME$c,[DISPLAY_NAME$b]:DIR_NAME$b,[DISPLAY_NAME$a]:DIR_NAME$a,[DISPLAY_NAME$9]:DIR_NAME$9,[DISPLAY_NAME$8]:DIR_NAME$8,[DISPLAY_NAME$7]:DIR_NAME$7,[DISPLAY_NAME$6]:DIR_NAME$6,[DISPLAY_NAME$5]:DIR_NAME$5,[DISPLAY_NAME$4]:DIR_NAME$4,[DISPLAY_NAME$3]:DIR_NAME$3,[DISPLAY_NAME$2]:DIR_NAME$2,[DISPLAY_NAME$1]:DIR_NAME$1,[DISPLAY_NAME]:DIR_NAME};
1074
1055
 
1075
1056
  const DEFAULT_INTEGRATIONS_CONFIG={All:true};
1076
1057
 
@@ -1129,6 +1110,8 @@ const queueErrResp=isErrRetryable(details)?details:null;if(!queueErrResp||attemp
1129
1110
 
1130
1111
  const METRICS_PAYLOAD_VERSION='1';
1131
1112
 
1113
+ const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX];
1114
+
1132
1115
  // Errors from the below scripts are NOT allowed to reach Bugsnag
1133
1116
  const SDK_FILE_NAME_PREFIXES=()=>['rsa'// Prefix for all the SDK scripts including plugins and module federated chunks
1134
1117
  ];const DEV_HOSTS=['www.test-host.com','localhost','127.0.0.1','[::1]'];// List of keys to exclude from the metadata
@@ -1136,11 +1119,19 @@ const SDK_FILE_NAME_PREFIXES=()=>['rsa'// Prefix for all the SDK scripts includi
1136
1119
  const APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','anonymousId','config','instance',// destination instance objects
1137
1120
  'eventBuffer',// pre-load event buffer (may contain PII)
1138
1121
  'traits'];const REQUEST_TIMEOUT_MS$1=10*1000;// 10 seconds
1139
- const NOTIFIER_NAME='RudderStack JavaScript SDK Error Notifier';const SDK_GITHUB_URL='https://github.com/rudderlabs/rudder-sdk-js';const SOURCE_NAME='js';
1122
+ const NOTIFIER_NAME='RudderStack JavaScript SDK Error Notifier';const SDK_GITHUB_URL='https://github.com/rudderlabs/rudder-sdk-js';const SOURCE_NAME='js';const ERROR_REPORTING_PLUGIN='ErrorReportingPlugin';
1140
1123
 
1141
1124
  const getConfigForPayloadCreation=(err,errorType)=>{switch(errorType){case ErrorType.UNHANDLEDEXCEPTION:{const{error}=err;return {component:'unhandledException handler',tolerateNonErrors:true,errorFramesToSkip:1,normalizedError:error||err};}case ErrorType.UNHANDLEDREJECTION:{const error=err;return {component:'unhandledrejection handler',tolerateNonErrors:false,errorFramesToSkip:1,normalizedError:error.reason};}case ErrorType.HANDLEDEXCEPTION:default:return {component:'notify()',tolerateNonErrors:true,errorFramesToSkip:2,normalizedError:err};}};const createNewBreadcrumb=(message,metaData)=>({type:'manual',name:message,timestamp:new Date(),metaData:metaData??{}});const getReleaseStage=()=>{const host=globalThis.location.hostname;return 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 getErrorContext=event=>{const{message}=event;let context=message;// Hack for easily grouping the script load errors
1142
1125
  // on the dashboard
1143
- if(message.includes('Error in loading a third-party script')){context='Script load failures';}return context;};const getBugsnagErrorEvent=(payload,errorState,state)=>({notifier:{name:NOTIFIER_NAME,version:state.context.app.value.version,url:SDK_GITHUB_URL},events:[{payloadVersion:'5',exceptions:clone(payload.errors),severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:state.context.app.value.version,releaseStage:getReleaseStage()},device:{locale:state.context.locale.value??undefined,userAgent:state.context.userAgent.value??undefined,time:new Date()},request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(state.reporting.breadcrumbs.value),context:getErrorContext(payload.errors[0]),metaData:{sdk:{name:'JS',installType:state.context.app.value.installType},state:getAppStateForMetadata(state)??{},source:{snippetVersion:globalThis.RudderSnippetVersion}},user:{id:state.source.value?.id??state.lifecycle.writeKey.value}}]});const isRudderSDKError=event=>{const errorOrigin=event.stacktrace?.[0]?.file;if(!errorOrigin||typeof errorOrigin!=='string'){return false;}const srcFileName=errorOrigin.substring(errorOrigin.lastIndexOf('/')+1);const paths=errorOrigin.split('/');// extract the parent folder name from the error origin file path
1126
+ if(message.includes('Error in loading a third-party script')){context='Script load failures';}return context;};const getBugsnagErrorEvent=(payload,errorState,state)=>({notifier:{name:NOTIFIER_NAME,version:state.context.app.value.version,url:SDK_GITHUB_URL},events:[{payloadVersion:'5',exceptions:clone(payload.errors),severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:state.context.app.value.version,releaseStage:getReleaseStage()},device:{locale:state.context.locale.value??undefined,userAgent:state.context.userAgent.value??undefined,time:new Date()},request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(state.reporting.breadcrumbs.value),context:getErrorContext(payload.errors[0]),metaData:{sdk:{name:'JS',installType:state.context.app.value.installType},state:getAppStateForMetadata(state)??{},source:{snippetVersion:globalThis.RudderSnippetVersion}},user:{id:state.source.value?.id??state.lifecycle.writeKey.value}}]});/**
1127
+ * A function to determine whether the error should be promoted to notify or not
1128
+ * @param {Error} error
1129
+ * @returns
1130
+ */const isAllowedToBeNotified=event=>{const errorMessage=event.message;if(errorMessage&&typeof errorMessage==='string'){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>errorMessage.includes(e));}return true;};/**
1131
+ * A function to determine if the error is from Rudder SDK
1132
+ * @param {Error} event
1133
+ * @returns
1134
+ */const isRudderSDKError=event=>{const errorOrigin=event.stacktrace?.[0]?.file;if(!errorOrigin||typeof errorOrigin!=='string'){return false;}const srcFileName=errorOrigin.substring(errorOrigin.lastIndexOf('/')+1);const paths=errorOrigin.split('/');// extract the parent folder name from the error origin file path
1144
1135
  // Ex: parentFolderName will be 'sample' for url: https://example.com/sample/file.min.js
1145
1136
  const parentFolderName=paths[paths.length-2];return parentFolderName===CDN_INT_DIR||SDK_FILE_NAME_PREFIXES().some(prefix=>srcFileName.startsWith(prefix)&&srcFileName.endsWith('.js'));};const getErrorDeliveryPayload=(payload,state)=>{const data={version:METRICS_PAYLOAD_VERSION,message_id:generateUUID(),source:{name:SOURCE_NAME,sdk_version:state.context.app.value.version,write_key:state.lifecycle.writeKey.value,install_type:state.context.app.value.installType},errors:payload};return stringifyWithoutCircular(data);};
1146
1137
 
@@ -1184,19 +1175,10 @@ const formatStackframe=frame=>{const f={file:frame.fileName,method:normaliseFunc
1184
1175
  // This adds one.
1185
1176
  if(f.lineNumber>-1&&!f.file&&!f.method){f.file='global code';}return f;};const ensureString=str=>typeof str==='string'?str:'';function createBugsnagError(errorClass,errorMessage,stacktrace){return {errorClass:ensureString(errorClass),message:ensureString(errorMessage),type:'browserjs',stacktrace:stacktrace.reduce((accum,frame)=>{const f=formatStackframe(frame);// don't include a stackframe if none of its properties are defined
1186
1177
  try{if(JSON.stringify(f)==='{}')return accum;return accum.concat(f);}catch(e){return accum;}},[])};}// Helpers
1187
- const getStacktrace=(error,errorFramesToSkip)=>{if(hasStack(error))return ErrorStackParser.parse(error).slice(errorFramesToSkip);return [];};const hasNecessaryFields=error=>(typeof error.name==='string'||typeof error.errorClass==='string')&&(typeof error.message==='string'||typeof error.errorMessage==='string');const normaliseError=(maybeError,tolerateNonErrors,component,logger)=>{let error;let internalFrames=0;const createAndLogInputError=reason=>{const verb=component==='error cause'?'was':'received';if(logger)logger.warn(`${component} ${verb} a non-error: "${reason}"`);const err=new Error(`${component} ${verb} a non-error. See "${component}" tab for more detail.`);err.name='InvalidError';return err;};// In some cases:
1188
- //
1189
- // - the promise rejection handler (both in the browser and node)
1190
- // - the node uncaughtException handler
1191
- //
1192
- // We are really limited in what we can do to get a stacktrace. So we use the
1193
- // tolerateNonErrors option to ensure that the resulting error communicates as
1194
- // such.
1195
- if(!tolerateNonErrors){if(isError(maybeError)){error=maybeError;}else {error=createAndLogInputError(typeof maybeError);internalFrames+=2;}}else {switch(typeof maybeError){case'string':case'number':case'boolean':error=new Error(String(maybeError));internalFrames+=1;break;case'function':error=createAndLogInputError('function');internalFrames+=2;break;case'object':if(maybeError!==null&&isError(maybeError)){error=maybeError;}else if(maybeError!==null&&hasNecessaryFields(maybeError)){error=new Error(maybeError.message||maybeError.errorMessage);error.name=maybeError.name||maybeError.errorClass;internalFrames+=1;}else {error=createAndLogInputError(maybeError===null?'null':'unsupported object');internalFrames+=2;}break;default:error=createAndLogInputError('nothing');internalFrames+=2;}}if(!hasStack(error)){// in IE10/11 a new Error() doesn't have a stacktrace until you throw it, so try that here
1178
+ const getStacktrace=(error,errorFramesToSkip)=>{if(hasStack(error))return ErrorStackParser.parse(error).slice(errorFramesToSkip);return [];};const hasNecessaryFields=error=>(typeof error.name==='string'||typeof error.errorClass==='string')&&(typeof error.message==='string'||typeof error.errorMessage==='string');const normaliseError=(maybeError,component,logger)=>{let error;let internalFrames=0;if(isError(maybeError)){error=maybeError;}else if(typeof maybeError==='object'&&hasNecessaryFields(maybeError)){error=new Error(maybeError.message||maybeError.errorMessage);error.name=maybeError.name||maybeError.errorClass;internalFrames+=1;}else {logger?.warn(`${ERROR_REPORTING_PLUGIN}:: ${component} received a non-error: ${stringifyWithoutCircular(error)}`);error=undefined;}if(error&&!hasStack(error)){// in IE10/11 a new Error() doesn't have a stacktrace until you throw it, so try that here
1196
1179
  try{throw error;}catch(e){if(hasStack(e)){error=e;// if the error only got a stacktrace after we threw it here, we know it
1197
- // will only have one extra internal frame from this function, regardless
1198
- // of whether it went through createAndLogInputError() or not
1199
- internalFrames=1;}}}return [error,internalFrames];};class ErrorFormat{constructor(errorClass,errorMessage,stacktrace){this.errors=[createBugsnagError(errorClass,errorMessage,stacktrace)];}static create(maybeError,tolerateNonErrors,handledState,component,errorFramesToSkip=0,logger){const[error,internalFrames]=normaliseError(maybeError,tolerateNonErrors,component,logger);let event;try{const stacktrace=getStacktrace(error,// if an error was created/throw in the normaliseError() function, we need to
1180
+ // will only have one extra internal frame from this function
1181
+ internalFrames=1;}}}return [error,internalFrames];};class ErrorFormat{constructor(errorClass,errorMessage,stacktrace){this.errors=[createBugsnagError(errorClass,errorMessage,stacktrace)];}static create(maybeError,tolerateNonErrors,handledState,component,errorFramesToSkip=0,logger){const[error,internalFrames]=normaliseError(maybeError,component,logger);if(!error){return undefined;}let event;try{const stacktrace=getStacktrace(error,// if an error was created/throw in the normaliseError() function, we need to
1200
1182
  // tell the getStacktrace() function to skip the number of frames we know will
1201
1183
  // be from our own functions. This is added to the number of frames deep we
1202
1184
  // were told about
@@ -1207,7 +1189,7 @@ const INVALID_SOURCE_CONFIG_ERROR=`Invalid source configuration or source id.`;
1207
1189
  const pluginName$9='ErrorReporting';const ErrorReporting=()=>({name:pluginName$9,deps:[],initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName$9];state.reporting.isErrorReportingPluginLoaded.value=true;if(state.reporting.breadcrumbs?.value){state.reporting.breadcrumbs.value=[createNewBreadcrumb('Error Reporting Plugin Loaded')];}},errorReporting:{// This extension point is deprecated
1208
1190
  // TODO: Remove this in the next major release
1209
1191
  init:(state,pluginEngine,externalSrcLoader,logger,isInvokedFromLatestCore)=>{if(isInvokedFromLatestCore){return undefined;}if(!state.source.value?.config||!state.source.value?.id){return Promise.reject(new Error(INVALID_SOURCE_CONFIG_ERROR));}return pluginEngine.invokeSingle('errorReportingProvider.init',state,externalSrcLoader,logger);},notify:(pluginEngine,client,error,state,logger,httpClient,errorState)=>{if(httpClient){const{component,tolerateNonErrors,errorFramesToSkip,normalizedError}=getConfigForPayloadCreation(error,errorState?.severityReason.type);// Generate the error payload
1210
- const errorPayload=ErrorFormat.create(normalizedError,tolerateNonErrors,errorState,component,errorFramesToSkip,logger);// filter errors
1192
+ const errorPayload=ErrorFormat.create(normalizedError,tolerateNonErrors,errorState,component,errorFramesToSkip,logger);if(!errorPayload||!isAllowedToBeNotified(errorPayload.errors[0])){return;}// filter errors
1211
1193
  if(!isRudderSDKError(errorPayload.errors[0])){return;}// enrich error payload
1212
1194
  const bugsnagPayload=getBugsnagErrorEvent(errorPayload,errorState,state);// send it to metrics service
1213
1195
  httpClient?.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true,timeout:REQUEST_TIMEOUT_MS$1,callback:(result,details)=>{// do nothing
@@ -2726,9 +2708,14 @@ if(utmParam==='campaign'){utmParam='name';}result[utmParam]=value;}});}catch(err
2726
2708
  */const getUrlWithoutHash=url=>{let urlWithoutHash=url;try{const urlObj=new URL(url);urlWithoutHash=urlObj.origin+urlObj.pathname+urlObj.search;}catch(error){// Do nothing
2727
2709
  }return urlWithoutHash;};
2728
2710
 
2711
+ /**
2712
+ * Determines if the SDK is running inside a chrome extension
2713
+ * @returns boolean
2714
+ */const isSDKRunningInChromeExtension=()=>!!(window.chrome&&window.chrome.runtime&&window.chrome.runtime.id);
2715
+
2729
2716
  const DEFAULT_PRE_CONSENT_STORAGE_STRATEGY='none';const DEFAULT_PRE_CONSENT_EVENTS_DELIVERY_TYPE='immediate';
2730
2717
 
2731
- const isMetricsReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.metrics?.enabled===true;
2718
+ const isErrorReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.errors?.enabled===true;const isMetricsReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.metrics?.enabled===true;
2732
2719
 
2733
2720
  /**
2734
2721
  * Validates and normalizes the consent options provided by the user
@@ -2762,10 +2749,7 @@ for(const script of scripts){const src=script.getAttribute('src');if(src&&sdkFil
2762
2749
  * Updates the reporting state variables from the source config data
2763
2750
  * @param res Source config
2764
2751
  * @param logger Logger instance
2765
- */const updateReportingState=res=>{state.reporting.isErrorReportingEnabled.value=false;// TODO: Enable this once the error reporting is tested properly
2766
- // state.reporting.isErrorReportingEnabled.value =
2767
- // isErrorReportingEnabled(res.source.config) && !isSDKRunningInChromeExtension();
2768
- state.reporting.isMetricsReportingEnabled.value=isMetricsReportingEnabled(res.source.config);};const updateStorageStateFromLoadOptions=logger=>{const{useServerSideCookies,dataServiceEndpoint,storage:storageOptsFromLoad,setCookieDomain,sameDomainCookiesOnly}=state.loadOptions.value;let storageType=storageOptsFromLoad?.type;if(isDefined(storageType)&&!isValidStorageType(storageType)){logger?.warn(STORAGE_TYPE_VALIDATION_WARNING(CONFIG_MANAGER,storageType,DEFAULT_STORAGE_TYPE));storageType=DEFAULT_STORAGE_TYPE;}let storageEncryptionVersion=storageOptsFromLoad?.encryption?.version;const encryptionPluginName=storageEncryptionVersion&&StorageEncryptionVersionsToPluginNameMap[storageEncryptionVersion];if(!isUndefined(storageEncryptionVersion)&&isUndefined(encryptionPluginName)){// set the default encryption plugin
2752
+ */const updateReportingState=res=>{state.reporting.isErrorReportingEnabled.value=isErrorReportingEnabled(res.source.config)&&!isSDKRunningInChromeExtension();state.reporting.isMetricsReportingEnabled.value=isMetricsReportingEnabled(res.source.config);};const updateStorageStateFromLoadOptions=logger=>{const{useServerSideCookies,dataServiceEndpoint,storage:storageOptsFromLoad,setCookieDomain,sameDomainCookiesOnly}=state.loadOptions.value;let storageType=storageOptsFromLoad?.type;if(isDefined(storageType)&&!isValidStorageType(storageType)){logger?.warn(STORAGE_TYPE_VALIDATION_WARNING(CONFIG_MANAGER,storageType,DEFAULT_STORAGE_TYPE));storageType=DEFAULT_STORAGE_TYPE;}let storageEncryptionVersion=storageOptsFromLoad?.encryption?.version;const encryptionPluginName=storageEncryptionVersion&&StorageEncryptionVersionsToPluginNameMap[storageEncryptionVersion];if(!isUndefined(storageEncryptionVersion)&&isUndefined(encryptionPluginName)){// set the default encryption plugin
2769
2753
  logger?.warn(UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(CONFIG_MANAGER,storageEncryptionVersion,StorageEncryptionVersionsToPluginNameMap,DEFAULT_STORAGE_ENCRYPTION_VERSION));storageEncryptionVersion=DEFAULT_STORAGE_ENCRYPTION_VERSION;}else if(isUndefined(storageEncryptionVersion)){storageEncryptionVersion=DEFAULT_STORAGE_ENCRYPTION_VERSION;}// Allow migration only if the configured encryption version is the default encryption version
2770
2754
  const configuredMigrationValue=storageOptsFromLoad?.migrate;const finalMigrationVal=configuredMigrationValue&&storageEncryptionVersion===DEFAULT_STORAGE_ENCRYPTION_VERSION;if(configuredMigrationValue===true&&finalMigrationVal!==configuredMigrationValue){logger?.warn(STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(CONFIG_MANAGER,storageEncryptionVersion,DEFAULT_STORAGE_ENCRYPTION_VERSION));}r(()=>{state.storage.type.value=storageType;let cookieOptions=storageOptsFromLoad?.cookie??{};if(useServerSideCookies){state.serverCookies.isEnabledServerSideCookies.value=useServerSideCookies;const providedCookieDomain=cookieOptions.domain??setCookieDomain;/**
2771
2755
  * Based on the following conditions, we decide whether to use the exact domain or not to determine the data service URL:
@@ -376,7 +376,7 @@
376
376
 
377
377
  const CAPABILITIES_MANAGER='CapabilitiesManager';const CONFIG_MANAGER='ConfigManager';const EVENT_MANAGER='EventManager';const PLUGINS_MANAGER='PluginsManager';const USER_SESSION_MANAGER='UserSessionManager';const ERROR_HANDLER='ErrorHandler';const PLUGIN_ENGINE='PluginEngine';const STORE_MANAGER='StoreManager';const READY_API='readyApi';const EVENT_REPOSITORY='EventRepository';const EXTERNAL_SRC_LOADER='ExternalSrcLoader';const HTTP_CLIENT='HttpClient';const RS_APP='RudderStackApplication';const ANALYTICS_CORE='AnalyticsCore';
378
378
 
379
- const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.7.5';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';
379
+ const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.7.7';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';
380
380
 
381
381
  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';
382
382
 
@@ -581,35 +581,14 @@
581
581
  extensionPointName=extensionPointName.replace(/(^!|!$)/g,'');if(!extensionPointName){throw new Error(PLUGIN_EXT_POINT_INVALID_ERROR);}const extensionPointNameParts=extensionPointName.split('.');extensionPointNameParts.pop();const pluginMethodPath=extensionPointNameParts.join('.');const pluginsToInvoke=allowMultiple?this.getPlugins(extensionPointName):[this.getPlugins(extensionPointName)[0]];return pluginsToInvoke.map(plugin=>{const method=getValueByPath(plugin,extensionPointName);if(!isFunction(method)||noCall){return method;}try{return method.apply(getValueByPath(plugin,pluginMethodPath),args);}catch(err){// When a plugin failed, doesn't break the app
582
582
  if(throws){throw err;}else {this.logger?.error(PLUGIN_INVOCATION_ERROR(PLUGIN_ENGINE,extensionPointName,plugin.name),err);}}return null;});}invokeSingle(extPoint,...args){return this.invoke(extPoint,false,...args)[0];}invokeMultiple(extPoint,...args){return this.invoke(extPoint,true,...args);}}const defaultPluginEngine=new PluginEngine({throws:true},defaultLogger);
583
583
 
584
- const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const UNHANDLEDEXCEPTION_FOR_NON_ERROR_OBJECT='unhandledException handler received a non-error';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX,UNHANDLEDEXCEPTION_FOR_NON_ERROR_OBJECT];
584
+ const LOAD_ORIGIN='RS_JS_SDK';
585
585
 
586
586
  /**
587
587
  * Utility method to normalise errors
588
588
  */const processError=error=>{let errorMessage;try{if(isString(error)){errorMessage=error;}else if(error instanceof Error){errorMessage=error.message;}else if(error instanceof ErrorEvent){errorMessage=error.message;}else {errorMessage=error.message?error.message:stringifyWithoutCircular(error);}}catch(e){errorMessage=`Unknown error: ${e.message}`;}return errorMessage;};const getNormalizedErrorForUnhandledError=error=>{try{if(error instanceof Error||error instanceof ErrorEvent||error instanceof PromiseRejectionEvent&&error.reason){return error;}// TODO: remove this block once all device mode integrations start using the v3 script loader module (TS)
589
- // if (error instanceof Event) {
590
- // const eventTarget = error.target as ErrorTarget;
591
- // // Discard all the non-script loading errors
592
- // if (eventTarget && eventTarget.localName !== 'script') {
593
- // return undefined;
594
- // }
595
- // // Discard script errors that are not originated at SDK or from native SDKs
596
- // if (
597
- // eventTarget?.dataset &&
598
- // (eventTarget.dataset.loader !== LOAD_ORIGIN ||
599
- // eventTarget.dataset.isnonnativesdk !== 'true')
600
- // ) {
601
- // return undefined;
602
- // }
603
- // const errorMessage = `Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`;
604
- // return Object.create(error, {
605
- // message: { value: errorMessage },
606
- // });
607
- // }
608
- return undefined;}catch(e){return e;}};/**
609
- * A function to determine whether the error should be promoted to notify or not
610
- * @param {Error} error
611
- * @returns
612
- */const isAllowedToBeNotified=error=>{if((error instanceof Error||error instanceof ErrorEvent)&&error.message){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>error.message.includes(e));}if(error instanceof PromiseRejectionEvent&&typeof error.reason==='string'){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>error.reason.includes(e));}return true;};
589
+ if(error instanceof Event){const eventTarget=error.target;// Discard all the non-script loading errors
590
+ if(eventTarget&&eventTarget.localName!=='script'){return undefined;}// Discard script errors that are not originated at SDK or from native SDKs
591
+ if(eventTarget?.dataset&&(eventTarget.dataset.loader!==LOAD_ORIGIN||eventTarget.dataset.isnonnativesdk!=='true')){return undefined;}const errorMessage=`Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`;return Object.create(error,{message:{value:errorMessage}});}return error;}catch(e){return e;}};
613
592
 
614
593
  /**
615
594
  * A service to handle errors
@@ -630,7 +609,7 @@
630
609
  * Send handled errors to external error monitoring service via a plugin
631
610
  *
632
611
  * @param {Error} error Error instance from handled error
633
- */notifyError(error,errorState){if(this.pluginEngine&&this.httpClient&&isAllowedToBeNotified(error)){try{this.pluginEngine.invokeSingle('errorReporting.notify',this.pluginEngine,// deprecated parameter
612
+ */notifyError(error,errorState){if(this.pluginEngine&&this.httpClient){try{this.pluginEngine.invokeSingle('errorReporting.notify',this.pluginEngine,// deprecated parameter
634
613
  this.errReportingClient,// deprecated parameter
635
614
  error,state,this.logger,this.httpClient,errorState);}catch(err){// Not calling onError here as we don't want to go into infinite loop
636
615
  this.logger?.error(NOTIFY_FAILURE_ERROR(ERROR_HANDLER),err);}}}}const defaultErrorHandler=new ErrorHandler(defaultLogger,defaultPluginEngine);
@@ -919,37 +898,39 @@
919
898
  // the configured resolution strategy
920
899
  const matchPredicate=consent=>allowedConsentIds.includes(consent);switch(resolutionStrategy){case'or':return configuredConsents.some(matchPredicate)||configuredConsents.length===0;case'and':default:return configuredConsents.every(matchPredicate);}}catch(err){errorHandler?.onError(err,CUSTOM_CONSENT_MANAGER_PLUGIN,DESTINATION_CONSENT_STATUS_ERROR$2);return true;}}}});
921
900
 
922
- const DIR_NAME$1d='AdobeAnalytics';const DISPLAY_NAME$1d='Adobe Analytics';
901
+ const DIR_NAME$1e='AdobeAnalytics';const DISPLAY_NAME$1e='Adobe Analytics';
902
+
903
+ const DIR_NAME$1d='Amplitude';const DISPLAY_NAME$1d='Amplitude';
923
904
 
924
- const DIR_NAME$1c='Amplitude';const DISPLAY_NAME$1c='Amplitude';
905
+ const DIR_NAME$1c='Appcues';const DISPLAY_NAME$1c='Appcues';
925
906
 
926
- const DIR_NAME$1b='Appcues';const DISPLAY_NAME$1b='Appcues';
907
+ const DIR_NAME$1b='BingAds';const DISPLAY_NAME$1b='Bing Ads';
927
908
 
928
- const DIR_NAME$1a='BingAds';const DISPLAY_NAME$1a='Bing Ads';
909
+ const DIR_NAME$1a='Braze';const DISPLAY_NAME$1a='Braze';
929
910
 
930
- const DIR_NAME$19='Braze';const DISPLAY_NAME$19='Braze';
911
+ const DIR_NAME$19='Bugsnag';const DISPLAY_NAME$19='Bugsnag';
931
912
 
932
- const DIR_NAME$18='Bugsnag';const DISPLAY_NAME$18='Bugsnag';
913
+ const DIR_NAME$18='Chartbeat';const DISPLAY_NAME$18='Chartbeat';
933
914
 
934
- const DIR_NAME$17='Chartbeat';const DISPLAY_NAME$17='Chartbeat';
915
+ const DIR_NAME$17='Clevertap';const DISPLAY_NAME$17='CleverTap';
935
916
 
936
- const DIR_NAME$16='Clevertap';const DISPLAY_NAME$16='CleverTap';
917
+ const DIR_NAME$16='Comscore';const DISPLAY_NAME$16='Comscore';
937
918
 
938
- const DIR_NAME$15='Comscore';const DISPLAY_NAME$15='Comscore';
919
+ const DIR_NAME$15='Criteo';const DISPLAY_NAME$15='Criteo';
939
920
 
940
- const DIR_NAME$14='Criteo';const DISPLAY_NAME$14='Criteo';
921
+ const DIR_NAME$14='CustomerIO';const DISPLAY_NAME$14='Customer IO';
941
922
 
942
- const DIR_NAME$13='CustomerIO';const DISPLAY_NAME$13='Customer IO';
923
+ const DIR_NAME$13='Drip';const DISPLAY_NAME$13='Drip';
943
924
 
944
- const DIR_NAME$12='Drip';const DISPLAY_NAME$12='Drip';
925
+ const DIR_NAME$12='FacebookPixel';const DISPLAY_NAME$12='Facebook Pixel';
945
926
 
946
- const DIR_NAME$11='FacebookPixel';const DISPLAY_NAME$11='Facebook Pixel';
927
+ const DIR_NAME$11='Fullstory';const DISPLAY_NAME$11='Fullstory';
947
928
 
948
- const DIR_NAME$10='Fullstory';const DISPLAY_NAME$10='Fullstory';
929
+ const DIR_NAME$10='GA';const DISPLAY_NAME$10='Google Analytics';
949
930
 
950
- const DIR_NAME$$='GA';const DISPLAY_NAME$$='Google Analytics';
931
+ const DIR_NAME$$='GA4';const DISPLAY_NAME$$='Google Analytics 4 (GA4)';
951
932
 
952
- const DIR_NAME$_='GA4';const DISPLAY_NAME$_='Google Analytics 4 (GA4)';
933
+ const DIR_NAME$_='GA4_V2';const DISPLAY_NAME$_='Google Analytics 4 (GA4) V2';
953
934
 
954
935
  const DIR_NAME$Z='GoogleAds';const DISPLAY_NAME$Z='Google Ads';
955
936
 
@@ -1076,7 +1057,7 @@
1076
1057
  const DIR_NAME='Ninetailed';const DISPLAY_NAME='Ninetailed';
1077
1058
 
1078
1059
  // map of the destination display names to the destination directory names
1079
- const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$U]:DIR_NAME$U,[DISPLAY_NAME$$]:DIR_NAME$$,[DISPLAY_NAME$V]:DIR_NAME$V,[DISPLAY_NAME$Z]:DIR_NAME$Z,[DISPLAY_NAME$x]:DIR_NAME$x,[DISPLAY_NAME$X]:DIR_NAME$X,[DISPLAY_NAME$19]:DIR_NAME$19,[DISPLAY_NAME$T]:DIR_NAME$T,[DISPLAY_NAME$S]:DIR_NAME$S,[DISPLAY_NAME$R]:DIR_NAME$R,[DISPLAY_NAME$13]:DIR_NAME$13,[DISPLAY_NAME$17]:DIR_NAME$17,[DISPLAY_NAME$15]:DIR_NAME$15,[DISPLAY_NAME$11]:DIR_NAME$11,[DISPLAY_NAME$N]:DIR_NAME$N,[DISPLAY_NAME$J]:DIR_NAME$J,[DISPLAY_NAME$18]:DIR_NAME$18,[DISPLAY_NAME$10]:DIR_NAME$10,[DISPLAY_NAME$y]:DIR_NAME$y,[DISPLAY_NAME$_]:DIR_NAME$_,[DISPLAY_NAME$K]:DIR_NAME$K,[DISPLAY_NAME$1c]:DIR_NAME$1c,[DISPLAY_NAME$I]:DIR_NAME$I,[DISPLAY_NAME$M]:DIR_NAME$M,[DISPLAY_NAME$1b]:DIR_NAME$1b,[DISPLAY_NAME$F]:DIR_NAME$F,[DISPLAY_NAME$Q]:DIR_NAME$Q,[DISPLAY_NAME$16]:DIR_NAME$16,[DISPLAY_NAME$1a]:DIR_NAME$1a,[DISPLAY_NAME$H]:DIR_NAME$H,[DISPLAY_NAME$1d]:DIR_NAME$1d,[DISPLAY_NAME$O]:DIR_NAME$O,[DISPLAY_NAME$B]:DIR_NAME$B,[DISPLAY_NAME$12]:DIR_NAME$12,[DISPLAY_NAME$W]:DIR_NAME$W,[DISPLAY_NAME$14]:DIR_NAME$14,[DISPLAY_NAME$L]:DIR_NAME$L,[DISPLAY_NAME$D]:DIR_NAME$D,[DISPLAY_NAME$E]:DIR_NAME$E,[DISPLAY_NAME$A]:DIR_NAME$A,[DISPLAY_NAME$C]:DIR_NAME$C,[DISPLAY_NAME$z]:DIR_NAME$z,[DISPLAY_NAME$G]:DIR_NAME$G,[DISPLAY_NAME$Y]:DIR_NAME$Y,[DISPLAY_NAME$P]:DIR_NAME$P,[DISPLAY_NAME$w]:DIR_NAME$w,[DISPLAY_NAME$v]:DIR_NAME$v,[DISPLAY_NAME$u]:DIR_NAME$u,[DISPLAY_NAME$t]:DIR_NAME$t,[DISPLAY_NAME$s]:DIR_NAME$s,[DISPLAY_NAME$r]:DIR_NAME$r,[DISPLAY_NAME$q]:DIR_NAME$q,[DISPLAY_NAME$p]:DIR_NAME$p,[DISPLAY_NAME$o]:DIR_NAME$o,[DISPLAY_NAME$n]:DIR_NAME$n,[DISPLAY_NAME$m]:DIR_NAME$m,[DISPLAY_NAME$l]:DIR_NAME$l,[DISPLAY_NAME$k]:DIR_NAME$k,[DISPLAY_NAME$j]:DIR_NAME$j,[DISPLAY_NAME$i]:DIR_NAME$i,[DISPLAY_NAME$h]:DIR_NAME$h,[DISPLAY_NAME$g]:DIR_NAME$g,[DISPLAY_NAME$f]:DIR_NAME$f,[DISPLAY_NAME$e]:DIR_NAME$e,[DISPLAY_NAME$d]:DIR_NAME$d,[DISPLAY_NAME$c]:DIR_NAME$c,[DISPLAY_NAME$b]:DIR_NAME$b,[DISPLAY_NAME$a]:DIR_NAME$a,[DISPLAY_NAME$9]:DIR_NAME$9,[DISPLAY_NAME$8]:DIR_NAME$8,[DISPLAY_NAME$7]:DIR_NAME$7,[DISPLAY_NAME$6]:DIR_NAME$6,[DISPLAY_NAME$5]:DIR_NAME$5,[DISPLAY_NAME$4]:DIR_NAME$4,[DISPLAY_NAME$3]:DIR_NAME$3,[DISPLAY_NAME$2]:DIR_NAME$2,[DISPLAY_NAME$1]:DIR_NAME$1,[DISPLAY_NAME]:DIR_NAME};
1060
+ const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$U]:DIR_NAME$U,[DISPLAY_NAME$10]:DIR_NAME$10,[DISPLAY_NAME$V]:DIR_NAME$V,[DISPLAY_NAME$Z]:DIR_NAME$Z,[DISPLAY_NAME$x]:DIR_NAME$x,[DISPLAY_NAME$X]:DIR_NAME$X,[DISPLAY_NAME$1a]:DIR_NAME$1a,[DISPLAY_NAME$T]:DIR_NAME$T,[DISPLAY_NAME$S]:DIR_NAME$S,[DISPLAY_NAME$R]:DIR_NAME$R,[DISPLAY_NAME$14]:DIR_NAME$14,[DISPLAY_NAME$18]:DIR_NAME$18,[DISPLAY_NAME$16]:DIR_NAME$16,[DISPLAY_NAME$12]:DIR_NAME$12,[DISPLAY_NAME$N]:DIR_NAME$N,[DISPLAY_NAME$J]:DIR_NAME$J,[DISPLAY_NAME$19]:DIR_NAME$19,[DISPLAY_NAME$11]:DIR_NAME$11,[DISPLAY_NAME$y]:DIR_NAME$y,[DISPLAY_NAME$$]:DIR_NAME$$,[DISPLAY_NAME$_]:DIR_NAME$_,[DISPLAY_NAME$K]:DIR_NAME$K,[DISPLAY_NAME$1d]:DIR_NAME$1d,[DISPLAY_NAME$I]:DIR_NAME$I,[DISPLAY_NAME$M]:DIR_NAME$M,[DISPLAY_NAME$1c]:DIR_NAME$1c,[DISPLAY_NAME$F]:DIR_NAME$F,[DISPLAY_NAME$Q]:DIR_NAME$Q,[DISPLAY_NAME$17]:DIR_NAME$17,[DISPLAY_NAME$1b]:DIR_NAME$1b,[DISPLAY_NAME$H]:DIR_NAME$H,[DISPLAY_NAME$1e]:DIR_NAME$1e,[DISPLAY_NAME$O]:DIR_NAME$O,[DISPLAY_NAME$B]:DIR_NAME$B,[DISPLAY_NAME$13]:DIR_NAME$13,[DISPLAY_NAME$W]:DIR_NAME$W,[DISPLAY_NAME$15]:DIR_NAME$15,[DISPLAY_NAME$L]:DIR_NAME$L,[DISPLAY_NAME$D]:DIR_NAME$D,[DISPLAY_NAME$E]:DIR_NAME$E,[DISPLAY_NAME$A]:DIR_NAME$A,[DISPLAY_NAME$C]:DIR_NAME$C,[DISPLAY_NAME$z]:DIR_NAME$z,[DISPLAY_NAME$G]:DIR_NAME$G,[DISPLAY_NAME$Y]:DIR_NAME$Y,[DISPLAY_NAME$P]:DIR_NAME$P,[DISPLAY_NAME$w]:DIR_NAME$w,[DISPLAY_NAME$v]:DIR_NAME$v,[DISPLAY_NAME$u]:DIR_NAME$u,[DISPLAY_NAME$t]:DIR_NAME$t,[DISPLAY_NAME$s]:DIR_NAME$s,[DISPLAY_NAME$r]:DIR_NAME$r,[DISPLAY_NAME$q]:DIR_NAME$q,[DISPLAY_NAME$p]:DIR_NAME$p,[DISPLAY_NAME$o]:DIR_NAME$o,[DISPLAY_NAME$n]:DIR_NAME$n,[DISPLAY_NAME$m]:DIR_NAME$m,[DISPLAY_NAME$l]:DIR_NAME$l,[DISPLAY_NAME$k]:DIR_NAME$k,[DISPLAY_NAME$j]:DIR_NAME$j,[DISPLAY_NAME$i]:DIR_NAME$i,[DISPLAY_NAME$h]:DIR_NAME$h,[DISPLAY_NAME$g]:DIR_NAME$g,[DISPLAY_NAME$f]:DIR_NAME$f,[DISPLAY_NAME$e]:DIR_NAME$e,[DISPLAY_NAME$d]:DIR_NAME$d,[DISPLAY_NAME$c]:DIR_NAME$c,[DISPLAY_NAME$b]:DIR_NAME$b,[DISPLAY_NAME$a]:DIR_NAME$a,[DISPLAY_NAME$9]:DIR_NAME$9,[DISPLAY_NAME$8]:DIR_NAME$8,[DISPLAY_NAME$7]:DIR_NAME$7,[DISPLAY_NAME$6]:DIR_NAME$6,[DISPLAY_NAME$5]:DIR_NAME$5,[DISPLAY_NAME$4]:DIR_NAME$4,[DISPLAY_NAME$3]:DIR_NAME$3,[DISPLAY_NAME$2]:DIR_NAME$2,[DISPLAY_NAME$1]:DIR_NAME$1,[DISPLAY_NAME]:DIR_NAME};
1080
1061
 
1081
1062
  const DEFAULT_INTEGRATIONS_CONFIG={All:true};
1082
1063
 
@@ -1135,6 +1116,8 @@
1135
1116
 
1136
1117
  const METRICS_PAYLOAD_VERSION='1';
1137
1118
 
1119
+ const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX];
1120
+
1138
1121
  // Errors from the below scripts are NOT allowed to reach Bugsnag
1139
1122
  const SDK_FILE_NAME_PREFIXES=()=>['rsa'// Prefix for all the SDK scripts including plugins and module federated chunks
1140
1123
  ];const DEV_HOSTS=['www.test-host.com','localhost','127.0.0.1','[::1]'];// List of keys to exclude from the metadata
@@ -1142,11 +1125,19 @@
1142
1125
  const APP_STATE_EXCLUDE_KEYS=['userId','userTraits','groupId','groupTraits','anonymousId','config','instance',// destination instance objects
1143
1126
  'eventBuffer',// pre-load event buffer (may contain PII)
1144
1127
  'traits'];const REQUEST_TIMEOUT_MS$1=10*1000;// 10 seconds
1145
- const NOTIFIER_NAME='RudderStack JavaScript SDK Error Notifier';const SDK_GITHUB_URL='https://github.com/rudderlabs/rudder-sdk-js';const SOURCE_NAME='js';
1128
+ const NOTIFIER_NAME='RudderStack JavaScript SDK Error Notifier';const SDK_GITHUB_URL='https://github.com/rudderlabs/rudder-sdk-js';const SOURCE_NAME='js';const ERROR_REPORTING_PLUGIN='ErrorReportingPlugin';
1146
1129
 
1147
1130
  const getConfigForPayloadCreation=(err,errorType)=>{switch(errorType){case ErrorType.UNHANDLEDEXCEPTION:{const{error}=err;return {component:'unhandledException handler',tolerateNonErrors:true,errorFramesToSkip:1,normalizedError:error||err};}case ErrorType.UNHANDLEDREJECTION:{const error=err;return {component:'unhandledrejection handler',tolerateNonErrors:false,errorFramesToSkip:1,normalizedError:error.reason};}case ErrorType.HANDLEDEXCEPTION:default:return {component:'notify()',tolerateNonErrors:true,errorFramesToSkip:2,normalizedError:err};}};const createNewBreadcrumb=(message,metaData)=>({type:'manual',name:message,timestamp:new Date(),metaData:metaData??{}});const getReleaseStage=()=>{const host=globalThis.location.hostname;return 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 getErrorContext=event=>{const{message}=event;let context=message;// Hack for easily grouping the script load errors
1148
1131
  // on the dashboard
1149
- if(message.includes('Error in loading a third-party script')){context='Script load failures';}return context;};const getBugsnagErrorEvent=(payload,errorState,state)=>({notifier:{name:NOTIFIER_NAME,version:state.context.app.value.version,url:SDK_GITHUB_URL},events:[{payloadVersion:'5',exceptions:clone(payload.errors),severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:state.context.app.value.version,releaseStage:getReleaseStage()},device:{locale:state.context.locale.value??undefined,userAgent:state.context.userAgent.value??undefined,time:new Date()},request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(state.reporting.breadcrumbs.value),context:getErrorContext(payload.errors[0]),metaData:{sdk:{name:'JS',installType:state.context.app.value.installType},state:getAppStateForMetadata(state)??{},source:{snippetVersion:globalThis.RudderSnippetVersion}},user:{id:state.source.value?.id??state.lifecycle.writeKey.value}}]});const isRudderSDKError=event=>{const errorOrigin=event.stacktrace?.[0]?.file;if(!errorOrigin||typeof errorOrigin!=='string'){return false;}const srcFileName=errorOrigin.substring(errorOrigin.lastIndexOf('/')+1);const paths=errorOrigin.split('/');// extract the parent folder name from the error origin file path
1132
+ if(message.includes('Error in loading a third-party script')){context='Script load failures';}return context;};const getBugsnagErrorEvent=(payload,errorState,state)=>({notifier:{name:NOTIFIER_NAME,version:state.context.app.value.version,url:SDK_GITHUB_URL},events:[{payloadVersion:'5',exceptions:clone(payload.errors),severity:errorState.severity,unhandled:errorState.unhandled,severityReason:errorState.severityReason,app:{version:state.context.app.value.version,releaseStage:getReleaseStage()},device:{locale:state.context.locale.value??undefined,userAgent:state.context.userAgent.value??undefined,time:new Date()},request:{url:getURLWithoutQueryString(),clientIp:'[NOT COLLECTED]'},breadcrumbs:clone(state.reporting.breadcrumbs.value),context:getErrorContext(payload.errors[0]),metaData:{sdk:{name:'JS',installType:state.context.app.value.installType},state:getAppStateForMetadata(state)??{},source:{snippetVersion:globalThis.RudderSnippetVersion}},user:{id:state.source.value?.id??state.lifecycle.writeKey.value}}]});/**
1133
+ * A function to determine whether the error should be promoted to notify or not
1134
+ * @param {Error} error
1135
+ * @returns
1136
+ */const isAllowedToBeNotified=event=>{const errorMessage=event.message;if(errorMessage&&typeof errorMessage==='string'){return !ERROR_MESSAGES_TO_BE_FILTERED.some(e=>errorMessage.includes(e));}return true;};/**
1137
+ * A function to determine if the error is from Rudder SDK
1138
+ * @param {Error} event
1139
+ * @returns
1140
+ */const isRudderSDKError=event=>{const errorOrigin=event.stacktrace?.[0]?.file;if(!errorOrigin||typeof errorOrigin!=='string'){return false;}const srcFileName=errorOrigin.substring(errorOrigin.lastIndexOf('/')+1);const paths=errorOrigin.split('/');// extract the parent folder name from the error origin file path
1150
1141
  // Ex: parentFolderName will be 'sample' for url: https://example.com/sample/file.min.js
1151
1142
  const parentFolderName=paths[paths.length-2];return parentFolderName===CDN_INT_DIR||SDK_FILE_NAME_PREFIXES().some(prefix=>srcFileName.startsWith(prefix)&&srcFileName.endsWith('.js'));};const getErrorDeliveryPayload=(payload,state)=>{const data={version:METRICS_PAYLOAD_VERSION,message_id:generateUUID(),source:{name:SOURCE_NAME,sdk_version:state.context.app.value.version,write_key:state.lifecycle.writeKey.value,install_type:state.context.app.value.installType},errors:payload};return stringifyWithoutCircular(data);};
1152
1143
 
@@ -1190,19 +1181,10 @@
1190
1181
  // This adds one.
1191
1182
  if(f.lineNumber>-1&&!f.file&&!f.method){f.file='global code';}return f;};const ensureString=str=>typeof str==='string'?str:'';function createBugsnagError(errorClass,errorMessage,stacktrace){return {errorClass:ensureString(errorClass),message:ensureString(errorMessage),type:'browserjs',stacktrace:stacktrace.reduce((accum,frame)=>{const f=formatStackframe(frame);// don't include a stackframe if none of its properties are defined
1192
1183
  try{if(JSON.stringify(f)==='{}')return accum;return accum.concat(f);}catch(e){return accum;}},[])};}// Helpers
1193
- const getStacktrace=(error,errorFramesToSkip)=>{if(hasStack(error))return ErrorStackParser.parse(error).slice(errorFramesToSkip);return [];};const hasNecessaryFields=error=>(typeof error.name==='string'||typeof error.errorClass==='string')&&(typeof error.message==='string'||typeof error.errorMessage==='string');const normaliseError=(maybeError,tolerateNonErrors,component,logger)=>{let error;let internalFrames=0;const createAndLogInputError=reason=>{const verb=component==='error cause'?'was':'received';if(logger)logger.warn(`${component} ${verb} a non-error: "${reason}"`);const err=new Error(`${component} ${verb} a non-error. See "${component}" tab for more detail.`);err.name='InvalidError';return err;};// In some cases:
1194
- //
1195
- // - the promise rejection handler (both in the browser and node)
1196
- // - the node uncaughtException handler
1197
- //
1198
- // We are really limited in what we can do to get a stacktrace. So we use the
1199
- // tolerateNonErrors option to ensure that the resulting error communicates as
1200
- // such.
1201
- if(!tolerateNonErrors){if(isError(maybeError)){error=maybeError;}else {error=createAndLogInputError(typeof maybeError);internalFrames+=2;}}else {switch(typeof maybeError){case'string':case'number':case'boolean':error=new Error(String(maybeError));internalFrames+=1;break;case'function':error=createAndLogInputError('function');internalFrames+=2;break;case'object':if(maybeError!==null&&isError(maybeError)){error=maybeError;}else if(maybeError!==null&&hasNecessaryFields(maybeError)){error=new Error(maybeError.message||maybeError.errorMessage);error.name=maybeError.name||maybeError.errorClass;internalFrames+=1;}else {error=createAndLogInputError(maybeError===null?'null':'unsupported object');internalFrames+=2;}break;default:error=createAndLogInputError('nothing');internalFrames+=2;}}if(!hasStack(error)){// in IE10/11 a new Error() doesn't have a stacktrace until you throw it, so try that here
1184
+ const getStacktrace=(error,errorFramesToSkip)=>{if(hasStack(error))return ErrorStackParser.parse(error).slice(errorFramesToSkip);return [];};const hasNecessaryFields=error=>(typeof error.name==='string'||typeof error.errorClass==='string')&&(typeof error.message==='string'||typeof error.errorMessage==='string');const normaliseError=(maybeError,component,logger)=>{let error;let internalFrames=0;if(isError(maybeError)){error=maybeError;}else if(typeof maybeError==='object'&&hasNecessaryFields(maybeError)){error=new Error(maybeError.message||maybeError.errorMessage);error.name=maybeError.name||maybeError.errorClass;internalFrames+=1;}else {logger?.warn(`${ERROR_REPORTING_PLUGIN}:: ${component} received a non-error: ${stringifyWithoutCircular(error)}`);error=undefined;}if(error&&!hasStack(error)){// in IE10/11 a new Error() doesn't have a stacktrace until you throw it, so try that here
1202
1185
  try{throw error;}catch(e){if(hasStack(e)){error=e;// if the error only got a stacktrace after we threw it here, we know it
1203
- // will only have one extra internal frame from this function, regardless
1204
- // of whether it went through createAndLogInputError() or not
1205
- internalFrames=1;}}}return [error,internalFrames];};class ErrorFormat{constructor(errorClass,errorMessage,stacktrace){this.errors=[createBugsnagError(errorClass,errorMessage,stacktrace)];}static create(maybeError,tolerateNonErrors,handledState,component,errorFramesToSkip=0,logger){const[error,internalFrames]=normaliseError(maybeError,tolerateNonErrors,component,logger);let event;try{const stacktrace=getStacktrace(error,// if an error was created/throw in the normaliseError() function, we need to
1186
+ // will only have one extra internal frame from this function
1187
+ internalFrames=1;}}}return [error,internalFrames];};class ErrorFormat{constructor(errorClass,errorMessage,stacktrace){this.errors=[createBugsnagError(errorClass,errorMessage,stacktrace)];}static create(maybeError,tolerateNonErrors,handledState,component,errorFramesToSkip=0,logger){const[error,internalFrames]=normaliseError(maybeError,component,logger);if(!error){return undefined;}let event;try{const stacktrace=getStacktrace(error,// if an error was created/throw in the normaliseError() function, we need to
1206
1188
  // tell the getStacktrace() function to skip the number of frames we know will
1207
1189
  // be from our own functions. This is added to the number of frames deep we
1208
1190
  // were told about
@@ -1213,7 +1195,7 @@
1213
1195
  const pluginName$9='ErrorReporting';const ErrorReporting=()=>({name:pluginName$9,deps:[],initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName$9];state.reporting.isErrorReportingPluginLoaded.value=true;if(state.reporting.breadcrumbs?.value){state.reporting.breadcrumbs.value=[createNewBreadcrumb('Error Reporting Plugin Loaded')];}},errorReporting:{// This extension point is deprecated
1214
1196
  // TODO: Remove this in the next major release
1215
1197
  init:(state,pluginEngine,externalSrcLoader,logger,isInvokedFromLatestCore)=>{if(isInvokedFromLatestCore){return undefined;}if(!state.source.value?.config||!state.source.value?.id){return Promise.reject(new Error(INVALID_SOURCE_CONFIG_ERROR));}return pluginEngine.invokeSingle('errorReportingProvider.init',state,externalSrcLoader,logger);},notify:(pluginEngine,client,error,state,logger,httpClient,errorState)=>{if(httpClient){const{component,tolerateNonErrors,errorFramesToSkip,normalizedError}=getConfigForPayloadCreation(error,errorState?.severityReason.type);// Generate the error payload
1216
- const errorPayload=ErrorFormat.create(normalizedError,tolerateNonErrors,errorState,component,errorFramesToSkip,logger);// filter errors
1198
+ const errorPayload=ErrorFormat.create(normalizedError,tolerateNonErrors,errorState,component,errorFramesToSkip,logger);if(!errorPayload||!isAllowedToBeNotified(errorPayload.errors[0])){return;}// filter errors
1217
1199
  if(!isRudderSDKError(errorPayload.errors[0])){return;}// enrich error payload
1218
1200
  const bugsnagPayload=getBugsnagErrorEvent(errorPayload,errorState,state);// send it to metrics service
1219
1201
  httpClient?.getAsyncData({url:state.metrics.metricsServiceUrl.value,options:{method:'POST',data:getErrorDeliveryPayload(bugsnagPayload,state),sendRawData:true},isRawResponse:true,timeout:REQUEST_TIMEOUT_MS$1,callback:(result,details)=>{// do nothing
@@ -2732,9 +2714,14 @@
2732
2714
  */const getUrlWithoutHash=url=>{let urlWithoutHash=url;try{const urlObj=new URL(url);urlWithoutHash=urlObj.origin+urlObj.pathname+urlObj.search;}catch(error){// Do nothing
2733
2715
  }return urlWithoutHash;};
2734
2716
 
2717
+ /**
2718
+ * Determines if the SDK is running inside a chrome extension
2719
+ * @returns boolean
2720
+ */const isSDKRunningInChromeExtension=()=>!!(window.chrome&&window.chrome.runtime&&window.chrome.runtime.id);
2721
+
2735
2722
  const DEFAULT_PRE_CONSENT_STORAGE_STRATEGY='none';const DEFAULT_PRE_CONSENT_EVENTS_DELIVERY_TYPE='immediate';
2736
2723
 
2737
- const isMetricsReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.metrics?.enabled===true;
2724
+ const isErrorReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.errors?.enabled===true;const isMetricsReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.metrics?.enabled===true;
2738
2725
 
2739
2726
  /**
2740
2727
  * Validates and normalizes the consent options provided by the user
@@ -2768,10 +2755,7 @@
2768
2755
  * Updates the reporting state variables from the source config data
2769
2756
  * @param res Source config
2770
2757
  * @param logger Logger instance
2771
- */const updateReportingState=res=>{state.reporting.isErrorReportingEnabled.value=false;// TODO: Enable this once the error reporting is tested properly
2772
- // state.reporting.isErrorReportingEnabled.value =
2773
- // isErrorReportingEnabled(res.source.config) && !isSDKRunningInChromeExtension();
2774
- state.reporting.isMetricsReportingEnabled.value=isMetricsReportingEnabled(res.source.config);};const updateStorageStateFromLoadOptions=logger=>{const{useServerSideCookies,dataServiceEndpoint,storage:storageOptsFromLoad,setCookieDomain,sameDomainCookiesOnly}=state.loadOptions.value;let storageType=storageOptsFromLoad?.type;if(isDefined(storageType)&&!isValidStorageType(storageType)){logger?.warn(STORAGE_TYPE_VALIDATION_WARNING(CONFIG_MANAGER,storageType,DEFAULT_STORAGE_TYPE));storageType=DEFAULT_STORAGE_TYPE;}let storageEncryptionVersion=storageOptsFromLoad?.encryption?.version;const encryptionPluginName=storageEncryptionVersion&&StorageEncryptionVersionsToPluginNameMap[storageEncryptionVersion];if(!isUndefined(storageEncryptionVersion)&&isUndefined(encryptionPluginName)){// set the default encryption plugin
2758
+ */const updateReportingState=res=>{state.reporting.isErrorReportingEnabled.value=isErrorReportingEnabled(res.source.config)&&!isSDKRunningInChromeExtension();state.reporting.isMetricsReportingEnabled.value=isMetricsReportingEnabled(res.source.config);};const updateStorageStateFromLoadOptions=logger=>{const{useServerSideCookies,dataServiceEndpoint,storage:storageOptsFromLoad,setCookieDomain,sameDomainCookiesOnly}=state.loadOptions.value;let storageType=storageOptsFromLoad?.type;if(isDefined(storageType)&&!isValidStorageType(storageType)){logger?.warn(STORAGE_TYPE_VALIDATION_WARNING(CONFIG_MANAGER,storageType,DEFAULT_STORAGE_TYPE));storageType=DEFAULT_STORAGE_TYPE;}let storageEncryptionVersion=storageOptsFromLoad?.encryption?.version;const encryptionPluginName=storageEncryptionVersion&&StorageEncryptionVersionsToPluginNameMap[storageEncryptionVersion];if(!isUndefined(storageEncryptionVersion)&&isUndefined(encryptionPluginName)){// set the default encryption plugin
2775
2759
  logger?.warn(UNSUPPORTED_STORAGE_ENCRYPTION_VERSION_WARNING(CONFIG_MANAGER,storageEncryptionVersion,StorageEncryptionVersionsToPluginNameMap,DEFAULT_STORAGE_ENCRYPTION_VERSION));storageEncryptionVersion=DEFAULT_STORAGE_ENCRYPTION_VERSION;}else if(isUndefined(storageEncryptionVersion)){storageEncryptionVersion=DEFAULT_STORAGE_ENCRYPTION_VERSION;}// Allow migration only if the configured encryption version is the default encryption version
2776
2760
  const configuredMigrationValue=storageOptsFromLoad?.migrate;const finalMigrationVal=configuredMigrationValue&&storageEncryptionVersion===DEFAULT_STORAGE_ENCRYPTION_VERSION;if(configuredMigrationValue===true&&finalMigrationVal!==configuredMigrationValue){logger?.warn(STORAGE_DATA_MIGRATION_OVERRIDE_WARNING(CONFIG_MANAGER,storageEncryptionVersion,DEFAULT_STORAGE_ENCRYPTION_VERSION));}r(()=>{state.storage.type.value=storageType;let cookieOptions=storageOptsFromLoad?.cookie??{};if(useServerSideCookies){state.serverCookies.isEnabledServerSideCookies.value=useServerSideCookies;const providedCookieDomain=cookieOptions.domain??setCookieDomain;/**
2777
2761
  * Based on the following conditions, we decide whether to use the exact domain or not to determine the data service URL: