Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kameleoon/javascript-sdk-core

Package Overview
Dependencies
Maintainers
0
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kameleoon/javascript-sdk-core - npm Package Compare versions

Comparing version 4.4.4 to 4.4.5

6

CHANGELOG.md
# Change Log
## 4.4.5 (2024-08-08)
### Patch Changes
- Fixed an issue that caused duplicate entries in feature flag results for both anonymous and authorized/identified visitors during data reconciliation. This problem occurred when custom data of type mapping ID was not consistently sent for all sessions.
## 4.4.4 (2024-07-19)

@@ -4,0 +10,0 @@

2

dist/kameleoonData/dataManager.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataManager=void 0;var _tsRes=require("ts-res"),_targeting=require("../targeting"),_dataProcessor=require("./dataProcessor"),_utilities=require("../utilities"),_clientConfiguration=require("../clientConfiguration"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class DataManager{constructor(a){let{storage:b,cleanupInterval:c}=a;if(_defineProperty(this,"targetingTrees",new Map),_defineProperty(this,"localCustomDataIndexes",new Set),_defineProperty(this,"persistentCustomDataIndexes",new Set),_defineProperty(this,"mappingIdentifierCustomDataIndex",null),_defineProperty(this,"cleanupIntervalId",null),_defineProperty(this,"dataProcessor",void 0),_defineProperty(this,"unsentData",void 0),_defineProperty(this,"sentPageViewTimestamps",new Map),this.dataProcessor=new _dataProcessor.DataProcessor(b),this.unsentData={},c){const a=()=>{this.dataProcessor.cleanupTargetingData(c),this.sentPageViewTimestamps.clear()};try{this.cleanupIntervalId=setInterval(a,c)}catch(a){throw this.cleanupIntervalId&&clearInterval(this.cleanupIntervalId),a}}}addData(a){this.unsentData[a]||(this.unsentData[a]=new Map);for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];for(const b of c)switch(this.dataProcessor.updateData(a,b),b.data.type){case _types.KameleoonData.CustomData:{const c=b,d=c.data;this.mappingIdentifierCustomDataIndex===d.index&&(c._isMappingIdentifier=!0,a!==d.value[0]&&this.dataProcessor.createReference(a,d.value[0])),this.localCustomDataIndexes.has(d.index)||b.isSent||this.unsentData[a].set(d.index,c);break}case _types.KameleoonData.PageView:{const c=b.data,d=this.dataProcessor.getTargetingData(a).or({});if(d){const e=d[_types.KameleoonData.PageView],f=e[c.urlAddress];if(!b.isSent)for(const c of f.timestamps)this.sentPageViewTimestamps.has(c)||(this.unsentData[a].set(c,b),this.sentPageViewTimestamps.set(c,!0));else for(const a of f.timestamps)this.sentPageViewTimestamps.has(a)||this.sentPageViewTimestamps.set(a,!0)}break}case _types.KameleoonData.Conversion:{const c=this.unsentData[a];if(!b.isSent)if(c.has(_types.KameleoonData.Conversion)){const a=c.get(_types.KameleoonData.Conversion);a.push(b),c.set(_types.KameleoonData.Conversion,a)}else c.set(_types.KameleoonData.Conversion,[b]);break}default:{const{data:c}=b;b.isSent||this.unsentData[a].set(c.type,b)}}return(0,_tsRes.Ok)()}getTree(a){if(this.targetingTrees.has(a.id))return this.targetingTrees.get(a.id);const b=new _targeting.Tree(a);return this.targetingTrees.set(a.id,b),b}clearTrees(){this.targetingTrees.clear()}getUnsentData(a){return this.unsentData[a]}clearUnsentData(a){var b;const c=null===(b=this.unsentData[a])||void 0===b?void 0:b.values();if(c&&this.persistentCustomDataIndexes.size){const b=new Map;for(const a of c)!Array.isArray(a)&&this.isPersistentCustomData(a)&&b.set(a.data.index,a);if(b.size)return void(this.unsentData[a]=b)}delete this.unsentData[a]}clearUnsentDataByKey(a,b){const c=this.unsentData[a];if(c){if(b===_types.KameleoonData.CustomData&&this.persistentCustomDataIndexes.size)for(const[a,d]of c.entries())this.isPersistentCustomData(d)||a===b&&c.delete(a);else if(b===_types.KameleoonData.PageView)for(const a of c.keys())"number"==typeof a&&c.delete(a);else c.delete(b);c.size||delete this.unsentData[a]}}isPersistentCustomData(a){return!!this.persistentCustomDataIndexes.size&&!!_utilities.Utilities.isCustomData(a)&&this.persistentCustomDataIndexes.has(a.data.index)}getLinkedVisitor(a){return this.dataProcessor.getLinkedVisitor(a,this.mappingIdentifierCustomDataIndex)}getVisitorIdentifier(a){const b=this.getTargetingData(a);if(!b)return a;const c=b[_types.KameleoonData.CustomData];if(!c||null===this.mappingIdentifierCustomDataIndex)return a;const d=c[this.mappingIdentifierCustomDataIndex];return d?d.value[0]:a}getTargetingData(a){const b=this.dataProcessor.getTargetingData(a).or(null);return b?b:void 0}get trees(){return this.targetingTrees}get unsentDataVisitors(){return Object.keys(this.unsentData)}get identifierCustomDataIndex(){return this.mappingIdentifierCustomDataIndex}get storedDataTypes(){return this.dataProcessor.storedDataTypeList}get storedCustomDataIndexes(){return this.dataProcessor.storedCustomDataIndexList}set customDataIndexes(a){const[b,c]=[[],[]];a.forEach(a=>{a.localOnly&&b.push(a.index),a.scope===_clientConfiguration.CustomDataScope.Visitor&&c.push(a.index),a.isMappingIdentifier&&(this.mappingIdentifierCustomDataIndex=a.index)}),b.length&&(this.localCustomDataIndexes=new Set(b)),c.length&&(this.persistentCustomDataIndexes=new Set(c))}}exports.DataManager=DataManager;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataManager=void 0;var _tsRes=require("ts-res"),_targeting=require("../targeting"),_dataProcessor=require("./dataProcessor"),_utilities=require("../utilities"),_clientConfiguration=require("../clientConfiguration"),_customData=require("./customData"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class DataManager{constructor(a){let{storage:b,cleanupInterval:c}=a;if(_defineProperty(this,"targetingTrees",new Map),_defineProperty(this,"localCustomDataIndexes",new Set),_defineProperty(this,"persistentCustomDataIndexes",new Set),_defineProperty(this,"mappingIdentifierCustomDataIndex",null),_defineProperty(this,"cleanupIntervalId",null),_defineProperty(this,"dataProcessor",void 0),_defineProperty(this,"unsentData",void 0),_defineProperty(this,"sentPageViewTimestamps",new Map),this.dataProcessor=new _dataProcessor.DataProcessor(b),this.unsentData={},c){const a=()=>{this.dataProcessor.cleanupTargetingData(c),this.sentPageViewTimestamps.clear()};try{this.cleanupIntervalId=setInterval(a,c)}catch(a){throw this.cleanupIntervalId&&clearInterval(this.cleanupIntervalId),a}}}addData(a){this.unsentData[a]||(this.unsentData[a]=new Map);for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];for(const b of c)switch(this.dataProcessor.updateData(a,b),b.data.type){case _types.KameleoonData.CustomData:{const c=b,d=c.data;this.mappingIdentifierCustomDataIndex===d.index&&(c._isMappingIdentifier=!0,a!==d.value[0]&&this.dataProcessor.createReference(a,d.value[0])),this.localCustomDataIndexes.has(d.index)||b.isSent||this.unsentData[a].set(d.index,c);break}case _types.KameleoonData.PageView:{const c=b.data,d=this.dataProcessor.getTargetingData(a).or({});if(d){const e=d[_types.KameleoonData.PageView],f=e[c.urlAddress];if(!b.isSent)for(const c of f.timestamps)this.sentPageViewTimestamps.has(c)||(this.unsentData[a].set(c,b),this.sentPageViewTimestamps.set(c,!0));else for(const a of f.timestamps)this.sentPageViewTimestamps.has(a)||this.sentPageViewTimestamps.set(a,!0)}break}case _types.KameleoonData.Conversion:{const c=this.unsentData[a];if(!b.isSent)if(c.has(_types.KameleoonData.Conversion)){const a=c.get(_types.KameleoonData.Conversion);a.push(b),c.set(_types.KameleoonData.Conversion,a)}else c.set(_types.KameleoonData.Conversion,[b]);break}default:{const{data:c}=b;b.isSent||this.unsentData[a].set(c.type,b)}}return(0,_tsRes.Ok)()}getTree(a){if(this.targetingTrees.has(a.id))return this.targetingTrees.get(a.id);const b=new _targeting.Tree(a);return this.targetingTrees.set(a.id,b),b}clearTrees(){this.targetingTrees.clear()}getUnsentData(a){if(null!==this.mappingIdentifierCustomDataIndex){const b=this.getTargetingData(a);if(b){const c=b[_types.KameleoonData.CustomData];if(c){const b=c[this.mappingIdentifierCustomDataIndex];if(b){const{index:c,value:d}=b,e=new _customData.CustomData(c,...d);e._isMappingIdentifier=!0,this.unsentData[a]||(this.unsentData[a]=new Map),this.unsentData[a].set(c,e)}}}}return this.unsentData[a]}clearUnsentData(a){var b;const c=null===(b=this.unsentData[a])||void 0===b?void 0:b.values();if(c&&this.persistentCustomDataIndexes.size){const b=new Map;for(const a of c)!Array.isArray(a)&&this.isPersistentCustomData(a)&&b.set(a.data.index,a);if(b.size)return void(this.unsentData[a]=b)}delete this.unsentData[a]}clearUnsentDataByKey(a,b){const c=this.unsentData[a];if(c){if(b===_types.KameleoonData.CustomData&&this.persistentCustomDataIndexes.size)for(const[a,d]of c.entries())this.isPersistentCustomData(d)||a===b&&c.delete(a);else if(b===_types.KameleoonData.PageView)for(const a of c.keys())"number"==typeof a&&c.delete(a);else c.delete(b);c.size||delete this.unsentData[a]}}isPersistentCustomData(a){return!!this.persistentCustomDataIndexes.size&&!!_utilities.Utilities.isCustomData(a)&&this.persistentCustomDataIndexes.has(a.data.index)}getLinkedVisitor(a){return this.dataProcessor.getLinkedVisitor(a,this.mappingIdentifierCustomDataIndex)}getVisitorIdentifier(a){const b=this.getTargetingData(a);if(!b)return a;const c=b[_types.KameleoonData.CustomData];if(!c||null===this.mappingIdentifierCustomDataIndex)return a;const d=c[this.mappingIdentifierCustomDataIndex];return d?d.value[0]:a}getTargetingData(a){const b=this.dataProcessor.getTargetingData(a).or(null);return b?b:void 0}get trees(){return this.targetingTrees}get unsentDataVisitors(){return Object.keys(this.unsentData)}get identifierCustomDataIndex(){return this.mappingIdentifierCustomDataIndex}get storedDataTypes(){return this.dataProcessor.storedDataTypeList}get storedCustomDataIndexes(){return this.dataProcessor.storedCustomDataIndexList}set customDataIndexes(a){const[b,c]=[[],[]];a.forEach(a=>{a.localOnly&&b.push(a.index),a.scope===_clientConfiguration.CustomDataScope.Visitor&&c.push(a.index),a.isMappingIdentifier&&(this.mappingIdentifierCustomDataIndex=a.index)}),b.length&&(this.localCustomDataIndexes=new Set(b)),c.length&&(this.persistentCustomDataIndexes=new Set(c))}}exports.DataManager=DataManager;
//# sourceMappingURL=dataManager.js.map
{
"name": "@kameleoon/javascript-sdk-core",
"version": "4.4.4",
"version": "4.4.5",
"description": "Kameleoon JS SDK Core",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc