@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
@@ -54,7 +54,7 @@ function _has(prop,obj){return Object.prototype.hasOwnProperty.call(obj,prop);}
|
|
54
54
|
* R.type(() => {}); //=> "Function"
|
55
55
|
* R.type(async () => {}); //=> "AsyncFunction"
|
56
56
|
* R.type(undefined); //=> "Undefined"
|
57
|
-
*/var type=/*#__PURE__*/_curry1(function type(val){return val===null?'Null':val===undefined?'Undefined':Object.prototype.toString.call(val).slice(8,-1);});
|
57
|
+
*/var type=/*#__PURE__*/_curry1(function type(val){return val===null?'Null':val===undefined?'Undefined':Object.prototype.toString.call(val).slice(8,-1);});
|
58
58
|
|
59
59
|
function _isObject(x){return Object.prototype.toString.call(x)==='[object Object]';}
|
60
60
|
|
@@ -94,7 +94,7 @@ function _isString(x){return Object.prototype.toString.call(x)==='[object String
|
|
94
94
|
* @symb R.nth(-1, [a, b, c]) = c
|
95
95
|
* @symb R.nth(0, [a, b, c]) = a
|
96
96
|
* @symb R.nth(1, [a, b, c]) = b
|
97
|
-
*/var nth=/*#__PURE__*/_curry2(function nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];});
|
97
|
+
*/var nth=/*#__PURE__*/_curry2(function nth(offset,list){var idx=offset<0?list.length+offset:offset;return _isString(list)?list.charAt(idx):list[idx];});
|
98
98
|
|
99
99
|
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':''));}
|
100
100
|
|
@@ -107,7 +107,7 @@ function _cloneRegExp(pattern){return new RegExp(pattern.source,pattern.flags?pa
|
|
107
107
|
* @return {*} The copied value.
|
108
108
|
*/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.
|
109
109
|
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.
|
110
|
-
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
|
110
|
+
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){/**
|
111
111
|
* 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,
|
112
112
|
* on my tests this number is 180, anything above that using the hash function is faster.
|
113
113
|
*/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;}();
|
@@ -138,7 +138,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
138
138
|
* const objectsClone = R.clone(objects);
|
139
139
|
* objects === objectsClone; //=> false
|
140
140
|
* objects[0] === objectsClone[0]; //=> false
|
141
|
-
*/var clone=/*#__PURE__*/_curry1(function clone(value){return value!=null&&typeof value.clone==='function'?value.clone():_clone(value,true);});
|
141
|
+
*/var clone=/*#__PURE__*/_curry1(function clone(value){return value!=null&&typeof value.clone==='function'?value.clone():_clone(value,true);});
|
142
142
|
|
143
143
|
/**
|
144
144
|
* Retrieves the values at given paths of an object.
|
@@ -157,7 +157,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
157
157
|
*
|
158
158
|
* R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
|
159
159
|
* R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]
|
160
|
-
*/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
|
160
|
+
*/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;});});
|
161
161
|
|
162
162
|
/**
|
163
163
|
* Retrieves the value at a given path. The nodes of the path can be arbitrary strings or non-negative integers.
|
@@ -182,7 +182,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
182
182
|
* R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2
|
183
183
|
* R.path([2], {'2': 2}); //=> 2
|
184
184
|
* R.path([-2], {'-2': 'a'}); //=> undefined
|
185
|
-
*/var path=/*#__PURE__*/_curry2(function path(pathAr,obj){return paths
|
185
|
+
*/var path=/*#__PURE__*/_curry2(function path(pathAr,obj){return paths([pathAr],obj)[0];});
|
186
186
|
|
187
187
|
/**
|
188
188
|
* Creates a new object with the own properties of the two provided objects. If
|
@@ -208,7 +208,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
208
208
|
* { b: true, thing: 'bar', values: [15, 35] });
|
209
209
|
* //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
210
210
|
* @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
211
|
-
*/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;});
|
211
|
+
*/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;});
|
212
212
|
|
213
213
|
/**
|
214
214
|
* Creates a new object with the own properties of the two provided objects.
|
@@ -237,7 +237,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
237
237
|
* { a: true, c: { thing: 'foo', values: [10, 20] }},
|
238
238
|
* { b: true, c: { thing: 'bar', values: [15, 35] }});
|
239
239
|
* //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
|
240
|
-
*/var mergeDeepWithKey=/*#__PURE__*/_curry3(function mergeDeepWithKey(fn,lObj,rObj){return mergeWithKey
|
240
|
+
*/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);});
|
241
241
|
|
242
242
|
/**
|
243
243
|
* Creates a new object with the own properties of the two provided objects.
|
@@ -265,7 +265,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
265
265
|
* { a: true, c: { values: [10, 20] }},
|
266
266
|
* { b: true, c: { values: [15, 35] }});
|
267
267
|
* //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
|
268
|
-
*/var mergeDeepWith=/*#__PURE__*/_curry3(function mergeDeepWith(fn,lObj,rObj){return mergeDeepWithKey
|
268
|
+
*/var mergeDeepWith=/*#__PURE__*/_curry3(function mergeDeepWith(fn,lObj,rObj){return mergeDeepWithKey(function(k,lVal,rVal){return fn(lVal,rVal);},lObj,rObj);});
|
269
269
|
|
270
270
|
/**
|
271
271
|
* Returns a partial copy of an object containing only the keys that satisfy
|
@@ -286,7 +286,7 @@ var cachedCopy=map.get(value);if(cachedCopy){return cachedCopy;}map.set(value,co
|
|
286
286
|
*
|
287
287
|
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
288
288
|
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
289
|
-
*/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;});
|
289
|
+
*/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;});
|
290
290
|
|
291
291
|
/**
|
292
292
|
* A function to check given value is a function
|
@@ -327,7 +327,7 @@ const isFunction=value=>typeof value==='function'&&Boolean(value.constructor&&va
|
|
327
327
|
* @returns true if the input is an instance of Error and false otherwise
|
328
328
|
*/const isTypeOfError=obj=>obj instanceof Error;
|
329
329
|
|
330
|
-
const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return path
|
330
|
+
const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return path(pathParts,obj);};const hasValueByPath=(obj,path)=>Boolean(getValueByPath(obj,path));/**
|
331
331
|
* Checks if the input is an object literal or built-in object type and not null
|
332
332
|
* @param value Input value
|
333
333
|
* @returns true if the input is an object and not null
|
@@ -335,8 +335,8 @@ const getValueByPath=(obj,keyPath)=>{const pathParts=keyPath.split('.');return p
|
|
335
335
|
* Checks if the input is an object literal and not null
|
336
336
|
* @param value Input value
|
337
337
|
* @returns true if the input is an object and not null
|
338
|
-
*/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
|
339
|
-
mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mergeDeepRight=(leftObject,rightObject)=>mergeDeepWith
|
338
|
+
*/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
|
339
|
+
mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mergeDeepRight=(leftObject,rightObject)=>mergeDeepWith(mergeDeepRightObjectArrays,leftObject,rightObject);/**
|
340
340
|
Checks if the input is a non-empty object literal type and not undefined or null
|
341
341
|
* @param value input any
|
342
342
|
* @returns boolean
|
@@ -344,11 +344,11 @@ mergeDeepRight(mergedArray[index],value):value;});return mergedArray;};const mer
|
|
344
344
|
* A utility to recursively remove undefined values from an object
|
345
345
|
* @param obj input object
|
346
346
|
* @returns a new object
|
347
|
-
*/const removeUndefinedValues=obj=>{const result=pickBy
|
347
|
+
*/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;};/**
|
348
348
|
* A utility to recursively remove undefined and null values from an object
|
349
349
|
* @param obj input object
|
350
350
|
* @returns a new object
|
351
|
-
*/const removeUndefinedAndNullValues=obj=>{const result=pickBy
|
351
|
+
*/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;};
|
352
352
|
|
353
353
|
const trim=value=>value.replace(/^\s+|\s+$/gm,'');const removeDoubleSpaces=value=>value.replace(/ {2,}/g,' ');/**
|
354
354
|
* A function to convert values to string
|
@@ -382,25 +382,25 @@ const trim=value=>value.replace(/^\s+|\s+$/gm,'');const removeDoubleSpaces=value
|
|
382
382
|
if(isString(category)&&!isString(name)){delete payload.category;payload.name=category;}// Rest of the code is just to clean up undefined values
|
383
383
|
// and set some proper defaults
|
384
384
|
// Also, to clone the incoming object type arguments
|
385
|
-
if(!isDefined(payload.category)){delete payload.category;}if(!isDefined(payload.name)){delete payload.name;}payload.properties=payload.properties?clone
|
385
|
+
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
|
386
386
|
payload.properties=mergeDeepRight(isObjectLiteralAndNotNull(payload.properties)?payload.properties:{},{name:isString(payload.name)?payload.name:null,category:isString(payload.category)?payload.category:null});return payload;};/*
|
387
387
|
* Normalise the overloaded arguments of the track call facade
|
388
388
|
*/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
|
389
389
|
// and set some proper defaults
|
390
390
|
// Also, to clone the incoming object type arguments
|
391
|
-
payload.properties=isDefinedAndNotNull(payload.properties)?clone
|
391
|
+
payload.properties=isDefinedAndNotNull(payload.properties)?clone(payload.properties):{};if(isDefined(payload.options)){payload.options=clone(payload.options);}else {delete payload.options;}return payload;};/*
|
392
392
|
* Normalise the overloaded arguments of the identify call facade
|
393
393
|
*/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
|
394
394
|
// in the Analytics class
|
395
395
|
payload.userId=null;payload.traits=userId;payload.options=traits;}// Rest of the code is just to clean up undefined values
|
396
396
|
// and set some proper defaults
|
397
397
|
// Also, to clone the incoming object type arguments
|
398
|
-
if(isDefined(payload.userId)){payload.userId=tryStringify(payload.userId);}else {delete payload.userId;}if(isObjectLiteralAndNotNull(payload.traits)){payload.traits=clone
|
398
|
+
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;};/*
|
399
399
|
* Normalise the overloaded arguments of the alias call facade
|
400
400
|
*/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
|
401
401
|
// and set some proper defaults
|
402
402
|
// Also, to clone the incoming object type arguments
|
403
|
-
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
|
403
|
+
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;};/*
|
404
404
|
* Normalise the overloaded arguments of the group call facade
|
405
405
|
*/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?
|
406
406
|
if(isFunction(groupId)){// Explicitly set null to prevent resetting the existing value
|
@@ -409,11 +409,11 @@ payload.groupId=null;delete payload.traits;delete payload.options;payload.callba
|
|
409
409
|
payload.groupId=null;payload.traits=groupId;payload.options=!isFunction(traits)?traits:null;}// Rest of the code is just to clean up undefined values
|
410
410
|
// and set some proper defaults
|
411
411
|
// Also, to clone the incoming object type arguments
|
412
|
-
if(isDefined(payload.groupId)){payload.groupId=tryStringify(payload.groupId);}else {delete payload.groupId;}payload.traits=isObjectLiteralAndNotNull(payload.traits)?clone
|
412
|
+
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;};
|
413
413
|
|
414
414
|
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';
|
415
415
|
|
416
|
-
const APP_NAME='RudderLabs JavaScript SDK';const APP_VERSION='3.0.0-beta.
|
416
|
+
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';
|
417
417
|
|
418
418
|
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';
|
419
419
|
|
@@ -446,7 +446,7 @@ if(queryObject.get(QUERY_PARAM_ANONYMOUS_ID_KEY)){argumentsArray.unshift(['setAn
|
|
446
446
|
* Retrieve an existing buffered load method call and remove from the existing array
|
447
447
|
*/const getPreloadedLoadEvent=preloadedEventsArray=>{const loadMethodName='load';let loadEvent=[];/**
|
448
448
|
* Iterate the buffered API calls until we find load call and process it separately
|
449
|
-
*/let i=0;while(i<preloadedEventsArray.length){if(preloadedEventsArray[i]&&preloadedEventsArray[i][0]===loadMethodName){loadEvent=clone
|
449
|
+
*/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;};/**
|
450
450
|
* Promote consent events to the top of the preloaded events array
|
451
451
|
* @param preloadedEventsArray Preloaded events array
|
452
452
|
* @returns None
|
@@ -529,6 +529,10 @@ timeoutID=globalThis.setTimeout(()=>{reject(new Error(SCRIPT_LOAD_TIMEOUT_ERROR(
|
|
529
529
|
|
530
530
|
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);}
|
531
531
|
|
532
|
+
/**
|
533
|
+
* A buffer queue to serve as a store for any type of data
|
534
|
+
*/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=[];}}
|
535
|
+
|
532
536
|
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;';/**
|
533
537
|
* Service to log messages/data to output provider, default is console
|
534
538
|
*/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
|
@@ -561,7 +565,7 @@ const DEFAULT_CONFIG_BE_URL='https://api.rudderstack.com';
|
|
561
565
|
|
562
566
|
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'};
|
563
567
|
|
564
|
-
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
|
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(defaultLoadOptions));
|
565
569
|
|
566
570
|
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};
|
567
571
|
|
@@ -569,7 +573,7 @@ const defaultSessionInfo={autoTrack:true,timeout:DEFAULT_SESSION_TIMEOUT_MS};con
|
|
569
573
|
|
570
574
|
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)};
|
571
575
|
|
572
|
-
const reportingState={isErrorReportingEnabled:a(false),isMetricsReportingEnabled:a(false),errorReportingProviderPluginName:a(undefined)};
|
576
|
+
const reportingState={isErrorReportingEnabled:a(false),isMetricsReportingEnabled:a(false),errorReportingProviderPluginName:a(undefined),isErrorReportingPluginLoaded:a(false)};
|
573
577
|
|
574
578
|
const sourceConfigState=a(undefined);
|
575
579
|
|
@@ -589,7 +593,7 @@ const pluginsState={ready:a(false),loadedPlugins:a([]),failedPlugins:a([]),plugi
|
|
589
593
|
|
590
594
|
const storageState={encryptionPluginName:a(undefined),migrate:a(false),type:a(undefined),cookie:a(undefined),entries:a({}),trulyAnonymousTracking:a(false)};
|
591
595
|
|
592
|
-
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
|
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(defaultStateValues)};
|
593
597
|
|
594
598
|
// to next or return the value if it is the last one instead of an array per
|
595
599
|
// plugin that is the normal invoke
|
@@ -603,9 +607,14 @@ if(throws){throw err;}else {this.logger?.error(PLUGIN_INVOCATION_ERROR(PLUGIN_EN
|
|
603
607
|
|
604
608
|
const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO_BE_FILTERED=[FAILED_REQUEST_ERR_MSG_PREFIX];
|
605
609
|
|
610
|
+
const LOAD_ORIGIN='RS_JS_SDK';
|
611
|
+
|
606
612
|
/**
|
607
613
|
* Utility method to normalise errors
|
608
|
-
*/const processError=error=>{let errorMessage;try{if(isString(error)){errorMessage=error;}else if(error instanceof Error){errorMessage=error.message;}else {errorMessage=error.message
|
614
|
+
*/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)
|
615
|
+
else if(error instanceof Event){const eventTarget=error.target;// Discard all the non-script loading errors
|
616
|
+
if(eventTarget&&eventTarget.localName!=='script'){return '';}// Discard script errors that are not originated at SDK or from native SDKs
|
617
|
+
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;};/**
|
609
618
|
* A function to determine whether the error should be promoted to notify or not
|
610
619
|
* @param {Error} error
|
611
620
|
* @returns
|
@@ -614,10 +623,12 @@ const FAILED_REQUEST_ERR_MSG_PREFIX='The request failed';const ERROR_MESSAGES_TO
|
|
614
623
|
/**
|
615
624
|
* A service to handle errors
|
616
625
|
*/class ErrorHandler{// If no logger is passed errors will be thrown as unhandled error
|
617
|
-
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
|
626
|
+
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
|
618
627
|
let errorMessage=processError(error);// If no error message after we normalize, then we swallow/ignore the errors
|
619
|
-
if(!errorMessage){return;}
|
620
|
-
|
628
|
+
if(!errorMessage){return;}// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
629
|
+
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
|
630
|
+
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
|
631
|
+
if(state.reporting.isErrorReportingEnabled.value&&!state.reporting.isErrorReportingPluginLoaded.value);}/**
|
621
632
|
* Add breadcrumbs to add insight of a user's journey before an error
|
622
633
|
* occurred and send to external error monitoring service via a plugin
|
623
634
|
*
|
@@ -684,7 +695,7 @@ const EVENT_PAYLOAD_SIZE_CHECK_FAIL_WARNING=(context,payloadSize,sizeLimit)=>`${
|
|
684
695
|
* Updates certain parameters like sentAt timestamp, integrations config etc.
|
685
696
|
* @param event RudderEvent object
|
686
697
|
* @returns Final event ready to be delivered
|
687
|
-
*/const getFinalEventForDeliveryMutator=(event,currentTime)=>{const finalEvent=clone
|
698
|
+
*/const getFinalEventForDeliveryMutator=(event,currentTime)=>{const finalEvent=clone(event);// Update sentAt timestamp to the latest timestamp
|
688
699
|
finalEvent.sentAt=currentTime;return finalEvent;};
|
689
700
|
|
690
701
|
const ENCRYPTION_PREFIX_V3='RS_ENC_v3_';
|
@@ -849,158 +860,160 @@ if(!cmpConfig?.consents){return true;}const configuredConsents=cmpConfig.consent
|
|
849
860
|
// the configured resolution strategy
|
850
861
|
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;}}}});
|
851
862
|
|
852
|
-
const DIR_NAME$
|
863
|
+
const DIR_NAME$1b='AdobeAnalytics';const DISPLAY_NAME$1b='Adobe Analytics';
|
853
864
|
|
854
|
-
const DIR_NAME$
|
865
|
+
const DIR_NAME$1a='Amplitude';const DISPLAY_NAME$1a='Amplitude';
|
855
866
|
|
856
|
-
const DIR_NAME$
|
867
|
+
const DIR_NAME$19='Appcues';const DISPLAY_NAME$19='Appcues';
|
857
868
|
|
858
|
-
const DIR_NAME$
|
869
|
+
const DIR_NAME$18='BingAds';const DISPLAY_NAME$18='Bing Ads';
|
859
870
|
|
860
|
-
const DIR_NAME$
|
871
|
+
const DIR_NAME$17='Braze';const DISPLAY_NAME$17='Braze';
|
861
872
|
|
862
|
-
const DIR_NAME$
|
873
|
+
const DIR_NAME$16='Bugsnag';const DISPLAY_NAME$16='Bugsnag';
|
863
874
|
|
864
|
-
const DIR_NAME$
|
875
|
+
const DIR_NAME$15='Chartbeat';const DISPLAY_NAME$15='Chartbeat';
|
865
876
|
|
866
|
-
const DIR_NAME$
|
877
|
+
const DIR_NAME$14='Clevertap';const DISPLAY_NAME$14='CleverTap';
|
867
878
|
|
868
|
-
const DIR_NAME$
|
879
|
+
const DIR_NAME$13='Comscore';const DISPLAY_NAME$13='Comscore';
|
869
880
|
|
870
|
-
const DIR_NAME$
|
881
|
+
const DIR_NAME$12='Criteo';const DISPLAY_NAME$12='Criteo';
|
871
882
|
|
872
|
-
const DIR_NAME$
|
883
|
+
const DIR_NAME$11='CustomerIO';const DISPLAY_NAME$11='Customer IO';
|
873
884
|
|
874
|
-
const DIR_NAME
|
885
|
+
const DIR_NAME$10='Drip';const DISPLAY_NAME$10='Drip';
|
875
886
|
|
876
|
-
const DIR_NAME
|
887
|
+
const DIR_NAME$$='FacebookPixel';const DISPLAY_NAME$$='Facebook Pixel';
|
877
888
|
|
878
|
-
const DIR_NAME$
|
889
|
+
const DIR_NAME$_='Fullstory';const DISPLAY_NAME$_='Fullstory';
|
879
890
|
|
880
|
-
const DIR_NAME$
|
891
|
+
const DIR_NAME$Z='GA';const DISPLAY_NAME$Z='Google Analytics';
|
881
892
|
|
882
|
-
const DIR_NAME$
|
893
|
+
const DIR_NAME$Y='GA4';const DISPLAY_NAME$Y='Google Analytics 4 (GA4)';
|
883
894
|
|
884
|
-
const DIR_NAME$
|
895
|
+
const DIR_NAME$X='GoogleAds';const DISPLAY_NAME$X='Google Ads';
|
885
896
|
|
886
|
-
const DIR_NAME$
|
897
|
+
const DIR_NAME$W='GoogleOptimize';const DISPLAY_NAME$W='Google Optimize';
|
887
898
|
|
888
|
-
const DIR_NAME$
|
899
|
+
const DIR_NAME$V='GoogleTagManager';const DISPLAY_NAME$V='Google Tag Manager';
|
889
900
|
|
890
|
-
const DIR_NAME$
|
901
|
+
const DIR_NAME$U='Heap';const DISPLAY_NAME$U='Heap.io';
|
891
902
|
|
892
|
-
const DIR_NAME$
|
903
|
+
const DIR_NAME$T='Hotjar';const DISPLAY_NAME$T='Hotjar';
|
893
904
|
|
894
|
-
const DIR_NAME$
|
905
|
+
const DIR_NAME$S='HubSpot';const DISPLAY_NAME$S='HubSpot';
|
895
906
|
|
896
|
-
const DIR_NAME$
|
907
|
+
const DIR_NAME$R='INTERCOM';const DISPLAY_NAME$R='Intercom';
|
897
908
|
|
898
|
-
const DIR_NAME$
|
909
|
+
const DIR_NAME$Q='Keen';const DISPLAY_NAME$Q='Keen';
|
899
910
|
|
900
|
-
const DIR_NAME$
|
911
|
+
const DIR_NAME$P='Kissmetrics';const DISPLAY_NAME$P='Kiss Metrics';
|
901
912
|
|
902
|
-
const DIR_NAME$
|
913
|
+
const DIR_NAME$O='Klaviyo';const DISPLAY_NAME$O='Klaviyo';
|
903
914
|
|
904
|
-
const DIR_NAME$
|
915
|
+
const DIR_NAME$N='LaunchDarkly';const DISPLAY_NAME$N='LaunchDarkly';
|
905
916
|
|
906
|
-
const DIR_NAME$
|
917
|
+
const DIR_NAME$M='LinkedInInsightTag';const DISPLAY_NAME$M='Linkedin Insight Tag';
|
907
918
|
|
908
|
-
const DIR_NAME$
|
919
|
+
const DIR_NAME$L='Lotame';const DISPLAY_NAME$L='Lotame';
|
909
920
|
|
910
|
-
const DIR_NAME$
|
921
|
+
const DIR_NAME$K='Lytics';const DISPLAY_NAME$K='Lytics';
|
911
922
|
|
912
|
-
const DIR_NAME$
|
923
|
+
const DIR_NAME$J='Mixpanel';const DISPLAY_NAME$J='Mixpanel';
|
913
924
|
|
914
|
-
const DIR_NAME$
|
925
|
+
const DIR_NAME$I='MoEngage';const DISPLAY_NAME$I='MoEngage';
|
915
926
|
|
916
|
-
const DIR_NAME$
|
927
|
+
const DIR_NAME$H='Optimizely';const DISPLAY_NAME$H='Optimizely Web';
|
917
928
|
|
918
|
-
const DIR_NAME$
|
929
|
+
const DIR_NAME$G='Pendo';const DISPLAY_NAME$G='Pendo';
|
919
930
|
|
920
|
-
const DIR_NAME$
|
931
|
+
const DIR_NAME$F='PinterestTag';const DISPLAY_NAME$F='Pinterest Tag';
|
921
932
|
|
922
|
-
const DIR_NAME$
|
933
|
+
const DIR_NAME$E='PostAffiliatePro';const DISPLAY_NAME$E='Post Affiliate Pro';
|
923
934
|
|
924
|
-
const DIR_NAME$
|
935
|
+
const DIR_NAME$D='Posthog';const DISPLAY_NAME$D='PostHog';
|
925
936
|
|
926
|
-
const DIR_NAME$
|
937
|
+
const DIR_NAME$C='ProfitWell';const DISPLAY_NAME$C='ProfitWell';
|
927
938
|
|
928
|
-
const DIR_NAME$
|
939
|
+
const DIR_NAME$B='Qualtrics';const DISPLAY_NAME$B='Qualtrics';
|
929
940
|
|
930
|
-
const DIR_NAME$
|
941
|
+
const DIR_NAME$A='QuantumMetric';const DISPLAY_NAME$A='Quantum Metric';
|
931
942
|
|
932
|
-
const DIR_NAME$
|
943
|
+
const DIR_NAME$z='RedditPixel';const DISPLAY_NAME$z='Reddit Pixel';
|
933
944
|
|
934
|
-
const DIR_NAME$
|
945
|
+
const DIR_NAME$y='Sentry';const DISPLAY_NAME$y='Sentry';
|
935
946
|
|
936
|
-
const DIR_NAME$
|
947
|
+
const DIR_NAME$x='SnapPixel';const DISPLAY_NAME$x='Snap Pixel';
|
937
948
|
|
938
|
-
const DIR_NAME$
|
949
|
+
const DIR_NAME$w='TVSquared';const DISPLAY_NAME$w='TVSquared';
|
939
950
|
|
940
|
-
const DIR_NAME$
|
951
|
+
const DIR_NAME$v='VWO';const DISPLAY_NAME$v='VWO';
|
941
952
|
|
942
|
-
const DIR_NAME$
|
953
|
+
const DIR_NAME$u='GA360';const DISPLAY_NAME$u='Google Analytics 360';
|
943
954
|
|
944
|
-
const DIR_NAME$
|
955
|
+
const DIR_NAME$t='Adroll';const DISPLAY_NAME$t='Adroll';
|
945
956
|
|
946
|
-
const DIR_NAME$
|
957
|
+
const DIR_NAME$s='DCMFloodlight';const DISPLAY_NAME$s='DCM Floodlight';
|
947
958
|
|
948
|
-
const DIR_NAME$
|
959
|
+
const DIR_NAME$r='Matomo';const DISPLAY_NAME$r='Matomo';
|
949
960
|
|
950
|
-
const DIR_NAME$
|
961
|
+
const DIR_NAME$q='Vero';const DISPLAY_NAME$q='Vero';
|
951
962
|
|
952
|
-
const DIR_NAME$
|
963
|
+
const DIR_NAME$p='Mouseflow';const DISPLAY_NAME$p='Mouseflow';
|
953
964
|
|
954
|
-
const DIR_NAME$
|
965
|
+
const DIR_NAME$o='Rockerbox';const DISPLAY_NAME$o='Rockerbox';
|
955
966
|
|
956
|
-
const DIR_NAME$
|
967
|
+
const DIR_NAME$n='ConvertFlow';const DISPLAY_NAME$n='ConvertFlow';
|
957
968
|
|
958
|
-
const DIR_NAME$
|
969
|
+
const DIR_NAME$m='SnapEngage';const DISPLAY_NAME$m='SnapEngage';
|
959
970
|
|
960
|
-
const DIR_NAME$
|
971
|
+
const DIR_NAME$l='LiveChat';const DISPLAY_NAME$l='LiveChat';
|
961
972
|
|
962
|
-
const DIR_NAME$
|
973
|
+
const DIR_NAME$k='Shynet';const DISPLAY_NAME$k='Shynet';
|
963
974
|
|
964
|
-
const DIR_NAME$
|
975
|
+
const DIR_NAME$j='Woopra';const DISPLAY_NAME$j='Woopra';
|
965
976
|
|
966
|
-
const DIR_NAME$
|
977
|
+
const DIR_NAME$i='RollBar';const DISPLAY_NAME$i='RollBar';
|
967
978
|
|
968
|
-
const DIR_NAME$
|
979
|
+
const DIR_NAME$h='QuoraPixel';const DISPLAY_NAME$h='Quora Pixel';
|
969
980
|
|
970
|
-
const DIR_NAME$
|
981
|
+
const DIR_NAME$g='June';const DISPLAY_NAME$g='June';
|
971
982
|
|
972
|
-
const DIR_NAME$
|
983
|
+
const DIR_NAME$f='Engage';const DISPLAY_NAME$f='Engage';
|
973
984
|
|
974
|
-
const DIR_NAME$
|
985
|
+
const DIR_NAME$e='Iterable';const DISPLAY_NAME$e='Iterable';
|
975
986
|
|
976
|
-
const DIR_NAME$
|
987
|
+
const DIR_NAME$d='YandexMetrica';const DISPLAY_NAME$d='Yandex.Metrica';
|
977
988
|
|
978
|
-
const DIR_NAME$
|
989
|
+
const DIR_NAME$c='Refiner';const DISPLAY_NAME$c='Refiner';
|
979
990
|
|
980
|
-
const DIR_NAME$
|
991
|
+
const DIR_NAME$b='Qualaroo';const DISPLAY_NAME$b='Qualaroo';
|
981
992
|
|
982
|
-
const DIR_NAME$
|
993
|
+
const DIR_NAME$a='Podsights';const DISPLAY_NAME$a='Podsights';
|
983
994
|
|
984
|
-
const DIR_NAME$
|
995
|
+
const DIR_NAME$9='Axeptio';const DISPLAY_NAME$9='Axeptio';
|
985
996
|
|
986
|
-
const DIR_NAME$
|
997
|
+
const DIR_NAME$8='Satismeter';const DISPLAY_NAME$8='Satismeter';
|
987
998
|
|
988
|
-
const DIR_NAME$
|
999
|
+
const DIR_NAME$7='MicrosoftClarity';const DISPLAY_NAME$7='Microsoft Clarity';
|
989
1000
|
|
990
|
-
const DIR_NAME$
|
1001
|
+
const DIR_NAME$6='Sendinblue';const DISPLAY_NAME$6='Sendinblue';
|
991
1002
|
|
992
|
-
const DIR_NAME$
|
1003
|
+
const DIR_NAME$5='Olark';const DISPLAY_NAME$5='Olark';
|
993
1004
|
|
994
|
-
const DIR_NAME$
|
1005
|
+
const DIR_NAME$4='Lemnisk';const DISPLAY_NAME$4='Lemnisk';
|
995
1006
|
|
996
|
-
const DIR_NAME$
|
1007
|
+
const DIR_NAME$3='TiktokAds';const DISPLAY_NAME$3='TikTok Ads';
|
997
1008
|
|
998
|
-
const DIR_NAME$
|
1009
|
+
const DIR_NAME$2='ActiveCampaign';const DISPLAY_NAME$2='Active Campaign';
|
999
1010
|
|
1000
|
-
const DIR_NAME='Sprig';const DISPLAY_NAME='Sprig';
|
1011
|
+
const DIR_NAME$1='Sprig';const DISPLAY_NAME$1='Sprig';
|
1012
|
+
|
1013
|
+
const DIR_NAME='SpotifyPixel';const DISPLAY_NAME='Spotify Pixel';
|
1001
1014
|
|
1002
1015
|
// map of the destination display names to the destination directory names
|
1003
|
-
const destDisplayNamesToFileNamesMap={[DISPLAY_NAME$
|
1016
|
+
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};
|
1004
1017
|
|
1005
1018
|
const DEFAULT_INTEGRATIONS_CONFIG={All:true};
|
1006
1019
|
|
@@ -1023,19 +1036,19 @@ const DESTINATION_NOT_SUPPORTED_ERROR=destUserFriendlyId=>`Destination ${destUse
|
|
1023
1036
|
* @param sdkTypeName The name of the destination SDK type
|
1024
1037
|
* @param logger Logger instance
|
1025
1038
|
* @returns true if the destination SDK code is evaluated, false otherwise
|
1026
|
-
*/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
|
1039
|
+
*/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);});/**
|
1027
1040
|
* Extracts the integration config, if any, from the given destination
|
1028
1041
|
* and merges it with the current integrations config
|
1029
1042
|
* @param dest Destination object
|
1030
1043
|
* @param curDestIntgConfig Current destinations integration config
|
1031
1044
|
* @param logger Logger object
|
1032
1045
|
* @returns Combined destinations integrations config
|
1033
|
-
*/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
|
1046
|
+
*/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
|
1034
1047
|
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
|
1035
1048
|
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));}};
|
1036
1049
|
|
1037
1050
|
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
|
1038
|
-
state.nativeDestinations.loadOnlyIntegrations.value=clone
|
1051
|
+
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
|
1039
1052
|
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
|
1040
1053
|
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
|
1041
1054
|
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
|
@@ -1218,7 +1231,7 @@ const pluginName$5='NativeDestinationQueue';const NativeDestinationQueue=()=>({n
|
|
1218
1231
|
* @returns IQueue instance
|
1219
1232
|
*/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
|
1220
1233
|
`${QUEUE_NAME$1}_${writeKey}`,finalQOpts,(rudderEvent,done)=>{const destinationsToSend=filterDestinations(rudderEvent.integrations,state.nativeDestinations.initializedDestinations.value);// list of destinations which are enable for DMT
|
1221
|
-
const destWithTransformationEnabled=[];const clonedRudderEvent=clone
|
1234
|
+
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
|
1222
1235
|
done(null);},storeManager,MEMORY_STORAGE);// TODO: This seems to not work as expected. Need to investigate
|
1223
1236
|
// effect(() => {
|
1224
1237
|
// if (state.nativeDestinations.clientDestinationsReady.value === true) {
|
@@ -2254,7 +2267,7 @@ const DATA_PLANE_API_VERSION='v1';const QUEUE_NAME='rudder';const XHR_QUEUE_PLUG
|
|
2254
2267
|
|
2255
2268
|
const EVENT_DELIVERY_FAILURE_ERROR_PREFIX=(context,url)=>`${context}${LOG_CONTEXT_SEPARATOR}Failed to deliver event(s) to ${url}.`;
|
2256
2269
|
|
2257
|
-
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
|
2270
|
+
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};};
|
2258
2271
|
|
2259
2272
|
const pluginName='XhrQueue';const XhrQueue=()=>({name:pluginName,deps:[],initialize:state=>{state.plugins.loadedPlugins.value=[...state.plugins.loadedPlugins.value,pluginName];},dataplaneEventsQueue:{/**
|
2260
2273
|
* Initialize the queue for delivery
|
@@ -2602,7 +2615,7 @@ const validateWriteKey=writeKey=>{if(!isString(writeKey)||writeKey.trim().length
|
|
2602
2615
|
*/const isPositiveInteger=num=>isNumber(num)&&num>=0&&Number.isInteger(num);
|
2603
2616
|
|
2604
2617
|
const normalizeLoadOptions=(loadOptionsFromState,loadOptions)=>{// TODO: Maybe add warnings for invalid values
|
2605
|
-
const normalizedLoadOpts=clone
|
2618
|
+
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
|
2606
2619
|
// doesn't seem to throw errors for empty URLs
|
2607
2620
|
// TODO: Need to improve this check to find out if the URL is valid or not
|
2608
2621
|
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}`;};
|
@@ -2643,7 +2656,7 @@ const isErrorReportingEnabled=sourceConfig=>sourceConfig?.statsCollection?.error
|
|
2643
2656
|
* Validates and normalizes the consent options provided by the user
|
2644
2657
|
* @param options Consent options provided by the user
|
2645
2658
|
* @returns Validated and normalized consent options
|
2646
|
-
*/const getValidPostConsentOptions=options=>{const validOptions={sendPageEvent:false,trackConsent:false,discardPreConsentEvents:false};if(isObjectLiteralAndNotNull(options)){const clonedOptions=clone
|
2659
|
+
*/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
|
2647
2660
|
validOptions.consentManagement=mergeDeepRight(clonedOptions.consentManagement,{enabled:state.consents.enabled.value});}}return validOptions;};/**
|
2648
2661
|
* Validates if the input is a valid consents data
|
2649
2662
|
* @param value Input consents data
|
@@ -2683,7 +2696,7 @@ enabled:state.loadOptions.value.preConsent?.enabled===true&&initialized===false&
|
|
2683
2696
|
* @param resp Source config response
|
2684
2697
|
* @param logger Logger instance
|
2685
2698
|
*/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
|
2686
|
-
if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}n(()=>{state.consents.metadata.value=clone
|
2699
|
+
if(state.consents.provider.value==='custom'){resolutionStrategy=undefined;}n(()=>{state.consents.metadata.value=clone(cmpMetadata);state.consents.resolutionStrategy.value=resolutionStrategy;});};
|
2687
2700
|
|
2688
2701
|
/**
|
2689
2702
|
* A function that determines integration SDK loading path
|
@@ -2858,18 +2871,18 @@ rudderEvent.context=getMergedContext(rudderEvent.context,options);}};/**
|
|
2858
2871
|
* Returns the final integrations config for the event based on the global config and event's config
|
2859
2872
|
* @param integrationsConfig Event's integrations config
|
2860
2873
|
* @returns Final integrations config
|
2861
|
-
*/const getEventIntegrationsConfig=integrationsConfig=>{let finalIntgConfig;if(shouldUseGlobalIntegrationsConfigInEvents()){finalIntgConfig=clone
|
2874
|
+
*/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;};/**
|
2862
2875
|
* Enrich the base event object with data from state and the API options
|
2863
2876
|
* @param rudderEvent RudderEvent object
|
2864
2877
|
* @param options API options
|
2865
2878
|
* @param pageProps Page properties
|
2866
2879
|
* @param logger logger
|
2867
2880
|
* @returns Enriched RudderEvent object
|
2868
|
-
*/const getEnrichedEvent=(rudderEvent,options,pageProps,logger)=>{const commonEventData={channel:CHANNEL,context:{traits:clone
|
2869
|
-
...(state.consents.enabled.value&&{consentManagement:{deniedConsentIds:clone
|
2881
|
+
*/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
|
2882
|
+
...(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
|
2870
2883
|
commonEventData.anonymousId=generateAnonymousId();}else {// Type casting to string as the user session manager will take care of initializing the value
|
2871
2884
|
commonEventData.anonymousId=state.session.anonymousId.value;}// set truly anonymous tracking flag
|
2872
|
-
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
|
2885
|
+
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
|
2873
2886
|
// matching with v1.1 payload
|
2874
2887
|
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
|
2875
2888
|
processedEvent.integrations=getEventIntegrationsConfig(processedEvent.integrations);return processedEvent;};
|
@@ -3030,10 +3043,6 @@ if(state.session.sessionInfo.value.autoTrack){this.startOrRenewAutoTracking();}}
|
|
3030
3043
|
* @param userId
|
3031
3044
|
*/setAuthToken(token){state.session.authToken.value=this.isPersistenceEnabledForStorageEntry('authToken')&&token?token:DEFAULT_USER_SESSION_VALUES.authToken;}}
|
3032
3045
|
|
3033
|
-
/**
|
3034
|
-
* A buffer queue to serve as a store for any type of data
|
3035
|
-
*/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=[];}}
|
3036
|
-
|
3037
3046
|
const DATA_PLANE_QUEUE_EXT_POINT_PREFIX='dataplaneEventsQueue';const DESTINATIONS_QUEUE_EXT_POINT_PREFIX='destinationsEventsQueue';const DMT_EXT_POINT_PREFIX='transformEvent';
|
3038
3047
|
|
3039
3048
|
/**
|
@@ -3041,12 +3050,12 @@ const DATA_PLANE_QUEUE_EXT_POINT_PREFIX='dataplaneEventsQueue';const DESTINATION
|
|
3041
3050
|
* @param eventIntgConfig User supplied integrations config at event level
|
3042
3051
|
* @param destinationsIntgConfig Cumulative integrations config from all destinations
|
3043
3052
|
* @returns Filtered user supplied integrations config
|
3044
|
-
*/const getOverriddenIntegrationOptions=(eventIntgConfig,destinationsIntgConfig)=>Object.keys(eventIntgConfig).filter(intgName=>eventIntgConfig[intgName]!==true||!destinationsIntgConfig[intgName]).reduce((obj,key)=>{const retVal=clone
|
3053
|
+
*/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;},{});/**
|
3045
3054
|
* Returns the event object with final integrations config
|
3046
3055
|
* @param event RudderEvent object
|
3047
3056
|
* @param state Application state
|
3048
3057
|
* @returns Mutated event with final integrations config
|
3049
|
-
*/const getFinalEvent=(event,state)=>{const finalEvent=clone
|
3058
|
+
*/const getFinalEvent=(event,state)=>{const finalEvent=clone(event);// Merge the destination specific integrations config with the event's integrations config
|
3050
3059
|
// In general, the preference is given to the event's integrations config
|
3051
3060
|
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');
|
3052
3061
|
|
@@ -3070,7 +3079,7 @@ if(state.loadOptions.value.bufferDataPlaneEventsUntilReady===true){timeoutId=glo
|
|
3070
3079
|
* Enqueues the event for processing
|
3071
3080
|
* @param event RudderEvent object
|
3072
3081
|
* @param callback API callback function
|
3073
|
-
*/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
|
3082
|
+
*/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
|
3074
3083
|
try{// Using the event sent to the data plane queue here
|
3075
3084
|
// to ensure the mutated (if any) event is sent to the callback
|
3076
3085
|
callback?.(dpQEvent);}catch(error){this.onError(error,API_CALLBACK_INVOKE_ERROR);}}/**
|
@@ -3088,7 +3097,7 @@ const dispatchSDKEvent=event=>{const customEvent=new CustomEvent(event,{detail:{
|
|
3088
3097
|
* Initialize services and components or use default ones if singletons
|
3089
3098
|
*/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;}/**
|
3090
3099
|
* Start application lifecycle if not already started
|
3091
|
-
*/load(writeKey,dataPlaneUrl,loadOptions={}){if(state.lifecycle.status.value){return;}let clonedDataPlaneUrl=clone
|
3100
|
+
*/load(writeKey,dataPlaneUrl,loadOptions={}){if(state.lifecycle.status.value){return;}let clonedDataPlaneUrl=clone(dataPlaneUrl);let clonedLoadOptions=clone(loadOptions);// dataPlaneUrl is not provided
|
3092
3101
|
if(isObjectAndNotNull(dataPlaneUrl)){clonedLoadOptions=dataPlaneUrl;clonedDataPlaneUrl=undefined;}// Set initial state values
|
3093
3102
|
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
|
3094
3103
|
if(state.loadOptions.value.logLevel){this.logger?.setMinLogLevel(state.loadOptions.value.logLevel);}// Expose state to global objects
|
@@ -3103,7 +3112,7 @@ if(state.consents.preConsent.value.enabled===true){state.lifecycle.status.value=
|
|
3103
3112
|
* Load browser polyfill if required
|
3104
3113
|
*/onMounted(){this.capabilitiesManager.init();}/**
|
3105
3114
|
* Enqueue in SDK preload buffer events, used from preloadBuffer component
|
3106
|
-
*/enqueuePreloadBufferEvents(bufferedEvents){if(Array.isArray(bufferedEvents)){bufferedEvents.forEach(bufferedEvent=>this.preloadBuffer.enqueue(clone
|
3115
|
+
*/enqueuePreloadBufferEvents(bufferedEvents){if(Array.isArray(bufferedEvents)){bufferedEvents.forEach(bufferedEvent=>this.preloadBuffer.enqueue(clone(bufferedEvent)));}}/**
|
3107
3116
|
* Process the buffer preloaded events by passing their arguments to the respective facade methods
|
3108
3117
|
*/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);}/**
|
3109
3118
|
* Load configuration
|
@@ -3182,7 +3191,7 @@ if(state.consents.postConsent.value.trackConsent){const trackOptions=trackArgume
|
|
3182
3191
|
constructor(){if(RudderAnalytics.globalSingleton){// START-NO-SONAR-SCAN
|
3183
3192
|
// eslint-disable-next-line no-constructor-return
|
3184
3193
|
return RudderAnalytics.globalSingleton;// END-NO-SONAR-SCAN
|
3185
|
-
}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
|
3194
|
+
}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
|
3186
3195
|
this.triggerBufferedLoadEvent();}/**
|
3187
3196
|
* Set instance to use if no specific writeKey is provided in methods
|
3188
3197
|
* automatically for the first created instance
|
@@ -3199,7 +3208,7 @@ promotePreloadedConsentEventsToTop(preloadedEventsArray);// Get any load method
|
|
3199
3208
|
// BTW, load method is also removed from the array
|
3200
3209
|
// So, the Analytics object can directly consume the remaining events
|
3201
3210
|
const loadEvent=getPreloadedLoadEvent(preloadedEventsArray);// Set the final preloaded events array in global object
|
3202
|
-
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone
|
3211
|
+
setExposedGlobal(GLOBAL_PRELOAD_BUFFER,clone(preloadedEventsArray));// Process load method if present in the buffered requests
|
3203
3212
|
if(loadEvent.length>0){// Remove the event name from the Buffered Event array and keep only arguments
|
3204
3213
|
loadEvent.shift();// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
3205
3214
|
// @ts-ignore
|