@rudderstack/analytics-js 3.0.0-beta.19 → 3.0.0-beta.20
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 +7 -0
- package/dist/npm/index.d.ts +30 -16
- package/dist/npm/legacy/cjs/index.js +193 -206
- package/dist/npm/legacy/esm/index.js +193 -206
- package/dist/npm/legacy/umd/index.js +193 -206
- package/dist/npm/modern/bundled/cjs/index.js +139 -130
- package/dist/npm/modern/bundled/esm/index.js +139 -130
- package/dist/npm/modern/bundled/umd/index.js +139 -130
- package/dist/npm/modern/cjs/index.js +55 -48
- package/dist/npm/modern/content-script/cjs/index.js +138 -129
- package/dist/npm/modern/content-script/esm/index.js +138 -129
- package/dist/npm/modern/content-script/umd/index.js +138 -129
- package/dist/npm/modern/esm/index.js +55 -48
- package/dist/npm/modern/umd/index.js +55 -48
- package/package.json +1 -1
@@ -58,7 +58,7 @@ function _has(prop,obj){return Object.prototype.hasOwnProperty.call(obj,prop);}
|
|
58
58
|
* R.type(() => {}); //=> "Function"
|
59
59
|
* R.type(async () => {}); //=> "AsyncFunction"
|
60
60
|
* R.type(undefined); //=> "Undefined"
|
61
|
-
*/var type=/*#__PURE__*/_curry1(function type(val){return val===null?'Null':val===undefined?'Undefined':Object.prototype.toString.call(val).slice(8,-1);});
|
61
|
+
*/var type=/*#__PURE__*/_curry1(function type(val){return val===null?'Null':val===undefined?'Undefined':Object.prototype.toString.call(val).slice(8,-1);});
|
62
62
|
|
63
63
|
function _isObject(x){return Object.prototype.toString.call(x)==='[object Object]';}
|
64
64
|
|
@@ -98,7 +98,7 @@ function _isString(x){return Object.prototype.toString.call(x)==='[object String
|
|
98
98
|
* @symb R.nth(-1, [a, b, c]) = c
|
99
99
|
* @symb R.nth(0, [a, b, c]) = a
|
100
100
|
* @symb R.nth(1, [a, b, c]) = b
|
101
|
-
*/var nth=/*#__PURE__*/_curry2(function nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];});
|
101
|
+
*/var nth=/*#__PURE__*/_curry2(function nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];});
|
102
102
|
|
103
103
|
function _cloneRegExp(pattern){return new RegExp(pattern.source,pattern.flags?pattern.flags:(pattern.global?'g':'')+(pattern.ignoreCase?'i':'')+(pattern.multiline?'m':'')+(pattern.sticky?'y':'')+(pattern.unicode?'u':'')+(pattern.dotAll?'s':''));}
|
104
104
|
|
@@ -111,7 +111,7 @@ function _cloneRegExp(pattern){return new RegExp(pattern.source,pattern.flags?pa
|
|
111
111
|
* @return {*} The copied value.
|
112
112
|
*/function _clone(value,deep,map){map||(map=new _ObjectMap());// this avoids the slower switch with a quick if decision removing some milliseconds in each run.
|
113
113
|
if(_isPrimitive(value)){return value;}var copy=function copy(copiedValue){// Check for circular and same references on the object graph and return its corresponding clone.
|
114
|
-
var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,copiedValue);for(var key in value){if(Object.prototype.hasOwnProperty.call(value,key)){copiedValue[key]=deep?_clone(value[key],true,map):value[key];}}return copiedValue;};switch(type
|
114
|
+
var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,copiedValue);for(var key in value){if(Object.prototype.hasOwnProperty.call(value,key)){copiedValue[key]=deep?_clone(value[key],true,map):value[key];}}return copiedValue;};switch(type(value)){case'Object':return copy(Object.create(Object.getPrototypeOf(value)));case'Array':return copy([]);case'Date':return new Date(value.valueOf());case'RegExp':return _cloneRegExp(value);case'Int8Array':case'Uint8Array':case'Uint8ClampedArray':case'Int16Array':case'Uint16Array':case'Int32Array':case'Uint32Array':case'Float32Array':case'Float64Array':case'BigInt64Array':case'BigUint64Array':return value.slice();default:return value;}}function _isPrimitive(param){var type=typeof param;return param==null||type!='object'&&type!='function';}var _ObjectMap=/*#__PURE__*/function(){function _ObjectMap(){this.map={};this.length=0;}_ObjectMap.prototype.set=function(key,value){const hashedKey=this.hash(key);let bucket=this.map[hashedKey];if(!bucket){this.map[hashedKey]=bucket=[];}bucket.push([key,value]);this.length+=1;};_ObjectMap.prototype.hash=function(key){let hashedKey=[];for(var value in key){hashedKey.push(Object.prototype.toString.call(key[value]));}return hashedKey.join();};_ObjectMap.prototype.get=function(key){/**
|
115
115
|
* depending on the number of objects to be cloned is faster to just iterate over the items in the map just because the hash function is so costly,
|
116
116
|
* on my tests this number is 180, anything above that using the hash function is faster.
|
117
117
|
*/if(this.length<=180){for(const p in this.map){const bucket=this.map[p];for(let i=0;i<bucket.length;i+=1){const element=bucket[i];if(element[0]===key){return element[1];}}}return;}const hashedKey=this.hash(key);const bucket=this.map[hashedKey];if(!bucket){return;}for(let i=0;i<bucket.length;i+=1){const element=bucket[i];if(element[0]===key){return element[1];}}};return _ObjectMap;}();
|
@@ -142,7 +142,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
142
142
|
* const objectsClone = R.clone(objects);
|
143
143
|
* objects === objectsClone; //=> false
|
144
144
|
* objects[0] === objectsClone[0]; //=> false
|
145
|
-
*/var clone=/*#__PURE__*/_curry1(function clone(value){return value!=null&&typeof value.clone==='function'?value.clone():_clone(value,true);});
|
145
|
+
*/var clone=/*#__PURE__*/_curry1(function clone(value){return value!=null&&typeof value.clone==='function'?value.clone():_clone(value,true);});
|
146
146
|
|
147
147
|
/**
|
148
148
|
* Retrieves the values at given paths of an object.
|
@@ -161,7 +161,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
161
161
|
*
|
162
162
|
* R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
|
163
163
|
* R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]
|
164
|
-
*/var paths=/*#__PURE__*/_curry2(function paths(pathsArray,obj){return pathsArray.map(function(paths){var val=obj;var idx=0;var p;while(idx<paths.length){if(val==null){return;}p=paths[idx];val=_isInteger(p)?nth
|
164
|
+
*/var paths=/*#__PURE__*/_curry2(function paths(pathsArray,obj){return pathsArray.map(function(paths){var val=obj;var idx=0;var p;while(idx<paths.length){if(val==null){return;}p=paths[idx];val=_isInteger(p)?nth(p,val):val[p];idx+=1;}return val;});});
|
165
165
|
|
166
166
|
/**
|
167
167
|
* Retrieves the value at a given path. The nodes of the path can be arbitrary strings or non-negative integers.
|
@@ -186,7 +186,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
186
186
|
* R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2
|
187
187
|
* R.path([2], {'2': 2}); //=> 2
|
188
188
|
* R.path([-2], {'-2': 'a'}); //=> undefined
|
189
|
-
*/var path=/*#__PURE__*/_curry2(function path(pathAr,obj){return paths
|
189
|
+
*/var path=/*#__PURE__*/_curry2(function path(pathAr,obj){return paths([pathAr],obj)[0];});
|
190
190
|
|
191
191
|
/**
|
192
192
|
* Creates a new object with the own properties of the two provided objects. If
|
@@ -212,7 +212,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
212
212
|
* { b: true, thing: 'bar', values: [15, 35] });
|
213
213
|
* //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
214
214
|
* @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
215
|
-
*/var mergeWithKey=/*#__PURE__*/_curry3(function mergeWithKey(fn,l,r){var result={};var k;l=l||{};r=r||{};for(k in l){if(_has(k,l)){result[k]=_has(k,r)?fn(k,l[k],r[k]):l[k];}}for(k in r){if(_has(k,r)&&!_has(k,result)){result[k]=r[k];}}return result;});
|
215
|
+
*/var mergeWithKey=/*#__PURE__*/_curry3(function mergeWithKey(fn,l,r){var result={};var k;l=l||{};r=r||{};for(k in l){if(_has(k,l)){result[k]=_has(k,r)?fn(k,l[k],r[k]):l[k];}}for(k in r){if(_has(k,r)&&!_has(k,result)){result[k]=r[k];}}return result;});
|
216
216
|
|
217
217
|
/**
|
218
218
|
* Creates a new object with the own properties of the two provided objects.
|
@@ -241,7 +241,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
241
241
|
* { a: true, c: { thing: 'foo', values: [10, 20] }},
|
242
242
|
* { b: true, c: { thing: 'bar', values: [15, 35] }});
|
243
243
|
* //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
|
244
|
-
*/var mergeDeepWithKey=/*#__PURE__*/_curry3(function mergeDeepWithKey(fn,lObj,rObj){return mergeWithKey
|
244
|
+
*/var mergeDeepWithKey=/*#__PURE__*/_curry3(function mergeDeepWithKey(fn,lObj,rObj){return mergeWithKey(function(k,lVal,rVal){if(_isObject(lVal)&&_isObject(rVal)){return mergeDeepWithKey(fn,lVal,rVal);}else {return fn(k,lVal,rVal);}},lObj,rObj);});
|
245
245
|
|
246
246
|
/**
|
247
247
|
* Creates a new object with the own properties of the two provided objects.
|
@@ -269,7 +269,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
269
269
|
* { a: true, c: { values: [10, 20] }},
|
270
270
|
* { b: true, c: { values: [15, 35] }});
|
271
271
|
* //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
|
272
|
-
*/var mergeDeepWith=/*#__PURE__*/_curry3(function mergeDeepWith(fn,lObj,rObj){return mergeDeepWithKey
|
272
|
+
*/var mergeDeepWith=/*#__PURE__*/_curry3(function mergeDeepWith(fn,lObj,rObj){return mergeDeepWithKey(function(k,lVal,rVal){return fn(lVal,rVal);},lObj,rObj);});
|
273
273
|
|
274
274
|
/**
|
275
275
|
* Returns a partial copy of an object containing only the keys that satisfy
|
@@ -290,7 +290,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
290
290
|
*
|
291
291
|
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
292
292
|
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
293
|
-
*/var pickBy=/*#__PURE__*/_curry2(function pickBy(test,obj){var result={};for(var prop in obj){if(test(obj[prop],prop,obj)){result[prop]=obj[prop];}}return result;});
|
293
|
+
*/var pickBy=/*#__PURE__*/_curry2(function pickBy(test,obj){var result={};for(var prop in obj){if(test(obj[prop],prop,obj)){result[prop]=obj[prop];}}return result;});
|
294
294
|
|
295
295
|
/**
|
296
296
|
* A function to check given value is a function
|
@@ -331,7 +331,7 @@ const isFunction=value=>typeof value==='function'&&Boolean(value.constructor&&va
|
|
331
331
|
* @returns true if the input is an instance of Error and false otherwise
|
332
332
|
*/const isTypeOfError=obj=>obj instanceof Error;
|
333
333
|
|
334
|
-
const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return path
|
334
|
+
const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return path(pathParts,obj);};const hasValueByPath=(obj,path)=>Boolean(getValueByPath(obj,path));/**
|
335
335
|
* Checks if the input is an object literal or built-in object type and not null
|
336
336
|
* @param value Input value
|
337
337
|
* @returns true if the input is an object and not null
|
@@ -339,8 +339,8 @@ const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return p
|
|
339
339
|
* Checks if the input is an object literal and not null
|
340
340
|
* @param value Input value
|
341
341
|
* @returns true if the input is an object and not null
|
342
|
-
*/const isObjectLiteralAndNotNull=value=>!isNull(value)&&Object.prototype.toString.call(value)==='[object Object]';const mergeDeepRightObjectArrays=(leftValue,rightValue)=>{if(!Array.isArray(leftValue)||!Array.isArray(rightValue)){return clone
|
343
|
-
mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mergeDeepRight=(leftObject,rightObject)=>mergeDeepWith
|
342
|
+
*/const isObjectLiteralAndNotNull=value=>!isNull(value)&&Object.prototype.toString.call(value)==='[object Object]';const mergeDeepRightObjectArrays=(leftValue,rightValue)=>{if(!Array.isArray(leftValue)||!Array.isArray(rightValue)){return clone(rightValue);}const mergedArray=clone(leftValue);rightValue.forEach((value,index)=>{mergedArray[index]=Array.isArray(value)||isObjectAndNotNull(value)?// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
343
|
+
mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mergeDeepRight=(leftObject,rightObject)=>mergeDeepWith(mergeDeepRightObjectArrays,leftObject,rightObject);/**
|
344
344
|
Checks if the input is a non-empty object literal type and not undefined or null
|
345
345
|
* @param value input any
|
346
346
|
* @returns boolean
|
@@ -348,11 +348,11 @@ mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mer
|
|
348
348
|
* A utility to recursively remove undefined values from an object
|
349
349
|
* @param obj input object
|
350
350
|
* @returns a new object
|
351
|
-
*/const removeUndefinedValues=obj=>{const result=pickBy
|
351
|
+
*/const removeUndefinedValues=obj=>{const result=pickBy(isDefined,obj);Object.keys(result).forEach(key=>{const value=result[key];if(isObjectLiteralAndNotNull(value)){result[key]=removeUndefinedValues(value);}});return result;};/**
|
352
352
|
* A utility to recursively remove undefined and null values from an object
|
353
353
|
* @param obj input object
|
354
354
|
* @returns a new object
|
355
|
-
*/const removeUndefinedAndNullValues=obj=>{const result=pickBy
|
355
|
+
*/const removeUndefinedAndNullValues=obj=>{const result=pickBy(isDefinedAndNotNull,obj);Object.keys(result).forEach(key=>{const value=result[key];if(isObjectLiteralAndNotNull(value)){result[key]=removeUndefinedAndNullValues(value);}});return result;};
|
356
356
|
|
357
357
|
const trim=value=>value.replace(/^\s+|\s+$/gm,'');const removeDoubleSpaces=value=>value.replace(/ {2,}/g,' ');/**
|
358
358
|
* A function to convert values to string
|
@@ -386,25 +386,25 @@ const trim=value=>value.replace(/^\s+|\s+$/gm,'');const removeDoubleSpaces=value
|
|
386
386
|
if(isString(category)&&!isString(name)){delete payload.category;payload.name=category;}// Rest of the code is just to clean up undefined values
|
387
387
|
// and set some proper defaults
|
388
388
|
// Also, to clone the incoming object type arguments
|
389
|
-
if(!isDefined(payload.category)){delete payload.category;}if(!isDefined(payload.name)){delete payload.name;}payload.properties=payload.properties?clone
|
389
|
+
if(!isDefined(payload.category)){delete payload.category;}if(!isDefined(payload.name)){delete payload.name;}payload.properties=payload.properties?clone(payload.properties):{};if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}// add name and category to properties
|
390
390
|
payload.properties=mergeDeepRight(isObjectLiteralAndNotNull(payload.properties)?payload.properties:{},{name:isString(payload.name)?payload.name:null,category:isString(payload.category)?payload.category:null});return payload;};/*
|
391
391
|
* Normalise the overloaded arguments of the track call facade
|
392
392
|
*/const trackArgumentsToCallOptions=(event,properties,options,callback)=>{const payload={name:event,properties:properties,options:options};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.properties=properties;delete payload.options;payload.callback=options;}if(isFunction(properties)){delete payload.properties;delete payload.options;payload.callback=properties;}// Rest of the code is just to clean up undefined values
|
393
393
|
// and set some proper defaults
|
394
394
|
// Also, to clone the incoming object type arguments
|
395
|
-
payload.properties=isDefinedAndNotNull(payload.properties)?clone
|
395
|
+
payload.properties=isDefinedAndNotNull(payload.properties)?clone(payload.properties):{};if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}return payload;};/*
|
396
396
|
* Normalise the overloaded arguments of the identify call facade
|
397
397
|
*/const identifyArgumentsToCallOptions=(userId,traits,options,callback)=>{const payload={userId:userId,traits:traits,options:options};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.userId=userId;payload.traits=traits;delete payload.options;payload.callback=options;}if(isFunction(traits)){payload.userId=userId;delete payload.traits;delete payload.options;payload.callback=traits;}if(isObjectLiteralAndNotNull(userId)||isNull(userId)){// Explicitly set null to prevent resetting the existing value
|
398
398
|
// in the Analytics class
|
399
399
|
payload.userId=null;payload.traits=userId;payload.options=traits;}// Rest of the code is just to clean up undefined values
|
400
400
|
// and set some proper defaults
|
401
401
|
// Also, to clone the incoming object type arguments
|
402
|
-
if(isDefined(payload.userId)){payload.userId=tryStringify(payload.userId);}else {delete payload.userId;}if(isObjectLiteralAndNotNull(payload.traits)){payload.traits=clone
|
402
|
+
if(isDefined(payload.userId)){payload.userId=tryStringify(payload.userId);}else {delete payload.userId;}if(isObjectLiteralAndNotNull(payload.traits)){payload.traits=clone(payload.traits);}else {delete payload.traits;}if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}return payload;};/*
|
403
403
|
* Normalise the overloaded arguments of the alias call facade
|
404
404
|
*/const aliasArgumentsToCallOptions=(to,from,options,callback)=>{const payload={to:to,from:from,options:options};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.to=to;payload.from=from;delete payload.options;payload.callback=options;}if(isFunction(from)){payload.to=to;delete payload.from;delete payload.options;payload.callback=from;}else if(isObjectLiteralAndNotNull(from)||isNull(from)){payload.to=to;delete payload.from;payload.options=from;}if(isFunction(to)){delete payload.to;delete payload.from;delete payload.options;payload.callback=to;}else if(isObjectLiteralAndNotNull(to)||isNull(to)){delete payload.to;delete payload.from;payload.options=to;}// Rest of the code is just to clean up undefined values
|
405
405
|
// and set some proper defaults
|
406
406
|
// Also, to clone the incoming object type arguments
|
407
|
-
if(isDefined(payload.to)){payload.to=tryStringify(payload.to);}else {delete payload.to;}if(isDefined(payload.from)){payload.from=tryStringify(payload.from);}else {delete payload.from;}if(isDefined(payload.options)){payload.options=clone
|
407
|
+
if(isDefined(payload.to)){payload.to=tryStringify(payload.to);}else {delete payload.to;}if(isDefined(payload.from)){payload.from=tryStringify(payload.from);}else {delete payload.from;}if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}return payload;};/*
|
408
408
|
* Normalise the overloaded arguments of the group call facade
|
409
409
|
*/const groupArgumentsToCallOptions=(groupId,traits,options,callback)=>{const payload={groupId:groupId,traits:traits,options:options};if(isFunction(callback)){payload.callback=callback;}if(isFunction(options)){payload.groupId=groupId;payload.traits=traits;delete payload.options;payload.callback=options;}if(isFunction(traits)){payload.groupId=groupId;delete payload.traits;delete payload.options;payload.callback=traits;}// TODO: why do we enable overload for group that only passes callback? is there any use case?
|
410
410
|
if(isFunction(groupId)){// Explicitly set null to prevent resetting the existing value
|
@@ -413,11 +413,11 @@ payload.groupId=null;delete payload.traits;delete payload.options;payload.callba
|
|
413
413
|
payload.groupId=null;payload.traits=groupId;payload.options=!isFunction(traits)?traits:null;}// Rest of the code is just to clean up undefined values
|
414
414
|
// and set some proper defaults
|
415
415
|
// Also, to clone the incoming object type arguments
|
416
|
-
if(isDefined(payload.groupId)){payload.groupId=tryStringify(payload.groupId);}else {delete payload.groupId;}payload.traits=isObjectLiteralAndNotNull(payload.traits)?clone
|
416
|
+
if(isDefined(payload.groupId)){payload.groupId=tryStringify(payload.groupId);}else {delete payload.groupId;}payload.traits=isObjectLiteralAndNotNull(payload.traits)?clone(payload.traits):{};if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}return payload;};
|
417
417
|
|
418
418
|
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';
|
419
419
|
|
420
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.0.0-beta.
|
420
|
+
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.0.0-beta.20';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';
|
421
421
|
|
422
422
|
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';
|
423
423
|
|
@@ -450,7 +450,7 @@ if(queryObject.get(QUERY_PARAM_ANONYMOUS_ID_KEY)){argumentsArray.unshift(['setAn
|
|
450
450
|
* Retrieve an existing buffered load method call and remove from the existing array
|
451
451
|
*/const getPreloadedLoadEvent=preloadedEventsArray=>{const loadMethodName='load';let loadEvent=[];/**
|
452
452
|
* Iterate the buffered API calls until we find load call and process it separately
|
453
|
-
*/let i=0;while(i<preloadedEventsArray.length){if(preloadedEventsArray[i]&&preloadedEventsArray[i][0]===loadMethodName){loadEvent=clone
|
453
|
+
*/let i=0;while(i<preloadedEventsArray.length){if(preloadedEventsArray[i]&&preloadedEventsArray[i][0]===loadMethodName){loadEvent=clone(preloadedEventsArray[i]);preloadedEventsArray.splice(i,1);break;}i+=1;}return loadEvent;};/**
|
454
454
|
* Promote consent events to the top of the preloaded events array
|
455
455
|
* @param preloadedEventsArray Preloaded events array
|
456
456
|
* @returns None
|
@@ -533,6 +533,10 @@ timeoutID=globalThis.setTimeout(()=>{reject(new Error(SCRIPT_LOAD_TIMEOUT_ERROR(
|
|
533
533
|
|
534
534
|
function i(){throw new Error("Cycle detected");}var t=Symbol.for("preact-signals");function r(){if(!(v>1)){var i,t=!1;while(void 0!==f){var r=f;f=void 0;e++;while(void 0!==r){var n=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&l(r))try{r.c();}catch(r){if(!t){i=r;t=!0;}}r=n;}}e=0;v--;if(t)throw i;}else v--;}function n(i){if(v>0)return i();v++;try{return i();}finally{r();}}var o=void 0;var f=void 0,v=0,e=0,u=0;function c(i){if(void 0!==o){var t=i.n;if(void 0===t||t.t!==o){t={i:0,S:i,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t};if(void 0!==o.s)o.s.n=t;o.s=t;i.n=t;if(32&o.f)i.S(t);return t;}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=o.s;t.n=void 0;o.s.n=t;o.s=t;}return t;}}}function d$1(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0;}d$1.prototype.brand=t;d$1.prototype.h=function(){return !0;};d$1.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i;}};d$1.prototype.U=function(i){if(void 0!==this.t){var t=i.e,r=i.x;if(void 0!==t){t.x=r;i.e=void 0;}if(void 0!==r){r.e=t;i.x=void 0;}if(i===this.t)this.t=r;}};d$1.prototype.subscribe=function(i){var t=this;return O(function(){var r=t.value,n=32&this.f;this.f&=-33;try{i(r);}finally{this.f|=n;}});};d$1.prototype.valueOf=function(){return this.value;};d$1.prototype.toString=function(){return this.value+"";};d$1.prototype.toJSON=function(){return this.value;};d$1.prototype.peek=function(){return this.v;};Object.defineProperty(d$1.prototype,"value",{get:function(){var i=c(this);if(void 0!==i)i.i=this.i;return this.v;},set:function(t){if(o instanceof _)!function(){throw new Error("Computed cannot have side-effects");}();if(t!==this.v){if(e>100)i();this.v=t;this.i++;u++;v++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N();}finally{r();}}}});function a(i){return new d$1(i);}function l(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return !0;return !1;}function y(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break;}}}function w(i){var t=i.s,r=void 0;while(void 0!==t){var n=t.p;if(-1===t.i){t.S.U(t);if(void 0!==n)n.n=t.n;if(void 0!==t.n)t.n.p=n;}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=n;}i.s=r;}function _(i){d$1.call(this,void 0);this.x=i;this.s=void 0;this.g=u-1;this.f=4;}(_.prototype=new d$1()).h=function(){this.f&=-3;if(1&this.f)return !1;if(32==(36&this.f))return !0;this.f&=-5;if(this.g===u)return !0;this.g=u;this.f|=1;if(this.i>0&&!l(this)){this.f&=-2;return !0;}var i=o;try{y(this);o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++;}}catch(i){this.v=i;this.f|=16;this.i++;}o=i;w(this);this.f&=-2;return !0;};_.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t);}d$1.prototype.S.call(this,i);};_.prototype.U=function(i){if(void 0!==this.t){d$1.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t);}}};_.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N();}};_.prototype.peek=function(){if(!this.h())i();if(16&this.f)throw this.v;return this.v;};Object.defineProperty(_.prototype,"value",{get:function(){if(1&this.f)i();var t=c(this);this.h();if(void 0!==t)t.i=this.i;if(16&this.f)throw this.v;return this.v;}});function g(i){var t=i.u;i.u=void 0;if("function"==typeof t){v++;var n=o;o=void 0;try{t();}catch(t){i.f&=-2;i.f|=8;b(i);throw t;}finally{o=n;r();}}}function b(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;g(i);}function x$1(i){if(o!==this)throw new Error("Out-of-order effect");w(this);o=i;this.f&=-2;if(8&this.f)b(this);r();}function E(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;}E.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t;}finally{i();}};E.prototype.S=function(){if(1&this.f)i();this.f|=1;this.f&=-9;g(this);y(this);v++;var t=o;o=this;return x$1.bind(this,t);};E.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=f;f=this;}};E.prototype.d=function(){this.f|=8;if(!(1&this.f))b(this);};function O(i){var t=new E(i);try{t.c();}catch(i){t.d();throw i;}return t.d.bind(t);}
|
535
535
|
|
536
|
+
/**
|
537
|
+
* A buffer queue to serve as a store for any type of data
|
538
|
+
*/class BufferQueue{constructor(){this.items=[];}enqueue(item){this.items.push(item);}dequeue(){if(this.items.length===0){return null;}return this.items.shift();}isEmpty(){return this.items.length===0;}size(){return this.items.length;}clear(){this.items=[];}}
|
539
|
+
|
536
540
|
const LOG_LEVEL_MAP={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5};const DEFAULT_LOG_LEVEL='ERROR';const LOG_MSG_PREFIX='RS SDK';const LOG_MSG_PREFIX_STYLE='font-weight: bold; background: black; color: white;';const LOG_MSG_STYLE='font-weight: normal;';/**
|
537
541
|
* Service to log messages/data to output provider, default is console
|
538
542
|
*/class Logger{constructor(minLogLevel=DEFAULT_LOG_LEVEL,scope='',logProvider=console){this.minLogLevel=LOG_LEVEL_MAP[minLogLevel];this.scope=scope;this.logProvider=logProvider;}log(...data){this.outputLog('LOG',data);}info(...data){this.outputLog('INFO',data);}debug(...data){this.outputLog('DEBUG',data);}warn(...data){this.outputLog('WARN',data);}error(...data){this.outputLog('ERROR',data);}outputLog(logMethod,data){if(this.minLogLevel<=LOG_LEVEL_MAP[logMethod]){this.logProvider[logMethod.toLowerCase()]?.(...this.formatLogData(data));}}setScope(scopeVal){this.scope=scopeVal||this.scope;}// TODO: should we allow to change the level via global variable on run time
|
@@ -565,7 +569,7 @@ const DEFAULT_CONFIG_BE_URL='https://api.rudderstack.com';
|
|
565
569
|
|
566
570
|
const DEFAULT_ERROR_REPORTING_PROVIDER='bugsnag';const DEFAULT_STORAGE_ENCRYPTION_VERSION='v3';const ConsentManagersToPluginNameMap={oneTrust:'OneTrustConsentManager',ketch:'KetchConsentManager',custom:'CustomConsentManager'};const ErrorReportingProvidersToPluginNameMap={[DEFAULT_ERROR_REPORTING_PROVIDER]:'Bugsnag'};const StorageEncryptionVersionsToPluginNameMap={[DEFAULT_STORAGE_ENCRYPTION_VERSION]:'StorageEncryption',legacy:'StorageEncryptionLegacy'};
|
567
571
|
|
568
|
-
const defaultLoadOptions={logLevel:'ERROR',configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:{All:true},useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:false,uaChTrackLevel:'none',plugins:[],useGlobalIntegrationsConfigInEvents:false,bufferDataPlaneEventsUntilReady:false,dataPlaneEventsBufferTimeout:DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS,storage:{encryption:{version:DEFAULT_STORAGE_ENCRYPTION_VERSION},migrate:false},sendAdblockPageOptions:{}};const loadOptionsState=a(clone
|
572
|
+
const defaultLoadOptions={logLevel:'ERROR',configUrl:DEFAULT_CONFIG_BE_URL,loadIntegration:true,sessions:{autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS},sameSiteCookie:'Lax',polyfillIfRequired:true,integrations:{All:true},useBeacon:false,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:false,uaChTrackLevel:'none',plugins:[],useGlobalIntegrationsConfigInEvents:false,bufferDataPlaneEventsUntilReady:false,dataPlaneEventsBufferTimeout:DEFAULT_DATA_PLANE_EVENTS_BUFFER_TIMEOUT_MS,storage:{encryption:{version:DEFAULT_STORAGE_ENCRYPTION_VERSION},migrate:false},sendAdblockPageOptions:{}};const loadOptionsState=a(clone(defaultLoadOptions));
|
569
573
|
|
570
574
|
const USER_SESSION_STORAGE_KEYS={userId:'rl_user_id',userTraits:'rl_trait',anonymousId:'rl_anonymous_id',groupId:'rl_group_id',groupTraits:'rl_group_trait',initialReferrer:'rl_page_init_referrer',initialReferringDomain:'rl_page_init_referring_domain',sessionInfo:'rl_session',authToken:'rl_auth_token'};const DEFAULT_USER_SESSION_VALUES={userId:'',userTraits:{},anonymousId:'',groupId:'',groupTraits:{},initialReferrer:'',initialReferringDomain:'',sessionInfo:{},authToken:null};
|
571
575
|
|
@@ -573,7 +577,7 @@ const defaultSessionInfo={autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS};con
|
|
573
577
|
|
574
578
|
const capabilitiesState={isOnline:a(true),storage:{isLocalStorageAvailable:a(false),isCookieStorageAvailable:a(false),isSessionStorageAvailable:a(false)},isBeaconAvailable:a(false),isLegacyDOM:a(false),isUaCHAvailable:a(false),isCryptoAvailable:a(false),isIE11:a(false),isAdBlocked:a(false)};
|
575
579
|
|
576
|
-
const reportingState={isErrorReportingEnabled:a(false),isMetricsReportingEnabled:a(false),errorReportingProviderPluginName:a(undefined)};
|
580
|
+
const reportingState={isErrorReportingEnabled:a(false),isMetricsReportingEnabled:a(false),errorReportingProviderPluginName:a(undefined),isErrorReportingPluginLoaded:a(false)};
|
577
581
|
|
578
582
|
const sourceConfigState=a(undefined);
|
579
583
|
|
@@ -593,7 +597,7 @@ const pluginsState={ready:a(false),loadedPlugins:a([]),failedPlugins:a([]),plugi
|
|
593
597
|
|
594
598
|
const storageState={encryptionPluginName:a(undefined),migrate:a(false),type:a(undefined),cookie:a(undefined),entries:a({}),trulyAnonymousTracking:a(false)};
|
595
599
|
|
596
|
-
const defaultStateValues={capabilities:capabilitiesState,consents:consentsState,context:contextState,eventBuffer:eventBufferState,lifecycle:lifecycleState,loadOptions:loadOptionsState,metrics:metricsState,nativeDestinations:nativeDestinationsState,plugins:pluginsState,reporting:reportingState,session:sessionState,source:sourceConfigState,storage:storageState};const state={...clone
|
600
|
+
const defaultStateValues={capabilities:capabilitiesState,consents:consentsState,context:contextState,eventBuffer:eventBufferState,lifecycle:lifecycleState,loadOptions:loadOptionsState,metrics:metricsState,nativeDestinations:nativeDestinationsState,plugins:pluginsState,reporting:reportingState,session:sessionState,source:sourceConfigState,storage:storageState};const state={...clone(defaultStateValues)};
|
597
601
|
|
598
602
|
// to next or return the value if it is the last one instead of an array per
|
599
603
|
// plugin that is the normal invoke
|
@@ -607,9 +611,14 @@ if(throws){throw err;}else {this.logger?.error(PLUGIN_INVOCATION_ERROR(PLUGIN_EN
|
|
607
611
|
|
608
612
|
const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX];
|
609
613
|
|
614
|
+
const LOAD_ORIGIN='RS_JS_SDK';
|
615
|
+
|
610
616
|
/**
|
611
617
|
* Utility method to normalise errors
|
612
|
-
*/const processError=error=>{let errorMessage;try{if(isString(error)){errorMessage=error;}else if(error instanceof Error){errorMessage=error.message;}else {errorMessage=error.message
|
618
|
+
*/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;}// TODO: remove this block once all device mode integrations start using the v3 script loader module (TS)
|
619
|
+
else if(error instanceof Event){const eventTarget=error.target;// Discard all the non-script loading errors
|
620
|
+
if(eventTarget&&eventTarget.localName!=='script'){return '';}// Discard script errors that are not originated at SDK or from native SDKs
|
621
|
+
if(eventTarget?.dataset&&(eventTarget.dataset.loader!==LOAD_ORIGIN||eventTarget.dataset.isnonnativesdk!=='true')){return '';}errorMessage=`Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`;}else {errorMessage=error.message?error.message:stringifyWithoutCircular(error);}}catch(e){errorMessage=`Unknown error: ${e.message}`;}return errorMessage;};/**
|
613
622
|
* A function to determine whether the error should be promoted to notify or not
|
614
623
|
* @param {Error} error
|
615
624
|
* @returns
|
@@ -618,10 +627,12 @@ const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO
|
|
618
627
|
/**
|
619
628
|
* A service to handle errors
|
620
629
|
*/class ErrorHandler{// If no logger is passed errors will be thrown as unhandled error
|
621
|
-
constructor(logger,pluginEngine){this.logger=logger;this.pluginEngine=pluginEngine;}init(externalSrcLoader){if(!this.pluginEngine){return;}try{const extPoint='errorReporting.init';const errReportingInitVal=this.pluginEngine.invokeSingle(extPoint,state,this.pluginEngine,externalSrcLoader,this.logger);if(errReportingInitVal instanceof Promise){errReportingInitVal.then(client=>{this.errReportingClient=client;}).catch(err=>{this.logger?.error(REPORTING_PLUGIN_INIT_FAILURE_ERROR(ERROR_HANDLER),err);});}}catch(err){this.onError(err,ERROR_HANDLER);}}onError(error,context='',customMessage='',shouldAlwaysThrow=false){// Error handling is already implemented in processError method
|
630
|
+
constructor(logger,pluginEngine){this.logger=logger;this.pluginEngine=pluginEngine;this.errorBuffer=new BufferQueue();this.attachEffect();}attachEffect(){if(state.reporting.isErrorReportingPluginLoaded.value===true){while(this.errorBuffer.size()>0){this.errorBuffer.dequeue();}}}attachErrorListeners(){if('addEventListener'in globalThis){globalThis.addEventListener('error',event=>{this.onError(event,undefined,undefined,undefined,'unhandledException');});globalThis.addEventListener('unhandledrejection',event=>{this.onError(event,undefined,undefined,undefined,'unhandledPromiseRejection');});}else {this.logger?.debug(`Failed to attach global error listeners.`);}}init(externalSrcLoader){if(!this.pluginEngine){return;}try{const extPoint='errorReporting.init';const errReportingInitVal=this.pluginEngine.invokeSingle(extPoint,state,this.pluginEngine,externalSrcLoader,this.logger);if(errReportingInitVal instanceof Promise){errReportingInitVal.then(client=>{this.errReportingClient=client;}).catch(err=>{this.logger?.error(REPORTING_PLUGIN_INIT_FAILURE_ERROR(ERROR_HANDLER),err);});}}catch(err){this.onError(err,ERROR_HANDLER);}}onError(error,context='',customMessage='',shouldAlwaysThrow=false,errorType='handled'){// Error handling is already implemented in processError method
|
622
631
|
let errorMessage=processError(error);// If no error message after we normalize, then we swallow/ignore the errors
|
623
|
-
if(!errorMessage){return;}
|
624
|
-
|
632
|
+
if(!errorMessage){return;}// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
633
|
+
errorMessage=removeDoubleSpaces(`${context}${LOG_CONTEXT_SEPARATOR}${customMessage} ${errorMessage}`);let normalizedError=new Error(errorMessage);if(isTypeOfError(error)){normalizedError=Object.create(error,{message:{value:errorMessage}});}if(errorType==='handled'){// TODO: Remove the below line once the new Reporting plugin is ready
|
634
|
+
this.notifyError(normalizedError);if(this.logger){this.logger.error(errorMessage);if(shouldAlwaysThrow){throw normalizedError;}}else {throw normalizedError;}}// eslint-disable-next-line sonarjs/no-all-duplicated-branches
|
635
|
+
if(state.reporting.isErrorReportingEnabled.value&&!state.reporting.isErrorReportingPluginLoaded.value);}/**
|
625
636
|
* Add breadcrumbs to add insight of a user's journey before an error
|
626
637
|
* occurred and send to external error monitoring service via a plugin
|
627
638
|
*
|
@@ -688,7 +699,7 @@ const EVENT_PAYLOAD_SIZE_CHECK_FAIL_WARNING=(context,payloadSize,sizeLimit)=>`${
|
|
688
699
|
* Updates certain parameters like sentAt timestamp, integrations config etc.
|
689
700
|
* @param event RudderEvent object
|
690
701
|
* @returns Final event ready to be delivered
|
691
|
-
*/const getFinalEventForDeliveryMutator=(event,currentTime)=>{const finalEvent=clone
|
702
|
+
*/const getFinalEventForDeliveryMutator=(event,currentTime)=>{const finalEvent=clone(event);// Update sentAt timestamp to the latest timestamp
|
692
703
|
finalEvent.sentAt=currentTime;return finalEvent;};
|
693
704
|
|
694
705
|
const ENCRYPTION_PREFIX_V3='RS_ENC_v3_';
|
@@ -853,158 +864,160 @@ if(!cmpConfig?.consents){return true;}const configuredConsents=cmpConfig.consent
|
|
853
864
|
// the configured resolution strategy
|
854
865
|
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;}}}});
|
855
866
|
|
856
|
-
const DIR_NAME$
|
867
|
+
const DIR_NAME$1b='AdobeAnalytics';const DISPLAY_NAME$1b='Adobe Analytics';
|
857
868
|
|
858
|
-
const DIR_NAME$
|
869
|
+
const DIR_NAME$1a='Amplitude';const DISPLAY_NAME$1a='Amplitude';
|
859
870
|
|
860
|
-
const DIR_NAME$
|
871
|
+
const DIR_NAME$19='Appcues';const DISPLAY_NAME$19='Appcues';
|
861
872
|
|
862
|
-
const DIR_NAME$
|
873
|
+
const DIR_NAME$18='BingAds';const DISPLAY_NAME$18='Bing Ads';
|
863
874
|
|
864
|
-
const DIR_NAME$
|
875
|
+
const DIR_NAME$17='Braze';const DISPLAY_NAME$17='Braze';
|
865
876
|
|
866
|
-
const DIR_NAME$
|
877
|
+
const DIR_NAME$16='Bugsnag';const DISPLAY_NAME$16='Bugsnag';
|
867
878
|
|
868
|
-
const DIR_NAME$
|
879
|
+
const DIR_NAME$15='Chartbeat';const DISPLAY_NAME$15='Chartbeat';
|
869
880
|
|
870
|
-
const DIR_NAME$
|
881
|
+
const DIR_NAME$14='Clevertap';const DISPLAY_NAME$14='CleverTap';
|
871
882
|
|
872
|
-
const DIR_NAME$
|
883
|
+
const DIR_NAME$13='Comscore';const DISPLAY_NAME$13='Comscore';
|
873
884
|
|
874
|
-
const DIR_NAME$
|
885
|
+
const DIR_NAME$12='Criteo';const DISPLAY_NAME$12='Criteo';
|
875
886
|
|
876
|
-
const DIR_NAME$
|
887
|
+
const DIR_NAME$11='CustomerIO';const DISPLAY_NAME$11='Customer IO';
|
877
888
|
|
878
|
-
const DIR_NAME
|
889
|
+
const DIR_NAME$10='Drip';const DISPLAY_NAME$10='Drip';
|
879
890
|
|
880
|
-
const DIR_NAME
|
891
|
+
const DIR_NAME$$='FacebookPixel';const DISPLAY_NAME$$='Facebook Pixel';
|
881
892
|
|
882
|
-
const DIR_NAME$
|
893
|
+
const DIR_NAME$_='Fullstory';const DISPLAY_NAME$_='Fullstory';
|
883
894
|
|
884
|
-
const DIR_NAME$
|
895
|
+
const DIR_NAME$Z='GA';const DISPLAY_NAME$Z='Google Analytics';
|
885
896
|
|
886
|
-
const DIR_NAME$
|
897
|
+
const DIR_NAME$Y='GA4';const DISPLAY_NAME$Y='Google Analytics 4 (GA4)';
|
887
898
|
|
888
|
-
const DIR_NAME$
|
899
|
+
const DIR_NAME$X='GoogleAds';const DISPLAY_NAME$X='Google Ads';
|
889
900
|
|
890
|
-
const DIR_NAME$
|
901
|
+
const DIR_NAME$W='GoogleOptimize';const DISPLAY_NAME$W='Google Optimize';
|
891
902
|
|
892
|
-
const DIR_NAME$
|
903
|
+
const DIR_NAME$V='GoogleTagManager';const DISPLAY_NAME$V='Google Tag Manager';
|
893
904
|
|
894
|
-
const DIR_NAME$
|
905
|
+
const DIR_NAME$U='Heap';const DISPLAY_NAME$U='Heap.io';
|
895
906
|
|
896
|
-
const DIR_NAME$
|
907
|
+
const DIR_NAME$T='Hotjar';const DISPLAY_NAME$T='Hotjar';
|
897
908
|
|
898
|
-
const DIR_NAME$
|
909
|
+
const DIR_NAME$S='HubSpot';const DISPLAY_NAME$S='HubSpot';
|
899
910
|
|
900
|
-
const DIR_NAME$
|
911
|
+
const DIR_NAME$R='INTERCOM';const DISPLAY_NAME$R='Intercom';
|
901
912
|
|
902
|
-
const DIR_NAME$
|
913
|
+
const DIR_NAME$Q='Keen';const DISPLAY_NAME$Q='Keen';
|
903
914
|
|
904
|
-
const DIR_NAME$
|
915
|
+
const DIR_NAME$P='Kissmetrics';const DISPLAY_NAME$P='Kiss Metrics';
|
905
916
|
|
906
|
-
const DIR_NAME$
|
917
|
+
const DIR_NAME$O='Klaviyo';const DISPLAY_NAME$O='Klaviyo';
|
907
918
|
|
908
|
-
const DIR_NAME$
|
919
|
+
const DIR_NAME$N='LaunchDarkly';const DISPLAY_NAME$N='LaunchDarkly';
|
909
920
|
|
910
|
-
const DIR_NAME$
|
921
|
+
const DIR_NAME$M='LinkedInInsightTag';const DISPLAY_NAME$M='Linkedin Insight Tag';
|
911
922
|
|
912
|
-
const DIR_NAME$
|
923
|
+
const DIR_NAME$L='Lotame';const DISPLAY_NAME$L='Lotame';
|
913
924
|
|
914
|
-
const DIR_NAME$
|
925
|
+
const DIR_NAME$K='Lytics';const DISPLAY_NAME$K='Lytics';
|
915
926
|
|
916
|
-
const DIR_NAME$
|
927
|
+
const DIR_NAME$J='Mixpanel';const DISPLAY_NAME$J='Mixpanel';
|
917
928
|
|
918
|
-
const DIR_NAME$
|
929
|
+
const DIR_NAME$I='MoEngage';const DISPLAY_NAME$I='MoEngage';
|
919
930
|
|
920
|
-
const DIR_NAME$
|
931
|
+
const DIR_NAME$H='Optimizely';const DISPLAY_NAME$H='Optimizely Web';
|
921
932
|
|
922
|
-
const DIR_NAME$
|
933
|
+
const DIR_NAME$G='Pendo';const DISPLAY_NAME$G='Pendo';
|
923
934
|
|
924
|
-
const DIR_NAME$
|
935
|
+
const DIR_NAME$F='PinterestTag';const DISPLAY_NAME$F='Pinterest Tag';
|
925
936
|
|
926
|
-
const DIR_NAME$
|
937
|
+
const DIR_NAME$E='PostAffiliatePro';const DISPLAY_NAME$E='Post Affiliate Pro';
|
927
938
|
|
928
|
-
const DIR_NAME$
|
939
|
+
const DIR_NAME$D='Posthog';const DISPLAY_NAME$D='PostHog';
|
929
940
|
|
930
|
-
const DIR_NAME$
|
941
|
+
const DIR_NAME$C='ProfitWell';const DISPLAY_NAME$C='ProfitWell';
|
931
942
|
|
932
|
-
const DIR_NAME$
|
943
|
+
const DIR_NAME$B='Qualtrics';const DISPLAY_NAME$B='Qualtrics';
|
933
944
|
|
934
|
-
const DIR_NAME$
|
945
|
+
const DIR_NAME$A='QuantumMetric';const DISPLAY_NAME$A='Quantum Metric';
|
935
946
|
|
936
|
-
const DIR_NAME$
|
947
|
+
const DIR_NAME$z='RedditPixel';const DISPLAY_NAME$z='Reddit Pixel';
|
937
948
|
|
938
|
-
const DIR_NAME$
|
949
|
+
const DIR_NAME$y='Sentry';const DISPLAY_NAME$y='Sentry';
|
939
950
|
|
940
|
-
const DIR_NAME$
|
951
|
+
const DIR_NAME$x='SnapPixel';const DISPLAY_NAME$x='Snap Pixel';
|
941
952
|
|
942
|
-
const DIR_NAME$
|
953
|
+
const DIR_NAME$w='TVSquared';const DISPLAY_NAME$w='TVSquared';
|
943
954
|
|
944
|
-
const DIR_NAME$
|
955
|
+
const DIR_NAME$v='VWO';const DISPLAY_NAME$v='VWO';
|
945
956
|
|
946
|
-
const DIR_NAME$
|
957
|
+
const DIR_NAME$u='GA360';const DISPLAY_NAME$u='Google Analytics 360';
|
947
958
|
|
948
|
-
const DIR_NAME$
|
959
|
+
const DIR_NAME$t='Adroll';const DISPLAY_NAME$t='Adroll';
|
949
960
|
|
950
|
-
const DIR_NAME$
|
961
|
+
const DIR_NAME$s='DCMFloodlight';const DISPLAY_NAME$s='DCM Floodlight';
|
951
962
|
|
952
|
-
const DIR_NAME$
|
963
|
+
const DIR_NAME$r='Matomo';const DISPLAY_NAME$r='Matomo';
|
953
964
|
|
954
|
-
const DIR_NAME$
|
965
|
+
const DIR_NAME$q='Vero';const DISPLAY_NAME$q='Vero';
|
955
966
|
|
956
|
-
const DIR_NAME$
|
967
|
+
const DIR_NAME$p='Mouseflow';const DISPLAY_NAME$p='Mouseflow';
|
957
968
|
|
958
|
-
const DIR_NAME$
|
969
|
+
const DIR_NAME$o='Rockerbox';const DISPLAY_NAME$o='Rockerbox';
|
959
970
|
|
960
|
-
const DIR_NAME$
|
971
|
+
const DIR_NAME$n='ConvertFlow';const DISPLAY_NAME$n='ConvertFlow';
|
961
972
|
|
962
|
-
const DIR_NAME$
|
973
|
+
const DIR_NAME$m='SnapEngage';const DISPLAY_NAME$m='SnapEngage';
|
963
974
|
|
964
|
-
const DIR_NAME$
|
975
|
+
const DIR_NAME$l='LiveChat';const DISPLAY_NAME$l='LiveChat';
|
965
976
|
|
966
|
-
const DIR_NAME$
|
977
|
+
const DIR_NAME$k='Shynet';const DISPLAY_NAME$k='Shynet';
|
967
978
|
|
968
|
-
const DIR_NAME$
|
979
|
+
const DIR_NAME$j='Woopra';const DISPLAY_NAME$j='Woopra';
|
969
980
|
|
970
|
-
const DIR_NAME$
|
981
|
+
const DIR_NAME$i='RollBar';const DISPLAY_NAME$i='RollBar';
|
971
982
|
|
972
|
-
const DIR_NAME$
|
983
|
+
const DIR_NAME$h='QuoraPixel';const DISPLAY_NAME$h='Quora Pixel';
|
973
984
|
|
974
|
-
const DIR_NAME$
|
985
|
+
const DIR_NAME$g='June';const DISPLAY_NAME$g='June';
|
975
986
|
|
976
|
-
const DIR_NAME$
|
987
|
+
const DIR_NAME$f='Engage';const DISPLAY_NAME$f='Engage';
|
977
988
|
|
978
|
-
const DIR_NAME$
|
989
|
+
const DIR_NAME$e='Iterable';const DISPLAY_NAME$e='Iterable';
|
979
990
|
|
980
|
-
const DIR_NAME$
|
991
|
+
const DIR_NAME$d='YandexMetrica';const DISPLAY_NAME$d='Yandex.Metrica';
|
981
992
|
|
982
|
-
const DIR_NAME$
|
993
|
+
const DIR_NAME$c='Refiner';const DISPLAY_NAME$c='Refiner';
|
983
994
|
|
984
|
-
const DIR_NAME$
|
995
|
+
const DIR_NAME$b='Qualaroo';const DISPLAY_NAME$b='Qualaroo';
|
985
996
|
|
986
|
-
const DIR_NAME$
|
997
|
+
const DIR_NAME$a='Podsights';const DISPLAY_NAME$a='Podsights';
|
987
998
|
|
988
|
-
const DIR_NAME$
|
999
|
+
const DIR_NAME$9='Axeptio';const DISPLAY_NAME$9='Axeptio';
|
989
1000
|
|
990
|
-
const DIR_NAME$
|
1001
|
+
const DIR_NAME$8='Satismeter';const DISPLAY_NAME$8='Satismeter';
|
991
1002
|
|
992
|
-
const DIR_NAME$
|
1003
|
+
const DIR_NAME$7='MicrosoftClarity';const DISPLAY_NAME$7='Microsoft Clarity';
|
993
1004
|
|
994
|
-
const DIR_NAME$
|
1005
|
+
const DIR_NAME$6='Sendinblue';const DISPLAY_NAME$6='Sendinblue';
|
995
1006
|
|
996
|
-
const DIR_NAME$
|
1007
|
+
const DIR_NAME$5='Olark';const DISPLAY_NAME$5='Olark';
|
997
1008
|
|
998
|
-
const DIR_NAME$
|
1009
|
+
const DIR_NAME$4='Lemnisk';const DISPLAY_NAME$4='Lemnisk';
|
999
1010
|
|
1000
|
-
const DIR_NAME$
|
1011
|
+
const DIR_NAME$3='TiktokAds';const DISPLAY_NAME$3='TikTok Ads';
|
1001
1012
|
|
1002
|
-
const DIR_NAME$
|
1013
|
+
const DIR_NAME$2='ActiveCampaign';const DISPLAY_NAME$2='Active Campaign';
|
1003
1014
|
|
1004
|
-
const DIR_NAME='Sprig';const DISPLAY_NAME='Sprig';
|
1015
|
+
const DIR_NAME$1='Sprig';const DISPLAY_NAME$1='Sprig';
|
1016
|
+
|
1017
|
+
const DIR_NAME='SpotifyPixel';const DISPLAY_NAME='Spotify Pixel';
|
1005
1018
|
|
1006
1019
|
// map of the destination display names to the destination directory names
|
1007
|
-
const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$
|
1020
|
+
const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$S]:DIR_NAME$S,[DISPLAY_NAME$Z]:DIR_NAME$Z,[DISPLAY_NAME$T]:DIR_NAME$T,[DISPLAY_NAME$X]:DIR_NAME$X,[DISPLAY_NAME$v]:DIR_NAME$v,[DISPLAY_NAME$V]:DIR_NAME$V,[DISPLAY_NAME$17]:DIR_NAME$17,[DISPLAY_NAME$R]:DIR_NAME$R,[DISPLAY_NAME$Q]:DIR_NAME$Q,[DISPLAY_NAME$P]:DIR_NAME$P,[DISPLAY_NAME$11]:DIR_NAME$11,[DISPLAY_NAME$15]:DIR_NAME$15,[DISPLAY_NAME$13]:DIR_NAME$13,[DISPLAY_NAME$$]:DIR_NAME$$,[DISPLAY_NAME$L]:DIR_NAME$L,[DISPLAY_NAME$H]:DIR_NAME$H,[DISPLAY_NAME$16]:DIR_NAME$16,[DISPLAY_NAME$_]:DIR_NAME$_,[DISPLAY_NAME$w]:DIR_NAME$w,[DISPLAY_NAME$Y]:DIR_NAME$Y,[DISPLAY_NAME$I]:DIR_NAME$I,[DISPLAY_NAME$1a]:DIR_NAME$1a,[DISPLAY_NAME$G]:DIR_NAME$G,[DISPLAY_NAME$K]:DIR_NAME$K,[DISPLAY_NAME$19]:DIR_NAME$19,[DISPLAY_NAME$D]:DIR_NAME$D,[DISPLAY_NAME$O]:DIR_NAME$O,[DISPLAY_NAME$14]:DIR_NAME$14,[DISPLAY_NAME$18]:DIR_NAME$18,[DISPLAY_NAME$F]:DIR_NAME$F,[DISPLAY_NAME$1b]:DIR_NAME$1b,[DISPLAY_NAME$M]:DIR_NAME$M,[DISPLAY_NAME$z]:DIR_NAME$z,[DISPLAY_NAME$10]:DIR_NAME$10,[DISPLAY_NAME$U]:DIR_NAME$U,[DISPLAY_NAME$12]:DIR_NAME$12,[DISPLAY_NAME$J]:DIR_NAME$J,[DISPLAY_NAME$B]:DIR_NAME$B,[DISPLAY_NAME$C]:DIR_NAME$C,[DISPLAY_NAME$y]:DIR_NAME$y,[DISPLAY_NAME$A]:DIR_NAME$A,[DISPLAY_NAME$x]:DIR_NAME$x,[DISPLAY_NAME$E]:DIR_NAME$E,[DISPLAY_NAME$W]:DIR_NAME$W,[DISPLAY_NAME$N]:DIR_NAME$N,[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};
|
1008
1021
|
|
1009
1022
|
const DEFAULT_INTEGRATIONS_CONFIG={All:true};
|
1010
1023
|
|
@@ -1027,19 +1040,19 @@ const DESTINATION_NOT_SUPPORTED_ERROR=destUserFriendlyId=>`Destination ${destUse
|
|
1027
1040
|
* @param sdkTypeName The name of the destination SDK type
|
1028
1041
|
* @param logger Logger instance
|
1029
1042
|
* @returns true if the destination SDK code is evaluated, false otherwise
|
1030
|
-
*/const isDestinationSDKMounted=(destSDKIdentifier,sdkTypeName,logger)=>Boolean(globalThis[destSDKIdentifier]&&globalThis[destSDKIdentifier][sdkTypeName]&&globalThis[destSDKIdentifier][sdkTypeName].prototype&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');const createDestinationInstance=(destSDKIdentifier,sdkTypeName,dest,state)=>{const rAnalytics=globalThis.rudderanalytics;const analytics=rAnalytics.getAnalyticsInstance(state.lifecycle.writeKey.value);return new globalThis[destSDKIdentifier][sdkTypeName](clone
|
1043
|
+
*/const isDestinationSDKMounted=(destSDKIdentifier,sdkTypeName,logger)=>Boolean(globalThis[destSDKIdentifier]&&globalThis[destSDKIdentifier][sdkTypeName]&&globalThis[destSDKIdentifier][sdkTypeName].prototype&&typeof globalThis[destSDKIdentifier][sdkTypeName].prototype.constructor!=='undefined');const createDestinationInstance=(destSDKIdentifier,sdkTypeName,dest,state)=>{const rAnalytics=globalThis.rudderanalytics;const analytics=rAnalytics.getAnalyticsInstance(state.lifecycle.writeKey.value);return new globalThis[destSDKIdentifier][sdkTypeName](clone(dest.config),{loadIntegration:state.nativeDestinations.loadIntegration.value,logLevel:state.lifecycle.logLevel.value,loadOnlyIntegrations:state.consents.postConsent.value?.integrations??state.nativeDestinations.loadOnlyIntegrations.value,page:(category,name,properties,options,callback)=>analytics.page(pageArgumentsToCallOptions(category,name,properties,options,callback)),track:(event,properties,options,callback)=>analytics.track(trackArgumentsToCallOptions(event,properties,options,callback)),identify:(userId,traits,options,callback)=>analytics.identify(identifyArgumentsToCallOptions(userId,traits,options,callback)),alias:(to,from,options,callback)=>analytics.alias(aliasArgumentsToCallOptions(to,from,options,callback)),group:(groupId,traits,options,callback)=>analytics.group(groupArgumentsToCallOptions(groupId,traits,options,callback)),getAnonymousId:()=>analytics.getAnonymousId(),getUserId:()=>analytics.getUserId(),getUserTraits:()=>analytics.getUserTraits(),getGroupId:()=>analytics.getGroupId(),getGroupTraits:()=>analytics.getGroupTraits(),getSessionId:()=>analytics.getSessionId()},{shouldApplyDeviceModeTransformation:dest.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:dest.propagateEventsUntransformedOnError,destinationId:dest.id});};const isDestinationReady=dest=>new Promise((resolve,reject)=>{const instance=dest.instance;let handleNumber;const checkReady=()=>{if(instance.isLoaded()&&(!instance.isReady||instance.isReady())){resolve(true);}else {handleNumber=globalThis.requestAnimationFrame(checkReady);}};checkReady();setTimeout(()=>{globalThis.cancelAnimationFrame(handleNumber);reject(new Error(DESTINATION_READY_TIMEOUT_ERROR(READY_CHECK_TIMEOUT_MS,dest.userFriendlyId)));},READY_CHECK_TIMEOUT_MS);});/**
|
1031
1044
|
* Extracts the integration config, if any, from the given destination
|
1032
1045
|
* and merges it with the current integrations config
|
1033
1046
|
* @param dest Destination object
|
1034
1047
|
* @param curDestIntgConfig Current destinations integration config
|
1035
1048
|
* @param logger Logger object
|
1036
1049
|
* @returns Combined destinations integrations config
|
1037
|
-
*/const getCumulativeIntegrationsConfig=(dest,curDestIntgConfig,errorHandler)=>{let integrationsConfig=curDestIntgConfig;if(isFunction(dest.instance?.getDataForIntegrationsObject)){try{integrationsConfig=mergeDeepRight(curDestIntgConfig,dest.instance?.getDataForIntegrationsObject());}catch(err){errorHandler?.onError(err,DEVICE_MODE_DESTINATIONS_PLUGIN,DESTINATION_INTEGRATIONS_DATA_ERROR(dest.userFriendlyId));}}return integrationsConfig;};const initializeDestination=(dest,state,destSDKIdentifier,sdkTypeName,errorHandler,logger)=>{try{const initializedDestination=clone
|
1050
|
+
*/const getCumulativeIntegrationsConfig=(dest,curDestIntgConfig,errorHandler)=>{let integrationsConfig=curDestIntgConfig;if(isFunction(dest.instance?.getDataForIntegrationsObject)){try{integrationsConfig=mergeDeepRight(curDestIntgConfig,dest.instance?.getDataForIntegrationsObject());}catch(err){errorHandler?.onError(err,DEVICE_MODE_DESTINATIONS_PLUGIN,DESTINATION_INTEGRATIONS_DATA_ERROR(dest.userFriendlyId));}}return integrationsConfig;};const initializeDestination=(dest,state,destSDKIdentifier,sdkTypeName,errorHandler,logger)=>{try{const initializedDestination=clone(dest);const destInstance=createDestinationInstance(destSDKIdentifier,sdkTypeName,dest,state);initializedDestination.instance=destInstance;destInstance.init();isDestinationReady(initializedDestination).then(()=>{// Collect the integrations data for the hybrid mode destinations
|
1038
1051
|
if(isHybridModeDestination(initializedDestination)){state.nativeDestinations.integrationsConfig.value=getCumulativeIntegrationsConfig(initializedDestination,state.nativeDestinations.integrationsConfig.value,errorHandler);}state.nativeDestinations.initializedDestinations.value=[...state.nativeDestinations.initializedDestinations.value,initializedDestination];}).catch(err=>{state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];// The error message is already formatted in the isDestinationReady function
|
1039
1052
|
logger?.error(err);});}catch(err){state.nativeDestinations.failedDestinations.value=[...state.nativeDestinations.failedDestinations.value,dest];errorHandler?.onError(err,DEVICE_MODE_DESTINATIONS_PLUGIN,DESTINATION_INIT_ERROR(dest.userFriendlyId));}};
|
1040
1053
|
|
1041
1054
|
const pluginName$b='DeviceModeDestinations';const DeviceModeDestinations=()=>({name:pluginName$b,initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName$b];},nativeDestinations:{setActiveDestinations(state,pluginsManager,errorHandler,logger){// Normalize the integration options from the load API call
|
1042
|
-
state.nativeDestinations.loadOnlyIntegrations.value=clone
|
1055
|
+
state.nativeDestinations.loadOnlyIntegrations.value=clone(state.loadOptions.value.integrations)??DEFAULT_INTEGRATIONS_CONFIG;state.nativeDestinations.loadIntegration.value=state.loadOptions.value.loadIntegration;// Filter destination that doesn't have mapping config-->Integration names
|
1043
1056
|
const configSupportedDestinations=state.nativeDestinations.configuredDestinations.value.filter(configDest=>{if(destDisplayNamesToFileNamesMap[configDest.displayName]){return true;}errorHandler?.onError(new Error(DESTINATION_NOT_SUPPORTED_ERROR(configDest.userFriendlyId)),DEVICE_MODE_DESTINATIONS_PLUGIN);return false;});// Filter destinations that are disabled through load or consent API options
|
1044
1057
|
const destinationsToLoad=filterDestinations(state.consents.postConsent.value?.integrations??state.nativeDestinations.loadOnlyIntegrations.value,configSupportedDestinations);const consentedDestinations=destinationsToLoad.filter(dest=>// if consent manager is not configured, then default to load the destination
|
1045
1058
|
pluginsManager.invokeSingle(`consentManager.isDestinationConsented`,state,dest.config,errorHandler,logger)??true);state.nativeDestinations.activeDestinations.value=consentedDestinations;},load(state,externalSrcLoader,errorHandler,logger,externalScriptOnLoad){const integrationsCDNPath=state.lifecycle.integrationsCDNPath.value;const activeDestinations=state.nativeDestinations.activeDestinations.value;activeDestinations.forEach(dest=>{const sdkName=destDisplayNamesToFileNamesMap[dest.displayName];const destSDKIdentifier=`${sdkName}_RS`;// this is the name of the object loaded on the window
|
@@ -1222,7 +1235,7 @@ const pluginName$5='NativeDestinationQueue';const NativeDestinationQueue=()=>({n
|
|
1222
1235
|
* @returns IQueue instance
|
1223
1236
|
*/init(state,pluginsManager,storeManager,dmtQueue,errorHandler,logger){const finalQOpts=getNormalizedQueueOptions$1(state.loadOptions.value.destinationsQueueOptions);const writeKey=state.lifecycle.writeKey.value;const eventsQueue=new RetryQueue(// adding write key to the queue name to avoid conflicts
|
1224
1237
|
`${QUEUE_NAME$1}_${writeKey}`,finalQOpts,(rudderEvent,done)=>{const destinationsToSend=filterDestinations(rudderEvent.integrations,state.nativeDestinations.initializedDestinations.value);// list of destinations which are enable for DMT
|
1225
|
-
const destWithTransformationEnabled=[];const clonedRudderEvent=clone
|
1238
|
+
const destWithTransformationEnabled=[];const clonedRudderEvent=clone(rudderEvent);destinationsToSend.forEach(dest=>{try{const sendEvent=!isEventDenyListed(clonedRudderEvent.type,clonedRudderEvent.event,dest);if(!sendEvent){logger?.warn(DESTINATION_EVENT_FILTERING_WARNING(NATIVE_DESTINATION_QUEUE_PLUGIN,clonedRudderEvent.event,dest.userFriendlyId));return;}if(dest.shouldApplyDeviceModeTransformation){destWithTransformationEnabled.push(dest);}else {sendEventToDestination(clonedRudderEvent,dest,errorHandler,logger);}}catch(e){errorHandler?.onError(e,NATIVE_DESTINATION_QUEUE_PLUGIN);}});if(destWithTransformationEnabled.length>0){pluginsManager.invokeSingle('transformEvent.enqueue',state,dmtQueue,clonedRudderEvent,destWithTransformationEnabled,errorHandler,logger);}// Mark success always
|
1226
1239
|
done(null);},storeManager,MEMORY_STORAGE);// TODO: This seems to not work as expected. Need to investigate
|
1227
1240
|
// effect(() => {
|
1228
1241
|
// if (state.nativeDestinations.clientDestinationsReady.value === true) {
|
@@ -2258,7 +2271,7 @@ const DATA_PLANE_API_VERSION='v1';const QUEUE_NAME='rudder';const XHR_QUEUE_PLUG
|
|
2258
2271
|
|
2259
2272
|
const EVENT_DELIVERY_FAILURE_ERROR_PREFIX=(context,url)=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to deliver event(s) to ${url}.`;
|
2260
2273
|
|
2261
|
-
const getBatchDeliveryPayload=(events,currentTime,logger)=>{const batchPayload={batch:events,sentAt:currentTime};return stringifyWithoutCircular(batchPayload,true,undefined,logger);};const getNormalizedQueueOptions=queueOpts=>mergeDeepRight(DEFAULT_RETRY_QUEUE_OPTIONS,queueOpts);const getDeliveryUrl=(dataplaneUrl,endpoint)=>{const dpUrl=new URL(dataplaneUrl);return new URL(removeDuplicateSlashes([dpUrl.pathname,'/',DATA_PLANE_API_VERSION,'/',endpoint].join('')),dpUrl).href;};const getBatchDeliveryUrl=dataplaneUrl=>getDeliveryUrl(dataplaneUrl,'batch');const logErrorOnFailure=(details,url,willBeRetried,attemptNumber,maxRetryAttempts,logger)=>{if(isUndefined(details?.error)||isUndefined(logger)){return;}const isRetryableFailure=isErrRetryable(details);let errMsg=EVENT_DELIVERY_FAILURE_ERROR_PREFIX(XHR_QUEUE_PLUGIN,url);const dropMsg=`The event(s) will be dropped.`;if(isRetryableFailure){if(willBeRetried){errMsg=`${errMsg} It/they will be retried.`;if(attemptNumber>0){errMsg=`${errMsg} Retry attempt ${attemptNumber} of ${maxRetryAttempts}.`;}}else {errMsg=`${errMsg} Retries exhausted (${maxRetryAttempts}). ${dropMsg}`;}}else {errMsg=`${errMsg} ${dropMsg}`;}logger?.error(errMsg);};const getRequestInfo=(itemData,state,logger)=>{let data;let headers;let url;const currentTime=getCurrentTimeFormatted();if(Array.isArray(itemData)){const finalEvents=itemData.map(queueItemData=>getFinalEventForDeliveryMutator(queueItemData.event,currentTime));data=getBatchDeliveryPayload(finalEvents,currentTime,logger);headers=itemData[0]?clone
|
2274
|
+
const getBatchDeliveryPayload=(events,currentTime,logger)=>{const batchPayload={batch:events,sentAt:currentTime};return stringifyWithoutCircular(batchPayload,true,undefined,logger);};const getNormalizedQueueOptions=queueOpts=>mergeDeepRight(DEFAULT_RETRY_QUEUE_OPTIONS,queueOpts);const getDeliveryUrl=(dataplaneUrl,endpoint)=>{const dpUrl=new URL(dataplaneUrl);return new URL(removeDuplicateSlashes([dpUrl.pathname,'/',DATA_PLANE_API_VERSION,'/',endpoint].join('')),dpUrl).href;};const getBatchDeliveryUrl=dataplaneUrl=>getDeliveryUrl(dataplaneUrl,'batch');const logErrorOnFailure=(details,url,willBeRetried,attemptNumber,maxRetryAttempts,logger)=>{if(isUndefined(details?.error)||isUndefined(logger)){return;}const isRetryableFailure=isErrRetryable(details);let errMsg=EVENT_DELIVERY_FAILURE_ERROR_PREFIX(XHR_QUEUE_PLUGIN,url);const dropMsg=`The event(s) will be dropped.`;if(isRetryableFailure){if(willBeRetried){errMsg=`${errMsg} It/they will be retried.`;if(attemptNumber>0){errMsg=`${errMsg} Retry attempt ${attemptNumber} of ${maxRetryAttempts}.`;}}else {errMsg=`${errMsg} Retries exhausted (${maxRetryAttempts}). ${dropMsg}`;}}else {errMsg=`${errMsg} ${dropMsg}`;}logger?.error(errMsg);};const getRequestInfo=(itemData,state,logger)=>{let data;let headers;let url;const currentTime=getCurrentTimeFormatted();if(Array.isArray(itemData)){const finalEvents=itemData.map(queueItemData=>getFinalEventForDeliveryMutator(queueItemData.event,currentTime));data=getBatchDeliveryPayload(finalEvents,currentTime,logger);headers=itemData[0]?clone(itemData[0].headers):{};url=getBatchDeliveryUrl(state.lifecycle.activeDataplaneUrl.value);}else {const{url:eventUrl,event,headers:eventHeaders}=itemData;const finalEvent=getFinalEventForDeliveryMutator(event,currentTime);data=getDeliveryPayload(finalEvent,logger);headers=clone(eventHeaders);url=eventUrl;}return {data,headers,url};};
|
2262
2275
|
|
2263
2276
|
const pluginName='XhrQueue';const XhrQueue=()=>({name:pluginName,deps:[],initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName];},dataplaneEventsQueue:{/**
|
2264
2277
|
* Initialize the queue for delivery
|
@@ -2606,7 +2619,7 @@ const validateWriteKey=writeKey=>{if(!isString(writeKey)||writeKey.trim().length
|
|
2606
2619
|
*/const isPositiveInteger=num=>isNumber(num)&&num>=0&&Number.isInteger(num);
|
2607
2620
|
|
2608
2621
|
const normalizeLoadOptions=(loadOptionsFromState,loadOptions)=>{// TODO: Maybe add warnings for invalid values
|
2609
|
-
const normalizedLoadOpts=clone
|
2622
|
+
const normalizedLoadOpts=clone(loadOptions);if(!isString(normalizedLoadOpts.setCookieDomain)){delete normalizedLoadOpts.setCookieDomain;}const cookieSameSiteValues=['Strict','Lax','None'];if(!cookieSameSiteValues.includes(normalizedLoadOpts.sameSiteCookie)){delete normalizedLoadOpts.sameSiteCookie;}normalizedLoadOpts.secureCookie=normalizedLoadOpts.secureCookie===true;const uaChTrackLevels=['none','default','full'];if(!uaChTrackLevels.includes(normalizedLoadOpts.uaChTrackLevel)){delete normalizedLoadOpts.uaChTrackLevel;}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.integrations)){delete normalizedLoadOpts.integrations;}normalizedLoadOpts.plugins=normalizedLoadOpts.plugins??defaultOptionalPluginsList;normalizedLoadOpts.useGlobalIntegrationsConfigInEvents=normalizedLoadOpts.useGlobalIntegrationsConfigInEvents===true;normalizedLoadOpts.bufferDataPlaneEventsUntilReady=normalizedLoadOpts.bufferDataPlaneEventsUntilReady===true;normalizedLoadOpts.sendAdblockPage=normalizedLoadOpts.sendAdblockPage===true;if(!isObjectLiteralAndNotNull(normalizedLoadOpts.sendAdblockPageOptions)){delete normalizedLoadOpts.sendAdblockPageOptions;}if(!isDefined(normalizedLoadOpts.loadIntegration)){delete normalizedLoadOpts.loadIntegration;}else {normalizedLoadOpts.loadIntegration=normalizedLoadOpts.loadIntegration===true;}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.storage)){delete normalizedLoadOpts.storage;}else {normalizedLoadOpts.storage=removeUndefinedAndNullValues(normalizedLoadOpts.storage);normalizedLoadOpts.storage.migrate=normalizedLoadOpts.storage?.migrate===true;}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.beaconQueueOptions)){delete normalizedLoadOpts.beaconQueueOptions;}else {normalizedLoadOpts.beaconQueueOptions=removeUndefinedAndNullValues(normalizedLoadOpts.beaconQueueOptions);}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.destinationsQueueOptions)){delete normalizedLoadOpts.destinationsQueueOptions;}else {normalizedLoadOpts.destinationsQueueOptions=removeUndefinedAndNullValues(normalizedLoadOpts.destinationsQueueOptions);}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.queueOptions)){delete normalizedLoadOpts.queueOptions;}else {normalizedLoadOpts.queueOptions=removeUndefinedAndNullValues(normalizedLoadOpts.queueOptions);}normalizedLoadOpts.lockIntegrationsVersion=normalizedLoadOpts.lockIntegrationsVersion===true;if(!isNumber(normalizedLoadOpts.dataPlaneEventsBufferTimeout)){delete normalizedLoadOpts.dataPlaneEventsBufferTimeout;}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.storage?.cookie)){delete normalizedLoadOpts.storage?.cookie;}else {normalizedLoadOpts.storage.cookie=removeUndefinedAndNullValues(normalizedLoadOpts.storage?.cookie);}if(!isObjectLiteralAndNotNull(normalizedLoadOpts.preConsent)){delete normalizedLoadOpts.preConsent;}else {normalizedLoadOpts.preConsent=removeUndefinedAndNullValues(normalizedLoadOpts.preConsent);}const mergedLoadOptions=mergeDeepRight(loadOptionsFromState,normalizedLoadOpts);return mergedLoadOptions;};const getSourceConfigURL=(configUrl,writeKey,lockIntegrationsVersion,logger)=>{const defSearchParams=new URLSearchParams({p:MODULE_TYPE,v:APP_VERSION,build:BUILD_TYPE,writeKey,lockIntegrationsVersion:lockIntegrationsVersion.toString()});let origin=DEFAULT_CONFIG_BE_URL;let searchParams=defSearchParams;let pathname='/sourceConfig/';let hash='';// Ideally, this check is not required but URL polyfill
|
2610
2623
|
// doesn't seem to throw errors for empty URLs
|
2611
2624
|
// TODO: Need to improve this check to find out if the URL is valid or not
|
2612
2625
|
if(configUrl){try{const configUrlInstance=new URL(configUrl);if(!removeTrailingSlashes(configUrlInstance.pathname).endsWith('/sourceConfig')){configUrlInstance.pathname=`${removeTrailingSlashes(configUrlInstance.pathname)}/sourceConfig/`;}configUrlInstance.pathname=removeDuplicateSlashes(configUrlInstance.pathname);defSearchParams.forEach((value,key)=>{if(configUrlInstance.searchParams.get(key)===null){configUrlInstance.searchParams.set(key,value);}});origin=configUrlInstance.origin;pathname=configUrlInstance.pathname;searchParams=configUrlInstance.searchParams;hash=configUrlInstance.hash;}catch(err){logger?.warn(INVALID_CONFIG_URL_WARNING(CONFIG_MANAGER,configUrl));}}return `${origin}${pathname}?${searchParams}${hash}`;};
|
@@ -2647,7 +2660,7 @@ const isErrorReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.error
|
|
2647
2660
|
* Validates and normalizes the consent options provided by the user
|
2648
2661
|
* @param options Consent options provided by the user
|
2649
2662
|
* @returns Validated and normalized consent options
|
2650
|
-
*/const getValidPostConsentOptions=options=>{const validOptions={sendPageEvent:false,trackConsent:false,discardPreConsentEvents:false};if(isObjectLiteralAndNotNull(options)){const clonedOptions=clone
|
2663
|
+
*/const getValidPostConsentOptions=options=>{const validOptions={sendPageEvent:false,trackConsent:false,discardPreConsentEvents:false};if(isObjectLiteralAndNotNull(options)){const clonedOptions=clone(options);validOptions.storage=clonedOptions.storage;if(isDefined(clonedOptions.integrations)){validOptions.integrations=isObjectLiteralAndNotNull(clonedOptions.integrations)?clonedOptions.integrations:DEFAULT_INTEGRATIONS_CONFIG;}validOptions.discardPreConsentEvents=clonedOptions.discardPreConsentEvents===true;validOptions.sendPageEvent=clonedOptions.sendPageEvent===true;validOptions.trackConsent=clonedOptions.trackConsent===true;if(isNonEmptyObject(clonedOptions.consentManagement)){// Override enabled value with the current state value
|
2651
2664
|
validOptions.consentManagement=mergeDeepRight(clonedOptions.consentManagement,{enabled:state.consents.enabled.value});}}return validOptions;};/**
|
2652
2665
|
* Validates if the input is a valid consents data
|
2653
2666
|
* @param value Input consents data
|
@@ -2687,7 +2700,7 @@ enabled:state.loadOptions.value.preConsent?.enabled===true&&initialized===false&
|
|
2687
2700
|
* @param resp Source config response
|
2688
2701
|
* @param logger Logger instance
|
2689
2702
|
*/const updateConsentsState=resp=>{let resolutionStrategy=state.consents.resolutionStrategy.value;let cmpMetadata;if(isObjectLiteralAndNotNull(resp.consentManagementMetadata)){if(state.consents.provider.value){resolutionStrategy=resp.consentManagementMetadata.providers.find(p=>p.provider===state.consents.provider.value)?.resolutionStrategy??state.consents.resolutionStrategy.value;}cmpMetadata=resp.consentManagementMetadata;}// If the provider is custom, then the resolution strategy is not applicable
|
2690
|
-
if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}n(()=>{state.consents.metadata.value=clone
|
2703
|
+
if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}n(()=>{state.consents.metadata.value=clone(cmpMetadata);state.consents.resolutionStrategy.value=resolutionStrategy;});};
|
2691
2704
|
|
2692
2705
|
/**
|
2693
2706
|
* A function that determines integration SDK loading path
|
@@ -2862,18 +2875,18 @@ rudderEvent.context=getMergedContext(rudderEvent.context,options);}};/**
|
|
2862
2875
|
* Returns the final integrations config for the event based on the global config and event's config
|
2863
2876
|
* @param integrationsConfig Event's integrations config
|
2864
2877
|
* @returns Final integrations config
|
2865
|
-
*/const getEventIntegrationsConfig=integrationsConfig=>{let finalIntgConfig;if(shouldUseGlobalIntegrationsConfigInEvents()){finalIntgConfig=clone
|
2878
|
+
*/const getEventIntegrationsConfig=integrationsConfig=>{let finalIntgConfig;if(shouldUseGlobalIntegrationsConfigInEvents()){finalIntgConfig=clone(state.consents.postConsent.value?.integrations??state.nativeDestinations.loadOnlyIntegrations.value);}else if(isObjectLiteralAndNotNull(integrationsConfig)){finalIntgConfig=integrationsConfig;}else {finalIntgConfig=DEFAULT_INTEGRATIONS_CONFIG;}return finalIntgConfig;};/**
|
2866
2879
|
* Enrich the base event object with data from state and the API options
|
2867
2880
|
* @param rudderEvent RudderEvent object
|
2868
2881
|
* @param options API options
|
2869
2882
|
* @param pageProps Page properties
|
2870
2883
|
* @param logger logger
|
2871
2884
|
* @returns Enriched RudderEvent object
|
2872
|
-
*/const getEnrichedEvent=(rudderEvent,options,pageProps,logger)=>{const commonEventData={channel:CHANNEL,context:{traits:clone
|
2873
|
-
...(state.consents.enabled.value&&{consentManagement:{deniedConsentIds:clone
|
2885
|
+
*/const getEnrichedEvent=(rudderEvent,options,pageProps,logger)=>{const commonEventData={channel:CHANNEL,context:{traits:clone(state.session.userTraits.value),sessionId:state.session.sessionInfo.value.id||undefined,sessionStart:state.session.sessionInfo.value.sessionStart||undefined,// Add 'consentManagement' only if consent management is enabled
|
2886
|
+
...(state.consents.enabled.value&&{consentManagement:{deniedConsentIds:clone(state.consents.data.value.deniedConsentIds),allowedConsentIds:clone(state.consents.data.value.allowedConsentIds),provider:state.consents.provider.value,resolutionStrategy:state.consents.resolutionStrategy.value}}),'ua-ch':state.context['ua-ch'].value,app:state.context.app.value,library:state.context.library.value,userAgent:state.context.userAgent.value,os:state.context.os.value,locale:state.context.locale.value,screen:state.context.screen.value,campaign:extractUTMParameters(globalThis.location.href),page:getContextPageProperties(pageProps),timezone:state.context.timezone.value},originalTimestamp:getCurrentTimeFormatted(),integrations:DEFAULT_INTEGRATIONS_CONFIG,messageId:generateUUID(),userId:rudderEvent.userId||state.session.userId.value};if(!isStorageTypeValidForStoringData(state.storage.entries.value.anonymousId?.type)){// Generate new anonymous id for each request
|
2874
2887
|
commonEventData.anonymousId=generateAnonymousId();}else {// Type casting to string as the user session manager will take care of initializing the value
|
2875
2888
|
commonEventData.anonymousId=state.session.anonymousId.value;}// set truly anonymous tracking flag
|
2876
|
-
if(state.storage.trulyAnonymousTracking.value){commonEventData.context.trulyAnonymousTracking=true;}if(rudderEvent.type==='identify'){commonEventData.context.traits=state.storage.entries.value.userTraits?.type!==NO_STORAGE?clone
|
2889
|
+
if(state.storage.trulyAnonymousTracking.value){commonEventData.context.trulyAnonymousTracking=true;}if(rudderEvent.type==='identify'){commonEventData.context.traits=state.storage.entries.value.userTraits?.type!==NO_STORAGE?clone(state.session.userTraits.value):rudderEvent.context.traits;}if(rudderEvent.type==='group'){if(rudderEvent.groupId||state.session.groupId.value){commonEventData.groupId=rudderEvent.groupId||state.session.groupId.value;}if(rudderEvent.traits||state.session.groupTraits.value){commonEventData.traits=state.storage.entries.value.groupTraits?.type!==NO_STORAGE?clone(state.session.groupTraits.value):rudderEvent.traits;}}const processedEvent=mergeDeepRight(rudderEvent,commonEventData);// Set the default values for the event properties
|
2877
2890
|
// matching with v1.1 payload
|
2878
2891
|
if(processedEvent.event===undefined){processedEvent.event=null;}if(processedEvent.properties===undefined){processedEvent.properties=null;}processOptions(processedEvent,options);checkForReservedElements(processedEvent,logger);// Update the integrations config for the event
|
2879
2892
|
processedEvent.integrations=getEventIntegrationsConfig(processedEvent.integrations);return processedEvent;};
|
@@ -3034,10 +3047,6 @@ if(state.session.sessionInfo.value.autoTrack){this.startOrRenewAutoTracking();}}
|
|
3034
3047
|
* @param userId
|
3035
3048
|
*/setAuthToken(token){state.session.authToken.value=this.isPersistenceEnabledForStorageEntry('authToken')&&token?token:DEFAULT_USER_SESSION_VALUES.authToken;}}
|
3036
3049
|
|
3037
|
-
/**
|
3038
|
-
* A buffer queue to serve as a store for any type of data
|
3039
|
-
*/class BufferQueue{constructor(){this.items=[];}enqueue(item){this.items.push(item);}dequeue(){if(this.items.length===0){return null;}return this.items.shift();}isEmpty(){return this.items.length===0;}size(){return this.items.length;}clear(){this.items=[];}}
|
3040
|
-
|
3041
3050
|
const DATA_PLANE_QUEUE_EXT_POINT_PREFIX='dataplaneEventsQueue';const DESTINATIONS_QUEUE_EXT_POINT_PREFIX='destinationsEventsQueue';const DMT_EXT_POINT_PREFIX='transformEvent';
|
3042
3051
|
|
3043
3052
|
/**
|
@@ -3045,12 +3054,12 @@ const DATA_PLANE_QUEUE_EXT_POINT_PREFIX='dataplaneEventsQueue';const DESTINATION
|
|
3045
3054
|
* @param eventIntgConfig User supplied integrations config at event level
|
3046
3055
|
* @param destinationsIntgConfig Cumulative integrations config from all destinations
|
3047
3056
|
* @returns Filtered user supplied integrations config
|
3048
|
-
*/const getOverriddenIntegrationOptions=(eventIntgConfig,destinationsIntgConfig)=>Object.keys(eventIntgConfig).filter(intgName=>eventIntgConfig[intgName]!==true||!destinationsIntgConfig[intgName]).reduce((obj,key)=>{const retVal=clone
|
3057
|
+
*/const getOverriddenIntegrationOptions=(eventIntgConfig,destinationsIntgConfig)=>Object.keys(eventIntgConfig).filter(intgName=>eventIntgConfig[intgName]!==true||!destinationsIntgConfig[intgName]).reduce((obj,key)=>{const retVal=clone(obj);retVal[key]=eventIntgConfig[key];return retVal;},{});/**
|
3049
3058
|
* Returns the event object with final integrations config
|
3050
3059
|
* @param event RudderEvent object
|
3051
3060
|
* @param state Application state
|
3052
3061
|
* @returns Mutated event with final integrations config
|
3053
|
-
*/const getFinalEvent=(event,state)=>{const finalEvent=clone
|
3062
|
+
*/const getFinalEvent=(event,state)=>{const finalEvent=clone(event);// Merge the destination specific integrations config with the event's integrations config
|
3054
3063
|
// In general, the preference is given to the event's integrations config
|
3055
3064
|
const eventIntgConfig=event.integrations??DEFAULT_INTEGRATIONS_CONFIG;const destinationsIntgConfig=state.nativeDestinations.integrationsConfig.value;const overriddenIntgOpts=getOverriddenIntegrationOptions(eventIntgConfig,destinationsIntgConfig);finalEvent.integrations=mergeDeepRight(destinationsIntgConfig,overriddenIntgOpts);return finalEvent;};const shouldBufferEventsForPreConsent=state=>state.consents.preConsent.value.enabled&&state.consents.preConsent.value.events?.delivery==='buffer'&&(state.consents.preConsent.value.storage?.strategy==='session'||state.consents.preConsent.value.storage?.strategy==='none');
|
3056
3065
|
|
@@ -3074,7 +3083,7 @@ if(state.loadOptions.value.bufferDataPlaneEventsUntilReady===true){timeoutId=glo
|
|
3074
3083
|
* Enqueues the event for processing
|
3075
3084
|
* @param event RudderEvent object
|
3076
3085
|
* @param callback API callback function
|
3077
|
-
*/enqueue(event,callback){let dpQEvent;try{dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);}catch(e){this.onError(e,DATAPLANE_PLUGIN_ENQUEUE_ERROR);}try{const dQEvent=clone
|
3086
|
+
*/enqueue(event,callback){let dpQEvent;try{dpQEvent=getFinalEvent(event,state);this.pluginsManager.invokeSingle(`${DATA_PLANE_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.dataplaneEventsQueue,dpQEvent,this.errorHandler,this.logger);}catch(e){this.onError(e,DATAPLANE_PLUGIN_ENQUEUE_ERROR);}try{const dQEvent=clone(event);this.pluginsManager.invokeSingle(`${DESTINATIONS_QUEUE_EXT_POINT_PREFIX}.enqueue`,state,this.destinationsEventsQueue,dQEvent,this.errorHandler,this.logger);}catch(e){this.onError(e,NATIVE_DEST_PLUGIN_ENQUEUE_ERROR);}// Invoke the callback if it exists
|
3078
3087
|
try{// Using the event sent to the data plane queue here
|
3079
3088
|
// to ensure the mutated (if any) event is sent to the callback
|
3080
3089
|
callback?.(dpQEvent);}catch(error){this.onError(error,API_CALLBACK_INVOKE_ERROR);}}/**
|
@@ -3092,7 +3101,7 @@ const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{
|
|
3092
3101
|
* Initialize services and components or use default ones if singletons
|
3093
3102
|
*/constructor(){this.preloadBuffer=new BufferQueue();this.initialized=false;this.errorHandler=defaultErrorHandler;this.logger=defaultLogger;this.externalSrcLoader=new ExternalSrcLoader(this.errorHandler,this.logger);this.capabilitiesManager=new CapabilitiesManager(this.errorHandler,this.logger);this.httpClient=defaultHttpClient;}/**
|
3094
3103
|
* Start application lifecycle if not already started
|
3095
|
-
*/load(writeKey,dataPlaneUrl,loadOptions={}){if(state.lifecycle.status.value){return;}let clonedDataPlaneUrl=clone
|
3104
|
+
*/load(writeKey,dataPlaneUrl,loadOptions={}){if(state.lifecycle.status.value){return;}let clonedDataPlaneUrl=clone(dataPlaneUrl);let clonedLoadOptions=clone(loadOptions);// dataPlaneUrl is not provided
|
3096
3105
|
if(isObjectAndNotNull(dataPlaneUrl)){clonedLoadOptions=dataPlaneUrl;clonedDataPlaneUrl=undefined;}// Set initial state values
|
3097
3106
|
n(()=>{state.lifecycle.writeKey.value=writeKey;state.lifecycle.dataPlaneUrl.value=clonedDataPlaneUrl;state.loadOptions.value=normalizeLoadOptions(state.loadOptions.value,clonedLoadOptions);state.lifecycle.status.value='mounted';});// set log level as early as possible
|
3098
3107
|
if(state.loadOptions.value.logLevel){this.logger?.setMinLogLevel(state.loadOptions.value.logLevel);}// Expose state to global objects
|
@@ -3107,7 +3116,7 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
3107
3116
|
* Load browser polyfill if required
|
3108
3117
|
*/onMounted(){this.capabilitiesManager.init();}/**
|
3109
3118
|
* Enqueue in SDK preload buffer events, used from preloadBuffer component
|
3110
|
-
*/enqueuePreloadBufferEvents(bufferedEvents){if(Array.isArray(bufferedEvents)){bufferedEvents.forEach(bufferedEvent=>this.preloadBuffer.enqueue(clone
|
3119
|
+
*/enqueuePreloadBufferEvents(bufferedEvents){if(Array.isArray(bufferedEvents)){bufferedEvents.forEach(bufferedEvent=>this.preloadBuffer.enqueue(clone(bufferedEvent)));}}/**
|
3111
3120
|
* Process the buffer preloaded events by passing their arguments to the respective facade methods
|
3112
3121
|
*/processDataInPreloadBuffer(){while(this.preloadBuffer.size()>0){const eventToProcess=this.preloadBuffer.dequeue();if(eventToProcess){consumePreloadBufferedEvent([...eventToProcess],this);}}}prepareInternalServices(){this.pluginsManager=new PluginsManager(defaultPluginEngine,this.errorHandler,this.logger);this.storeManager=new StoreManager(this.pluginsManager,this.errorHandler,this.logger);this.configManager=new ConfigManager(this.httpClient,this.errorHandler,this.logger);this.userSessionManager=new UserSessionManager(this.errorHandler,this.logger,this.pluginsManager,this.storeManager);this.eventRepository=new EventRepository(this.pluginsManager,this.storeManager,this.errorHandler,this.logger);this.eventManager=new EventManager(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger);}/**
|
3113
3122
|
* Load configuration
|
@@ -3186,7 +3195,7 @@ if(state.consents.postConsent.value.trackConsent){const trackOptions=trackArgume
|
|
3186
3195
|
constructor(){if(RudderAnalytics.globalSingleton){// START-NO-SONAR-SCAN
|
3187
3196
|
// eslint-disable-next-line no-constructor-return
|
3188
3197
|
return RudderAnalytics.globalSingleton;// END-NO-SONAR-SCAN
|
3189
|
-
}this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this);this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this);this.load=this.load.bind(this);this.ready=this.ready.bind(this);this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this);this.page=this.page.bind(this);this.track=this.track.bind(this);this.identify=this.identify.bind(this);this.alias=this.alias.bind(this);this.group=this.group.bind(this);this.reset=this.reset.bind(this);this.getAnonymousId=this.getAnonymousId.bind(this);this.setAnonymousId=this.setAnonymousId.bind(this);this.getUserId=this.getUserId.bind(this);this.getUserTraits=this.getUserTraits.bind(this);this.getGroupId=this.getGroupId.bind(this);this.getGroupTraits=this.getGroupTraits.bind(this);this.startSession=this.startSession.bind(this);this.endSession=this.endSession.bind(this);this.getSessionId=this.getSessionId.bind(this);this.setAuthToken=this.setAuthToken.bind(this);this.consent=this.consent.bind(this);RudderAnalytics.globalSingleton=this;// start loading if a load event was buffered or wait for explicit load call
|
3198
|
+
}defaultErrorHandler.attachErrorListeners();this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this);this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this);this.load=this.load.bind(this);this.ready=this.ready.bind(this);this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this);this.page=this.page.bind(this);this.track=this.track.bind(this);this.identify=this.identify.bind(this);this.alias=this.alias.bind(this);this.group=this.group.bind(this);this.reset=this.reset.bind(this);this.getAnonymousId=this.getAnonymousId.bind(this);this.setAnonymousId=this.setAnonymousId.bind(this);this.getUserId=this.getUserId.bind(this);this.getUserTraits=this.getUserTraits.bind(this);this.getGroupId=this.getGroupId.bind(this);this.getGroupTraits=this.getGroupTraits.bind(this);this.startSession=this.startSession.bind(this);this.endSession=this.endSession.bind(this);this.getSessionId=this.getSessionId.bind(this);this.setAuthToken=this.setAuthToken.bind(this);this.consent=this.consent.bind(this);RudderAnalytics.globalSingleton=this;// start loading if a load event was buffered or wait for explicit load call
|
3190
3199
|
this.triggerBufferedLoadEvent();}/**
|
3191
3200
|
* Set instance to use if no specific writeKey is provided in methods
|
3192
3201
|
* automatically for the first created instance
|
@@ -3203,7 +3212,7 @@ promotePreloadedConsentEventsToTop(preloadedEventsArray);// Get any load method
|
|
3203
3212
|
// BTW, load method is also removed from the array
|
3204
3213
|
// So, the Analytics object can directly consume the remaining events
|
3205
3214
|
const loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
|
3206
|
-
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone
|
3215
|
+
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
|
3207
3216
|
if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
|
3208
3217
|
loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
3209
3218
|
// @ts-ignore
|