@kameleoon/javascript-sdk-core 3.0.0 → 3.2.0

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.
Files changed (82) hide show
  1. package/dist/clientConfiguration/clientConfiguration.d.ts +4 -1
  2. package/dist/clientConfiguration/clientConfiguration.js +1 -1
  3. package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
  4. package/dist/clientConfiguration/constants.js +1 -1
  5. package/dist/clientConfiguration/constants.js.map +1 -1
  6. package/dist/clientConfiguration/index.d.ts +1 -1
  7. package/dist/clientConfiguration/index.js +1 -1
  8. package/dist/clientConfiguration/index.js.map +1 -1
  9. package/dist/clientConfiguration/types.d.ts +13 -4
  10. package/dist/clientConfiguration/types.js +1 -1
  11. package/dist/clientConfiguration/types.js.map +1 -1
  12. package/dist/constants.js +1 -1
  13. package/dist/constants.js.map +1 -1
  14. package/dist/cookieManager/cookieManager.d.ts +16 -0
  15. package/dist/cookieManager/cookieManager.js +2 -0
  16. package/dist/cookieManager/cookieManager.js.map +1 -0
  17. package/dist/cookieManager/index.d.ts +1 -0
  18. package/dist/cookieManager/index.js +2 -0
  19. package/dist/cookieManager/index.js.map +1 -0
  20. package/dist/hasher/hasher.d.ts +1 -1
  21. package/dist/hasher/hasher.js +1 -1
  22. package/dist/hasher/hasher.js.map +1 -1
  23. package/dist/hasher/types.d.ts +1 -1
  24. package/dist/hasher/types.js.map +1 -1
  25. package/dist/index.d.ts +4 -3
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/kameleoonClient.d.ts +32 -1
  29. package/dist/kameleoonClient.js +1 -1
  30. package/dist/kameleoonClient.js.map +1 -1
  31. package/dist/kameleoonData/customData.d.ts +6 -0
  32. package/dist/kameleoonData/customData.js +1 -1
  33. package/dist/kameleoonData/customData.js.map +1 -1
  34. package/dist/kameleoonData/dataManager.d.ts +4 -1
  35. package/dist/kameleoonData/dataManager.js +1 -1
  36. package/dist/kameleoonData/dataManager.js.map +1 -1
  37. package/dist/kameleoonData/pageView.js +1 -1
  38. package/dist/kameleoonData/pageView.js.map +1 -1
  39. package/dist/kameleoonData/types.d.ts +1 -0
  40. package/dist/kameleoonData/types.js.map +1 -1
  41. package/dist/kameleoonError/constants.d.ts +1 -0
  42. package/dist/kameleoonError/constants.js +1 -1
  43. package/dist/kameleoonError/constants.js.map +1 -1
  44. package/dist/kameleoonError/kameleoonError.d.ts +2 -1
  45. package/dist/kameleoonError/kameleoonError.js +1 -1
  46. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  47. package/dist/kameleoonError/types.d.ts +1 -0
  48. package/dist/kameleoonError/types.js +1 -1
  49. package/dist/kameleoonError/types.js.map +1 -1
  50. package/dist/kameleoonUtils.d.ts +0 -6
  51. package/dist/kameleoonUtils.js +1 -1
  52. package/dist/kameleoonUtils.js.map +1 -1
  53. package/dist/requester/constants.d.ts +3 -2
  54. package/dist/requester/constants.js +1 -1
  55. package/dist/requester/constants.js.map +1 -1
  56. package/dist/requester/index.d.ts +2 -2
  57. package/dist/requester/index.js +1 -1
  58. package/dist/requester/index.js.map +1 -1
  59. package/dist/requester/requester.d.ts +5 -5
  60. package/dist/requester/requester.js +1 -1
  61. package/dist/requester/requester.js.map +1 -1
  62. package/dist/requester/types.d.ts +8 -6
  63. package/dist/requester/types.js +1 -1
  64. package/dist/requester/types.js.map +1 -1
  65. package/dist/storage/constants.d.ts +2 -1
  66. package/dist/storage/constants.js +1 -1
  67. package/dist/storage/constants.js.map +1 -1
  68. package/dist/storage/types.d.ts +10 -1
  69. package/dist/storage/types.js.map +1 -1
  70. package/dist/types.d.ts +46 -14
  71. package/dist/types.js.map +1 -1
  72. package/dist/utilities/types.d.ts +12 -2
  73. package/dist/utilities/types.js.map +1 -1
  74. package/dist/utilities/utilities.d.ts +10 -4
  75. package/dist/utilities/utilities.js +1 -1
  76. package/dist/utilities/utilities.js.map +1 -1
  77. package/dist/variationConfiguration/types.d.ts +2 -0
  78. package/dist/variationConfiguration/types.js.map +1 -1
  79. package/dist/variationConfiguration/variationConfiguration.d.ts +1 -1
  80. package/dist/variationConfiguration/variationConfiguration.js +1 -1
  81. package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
  82. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataManager=void 0;var _targeting=require("../targeting"),_dataProcessor=require("./dataProcessor"),_utilities=require("../utilities"),_clientConfiguration=require("../clientConfiguration"),_types=require("../types"),_types2=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var DataManager=function(){function a(b){var c=this,d=b.storage,e=b.targetingCleanupInterval;if(_classCallCheck(this,a),_defineProperty(this,"targetingTrees",new Map),_defineProperty(this,"localCustomDataIndexes",new Set),_defineProperty(this,"persistentCustomDataIndexes",new Set),_defineProperty(this,"targetingDataIntervalId",null),_defineProperty(this,"dataProcessor",void 0),_defineProperty(this,"unsentData",void 0),_defineProperty(this,"sentPageViewTimestamps",new Map),this.dataProcessor=new _dataProcessor.DataProcessor(d),this.unsentData={},e){var f=0>e?1:e,g=function(){c.dataProcessor.cleanupOutdatedTargetingData(e),c.sentPageViewTimestamps.clear()};try{this.targetingDataIntervalId=setInterval(g,f*_types.Milliseconds.Minute)}catch(a){throw this.targetingDataIntervalId&&clearInterval(this.targetingDataIntervalId),a}}}return _createClass(a,[{key:"addData",value:function 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(var e,f=0,g=c;f<g.length;f++)switch(e=g[f],this.dataProcessor.updateData(a,e),e.data.type){case _types2.KameleoonData.CustomData:{var h=e.data;this.localCustomDataIndexes.has(h.index)||e.isSent||this.unsentData[a].set(h.index,e);break}case _types2.KameleoonData.PageView:{var i=e.data,j=this.dataProcessor.storedTargetingData.or({}),k=j[a][_types2.KameleoonData.PageView];if(k){var l=k[i.urlAddress];if(!e.isSent){var m,n=_createForOfIteratorHelper(l.timestamps);try{for(n.s();!(m=n.n()).done;){var o=m.value;this.sentPageViewTimestamps.has(o)||(this.unsentData[a].set(o,e),this.sentPageViewTimestamps.set(o,!0))}}catch(a){n.e(a)}finally{n.f()}}}break}case _types2.KameleoonData.Conversion:{var p=this.unsentData[a];if(!e.isSent)if(p.has(_types2.KameleoonData.Conversion)){var q=p.get(_types2.KameleoonData.Conversion);q.push(e),p.set(_types2.KameleoonData.Conversion,q)}else p.set(_types2.KameleoonData.Conversion,[e]);break}default:{var r=e.data;e.isSent||this.unsentData[a].set(r.type,e)}}return this.dataProcessor.createVisit(a)}},{key:"getTree",value:function getTree(a){if(!this.targetingTrees.has(a.id)){var b=new _targeting.Tree(a);return this.targetingTrees.set(a.id,new _targeting.Tree(a)),b}return this.targetingTrees.get(a.id)}},{key:"clearTrees",value:function clearTrees(){this.targetingTrees.clear()}},{key:"getUnsentData",value:function getUnsentData(a){return this.unsentData[a]}},{key:"clearUnsentData",value:function clearUnsentData(a){var b,c=null===(b=this.unsentData[a])||void 0===b?void 0:b.values();if(c&&this.persistentCustomDataIndexes.size){var d,e=new Map,f=_createForOfIteratorHelper(c);try{for(f.s();!(d=f.n()).done;){var g=d.value;!Array.isArray(g)&&this.isPersistentCustomData(g)&&e.set(g.data.index,g)}}catch(a){f.e(a)}finally{f.f()}if(e.size)return void(this.unsentData[a]=e)}delete this.unsentData[a]}},{key:"isPersistentCustomData",value:function isPersistentCustomData(a){return!!this.persistentCustomDataIndexes.size&&!!_utilities.Utilities.isCustomData(a)&&this.persistentCustomDataIndexes.has(a.data.index)}},{key:"trees",get:function get(){return this.targetingTrees}},{key:"unsentDataVisitors",get:function get(){return Object.keys(this.unsentData)}},{key:"storedTargetingData",get:function get(){return this.dataProcessor.storedTargetingData.or({})}},{key:"customDataIndexes",set:function set(a){var b=[],c=[];a.forEach(function(a){a.localOnly&&b.push(a.index),a.scope===_clientConfiguration.CustomDataScope.Visitor&&c.push(a.index)}),b.length&&(this.localCustomDataIndexes=new Set(b)),c.length&&(this.persistentCustomDataIndexes=new Set(c))}}]),a}();exports.DataManager=DataManager;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataManager=void 0;var _targeting=require("../targeting"),_dataProcessor=require("./dataProcessor"),_utilities=require("../utilities"),_clientConfiguration=require("../clientConfiguration"),_types=require("../types"),_types2=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var DataManager=function(){function a(b){var c=this,d=b.storage,e=b.targetingCleanupInterval;if(_classCallCheck(this,a),_defineProperty(this,"targetingTrees",new Map),_defineProperty(this,"localCustomDataIndexes",new Set),_defineProperty(this,"persistentCustomDataIndexes",new Set),_defineProperty(this,"mappingIdentifierCustomDataIndexes",new Set),_defineProperty(this,"targetingDataIntervalId",null),_defineProperty(this,"dataProcessor",void 0),_defineProperty(this,"unsentData",void 0),_defineProperty(this,"sentPageViewTimestamps",new Map),this.dataProcessor=new _dataProcessor.DataProcessor(d),this.unsentData={},e){var f=0>e?1:e,g=function(){c.dataProcessor.cleanupOutdatedTargetingData(e),c.sentPageViewTimestamps.clear()};try{this.targetingDataIntervalId=setInterval(g,f*_types.Milliseconds.Minute)}catch(a){throw this.targetingDataIntervalId&&clearInterval(this.targetingDataIntervalId),a}}}return _createClass(a,[{key:"addData",value:function 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(var e,f=0,g=c;f<g.length;f++)switch(e=g[f],this.dataProcessor.updateData(a,e),e.data.type){case _types2.KameleoonData.CustomData:{var h=e,i=h.data;this.mappingIdentifierCustomDataIndexes.has(i.index)&&(i.isIdentifier=!0),this.localCustomDataIndexes.has(i.index)||e.isSent||this.unsentData[a].set(i.index,h);break}case _types2.KameleoonData.PageView:{var j=e.data,k=this.dataProcessor.storedTargetingData.or({}),l=k[a][_types2.KameleoonData.PageView];if(l){var m=l[j.urlAddress];if(!e.isSent){var n,o=_createForOfIteratorHelper(m.timestamps);try{for(o.s();!(n=o.n()).done;){var p=n.value;this.sentPageViewTimestamps.has(p)||(this.unsentData[a].set(p,e),this.sentPageViewTimestamps.set(p,!0))}}catch(a){o.e(a)}finally{o.f()}}else{var q,r=_createForOfIteratorHelper(m.timestamps);try{for(r.s();!(q=r.n()).done;){var s=q.value;this.sentPageViewTimestamps.has(s)||this.sentPageViewTimestamps.set(s,!0)}}catch(a){r.e(a)}finally{r.f()}}}break}case _types2.KameleoonData.Conversion:{var t=this.unsentData[a];if(!e.isSent)if(t.has(_types2.KameleoonData.Conversion)){var u=t.get(_types2.KameleoonData.Conversion);u.push(e),t.set(_types2.KameleoonData.Conversion,u)}else t.set(_types2.KameleoonData.Conversion,[e]);break}default:{var v=e.data;e.isSent||this.unsentData[a].set(v.type,e)}}return this.dataProcessor.createVisit(a)}},{key:"getTree",value:function getTree(a){if(!this.targetingTrees.has(a.id)){var b=new _targeting.Tree(a);return this.targetingTrees.set(a.id,new _targeting.Tree(a)),b}return this.targetingTrees.get(a.id)}},{key:"clearTrees",value:function clearTrees(){this.targetingTrees.clear()}},{key:"getUnsentData",value:function getUnsentData(a){return this.unsentData[a]}},{key:"clearUnsentData",value:function clearUnsentData(a){var b,c=null===(b=this.unsentData[a])||void 0===b?void 0:b.values();if(c&&this.persistentCustomDataIndexes.size){var d,e=new Map,f=_createForOfIteratorHelper(c);try{for(f.s();!(d=f.n()).done;){var g=d.value;!Array.isArray(g)&&this.isPersistentCustomData(g)&&e.set(g.data.index,g)}}catch(a){f.e(a)}finally{f.f()}if(e.size)return void(this.unsentData[a]=e)}delete this.unsentData[a]}},{key:"clearUnsentDataByKey",value:function clearUnsentDataByKey(a,b){var c=this.unsentData[a];if(c){if(b===_types2.KameleoonData.CustomData&&this.persistentCustomDataIndexes.size){var d,e=_createForOfIteratorHelper(c.entries());try{for(e.s();!(d=e.n()).done;){var f=_slicedToArray(d.value,2),g=f[0],h=f[1];this.isPersistentCustomData(h)||g===b&&c.delete(g)}}catch(a){e.e(a)}finally{e.f()}}else if(b===_types2.KameleoonData.PageView){var i,j=_createForOfIteratorHelper(c.keys());try{for(j.s();!(i=j.n()).done;){var k=i.value;"number"==typeof k&&c.delete(k)}}catch(a){j.e(a)}finally{j.f()}}else c.delete(b);c.size||delete this.unsentData[a]}}},{key:"isPersistentCustomData",value:function isPersistentCustomData(a){return!!this.persistentCustomDataIndexes.size&&!!_utilities.Utilities.isCustomData(a)&&this.persistentCustomDataIndexes.has(a.data.index)}},{key:"getVisitorIdentifier",value:function getVisitorIdentifier(a){var b=this.storedTargetingData;if(!b[a])return a;var c=b[a][_types2.KameleoonData.CustomData];if(!c)return a;for(var d=0,e=Object.entries(c);d<e.length;d++){var f=_slicedToArray(e[d],2),g=f[0],h=f[1];if(this.mappingIdentifierCustomDataIndexes.has(parseInt(g))&&h)return h.value[0]}return a}},{key:"trees",get:function get(){return this.targetingTrees}},{key:"unsentDataVisitors",get:function get(){return Object.keys(this.unsentData)}},{key:"storedTargetingData",get:function get(){return this.dataProcessor.storedTargetingData.or({})}},{key:"customDataIndexes",set:function set(a){var b=[],c=[],d=[];a.forEach(function(a){a.localOnly&&b.push(a.index),a.scope===_clientConfiguration.CustomDataScope.Visitor&&c.push(a.index),a.isMappingIdentifier&&d.push(a.index)}),b.length&&(this.localCustomDataIndexes=new Set(b)),c.length&&(this.persistentCustomDataIndexes=new Set(c)),d.length&&(this.mappingIdentifierCustomDataIndexes=new Set(d))}}]),a}();exports.DataManager=DataManager;
2
2
  //# sourceMappingURL=dataManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataManager.js","names":["DataManager","a","b","c","storage","targetingCleanupInterval","_classCallCheck","_defineProperty","Map","Set","dataProcessor","DataProcessor","unsentData","cleanupInterval","cleanupCallback","cleanupOutdatedTargetingData","sentPageViewTimestamps","clear","targetingDataIntervalId","setInterval","Milliseconds","Minute","err","clearInterval","_createClass","key","value","addData","visitorCode","arguments","length","kameleoonData","Array","d","dataItem","f","g","updateData","data","type","KameleoonData","CustomData","localCustomDataIndexes","has","index","isSent","set","PageView","storedData","storedTargetingData","or","storedVisitorData","pageView","urlAddress","m","n","_createForOfIteratorHelper","timestamps","s","done","timestamp","e","Conversion","existingConversions","get","push","createVisit","getTree","segment","targetingTrees","id","targetingTree","Tree","clearTrees","getUnsentData","clearUnsentData","dataItems","values","persistentCustomDataIndexes","size","persistentCustomData","isArray","isPersistentCustomData","Utilities","isCustomData","Object","keys","customData","customDataLocalOnlyIndexes","forEach","localOnly","scope","CustomDataScope","Visitor","exports"],"sources":["../../src/kameleoonData/dataManager.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { SegmentType, TargetingDataType, Tree } from 'src/targeting';\nimport { DataProcessor } from './dataProcessor';\nimport { Utilities } from 'src/utilities';\nimport {\n CustomDataConfigurationType,\n CustomDataScope,\n} from 'src/clientConfiguration';\nimport { Milliseconds } from 'src/types';\nimport { CustomData } from './customData';\nimport {\n CustomDataType,\n DataManagerParametersType,\n ExistingPageViewDataType,\n KameleoonData,\n KameleoonDataType,\n PageViewDataType,\n UnsentTargetingDataType,\n UnsentVisitorTargetingDataType,\n} from './types';\n\ninterface IDataManager {\n addData(visitorCode: string, ...kameleoonData: KameleoonDataType[]): void;\n getUnsentData: (\n visitorCode: string,\n ) => UnsentTargetingDataType[string] | undefined;\n getTree(segment: SegmentType): Tree;\n clearTrees(): void;\n clearUnsentData: (visitorCode: string) => void;\n isPersistentCustomData: (dataItem: KameleoonDataType) => boolean;\n readonly trees: Map<string, Tree>;\n readonly storedTargetingData: TargetingDataType;\n readonly unsentDataVisitors: string[];\n}\n\nexport class DataManager implements IDataManager {\n private targetingTrees: Map<string, Tree> = new Map();\n private localCustomDataIndexes: Set<number> = new Set();\n private persistentCustomDataIndexes: Set<number> = new Set();\n private targetingDataIntervalId: NodeJS.Timer | null = null;\n private dataProcessor: DataProcessor;\n private unsentData: UnsentTargetingDataType;\n private sentPageViewTimestamps: Map<number, boolean> = new Map();\n\n constructor({\n storage,\n targetingCleanupInterval,\n }: DataManagerParametersType) {\n this.dataProcessor = new DataProcessor(storage);\n this.unsentData = {};\n\n if (targetingCleanupInterval) {\n const cleanupInterval =\n targetingCleanupInterval < 0 ? 1 : targetingCleanupInterval;\n\n const cleanupCallback = () => {\n this.dataProcessor.cleanupOutdatedTargetingData(\n targetingCleanupInterval,\n );\n this.sentPageViewTimestamps.clear();\n };\n\n // --- Note ---\n // We can not make delayed code execution recoverable, as it might lead\n // to targeting data storage size overflow\n try {\n this.targetingDataIntervalId = setInterval(\n cleanupCallback,\n cleanupInterval * Milliseconds.Minute,\n );\n } catch (err) {\n if (this.targetingDataIntervalId) {\n clearInterval(this.targetingDataIntervalId);\n }\n\n throw err;\n }\n }\n }\n\n public addData(\n visitorCode: string,\n ...kameleoonData: KameleoonDataType[]\n ): Result<void, KameleoonError> {\n // --- Note ---\n // We assume `this.unsentTargetingData[visitorCode]` is always presents further\n if (!this.unsentData[visitorCode]) {\n this.unsentData[visitorCode] = new Map();\n }\n\n for (const dataItem of kameleoonData) {\n this.dataProcessor.updateData(visitorCode, dataItem);\n\n switch (dataItem.data.type) {\n case KameleoonData.CustomData: {\n const data = dataItem.data as CustomDataType;\n\n if (\n !this.localCustomDataIndexes.has(data.index) &&\n !dataItem.isSent\n ) {\n this.unsentData[visitorCode]!.set(data.index, dataItem);\n }\n\n break;\n }\n case KameleoonData.PageView: {\n const data = dataItem.data as PageViewDataType;\n\n // --- Note ---\n // `PageViews` can only be processed during storage update as they\n // can't create and merge referrers/titles/timestamps on their own\n // So we have to extract them from storage to update `unsentData` correctly\n const storedData = this.dataProcessor.storedTargetingData.or({});\n const storedVisitorData =\n storedData[visitorCode][KameleoonData.PageView];\n\n if (storedVisitorData) {\n const pageView = (storedVisitorData as ExistingPageViewDataType)[\n data.urlAddress\n ];\n\n if (!dataItem.isSent) {\n for (const timestamp of pageView.timestamps) {\n // --- Note ---\n // As we don't keep `sent` status for each timestamp, we have to\n // check if it was already sent to avoid duplicates\n if (!this.sentPageViewTimestamps.has(timestamp)) {\n this.unsentData[visitorCode]!.set(timestamp, dataItem);\n this.sentPageViewTimestamps.set(timestamp, true);\n }\n }\n }\n }\n\n break;\n }\n case KameleoonData.Conversion: {\n const unsentData = this.unsentData[visitorCode]!;\n\n if (!dataItem.isSent) {\n if (unsentData.has(KameleoonData.Conversion)) {\n const existingConversions = unsentData.get(\n KameleoonData.Conversion,\n ) as KameleoonDataType[];\n\n existingConversions.push(dataItem);\n\n unsentData.set(KameleoonData.Conversion, existingConversions);\n } else {\n unsentData.set(KameleoonData.Conversion, [dataItem]);\n }\n }\n\n break;\n }\n default: {\n const { data } = dataItem;\n\n if (!dataItem.isSent) {\n this.unsentData[visitorCode]!.set(data.type, dataItem);\n }\n }\n }\n }\n\n return this.dataProcessor.createVisit(visitorCode);\n }\n\n public getTree(segment: SegmentType): Tree {\n if (!this.targetingTrees.has(segment.id)) {\n const targetingTree = new Tree(segment);\n\n this.targetingTrees.set(segment.id, new Tree(segment));\n\n return targetingTree;\n }\n\n return this.targetingTrees.get(segment.id) as Tree;\n }\n\n public clearTrees(): void {\n this.targetingTrees.clear();\n }\n\n public getUnsentData(\n visitorCode: string,\n ): UnsentTargetingDataType[string] | undefined {\n return this.unsentData[visitorCode];\n }\n\n public clearUnsentData(visitorCode: string): void {\n const dataItems = this.unsentData[visitorCode]?.values();\n\n if (dataItems && this.persistentCustomDataIndexes.size) {\n const persistentCustomData: UnsentVisitorTargetingDataType = new Map();\n\n for (const dataItem of dataItems) {\n if (!Array.isArray(dataItem) && this.isPersistentCustomData(dataItem)) {\n persistentCustomData.set(dataItem.data.index, dataItem);\n }\n }\n\n if (persistentCustomData.size) {\n this.unsentData[visitorCode] = persistentCustomData;\n return;\n }\n }\n\n delete this.unsentData[visitorCode];\n }\n\n public isPersistentCustomData(\n dataItem: KameleoonDataType,\n ): dataItem is CustomData {\n if (!this.persistentCustomDataIndexes.size) {\n return false;\n }\n\n if (Utilities.isCustomData(dataItem)) {\n return this.persistentCustomDataIndexes.has(dataItem.data.index);\n }\n\n return false;\n }\n\n get trees() {\n return this.targetingTrees;\n }\n\n get unsentDataVisitors(): string[] {\n return Object.keys(this.unsentData);\n }\n\n get storedTargetingData(): TargetingDataType {\n return this.dataProcessor.storedTargetingData.or({});\n }\n\n set customDataIndexes(customData: CustomDataConfigurationType[]) {\n const customDataLocalOnlyIndexes: number[] = [];\n const persistentCustomDataIndexes: number[] = [];\n\n customData.forEach((customData) => {\n if (customData.localOnly) {\n customDataLocalOnlyIndexes.push(customData.index);\n }\n\n if (customData.scope === CustomDataScope.Visitor) {\n persistentCustomDataIndexes.push(customData.index);\n }\n });\n\n if (customDataLocalOnlyIndexes.length) {\n this.localCustomDataIndexes = new Set(customDataLocalOnlyIndexes);\n }\n\n if (persistentCustomDataIndexes.length) {\n this.persistentCustomDataIndexes = new Set(persistentCustomDataIndexes);\n }\n }\n}\n"],"mappings":"2rFAoCa,CAAAA,WAAW,YAStB,SAAAC,EAAAC,CAAA,CAG8B,KAAAC,CAAA,MAF5BC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CACPC,CAAwB,CAAAH,CAAA,CAAxBG,wBAAwB,CAKxB,GAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,uBAf0C,GAAI,CAAAC,GAAK,EAAAD,eAAA,+BACP,GAAI,CAAAE,GAAK,EAAAF,eAAA,oCACJ,GAAI,CAAAE,GAAK,EAAAF,eAAA,gCACL,IAAI,EAAAA,eAAA,8BAAAA,eAAA,2BAAAA,eAAA,+BAGJ,GAAI,CAAAC,GAAK,EAM9D,IAAI,CAACE,aAAa,CAAG,GAAI,CAAAC,4BAAa,CAACP,CAAO,CAAC,CAC/C,IAAI,CAACQ,UAAU,CAAG,CAAC,CAAC,CAEhBP,CAAwB,CAAE,IACtB,CAAAQ,CAAe,CACQ,CAAC,CAA5BR,CAA4B,CAAG,CAAC,CAAGA,CAAwB,CAEvDS,CAAe,CAAG,QAAAA,CAAA,CAAM,CAC5BX,CAAI,CAACO,aAAa,CAACK,4BAA4B,CAC7CV,CAAwB,CACzB,CACDF,CAAI,CAACa,sBAAsB,CAACC,KAAK,EACnC,CAAC,CAKD,GAAI,CACF,IAAI,CAACC,uBAAuB,CAAGC,WAAW,CACxCL,CAAe,CACfD,CAAe,CAAGO,mBAAY,CAACC,MAAM,CAEzC,CAAE,MAAOC,CAAG,CAAE,CAKZ,KAJI,KAAI,CAACJ,uBAAuB,EAC9BK,aAAa,CAAC,IAAI,C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GAAA,CAED,SAAAA,IAAA,CAA6C,CAC3C,MAAO,KAAI,CAACtD,aAAa,CAACuC,mBAAmB,CAACC,EAAE,CAAC,CAAC,CAAC,CACrD,CAAC,GAAAzB,GAAA,qBAAAqB,GAAA,CAED,SAAAA,IAAsByC,CAAyC,CAAE,IACzD,CAAAC,CAAoC,CAAG,EAAE,CACzCV,CAAqC,CAAG,EAAE,CAEhDS,CAAU,CAACE,OAAO,CAAC,SAACF,CAAU,CAAK,CAC7BA,CAAU,CAACG,SAAS,EACtBF,CAA0B,CAACvB,IAAI,CAACsB,CAAU,CAAC3C,KAAK,CAAC,CAG/C2C,CAAU,CAACI,KAAK,GAAKC,oCAAe,CAACC,OAAO,EAC9Cf,CAA2B,CAACb,IAAI,CAACsB,CAAU,CAAC3C,KAAK,CAErD,CAAC,CAAC,CAEE4C,CAA0B,CAAC1D,MAAM,GACnC,IAAI,CAACY,sBAAsB,CAAG,GAAI,CAAAjC,GAAG,CAAC+E,CAA0B,CAAC,EAG/DV,CAA2B,CAAChD,MAAM,GACpC,IAAI,CAACgD,2BAA2B,CAAG,GAAI,CAAArE,GAAG,CAACqE,CAA2B,CAAC,CAE3E,CAAC,IAAA7E,CAAA,IAAA6F,OAAA,CAAA9F,WAAA,CAAAA,WAAA"}
1
+ {"version":3,"file":"dataManager.js","names":["DataManager","a","b","c","storage","targetingCleanupInterval","_classCallCheck","_defineProperty","Map","Set","dataProcessor","DataProcessor","unsentData","cleanupInterval","cleanupCallback","cleanupOutdatedTargetingData","sentPageViewTimestamps","clear","targetingDataIntervalId","setInterval","Milliseconds","Minute","err","clearInterval","_createClass","key","value","addData","visitorCode","arguments","length","kameleoonData","Array","d","dataItem","f","g","updateData","data","type","KameleoonData","CustomData","customData","mappingIdentifierCustomDataIndexes","has","index","isIdentifier","localCustomDataIndexes","isSent","set","PageView","storedData","storedTargetingData","or","storedVisitorData","pageView","urlAddress","n","o","_createForOfIteratorHelper","timestamps","s","done","timestamp","e","q","r","Conversion","existingConversions","get","push","createVisit","getTree","segment","targetingTrees","id","targetingTree","Tree","clearTrees","getUnsentData","clearUnsentData","dataItems","values","persistentCustomDataIndexes","size","persistentCustomData","isArray","isPersistentCustomData","clearUnsentDataByKey","visitorData","entries","_slicedToArray","dataKey","delete","i","j","keys","Utilities","isCustomData","getVisitorIdentifier","targetingData","Object","parseInt","customDataLocalOnlyIndexes","forEach","localOnly","scope","CustomDataScope","Visitor","isMappingIdentifier","exports"],"sources":["../../src/kameleoonData/dataManager.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { SegmentType, TargetingDataType, Tree } from 'src/targeting';\nimport { DataProcessor } from './dataProcessor';\nimport { Utilities } from 'src/utilities';\nimport {\n CustomDataConfigurationType,\n CustomDataScope,\n} from 'src/clientConfiguration';\nimport { Milliseconds } from 'src/types';\nimport { CustomData } from './customData';\nimport {\n DataManagerParametersType,\n ExistingPageViewDataType,\n KameleoonData,\n KameleoonDataType,\n PageViewDataType,\n UnsentTargetingDataType,\n UnsentVisitorTargetingDataType,\n} from './types';\n\ninterface IDataManager {\n addData(visitorCode: string, ...kameleoonData: KameleoonDataType[]): void;\n getUnsentData: (\n visitorCode: string,\n ) => UnsentTargetingDataType[string] | undefined;\n getTree(segment: SegmentType): Tree;\n clearTrees(): void;\n clearUnsentData: (visitorCode: string) => void;\n isPersistentCustomData: (dataItem: KameleoonDataType) => boolean;\n readonly trees: Map<string, Tree>;\n readonly storedTargetingData: TargetingDataType;\n readonly unsentDataVisitors: string[];\n}\n\nexport class DataManager implements IDataManager {\n private targetingTrees: Map<string, Tree> = new Map();\n private localCustomDataIndexes: Set<number> = new Set();\n private persistentCustomDataIndexes: Set<number> = new Set();\n private mappingIdentifierCustomDataIndexes: Set<number> = new Set();\n private targetingDataIntervalId: NodeJS.Timer | null = null;\n private dataProcessor: DataProcessor;\n private unsentData: UnsentTargetingDataType;\n private sentPageViewTimestamps: Map<number, boolean> = new Map();\n\n constructor({\n storage,\n targetingCleanupInterval,\n }: DataManagerParametersType) {\n this.dataProcessor = new DataProcessor(storage);\n this.unsentData = {};\n\n if (targetingCleanupInterval) {\n const cleanupInterval =\n targetingCleanupInterval < 0 ? 1 : targetingCleanupInterval;\n\n const cleanupCallback = () => {\n this.dataProcessor.cleanupOutdatedTargetingData(\n targetingCleanupInterval,\n );\n this.sentPageViewTimestamps.clear();\n };\n\n // --- Note ---\n // We can not make delayed code execution recoverable, as it might lead\n // to targeting data storage size overflow\n try {\n this.targetingDataIntervalId = setInterval(\n cleanupCallback,\n cleanupInterval * Milliseconds.Minute,\n );\n } catch (err) {\n if (this.targetingDataIntervalId) {\n clearInterval(this.targetingDataIntervalId);\n }\n\n throw err;\n }\n }\n }\n\n public addData(\n visitorCode: string,\n ...kameleoonData: KameleoonDataType[]\n ): Result<void, KameleoonError> {\n // --- Note ---\n // We assume `this.unsentTargetingData[visitorCode]` is always presents further\n if (!this.unsentData[visitorCode]) {\n this.unsentData[visitorCode] = new Map();\n }\n\n for (const dataItem of kameleoonData) {\n this.dataProcessor.updateData(visitorCode, dataItem);\n\n switch (dataItem.data.type) {\n case KameleoonData.CustomData: {\n const customData = dataItem as CustomData;\n const data = customData.data;\n\n // --- Bug ---\n // - There's a known issue here: `mappingIdentifier` won't be updated\n // in the storage because the data is written before `unsentData` update\n // and we get `mappingIdentifier` only by checking CC here\n // - It doesn't affect the functionality, as stored data is\n // only used for condition evaluation and `Visitor` scoped CD is never removed from `unsentData`\n // still it should be fixed with some `.updateData` refactor\n if (this.mappingIdentifierCustomDataIndexes.has(data.index)) {\n data.isIdentifier = true;\n }\n\n if (\n !this.localCustomDataIndexes.has(data.index) &&\n !dataItem.isSent\n ) {\n this.unsentData[visitorCode]!.set(data.index, customData);\n }\n\n break;\n }\n case KameleoonData.PageView: {\n const data = dataItem.data as PageViewDataType;\n\n // --- Note ---\n // `PageViews` can only be processed during storage update as they\n // can't create and merge referrers/titles/timestamps on their own\n // So we have to extract them from storage to update `unsentData` correctly\n const storedData = this.dataProcessor.storedTargetingData.or({});\n const storedVisitorData =\n storedData[visitorCode][KameleoonData.PageView];\n\n if (storedVisitorData) {\n const pageView = (storedVisitorData as ExistingPageViewDataType)[\n data.urlAddress\n ];\n\n // --- Note ---\n // A case for newly created page view\n if (!dataItem.isSent) {\n for (const timestamp of pageView.timestamps) {\n // --- Note ---\n // As we don't keep `sent` status for each timestamp, we have to\n // check if it was already sent to avoid duplicates\n if (!this.sentPageViewTimestamps.has(timestamp)) {\n this.unsentData[visitorCode]!.set(timestamp, dataItem);\n this.sentPageViewTimestamps.set(timestamp, true);\n }\n }\n // --- Note ---\n // A case for `getRemoteVisitorData` pre-loaded pages that shouldn't be sent again\n } else {\n for (const timestamp of pageView.timestamps) {\n if (!this.sentPageViewTimestamps.has(timestamp)) {\n this.sentPageViewTimestamps.set(timestamp, true);\n }\n }\n }\n }\n\n break;\n }\n case KameleoonData.Conversion: {\n const unsentData = this.unsentData[visitorCode]!;\n\n if (!dataItem.isSent) {\n if (unsentData.has(KameleoonData.Conversion)) {\n const existingConversions = unsentData.get(\n KameleoonData.Conversion,\n ) as KameleoonDataType[];\n\n existingConversions.push(dataItem);\n\n unsentData.set(KameleoonData.Conversion, existingConversions);\n } else {\n unsentData.set(KameleoonData.Conversion, [dataItem]);\n }\n }\n\n break;\n }\n default: {\n const { data } = dataItem;\n\n if (!dataItem.isSent) {\n this.unsentData[visitorCode]!.set(data.type, dataItem);\n }\n }\n }\n }\n\n return this.dataProcessor.createVisit(visitorCode);\n }\n\n public getTree(segment: SegmentType): Tree {\n if (!this.targetingTrees.has(segment.id)) {\n const targetingTree = new Tree(segment);\n\n this.targetingTrees.set(segment.id, new Tree(segment));\n\n return targetingTree;\n }\n\n return this.targetingTrees.get(segment.id) as Tree;\n }\n\n public clearTrees(): void {\n this.targetingTrees.clear();\n }\n\n public getUnsentData(\n visitorCode: string,\n ): UnsentTargetingDataType[string] | undefined {\n return this.unsentData[visitorCode];\n }\n\n public clearUnsentData(visitorCode: string): void {\n const dataItems = this.unsentData[visitorCode]?.values();\n\n if (dataItems && this.persistentCustomDataIndexes.size) {\n const persistentCustomData: UnsentVisitorTargetingDataType = new Map();\n\n for (const dataItem of dataItems) {\n if (!Array.isArray(dataItem) && this.isPersistentCustomData(dataItem)) {\n persistentCustomData.set(dataItem.data.index, dataItem);\n }\n }\n\n if (persistentCustomData.size) {\n this.unsentData[visitorCode] = persistentCustomData;\n return;\n }\n }\n\n delete this.unsentData[visitorCode];\n }\n\n public clearUnsentDataByKey(visitorCode: string, key: KameleoonData): void {\n const visitorData = this.unsentData[visitorCode];\n\n if (!visitorData) {\n return;\n }\n\n if (\n key === KameleoonData.CustomData &&\n this.persistentCustomDataIndexes.size\n ) {\n for (const [dataKey, dataItem] of visitorData.entries()) {\n if (this.isPersistentCustomData(dataItem as KameleoonDataType)) {\n continue;\n }\n\n if (dataKey === key) {\n visitorData.delete(dataKey);\n }\n }\n } else if (key === KameleoonData.PageView) {\n for (const dataKey of visitorData.keys()) {\n if (typeof dataKey === 'number') {\n visitorData.delete(dataKey);\n }\n }\n } else {\n visitorData.delete(key);\n }\n\n if (!visitorData.size) {\n delete this.unsentData[visitorCode];\n }\n }\n\n public isPersistentCustomData(\n dataItem: KameleoonDataType,\n ): dataItem is CustomData {\n if (!this.persistentCustomDataIndexes.size) {\n return false;\n }\n\n if (Utilities.isCustomData(dataItem)) {\n return this.persistentCustomDataIndexes.has(dataItem.data.index);\n }\n\n return false;\n }\n\n public getVisitorIdentifier(visitorCode: string): string {\n const targetingData = this.storedTargetingData;\n\n if (!targetingData[visitorCode]) {\n return visitorCode;\n }\n\n const customData = targetingData[visitorCode][KameleoonData.CustomData];\n\n if (!customData) {\n return visitorCode;\n }\n\n for (const [index, dataItem] of Object.entries(customData)) {\n if (\n this.mappingIdentifierCustomDataIndexes.has(parseInt(index)) &&\n dataItem\n ) {\n return dataItem.value[0];\n }\n }\n\n return visitorCode;\n }\n\n get trees() {\n return this.targetingTrees;\n }\n\n get unsentDataVisitors(): string[] {\n return Object.keys(this.unsentData);\n }\n\n get storedTargetingData(): TargetingDataType {\n return this.dataProcessor.storedTargetingData.or({});\n }\n\n set customDataIndexes(customData: CustomDataConfigurationType[]) {\n const [\n customDataLocalOnlyIndexes,\n persistentCustomDataIndexes,\n mappingIdentifierCustomDataIndexes,\n ]: Array<number[]> = [[], [], []];\n\n customData.forEach((customData) => {\n if (customData.localOnly) {\n customDataLocalOnlyIndexes.push(customData.index);\n }\n\n if (customData.scope === CustomDataScope.Visitor) {\n persistentCustomDataIndexes.push(customData.index);\n }\n\n if (customData.isMappingIdentifier) {\n mappingIdentifierCustomDataIndexes.push(customData.index);\n }\n });\n\n if (customDataLocalOnlyIndexes.length) {\n this.localCustomDataIndexes = new Set(customDataLocalOnlyIndexes);\n }\n\n if (persistentCustomDataIndexes.length) {\n this.persistentCustomDataIndexes = new Set(persistentCustomDataIndexes);\n }\n\n if (mappingIdentifierCustomDataIndexes.length) {\n this.mappingIdentifierCustomDataIndexes = new Set(\n mappingIdentifierCustomDataIndexes,\n );\n }\n }\n}\n"],"mappings":"09GAmCa,CAAAA,WAAW,YAUtB,SAAAC,EAAAC,CAAA,CAG8B,KAAAC,CAAA,MAF5BC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CACPC,CAAwB,CAAAH,CAAA,CAAxBG,wBAAwB,CAKxB,GAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,uBAhB0C,GAAI,CAAAC,GAAK,EAAAD,eAAA,+BACP,GAAI,CAAAE,GAAK,EAAAF,eAAA,oCACJ,GAAI,CAAAE,GAAK,EAAAF,eAAA,2CACF,GAAI,CAAAE,GAAK,EAAAF,eAAA,gCACZ,IAAI,EAAAA,eAAA,8BAAAA,eAAA,2BAAAA,eAAA,+BAGJ,GAAI,CAAAC,GAAK,EAM9D,IAAI,CAACE,aAAa,CAAG,GAAI,CAAAC,4BAAa,CAACP,CAAO,CAAC,CAC/C,IAAI,CAACQ,UAAU,CAAG,CAAC,CAAC,C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AAU,CAACG,KAAK,CAAC,CAGhDH,CAAU,CAACmE,mBAAmB,EAChClE,CAAkC,CAAC2B,IAAI,CAAC5B,CAAU,CAACG,KAAK,CAE5D,CAAC,CAAC,CAEE0D,CAA0B,CAACzE,MAAM,GACnC,IAAI,CAACiB,sBAAsB,CAAG,GAAI,CAAAtC,GAAG,CAAC8F,CAA0B,CAAC,EAG/DpB,CAA2B,CAACrD,MAAM,GACpC,IAAI,CAACqD,2BAA2B,CAAG,GAAI,CAAA1E,GAAG,CAAC0E,CAA2B,CAAC,EAGrExC,CAAkC,CAACb,MAAM,GAC3C,IAAI,CAACa,kCAAkC,CAAG,GAAI,CAAAlC,GAAG,CAC/CkC,CAAkC,CACnC,CAEL,CAAC,IAAA1C,CAAA,IAAA6G,OAAA,CAAA9G,WAAA,CAAAA,WAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var PageView=function(){function a(b){var c=b.urlAddress,d=b.title,e=b.referrers;_classCallCheck(this,a),_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"referrers",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"timestampList",[]),this.urlAddress=c,this.title=d,this.referrers=e,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){var a;if(!this.urlAddress)return"";var b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c}},{key:"data",get:function get(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types2.KameleoonData.PageView,sent:this.sent,timestamps:this.timestampList}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}},{key:"timestamps",get:function get(){return this.timestampList},set:function set(a){var b=this;this.timestampList.length?a.forEach(function(a){_utilities.Utilities.insertInOrderedListMutably({list:b.timestampList,element:a,order:_types.Order.Ascending})}):this.timestampList=a}}],[{key:"_listFromVisits",value:function _listFromVisits(b){for(var c,d=[],e=new Map,f=b.length-1;0<=f;f--)if(c=b[f],!!c.pageEvents){var g,h=c.pageEvents,j=_createForOfIteratorHelper(h);try{for(j.s();!(g=j.n()).done;){var k=g.value,l=[],m=k.time,n=k.data,o=n.href,p=n.title,q=n.referrersIndices;"number"==typeof q[0]&&(l=q);var r=void 0;if(e.has(o)){var s=e.get(o).timestamps;r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[].concat(_toConsumableArray(s),[m])}else r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[m];e.set(o,r)}}catch(a){j.e(a)}finally{j.f()}}return e.forEach(function(a){a.isSent=!0,d.push(a)}),d}}]),a}();exports.PageView=PageView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var PageView=function(){function a(b){var c=b.urlAddress,d=b.title,e=b.referrers;_classCallCheck(this,a),_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"referrers",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"timestampList",[]),this.urlAddress=c,this.title=d,this.referrers=e,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){var a;if(!this.urlAddress)return"";var b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c}},{key:"data",get:function get(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types2.KameleoonData.PageView,sent:this.sent,timestamps:this.timestampList}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}},{key:"timestamps",get:function get(){return this.timestampList},set:function set(a){var b=this,c=new Set(a);this.timestampList.length?c.forEach(function(a){_utilities.Utilities.insertInOrderedListMutably({list:b.timestampList,element:a,order:_types.Order.Ascending})}):this.timestampList=_toConsumableArray(c)}}],[{key:"_listFromVisits",value:function _listFromVisits(b){for(var c,d=[],e=new Map,f=b.length-1;0<=f;f--)if(c=b[f],!!c.pageEvents){var g,h=c.pageEvents,j=_createForOfIteratorHelper(h);try{for(j.s();!(g=j.n()).done;){var k=g.value,l=[],m=k.time,n=k.data,o=n.href,p=n.title,q=n.referrersIndices;"number"==typeof q[0]&&(l=q);var r=void 0;if(e.has(o)){var s=e.get(o).timestamps;r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[].concat(_toConsumableArray(s),[m])}else r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[m];e.set(o,r)}}catch(a){j.e(a)}finally{j.f()}}return e.forEach(function(a){a.isSent=!0,d.push(a)}),d}}]),a}();exports.PageView=PageView;
2
2
  //# sourceMappingURL=pageView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageView.js","names":["PageView","a","b","urlAddress","title","referrers","_classCallCheck","_defineProperty","sent","_createClass","key","get","titleParameter","UrlParameter","Title","encodeURIComponent","referrersParameter","length","ReferrersIndices","JSON","stringify","UrlEventType","Page","Href","type","KameleoonData","timestamps","timestampList","set","value","forEach","timestamp","Utilities","insertInOrderedListMutably","list","element","order","Order","Ascending","_listFromVisits","visits","visit","resultData","pageViewMap","Map","i","pageEvents","g","j","_createForOfIteratorHelper","s","n","done","pageEvent","time","data","href","referrersIndices","pageView","has","existingTimestamps","concat","_toConsumableArray","e","f","isSent","push","exports"],"sources":["../../src/kameleoonData/pageView.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { Utilities } from 'src/utilities';\nimport { Order } from 'src/utilities/types';\nimport {\n IKameleoonData,\n KameleoonData,\n PageViewDataType,\n PageViewParametersType,\n} from './types';\n\n/**\n * @class\n * PageView - a class for creating an instance of a page view data\n * */\nexport class PageView implements IKameleoonData {\n private urlAddress: string;\n private title: string;\n private referrers?: number[];\n private sent: boolean;\n // --- Note ---\n // Ascending order\n private timestampList: number[] = [];\n\n /**\n * @param {PageViewParametersType} pageViewParameters - an object with page view parameters\n * */\n constructor({ urlAddress, title, referrers }: PageViewParametersType) {\n this.urlAddress = urlAddress;\n this.title = title;\n this.referrers = referrers;\n this.sent = false;\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.urlAddress) {\n return '';\n }\n\n const titleParameter = this.title\n ? UrlParameter.Title + encodeURIComponent(this.title)\n : '';\n\n const referrersParameter = this.referrers?.length\n ? UrlParameter.ReferrersIndices + JSON.stringify(this.referrers)\n : '';\n\n return (\n UrlEventType.Page +\n UrlParameter.Href +\n encodeURIComponent(this.urlAddress) +\n titleParameter +\n referrersParameter\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): PageViewDataType {\n return {\n urlAddress: this.urlAddress,\n title: this.title,\n referrers: this.referrers,\n type: KameleoonData.PageView,\n sent: this.sent,\n timestamps: this.timestampList,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @property timestamps - a list of timestamps for the current data type\n * */\n get timestamps(): number[] {\n return this.timestampList;\n }\n\n set timestamps(value: number[]) {\n if (this.timestampList.length) {\n // --- Note ---\n // We want to keep the list in ascending order\n value.forEach((timestamp) => {\n Utilities.insertInOrderedListMutably({\n list: this.timestampList,\n element: timestamp,\n order: Order.Ascending,\n });\n });\n } else {\n this.timestampList = value;\n }\n }\n\n /**\n * @private\n * @method _listFromVisits - an internal method for creating a list of page view data from a list of visits\n * @param {VisitType[]} visits - a list of visits\n * @returns {PageView[]} a list of PageView instances\n * */\n public static _listFromVisits(visits: VisitType[]): PageView[] {\n const resultData: PageView[] = [];\n const pageViewMap = new Map<string, PageView>();\n\n // --- Note ---\n // Going backwards to get the latest visit data\n for (let i = visits.length - 1; i >= 0; i--) {\n const visit = visits[i];\n\n if (!visit.pageEvents) {\n continue;\n }\n\n const pageEvents = visit.pageEvents;\n\n for (const pageEvent of pageEvents) {\n let referrers: number[] = [];\n\n const { time } = pageEvent;\n const { href, title, referrersIndices } = pageEvent.data;\n\n if (typeof referrersIndices[0] === 'number') {\n referrers = referrersIndices as number[];\n }\n\n let pageView: PageView;\n\n if (pageViewMap.has(href)) {\n const existingTimestamps = pageViewMap.get(href)!.timestamps;\n\n pageView = new PageView({\n urlAddress: href,\n title,\n referrers,\n });\n\n pageView.timestamps = [...existingTimestamps, time];\n } else {\n pageView = new PageView({\n urlAddress: href,\n title,\n referrers,\n });\n\n pageView.timestamps = [time];\n }\n\n pageViewMap.set(href, pageView);\n }\n }\n\n pageViewMap.forEach((value) => {\n // --- Note ---\n // We don't want to track collected pages again\n value.isSent = true;\n resultData.push(value);\n });\n\n return resultData;\n }\n}\n"],"mappings":"knGAca,CAAAA,QAAQ,YAYnB,SAAAC,EAAAC,CAAA,CAAsE,IAAxD,CAAAC,CAAU,CAAAD,CAAA,CAAVC,UAAU,CAAEC,CAAK,CAAAF,CAAA,CAALE,KAAK,CAAEC,CAAS,CAAAH,CAAA,CAATG,SAAS,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,2BAAAA,eAAA,sBAAAA,eAAA,0BAAAA,eAAA,qBAAAA,eAAA,sBALR,EAAE,EAMlC,IAAI,CAACJ,UAAU,CAAGA,CAAU,CAC5B,IAAI,CAACC,KAAK,CAAGA,CAAK,CAClB,IAAI,CAACC,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,IAAI,GACX,CAAC,OAAAC,YAAA,CAAAR,CAAA,GAAAS,GAAA,OAAAC,GAAA,CAKD,SAAAA,IAAA,CAAkB,KAAAV,CAAA,CAIhB,GAAI,CAAC,IAAI,CAACE,UAAU,CAClB,MAAO,EAAE,CACV,GAEK,CAAAS,CAAc,CAAG,IAAI,CAACR,KAAK,CAC7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,CAAA1D,CAAQ,CAAC,CACtBG,UAAU,CAAEqD,CAAI,CAChBpD,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CACF,CAAC,CAAC,CAEFqD,CAAQ,CAAChC,UAAU,IAAAmC,MAAA,CAAAC,kBAAA,CAAOF,CAAkB,GAAEN,CAAI,EACpD,CAAC,IACC,CAAAI,CAAQ,CAAG,GAAI,CAAA1D,CAAQ,CAAC,CACtBG,UAAU,CAAEqD,CAAI,CAChBpD,KAAK,CAALA,CAAK,CACLC,SAAS,CAATA,CACF,CAAC,CAAC,CAEFqD,CAAQ,CAAChC,UAAU,CAAG,CAAC4B,CAAI,CAAC,CAG9BX,CAAW,CAACf,GAAG,CAAC4B,CAAI,CAAEE,CAAQ,CAChC,CAAC,OAAAzD,CAAA,EAAA+C,CAAA,CAAAe,CAAA,CAAA9D,CAAA,UAAA+C,CAAA,CAAAgB,CAAA,IAUH,MAPA,CAAArB,CAAW,CAACb,OAAO,CAAC,SAACD,CAAK,CAAK,CAG7BA,CAAK,CAACoC,MAAM,GAAO,CACnBvB,CAAU,CAACwB,IAAI,CAACrC,CAAK,CACvB,CAAC,CAAC,CAEKa,CACT,CAAC,IAAAzC,CAAA,IAAAkE,OAAA,CAAAnE,QAAA,CAAAA,QAAA"}
1
+ {"version":3,"file":"pageView.js","names":["PageView","a","b","urlAddress","title","referrers","_classCallCheck","_defineProperty","sent","_createClass","key","get","titleParameter","UrlParameter","Title","encodeURIComponent","referrersParameter","length","ReferrersIndices","JSON","stringify","UrlEventType","Page","Href","type","KameleoonData","timestamps","timestampList","set","value","uniqueValues","Set","forEach","timestamp","Utilities","insertInOrderedListMutably","list","element","order","Order","Ascending","_toConsumableArray","_listFromVisits","visits","visit","resultData","pageViewMap","Map","i","pageEvents","g","j","_createForOfIteratorHelper","s","n","done","pageEvent","time","data","href","referrersIndices","pageView","has","existingTimestamps","concat","e","f","isSent","push","exports"],"sources":["../../src/kameleoonData/pageView.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { Utilities } from 'src/utilities';\nimport { Order } from 'src/utilities/types';\nimport {\n IKameleoonData,\n KameleoonData,\n PageViewDataType,\n PageViewParametersType,\n} from './types';\n\n/**\n * @class\n * PageView - a class for creating an instance of a page view data\n * */\nexport class PageView implements IKameleoonData {\n private urlAddress: string;\n private title: string;\n private referrers?: number[];\n private sent: boolean;\n // --- Note ---\n // Ascending order\n private timestampList: number[] = [];\n\n /**\n * @param {PageViewParametersType} pageViewParameters - an object with page view parameters\n * */\n constructor({ urlAddress, title, referrers }: PageViewParametersType) {\n this.urlAddress = urlAddress;\n this.title = title;\n this.referrers = referrers;\n this.sent = false;\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.urlAddress) {\n return '';\n }\n\n const titleParameter = this.title\n ? UrlParameter.Title + encodeURIComponent(this.title)\n : '';\n\n const referrersParameter = this.referrers?.length\n ? UrlParameter.ReferrersIndices + JSON.stringify(this.referrers)\n : '';\n\n return (\n UrlEventType.Page +\n UrlParameter.Href +\n encodeURIComponent(this.urlAddress) +\n titleParameter +\n referrersParameter\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): PageViewDataType {\n return {\n urlAddress: this.urlAddress,\n title: this.title,\n referrers: this.referrers,\n type: KameleoonData.PageView,\n sent: this.sent,\n timestamps: this.timestampList,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @property timestamps - a list of timestamps for the current data type\n * */\n get timestamps(): number[] {\n return this.timestampList;\n }\n\n set timestamps(value: number[]) {\n const uniqueValues = new Set<number>(value);\n\n if (this.timestampList.length) {\n // --- Note ---\n // We want to keep the list in ascending order\n uniqueValues.forEach((timestamp) => {\n Utilities.insertInOrderedListMutably({\n list: this.timestampList,\n element: timestamp,\n order: Order.Ascending,\n });\n });\n } else {\n this.timestampList = [...uniqueValues];\n }\n }\n\n /**\n * @private\n * @method _listFromVisits - an internal method for creating a list of page view data from a list of visits\n * @param {VisitType[]} visits - a list of visits\n * @returns {PageView[]} a list of PageView instances\n * */\n public static _listFromVisits(visits: VisitType[]): PageView[] {\n const resultData: PageView[] = [];\n const pageViewMap = new Map<string, PageView>();\n\n // --- Note ---\n // Going backwards to get the latest visit data\n for (let i = visits.length - 1; i >= 0; i--) {\n const visit = visits[i];\n\n if (!visit.pageEvents) {\n continue;\n }\n\n const pageEvents = visit.pageEvents;\n\n for (const pageEvent of pageEvents) {\n let referrers: number[] = [];\n\n const { time } = pageEvent;\n const { href, title, referrersIndices } = pageEvent.data;\n\n if (typeof referrersIndices[0] === 'number') {\n referrers = referrersIndices as number[];\n }\n\n let pageView: PageView;\n\n if (pageViewMap.has(href)) {\n const existingTimestamps = pageViewMap.get(href)!.timestamps;\n\n pageView = new PageView({\n urlAddress: href,\n title,\n referrers,\n });\n\n pageView.timestamps = [...existingTimestamps, time];\n } else {\n pageView = new PageView({\n urlAddress: href,\n title,\n referrers,\n });\n\n pageView.timestamps = [time];\n }\n\n pageViewMap.set(href, pageView);\n }\n }\n\n pageViewMap.forEach((value) => {\n // --- Note ---\n // We don't want to track collected pages again\n value.isSent = true;\n resultData.push(value);\n });\n\n return resultData;\n }\n}\n"],"mappings":"knGAca,CAAAA,QAAQ,YAYnB,SAAAC,EAAAC,CAAA,CAAsE,IAAxD,CAAAC,CAAU,CAAAD,CAAA,CAAVC,UAAU,CAAEC,CAAK,CAAAF,CAAA,CAALE,KAAK,CAAEC,CAAS,CAAAH,CAAA,CAATG,SAAS,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,2BAAAA,eAAA,sBAAAA,eAAA,0BAAAA,eAAA,qBAAAA,eAAA,sBALR,EAAE,EAMlC,IAAI,CAACJ,UAAU,CAAGA,CAAU,CAC5B,IAA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
102
  value: string[];
103
+ isIdentifier: boolean;
103
104
  } & SharedDataPropertiesType;
104
105
  export type DeviceDataType = {
105
106
  device: DeviceType;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["KameleoonData","CustomData","PageView","GeolocationData","Browser","Conversion","Cookie","Device","OperatingSystem","UserAgent","ApplicationVersion","VisitsData","exports","DeviceType","Phone","Tablet","Desktop","OperatingSystemType","WindowsPhone","Windows","Android","Linux","Mac","IOS","BrowserType","Chrome","InternetExplorer","Firefox","Safari","Opera","Other","OperatingSystemIndexMap","_OperatingSystemIndex","_defineProperty","OperatingSystemTypeMap","constructTypeMap","BrowserIndexMap","_BrowserIndexMap","BrowserTypeMap"],"sources":["../../src/kameleoonData/types.ts"],"sourcesContent":["import { TargetingDataType } from 'src/targeting';\nimport { IExternalStorage } from 'src/storage';\nimport {\n Browser,\n Conversion,\n Cookie,\n CustomData,\n Device,\n GeolocationData,\n OperatingSystem,\n PageView,\n UserAgent,\n ApplicationVersion,\n VisitsData,\n} from 'src/kameleoonData';\nimport { constructTypeMap } from './helpers';\n\n// --- Note ---\n// -- `Conversion`s are stored by `KameleoonData.Conversion` key in a form of an `KameleoonDataType[]` array\n// -- `PageView`s are store by `timestamp` (number) key in a form of `KameleoonDataType`\n// -- All the other unsent data types are stored in a form of `KameleoonData` key and `KameleoonDataType` value\nexport type UnsentVisitorTargetingDataType = Map<\n KameleoonData | number,\n KameleoonDataType | KameleoonDataType[]\n>;\n\nexport type UnsentTargetingDataType = {\n [visitorCode: string]: UnsentVisitorTargetingDataType | undefined;\n};\n\nexport type FieldParametersType = {\n visitorCode: string;\n key: KameleoonData;\n value:\n | BrowserDataType\n | CookieDataType\n | DeviceDataType\n | GeolocationDataType\n | OperatingSystemDataType\n | UserAgentDataType\n | VisitsDataType;\n data: TargetingDataType;\n};\n\nexport type ArrayFieldParametersType = {\n visitorCode: string;\n key: KameleoonData;\n value: ConversionDataType;\n data: TargetingDataType;\n};\nexport type NestedFieldParametersType = {\n visitorCode: string;\n key: KameleoonData.CustomData | KameleoonData.PageView;\n nestedKey: string;\n value: CustomDataType | PageViewDataType;\n data: TargetingDataType;\n};\n\nexport type DataManagerParametersType = {\n targetingCleanupInterval?: number;\n storage: IExternalStorage<TargetingDataType>;\n};\n\nexport type KameleoonDataItemType =\n | BrowserDataType\n | ConversionDataType\n | CustomDataType\n | DeviceDataType\n | PageViewDataType\n | UserAgentDataType\n | CookieDataType\n | GeolocationDataType\n | OperatingSystemDataType\n | ApplicationVersionDataType\n | VisitsDataType;\n\n/**\n * @interface an interface of KameleoonData\n * each class instance will have url getter method\n * for handling url of different data types\n * */\nexport interface IKameleoonData {\n readonly url: string;\n readonly data: KameleoonDataItemType;\n isSent: boolean;\n}\n\n/**\n * @type a tuple of each possible type of data for `addData` method\n * of KameleoonClient\n * */\nexport type KameleoonDataType =\n | Browser\n | Conversion\n | CustomData\n | Device\n | PageView\n | UserAgent\n | VisitsData\n | GeolocationData\n | OperatingSystem\n | Cookie\n | ApplicationVersion;\n\nexport type ActivityTimePropertyType = {\n lastActivityTime: number;\n};\n\nexport type ExistingCustomDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.CustomData]\n>;\n\nexport type ExistingPageViewDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.PageView]\n>;\n\nexport type ExistingNestedDataType =\n | ExistingCustomDataType\n | ExistingPageViewDataType;\n\nexport type ExistingArrayDataType = ExistingConversionDataType;\n\nexport type ExistingConversionDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.Conversion]\n>;\n\nexport type ExistingVisitsDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.VisitsData]\n>;\n\nexport type ExistingDataType<T extends KameleoonData> = NonNullable<\n KameleoonVisitorDataType[T]\n>;\n\nexport type KameleoonVisitorDataType<T = ActivityTimePropertyType> = {\n [KameleoonData.CustomData]?: {\n [index: string]: (CustomDataType & T) | undefined;\n };\n [KameleoonData.Conversion]?: (ConversionDataType & T)[];\n [KameleoonData.GeolocationData]?: GeolocationDataType & T;\n [KameleoonData.UserAgent]?: UserAgentDataType & T;\n [KameleoonData.PageView]?: { [url: string]: PageViewDataType & T };\n [KameleoonData.Browser]?: BrowserDataType & T;\n [KameleoonData.Device]?: DeviceDataType & T;\n [KameleoonData.Cookie]?: CookieDataType & T;\n [KameleoonData.OperatingSystem]?: OperatingSystemDataType & T;\n [KameleoonData.ApplicationVersion]?: ApplicationVersionDataType & T;\n [KameleoonData.VisitsData]?: VisitsDataType & T;\n};\n\nexport enum KameleoonData {\n CustomData = 'customData',\n PageView = 'pageView',\n GeolocationData = 'geolocation',\n Browser = 'browser',\n Conversion = 'conversion',\n Cookie = 'cookie',\n Device = 'device',\n OperatingSystem = 'operatingSystem',\n UserAgent = 'userAgent',\n ApplicationVersion = 'applicationVersion',\n VisitsData = 'visitsData',\n}\n\ntype SharedDataPropertiesType = {\n type: KameleoonData;\n sent: boolean;\n};\n\nexport type BrowserDataType = {\n browser: BrowserType;\n version?: number;\n} & SharedDataPropertiesType;\n\nexport type ConversionDataType = {\n goalId: number;\n revenue: number;\n negative: boolean;\n} & SharedDataPropertiesType;\n\nexport type CustomDataType = {\n index: number;\n value: string[];\n} & SharedDataPropertiesType;\n\nexport type DeviceDataType = {\n device: DeviceType;\n} & SharedDataPropertiesType;\n\nexport type VisitsDataType = {\n previousVisits: number[];\n currentVisit: number | null;\n} & SharedDataPropertiesType;\n\nexport type OperatingSystemDataType = {\n operatingSystem: OperatingSystemType;\n} & SharedDataPropertiesType;\n\nexport type CookieDataType = {\n cookie: CookieType[];\n} & SharedDataPropertiesType;\n\nexport type GeolocationDataType = GeolocationInfoType &\n SharedDataPropertiesType;\n\nexport type PageViewDataType = {\n urlAddress: string;\n title: string;\n referrers?: number[];\n timestamps: number[];\n} & SharedDataPropertiesType;\n\nexport type UserAgentDataType = {\n value: string;\n} & SharedDataPropertiesType;\n\nexport type ApplicationVersionDataType = {\n version: string;\n} & SharedDataPropertiesType;\n\n/**\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} negative - an optional parameter identifying whether the conversion should be removed, default value is `false`\n * */\nexport type ConversionParametersType = {\n goalId: number;\n revenue?: number;\n negative?: boolean;\n};\n\n/**\n * @param {string} urlAddress - url address of the page to track\n * @param {string} title - title of the web page\n * @param {number[] | undefined} referrers - an optional parameter containing a list of referrersIndices, has no default value\n * */\nexport type PageViewParametersType = {\n urlAddress: string;\n title: string;\n referrers?: number[];\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for device type\n * */\nexport enum DeviceType {\n Phone = 'PHONE',\n Tablet = 'TABLET',\n Desktop = 'DESKTOP',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for operating system type\n * */\nexport enum OperatingSystemType {\n WindowsPhone = 'WINDOWS_PHONE',\n Windows = 'WINDOWS',\n Android = 'ANDROID',\n Linux = 'LINUX',\n Mac = 'MAC',\n IOS = 'IOS',\n}\n\n/**\n * @param {string} country - a country of a visitor\n * @param {string | undefined} region - an optional parameter containing a region of a visitor, has no default value\n * @param {string | undefined} city - an optional parameter containing a city of a visitor, has no default value\n * @param {string | undefined} postalCode - an optional parameter containing a postal code of a visitor, has no default value\n * @param {[number, number] | undefined} coordinates - an optional parameter containing a pair of coordinates (longitude and latitude) of a visitor, has no default value. Coordinate `number` represents decimal degrees (double that can be negative)\n * */\nexport type GeolocationInfoType = {\n country: string;\n region?: string;\n city?: string;\n postalCode?: string;\n coordinates?: [number, number];\n};\n\n/**\n * @param {string} key - a key of a cookie\n * @param {string} value - a value of a cookie\n * */\nexport type CookieType = {\n key: string;\n value: string;\n};\n\nexport type OptionalCookieType = Omit<CookieType, 'key'> & {\n key?: string;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for browser type\n * */\nexport enum BrowserType {\n Chrome = 'CHROME',\n InternetExplorer = 'IE',\n Firefox = 'FIREFOX',\n Safari = 'SAFARI',\n Opera = 'OPERA',\n Other = 'OTHER',\n}\n\nexport const OperatingSystemIndexMap = {\n [OperatingSystemType.Windows]: 0,\n [OperatingSystemType.Mac]: 1,\n [OperatingSystemType.IOS]: 2,\n [OperatingSystemType.Linux]: 3,\n [OperatingSystemType.Android]: 4,\n [OperatingSystemType.WindowsPhone]: 5,\n} as const;\n\nexport const OperatingSystemTypeMap = constructTypeMap<OperatingSystemType>(\n OperatingSystemIndexMap,\n);\n\nexport const BrowserIndexMap = {\n [BrowserType.Chrome]: 0,\n [BrowserType.InternetExplorer]: 1,\n [BrowserType.Firefox]: 2,\n [BrowserType.Safari]: 3,\n [BrowserType.Opera]: 4,\n [BrowserType.Other]: 5,\n} as const;\n\nexport const BrowserTypeMap = constructTypeMap<BrowserType>(BrowserIndexMap);\n"],"mappings":"koCAsJY,CAAAA,aAAa,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,UAAA,cAAbD,CAAa,CAAAE,QAAA,YAAbF,CAAa,CAAAG,eAAA,eAAbH,CAAa,CAAAI,OAAA,WAAbJ,CAAa,CAAAK,UAAA,cAAbL,CAAa,CAAAM,MAAA,UAAbN,CAAa,CAAAO,MAAA,UAAbP,CAAa,CAAAQ,eAAA,mBAAbR,CAAa,CAAAS,SAAA,aAAbT,CAAa,CAAAU,kBAAA,sBAAbV,CAAa,CAAAW,UAAA,cAAbX,CAAa,MAAAY,OAAA,CAAAZ,aAAA,CAAAA,aAAA,IAgGb,CAAAa,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,KAAA,SAAVD,CAAU,CAAAE,MAAA,UAAVF,CAAU,CAAAG,OAAA,WAAVH,CAAU,MAAAD,OAAA,CAAAC,UAAA,CAAAA,UAAA,IAUV,CAAAI,mBAAmB,UAAnBA,CAAmB,QAAnB,CAAAA,CAAmB,CAAAC,YAAA,iBAAnBD,CAAmB,CAAAE,OAAA,WAAnBF,CAAmB,CAAAG,OAAA,WAAnBH,CAAmB,CAAAI,KAAA,SAAnBJ,CAAmB,CAAAK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AAM,eAAA,CAAAI,gBAAA,CACvBb,WAAW,CAACI,MAAM,CAAG,CAAC,EAAAK,eAAA,CAAAI,gBAAA,CACtBb,WAAW,CAACK,KAAK,CAAG,CAAC,EAAAI,eAAA,CAAAI,gBAAA,CACrBb,WAAW,CAACM,KAAK,CAAG,CAAC,EAAAO,gBAAA,CACd,CAACzB,OAAA,CAAAwB,eAAA,CAAAA,eAAA,CAEJ,GAAM,CAAAE,cAAc,CAAG,GAAAH,yBAAgB,EAAcC,eAAe,CAAC,CAACxB,OAAA,CAAA0B,cAAA,CAAAA,cAAA"}
1
+ {"version":3,"file":"types.js","names":["KameleoonData","CustomData","PageView","GeolocationData","Browser","Conversion","Cookie","Device","OperatingSystem","UserAgent","ApplicationVersion","VisitsData","exports","DeviceType","Phone","Tablet","Desktop","OperatingSystemType","WindowsPhone","Windows","Android","Linux","Mac","IOS","BrowserType","Chrome","InternetExplorer","Firefox","Safari","Opera","Other","OperatingSystemIndexMap","_OperatingSystemIndex","_defineProperty","OperatingSystemTypeMap","constructTypeMap","BrowserIndexMap","_BrowserIndexMap","BrowserTypeMap"],"sources":["../../src/kameleoonData/types.ts"],"sourcesContent":["import { TargetingDataType } from 'src/targeting';\nimport { IExternalStorage } from 'src/storage';\nimport {\n Browser,\n Conversion,\n Cookie,\n CustomData,\n Device,\n GeolocationData,\n OperatingSystem,\n PageView,\n UserAgent,\n ApplicationVersion,\n VisitsData,\n} from 'src/kameleoonData';\nimport { constructTypeMap } from './helpers';\n\n// --- Note ---\n// -- `Conversion`s are stored by `KameleoonData.Conversion` key in a form of an `KameleoonDataType[]` array\n// -- `PageView`s are store by `timestamp` (number) key in a form of `KameleoonDataType`\n// -- All the other unsent data types are stored in a form of `KameleoonData` key and `KameleoonDataType` value\nexport type UnsentVisitorTargetingDataType = Map<\n KameleoonData | number,\n KameleoonDataType | KameleoonDataType[]\n>;\n\nexport type UnsentTargetingDataType = {\n [visitorCode: string]: UnsentVisitorTargetingDataType | undefined;\n};\n\nexport type FieldParametersType = {\n visitorCode: string;\n key: KameleoonData;\n value:\n | BrowserDataType\n | CookieDataType\n | DeviceDataType\n | GeolocationDataType\n | OperatingSystemDataType\n | UserAgentDataType\n | VisitsDataType;\n data: TargetingDataType;\n};\n\nexport type ArrayFieldParametersType = {\n visitorCode: string;\n key: KameleoonData;\n value: ConversionDataType;\n data: TargetingDataType;\n};\nexport type NestedFieldParametersType = {\n visitorCode: string;\n key: KameleoonData.CustomData | KameleoonData.PageView;\n nestedKey: string;\n value: CustomDataType | PageViewDataType;\n data: TargetingDataType;\n};\n\nexport type DataManagerParametersType = {\n targetingCleanupInterval?: number;\n storage: IExternalStorage<TargetingDataType>;\n};\n\nexport type KameleoonDataItemType =\n | BrowserDataType\n | ConversionDataType\n | CustomDataType\n | DeviceDataType\n | PageViewDataType\n | UserAgentDataType\n | CookieDataType\n | GeolocationDataType\n | OperatingSystemDataType\n | ApplicationVersionDataType\n | VisitsDataType;\n\n/**\n * @interface an interface of KameleoonData\n * each class instance will have url getter method\n * for handling url of different data types\n * */\nexport interface IKameleoonData {\n readonly url: string;\n readonly data: KameleoonDataItemType;\n isSent: boolean;\n}\n\n/**\n * @type a tuple of each possible type of data for `addData` method\n * of KameleoonClient\n * */\nexport type KameleoonDataType =\n | Browser\n | Conversion\n | CustomData\n | Device\n | PageView\n | UserAgent\n | VisitsData\n | GeolocationData\n | OperatingSystem\n | Cookie\n | ApplicationVersion;\n\nexport type ActivityTimePropertyType = {\n lastActivityTime: number;\n};\n\nexport type ExistingCustomDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.CustomData]\n>;\n\nexport type ExistingPageViewDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.PageView]\n>;\n\nexport type ExistingNestedDataType =\n | ExistingCustomDataType\n | ExistingPageViewDataType;\n\nexport type ExistingArrayDataType = ExistingConversionDataType;\n\nexport type ExistingConversionDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.Conversion]\n>;\n\nexport type ExistingVisitsDataType = NonNullable<\n KameleoonVisitorDataType[KameleoonData.VisitsData]\n>;\n\nexport type ExistingDataType<T extends KameleoonData> = NonNullable<\n KameleoonVisitorDataType[T]\n>;\n\nexport type KameleoonVisitorDataType<T = ActivityTimePropertyType> = {\n [KameleoonData.CustomData]?: {\n [index: string]: (CustomDataType & T) | undefined;\n };\n [KameleoonData.Conversion]?: (ConversionDataType & T)[];\n [KameleoonData.GeolocationData]?: GeolocationDataType & T;\n [KameleoonData.UserAgent]?: UserAgentDataType & T;\n [KameleoonData.PageView]?: { [url: string]: PageViewDataType & T };\n [KameleoonData.Browser]?: BrowserDataType & T;\n [KameleoonData.Device]?: DeviceDataType & T;\n [KameleoonData.Cookie]?: CookieDataType & T;\n [KameleoonData.OperatingSystem]?: OperatingSystemDataType & T;\n [KameleoonData.ApplicationVersion]?: ApplicationVersionDataType & T;\n [KameleoonData.VisitsData]?: VisitsDataType & T;\n};\n\nexport enum KameleoonData {\n CustomData = 'customData',\n PageView = 'pageView',\n GeolocationData = 'geolocation',\n Browser = 'browser',\n Conversion = 'conversion',\n Cookie = 'cookie',\n Device = 'device',\n OperatingSystem = 'operatingSystem',\n UserAgent = 'userAgent',\n ApplicationVersion = 'applicationVersion',\n VisitsData = 'visitsData',\n}\n\ntype SharedDataPropertiesType = {\n type: KameleoonData;\n sent: boolean;\n};\n\nexport type BrowserDataType = {\n browser: BrowserType;\n version?: number;\n} & SharedDataPropertiesType;\n\nexport type ConversionDataType = {\n goalId: number;\n revenue: number;\n negative: boolean;\n} & SharedDataPropertiesType;\n\nexport type CustomDataType = {\n index: number;\n value: string[];\n isIdentifier: boolean;\n} & SharedDataPropertiesType;\n\nexport type DeviceDataType = {\n device: DeviceType;\n} & SharedDataPropertiesType;\n\nexport type VisitsDataType = {\n previousVisits: number[];\n currentVisit: number | null;\n} & SharedDataPropertiesType;\n\nexport type OperatingSystemDataType = {\n operatingSystem: OperatingSystemType;\n} & SharedDataPropertiesType;\n\nexport type CookieDataType = {\n cookie: CookieType[];\n} & SharedDataPropertiesType;\n\nexport type GeolocationDataType = GeolocationInfoType &\n SharedDataPropertiesType;\n\nexport type PageViewDataType = {\n urlAddress: string;\n title: string;\n referrers?: number[];\n timestamps: number[];\n} & SharedDataPropertiesType;\n\nexport type UserAgentDataType = {\n value: string;\n} & SharedDataPropertiesType;\n\nexport type ApplicationVersionDataType = {\n version: string;\n} & SharedDataPropertiesType;\n\n/**\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} negative - an optional parameter identifying whether the conversion should be removed, default value is `false`\n * */\nexport type ConversionParametersType = {\n goalId: number;\n revenue?: number;\n negative?: boolean;\n};\n\n/**\n * @param {string} urlAddress - url address of the page to track\n * @param {string} title - title of the web page\n * @param {number[] | undefined} referrers - an optional parameter containing a list of referrersIndices, has no default value\n * */\nexport type PageViewParametersType = {\n urlAddress: string;\n title: string;\n referrers?: number[];\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for device type\n * */\nexport enum DeviceType {\n Phone = 'PHONE',\n Tablet = 'TABLET',\n Desktop = 'DESKTOP',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for operating system type\n * */\nexport enum OperatingSystemType {\n WindowsPhone = 'WINDOWS_PHONE',\n Windows = 'WINDOWS',\n Android = 'ANDROID',\n Linux = 'LINUX',\n Mac = 'MAC',\n IOS = 'IOS',\n}\n\n/**\n * @param {string} country - a country of a visitor\n * @param {string | undefined} region - an optional parameter containing a region of a visitor, has no default value\n * @param {string | undefined} city - an optional parameter containing a city of a visitor, has no default value\n * @param {string | undefined} postalCode - an optional parameter containing a postal code of a visitor, has no default value\n * @param {[number, number] | undefined} coordinates - an optional parameter containing a pair of coordinates (longitude and latitude) of a visitor, has no default value. Coordinate `number` represents decimal degrees (double that can be negative)\n * */\nexport type GeolocationInfoType = {\n country: string;\n region?: string;\n city?: string;\n postalCode?: string;\n coordinates?: [number, number];\n};\n\n/**\n * @param {string} key - a key of a cookie\n * @param {string} value - a value of a cookie\n * */\nexport type CookieType = {\n key: string;\n value: string;\n};\n\nexport type OptionalCookieType = Omit<CookieType, 'key'> & {\n key?: string;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for browser type\n * */\nexport enum BrowserType {\n Chrome = 'CHROME',\n InternetExplorer = 'IE',\n Firefox = 'FIREFOX',\n Safari = 'SAFARI',\n Opera = 'OPERA',\n Other = 'OTHER',\n}\n\nexport const OperatingSystemIndexMap = {\n [OperatingSystemType.Windows]: 0,\n [OperatingSystemType.Mac]: 1,\n [OperatingSystemType.IOS]: 2,\n [OperatingSystemType.Linux]: 3,\n [OperatingSystemType.Android]: 4,\n [OperatingSystemType.WindowsPhone]: 5,\n} as const;\n\nexport const OperatingSystemTypeMap = constructTypeMap<OperatingSystemType>(\n OperatingSystemIndexMap,\n);\n\nexport const BrowserIndexMap = {\n [BrowserType.Chrome]: 0,\n [BrowserType.InternetExplorer]: 1,\n [BrowserType.Firefox]: 2,\n [BrowserType.Safari]: 3,\n [BrowserType.Opera]: 4,\n [BrowserType.Other]: 5,\n} as const;\n\nexport const BrowserTypeMap = constructTypeMap<BrowserType>(BrowserIndexMap);\n"],"mappings":"koCAsJY,CAAAA,aAAa,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,UAAA,cAAbD,CAAa,CAAAE,QAAA,YAAbF,CAAa,CAAAG,eAAA,eAAbH,CAAa,CAAAI,OAAA,WAAbJ,CAAa,CAAAK,UAAA,cAAbL,CAAa,CAAAM,MAAA,UAAbN,CAAa,CAAAO,MAAA,UAAbP,CAAa,CAAAQ,eAAA,mBAAbR,CAAa,CAAAS,SAAA,aAAbT,CAAa,CAAAU,kBAAA,sBAAbV,CAAa,CAAAW,UAAA,cAAbX,CAAa,MAAAY,OAAA,CAAAZ,aAAA,CAAAA,aAAA,IAiGb,CAAAa,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,KAAA,SAAVD,CAAU,CA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,CAAAsB,sBAAA,CAAAA,sBAAA,CAEK,GAAM,CAAAE,eAAe,EAAAC,gBAAA,IAAAJ,eAAA,CAAAI,gBAAA,CACzBb,WAAW,CAACC,MAAM,CAAG,CAAC,EAAAQ,eAAA,CAAAI,gBAAA,CACtBb,WAAW,CAACE,gBAAgB,CAAG,CAAC,EAAAO,eAAA,CAAAI,gBAAA,CAChCb,WAAW,CAACG,OAAO,CAAG,CAAC,EAAAM,eAAA,CAAAI,gBAAA,CACvBb,WAAW,CAACI,MAAM,CAAG,CAAC,EAAAK,eAAA,CAAAI,gBAAA,CACtBb,WAAW,CAACK,KAAK,CAAG,CAAC,EAAAI,eAAA,CAAAI,gBAAA,CACrBb,WAAW,CAACM,KAAK,CAAG,CAAC,EAAAO,gBAAA,CACd,CAACzB,OAAA,CAAAwB,eAAA,CAAAA,eAAA,CAEJ,GAAM,CAAAE,cAAc,CAAG,GAAAH,yBAAgB,EAAcC,eAAe,CAAC,CAACxB,OAAA,CAAA0B,cAAA,CAAAA,cAAA"}
@@ -11,6 +11,7 @@ export declare const ERROR_MESSAGES: {
11
11
  StorageInitialization: () => string;
12
12
  EventSourceInitialization: () => string;
13
13
  FeatureFlagConfigurationNotFound: (featureKey: string) => string;
14
+ FeatureFlagEnvironmentDisabled: (featureKey: string, environment: string) => string;
14
15
  FeatureFlagVariableNotFound: (variableKey: string, visitorCode: string) => string;
15
16
  FeatureFlagVariationNotFound: (variationKey: string, visitorCode: string) => string;
16
17
  NotTargeted: (visitorCode: string) => string;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;var _ERROR_MESSAGES,_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var ERROR_MESSAGES=(_ERROR_MESSAGES={},_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.CookieParse,function(a){return"Couldn't parse cookie string: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.JSONParse,function(a){return"Couldn't parse JSON variable: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NumberParse,function(a){return"It's not possible to parse value ".concat(a," to Number")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.SemanticVersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Initialization,function(){return"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Credentials,function(){return"KameleoonClient can not be created without credentials"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageInitialization,function(){return"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.EventSourceInitialization,function(){return"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagConfigurationNotFound,function(a){return"No feature flag with key ".concat(a," was found.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariableNotFound,function(a,b){return"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariationNotFound,function(a,b){return"No feature flag variation with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NotTargeted,function(a){return"Visitor code ".concat(a," is not targeted")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitAmount,function(){return"Visit amount must be a number between 1 and 25"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeMaxLength,function(){return"Visitor code can not be more than 255 characters long"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeEmpty,function(){return"Visitor code can not be empty"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageWrite,function(a){return"Couldn't update storage for kameleoonClient: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageRead,function(a){return"No data found in storage under ".concat(a," key")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageParse,function(a,b){return"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.ClientConfiguration,function(){return"Couldn't retrieve client configuration from Kameleoon Api"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.TargetingCondition,function(a){return"".concat(a," targeting condition is not yet supported.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.AmongValuesCheck,function(a,b){return"Couldn't parse value \"".concat(b,"\": ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.RemoteData,function(){return"Couldn't retrieve data from Kameleoon server"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.MaximumRetriesReached,function(){return"Maximum retries reached, request failed"}),_ERROR_MESSAGES);exports.ERROR_MESSAGES=ERROR_MESSAGES;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;var _ERROR_MESSAGES,_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var ERROR_MESSAGES=(_ERROR_MESSAGES={},_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.CookieParse,function(a){return"Couldn't parse cookie string: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.JSONParse,function(a){return"Couldn't parse JSON variable: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NumberParse,function(a){return"It's not possible to parse value ".concat(a," to Number")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.SemanticVersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Initialization,function(){return"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Credentials,function(){return"KameleoonClient can not be created without credentials"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageInitialization,function(){return"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.EventSourceInitialization,function(){return"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagConfigurationNotFound,function(a){return"No feature flag with key ".concat(a," was found.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagEnvironmentDisabled,function(a,b){return"Environment of feature flag with key ".concat(a," is disabled in ").concat(b," environment.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariableNotFound,function(a,b){return"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariationNotFound,function(a,b){return"No feature flag variation with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NotTargeted,function(a){return"Visitor code ".concat(a," is not targeted")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitAmount,function(){return"Visit amount must be a number between 1 and 25"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeMaxLength,function(){return"Visitor code can not be more than 255 characters long"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeEmpty,function(){return"Visitor code can not be empty"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageWrite,function(a){return"Couldn't update storage for kameleoonClient: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageRead,function(a){return"No data found in storage under ".concat(a," key")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageParse,function(a,b){return"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.ClientConfiguration,function(){return"Couldn't retrieve client configuration from Kameleoon Api"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.TargetingCondition,function(a){return"".concat(a," targeting condition is not yet supported.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.AmongValuesCheck,function(a,b){return"Couldn't parse value \"".concat(b,"\": ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.RemoteData,function(){return"Couldn't retrieve data from Kameleoon server"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.MaximumRetriesReached,function(){return"Maximum retries reached, request failed"}),_ERROR_MESSAGES);exports.ERROR_MESSAGES=ERROR_MESSAGES;
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["ERROR_MESSAGES","_ERROR_MESSAGES","_defineProperty","KameleoonException","CookieParse","reason","concat","JSONParse","err","NumberParse","value","VersionParse","SemanticVersionParse","Initialization","Credentials","StorageInitialization","EventSourceInitialization","FeatureFlagConfigurationNotFound","featureKey","FeatureFlagVariableNotFound","variableKey","visitorCode","FeatureFlagVariationNotFound","variationKey","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageWrite","StorageRead","key","StorageParse","ClientConfiguration","TargetingCondition","targetingType","AmongValuesCheck","RemoteData","MaximumRetriesReached","exports"],"sources":["../../src/kameleoonError/constants.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { KameleoonException } from './types';\n\nexport const ERROR_MESSAGES = {\n [KameleoonException.CookieParse]: (reason: string) =>\n `Couldn't parse cookie string: ${reason}`,\n [KameleoonException.JSONParse]: (err: unknown) =>\n `Couldn't parse JSON variable: ${err}`,\n [KameleoonException.NumberParse]: (value: string) =>\n `It's not possible to parse value ${value} to Number`,\n [KameleoonException.VersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x`,\n [KameleoonException.SemanticVersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x.x`,\n [KameleoonException.Initialization]: () =>\n \"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods\",\n [KameleoonException.Credentials]: () =>\n 'KameleoonClient can not be created without credentials',\n [KameleoonException.StorageInitialization]: () =>\n \"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed\",\n [KameleoonException.EventSourceInitialization]: () =>\n \"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed\",\n [KameleoonException.FeatureFlagConfigurationNotFound]: (featureKey: string) =>\n `No feature flag with key ${featureKey} was found.`,\n [KameleoonException.FeatureFlagVariableNotFound]: (\n variableKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variable with key ${variableKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.FeatureFlagVariationNotFound]: (\n variationKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variation with key ${variationKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.NotTargeted]: (visitorCode: string) =>\n `Visitor code ${visitorCode} is not targeted`,\n [KameleoonException.VisitAmount]: () =>\n 'Visit amount must be a number between 1 and 25',\n [KameleoonException.VisitorCodeMaxLength]: () =>\n 'Visitor code can not be more than 255 characters long',\n [KameleoonException.VisitorCodeEmpty]: () => 'Visitor code can not be empty',\n [KameleoonException.StorageWrite]: (err: unknown) =>\n `Couldn't update storage for kameleoonClient: ${err}`,\n [KameleoonException.StorageRead]: (key: KameleoonStorageKey) =>\n `No data found in storage under ${key} key`,\n [KameleoonException.StorageParse]: (err: unknown, key: KameleoonStorageKey) =>\n `Couldn't parse ${key} storage data, the data may be corrupted. Error: ${err}`,\n [KameleoonException.ClientConfiguration]: () =>\n \"Couldn't retrieve client configuration from Kameleoon Api\",\n [KameleoonException.TargetingCondition]: (targetingType: TargetingType) =>\n `${targetingType} targeting condition is not yet supported.`,\n [KameleoonException.AmongValuesCheck]: (err: unknown, value: string) =>\n `Couldn't parse value \"${value}\": ${err}`,\n [KameleoonException.RemoteData]: () =>\n `Couldn't retrieve data from Kameleoon server`,\n [KameleoonException.MaximumRetriesReached]: () =>\n `Maximum retries reached, request failed`,\n};\n"],"mappings":"o7BAIO,GAAM,CAAAA,cAAc,EAAAC,eAAA,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eAAA,CAC/CE,yBAAkB,CAACkC,qBAAqB,CAAG,2DACD,EAAApC,eAAA,CAC5C,CAACqC,OAAA,CAAAtC,cAAA,CAAAA,cAAA"}
1
+ {"version":3,"file":"constants.js","names":["ERROR_MESSAGES","_ERROR_MESSAGES","_defineProperty","KameleoonException","CookieParse","reason","concat","JSONParse","err","NumberParse","value","VersionParse","SemanticVersionParse","Initialization","Credentials","StorageInitialization","EventSourceInitialization","FeatureFlagConfigurationNotFound","featureKey","FeatureFlagEnvironmentDisabled","environment","FeatureFlagVariableNotFound","variableKey","visitorCode","FeatureFlagVariationNotFound","variationKey","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageWrite","StorageRead","key","StorageParse","ClientConfiguration","TargetingCondition","targetingType","AmongValuesCheck","RemoteData","MaximumRetriesReached","exports"],"sources":["../../src/kameleoonError/constants.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { KameleoonException } from './types';\n\nexport const ERROR_MESSAGES = {\n [KameleoonException.CookieParse]: (reason: string) =>\n `Couldn't parse cookie string: ${reason}`,\n [KameleoonException.JSONParse]: (err: unknown) =>\n `Couldn't parse JSON variable: ${err}`,\n [KameleoonException.NumberParse]: (value: string) =>\n `It's not possible to parse value ${value} to Number`,\n [KameleoonException.VersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x`,\n [KameleoonException.SemanticVersionParse]: (value: string) =>\n `It's not possible to parse a version value ${value} to Number, version should be in format x.x.x`,\n [KameleoonException.Initialization]: () =>\n \"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods\",\n [KameleoonException.Credentials]: () =>\n 'KameleoonClient can not be created without credentials',\n [KameleoonException.StorageInitialization]: () =>\n \"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed\",\n [KameleoonException.EventSourceInitialization]: () =>\n \"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed\",\n [KameleoonException.FeatureFlagConfigurationNotFound]: (featureKey: string) =>\n `No feature flag with key ${featureKey} was found.`,\n [KameleoonException.FeatureFlagEnvironmentDisabled]: (\n featureKey: string,\n environment: string,\n ) =>\n `Environment of feature flag with key ${featureKey} is disabled in ${environment} environment.`,\n [KameleoonException.FeatureFlagVariableNotFound]: (\n variableKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variable with key ${variableKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.FeatureFlagVariationNotFound]: (\n variationKey: string,\n visitorCode: string,\n ) =>\n `No feature flag variation with key ${variationKey} was found for ${visitorCode} visitorCode.`,\n [KameleoonException.NotTargeted]: (visitorCode: string) =>\n `Visitor code ${visitorCode} is not targeted`,\n [KameleoonException.VisitAmount]: () =>\n 'Visit amount must be a number between 1 and 25',\n [KameleoonException.VisitorCodeMaxLength]: () =>\n 'Visitor code can not be more than 255 characters long',\n [KameleoonException.VisitorCodeEmpty]: () => 'Visitor code can not be empty',\n [KameleoonException.StorageWrite]: (err: unknown) =>\n `Couldn't update storage for kameleoonClient: ${err}`,\n [KameleoonException.StorageRead]: (key: KameleoonStorageKey) =>\n `No data found in storage under ${key} key`,\n [KameleoonException.StorageParse]: (err: unknown, key: KameleoonStorageKey) =>\n `Couldn't parse ${key} storage data, the data may be corrupted. Error: ${err}`,\n [KameleoonException.ClientConfiguration]: () =>\n \"Couldn't retrieve client configuration from Kameleoon Api\",\n [KameleoonException.TargetingCondition]: (targetingType: TargetingType) =>\n `${targetingType} targeting condition is not yet supported.`,\n [KameleoonException.AmongValuesCheck]: (err: unknown, value: string) =>\n `Couldn't parse value \"${value}\": ${err}`,\n [KameleoonException.RemoteData]: () =>\n `Couldn't retrieve data from Kameleoon server`,\n [KameleoonException.MaximumRetriesReached]: () =>\n `Maximum retries reached, request failed`,\n};\n"],"mappings":"o7BAIO,GAAM,CAAAA,cAAc,EAAAC,eAAA,IAAAC,eAAA,CAAAD,eAAA,CACxBE,yBAAkB,CAACC,WAAW,C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AA,CAAME,CAAG,EAAE,EAAAN,eAAA,CAAAD,eAAA,CAC1CE,yBAAkB,CAACmC,UAAU,CAAG,gEACe,EAAApC,eAAA,CAAAD,eAAA,CAC/CE,yBAAkB,CAACoC,qBAAqB,CAAG,2DACD,EAAAtC,eAAA,CAC5C,CAACuC,OAAA,CAAAxC,cAAA,CAAAA,cAAA"}
@@ -11,7 +11,8 @@ export declare class KameleoonError extends Error {
11
11
  * @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum
12
12
  * */
13
13
  constructor(type: KameleoonException.Initialization | KameleoonException.Credentials | KameleoonException.ClientConfiguration | KameleoonException.VisitorCodeMaxLength | KameleoonException.VisitorCodeEmpty | KameleoonException.VisitAmount | KameleoonException.StorageInitialization | KameleoonException.EventSourceInitialization | KameleoonException.RemoteData | KameleoonException.MaximumRetriesReached);
14
- constructor(type: KameleoonException.FeatureFlagConfigurationNotFound, featureKey: string);
14
+ constructor(type: KameleoonException.FeatureFlagConfigurationNotFound | KameleoonException.FeatureFlagEnvironmentDisabled, featureKey: string);
15
+ constructor(type: KameleoonException.FeatureFlagConfigurationNotFound | KameleoonException.FeatureFlagEnvironmentDisabled, featureKey: string, environment: string);
15
16
  constructor(type: KameleoonException.FeatureFlagVariableNotFound, variableKey: string, visitorCode: string);
16
17
  constructor(type: KameleoonException.FeatureFlagVariationNotFound, variationKey: string, visitorCode: string);
17
18
  constructor(type: KameleoonException.NotTargeted, visitorCode: string);
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var KameleoonError=function(a){function b(a,d,e){var f;return _classCallCheck(this,b),f=c.call(this,"Error: ".concat(a)),_defineProperty(_assertThisInitialized(f),"errorType",void 0),f.name="KameleoonError",f.errorType=a,(a===_types.KameleoonException.Initialization||a===_types.KameleoonException.Credentials||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VisitAmount||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached?f.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.CookieParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.NotTargeted?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.FeatureFlagConfigurationNotFound?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.FeatureFlagVariationNotFound||a===_types.KameleoonException.FeatureFlagVariableNotFound?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageRead?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageParse?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.TargetingCondition?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.AmongValuesCheck?f.message=_constants.ERROR_MESSAGES[a](d,e):(0,_helpers.exhaustCheck)(a),f)}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"type",get:function get(){return this.errorType}}]),b}(_wrapNativeSuper(Error));exports.KameleoonError=KameleoonError;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var KameleoonError=function(a){function b(a,d,e){var f;return _classCallCheck(this,b),f=c.call(this,"Error: ".concat(a)),_defineProperty(_assertThisInitialized(f),"errorType",void 0),f.name="KameleoonError",f.errorType=a,(a===_types.KameleoonException.Initialization||a===_types.KameleoonException.Credentials||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VisitAmount||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached?f.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.CookieParse||a===_types.KameleoonException.NotTargeted||a===_types.KameleoonException.FeatureFlagConfigurationNotFound||a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.FeatureFlagVariationNotFound||a===_types.KameleoonException.FeatureFlagEnvironmentDisabled||a===_types.KameleoonException.FeatureFlagVariableNotFound?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageRead?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageParse?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.TargetingCondition?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.AmongValuesCheck?f.message=_constants.ERROR_MESSAGES[a](d,e):(0,_helpers.exhaustCheck)(a),f)}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"type",get:function get(){return this.errorType}}]),b}(_wrapNativeSuper(Error));exports.KameleoonError=KameleoonError;
2
2
  //# sourceMappingURL=kameleoonError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonError.js","names":["KameleoonError","a","b","type","secondParam","thirdParam","f","_classCallCheck","c","call","concat","_defineProperty","_assertThisInitialized","name","errorType","KameleoonException","Initialization","Credentials","ClientConfiguration","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","VisitAmount","EventSourceInitialization","RemoteData","MaximumRetriesReached","message","ERROR_MESSAGES","CookieParse","NotTargeted","FeatureFlagConfigurationNotFound","FeatureFlagVariationNotFound","FeatureFlagVariableNotFound","StorageWrite","JSONParse","StorageRead","StorageParse","TargetingCondition","NumberParse","VersionParse","SemanticVersionParse","AmongValuesCheck","exhaustCheck","_inherits","_createSuper","_createClass","key","get","_wrapNativeSuper","Error","exports"],"sources":["../../src/kameleoonError/kameleoonError.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { ERROR_MESSAGES } from './constants';\nimport { exhaustCheck } from './helpers';\nimport { KameleoonException } from './types';\n\n/**\n * @class\n * KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`\n * */\nexport class KameleoonError extends Error {\n private errorType: KameleoonException;\n\n /**\n * @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum\n * */\n constructor(\n type:\n | KameleoonException.Initialization\n | KameleoonException.Credentials\n | KameleoonException.ClientConfiguration\n | KameleoonException.VisitorCodeMaxLength\n | KameleoonException.VisitorCodeEmpty\n | KameleoonException.VisitAmount\n | KameleoonException.StorageInitialization\n | KameleoonException.EventSourceInitialization\n | KameleoonException.RemoteData\n | KameleoonException.MaximumRetriesReached,\n );\n constructor(\n type: KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariableNotFound,\n variableKey: string,\n visitorCode: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariationNotFound,\n variationKey: string,\n visitorCode: string,\n );\n constructor(type: KameleoonException.NotTargeted, visitorCode: string);\n constructor(type: KameleoonException.CookieParse, message: string);\n constructor(\n type: KameleoonException.StorageWrite | KameleoonException.JSONParse,\n err: unknown,\n );\n constructor(type: KameleoonException.StorageRead, storageKey: string);\n constructor(\n type: KameleoonException.StorageParse,\n err: unknown,\n key: KameleoonStorageKey,\n );\n constructor(\n type: KameleoonException.TargetingCondition,\n targetingType: TargetingType,\n );\n constructor(\n type: KameleoonException.AmongValuesCheck,\n err: unknown,\n value: string,\n );\n constructor(\n type:\n | KameleoonException.NumberParse\n | KameleoonException.VersionParse\n | KameleoonException.SemanticVersionParse,\n value: string,\n );\n constructor(\n type: KameleoonException,\n secondParam?:\n | number\n | string\n | unknown\n | KameleoonStorageKey\n | TargetingType,\n thirdParam?: string | KameleoonStorageKey,\n ) {\n super(`Error: ${type}`);\n\n this.name = 'KameleoonError';\n this.errorType = type;\n\n switch (type) {\n case KameleoonException.Initialization:\n case KameleoonException.Credentials:\n case KameleoonException.ClientConfiguration:\n case KameleoonException.VisitorCodeMaxLength:\n case KameleoonException.VisitorCodeEmpty:\n case KameleoonException.StorageInitialization:\n case KameleoonException.VisitAmount:\n case KameleoonException.EventSourceInitialization:\n case KameleoonException.RemoteData:\n case KameleoonException.MaximumRetriesReached:\n this.message = ERROR_MESSAGES[type]();\n break;\n case KameleoonException.CookieParse:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.NotTargeted:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.FeatureFlagConfigurationNotFound:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.FeatureFlagVariationNotFound:\n case KameleoonException.FeatureFlagVariableNotFound:\n this.message = ERROR_MESSAGES[type](\n secondParam as string,\n thirdParam as string,\n );\n break;\n case KameleoonException.StorageWrite:\n case KameleoonException.JSONParse:\n this.message = ERROR_MESSAGES[type](secondParam);\n break;\n case KameleoonException.StorageRead:\n this.message = ERROR_MESSAGES[type](secondParam as KameleoonStorageKey);\n break;\n case KameleoonException.StorageParse:\n this.message = ERROR_MESSAGES[type](\n secondParam,\n thirdParam as KameleoonStorageKey,\n );\n break;\n case KameleoonException.TargetingCondition:\n this.message = ERROR_MESSAGES[type](secondParam as TargetingType);\n break;\n case KameleoonException.NumberParse:\n case KameleoonException.VersionParse:\n case KameleoonException.SemanticVersionParse:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.AmongValuesCheck:\n this.message = ERROR_MESSAGES[type](secondParam, thirdParam as string);\n break;\n default:\n exhaustCheck(type);\n }\n }\n\n get type(): KameleoonException {\n return this.errorType;\n }\n}\n"],"mappings":"4zHAUa,CAAAA,cAAc,UAAAC,CAAA,EA6DzB,SAAAC,EACEC,CAAwB,CACxBC,CAKiB,CACjBC,CAAyC,CACzC,KAAAC,CAAA,QAAAC,eAAA,MAAAL,CAAA,EAAAI,CAAA,CAAAE,CAAA,CAAAC,IAAA,gBAAAC,MAAA,CACgBP,CAAI,GAAAQ,eAAA,CAAAC,sBAAA,CAAAN,CAAA,sBAEpBA,CAAA,CAAKO,IAAI,CAAG,gBAAgB,CAC5BP,CAAA,CAAKQ,SAAS,CAAGX,CAAI,EAEbA,CAAI,GACLY,yBAAkB,CAACC,cAAc,EADhCb,CAAI,GAELY,yBAAkB,CAACE,WAAW,EAF7Bd,CAAI,GAGLY,yBAAkB,CAACG,mBAAmB,EAHrCf,CAAI,GAILY,yBAAkB,CAACI,oBAAoB,EAJtChB,CAAI,GAKLY,yBAAkB,CAACK,gBAAgB,EALlCjB,CAAI,GAMLY,yBAAkB,CAACM,qBAAqB,EANvClB,CAAI,GAOLY,yBAAkB,CAACO,WAAW,E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B,CAACsB,kBAAkB,CACxC/B,CAAA,CAAKoB,OAAO,CAAGC,yBAAc,CAACxB,CAAI,CAAC,CAACC,CAAW,CAAkB,CA3C7DD,CAAI,GA6CLY,yBAAkB,CAACuB,WAAW,EA7C7BnC,CAAI,GA8CLY,yBAAkB,CAACwB,YAAY,EA9C9BpC,CAAI,GA+CLY,yBAAkB,CAACyB,oBAAoB,CAC1ClC,CAAA,CAAKoB,OAAO,CAAGC,yBAAc,CAACxB,CAAI,CAAC,CAACC,CAAW,CAAW,CAhDtDD,CAAI,GAkDLY,yBAAkB,CAAC0B,gBAAgB,CACtCnC,CAAA,CAAKoB,OAAO,CAAGC,yBAAc,CAACxB,CAAI,CAAC,CAACC,CAAW,CAAEC,CAAU,CAAW,CAGtE,GAAAqC,qBAAY,EAACvC,CAAI,CAAC,CAAAG,CAAA,CAExB,CAACqC,SAAA,CAAAzC,CAAA,CAAAD,CAAA,MAAAO,CAAA,CAAAoC,YAAA,CAAA1C,CAAA,SAAA2C,YAAA,CAAA3C,CAAA,GAAA4C,GAAA,QAAAC,GAAA,CAED,SAAAA,IAAA,CAA+B,CAC7B,MAAO,KAAI,CAACjC,SACd,CAAC,IAAAZ,CAAA,EAAA8C,gBAAA,CAxIiCC,KAAK,GAAAC,OAAA,CAAAlD,cAAA,CAAAA,cAAA"}
1
+ {"version":3,"file":"kameleoonError.js","names":["KameleoonError","a","b","type","secondParam","thirdParam","f","_classCallCheck","c","call","concat","_defineProperty","_assertThisInitialized","name","errorType","KameleoonException","Initialization","Credentials","ClientConfiguration","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","VisitAmount","EventSourceInitialization","RemoteData","MaximumRetriesReached","message","ERROR_MESSAGES","CookieParse","NotTargeted","FeatureFlagConfigurationNotFound","NumberParse","VersionParse","SemanticVersionParse","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","FeatureFlagVariableNotFound","StorageWrite","JSONParse","StorageRead","StorageParse","TargetingCondition","AmongValuesCheck","exhaustCheck","_inherits","_createSuper","_createClass","key","get","_wrapNativeSuper","Error","exports"],"sources":["../../src/kameleoonError/kameleoonError.ts"],"sourcesContent":["import { KameleoonStorageKey } from 'src/storage';\nimport { TargetingType } from 'src/targeting';\nimport { ERROR_MESSAGES } from './constants';\nimport { exhaustCheck } from './helpers';\nimport { KameleoonException } from './types';\n\n/**\n * @class\n * KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`\n * */\nexport class KameleoonError extends Error {\n private errorType: KameleoonException;\n\n /**\n * @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum\n * */\n constructor(\n type:\n | KameleoonException.Initialization\n | KameleoonException.Credentials\n | KameleoonException.ClientConfiguration\n | KameleoonException.VisitorCodeMaxLength\n | KameleoonException.VisitorCodeEmpty\n | KameleoonException.VisitAmount\n | KameleoonException.StorageInitialization\n | KameleoonException.EventSourceInitialization\n | KameleoonException.RemoteData\n | KameleoonException.MaximumRetriesReached,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n );\n constructor(\n type:\n | KameleoonException.FeatureFlagConfigurationNotFound\n | KameleoonException.FeatureFlagEnvironmentDisabled,\n featureKey: string,\n environment: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariableNotFound,\n variableKey: string,\n visitorCode: string,\n );\n constructor(\n type: KameleoonException.FeatureFlagVariationNotFound,\n variationKey: string,\n visitorCode: string,\n );\n constructor(type: KameleoonException.NotTargeted, visitorCode: string);\n constructor(type: KameleoonException.CookieParse, message: string);\n constructor(\n type: KameleoonException.StorageWrite | KameleoonException.JSONParse,\n err: unknown,\n );\n constructor(type: KameleoonException.StorageRead, storageKey: string);\n constructor(\n type: KameleoonException.StorageParse,\n err: unknown,\n key: KameleoonStorageKey,\n );\n constructor(\n type: KameleoonException.TargetingCondition,\n targetingType: TargetingType,\n );\n constructor(\n type: KameleoonException.AmongValuesCheck,\n err: unknown,\n value: string,\n );\n constructor(\n type:\n | KameleoonException.NumberParse\n | KameleoonException.VersionParse\n | KameleoonException.SemanticVersionParse,\n value: string,\n );\n constructor(\n type: KameleoonException,\n secondParam?:\n | number\n | string\n | unknown\n | KameleoonStorageKey\n | TargetingType,\n thirdParam?: string | KameleoonStorageKey,\n ) {\n super(`Error: ${type}`);\n\n this.name = 'KameleoonError';\n this.errorType = type;\n\n switch (type) {\n case KameleoonException.Initialization:\n case KameleoonException.Credentials:\n case KameleoonException.ClientConfiguration:\n case KameleoonException.VisitorCodeMaxLength:\n case KameleoonException.VisitorCodeEmpty:\n case KameleoonException.StorageInitialization:\n case KameleoonException.VisitAmount:\n case KameleoonException.EventSourceInitialization:\n case KameleoonException.RemoteData:\n case KameleoonException.MaximumRetriesReached:\n this.message = ERROR_MESSAGES[type]();\n break;\n case KameleoonException.CookieParse:\n case KameleoonException.NotTargeted:\n case KameleoonException.FeatureFlagConfigurationNotFound:\n case KameleoonException.NumberParse:\n case KameleoonException.VersionParse:\n case KameleoonException.SemanticVersionParse:\n this.message = ERROR_MESSAGES[type](secondParam as string);\n break;\n case KameleoonException.FeatureFlagVariationNotFound:\n case KameleoonException.FeatureFlagEnvironmentDisabled:\n case KameleoonException.FeatureFlagVariableNotFound:\n this.message = ERROR_MESSAGES[type](\n secondParam as string,\n thirdParam as string,\n );\n break;\n case KameleoonException.StorageWrite:\n case KameleoonException.JSONParse:\n this.message = ERROR_MESSAGES[type](secondParam);\n break;\n case KameleoonException.StorageRead:\n this.message = ERROR_MESSAGES[type](secondParam as KameleoonStorageKey);\n break;\n case KameleoonException.StorageParse:\n this.message = ERROR_MESSAGES[type](\n secondParam,\n thirdParam as KameleoonStorageKey,\n );\n break;\n case KameleoonException.TargetingCondition:\n this.message = ERROR_MESSAGES[type](secondParam as TargetingType);\n break;\n case KameleoonException.AmongValuesCheck:\n this.message = ERROR_MESSAGES[type](secondParam, thirdParam as string);\n break;\n default:\n exhaustCheck(type);\n }\n }\n\n get type(): KameleoonException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5IiCC,KAAK,GAAAC,OAAA,CAAAnD,cAAA,CAAAA,cAAA"}
@@ -8,6 +8,7 @@ export declare enum KameleoonException {
8
8
  FeatureFlagConfigurationNotFound = "FeatureFlagConfigurationNotFound",
9
9
  FeatureFlagVariableNotFound = "FeatureFlagVariableNotFound",
10
10
  FeatureFlagVariationNotFound = "FeatureFlagVariationNotFound",
11
+ FeatureFlagEnvironmentDisabled = "FeatureFlagEnvironmentDisabled",
11
12
  NotTargeted = "NotTargeted",
12
13
  VisitAmount = "VisitAmount",
13
14
  VisitorCodeMaxLength = "VisitorCodeMaxLength",
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;var KameleoonException=function(a){return a.Credentials="Credentials",a.EventSourceInitialization="EventSourceInitialization",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.FeatureFlagVariationNotFound="FeatureFlagVariationNotFound",a.NotTargeted="NotTargeted",a.VisitAmount="VisitAmount",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.CookieParse="CookieParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});exports.KameleoonException=KameleoonException;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;var KameleoonException=function(a){return a.Credentials="Credentials",a.EventSourceInitialization="EventSourceInitialization",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.FeatureFlagVariationNotFound="FeatureFlagVariationNotFound",a.FeatureFlagEnvironmentDisabled="FeatureFlagEnvironmentDisabled",a.NotTargeted="NotTargeted",a.VisitAmount="VisitAmount",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.CookieParse="CookieParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});exports.KameleoonException=KameleoonException;
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["KameleoonException","Credentials","EventSourceInitialization","FeatureFlagConfigurationNotFound","FeatureFlagVariableNotFound","FeatureFlagVariationNotFound","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","StorageWrite","StorageRead","StorageParse","ClientConfiguration","TargetingCondition","AmongValuesCheck","Initialization","JSONParse","NumberParse","VersionParse","CookieParse","SemanticVersionParse","RemoteData","MaximumRetriesReached","exports"],"sources":["../../src/kameleoonError/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of exception types `KameleoonError`\n * */\nexport enum KameleoonException {\n Credentials = 'Credentials',\n EventSourceInitialization = 'EventSourceInitialization',\n FeatureFlagConfigurationNotFound = 'FeatureFlagConfigurationNotFound',\n FeatureFlagVariableNotFound = 'FeatureFlagVariableNotFound',\n FeatureFlagVariationNotFound = 'FeatureFlagVariationNotFound',\n NotTargeted = 'NotTargeted',\n VisitAmount = 'VisitAmount',\n VisitorCodeMaxLength = 'VisitorCodeMaxLength',\n VisitorCodeEmpty = 'VisitorCodeEmpty',\n StorageInitialization = 'StorageInitialization',\n StorageWrite = 'StorageWrite',\n StorageRead = 'StorageRead',\n StorageParse = 'StorageParse',\n ClientConfiguration = 'ClientConfiguration',\n TargetingCondition = 'TargetingCondition',\n AmongValuesCheck = 'AmongValuesCheck',\n Initialization = 'Initialization',\n JSONParse = 'JSONParse',\n NumberParse = 'NumberParse',\n VersionParse = 'VersionParse',\n CookieParse = 'CookieParse',\n SemanticVersionParse = 'SemanticVersionParse',\n RemoteData = 'RemoteData',\n MaximumRetriesReached = 'MaximumRetriesReached',\n}\n"],"mappings":"yGAIY,CAAAA,kBAAkB,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAC,WAAA,eAAlBD,CAAkB,CAAAE,yBAAA,6BAAlBF,CAAkB,CAAAG,gCAAA,oCAAlBH,CAAkB,CAAAI,2BAAA,+BAAlBJ,CAAkB,CAAAK,4BAAA,gCAAlBL,CAAkB,CAAAM,WAAA,eAAlBN,CAAkB,CAAAO,WAAA,eAAlBP,CAAkB,CAAAQ,oBAAA,wBAAlBR,CAAkB,CAAAS,gBAAA,oBAAlBT,CAAkB,CAAAU,qBAAA,yBAAlBV,CAAkB,CAAAW,YAAA,gBAAlBX,CAAkB,CAAAY,WAAA,eAAlBZ,CAAkB,CAAAa,YAAA,gBAAlBb,CAAkB,CAAAc,mBAAA,uBAAlBd,CAAkB,CAAAe,kBAAA,sBAAlBf,CAAkB,CAAAgB,gBAAA,oBAAlBhB,CAAkB,CAAAiB,cAAA,kBAAlBjB,CAAkB,CAAAkB,SAAA,aAAlBlB,CAAkB,CAAAmB,WAAA,eAAlBnB,CAAkB,CAAAoB,YAAA,gBAAlBpB,CAAkB,CAAAqB,WAAA,eAAlBrB,CAAkB,CAAAsB,oBAAA,wBAAlBtB,CAAkB,CAAAuB,UAAA,cAAlBvB,CAAkB,CAAAwB,qBAAA,yBAAlBxB,CAAkB,MAAAyB,OAAA,CAAAzB,kBAAA,CAAAA,kBAAA"}
1
+ {"version":3,"file":"types.js","names":["KameleoonException","Credentials","EventSourceInitialization","FeatureFlagConfigurationNotFound","FeatureFlagVariableNotFound","FeatureFlagVariationNotFound","FeatureFlagEnvironmentDisabled","NotTargeted","VisitAmount","VisitorCodeMaxLength","VisitorCodeEmpty","StorageInitialization","StorageWrite","StorageRead","StorageParse","ClientConfiguration","TargetingCondition","AmongValuesCheck","Initialization","JSONParse","NumberParse","VersionParse","CookieParse","SemanticVersionParse","RemoteData","MaximumRetriesReached","exports"],"sources":["../../src/kameleoonError/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of exception types `KameleoonError`\n * */\nexport enum KameleoonException {\n Credentials = 'Credentials',\n EventSourceInitialization = 'EventSourceInitialization',\n FeatureFlagConfigurationNotFound = 'FeatureFlagConfigurationNotFound',\n FeatureFlagVariableNotFound = 'FeatureFlagVariableNotFound',\n FeatureFlagVariationNotFound = 'FeatureFlagVariationNotFound',\n FeatureFlagEnvironmentDisabled = 'FeatureFlagEnvironmentDisabled',\n NotTargeted = 'NotTargeted',\n VisitAmount = 'VisitAmount',\n VisitorCodeMaxLength = 'VisitorCodeMaxLength',\n VisitorCodeEmpty = 'VisitorCodeEmpty',\n StorageInitialization = 'StorageInitialization',\n StorageWrite = 'StorageWrite',\n StorageRead = 'StorageRead',\n StorageParse = 'StorageParse',\n ClientConfiguration = 'ClientConfiguration',\n TargetingCondition = 'TargetingCondition',\n AmongValuesCheck = 'AmongValuesCheck',\n Initialization = 'Initialization',\n JSONParse = 'JSONParse',\n NumberParse = 'NumberParse',\n VersionParse = 'VersionParse',\n CookieParse = 'CookieParse',\n SemanticVersionParse = 'SemanticVersionParse',\n RemoteData = 'RemoteData',\n MaximumRetriesReached = 'MaximumRetriesReached',\n}\n"],"mappings":"yGAIY,CAAAA,kBAAkB,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAC,WAAA,eAAlBD,CAAkB,CAAAE,yBAAA,6BAAlBF,CAAkB,CAAAG,gCAAA,oCAAlBH,CAAkB,CAAAI,2BAAA,+BAAlBJ,CAAkB,CAAAK,4BAAA,gCAAlBL,CAAkB,CAAAM,8BAAA,kCAAlBN,CAAkB,CAAAO,WAAA,eAAlBP,CAAkB,CAAAQ,WAAA,eAAlBR,CAAkB,CAAAS,oBAAA,wBAAlBT,CAAkB,CAAAU,gBAAA,oBAAlBV,CAAkB,CAAAW,qBAAA,yBAAlBX,CAAkB,CAAAY,YAAA,gBAAlBZ,CAAkB,CAAAa,WAAA,eAAlBb,CAAkB,CAAAc,YAAA,gBAAlBd,CAAkB,CAAAe,mBAAA,uBAAlBf,CAAkB,CAAAgB,kBAAA,sBAAlBhB,CAAkB,CAAAiB,gBAAA,oBAAlBjB,CAAkB,CAAAkB,cAAA,kBAAlBlB,CAAkB,CAAAmB,SAAA,aAAlBnB,CAAkB,CAAAoB,WAAA,eAAlBpB,CAAkB,CAAAqB,YAAA,gBAAlBrB,CAAkB,CAAAsB,WAAA,eAAlBtB,CAAkB,CAAAuB,oBAAA,wBAAlBvB,CAAkB,CAAAwB,UAAA,cAAlBxB,CAAkB,CAAAyB,qBAAA,yBAAlBzB,CAAkB,MAAA0B,OAAA,CAAA1B,kBAAA,CAAAA,kBAAA"}
@@ -1,13 +1,7 @@
1
- import { Result } from 'ts-res';
2
- import { GetResultCookieParametersType, ClientGetVisitorCodeParametersType, ServerGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType } from './types';
3
1
  /**
4
2
  * @abstract
5
3
  * KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures
6
4
  * */
7
5
  export declare abstract class KameleoonUtils {
8
- abstract getVisitorCode(param: ClientGetVisitorCodeParametersType | ServerGetVisitorCodeParametersType | MobileGetVisitorCodeParametersType): string;
9
- protected generateRandomString(length: number): string;
10
- protected getCookieVisitorCode(cookie: string): Result<string, void>;
11
- protected getResultCookie({ domain, visitorCode, }: GetResultCookieParametersType): string;
12
6
  protected getClientConfigurationUrl(siteCode: string): string;
13
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;var _tsRes=require("ts-res"),_requester=require("./requester"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var KameleoonUtils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"generateRandomString",value:function generateRandomString(a){var b="";if(0>a)return b;for(var c=0;c<a;c++)b+="abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())];return b}},{key:"getCookieVisitorCode",value:function getCookieVisitorCode(a){var b=a.split(_constants.CookieParameter.PairsDelimiter),c=b.find(function(a){var b=a.split(_constants.CookieParameter.KeyValueDelimiter),c=_slicedToArray(b,2),d=c[0],e=c[1];return d===_constants.KAMELEOON_COOKIE_KEY});if(c){var d=c.split(_constants.CookieParameter.KeyValueDelimiter),e=_slicedToArray(d,2),f=e[0],g=e[1];return(0,_tsRes.Ok)(g)}return(0,_tsRes.Err)()}},{key:"getResultCookie",value:function getResultCookie(a){var b=a.domain,c=a.visitorCode,d=[_constants.KAMELEOON_COOKIE_KEY+_constants.CookieParameter.KeyValueDelimiter+c,_constants.CookieParameter.MaxAge+_constants.CookieParameter.KeyValueDelimiter+31536000,_constants.CookieParameter.Path+_constants.CookieParameter.KeyValueDelimiter+"/",_constants.CookieParameter.Domain+_constants.CookieParameter.KeyValueDelimiter+b];return d.join(_constants.CookieParameter.PairsDelimiter)}},{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a){return _requester.URL.CLIENT_CONFIGURATION+_requester.UrlQuery.Mobile+a}}]),a}();exports.KameleoonUtils=KameleoonUtils;
1
+ "use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var KameleoonUtils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a){return(0,_requester.getClientConfigurationUrl)(a)}}]),a}();exports.KameleoonUtils=KameleoonUtils;
2
2
  //# sourceMappingURL=kameleoonUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonUtils.js","names":["KameleoonUtils","a","_classCallCheck","_createClass","key","value","generateRandomString","length","randomString","i","Math","floor","random","getCookieVisitorCode","cookie","pairs","split","Cookie","PairsDelimiter","pair","find","b","KeyValueDelimiter","c","_slicedToArray","_","KAMELEOON_COOKIE_KEY","d","e","Ok","Err","getResultCookie","domain","visitorCode","cookieArray","MaxAge","Path","Domain","join","getClientConfigurationUrl","siteCode","URL","CLIENT_CONFIGURATION","UrlQuery","Mobile","exports"],"sources":["../src/kameleoonUtils.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { URL, UrlQuery } from './requester';\nimport { CookieParameter as Cookie, KAMELEOON_COOKIE_KEY } from './constants';\nimport {\n GetResultCookieParametersType,\n ClientGetVisitorCodeParametersType,\n ServerGetVisitorCodeParametersType,\n MobileGetVisitorCodeParametersType,\n} from './types';\n\n/**\n * @abstract\n * KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures\n * */\nexport abstract class KameleoonUtils {\n abstract getVisitorCode(\n param:\n | ClientGetVisitorCodeParametersType\n | ServerGetVisitorCodeParametersType\n | MobileGetVisitorCodeParametersType,\n ): string;\n\n protected generateRandomString(length: number): string {\n const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';\n let randomString = '';\n\n if (length < 0) {\n return randomString;\n }\n\n for (let i = 0; i < length; i++) {\n randomString += characters[Math.floor(Math.random() * characters.length)];\n }\n\n return randomString;\n }\n\n protected getCookieVisitorCode(cookie: string): Result<string, void> {\n const pairs = cookie.split(Cookie.PairsDelimiter);\n const pair = pairs.find((pair) => {\n const [key, _] = pair.split(Cookie.KeyValueDelimiter) as [string, string];\n\n return key === KAMELEOON_COOKIE_KEY;\n });\n\n if (pair) {\n const [_, value] = pair.split(Cookie.KeyValueDelimiter);\n\n return Ok(value);\n }\n\n return Err();\n }\n\n protected getResultCookie({\n domain,\n visitorCode,\n }: GetResultCookieParametersType): string {\n const yearSeconds = 60 * 60 * 24 * 365;\n const cookieArray = [\n KAMELEOON_COOKIE_KEY + Cookie.KeyValueDelimiter + visitorCode,\n Cookie.MaxAge + Cookie.KeyValueDelimiter + yearSeconds,\n Cookie.Path + Cookie.KeyValueDelimiter + '/',\n Cookie.Domain + Cookie.KeyValueDelimiter + domain,\n ];\n\n return cookieArray.join(Cookie.PairsDelimiter);\n }\n\n protected getClientConfigurationUrl(siteCode: string): string {\n return URL.CLIENT_CONFIGURATION + UrlQuery.Mobile + siteCode;\n }\n}\n"],"mappings":"kgFAcsB,CAAAA,cAAc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xC,CAAA+B,CAAM,CAAA/B,CAAA,CAAN+B,MAAM,CACNC,CAAW,CAAAhC,CAAA,CAAXgC,WAAW,CAGLC,CAAW,CAAG,CAClBR,+BAAoB,CAAGT,0BAAM,CAACK,iBAAiB,CAAGW,CAAW,CAC7DhB,0BAAM,CAACkB,MAAM,CAAGlB,0BAAM,CAACK,iBAAiB,SAAc,CACtDL,0BAAM,CAACmB,IAAI,CAAGnB,0BAAM,CAACK,iBAAiB,CAAG,GAAG,CAC5CL,0BAAM,CAACoB,MAAM,CAAGpB,0BAAM,CAACK,iBAAiB,CAAGU,CAAM,CAClD,CAED,MAAO,CAAAE,CAAW,CAACI,IAAI,CAACrB,0BAAM,CAACC,cAAc,CAC/C,CAAC,GAAAd,GAAA,6BAAAC,KAAA,CAED,SAAAkC,0BAAoCC,CAAgB,CAAU,CAC5D,MAAO,CAAAC,cAAG,CAACC,oBAAoB,CAAGC,mBAAQ,CAACC,MAAM,CAAGJ,CACtD,CAAC,IAAAvC,CAAA,IAAA4C,OAAA,CAAA7C,cAAA,CAAAA,cAAA"}
1
+ {"version":3,"file":"kameleoonUtils.js","names":["_requester","require","Object","defineProperty","exports","value","KameleoonUtils","_typeof","a","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getClientConfigurationUrl","siteCode"],"sources":["../src/kameleoonUtils.ts"],"sourcesContent":["import { getClientConfigurationUrl } from './requester';\n\n/**\n * @abstract\n * KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures\n * */\nexport abstract class KameleoonUtils {\n protected getClientConfigurationUrl(siteCode: string): string {\n return getClientConfigurationUrl(siteCode);\n }\n}\n"],"mappings":"aAAA,IAAAA,UAAA,CAAAC,OAAA,gBAAwDC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,cAAA,iBAAAC,QAAAC,CAAA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