@kameleoon/javascript-sdk-core 3.1.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.
- package/dist/clientConfiguration/types.d.ts +1 -0
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/hasher/hasher.d.ts +1 -1
- package/dist/hasher/hasher.js +1 -1
- package/dist/hasher/hasher.js.map +1 -1
- package/dist/hasher/types.d.ts +1 -1
- package/dist/hasher/types.js.map +1 -1
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonData/customData.d.ts +6 -0
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.d.ts +2 -0
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +1 -0
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/types.d.ts +1 -1
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +1 -0
- package/dist/variationConfiguration/types.js.map +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +1 -1
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["UpdateType","Polling","RealTime","Idle","exports","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IExternalEventSourceConstructor } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { CookieManager } from 'src/cookieManager';\nimport { ClientDataType, IExternalStorage } from 'src/storage';\nimport { OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type UpdateClientConfigurationParameters = {\n timestamp?: number;\n useCache?: boolean;\n};\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n projectEnabled: boolean;\n consentType: ConsentType;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IExternalStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalEventSource: IExternalEventSourceConstructor;\n externalCookieManager: CookieManager;\n};\n"],"mappings":"uNAoBY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAC,OAAA,cAAVD,CAAU,CAAVA,CAAU,CAAAE,QAAA,eAAVF,CAAU,CAAVA,CAAU,CAAAG,IAAA,WAAVH,CAAU,MAAAI,OAAA,CAAAJ,UAAA,CAAAA,UAAA,IAeV,CAAAK,QAAQ,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAAAD,OAAA,CAAAC,QAAA,CAAAA,QAAA,IAKR,CAAAG,0BAA0B,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAAAJ,OAAA,CAAAI,0BAAA,CAAAA,0BAAA,IAa1B,CAAAW,aAAa,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAAAf,OAAA,CAAAe,aAAA,CAAAA,aAAA,IAMb,CAAAI,eAAe,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAAAnB,OAAA,CAAAmB,eAAA,CAAAA,eAAA,IAMf,CAAAI,WAAW,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW,MAAAvB,OAAA,CAAAuB,WAAA,CAAAA,WAAA"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["UpdateType","Polling","RealTime","Idle","exports","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IExternalEventSourceConstructor } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { CookieManager } from 'src/cookieManager';\nimport { ClientDataType, IExternalStorage } from 'src/storage';\nimport { OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type UpdateClientConfigurationParameters = {\n timestamp?: number;\n useCache?: boolean;\n};\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n isMappingIdentifier: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n projectEnabled: boolean;\n consentType: ConsentType;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IExternalStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalEventSource: IExternalEventSourceConstructor;\n externalCookieManager: CookieManager;\n};\n"],"mappings":"uNAoBY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAC,OAAA,cAAVD,CAAU,CAAVA,CAAU,CAAAE,QAAA,eAAVF,CAAU,CAAVA,CAAU,CAAAG,IAAA,WAAVH,CAAU,MAAAI,OAAA,CAAAJ,UAAA,CAAAA,UAAA,IAeV,CAAAK,QAAQ,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAAAD,OAAA,CAAAC,QAAA,CAAAA,QAAA,IAKR,CAAAG,0BAA0B,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAAAJ,OAAA,CAAAI,0BAAA,CAAAA,0BAAA,IAa1B,CAAAW,aAAa,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAAAf,OAAA,CAAAe,aAAA,CAAAA,aAAA,IAMb,CAAAI,eAAe,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAAAnB,OAAA,CAAAmB,eAAA,CAAAA,eAAA,IAMf,CAAAI,WAAW,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW,MAAAvB,OAAA,CAAAuB,WAAA,CAAAA,WAAA"}
|
package/dist/hasher/hasher.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GetHashDoubleParamsType } from './types';
|
|
2
2
|
export declare class Hasher {
|
|
3
|
-
static getHashDouble({
|
|
3
|
+
static getHashDouble({ visitorIdentifier, id, respoolTime, }: GetHashDoubleParamsType): number;
|
|
4
4
|
static calculateHash(seed: string): number;
|
|
5
5
|
}
|
package/dist/hasher/hasher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}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 Hasher=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"getHashDouble",value:function getHashDouble(a){var b=a.
|
|
1
|
+
"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}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 Hasher=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"getHashDouble",value:function getHashDouble(a){var b=a.visitorIdentifier,c=a.id,d=a.respoolTime,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}},{key:"calculateHash",value:function calculateHash(a){var b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}]),a}();exports.Hasher=Hasher;
|
|
2
2
|
//# sourceMappingURL=hasher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getHashDouble","
|
|
1
|
+
{"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getHashDouble","visitorIdentifier","id","respoolTime","suffix","calculateHash","seed","hashDigest","sha256","toString","parseInt","Math","pow"],"sources":["../../src/hasher/hasher.ts"],"sourcesContent":["import sha256 from 'crypto-js/sha256';\nimport { GetHashDoubleParamsType } from './types';\n\nexport class Hasher {\n static getHashDouble({\n visitorIdentifier,\n id,\n respoolTime,\n }: GetHashDoubleParamsType): number {\n let suffix = '';\n\n if (respoolTime) {\n suffix += String(respoolTime);\n }\n\n return this.calculateHash(visitorIdentifier + id + suffix);\n }\n\n // --- Note ---\n // `hashDouble` is a seeded pseudo-random number between 0 and 1\n // used for deciding what variation to assign\n // `calculateHash` algorithm is consistent between every SDK\n // and will always provide same pseudo-random value for the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tC,CAAA,IAAAH,OAAA,CAAAE,MAAA,CAAAA,MAAA"}
|
package/dist/hasher/types.d.ts
CHANGED
package/dist/hasher/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/hasher/types.ts"],"sourcesContent":["export type GetHashDoubleParamsType = {\n respoolTime: number | null;\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/hasher/types.ts"],"sourcesContent":["export type GetHashDoubleParamsType = {\n respoolTime: number | null;\n visitorIdentifier: string;\n id: string;\n};\n"],"mappings":""}
|
package/dist/kameleoonClient.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_types=require("./types"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");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 _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 _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}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 _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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 KameleoonClient=function(){function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"consentDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1),_defineProperty(this,"environment",void 0),_defineProperty(this,"cookieManager",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings;this.environment=g.environment;var h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalCookieManager,l=e.externalRequestDispatcher,m=e.externalClientConfiguration,n=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:l}),o=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),p=h.initialize(_storage.KameleoonStorageKey.ClientData),q=h.initialize(_storage.KameleoonStorageKey.TargetingData),r=h.initialize(_storage.KameleoonStorageKey.VariationData),s=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),t=h.initialize(_storage.KameleoonStorageKey.ConsentData),u=new _kameleoonData.DataManager({storage:q,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval}),v=new _clientConfiguration.ClientConfiguration({settings:g,storage:p,dataManager:u,requester:n,externalClientConfiguration:m,offlineTrackingStorage:s,externalEventSource:i,externalCookieManager:k}),w=new _variationConfiguration.VariationConfiguration(r);this.variationConfiguration=w,this.requester=n,this.trackingCache=o,this.dataManager=u,this.clientConfiguration=v,this.externalPackageInfo=j,this.offlineTrackingStorage=s,this.consentDataStorage=t,this.cookieManager=k}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.clientConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.dataManager).addData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.visitorCode,d=a.shouldAddData,e=void 0===d||d,f=a.filters,g=void 0===f?_constants.DEFAULT_VISITOR_DATA_FILTERS:f,this.initialized){b.next=3;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);case 3:if(_utilities.Utilities.validateVisitorCode(c).throw(),h=g.previousVisitAmount,!("number"==typeof h&&(1>h||25<h))){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);case 7:return b.next=9,this.requester.getVisitorData(c,g);case 9:i=b.sent,j=i.throw(),k=_utilities.Utilities.parseVisitorData({data:j,filters:g,visitorCode:c,variationConfiguration:this.variationConfiguration}),l=_createForOfIteratorHelper(k);try{for(l.s();!(m=l.n()).done;)n=m.value,(e||this.dataManager.isPersistentCustomData(n))&&this.addData(c,n)}catch(a){l.e(a)}finally{l.f()}return b.abrupt("return",k);case 15:case"end":return b.stop();}},b,this)}));return a}()},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage});if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.dataManager.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(d),offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.clientConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.clientConfiguration.featureFlags,d=[],e=this.dataManager.storedTargetingData[a],f=_createForOfIteratorHelper(c);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=this.variationConfiguration.getVariation({visitorCode:a,targetingData:e,featureFlag:g,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();if(h.variationKey!==_constants.OFF_VARIATION_KEY&&g.environmentEnabled){var i=h.featureFlagId,j=h.featureKey;d.push({id:i,key:j})}}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.clientConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"getFeatureFlagVariables",value:function getFeatureFlagVariables(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey,e=this.clientConfiguration.featureFlags,f=e.find(function(a){return a.featureKey===b});if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b);var g=f.variations.find(function(a){return a.key===d});if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,d,a);var h,i=[],j=_createForOfIteratorHelper(g.variables);try{for(j.s();!(h=j.n()).done;){var k=h.value,l=_utilities.Utilities.parseFeatureVariable(k).throw();i.push(l)}}catch(a){j.e(a)}finally{j.f()}return i}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){try{var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}catch(a){if(a instanceof _kameleoonError.KameleoonError&&a.type===_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled)return!1;throw a}}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.dataManager.addData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"getVisitorCode",value:function getVisitorCode(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.cookieManager.getVisitorCode(a)}},{key:"setLegalConsent",value:function setLegalConsent(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b=a.visitorCode,c=a.consent;_utilities.Utilities.validateVisitorCode(b).throw(),this.consentDataStorage.update(_defineProperty({},b,c)),c?_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:a.visitorCode,response:a.response}):this.cookieManager.setCookie({visitorCode:a.visitorCode}):this.cookieManager.getConsentRequired()&&(_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:"",response:a.response}):this.cookieManager.setCookie({visitorCode:""}))}},{key:"_isConsentProvided",value:function _isConsentProvided(a){var b=this.clientConfiguration.isConsentRequired,c=this.consentDataStorage.read();return!b||c.ok&&c.data[a]}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.clientConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));if(!d.environmentEnabled)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled,d.featureKey,this.environment||_types.Environment.Production));var e=this.dataManager.storedTargetingData[a],f=this.variationConfiguration.getVariation({visitorCode:a,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),g=f.experimentId,h=f.variationId;return"number"==typeof h&&"number"==typeof g&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:g,variationId:h}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:f,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(f)}}]),a}();exports.KameleoonClient=KameleoonClient;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_types=require("./types"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");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 _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 _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}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 _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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 KameleoonClient=function(){function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"consentDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1),_defineProperty(this,"environment",void 0),_defineProperty(this,"cookieManager",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings;this.environment=g.environment;var h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalCookieManager,l=e.externalRequestDispatcher,m=e.externalClientConfiguration,n=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:l}),o=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),p=h.initialize(_storage.KameleoonStorageKey.ClientData),q=h.initialize(_storage.KameleoonStorageKey.TargetingData),r=h.initialize(_storage.KameleoonStorageKey.VariationData),s=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),t=h.initialize(_storage.KameleoonStorageKey.ConsentData),u=new _kameleoonData.DataManager({storage:q,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval}),v=new _clientConfiguration.ClientConfiguration({settings:g,storage:p,dataManager:u,requester:n,externalClientConfiguration:m,offlineTrackingStorage:s,externalEventSource:i,externalCookieManager:k}),w=new _variationConfiguration.VariationConfiguration(r);this.variationConfiguration=w,this.requester=n,this.trackingCache=o,this.dataManager=u,this.clientConfiguration=v,this.externalPackageInfo=j,this.offlineTrackingStorage=s,this.consentDataStorage=t,this.cookieManager=k}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.clientConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.dataManager).addData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.visitorCode,d=a.shouldAddData,e=void 0===d||d,f=a.filters,g=void 0===f?_constants.DEFAULT_VISITOR_DATA_FILTERS:f,this.initialized){b.next=3;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);case 3:if(_utilities.Utilities.validateVisitorCode(c).throw(),h=g.previousVisitAmount,!("number"==typeof h&&(1>h||25<h))){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);case 7:return b.next=9,this.requester.getVisitorData(c,g);case 9:i=b.sent,j=i.throw(),k=_utilities.Utilities.parseVisitorData({data:j,filters:g,visitorCode:c,variationConfiguration:this.variationConfiguration}),l=_createForOfIteratorHelper(k);try{for(l.s();!(m=l.n()).done;)n=m.value,(e||this.dataManager.isPersistentCustomData(n))&&this.addData(c,n)}catch(a){l.e(a)}finally{l.f()}return b.abrupt("return",k);case 15:case"end":return b.stop();}},b,this)}));return a}()},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage});if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.dataManager.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(d),offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.clientConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.clientConfiguration.featureFlags,d=[],e=this.dataManager.storedTargetingData[a],f=this.dataManager.getVisitorIdentifier(a),g=_createForOfIteratorHelper(c);try{for(g.s();!(b=g.n()).done;){var h=b.value,i=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:f,targetingData:e,featureFlag:h,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();if(i.variationKey!==_constants.OFF_VARIATION_KEY&&h.environmentEnabled){var j=i.featureFlagId,k=i.featureKey;d.push({id:j,key:k})}}}catch(a){g.e(a)}finally{g.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.clientConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"getFeatureFlagVariables",value:function getFeatureFlagVariables(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey,e=this.clientConfiguration.featureFlags,f=e.find(function(a){return a.featureKey===b});if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b);var g=f.variations.find(function(a){return a.key===d});if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,d,a);var h,i=[],j=_createForOfIteratorHelper(g.variables);try{for(j.s();!(h=j.n()).done;){var k=h.value,l=_utilities.Utilities.parseFeatureVariable(k).throw();i.push(l)}}catch(a){j.e(a)}finally{j.f()}return i}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){try{var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}catch(a){if(a instanceof _kameleoonError.KameleoonError&&a.type===_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled)return!1;throw a}}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.dataManager.addData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"getVisitorCode",value:function getVisitorCode(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.cookieManager.getVisitorCode(a)}},{key:"setLegalConsent",value:function setLegalConsent(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b=a.visitorCode,c=a.consent;_utilities.Utilities.validateVisitorCode(b).throw(),this.consentDataStorage.update(_defineProperty({},b,c)),c?_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:a.visitorCode,response:a.response}):this.cookieManager.setCookie({visitorCode:a.visitorCode}):this.cookieManager.getConsentRequired()&&(_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:"",response:a.response}):this.cookieManager.setCookie({visitorCode:""}))}},{key:"_isConsentProvided",value:function _isConsentProvided(a){var b=this.clientConfiguration.isConsentRequired,c=this.consentDataStorage.read();return!b||c.ok&&c.data[a]}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.clientConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));if(!d.environmentEnabled)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled,d.featureKey,this.environment||_types.Environment.Production));var e=this.dataManager.storedTargetingData[a],f=this.dataManager.getVisitorIdentifier(a),g=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:f,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),h=g.experimentId,i=g.variationId;return"number"==typeof i&&"number"==typeof h&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:h,variationId:i}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:g,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(g)}}]),a}();exports.KameleoonClient=KameleoonClient;
|
|
2
2
|
//# sourceMappingURL=kameleoonClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","a","b","siteCode","configuration","internalConfiguration","_classCallCheck","_defineProperty","f","ClientSettings","clientSettings","settings","environment","externalStorage","externalEventSource","externalPackageInfo","externalCookieManager","externalRequestDispatcher","externalClientConfiguration","requester","Requester","packageInfo","requestDispatcher","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","initialize","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","cookieManager","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","useCache","c","wrap","d","prev","next","result","sent","throw","isOfflineModeOn","initialized","abrupt","ok","stop","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","length","data","Array","e","concat","g","h","i","j","k","l","m","n","o","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","VisitAmount","getVisitorData","visitorData","parseVisitorData","_createForOfIteratorHelper","s","done","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","map","id","featureKey","getVisitorFeatureFlags","resultFeatureFlags","targetingData","storedTargetingData","featureFlag","variationData","getVariation","variationKey","OFF_VARIATION_KEY","environmentEnabled","featureFlagId","push","getFeatureFlagVariationKey","_getFeatureFlagVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagConfigurationNotFound","variable","variations","variables","FeatureFlagVariableNotFound","featureVariable","parseFeatureVariable","getFeatureFlagVariables","variation","FeatureFlagVariationNotFound","parsedVariable","isFeatureFlagActive","err","type","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","_construct","CustomData","_toConsumableArray","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","getVisitorCode","params","setLegalConsent","consent","update","isServerEnvironment","setCookie","response","getConsentRequired","isConsentRequired","consentDataResult","read","Err","Environment","Production","withAssignment","experimentId","variationId","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport { ClientConfiguration, JSONType } from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n ServerGetVisitorCodeParametersType,\n ClientGetVisitorCodeParametersType,\n ServerSetLegalConsentParametersType,\n ClientSetLegalConsentParametersType,\n} from './types';\nimport { CookieManager } from './cookieManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport {\n ConsentDataType,\n IExternalStorage,\n OfflineTracking,\n} from './storage/types';\nimport { TargetingDataType } from './targeting';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode: string) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureVariableResultType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method getVisitorCode - obtains visitor code from cookie or storage, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default)\n * @param { ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType } params - an object of type `ServerGetVisitorCodeParametersType` or `ClientGetVisitorCodeParametersType`\n * @returns {string} result visitor code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getVisitorCode: (\n params:\n | ServerGetVisitorCodeParametersType\n | ClientGetVisitorCodeParametersType,\n ) => string;\n /**\n * @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status\n * @param {ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType} params - an object of type `ServerSetLegalConsentParametersType` or `ClientSetLegalConsentParametersType`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n setLegalConsent: (\n params:\n | ServerSetLegalConsentParametersType\n | ClientSetLegalConsentParametersType,\n ) => void;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n private consentDataStorage: IExternalStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private isOfflineModeOn?: boolean;\n private initialized: boolean = false;\n private environment?: Environment;\n private cookieManager: CookieManager;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalCookieManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = externalStorage.initialize<ClientDataType>(\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = externalStorage.initialize<TargetingDataType>(\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = externalStorage.initialize<VariationDataType>(\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = externalStorage.initialize<OfflineTracking>(\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = externalStorage.initialize<ConsentDataType>(\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n externalEventSource,\n externalCookieManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.cookieManager = externalCookieManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize(useCache);\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData(visitorCode, filters);\n const data = result.throw();\n\n const visitorData = Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of visitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode);\n }\n\n public flush(visitorCode?: string): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n Utilities.trackData({\n visitorCode,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.clientConfiguration.featureFlags.map(({ id, featureKey }) => ({\n id,\n key: featureKey,\n }));\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n const targetingData = this.dataManager.storedTargetingData[visitorCode];\n\n for (const featureFlag of featureFlags) {\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n if (\n variationData.variationKey !== OFF_VARIATION_KEY &&\n featureFlag.environmentEnabled\n ) {\n const { featureFlagId, featureKey } = variationData;\n\n resultFeatureFlags.push({ id: featureFlagId, key: featureKey });\n }\n }\n\n return resultFeatureFlags;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureVariableResultType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variable = featureFlag.variations\n .find((item) => item.key === variationKey)\n ?.variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const featureVariable = Utilities.parseFeatureVariable(variable).throw();\n\n return featureVariable;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n const variables: FeatureVariableResultType[] = [];\n\n for (const variable of variation.variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n variables.push(parsedVariable);\n }\n\n return variables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.clientConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public getVisitorCode(\n params:\n | ServerGetVisitorCodeParametersType\n | ClientGetVisitorCodeParametersType,\n ): string {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.cookieManager.getVisitorCode(params);\n }\n\n public setLegalConsent(\n params:\n | ServerSetLegalConsentParametersType\n | ClientSetLegalConsentParametersType,\n ): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const { visitorCode, consent } = params;\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n if (Utilities.isServerEnvironment(params)) {\n this.cookieManager.setCookie({\n visitorCode: params.visitorCode,\n response: params.response,\n });\n } else {\n this.cookieManager.setCookie({ visitorCode: params.visitorCode });\n }\n } else {\n if (this.cookieManager.getConsentRequired()) {\n if (Utilities.isServerEnvironment(params)) {\n this.cookieManager.setCookie({\n visitorCode: '',\n response: params.response,\n });\n } else {\n this.cookieManager.setCookie({ visitorCode: '' });\n }\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureFlagVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.storedTargetingData[visitorCode];\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"qgWAiTa,CAAAA,eAAe,YAiB1B,SAAAC,EAAAC,CAAA,CAIsB,IAHpB,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAa,CAAAF,CAAA,CAAbE,aAAa,CACbC,CAAqB,CAAAH,CAAA,CAArBG,qBAAqB,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,gCAAAA,eAAA,wBAAAA,eAAA,4BAAAA,eAAA,8BAErB,IAAAC,CAAA,CAAqC,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CAAa,CACd,CAHiBM,CAAc,CAAAF,CAAA,CAAxBG,QAAQ,CAIhB,IAAI,CAACC,WAAW,CAAGF,CAAc,CAACE,WAAW,IAE3C,CAAAC,CAAe,CAMbR,CAAqB,CANvBQ,eAAe,CACfC,CAAmB,CAKjBT,CAAqB,CALvBS,mBAAmB,CACnBC,CAAmB,CAIjBV,CAAqB,CAJvBU,mBAAmB,CACnBC,CAAqB,CAGnBX,CAAqB,CAHvBW,qBAAqB,CACrBC,CAAyB,CAEvBZ,CAAqB,CAFvBY,yBAAyB,CACzBC,CAA2B,CACzBb,CAAqB,CADvBa,2BAA2B,CAEvBC,CAAS,CAAG,GAAI,CAAAC,oBAAS,CAAC,CAC9Bj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rC,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAA6J,SAAE,EAAClE,CAAa,CACzB,CAAC,IAAA5H,CAAA,IAAA+L,OAAA,CAAAhM,eAAA,CAAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","a","b","siteCode","configuration","internalConfiguration","_classCallCheck","_defineProperty","f","ClientSettings","clientSettings","settings","environment","externalStorage","externalEventSource","externalPackageInfo","externalCookieManager","externalRequestDispatcher","externalClientConfiguration","requester","Requester","packageInfo","requestDispatcher","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","initialize","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","cookieManager","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","useCache","c","wrap","d","prev","next","result","sent","throw","isOfflineModeOn","initialized","abrupt","ok","stop","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","length","data","Array","e","concat","g","h","i","j","k","l","m","n","o","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","VisitAmount","getVisitorData","visitorData","parseVisitorData","_createForOfIteratorHelper","s","done","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","map","id","featureKey","getVisitorFeatureFlags","resultFeatureFlags","targetingData","storedTargetingData","visitorIdentifier","getVisitorIdentifier","featureFlag","variationData","getVariation","variationKey","OFF_VARIATION_KEY","environmentEnabled","featureFlagId","push","getFeatureFlagVariationKey","_getFeatureFlagVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagConfigurationNotFound","variable","variations","variables","FeatureFlagVariableNotFound","featureVariable","parseFeatureVariable","getFeatureFlagVariables","variation","FeatureFlagVariationNotFound","parsedVariable","isFeatureFlagActive","err","type","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","_construct","CustomData","_toConsumableArray","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","getVisitorCode","params","setLegalConsent","consent","update","isServerEnvironment","setCookie","response","getConsentRequired","isConsentRequired","consentDataResult","read","Err","Environment","Production","withAssignment","experimentId","variationId","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport { ClientConfiguration, JSONType } from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n ServerGetVisitorCodeParametersType,\n ClientGetVisitorCodeParametersType,\n ServerSetLegalConsentParametersType,\n ClientSetLegalConsentParametersType,\n} from './types';\nimport { CookieManager } from './cookieManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport {\n ConsentDataType,\n IExternalStorage,\n OfflineTracking,\n} from './storage/types';\nimport { TargetingDataType } from './targeting';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode: string) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureVariableResultType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method getVisitorCode - obtains visitor code from cookie or storage, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default)\n * @param { ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType } params - an object of type `ServerGetVisitorCodeParametersType` or `ClientGetVisitorCodeParametersType`\n * @returns {string} result visitor code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getVisitorCode: (\n params:\n | ServerGetVisitorCodeParametersType\n | ClientGetVisitorCodeParametersType,\n ) => string;\n /**\n * @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status\n * @param {ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType} params - an object of type `ServerSetLegalConsentParametersType` or `ClientSetLegalConsentParametersType`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n setLegalConsent: (\n params:\n | ServerSetLegalConsentParametersType\n | ClientSetLegalConsentParametersType,\n ) => void;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n private consentDataStorage: IExternalStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private isOfflineModeOn?: boolean;\n private initialized: boolean = false;\n private environment?: Environment;\n private cookieManager: CookieManager;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalCookieManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = externalStorage.initialize<ClientDataType>(\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = externalStorage.initialize<TargetingDataType>(\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = externalStorage.initialize<VariationDataType>(\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = externalStorage.initialize<OfflineTracking>(\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = externalStorage.initialize<ConsentDataType>(\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n externalEventSource,\n externalCookieManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.cookieManager = externalCookieManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize(useCache);\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData(visitorCode, filters);\n const data = result.throw();\n\n const visitorData = Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of visitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode);\n }\n\n public flush(visitorCode?: string): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n Utilities.trackData({\n visitorCode,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.clientConfiguration.featureFlags.map(({ id, featureKey }) => ({\n id,\n key: featureKey,\n }));\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n const targetingData = this.dataManager.storedTargetingData[visitorCode];\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n for (const featureFlag of featureFlags) {\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n if (\n variationData.variationKey !== OFF_VARIATION_KEY &&\n featureFlag.environmentEnabled\n ) {\n const { featureFlagId, featureKey } = variationData;\n\n resultFeatureFlags.push({ id: featureFlagId, key: featureKey });\n }\n }\n\n return resultFeatureFlags;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureVariableResultType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variable = featureFlag.variations\n .find((item) => item.key === variationKey)\n ?.variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const featureVariable = Utilities.parseFeatureVariable(variable).throw();\n\n return featureVariable;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n const variables: FeatureVariableResultType[] = [];\n\n for (const variable of variation.variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n variables.push(parsedVariable);\n }\n\n return variables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.clientConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public getVisitorCode(\n params:\n | ServerGetVisitorCodeParametersType\n | ClientGetVisitorCodeParametersType,\n ): string {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.cookieManager.getVisitorCode(params);\n }\n\n public setLegalConsent(\n params:\n | ServerSetLegalConsentParametersType\n | ClientSetLegalConsentParametersType,\n ): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const { visitorCode, consent } = params;\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n if (Utilities.isServerEnvironment(params)) {\n this.cookieManager.setCookie({\n visitorCode: params.visitorCode,\n response: params.response,\n });\n } else {\n this.cookieManager.setCookie({ visitorCode: params.visitorCode });\n }\n } else {\n if (this.cookieManager.getConsentRequired()) {\n if (Utilities.isServerEnvironment(params)) {\n this.cookieManager.setCookie({\n visitorCode: '',\n response: params.response,\n });\n } else {\n this.cookieManager.setCookie({ visitorCode: '' });\n }\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureFlagVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.storedTargetingData[visitorCode];\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"qgWAiTa,CAAAA,eAAe,YAiB1B,SAAAC,EAAAC,CAAA,CAIsB,IAHpB,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAa,CAAAF,CAAA,CAAbE,aAAa,CACbC,CAAqB,CAAAH,CAAA,CAArBG,qBAAqB,CAAAC,eAAA,MAAAL,CAAA,EAAAM,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,gCAAAA,eAAA,wBAAAA,eAAA,4BAAAA,eAAA,8BAErB,IAAAC,CAAA,CAAqC,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CAAa,CACd,CAHiBM,CAAc,CAAAF,CAAA,CAAxBG,QAAQ,CAIhB,IAAI,CAACC,WAAW,CAAGF,CAAc,CAACE,WAAW,IAE3C,CAAAC,CAAe,CAMbR,CAAqB,CANvBQ,eAAe,CACfC,CAAmB,CAKjBT,CAAqB,CALvBS,mBAAmB,CACnBC,CAAmB,CAIjBV,CAAqB,CAJvBU,mBAAmB,CACnBC,CAAqB,CAGnBX,CAAqB,CAHvBW,qBAAqB,CACrBC,CAAyB,CAEvBZ,CAAqB,CAFvBY,yBAAyB,CACzBC,CAA2B,CACzBb,CAAqB,CADvBa,2BAA2B,CAEvBC,CAAS,CAAG,GAAI,CAAAC,oBAAS,CAAC,CAC9BjB,QAAQ,CAARA,CAAQ,CACRS,WAAW,CAAEF,CAAc,CAACE,WAAW,CACvCS,WAAW,CAAEN,CAAmB,CAChCO,iBAAiB,CAAEL,CACrB,CAAC,CAAC,CACIM,CAAa,CAAG,GAAI,CAAAC,0BAAY,CACpCC,gCAAqB,CACtB,CAEKC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kB,CAACxC,CAAW,CAAC,CACvDrC,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAA+J,SAAE,EAAClE,CAAa,CACzB,CAAC,IAAA9H,CAAA,IAAAiM,OAAA,CAAAlM,eAAA,CAAAA,eAAA"}
|
|
@@ -8,6 +8,7 @@ export declare class CustomData implements IKameleoonData {
|
|
|
8
8
|
private index;
|
|
9
9
|
private value;
|
|
10
10
|
private sent;
|
|
11
|
+
private isIdentifier;
|
|
11
12
|
/**
|
|
12
13
|
* @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application
|
|
13
14
|
* @param {string[]} value - custom value to store under the specified id, value can be anything but has to be stringified to match the `string` type. *Note* value is variadic parameter and can be used as follows
|
|
@@ -36,6 +37,11 @@ export declare class CustomData implements IKameleoonData {
|
|
|
36
37
|
* */
|
|
37
38
|
get isSent(): boolean;
|
|
38
39
|
set isSent(value: boolean);
|
|
40
|
+
/**
|
|
41
|
+
* @property isMappingIdentifier - signifying if the data is a mapping identifier
|
|
42
|
+
* @private
|
|
43
|
+
* */
|
|
44
|
+
set _isMappingIdentifier(value: boolean);
|
|
39
45
|
/**
|
|
40
46
|
* @private
|
|
41
47
|
* @method _listFromVisits - an internal method for creating a list of custom data from a list of visits
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_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 _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 _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}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 _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 CustomData=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"index",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"sent",void 0),this.index=b;for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];this.value=d,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){if("number"!=typeof this.index)return"";var a=_toConsumableArray(new Set(this.value)),b={};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_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 _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 _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}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 _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 CustomData=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"index",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"isIdentifier",void 0),this.index=b;for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];this.value=d,this.sent=!1,this.isIdentifier=!1}return _createClass(a,[{key:"url",get:function get(){if("number"!=typeof this.index)return"";var a=_toConsumableArray(new Set(this.value)),b={};if(a.forEach(function(a){b[a]=1}),!Object.keys(b).length)return"";var c="";return this.isIdentifier&&(c=_requester.UrlParameter.MappingIdentifier+"true"),_requester.UrlEventType.CustomData+_requester.UrlParameter.Index+this.index+_requester.UrlParameter.ValuesCountMap+encodeURIComponent(JSON.stringify(b))+_requester.UrlParameter.Overwrite+"true"+c}},{key:"data",get:function get(){return{index:this.index,value:this.value,type:_types.KameleoonData.CustomData,isIdentifier:this.isIdentifier,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}},{key:"_isMappingIdentifier",set:function set(a){this.isIdentifier=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.customDataEvents){var g,h=c.customDataEvents,j=_createForOfIteratorHelper(h);try{for(j.s();!(g=j.n()).done;){var k=g.value,l=k.data,m=l.index,n=l.valuesCountMap;e.set(m,Object.keys(n))}}catch(a){j.e(a)}finally{j.f()}}var o,p=_createForOfIteratorHelper(e);try{for(p.s();!(o=p.n()).done;){var q=_slicedToArray(o.value,2),r=q[0],s=q[1];d.push(_construct(a,[r].concat(_toConsumableArray(s))))}}catch(a){p.e(a)}finally{p.f()}return d}}]),a}();exports.CustomData=CustomData;
|
|
2
2
|
//# sourceMappingURL=customData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customData.js","names":["CustomData","a","index","_classCallCheck","_defineProperty","c","arguments","length","value","Array","e","sent","_createClass","key","get","uniqueValues","_toConsumableArray","Set","resultValue","forEach","Object","keys","
|
|
1
|
+
{"version":3,"file":"customData.js","names":["CustomData","a","index","_classCallCheck","_defineProperty","c","arguments","length","value","Array","e","sent","isIdentifier","_createClass","key","get","uniqueValues","_toConsumableArray","Set","resultValue","forEach","Object","keys","identifierParameter","UrlParameter","MappingIdentifier","UrlEventType","Index","ValuesCountMap","encodeURIComponent","JSON","stringify","Overwrite","type","KameleoonData","set","_listFromVisits","visits","visit","resultData","customDataMap","Map","i","customDataEvents","g","j","_createForOfIteratorHelper","s","n","done","customDataEvent","l","data","valuesCountMap","f","o","p","q","_slicedToArray","push","_construct","concat","exports"],"sources":["../../src/kameleoonData/customData.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { CustomDataType, IKameleoonData, KameleoonData } from './types';\n\n/**\n * @class\n * CustomData - a class for creating an instance for user's custom data\n * */\nexport class CustomData implements IKameleoonData {\n private index: number;\n private value: string[];\n private sent: boolean;\n private isIdentifier: boolean;\n\n /**\n * @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application\n * @param {string[]} value - custom value to store under the specified id, value can be anything but has to be stringified to match the `string` type. *Note* value is variadic parameter and can be used as follows\n * @example\n * ```ts\n * // - Single value\n * const customData = new CustomData(0, 'value_1');\n * // - Variadic number of values\n * const customData = new CustomData(0, 'value_1', 'value_2', 'value_3');\n * // - Array of values\n * const values = ['value_1', 'value_2', 'value_3'];\n * const customData = new CustomData(0, ...values);\n * ```\n * */\n constructor(index: number, ...value: string[]) {\n this.index = index;\n this.value = value;\n this.sent = false;\n this.isIdentifier = 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 (typeof this.index !== 'number') {\n return '';\n }\n\n const uniqueValues = [...new Set(this.value)];\n let resultValue: Record<string, 1> = {};\n\n // --- Note ---\n // Final value should look like this `{ \"value_1\": 1, \"value_2\": 1, \"value_3\": 1}`\n // With no duplicates\n uniqueValues.forEach((value) => {\n resultValue[value] = 1;\n });\n\n if (!Object.keys(resultValue).length) {\n return '';\n }\n\n let identifierParameter = '';\n\n if (this.isIdentifier) {\n identifierParameter = UrlParameter.MappingIdentifier + String(true);\n }\n\n return (\n UrlEventType.CustomData +\n UrlParameter.Index +\n this.index +\n UrlParameter.ValuesCountMap +\n encodeURIComponent(JSON.stringify(resultValue)) +\n UrlParameter.Overwrite +\n String(true) +\n identifierParameter\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): CustomDataType {\n return {\n index: this.index,\n value: this.value,\n type: KameleoonData.CustomData,\n isIdentifier: this.isIdentifier,\n sent: this.sent,\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 isMappingIdentifier - signifying if the data is a mapping identifier\n * @private\n * */\n set _isMappingIdentifier(value: boolean) {\n this.isIdentifier = value;\n }\n\n /**\n * @private\n * @method _listFromVisits - an internal method for creating a list of custom data from a list of visits\n * @param {VisitType[]} visits - a list of visits\n * @returns {CustomData[]} a list of custom data\n * */\n public static _listFromVisits(visits: VisitType[]): CustomData[] {\n const resultData: CustomData[] = [];\n const customDataMap = new Map<number, string[]>();\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.customDataEvents) {\n continue;\n }\n\n const customDataEvents = visit.customDataEvents;\n\n for (const customDataEvent of customDataEvents) {\n const { index, valuesCountMap } = customDataEvent.data;\n\n customDataMap.set(index, Object.keys(valuesCountMap));\n }\n }\n\n for (const [index, data] of customDataMap) {\n resultData.push(new CustomData(index, ...data));\n }\n\n return resultData;\n }\n}\n"],"mappings":"kgJAOa,CAAAA,UAAU,YAoBrB,SAAAC,EAAYC,CAAa,CAAsB,CAAAC,eAAA,MAAAF,CAAA,EAAAG,eAAA,sBAAAA,eAAA,sBAAAA,eAAA,qBAAAA,eAAA,6BAC7C,IAAI,CAACF,KAAK,CAAGA,CAAK,SAAAG,CAAA,CAAAC,SAAA,CAAAC,MAAA,CADUC,CAAK,CAAAC,KAAA,GAAAJ,CAAA,CAAAA,CAAA,MAAAK,CAAA,GAAAA,CAAA,CAAAL,CAAA,CAAAK,CAAA,GAALF,CAAK,CAAAE,CAAA,IAAAJ,SAAA,CAAAI,CAAA,EAEjC,IAAI,CAACF,KAAK,CAAGA,CAAK,CAClB,IAAI,CAACG,IAAI,GAAQ,CACjB,IAAI,CAACC,YAAY,GACnB,CAAC,OAAAC,YAAA,CAAAZ,CAAA,GAAAa,GAAA,OAAAC,GAAA,CAKD,SAAAA,IAAA,CAAkB,CAIhB,GAA0B,QAAQ,EAA9B,MAAO,KAAI,CAACb,KAAkB,CAChC,MAAO,EAAE,CACV,GAEK,CAAAc,CAAY,CAAAC,kBAAA,CAAO,GAAI,CAAAC,GAAG,CAAC,IAAI,CAACV,KAAK,CAAC,CAAC,CACzCW,CAA8B,CAAG,CAAC,CAAC,CASvC,GAJAH,CAAY,CAACI,OAAO,CAAC,SAACZ,CAAK,CAAK,CAC9BW,CAAW,CAACX,CAAK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
|
|
@@ -19,6 +19,7 @@ export declare class DataManager implements IDataManager {
|
|
|
19
19
|
private targetingTrees;
|
|
20
20
|
private localCustomDataIndexes;
|
|
21
21
|
private persistentCustomDataIndexes;
|
|
22
|
+
private mappingIdentifierCustomDataIndexes;
|
|
22
23
|
private targetingDataIntervalId;
|
|
23
24
|
private dataProcessor;
|
|
24
25
|
private unsentData;
|
|
@@ -31,6 +32,7 @@ export declare class DataManager implements IDataManager {
|
|
|
31
32
|
clearUnsentData(visitorCode: string): void;
|
|
32
33
|
clearUnsentDataByKey(visitorCode: string, key: KameleoonData): void;
|
|
33
34
|
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
35
|
+
getVisitorIdentifier(visitorCode: string): string;
|
|
34
36
|
get trees(): Map<string, Tree>;
|
|
35
37
|
get unsentDataVisitors(): string[];
|
|
36
38
|
get storedTargetingData(): TargetingDataType;
|
|
@@ -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 _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,"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(
|
|
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","p","q","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","Object","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 // --- 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 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":"09GAoCa,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,WA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D,KAAK,CAErD,CAAC,CAAC,CAEEsD,CAA0B,CAACpE,MAAM,GACnC,IAAI,CAACY,sBAAsB,CAAG,GAAI,CAAAjC,GAAG,CAACyF,CAA0B,CAAC,EAG/DlB,CAA2B,CAAClD,MAAM,GACpC,IAAI,CAACkD,2BAA2B,CAAG,GAAI,CAAAvE,GAAG,CAACuE,CAA2B,CAAC,CAE3E,CAAC,IAAA/E,CAAA,IAAAuG,OAAA,CAAAxG,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,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,CAACL,uBAAuB,CAAC,CAGvCI,CACR,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OAAA,CAAA9G,WAAA,CAAAA,WAAA"}
|
|
@@ -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,GAAA,OAAnBL,CAAmB,CAAAM,GAAA,OAAn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ACI,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,CAAAE,MAAA,UAAVF,CAAU,CAAAG,OA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EK,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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlFirstParameter=exports.UrlEventType=exports.URL=exports.Header=void 0,exports.getClientConfigurationUrl=getClientConfigurationUrl;var Header=function(a){return a.UserAgent="User-Agent",a.ContentType="Content-Type",a.Authorization="Authorization",a.AcceptEncoding="Accept-Encoding",a}({});exports.Header=Header;var UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment",Geolocation:"eventType=geolocation"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"¤tVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits=",Os:"&os=",OsIndex:"&osIndex=",Country:"&country=",City:"&city=",Region:"®ion=",Latitude:"&latitude=",Longitude:"&longitude=",PostalCode:"&postalCode=",Conversion:"&conversion=",StaticData:"&staticData=",Geolocation:"&geolocation=",Page:"&page=",Experiment:"&experiment=",Browser:"&browser=",Environment:"&environment="};exports.UrlParameter=UrlParameter;var UrlFirstParameter={CustomData:"?customData=",StaticData:"?staticData=",Page:"?page=",Conversion:"?conversion=",Geolocation:"?geolocation=",Experiment:"?experiment=",ValuesCountMap:"?valuesCountMap=",Id:"?id=",Nonce:"?nonce=",Country:"?country=",Environment:"?environment=",City:"?city=",Region:"?region=",Latitude:"?latitude=",Longitude:"?longitude=",PostalCode:"?postalCode=",SdkName:"?sdkName=",SdkVersion:"?sdkVersion=",BrowserIndex:"?browserIndex=",BrowserVersion:"?browserVersion=",SiteCode:"?siteCode=",VisitorCode:"?visitorCode=",CurrentVisit:"?currentVisit=",MaxNumberPreviousVisits:"?maxNumberPreviousVisits=",Negative:"?negative=",Revenue:"?revenue=",Title:"?title=",Os:"?os=",OsIndex:"?osIndex=",Browser:"?browser=",ReferrersIndices:"?referrersIndices=",Overwrite:"?overwrite=",Index:"?index=",Href:"?href=",VariationId:"?variationId=",DeviceType:"?deviceType=",GoalId:"?goalId=",Ts:"?ts=",Key:"?key="};exports.UrlFirstParameter=UrlFirstParameter;var UrlQuery={Sse:"sse?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var topLevelDomain="io",URL_DATA_API="https://data.kameleoon.".concat("io"),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.com:8110/",VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;function getClientConfigurationUrl(a){return"https://".concat(a,".kameleoon.eu/sdk-config")}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlFirstParameter=exports.UrlEventType=exports.URL=exports.Header=void 0,exports.getClientConfigurationUrl=getClientConfigurationUrl;var Header=function(a){return a.UserAgent="User-Agent",a.ContentType="Content-Type",a.Authorization="Authorization",a.AcceptEncoding="Accept-Encoding",a}({});exports.Header=Header;var UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment",Geolocation:"eventType=geolocation"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"¤tVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits=",Os:"&os=",OsIndex:"&osIndex=",Country:"&country=",City:"&city=",Region:"®ion=",Latitude:"&latitude=",Longitude:"&longitude=",PostalCode:"&postalCode=",Conversion:"&conversion=",StaticData:"&staticData=",Geolocation:"&geolocation=",Page:"&page=",Experiment:"&experiment=",Browser:"&browser=",Environment:"&environment=",MappingIdentifier:"&mappingIdentifier="};exports.UrlParameter=UrlParameter;var UrlFirstParameter={CustomData:"?customData=",StaticData:"?staticData=",Page:"?page=",Conversion:"?conversion=",Geolocation:"?geolocation=",Experiment:"?experiment=",ValuesCountMap:"?valuesCountMap=",Id:"?id=",Nonce:"?nonce=",Country:"?country=",Environment:"?environment=",City:"?city=",Region:"?region=",Latitude:"?latitude=",Longitude:"?longitude=",PostalCode:"?postalCode=",SdkName:"?sdkName=",SdkVersion:"?sdkVersion=",BrowserIndex:"?browserIndex=",BrowserVersion:"?browserVersion=",SiteCode:"?siteCode=",VisitorCode:"?visitorCode=",CurrentVisit:"?currentVisit=",MaxNumberPreviousVisits:"?maxNumberPreviousVisits=",Negative:"?negative=",Revenue:"?revenue=",Title:"?title=",Os:"?os=",OsIndex:"?osIndex=",Browser:"?browser=",ReferrersIndices:"?referrersIndices=",Overwrite:"?overwrite=",Index:"?index=",Href:"?href=",VariationId:"?variationId=",DeviceType:"?deviceType=",GoalId:"?goalId=",Ts:"?ts=",Key:"?key=",MappingIdentifier:"?mappingIdentifier="};exports.UrlFirstParameter=UrlFirstParameter;var UrlQuery={Sse:"sse?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var topLevelDomain="io",URL_DATA_API="https://data.kameleoon.".concat("io"),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.com:8110/",VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;function getClientConfigurationUrl(a){return"https://".concat(a,".kameleoon.eu/sdk-config")}
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["Header","UserAgent","ContentType","Authorization","AcceptEncoding","exports","UrlEventType","CustomData","StaticData","Page","Conversion","Activity","Experiment","Geolocation","UrlParameter","Title","ReferrersIndices","Negative","Revenue","Overwrite","Index","BrowserIndex","BrowserVersion","Href","DeviceType","SiteCode","GoalId","VisitorCode","VariationId","Ts","Key","SdkName","SdkVersion","ValuesCountMap","Nonce","Id","CurrentVisit","MaxNumberPreviousVisits","Os","OsIndex","Country","City","Region","Latitude","Longitude","PostalCode","Browser","Environment","UrlFirstParameter","UrlQuery","Sse","Map","Events","Visitor","UrlTracking","Visit","topLevelDomain","URL_DATA_API","concat","URL","SERVER_SENT_EVENTS","VISIT_EVENT","VISIT_DATA","DATA_MAP","getClientConfigurationUrl","siteCode"],"sources":["../../src/requester/constants.ts"],"sourcesContent":["import {\n EventType,\n ParameterType,\n QueryType,\n StrictEventTypeRecord,\n StrictFirstParameterRecord,\n StrictParameterRecord,\n StrictQueryRecord,\n StrictTrackingRecord,\n TrackingType,\n} from './types';\n\nexport enum Header {\n UserAgent = 'User-Agent',\n ContentType = 'Content-Type',\n Authorization = 'Authorization',\n AcceptEncoding = 'Accept-Encoding',\n}\n\nexport const UrlEventType: StrictEventTypeRecord<EventType> = {\n CustomData: 'eventType=customData',\n StaticData: 'eventType=staticData',\n Page: 'eventType=page',\n Conversion: 'eventType=conversion',\n Activity: 'eventType=activity',\n Experiment: 'eventType=experiment',\n Geolocation: 'eventType=geolocation',\n};\nexport const UrlParameter: StrictParameterRecord<ParameterType> = {\n Title: '&title=',\n ReferrersIndices: '&referrersIndices=',\n Negative: '&negative=',\n Revenue: '&revenue=',\n Overwrite: '&overwrite=',\n Index: '&index=',\n BrowserIndex: '&browserIndex=',\n BrowserVersion: '&browserVersion=',\n Href: '&href=',\n DeviceType: '&deviceType=',\n SiteCode: '&siteCode=',\n GoalId: '&goalId=',\n VisitorCode: '&visitorCode=',\n VariationId: '&variationId=',\n Ts: '&ts=',\n Key: '&key=',\n SdkName: '&sdkName=',\n SdkVersion: '&sdkVersion=',\n ValuesCountMap: '&valuesCountMap=',\n Nonce: '&nonce=',\n Id: '&id=',\n CustomData: '&customData=',\n CurrentVisit: '¤tVisit=',\n MaxNumberPreviousVisits: '&maxNumberPreviousVisits=',\n Os: '&os=',\n OsIndex: '&osIndex=',\n Country: '&country=',\n City: '&city=',\n Region: '®ion=',\n Latitude: '&latitude=',\n Longitude: '&longitude=',\n PostalCode: '&postalCode=',\n Conversion: '&conversion=',\n StaticData: '&staticData=',\n Geolocation: '&geolocation=',\n Page: '&page=',\n Experiment: '&experiment=',\n Browser: '&browser=',\n Environment: '&environment=',\n};\nexport const UrlFirstParameter: StrictFirstParameterRecord<ParameterType> = {\n CustomData: '?customData=',\n StaticData: '?staticData=',\n Page: '?page=',\n Conversion: '?conversion=',\n Geolocation: '?geolocation=',\n Experiment: '?experiment=',\n ValuesCountMap: '?valuesCountMap=',\n Id: '?id=',\n Nonce: '?nonce=',\n Country: '?country=',\n Environment: '?environment=',\n City: '?city=',\n Region: '?region=',\n Latitude: '?latitude=',\n Longitude: '?longitude=',\n PostalCode: '?postalCode=',\n SdkName: '?sdkName=',\n SdkVersion: '?sdkVersion=',\n BrowserIndex: '?browserIndex=',\n BrowserVersion: '?browserVersion=',\n SiteCode: '?siteCode=',\n VisitorCode: '?visitorCode=',\n CurrentVisit: '?currentVisit=',\n MaxNumberPreviousVisits: '?maxNumberPreviousVisits=',\n Negative: '?negative=',\n Revenue: '?revenue=',\n Title: '?title=',\n Os: '?os=',\n OsIndex: '?osIndex=',\n Browser: '?browser=',\n ReferrersIndices: '?referrersIndices=',\n Overwrite: '?overwrite=',\n Index: '?index=',\n Href: '?href=',\n VariationId: '?variationId=',\n DeviceType: '?deviceType=',\n GoalId: '?goalId=',\n Ts: '?ts=',\n Key: '?key=',\n};\nexport const UrlQuery: StrictQueryRecord<QueryType> = {\n Sse: 'sse?siteCode=',\n Map: 'map?siteCode=',\n Events: 'events?siteCode=',\n Visitor: 'visitor?siteCode=',\n};\nexport const UrlTracking: StrictTrackingRecord<TrackingType> = {\n Visit: 'visit/',\n Map: 'map/',\n};\n\nconst topLevelDomain = process.env.NODE_ENV === 'test' ? 'net' : 'io';\n\nconst URL_DATA_API = `https://data.kameleoon.${topLevelDomain}`;\n\nexport const URL = {\n SERVER_SENT_EVENTS: 'https://events.kameleoon.com:8110/',\n VISIT_EVENT: `${URL_DATA_API}/${UrlTracking.Visit + UrlQuery.Events}`,\n VISIT_DATA: `${URL_DATA_API}/${UrlTracking.Visit + UrlQuery.Visitor}`,\n DATA_MAP: `${URL_DATA_API}/${UrlTracking.Map + UrlQuery.Map}`,\n};\n\nexport function getClientConfigurationUrl(siteCode: string): string {\n return `https://${siteCode}.kameleoon.eu/sdk-config`;\n}\n"],"mappings":"8QAYY,CAAAA,MAAM,UAANA,CAAM,QAAN,CAAAA,CAAM,CAAAC,SAAA,cAAND,CAAM,CAAAE,WAAA,gBAANF,CAAM,CAAAG,aAAA,iBAANH,CAAM,CAAAI,cAAA,mBAANJ,CAAM,MAAAK,OAAA,CAAAL,MAAA,CAAAA,MAAA,CAOX,GAAM,CAAAM,YAA8C,CAAG,CAC5DC,UAAU,CAAE,sBAAsB,CAClCC,UAAU,CAAE,sBAAsB,CAClCC,IAAI,CAAE,gBAAgB,CACtBC,UAAU,CAAE,sBAAsB,CAClCC,QAAQ,CAAE,oBAAoB,CAC9BC,UAAU,CAAE,sBAAsB,CAClCC,WAAW,CAAE,uBACf,CAAC,CAACR,OAAA,CAAAC,YAAA,CAAAA,YAAA,CACK,GAAM,CAAAQ,YAAkD,CAAG,CAChEC,KAAK,CAAE,SAAS,CAChBC,gBAAgB,CAAE,oBAAoB,CACtCC,QAAQ,CAAE,YAAY,CACtBC,OAAO,CAAE,WAAW,CACpBC,SAAS,CAAE,aAAa,CACxBC,KAAK,CAAE,SAAS,CAChBC,YAAY,CAAE,gBAAgB,CAC9BC,cAAc,CAAE,kBAAkB,CAClCC,IAAI,CAAE,QAAQ,CACdC,UAAU,CAAE,cAAc,CAC1BC,QAAQ,CAAE,YAAY,CACtBC,MAAM,CAAE,UAAU,CAClBC,WAAW,CAAE,eAAe,CAC5BC,WAAW,CAAE,eAAe,CAC5BC,EAAE,CAAE,MAAM,CACVC,GAAG,CAAE,OAAO,CACZC,OAAO,CAAE,WAAW,CACpBC,UAAU,CAAE,cAAc,CAC1BC,cAAc,CAAE,kBAAkB,CAClCC,KAAK,CAAE,SAAS,CAChBC,EAAE,CAAE,MAAM,CACV5B,UAAU,CAAE,cAAc,CAC1B6B,YAAY,CAAE,gBAAgB,CAC9BC,uBAAuB,CAAE,2BAA2B,CACpDC,EAAE,CAAE,MAAM,CACVC,OAAO,CAAE,WAAW,CACpBC,OAAO,CAAE,WAAW,CACpBC,IAAI,CAAE,QAAQ,CACdC,MAAM,CAAE,UAAU,CAClBC,QAAQ,CAAE,YAAY,CACtBC,SAAS,CAAE,aAAa,CACxBC,UAAU,CAAE,cAAc,CAC1BnC,UAAU,CAAE,cAAc,CAC1BF,UAAU,CAAE,cAAc,CAC1BK,WAAW,CAAE,eAAe,CAC5BJ,IAAI,CAAE,QAAQ,CACdG,UAAU,CAAE,cAAc,CAC1BkC,OAAO,CAAE,WAAW,CACpBC,WAAW,CAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["Header","UserAgent","ContentType","Authorization","AcceptEncoding","exports","UrlEventType","CustomData","StaticData","Page","Conversion","Activity","Experiment","Geolocation","UrlParameter","Title","ReferrersIndices","Negative","Revenue","Overwrite","Index","BrowserIndex","BrowserVersion","Href","DeviceType","SiteCode","GoalId","VisitorCode","VariationId","Ts","Key","SdkName","SdkVersion","ValuesCountMap","Nonce","Id","CurrentVisit","MaxNumberPreviousVisits","Os","OsIndex","Country","City","Region","Latitude","Longitude","PostalCode","Browser","Environment","MappingIdentifier","UrlFirstParameter","UrlQuery","Sse","Map","Events","Visitor","UrlTracking","Visit","topLevelDomain","URL_DATA_API","concat","URL","SERVER_SENT_EVENTS","VISIT_EVENT","VISIT_DATA","DATA_MAP","getClientConfigurationUrl","siteCode"],"sources":["../../src/requester/constants.ts"],"sourcesContent":["import {\n EventType,\n ParameterType,\n QueryType,\n StrictEventTypeRecord,\n StrictFirstParameterRecord,\n StrictParameterRecord,\n StrictQueryRecord,\n StrictTrackingRecord,\n TrackingType,\n} from './types';\n\nexport enum Header {\n UserAgent = 'User-Agent',\n ContentType = 'Content-Type',\n Authorization = 'Authorization',\n AcceptEncoding = 'Accept-Encoding',\n}\n\nexport const UrlEventType: StrictEventTypeRecord<EventType> = {\n CustomData: 'eventType=customData',\n StaticData: 'eventType=staticData',\n Page: 'eventType=page',\n Conversion: 'eventType=conversion',\n Activity: 'eventType=activity',\n Experiment: 'eventType=experiment',\n Geolocation: 'eventType=geolocation',\n};\nexport const UrlParameter: StrictParameterRecord<ParameterType> = {\n Title: '&title=',\n ReferrersIndices: '&referrersIndices=',\n Negative: '&negative=',\n Revenue: '&revenue=',\n Overwrite: '&overwrite=',\n Index: '&index=',\n BrowserIndex: '&browserIndex=',\n BrowserVersion: '&browserVersion=',\n Href: '&href=',\n DeviceType: '&deviceType=',\n SiteCode: '&siteCode=',\n GoalId: '&goalId=',\n VisitorCode: '&visitorCode=',\n VariationId: '&variationId=',\n Ts: '&ts=',\n Key: '&key=',\n SdkName: '&sdkName=',\n SdkVersion: '&sdkVersion=',\n ValuesCountMap: '&valuesCountMap=',\n Nonce: '&nonce=',\n Id: '&id=',\n CustomData: '&customData=',\n CurrentVisit: '¤tVisit=',\n MaxNumberPreviousVisits: '&maxNumberPreviousVisits=',\n Os: '&os=',\n OsIndex: '&osIndex=',\n Country: '&country=',\n City: '&city=',\n Region: '®ion=',\n Latitude: '&latitude=',\n Longitude: '&longitude=',\n PostalCode: '&postalCode=',\n Conversion: '&conversion=',\n StaticData: '&staticData=',\n Geolocation: '&geolocation=',\n Page: '&page=',\n Experiment: '&experiment=',\n Browser: '&browser=',\n Environment: '&environment=',\n MappingIdentifier: '&mappingIdentifier=',\n};\nexport const UrlFirstParameter: StrictFirstParameterRecord<ParameterType> = {\n CustomData: '?customData=',\n StaticData: '?staticData=',\n Page: '?page=',\n Conversion: '?conversion=',\n Geolocation: '?geolocation=',\n Experiment: '?experiment=',\n ValuesCountMap: '?valuesCountMap=',\n Id: '?id=',\n Nonce: '?nonce=',\n Country: '?country=',\n Environment: '?environment=',\n City: '?city=',\n Region: '?region=',\n Latitude: '?latitude=',\n Longitude: '?longitude=',\n PostalCode: '?postalCode=',\n SdkName: '?sdkName=',\n SdkVersion: '?sdkVersion=',\n BrowserIndex: '?browserIndex=',\n BrowserVersion: '?browserVersion=',\n SiteCode: '?siteCode=',\n VisitorCode: '?visitorCode=',\n CurrentVisit: '?currentVisit=',\n MaxNumberPreviousVisits: '?maxNumberPreviousVisits=',\n Negative: '?negative=',\n Revenue: '?revenue=',\n Title: '?title=',\n Os: '?os=',\n OsIndex: '?osIndex=',\n Browser: '?browser=',\n ReferrersIndices: '?referrersIndices=',\n Overwrite: '?overwrite=',\n Index: '?index=',\n Href: '?href=',\n VariationId: '?variationId=',\n DeviceType: '?deviceType=',\n GoalId: '?goalId=',\n Ts: '?ts=',\n Key: '?key=',\n MappingIdentifier: '?mappingIdentifier=',\n};\nexport const UrlQuery: StrictQueryRecord<QueryType> = {\n Sse: 'sse?siteCode=',\n Map: 'map?siteCode=',\n Events: 'events?siteCode=',\n Visitor: 'visitor?siteCode=',\n};\nexport const UrlTracking: StrictTrackingRecord<TrackingType> = {\n Visit: 'visit/',\n Map: 'map/',\n};\n\nconst topLevelDomain = process.env.NODE_ENV === 'test' ? 'net' : 'io';\n\nconst URL_DATA_API = `https://data.kameleoon.${topLevelDomain}`;\n\nexport const URL = {\n SERVER_SENT_EVENTS: 'https://events.kameleoon.com:8110/',\n VISIT_EVENT: `${URL_DATA_API}/${UrlTracking.Visit + UrlQuery.Events}`,\n VISIT_DATA: `${URL_DATA_API}/${UrlTracking.Visit + UrlQuery.Visitor}`,\n DATA_MAP: `${URL_DATA_API}/${UrlTracking.Map + UrlQuery.Map}`,\n};\n\nexport function getClientConfigurationUrl(siteCode: string): string {\n return `https://${siteCode}.kameleoon.eu/sdk-config`;\n}\n"],"mappings":"8QAYY,CAAAA,MAAM,UAANA,CAAM,QAAN,CAAAA,CAAM,CAAAC,SAAA,cAAND,CAAM,CAAAE,WAAA,gBAANF,CAAM,CAAAG,aAAA,iBAANH,CAAM,CAAAI,cAAA,mBAANJ,CAAM,MAAAK,OAAA,CAAAL,MAAA,CAAAA,MAAA,CAOX,GAAM,CAAAM,YAA8C,CAAG,CAC5DC,UAAU,CAAE,sBAAsB,CAClCC,UAAU,CAAE,sBAAsB,CAClCC,IAAI,CAAE,gBAAgB,CACtBC,UAAU,CAAE,sBAAsB,CAClCC,QAAQ,CAAE,oBAAoB,CAC9BC,UAAU,CAAE,sBAAsB,CAClCC,WAAW,CAAE,uBACf,CAAC,CAACR,OAAA,CAAAC,YAAA,CAAAA,YAAA,CACK,GAAM,CAAAQ,YAAkD,CAAG,CAChEC,KAAK,CAAE,SAAS,CAChBC,gBAAgB,CAAE,oBAAoB,CACtCC,QAAQ,CAAE,YAAY,CACtBC,OAAO,CAAE,WAAW,CACpBC,SAAS,CAAE,aAAa,CACxBC,KAAK,CAAE,SAAS,CAChBC,YAAY,CAAE,gBAAgB,CAC9BC,cAAc,CAAE,kBAAkB,CAClCC,IAAI,CAAE,QAAQ,CACdC,UAAU,CAAE,cAAc,CAC1BC,QAAQ,CAAE,YAAY,CACtBC,MAAM,CAAE,UAAU,CAClBC,WAAW,CAAE,eAAe,CAC5BC,WAAW,CAAE,eAAe,CAC5BC,EAAE,CAAE,MAAM,CACVC,GAAG,CAAE,OAAO,CACZC,OAAO,CAAE,WAAW,CACpBC,UAAU,CAAE,cAAc,CAC1BC,cAAc,CAAE,kBAAkB,CAClCC,KAAK,CAAE,SAAS,CAChBC,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,CAACE,GAAG,CAC7D,CAAC,CAAA/C,OAAA,CAAAuD,GAAA,CAAAA,GAAA,CAEM,QAAS,CAAAK,yBAAyBA,CAACC,CAAgB,CAAU,CAClE,iBAAAP,MAAA,CAAkBO,CAAQ,4BAC5B"}
|
|
@@ -117,7 +117,7 @@ export declare enum HttpMethod {
|
|
|
117
117
|
Post = "POST"
|
|
118
118
|
}
|
|
119
119
|
declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "geolocation", "activity", "experiment"];
|
|
120
|
-
declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "country", "environment", "city", "region", "latitude", "geolocation", "longitude", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
|
|
120
|
+
declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "country", "environment", "city", "region", "latitude", "geolocation", "longitude", "mappingIdentifier", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
|
|
121
121
|
declare const TRACKING_KEYS: readonly ["visit", "map"];
|
|
122
122
|
declare const QUERY_KEYS: readonly ["sse", "visitor", "map", "events"];
|
|
123
123
|
export type TrackingType = Record<Capitalize<(typeof TRACKING_KEYS)[number]>, string>;
|
package/dist/requester/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","country","environment","city","region","latitude","geolocation","longitude","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","map","events"];
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","country","environment","city","region","latitude","geolocation","longitude","mappingIdentifier","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","map","events"];
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport { Header } from './constants';\nimport { DeviceType, OperatingSystemIndexMap } from 'src/kameleoonData/types';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n body: string;\n variationId: number;\n visitorCode: string;\n experimentId: number;\n isUnallocated: boolean;\n isConsentProvided: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\nexport type TrackParametersType = {\n url: string;\n headers?: Partial<Record<Header, string>>;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * */\n getClientConfiguration: (url: string) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGAqIY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport { Header } from './constants';\nimport { DeviceType, OperatingSystemIndexMap } from 'src/kameleoonData/types';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n body: string;\n variationId: number;\n visitorCode: string;\n experimentId: number;\n isUnallocated: boolean;\n isConsentProvided: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'mappingIdentifier',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\nexport type TrackParametersType = {\n url: string;\n headers?: Partial<Record<Header, string>>;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * */\n getClientConfiguration: (url: string) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGAqIY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,mBAAmB,CACnB,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/variationConfiguration/types.ts"],"sourcesContent":["import {\n ClientConfiguration,\n FeatureFlagType,\n RuleItemType,\n} from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { ExternalPackageInfoType } from 'src/types';\n\nexport type FeatureFlagVariationType = {\n variationKey: string;\n variationId: number | null;\n experimentId: number | null;\n featureFlagId: number;\n featureKey: string;\n rule: RuleItemType | null;\n isTargetedRule?: boolean;\n};\n\nexport type GetVariationParametersType = {\n visitorCode: string;\n featureFlag: FeatureFlagType;\n targetingData: KameleoonVisitorDataType;\n withAssignment?: boolean;\n packageInfo: ExternalPackageInfoType;\n clientConfiguration: ClientConfiguration;\n dataManager: DataManager;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/variationConfiguration/types.ts"],"sourcesContent":["import {\n ClientConfiguration,\n FeatureFlagType,\n RuleItemType,\n} from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { ExternalPackageInfoType } from 'src/types';\n\nexport type FeatureFlagVariationType = {\n variationKey: string;\n variationId: number | null;\n experimentId: number | null;\n featureFlagId: number;\n featureKey: string;\n rule: RuleItemType | null;\n isTargetedRule?: boolean;\n};\n\nexport type GetVariationParametersType = {\n visitorCode: string;\n visitorIdentifier: string;\n featureFlag: FeatureFlagType;\n targetingData: KameleoonVisitorDataType;\n withAssignment?: boolean;\n packageInfo: ExternalPackageInfoType;\n clientConfiguration: ClientConfiguration;\n dataManager: DataManager;\n};\n"],"mappings":""}
|
|
@@ -21,7 +21,7 @@ export declare class VariationConfiguration implements IVariationConfiguration {
|
|
|
21
21
|
private storage;
|
|
22
22
|
constructor(externalStorage: IExternalStorage<VariationDataType>);
|
|
23
23
|
getStoredVariations(visitorCode: string): Result<FeatureFlagVariationsType, KameleoonError>;
|
|
24
|
-
getVariation({ visitorCode, featureFlag, targetingData, packageInfo, clientConfiguration, dataManager, withAssignment, }: GetVariationParametersType): Result<FeatureFlagVariationType, KameleoonError>;
|
|
24
|
+
getVariation({ visitorCode, visitorIdentifier, featureFlag, targetingData, packageInfo, clientConfiguration, dataManager, withAssignment, }: GetVariationParametersType): Result<FeatureFlagVariationType, KameleoonError>;
|
|
25
25
|
updateStoredVariations(visitorCode: string, variationData: FeatureFlagVariationsType): Result<void, KameleoonError>;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariationConfiguration=void 0;var _tsRes=require("ts-res"),_hasher=require("../hasher"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_types=require("../clientConfiguration/types"),_excluded=["exposition"];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 ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}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 VariationConfiguration=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"storage",void 0),this.storage=b}return _createClass(a,[{key:"getStoredVariations",value:function getStoredVariations(a){var b=this.storage.read();if(!b.ok)return b;var c=b.data[a];return c?(0,_tsRes.Ok)(c):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.StorageRead,a))}},{key:"getVariation",value:function getVariation(a){var b=a.visitorCode,c=a.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariationConfiguration=void 0;var _tsRes=require("ts-res"),_hasher=require("../hasher"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_types=require("../clientConfiguration/types"),_excluded=["exposition"];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 ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}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 VariationConfiguration=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"storage",void 0),this.storage=b}return _createClass(a,[{key:"getStoredVariations",value:function getStoredVariations(a){var b=this.storage.read();if(!b.ok)return b;var c=b.data[a];return c?(0,_tsRes.Ok)(c):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.StorageRead,a))}},{key:"getVariation",value:function getVariation(a){var b=a.visitorCode,c=a.visitorIdentifier,d=a.featureFlag,e=a.targetingData,f=a.packageInfo,g=a.clientConfiguration,h=a.dataManager,i=a.withAssignment,j=_utilities.Utilities.validateVisitorCode(b);if(!j.ok)return(0,_tsRes.Err)(j.error);var k,l=d.rules,m=d.featureKey,n=d.id,o=d.defaultVariationKey,p=_createForOfIteratorHelper(l);try{for(p.s();!(k=p.n()).done;){var q=k.value,r=q.segment,s=q.experimentId,t=q.id,u=q.exposition,v=q.respoolTime,w=q.variationByExposition,x=_utilities.Utilities.checkTargeting({segment:r,visitorCode:b,experimentId:s,targetingData:e,packageInfo:f,clientConfiguration:g,dataManager:h,variationConfiguration:this});if(!x.ok)return x;if(x.data){var y=_hasher.Hasher.getHashDouble({visitorIdentifier:c,respoolTime:v,id:t+""});if(y<=u){var z,A=0,B=_hasher.Hasher.getHashDouble({visitorIdentifier:c,respoolTime:v,id:s+""}),C=_createForOfIteratorHelper(w);try{for(C.s();!(z=C.n()).done;){var D=z.value;if(A+=D.exposition,B<=A){void 0!==i&&i&&this.updateStoredVariations(b,_defineProperty({},s,D.variationId));var E=D.exposition,F=_objectWithoutProperties(D,_excluded);return(0,_tsRes.Ok)(_objectSpread(_objectSpread({},F),{},{rule:q,featureFlagId:n,featureKey:m,experimentId:s,isTargetedRule:q.type===_types.RuleType.TARGETED_DELIVERY}))}}}catch(a){C.e(a)}finally{C.f()}}if(q.type===_types.RuleType.TARGETED_DELIVERY)return(0,_tsRes.Ok)({featureKey:m,featureFlagId:n,experimentId:null,variationKey:o,variationId:null,rule:null,isTargetedRule:!0})}}}catch(a){p.e(a)}finally{p.f()}return(0,_tsRes.Ok)({featureKey:m,featureFlagId:n,experimentId:null,variationKey:o,variationId:null,rule:null})}},{key:"updateStoredVariations",value:function updateStoredVariations(a,b){var c=this.storage.read();if(!c.ok&&c.error.type===_kameleoonError.KameleoonException.StorageParse)return c;var d=c.ok?c.data:{};return d[a]?d[a]=_objectSpread(_objectSpread({},d[a]),b):d=_objectSpread(_objectSpread({},d),{},_defineProperty({},a,_objectSpread({},b))),this.storage.write(d)}}]),a}();exports.VariationConfiguration=VariationConfiguration;
|
|
2
2
|
//# sourceMappingURL=variationConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variationConfiguration.js","names":["VariationConfiguration","a","externalStorage","_classCallCheck","_defineProperty","storage","_createClass","key","value","getStoredVariations","visitorCode","result","read","ok","featureFlagVariations","data","Ok","Err","KameleoonError","KameleoonException","StorageRead","getVariation","featureFlag","targetingData","packageInfo","clientConfiguration","dataManager","h","withAssignment","validateResult","Utilities","validateVisitorCode","error","j","rules","featureKey","featureFlagId","id","defaultVariationKey","o","_createForOfIteratorHelper","s","n","done","rule","segment","experimentId","exposition","respoolTime","variationByExposition","targetingResult","checkTargeting","variationConfiguration","ruleHash","Hasher","getHashDouble","y","totalDeviation","variationHash","B","variation","updateStoredVariations","variationId","restParameters","_objectWithoutProperties","_excluded","_objectSpread","isTargetedRule","type","RuleType","TARGETED_DELIVERY","e","f","variationKey","variationData","StorageParse","updatedVariationData","write","exports"],"sources":["../../src/variationConfiguration/variationConfiguration.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { Hasher } from 'src/hasher';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { IExternalStorage, VariationDataType } from 'src/storage';\nimport { Utilities } from 'src/utilities';\nimport { RuleType } from 'src/clientConfiguration/types';\nimport { FeatureFlagVariationType, GetVariationParametersType } from './types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\n\ninterface IVariationConfiguration {\n /**\n * @method getStoredVariations - obtains campaigns with according variations that are *already assigned* and *stored* in the `variationStorage`.\n */\n getStoredVariations(\n visitorCode: string,\n ): Result<FeatureFlagVariationsType, KameleoonError>;\n /**\n * @method updateStoredVariations - updates stored variations for the visitor\n */\n updateStoredVariations: (\n visitorCode: string,\n variationData: FeatureFlagVariationsType,\n ) => void;\n /**\n * @method getVariation - obtains variation for the rule of the feature flag which is both targeted and has a variation, if no such rule was found, returns empty rule with default `variationKey`, given an option `withAssignment` of `true` will also assign a new variation and save it in the storage\n */\n getVariation: (\n params: GetVariationParametersType,\n ) => Result<FeatureFlagVariationType, KameleoonError>;\n}\n\nexport class VariationConfiguration implements IVariationConfiguration {\n private storage: IExternalStorage<VariationDataType>;\n\n constructor(externalStorage: IExternalStorage<VariationDataType>) {\n this.storage = externalStorage;\n }\n\n public getStoredVariations(\n visitorCode: string,\n ): Result<FeatureFlagVariationsType, KameleoonError> {\n const result = this.storage.read();\n\n if (!result.ok) {\n return result;\n }\n\n const featureFlagVariations = result.data[visitorCode];\n\n if (!featureFlagVariations) {\n return Err(\n new KameleoonError(KameleoonException.StorageRead, visitorCode),\n );\n }\n\n return Ok(featureFlagVariations);\n }\n\n public getVariation({\n visitorCode,\n featureFlag,\n targetingData,\n packageInfo,\n clientConfiguration,\n dataManager,\n withAssignment = false,\n }: GetVariationParametersType): Result<\n FeatureFlagVariationType,\n KameleoonError\n > {\n const validateResult = Utilities.validateVisitorCode(visitorCode);\n\n if (!validateResult.ok) {\n return Err(validateResult.error);\n }\n\n const {\n rules,\n featureKey,\n id: featureFlagId,\n defaultVariationKey,\n } = featureFlag;\n\n for (const rule of rules) {\n const {\n segment,\n experimentId,\n id,\n exposition,\n respoolTime,\n variationByExposition,\n } = rule;\n\n // --- Check targeting ---\n const targetingResult = Utilities.checkTargeting({\n segment,\n visitorCode,\n experimentId,\n targetingData,\n packageInfo,\n clientConfiguration,\n dataManager,\n variationConfiguration: this,\n });\n\n if (!targetingResult.ok) {\n return targetingResult;\n }\n\n if (!targetingResult.data) {\n continue;\n }\n\n // --- Note ---\n // Calculate new variation (and assign it if `withAssignment` is `true`)\n // First the the exposed rule is calculated and then the variation inside of it\n const ruleHash = Hasher.getHashDouble({\n visitorCode,\n respoolTime,\n id: String(id),\n });\n\n if (ruleHash <= exposition) {\n let totalDeviation = 0;\n\n const variationHash = Hasher.getHashDouble({\n visitorCode,\n respoolTime,\n id: String(experimentId),\n });\n\n for (const variation of variationByExposition) {\n totalDeviation += variation.exposition;\n\n if (variationHash <= totalDeviation) {\n if (withAssignment) {\n this.updateStoredVariations(visitorCode, {\n [experimentId]: variation.variationId,\n });\n }\n\n const { exposition, ...restParameters } = variation;\n\n return Ok({\n ...restParameters,\n rule,\n featureFlagId,\n featureKey,\n experimentId,\n isTargetedRule: rule.type === RuleType.TARGETED_DELIVERY,\n });\n }\n }\n }\n\n if (rule.type === RuleType.TARGETED_DELIVERY) {\n return Ok({\n featureKey,\n featureFlagId,\n experimentId: null,\n variationKey: defaultVariationKey,\n variationId: null,\n rule: null,\n isTargetedRule: true,\n });\n }\n }\n\n return Ok({\n featureKey,\n featureFlagId,\n experimentId: null,\n variationKey: defaultVariationKey,\n variationId: null,\n rule: null,\n });\n }\n\n public updateStoredVariations(\n visitorCode: string,\n variationData: FeatureFlagVariationsType,\n ): Result<void, KameleoonError> {\n const result = this.storage.read();\n\n if (!result.ok) {\n // --- Note ---\n // If there is a parsing error we return error\n // But if there is `LocalStorageRead` error it means that\n // data was read successfully and it's empty, which is not problem\n // cause that might be initial `read`\n if (result.error.type === KameleoonException.StorageParse) {\n return result;\n }\n }\n\n let updatedVariationData: VariationDataType = result.ok ? result.data : {};\n\n if (updatedVariationData[visitorCode]) {\n updatedVariationData[visitorCode] = {\n ...updatedVariationData[visitorCode],\n ...variationData,\n };\n } else {\n updatedVariationData = {\n ...updatedVariationData,\n [visitorCode]: {\n ...variationData,\n },\n };\n }\n\n return this.storage.write(updatedVariationData);\n }\n}\n"],"mappings":"+tHA+Ba,CAAAA,sBAAsB,YAGjC,SAAAC,EAAYC,CAAoD,CAAE,CAAAC,eAAA,MAAAF,CA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Aa,CACbU,YAAY,CAAE,IAAI,CAClB2B,YAAY,CAAEnC,CAAmB,CACjCwB,WAAW,CAAE,IAAI,CACjBlB,IAAI,CAAE,IACR,CAAC,CACH,CAAC,GAAArC,GAAA,0BAAAC,KAAA,CAED,SAAAqD,uBACEnD,CAAmB,CACnBgE,CAAwC,CACV,CAC9B,GAAM,CAAA/D,CAAM,CAAG,IAAI,CAACN,OAAO,CAACO,IAAI,EAAE,CAElC,GAAI,CAACD,CAAM,CAACE,EAAE,EAMRF,CAAM,CAACqB,KAAK,CAACoC,IAAI,GAAKjD,kCAAkB,CAACwD,YAAY,CACvD,MAAO,CAAAhE,CAAM,CAIjB,GAAI,CAAAiE,CAAuC,CAAGjE,CAAM,CAACE,EAAE,CAAGF,CAAM,CAACI,IAAI,CAAG,CAAC,CAAC,CAgB1E,MAdI,CAAA6D,CAAoB,CAAClE,CAAW,CAAC,CACnCkE,CAAoB,CAAClE,CAAW,CAAC,CAAAwD,aAAA,CAAAA,aAAA,IAC5BU,CAAoB,CAAClE,CAAW,CAAC,EACjCgE,CAAa,CACjB,CAEDE,CAAoB,CAAAV,aAAA,CAAAA,aAAA,IACfU,CAAoB,KAAAxE,eAAA,IACtBM,CAAW,CAAAwD,aAAA,IACPQ,CAAa,GAEnB,CAGI,IAAI,CAACrE,OAAO,CAACwE,KAAK,CAACD,CAAoB,CAChD,CAAC,IAAA3E,CAAA,IAAA6E,OAAA,CAAA9E,sBAAA,CAAAA,sBAAA"}
|
|
1
|
+
{"version":3,"file":"variationConfiguration.js","names":["VariationConfiguration","a","externalStorage","_classCallCheck","_defineProperty","storage","_createClass","key","value","getStoredVariations","visitorCode","result","read","ok","featureFlagVariations","data","Ok","Err","KameleoonError","KameleoonException","StorageRead","getVariation","visitorIdentifier","featureFlag","targetingData","packageInfo","clientConfiguration","dataManager","i","withAssignment","validateResult","Utilities","validateVisitorCode","error","k","rules","featureKey","featureFlagId","id","defaultVariationKey","p","_createForOfIteratorHelper","s","n","done","rule","segment","experimentId","exposition","respoolTime","variationByExposition","targetingResult","checkTargeting","variationConfiguration","ruleHash","Hasher","getHashDouble","z","totalDeviation","variationHash","C","variation","updateStoredVariations","variationId","restParameters","_objectWithoutProperties","_excluded","_objectSpread","isTargetedRule","type","RuleType","TARGETED_DELIVERY","e","f","variationKey","variationData","StorageParse","updatedVariationData","write","exports"],"sources":["../../src/variationConfiguration/variationConfiguration.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { Hasher } from 'src/hasher';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { IExternalStorage, VariationDataType } from 'src/storage';\nimport { Utilities } from 'src/utilities';\nimport { RuleType } from 'src/clientConfiguration/types';\nimport { FeatureFlagVariationType, GetVariationParametersType } from './types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\n\ninterface IVariationConfiguration {\n /**\n * @method getStoredVariations - obtains campaigns with according variations that are *already assigned* and *stored* in the `variationStorage`.\n */\n getStoredVariations(\n visitorCode: string,\n ): Result<FeatureFlagVariationsType, KameleoonError>;\n /**\n * @method updateStoredVariations - updates stored variations for the visitor\n */\n updateStoredVariations: (\n visitorCode: string,\n variationData: FeatureFlagVariationsType,\n ) => void;\n /**\n * @method getVariation - obtains variation for the rule of the feature flag which is both targeted and has a variation, if no such rule was found, returns empty rule with default `variationKey`, given an option `withAssignment` of `true` will also assign a new variation and save it in the storage\n */\n getVariation: (\n params: GetVariationParametersType,\n ) => Result<FeatureFlagVariationType, KameleoonError>;\n}\n\nexport class VariationConfiguration implements IVariationConfiguration {\n private storage: IExternalStorage<VariationDataType>;\n\n constructor(externalStorage: IExternalStorage<VariationDataType>) {\n this.storage = externalStorage;\n }\n\n public getStoredVariations(\n visitorCode: string,\n ): Result<FeatureFlagVariationsType, KameleoonError> {\n const result = this.storage.read();\n\n if (!result.ok) {\n return result;\n }\n\n const featureFlagVariations = result.data[visitorCode];\n\n if (!featureFlagVariations) {\n return Err(\n new KameleoonError(KameleoonException.StorageRead, visitorCode),\n );\n }\n\n return Ok(featureFlagVariations);\n }\n\n public getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n packageInfo,\n clientConfiguration,\n dataManager,\n withAssignment = false,\n }: GetVariationParametersType): Result<\n FeatureFlagVariationType,\n KameleoonError\n > {\n const validateResult = Utilities.validateVisitorCode(visitorCode);\n\n if (!validateResult.ok) {\n return Err(validateResult.error);\n }\n\n const {\n rules,\n featureKey,\n id: featureFlagId,\n defaultVariationKey,\n } = featureFlag;\n\n for (const rule of rules) {\n const {\n segment,\n experimentId,\n id,\n exposition,\n respoolTime,\n variationByExposition,\n } = rule;\n\n // --- Check targeting ---\n const targetingResult = Utilities.checkTargeting({\n segment,\n visitorCode,\n experimentId,\n targetingData,\n packageInfo,\n clientConfiguration,\n dataManager,\n variationConfiguration: this,\n });\n\n if (!targetingResult.ok) {\n return targetingResult;\n }\n\n if (!targetingResult.data) {\n continue;\n }\n\n // --- Note ---\n // Calculate new variation (and assign it if `withAssignment` is `true`)\n // First the the exposed rule is calculated and then the variation inside of it\n const ruleHash = Hasher.getHashDouble({\n visitorIdentifier,\n respoolTime,\n id: String(id),\n });\n\n if (ruleHash <= exposition) {\n let totalDeviation = 0;\n\n const variationHash = Hasher.getHashDouble({\n visitorIdentifier,\n respoolTime,\n id: String(experimentId),\n });\n\n for (const variation of variationByExposition) {\n totalDeviation += variation.exposition;\n\n if (variationHash <= totalDeviation) {\n if (withAssignment) {\n this.updateStoredVariations(visitorCode, {\n [experimentId]: variation.variationId,\n });\n }\n\n const { exposition, ...restParameters } = variation;\n\n return Ok({\n ...restParameters,\n rule,\n featureFlagId,\n featureKey,\n experimentId,\n isTargetedRule: rule.type === RuleType.TARGETED_DELIVERY,\n });\n }\n }\n }\n\n if (rule.type === RuleType.TARGETED_DELIVERY) {\n return Ok({\n featureKey,\n featureFlagId,\n experimentId: null,\n variationKey: defaultVariationKey,\n variationId: null,\n rule: null,\n isTargetedRule: true,\n });\n }\n }\n\n return Ok({\n featureKey,\n featureFlagId,\n experimentId: null,\n variationKey: defaultVariationKey,\n variationId: null,\n rule: null,\n });\n }\n\n public updateStoredVariations(\n visitorCode: string,\n variationData: FeatureFlagVariationsType,\n ): Result<void, KameleoonError> {\n const result = this.storage.read();\n\n if (!result.ok) {\n // --- Note ---\n // If there is a parsing error we return error\n // But if there is `LocalStorageRead` error it means that\n // data was read successfully and it's empty, which is not problem\n // cause that might be initial `read`\n if (result.error.type === KameleoonException.StorageParse) {\n return result;\n }\n }\n\n let updatedVariationData: VariationDataType = result.ok ? result.data : {};\n\n if (updatedVariationData[visitorCode]) {\n updatedVariationData[visitorCode] = {\n ...updatedVariationData[visitorCode],\n ...variationData,\n };\n } else {\n updatedVariationData = {\n ...updatedVariationData,\n [visitorCode]: {\n ...variationData,\n },\n };\n }\n\n return this.storage.write(updatedVariationData);\n }\n}\n"],"mappings":"+tHA+Ba,CAAAA,sBAAsB,YAGjC,SAAAC,EAAYC,CAAoD,CAAE,CAAAC,eAAA,MAAAF,CAAA,EAAAG,eAAA,wBAChE,IAAI,CAACC,OAAO,CAAGH,CACjB,CAAC,OAAAI,YAAA,CAAAL,CAAA,GAAAM,GAAA,uBAAAC,KAAA,CAED,SAAAC,oBACEC,CAAmB,CACgC,CACnD,GAAM,CAAAC,CAAM,CAAG,IAAI,CAACN,OAAO,CAACO,IAAI,EAAE,CAElC,GAAI,CAACD,CAAM,CAACE,EAAE,CACZ,MAAO,CAAAF,CAAM,CAGf,GAAM,CAAAG,CAAqB,CAAGH,CAAM,CAACI,IAAI,CAACL,CAAW,CAAC,CAAC,MAElD,CAAAI,CAAqB,CAMnB,GAAAE,SAAE,EAACF,CAAqB,CAAC,CALvB,GAAAG,UAAG,EACR,GAAI,CAAAC,8BAAc,CAACC,kCAAkB,CAACC,WAAW,CAAEV,CAAW,CAAC,CAKrE,CAAC,GAAAH,GAAA,gBAAAC,KAAA,CAED,SAAAa,aAAApB,CAAA,CAYE,IAXA,CAAAS,CAAW,CAAAT,CAAA,C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