@rudderstack/analytics-js 3.28.1-beta.pr.2745.7302a89 → 3.29.0-beta.pr.2744.4ae3336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/npm/legacy/bundled/cjs/index.cjs +19 -15
- package/dist/npm/legacy/bundled/esm/index.mjs +19 -15
- package/dist/npm/legacy/bundled/umd/index.js +19 -15
- package/dist/npm/legacy/cjs/index.cjs +19 -15
- package/dist/npm/legacy/content-script/cjs/index.cjs +19 -15
- package/dist/npm/legacy/content-script/esm/index.mjs +19 -15
- package/dist/npm/legacy/content-script/umd/index.js +19 -15
- package/dist/npm/legacy/esm/index.mjs +19 -15
- package/dist/npm/legacy/lite/cjs/index.cjs +19 -15
- package/dist/npm/legacy/lite/esm/index.mjs +19 -15
- package/dist/npm/legacy/lite/umd/index.js +19 -15
- package/dist/npm/legacy/umd/index.js +19 -15
- package/dist/npm/modern/bundled/cjs/index.cjs +18 -14
- package/dist/npm/modern/bundled/esm/index.mjs +18 -14
- package/dist/npm/modern/bundled/umd/index.js +18 -14
- package/dist/npm/modern/cjs/index.cjs +18 -14
- package/dist/npm/modern/content-script/cjs/index.cjs +18 -14
- package/dist/npm/modern/content-script/esm/index.mjs +18 -14
- package/dist/npm/modern/content-script/umd/index.js +18 -14
- package/dist/npm/modern/esm/index.mjs +18 -14
- package/dist/npm/modern/lite/cjs/index.cjs +18 -14
- package/dist/npm/modern/lite/esm/index.mjs +18 -14
- package/dist/npm/modern/lite/umd/index.js +18 -14
- package/dist/npm/modern/umd/index.js +18 -14
- package/package.json +1 -1
|
@@ -519,7 +519,7 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
|
|
|
519
519
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
520
520
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
521
521
|
|
|
522
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
522
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='content-script';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';
|
|
523
523
|
|
|
524
524
|
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';
|
|
525
525
|
|
|
@@ -3494,19 +3494,21 @@ const safelyInvokeCallback=(callback,args,apiName,logger)=>{if(!isDefined(callba
|
|
|
3494
3494
|
* @param storeManager Store Manager instance
|
|
3495
3495
|
* @param errorHandler Error handler object
|
|
3496
3496
|
* @param logger Logger object
|
|
3497
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
3497
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
3498
3498
|
* Initializes the event repository
|
|
3499
3499
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
3500
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
3501
|
-
//
|
|
3502
|
-
//
|
|
3503
|
-
//
|
|
3504
|
-
|
|
3505
|
-
|
|
3500
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
3501
|
+
// This function is called when the client destinations are ready
|
|
3502
|
+
// or when the timeout expires
|
|
3503
|
+
// or when no buffering is required
|
|
3504
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
3505
|
+
// or when buffering is required and the client destinations are ready
|
|
3506
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
3507
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
3506
3508
|
* Enqueues the event for processing
|
|
3507
3509
|
* @param event RudderEvent object
|
|
3508
3510
|
* @param callback API callback function
|
|
3509
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
3511
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
3510
3512
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
3511
3513
|
|
|
3512
3514
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -3539,7 +3541,9 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
|
3539
3541
|
* Initialize the storage and event queue
|
|
3540
3542
|
*/onPluginsReady(){// Initialize storage
|
|
3541
3543
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
3542
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
3544
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
3545
|
+
// So, it should be done before initializing the event manager.
|
|
3546
|
+
this.setActiveDestinations();// Initialize event manager
|
|
3543
3547
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
3544
3548
|
state.lifecycle.status.value='initialized';}/**
|
|
3545
3549
|
* Load plugins
|
|
@@ -3563,13 +3567,13 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
3563
3567
|
// for-loop as the individual events that are processed may
|
|
3564
3568
|
// add more events to the buffer (this is needed for the consent API)
|
|
3565
3569
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
3566
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
3570
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
3567
3571
|
* Load device mode destinations
|
|
3568
3572
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
3569
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
3570
|
-
this.
|
|
3573
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
3574
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
3571
3575
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
3572
|
-
m(()=>{const areAllDestinationsReady=
|
|
3576
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
3573
3577
|
* Move to the ready state
|
|
3574
3578
|
*/// eslint-disable-next-line class-methods-use-this
|
|
3575
3579
|
onDestinationsReady(){// May be do any destination specific actions here
|
|
@@ -515,7 +515,7 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
|
|
|
515
515
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
516
516
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
517
517
|
|
|
518
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
518
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='content-script';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';
|
|
519
519
|
|
|
520
520
|
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';
|
|
521
521
|
|
|
@@ -3490,19 +3490,21 @@ const safelyInvokeCallback=(callback,args,apiName,logger)=>{if(!isDefined(callba
|
|
|
3490
3490
|
* @param storeManager Store Manager instance
|
|
3491
3491
|
* @param errorHandler Error handler object
|
|
3492
3492
|
* @param logger Logger object
|
|
3493
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
3493
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
3494
3494
|
* Initializes the event repository
|
|
3495
3495
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
3496
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
3497
|
-
//
|
|
3498
|
-
//
|
|
3499
|
-
//
|
|
3500
|
-
|
|
3501
|
-
|
|
3496
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
3497
|
+
// This function is called when the client destinations are ready
|
|
3498
|
+
// or when the timeout expires
|
|
3499
|
+
// or when no buffering is required
|
|
3500
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
3501
|
+
// or when buffering is required and the client destinations are ready
|
|
3502
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
3503
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
3502
3504
|
* Enqueues the event for processing
|
|
3503
3505
|
* @param event RudderEvent object
|
|
3504
3506
|
* @param callback API callback function
|
|
3505
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
3507
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
3506
3508
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
3507
3509
|
|
|
3508
3510
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -3535,7 +3537,9 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
|
3535
3537
|
* Initialize the storage and event queue
|
|
3536
3538
|
*/onPluginsReady(){// Initialize storage
|
|
3537
3539
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
3538
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
3540
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
3541
|
+
// So, it should be done before initializing the event manager.
|
|
3542
|
+
this.setActiveDestinations();// Initialize event manager
|
|
3539
3543
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
3540
3544
|
state.lifecycle.status.value='initialized';}/**
|
|
3541
3545
|
* Load plugins
|
|
@@ -3559,13 +3563,13 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
3559
3563
|
// for-loop as the individual events that are processed may
|
|
3560
3564
|
// add more events to the buffer (this is needed for the consent API)
|
|
3561
3565
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
3562
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
3566
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
3563
3567
|
* Load device mode destinations
|
|
3564
3568
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
3565
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
3566
|
-
this.
|
|
3569
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
3570
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
3567
3571
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
3568
|
-
m(()=>{const areAllDestinationsReady=
|
|
3572
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
3569
3573
|
* Move to the ready state
|
|
3570
3574
|
*/// eslint-disable-next-line class-methods-use-this
|
|
3571
3575
|
onDestinationsReady(){// May be do any destination specific actions here
|
|
@@ -521,7 +521,7 @@
|
|
|
521
521
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
522
522
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
523
523
|
|
|
524
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
524
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='content-script';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';
|
|
525
525
|
|
|
526
526
|
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';
|
|
527
527
|
|
|
@@ -3496,19 +3496,21 @@
|
|
|
3496
3496
|
* @param storeManager Store Manager instance
|
|
3497
3497
|
* @param errorHandler Error handler object
|
|
3498
3498
|
* @param logger Logger object
|
|
3499
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
3499
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
3500
3500
|
* Initializes the event repository
|
|
3501
3501
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
3502
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
3503
|
-
//
|
|
3504
|
-
//
|
|
3505
|
-
//
|
|
3506
|
-
|
|
3507
|
-
|
|
3502
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
3503
|
+
// This function is called when the client destinations are ready
|
|
3504
|
+
// or when the timeout expires
|
|
3505
|
+
// or when no buffering is required
|
|
3506
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
3507
|
+
// or when buffering is required and the client destinations are ready
|
|
3508
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
3509
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
3508
3510
|
* Enqueues the event for processing
|
|
3509
3511
|
* @param event RudderEvent object
|
|
3510
3512
|
* @param callback API callback function
|
|
3511
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
3513
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
3512
3514
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
3513
3515
|
|
|
3514
3516
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -3541,7 +3543,9 @@
|
|
|
3541
3543
|
* Initialize the storage and event queue
|
|
3542
3544
|
*/onPluginsReady(){// Initialize storage
|
|
3543
3545
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
3544
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
3546
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
3547
|
+
// So, it should be done before initializing the event manager.
|
|
3548
|
+
this.setActiveDestinations();// Initialize event manager
|
|
3545
3549
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
3546
3550
|
state.lifecycle.status.value='initialized';}/**
|
|
3547
3551
|
* Load plugins
|
|
@@ -3565,13 +3569,13 @@
|
|
|
3565
3569
|
// for-loop as the individual events that are processed may
|
|
3566
3570
|
// add more events to the buffer (this is needed for the consent API)
|
|
3567
3571
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
3568
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
3572
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
3569
3573
|
* Load device mode destinations
|
|
3570
3574
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
3571
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
3572
|
-
this.
|
|
3575
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
3576
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
3573
3577
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
3574
|
-
m(()=>{const areAllDestinationsReady=
|
|
3578
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
3575
3579
|
* Move to the ready state
|
|
3576
3580
|
*/// eslint-disable-next-line class-methods-use-this
|
|
3577
3581
|
onDestinationsReady(){// May be do any destination specific actions here
|
|
@@ -506,7 +506,7 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
|
|
|
506
506
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
507
507
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
508
508
|
|
|
509
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
509
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='modern';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';
|
|
510
510
|
|
|
511
511
|
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';
|
|
512
512
|
|
|
@@ -1782,19 +1782,21 @@ const safelyInvokeCallback=(callback,args,apiName,logger)=>{if(!isDefined(callba
|
|
|
1782
1782
|
* @param storeManager Store Manager instance
|
|
1783
1783
|
* @param errorHandler Error handler object
|
|
1784
1784
|
* @param logger Logger object
|
|
1785
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
1785
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
1786
1786
|
* Initializes the event repository
|
|
1787
1787
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
1788
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
1789
|
-
//
|
|
1790
|
-
//
|
|
1791
|
-
//
|
|
1792
|
-
|
|
1793
|
-
|
|
1788
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
1789
|
+
// This function is called when the client destinations are ready
|
|
1790
|
+
// or when the timeout expires
|
|
1791
|
+
// or when no buffering is required
|
|
1792
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
1793
|
+
// or when buffering is required and the client destinations are ready
|
|
1794
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
1795
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
1794
1796
|
* Enqueues the event for processing
|
|
1795
1797
|
* @param event RudderEvent object
|
|
1796
1798
|
* @param callback API callback function
|
|
1797
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
1799
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
1798
1800
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
1799
1801
|
|
|
1800
1802
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -1827,7 +1829,9 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
|
1827
1829
|
* Initialize the storage and event queue
|
|
1828
1830
|
*/onPluginsReady(){// Initialize storage
|
|
1829
1831
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
1830
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
1832
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
1833
|
+
// So, it should be done before initializing the event manager.
|
|
1834
|
+
this.setActiveDestinations();// Initialize event manager
|
|
1831
1835
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
1832
1836
|
state.lifecycle.status.value='initialized';}/**
|
|
1833
1837
|
* Load plugins
|
|
@@ -1851,13 +1855,13 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
1851
1855
|
// for-loop as the individual events that are processed may
|
|
1852
1856
|
// add more events to the buffer (this is needed for the consent API)
|
|
1853
1857
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
1854
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
1858
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
1855
1859
|
* Load device mode destinations
|
|
1856
1860
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
1857
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
1858
|
-
this.
|
|
1861
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
1862
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
1859
1863
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
1860
|
-
m(()=>{const areAllDestinationsReady=
|
|
1864
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
1861
1865
|
* Move to the ready state
|
|
1862
1866
|
*/// eslint-disable-next-line class-methods-use-this
|
|
1863
1867
|
onDestinationsReady(){// May be do any destination specific actions here
|
|
@@ -519,7 +519,7 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
|
|
|
519
519
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
520
520
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
521
521
|
|
|
522
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
522
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='lite';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';
|
|
523
523
|
|
|
524
524
|
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';
|
|
525
525
|
|
|
@@ -2038,19 +2038,21 @@ const safelyInvokeCallback=(callback,args,apiName,logger)=>{if(!isDefined(callba
|
|
|
2038
2038
|
* @param storeManager Store Manager instance
|
|
2039
2039
|
* @param errorHandler Error handler object
|
|
2040
2040
|
* @param logger Logger object
|
|
2041
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
2041
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
2042
2042
|
* Initializes the event repository
|
|
2043
2043
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
2044
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
2045
|
-
//
|
|
2046
|
-
//
|
|
2047
|
-
//
|
|
2048
|
-
|
|
2049
|
-
|
|
2044
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
2045
|
+
// This function is called when the client destinations are ready
|
|
2046
|
+
// or when the timeout expires
|
|
2047
|
+
// or when no buffering is required
|
|
2048
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
2049
|
+
// or when buffering is required and the client destinations are ready
|
|
2050
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
2051
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
2050
2052
|
* Enqueues the event for processing
|
|
2051
2053
|
* @param event RudderEvent object
|
|
2052
2054
|
* @param callback API callback function
|
|
2053
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
2055
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
2054
2056
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
2055
2057
|
|
|
2056
2058
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -2083,7 +2085,9 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
|
2083
2085
|
* Initialize the storage and event queue
|
|
2084
2086
|
*/onPluginsReady(){// Initialize storage
|
|
2085
2087
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
2086
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
2088
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
2089
|
+
// So, it should be done before initializing the event manager.
|
|
2090
|
+
this.setActiveDestinations();// Initialize event manager
|
|
2087
2091
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
2088
2092
|
state.lifecycle.status.value='initialized';}/**
|
|
2089
2093
|
* Load plugins
|
|
@@ -2107,13 +2111,13 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
2107
2111
|
// for-loop as the individual events that are processed may
|
|
2108
2112
|
// add more events to the buffer (this is needed for the consent API)
|
|
2109
2113
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
2110
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
2114
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
2111
2115
|
* Load device mode destinations
|
|
2112
2116
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
2113
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
2114
|
-
this.
|
|
2117
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
2118
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
2115
2119
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
2116
|
-
m(()=>{const areAllDestinationsReady=
|
|
2120
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
2117
2121
|
* Move to the ready state
|
|
2118
2122
|
*/// eslint-disable-next-line class-methods-use-this
|
|
2119
2123
|
onDestinationsReady(){// May be do any destination specific actions here
|
|
@@ -515,7 +515,7 @@ error.stack=`${stack}\n${MANUAL_ERROR_IDENTIFIER}`;break;case stacktrace:// esli
|
|
|
515
515
|
error.stacktrace=`${stacktrace}\n${MANUAL_ERROR_IDENTIFIER}`;break;case operaSourceloc:default:// eslint-disable-next-line no-param-reassign
|
|
516
516
|
error['opera#sourceloc']=`${operaSourceloc}\n${MANUAL_ERROR_IDENTIFIER}`;break;}}}globalThis.dispatchEvent(new ErrorEvent('error',{error,bubbles:true,cancelable:true,composed:true}));};
|
|
517
517
|
|
|
518
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.
|
|
518
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.29.0-beta.pr.2744.4ae3336';const APP_NAMESPACE='com.rudderlabs.javascript';const MODULE_TYPE='npm';const BUILD_VARIANT='lite';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';
|
|
519
519
|
|
|
520
520
|
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';
|
|
521
521
|
|
|
@@ -2034,19 +2034,21 @@ const safelyInvokeCallback=(callback,args,apiName,logger)=>{if(!isDefined(callba
|
|
|
2034
2034
|
* @param storeManager Store Manager instance
|
|
2035
2035
|
* @param errorHandler Error handler object
|
|
2036
2036
|
* @param logger Logger object
|
|
2037
|
-
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;}/**
|
|
2037
|
+
*/constructor(pluginsManager,storeManager,httpClient,errorHandler,logger){this.pluginsManager=pluginsManager;this.errorHandler=errorHandler;this.httpClient=httpClient;this.logger=logger;this.storeManager=storeManager;this.eventsBuffer=[];this.isEventBufferingActive=true;}/**
|
|
2038
2038
|
* Initializes the event repository
|
|
2039
2039
|
*/init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.init`,state,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DMT_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger);this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.init`,state,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger);// Start the queue once the client destinations are ready
|
|
2040
|
-
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);// Start the
|
|
2041
|
-
//
|
|
2042
|
-
//
|
|
2043
|
-
//
|
|
2044
|
-
|
|
2045
|
-
|
|
2040
|
+
m(()=>{if(state.nativeDestinations.clientDestinationsReady.value===true){this.destinationsEventsQueue?.start();this.dmtEventsQueue?.start();}});const bufferEventsBeforeConsent=shouldBufferEventsForPreConsent(state);if(!bufferEventsBeforeConsent){this.startDpEventsQueue();}}startDpEventsQueue(){const bufferEventsUntilReady=state.loadOptions.value.bufferDataPlaneEventsUntilReady;const hybridDestExist=state.nativeDestinations.activeDestinations.value.some(dest=>isHybridModeDestination(dest));const shouldBufferEvents=bufferEventsUntilReady&&hybridDestExist;// Start the data plane events queue and replay the events from the buffer
|
|
2041
|
+
// This function is called when the client destinations are ready
|
|
2042
|
+
// or when the timeout expires
|
|
2043
|
+
// or when no buffering is required
|
|
2044
|
+
const startDpQueueAndReplayEvents=()=>{this.isEventBufferingActive=false;this.eventsBuffer.forEach(event=>{this.enqueue(event);});if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true){this.dataplaneEventsQueue?.start();}this.eventsBuffer=[];};let timeoutId;// Start the queue when no event buffering is required
|
|
2045
|
+
// or when buffering is required and the client destinations are ready
|
|
2046
|
+
m(()=>{if(!shouldBufferEvents||state.nativeDestinations.clientDestinationsReady.value){globalThis.clearTimeout(timeoutId);startDpQueueAndReplayEvents();}});// Force start the data plane events queue processing after a timeout
|
|
2047
|
+
if(shouldBufferEvents){this.isEventBufferingActive=true;timeoutId=globalThis.setTimeout(()=>{startDpQueueAndReplayEvents();},state.loadOptions.value.dataPlaneEventsBufferTimeout);}}resume(){if(this.dataplaneEventsQueue?.scheduleTimeoutActive!==true&&state.consents.postConsent.value.discardPreConsentEvents){this.dataplaneEventsQueue?.clear();this.destinationsEventsQueue?.clear();}this.startDpEventsQueue();}/**
|
|
2046
2048
|
* Enqueues the event for processing
|
|
2047
2049
|
* @param event RudderEvent object
|
|
2048
2050
|
* @param callback API callback function
|
|
2049
|
-
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger)
|
|
2051
|
+
*/enqueue(event,callback){const dpQEvent=getFinalEvent(event,state);if(this.isEventBufferingActive){this.eventsBuffer.push(dpQEvent);}else {this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}// Invoke the callback if it exists
|
|
2050
2052
|
const apiName=`${event.type.charAt(0).toUpperCase()}${event.type.slice(1)}${API_SUFFIX}`;safelyInvokeCallback(callback,[dpQEvent],apiName,this.logger);}}
|
|
2051
2053
|
|
|
2052
2054
|
const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:true,cancelable:true,composed:true});globalThis.document.dispatchEvent(customEvent);};const isWriteKeyValid=writeKey=>isString(writeKey)&&writeKey.trim().length>0;const isDataPlaneUrlValid=dataPlaneUrl=>isValidURL(dataPlaneUrl);
|
|
@@ -2079,7 +2081,9 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
|
2079
2081
|
* Initialize the storage and event queue
|
|
2080
2082
|
*/onPluginsReady(){// Initialize storage
|
|
2081
2083
|
this.storeManager?.init();this.userSessionManager?.init();// Initialize the appropriate consent manager plugin
|
|
2082
|
-
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}//
|
|
2084
|
+
if(state.consents.enabled.value&&!state.consents.initialized.value){this.pluginsManager?.invokeSingle(`consentManager.init`,state,this.logger);if(state.consents.preConsent.value.enabled===false){this.pluginsManager?.invokeSingle(`consentManager.updateConsentsInfo`,state,this.storeManager,this.logger);}}// Setting the active destinations is important for the events processing.
|
|
2085
|
+
// So, it should be done before initializing the event manager.
|
|
2086
|
+
this.setActiveDestinations();// Initialize event manager
|
|
2083
2087
|
this.eventManager?.init();// Mark the SDK as initialized
|
|
2084
2088
|
state.lifecycle.status.value='initialized';}/**
|
|
2085
2089
|
* Load plugins
|
|
@@ -2103,13 +2107,13 @@ dispatchSDKEvent('RSA_Ready');}/**
|
|
|
2103
2107
|
// for-loop as the individual events that are processed may
|
|
2104
2108
|
// add more events to the buffer (this is needed for the consent API)
|
|
2105
2109
|
let bufferedEvents=state.eventBuffer.toBeProcessedArray.value;while(bufferedEvents.length>0){const bufferedEvent=bufferedEvents.shift();state.eventBuffer.toBeProcessedArray.value=bufferedEvents;if(bufferedEvent){const methodName=bufferedEvent[0];if(isFunction(this[methodName])){// Send additional arg 'true' to indicate that this is a buffered invocation
|
|
2106
|
-
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}/**
|
|
2110
|
+
this[methodName](...bufferedEvent.slice(1),true);}}bufferedEvents=state.eventBuffer.toBeProcessedArray.value;}}setActiveDestinations(){this.pluginsManager?.invokeSingle('nativeDestinations.setActiveDestinations',state,this.pluginsManager,this.errorHandler,this.logger);}/**
|
|
2107
2111
|
* Load device mode destinations
|
|
2108
2112
|
*/loadDestinations(){// If the integrations load is already triggered or completed, skip the rest of the logic
|
|
2109
|
-
if(state.lifecycle.status.value==='destinationsLoading'||state.
|
|
2110
|
-
this.
|
|
2113
|
+
if(state.lifecycle.status.value==='destinationsLoading'||state.nativeDestinations.clientDestinationsReady.value===true){return;}// Set in state the desired activeDestinations to inject in DOM
|
|
2114
|
+
this.setActiveDestinations();const totalDestinationsToLoad=state.nativeDestinations.activeDestinations.value.length;if(totalDestinationsToLoad===0){n(()=>{state.nativeDestinations.clientDestinationsReady.value=true;state.lifecycle.status.value='destinationsReady';});return;}// Start loading native integration scripts and create instances
|
|
2111
2115
|
state.lifecycle.status.value='destinationsLoading';this.pluginsManager?.invokeSingle('nativeDestinations.load',state,this.externalSrcLoader,this.errorHandler,this.logger);// Progress to next lifecycle phase if all native destinations are initialized or failed
|
|
2112
|
-
m(()=>{const areAllDestinationsReady=
|
|
2116
|
+
m(()=>{const areAllDestinationsReady=state.nativeDestinations.initializedDestinations.value.length+state.nativeDestinations.failedDestinations.value.length===totalDestinationsToLoad;if(areAllDestinationsReady){n(()=>{state.lifecycle.status.value='destinationsReady';state.nativeDestinations.clientDestinationsReady.value=true;});}});}/**
|
|
2113
2117
|
* Move to the ready state
|
|
2114
2118
|
*/// eslint-disable-next-line class-methods-use-this
|
|
2115
2119
|
onDestinationsReady(){// May be do any destination specific actions here
|