@kameleoon/javascript-sdk-core 4.4.8 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/cacheManager/cacheManager.js +1 -1
- package/dist/cacheManager/cacheManager.js.map +1 -1
- package/dist/cacheManager/index.js.map +1 -1
- package/dist/cacheManager/types.js.map +1 -1
- package/dist/clientConfiguration/clientConfiguration.d.ts +2 -6
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/index.js.map +1 -1
- package/dist/clientConfiguration/types.d.ts +2 -5
- package/dist/clientConfiguration/types.js +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/clientSettings/clientSettings.d.ts +2 -1
- package/dist/clientSettings/clientSettings.js +1 -1
- package/dist/clientSettings/clientSettings.js.map +1 -1
- package/dist/clientSettings/index.js.map +1 -1
- package/dist/clientSettings/types.d.ts +1 -0
- package/dist/clientSettings/types.js.map +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/eventManager/eventManager.js +1 -1
- package/dist/eventManager/eventManager.js.map +1 -1
- package/dist/eventManager/index.js.map +1 -1
- package/dist/eventManager/types.js.map +1 -1
- package/dist/eventSource/constants.js.map +1 -1
- package/dist/eventSource/eventSource.js +1 -1
- package/dist/eventSource/eventSource.js.map +1 -1
- package/dist/eventSource/index.js.map +1 -1
- package/dist/eventSource/types.js.map +1 -1
- package/dist/hasher/hasher.js.map +1 -1
- package/dist/hasher/index.js.map +1 -1
- package/dist/hasher/types.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +6 -13
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +18 -16
- package/dist/kameleoonClientInterface.js.map +1 -1
- package/dist/kameleoonData/applicationVersion.d.ts +2 -3
- package/dist/kameleoonData/applicationVersion.js +1 -1
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +9 -3
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/conversion.d.ts +12 -3
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.d.ts +2 -3
- package/dist/kameleoonData/cookie.js +1 -1
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.d.ts +11 -3
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.d.ts +34 -23
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +22 -24
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.d.ts +9 -3
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.d.ts +9 -3
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/helpers.js.map +1 -1
- package/dist/kameleoonData/index.d.ts +2 -1
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/index.js.map +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.d.ts +2 -1
- package/dist/kameleoonData/kameleoonConversionScore.js +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.js.map +1 -1
- package/dist/kameleoonData/operatingSystem.d.ts +9 -3
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.d.ts +12 -8
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +97 -31
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/uniqueIdentifier.d.ts +19 -0
- package/dist/kameleoonData/uniqueIdentifier.js +2 -0
- package/dist/kameleoonData/uniqueIdentifier.js.map +1 -0
- package/dist/kameleoonData/userAgent.d.ts +2 -3
- package/dist/kameleoonData/userAgent.js +1 -1
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitProcessor.d.ts +3 -4
- package/dist/kameleoonData/visitProcessor.js +1 -1
- package/dist/kameleoonData/visitProcessor.js.map +1 -1
- package/dist/kameleoonData/visitsData.d.ts +2 -0
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/kameleoonError/constants.js +1 -1
- package/dist/kameleoonError/constants.js.map +1 -1
- package/dist/kameleoonError/helpers.js +1 -1
- package/dist/kameleoonError/helpers.js.map +1 -1
- package/dist/kameleoonError/index.js.map +1 -1
- package/dist/kameleoonError/kameleoonError.js +1 -1
- package/dist/kameleoonError/kameleoonError.js.map +1 -1
- package/dist/kameleoonError/types.js.map +1 -1
- package/dist/kameleoonUtils.d.ts +1 -11
- package/dist/kameleoonUtils.js +1 -1
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +5 -7
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +7 -26
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +2 -2
- package/dist/requester/urlProvider.js +1 -1
- package/dist/requester/urlProvider.js.map +1 -1
- package/dist/storage/constants.d.ts +6 -2
- package/dist/storage/constants.js +1 -1
- package/dist/storage/constants.js.map +1 -1
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/integrityChecker.d.ts +20 -0
- package/dist/storage/integrityChecker.js +2 -0
- package/dist/storage/integrityChecker.js.map +1 -0
- package/dist/storage/storage.d.ts +0 -1
- package/dist/storage/storage.js +1 -1
- package/dist/storage/storage.js.map +1 -1
- package/dist/storage/types.d.ts +25 -17
- package/dist/storage/types.js.map +1 -1
- package/dist/targeting/conditions/applicationVersion.js +1 -1
- package/dist/targeting/conditions/applicationVersion.js.map +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/browser.js.map +1 -1
- package/dist/targeting/conditions/conditionFactory.js.map +1 -1
- package/dist/targeting/conditions/conversion.js +1 -1
- package/dist/targeting/conditions/conversion.js.map +1 -1
- package/dist/targeting/conditions/conversionLikelihood.js +1 -1
- package/dist/targeting/conditions/conversionLikelihood.js.map +1 -1
- package/dist/targeting/conditions/cookie.js +1 -1
- package/dist/targeting/conditions/cookie.js.map +1 -1
- package/dist/targeting/conditions/customData.js +1 -1
- package/dist/targeting/conditions/customData.js.map +1 -1
- package/dist/targeting/conditions/device.js +1 -1
- package/dist/targeting/conditions/device.js.map +1 -1
- package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -1
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/firstVisit.js.map +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/geolocation.js.map +1 -1
- package/dist/targeting/conditions/index.js.map +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/lastVisit.js.map +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/newVisitor.js.map +1 -1
- package/dist/targeting/conditions/operatingSystem.js +1 -1
- package/dist/targeting/conditions/operatingSystem.js.map +1 -1
- package/dist/targeting/conditions/pageTitle.js +1 -1
- package/dist/targeting/conditions/pageTitle.js.map +1 -1
- package/dist/targeting/conditions/pageUrl.js +1 -1
- package/dist/targeting/conditions/pageUrl.js.map +1 -1
- package/dist/targeting/conditions/previousPage.js +1 -1
- package/dist/targeting/conditions/previousPage.js.map +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
- package/dist/targeting/conditions/sdkLanguage.js +1 -1
- package/dist/targeting/conditions/sdkLanguage.js.map +1 -1
- package/dist/targeting/conditions/segment.js +1 -1
- package/dist/targeting/conditions/segment.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -1
- package/dist/targeting/conditions/types.js.map +1 -1
- package/dist/targeting/conditions/utilities.d.ts +5 -0
- package/dist/targeting/conditions/utilities.js +2 -0
- package/dist/targeting/conditions/utilities.js.map +1 -0
- package/dist/targeting/conditions/visitedPages.js +1 -1
- package/dist/targeting/conditions/visitedPages.js.map +1 -1
- package/dist/targeting/conditions/visitorCode.js +1 -1
- package/dist/targeting/conditions/visitorCode.js.map +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/conditions/visits.js.map +1 -1
- package/dist/targeting/index.d.ts +1 -1
- package/dist/targeting/index.js.map +1 -1
- package/dist/targeting/node.js +1 -1
- package/dist/targeting/node.js.map +1 -1
- package/dist/targeting/tree.js +1 -1
- package/dist/targeting/tree.js.map +1 -1
- package/dist/targeting/types.js.map +1 -1
- package/dist/tracking/bodyProvider.d.ts +26 -0
- package/dist/tracking/bodyProvider.js +2 -0
- package/dist/tracking/bodyProvider.js.map +1 -0
- package/dist/tracking/constants.d.ts +2 -0
- package/dist/tracking/constants.js +2 -0
- package/dist/tracking/constants.js.map +1 -0
- package/dist/tracking/index.d.ts +1 -0
- package/dist/tracking/index.js +2 -0
- package/dist/tracking/index.js.map +1 -0
- package/dist/tracking/tracker.d.ts +21 -0
- package/dist/tracking/tracker.js +2 -0
- package/dist/tracking/tracker.js.map +1 -0
- package/dist/tracking/types.d.ts +45 -0
- package/dist/tracking/types.js +2 -0
- package/dist/tracking/types.js.map +1 -0
- package/dist/types.d.ts +44 -15
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.d.ts +0 -1
- package/dist/utilities/constants.js +1 -1
- package/dist/utilities/constants.js.map +1 -1
- package/dist/utilities/index.d.ts +3 -2
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/parser.d.ts +10 -0
- package/dist/utilities/parser.js +2 -0
- package/dist/utilities/parser.js.map +1 -0
- package/dist/utilities/types.d.ts +3 -40
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.d.ts +5 -21
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/utilities/validator.d.ts +5 -0
- package/dist/utilities/validator.js +2 -0
- package/dist/utilities/validator.js.map +1 -0
- package/dist/variationConfiguration/index.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +7 -2
- package/dist/variationConfiguration/types.js.map +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +15 -7
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/dist/visitorCodeManager/constants.d.ts +2 -0
- package/dist/visitorCodeManager/constants.js +1 -1
- package/dist/visitorCodeManager/constants.js.map +1 -1
- package/dist/visitorCodeManager/index.js.map +1 -1
- package/dist/visitorCodeManager/types.d.ts +3 -0
- package/dist/visitorCodeManager/types.js.map +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.d.ts +4 -0
- package/dist/visitorCodeManager/visitorCodeManager.js +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.0.1 (2024-11-05)
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed an issue with the [`Page URL`][Targeting Conditions] and [`Page Title`][Targeting Conditions] targeting conditions, where the condition evaluated all previously visited URLs in the session instead of only the current URL, corresponding to the latest added `PageView`
|
|
8
|
+
NOTE: This change may impact your existing targeting. Please review your targeting conditions to ensure accuracy.
|
|
9
|
+
|
|
10
|
+
[Targeting Conditions]: https://developers.kameleoon.com/feature-management-and-experimentation/using-visit-history-in-feature-flags-and-experiments#benefits-of-calling-getremotevisitordata
|
|
11
|
+
|
|
12
|
+
## 5.0.0 (2024-10-03)
|
|
13
|
+
|
|
14
|
+
### Breaking Changes
|
|
15
|
+
|
|
16
|
+
- `isUniqueIdentifier` parameter has been removed from methods [`flush`][flush], [`getRemoteVisitorData`][getremotevisitordata] and [`trackConversion`][trackconversion]
|
|
17
|
+
- Previously deprecated method [`onConfigurationUpdate`][onconfigurationupdate] has been removed from SDKs. Use [`onEvent`][onevent] method with `EventType.ConfigurationUpdate` to achieve the same effect.
|
|
18
|
+
- Previously deprecated field [`domain`][domain] of `SDKConfiguration` has been removed from SDKs. Use [`cookieDomain`][domain] field of `SDKConfiguration` instead.
|
|
19
|
+
- Parameter `text` of `KameleoonResponseType` used in custom [`requester`][requester] implementation is now mandatory, for the vast majority of implementations like `fetch`, `axios` or `node-fetch` it won't require any changes.
|
|
20
|
+
- Method [`initialize`][initialize] no more accepts `useCache` boolean parameter. Using storage cached client configuration on failed configuration request is now default behavior.
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- Added new [`UniqueIdentifier`][uniqueidentifier] data to be used instead of removed `isUniqueIdentifier` parameters in some methods
|
|
25
|
+
- Added new [`SDKConfiguration`][sdkconfiguration] parameter `trackingInterval` to set the interval between SDK tracking network requests in _milliseconds_, default value is 1000, which is also maximum interval, minimum value is 100
|
|
26
|
+
- `FeatureVariableType` returned from the methods obtaining feature flag variables can now have two new `VariableType`s - `VariableType.JS` containing a `string` of JavaScript code and `VariableType.CSS` containing a string with CSS code
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- [`getEngineTrackingCode`][getenginetrackingcode] method now correctly sets `triggerExperiment` parameter based on variable types
|
|
31
|
+
|
|
32
|
+
[uniqueidentifier]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#uniqueidentifier
|
|
33
|
+
[sdkconfiguration]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#arguments
|
|
34
|
+
[flush]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#flush
|
|
35
|
+
[getremotevisitordata]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getremotevisitordata
|
|
36
|
+
[trackconversion]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#trackconversion
|
|
37
|
+
[onconfigurationupdate]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#onconfigurationupdate
|
|
38
|
+
[onevent]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#onevent
|
|
39
|
+
[domain]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#configuration-parameters
|
|
40
|
+
[requester]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#requester
|
|
41
|
+
[initialize]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#initialize
|
|
42
|
+
[getenginetrackingcode]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getenginetrackingcode
|
|
43
|
+
|
|
3
44
|
## 4.4.8 (2024-09-09)
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CacheManager=void 0;function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CacheManager=void 0;function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class CacheManager{constructor(a){_defineProperty(this,"cacheMap",new Map),_defineProperty(this,"intervalId",null),_defineProperty(this,"cleanupTimeout",void 0),this.cleanupTimeout=a*_types.Milliseconds.Second}add(a){let{key:b,data:c,lifetime:d}=a;null===this.intervalId&&this.activate();const e=d*_types.Milliseconds.Second,f={data:c,expirationTime:Date.now()+e};this.cacheMap.set(b,f)}getAliveItem(a){const b=this.cacheMap.get(a);return b&&b.expirationTime>=Date.now()?b.data:(b&&this.cacheMap.delete(a),null)}activate(){this.intervalId=setInterval(()=>{const a=Date.now();for(const[b,c]of this.cacheMap)c.expirationTime<a&&this.cacheMap.delete(b);this.cacheMap.size||this.cleanupInterval()},this.cleanupTimeout)}cleanupInterval(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}}exports.CacheManager=CacheManager;
|
|
2
2
|
//# sourceMappingURL=cacheManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheManager.js","names":["_types","require","Object","defineProperty","exports","value","CacheManager","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","cleanupTimeout","Map","Milliseconds","Second","add","key","data","lifetime","intervalId","activate","expirationTime","cacheItem","Date","now","cacheMap","set","getAliveItem","get","delete","setInterval","item","size","cleanupInterval","clearInterval"],"sources":["../../src/cacheManager/cacheManager.ts"],"sourcesContent":["import { Milliseconds } from 'src/types';\nimport { AddParametersType, CacheItemType } from './types';\n\ninterface ICacheManager<T> {\n /**\n * Add item to cache\n * @param {AddParametersType<T>} parameters - parameters for adding new item cache\n * @returns {void}\n */\n add({ key, data, lifetime }: AddParametersType<T>): void;\n /**\n * Get item that is not expired from cache\n * @param {string} key - key of item\n * @returns {T} an item that is not expired\n */\n getAliveItem(key: string): T | null;\n}\n\n/**\n * @class\n * CacheManager - a class for managing cache\n */\nexport class CacheManager<T> implements ICacheManager<T> {\n private cacheMap = new Map<string, CacheItemType<T>>();\n private intervalId: NodeJS.Timeout | null = null;\n private cleanupTimeout: number;\n\n /**\n * @param {number} cleanupTimeout - timeout for cleaning cache in seconds\n * generic type `T` is a type of data that will be stored in cache\n * @example\n * ```typescript\n * const cacheManager = new CacheManager<number>(60);\n * ```\n */\n constructor(cleanupTimeout: number) {\n this.cleanupTimeout = cleanupTimeout * Milliseconds.Second;\n }\n\n public add({ key, data, lifetime }: AddParametersType<T>): void {\n if (this.intervalId === null) {\n this.activate();\n }\n\n const expirationTime = lifetime * Milliseconds.Second;\n\n const cacheItem: CacheItemType<T> = {\n data,\n expirationTime: Date.now() + expirationTime,\n };\n\n this.cacheMap.set(key, cacheItem);\n }\n\n public getAliveItem(key: string): T | null {\n const cacheItem = this.cacheMap.get(key);\n\n if (cacheItem && cacheItem.expirationTime >= Date.now()) {\n return cacheItem.data;\n }\n\n cacheItem && this.cacheMap.delete(key);\n\n return null;\n }\n\n private activate(): void {\n this.intervalId = setInterval(() => {\n const now = Date.now();\n\n for (const [key, item] of this.cacheMap) {\n if (item.expirationTime < now) {\n this.cacheMap.delete(key);\n }\n }\n\n if (!this.cacheMap.size) {\n this.cleanupInterval();\n }\n }, this.cleanupTimeout);\n }\n\n private cleanupInterval(): void {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n }\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,aAAyCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,iBAAAC,gBAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAD,CAAA,CAAAE,cAAA,CAAAF,CAAA,
|
|
1
|
+
{"version":3,"file":"cacheManager.js","names":["_types","require","Object","defineProperty","exports","value","CacheManager","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","cleanupTimeout","Map","Milliseconds","Second","add","key","data","lifetime","intervalId","activate","expirationTime","cacheItem","Date","now","cacheMap","set","getAliveItem","get","delete","setInterval","item","size","cleanupInterval","clearInterval"],"sources":["../../src/cacheManager/cacheManager.ts"],"sourcesContent":["import { Milliseconds } from 'src/types';\nimport { AddParametersType, CacheItemType } from './types';\n\ninterface ICacheManager<T> {\n /**\n * Add item to cache\n * @param {AddParametersType<T>} parameters - parameters for adding new item cache\n * @returns {void}\n */\n add({ key, data, lifetime }: AddParametersType<T>): void;\n /**\n * Get item that is not expired from cache\n * @param {string} key - key of item\n * @returns {T} an item that is not expired\n */\n getAliveItem(key: string): T | null;\n}\n\n/**\n * @class\n * CacheManager - a class for managing cache\n */\nexport class CacheManager<T> implements ICacheManager<T> {\n private cacheMap = new Map<string, CacheItemType<T>>();\n private intervalId: NodeJS.Timeout | null = null;\n private cleanupTimeout: number;\n\n /**\n * @param {number} cleanupTimeout - timeout for cleaning cache in seconds\n * generic type `T` is a type of data that will be stored in cache\n * @example\n * ```typescript\n * const cacheManager = new CacheManager<number>(60);\n * ```\n */\n constructor(cleanupTimeout: number) {\n this.cleanupTimeout = cleanupTimeout * Milliseconds.Second;\n }\n\n public add({ key, data, lifetime }: AddParametersType<T>): void {\n if (this.intervalId === null) {\n this.activate();\n }\n\n const expirationTime = lifetime * Milliseconds.Second;\n\n const cacheItem: CacheItemType<T> = {\n data,\n expirationTime: Date.now() + expirationTime,\n };\n\n this.cacheMap.set(key, cacheItem);\n }\n\n public getAliveItem(key: string): T | null {\n const cacheItem = this.cacheMap.get(key);\n\n if (cacheItem && cacheItem.expirationTime >= Date.now()) {\n return cacheItem.data;\n }\n\n cacheItem && this.cacheMap.delete(key);\n\n return null;\n }\n\n private activate(): void {\n this.intervalId = setInterval(() => {\n const now = Date.now();\n\n for (const [key, item] of this.cacheMap) {\n if (item.expirationTime < now) {\n this.cacheMap.delete(key);\n }\n }\n\n if (!this.cacheMap.size) {\n this.cleanupInterval();\n }\n }, this.cleanupTimeout);\n }\n\n private cleanupInterval(): void {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n }\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,aAAyCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,iBAAAC,gBAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAD,CAAA,CAAAE,cAAA,CAAAF,CAAA,KAAAD,CAAA,CAAAN,MAAA,CAAAC,cAAA,CAAAK,CAAA,CAAAC,CAAA,EAAAJ,KAAA,CAAAK,CAAA,CAAAE,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAN,CAAA,CAAAC,CAAA,EAAAC,CAAA,CAAAF,CAAA,UAAAG,eAAAH,CAAA,MAAAC,CAAA,CAAAM,YAAA,CAAAP,CAAA,kCAAAC,CAAA,CAAAA,CAAA,CAAAA,CAAA,aAAAM,aAAAP,CAAA,CAAAC,CAAA,sBAAAD,CAAA,GAAAA,CAAA,QAAAA,CAAA,KAAAE,CAAA,CAAAF,CAAA,CAAAQ,MAAA,CAAAC,WAAA,cAAAP,CAAA,MAAAQ,CAAA,CAAAR,CAAA,CAAAS,IAAA,CAAAX,CAAA,CAAAC,CAAA,iCAAAS,CAAA,Q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KAAM,CAACR,CAAG,CAAEe,CAAI,CAAC,EAAI,KAAI,CAACN,QAAQ,CACjCM,CAAI,CAACV,cAAc,CAAGG,CAAG,EAC3B,IAAI,CAACC,QAAQ,CAACI,MAAM,CAACb,CAAG,CAAC,CAIxB,IAAI,CAACS,QAAQ,CAACO,IAAI,EACrB,IAAI,CAACC,eAAe,CAAC,CAEzB,CAAC,CAAE,IAAI,CAACtB,cAAc,CACxB,CAEQsB,eAAeA,CAAA,CAAS,CAC1B,IAAI,CAACd,UAAU,GACjBe,aAAa,CAAC,IAAI,CAACf,UAAU,CAAC,CAC9B,IAAI,CAACA,UAAU,CAAG,IAAI,CAE1B,CACF,CAAC5B,OAAA,CAAAE,YAAA,CAAAA,YAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cacheManager/index.ts"],"sourcesContent":["export { CacheManager } from './cacheManager';\nexport { AddParametersType } from './types';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cacheManager/index.ts"],"sourcesContent":["export { CacheManager } from './cacheManager';\nexport { AddParametersType } from './types';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/cacheManager/types.ts"],"sourcesContent":["/**\n * @param {string} key - key for adding new item cache, key must be unique otherwise the item will be overwritten\n * @param {T} data - data for adding new item cache\n * @param {number} lifetime - lifetime for adding new item cache in seconds\n */\nexport type AddParametersType<T> = {\n key: string;\n data: T;\n lifetime: number;\n};\n\nexport type CacheItemType<T> = {\n data: T;\n expirationTime: number;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/cacheManager/types.ts"],"sourcesContent":["/**\n * @param {string} key - key for adding new item cache, key must be unique otherwise the item will be overwritten\n * @param {T} data - data for adding new item cache\n * @param {number} lifetime - lifetime for adding new item cache in seconds\n */\nexport type AddParametersType<T> = {\n key: string;\n data: T;\n lifetime: number;\n};\n\nexport type CacheItemType<T> = {\n data: T;\n expirationTime: number;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ import { KameleoonError } from '../kameleoonError/kameleoonError';
|
|
|
3
3
|
import { SegmentType } from '../targeting';
|
|
4
4
|
import { ClientConfigurationParametersType, ConfigurationType, FeatureFlagType, MappedRuleType } from './types';
|
|
5
5
|
interface IClientConfiguration {
|
|
6
|
-
initialize: (
|
|
6
|
+
initialize: () => Promise<Result<void, KameleoonError>>;
|
|
7
7
|
readonly featureFlags: Map<string, FeatureFlagType>;
|
|
8
8
|
readonly configuration: ConfigurationType;
|
|
9
9
|
readonly segments: Map<string, SegmentType>;
|
|
@@ -19,19 +19,16 @@ export declare class ClientConfiguration implements IClientConfiguration {
|
|
|
19
19
|
private updateInterval;
|
|
20
20
|
private lastUpdate;
|
|
21
21
|
private storage;
|
|
22
|
-
private offlineTrackingStorage;
|
|
23
22
|
private requester;
|
|
24
23
|
private eventSource;
|
|
25
|
-
private externalClientConfiguration?;
|
|
26
24
|
private mappedRules;
|
|
27
25
|
private dataManager;
|
|
28
26
|
private visitorCodeManager;
|
|
29
27
|
private eventManager;
|
|
30
28
|
private urlProvider;
|
|
31
|
-
constructor({ updateInterval, urlProvider, storage, requester, dataManager,
|
|
29
|
+
constructor({ updateInterval, urlProvider, storage, requester, dataManager, eventSource, externalVisitorCodeManager, eventManager, }: ClientConfigurationParametersType);
|
|
32
30
|
initialize(): Promise<Result<void, KameleoonError>>;
|
|
33
31
|
private cleanupHandlers;
|
|
34
|
-
private handleExternalUpdates;
|
|
35
32
|
private handleRealTimeUpdates;
|
|
36
33
|
private handlePollingUpdates;
|
|
37
34
|
get featureFlags(): Map<string, FeatureFlagType>;
|
|
@@ -40,7 +37,6 @@ export declare class ClientConfiguration implements IClientConfiguration {
|
|
|
40
37
|
get ruleMap(): Map<number, MappedRuleType>;
|
|
41
38
|
get isConsentRequired(): boolean;
|
|
42
39
|
get hasAnyTargetedDeliveryRule(): boolean;
|
|
43
|
-
private checkIntegrity;
|
|
44
40
|
private checkShouldUpdate;
|
|
45
41
|
private readStorageData;
|
|
46
42
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_types=require("./types"),_eventManager=require("../eventManager"),_constants=require("./constants");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 _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class ClientConfiguration{constructor(a){let{updateInterval:b,urlProvider:c,storage:d,requester:e,dataManager:f,eventSource:g,externalVisitorCodeManager:h,eventManager:i}=a;_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Polling),_defineProperty(this,"configurationData",_constants.DEFAULT_CLIENT_CONFIGURATION),_defineProperty(this,"featureFlagsData",new Map),_defineProperty(this,"isTargetedDeliveryRule",null),_defineProperty(this,"segmentsData",null),_defineProperty(this,"updateInterval",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"mappedRules",null),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),_defineProperty(this,"eventManager",void 0),_defineProperty(this,"urlProvider",void 0),this.urlProvider=c,this.requester=e,this.updateInterval=b,this.lastUpdate=new Date,this.storage=d,this.dataManager=f,this.eventManager=i,this.visitorCodeManager=h,this.eventSource=g}async initialize(){this.readStorageData();const a=this.checkShouldUpdate();if(a){const a=await this.updateClientConfiguration();if(!a.ok)return a;const b=a.data;if(b)return(0,_tsRes.Ok)()}return this.updateType!==_types.UpdateType.RealTime||this.eventSource.isOpen?(this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(),(0,_tsRes.Ok)()):(this.updateType=_types.UpdateType.Polling,this.handleRealTimeUpdates(),(0,_tsRes.Ok)())}cleanupHandlers(){this.eventSource.isOpen&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}handleRealTimeUpdates(){this.cleanupHandlers();const a=a=>{this.updateClientConfiguration(a).then(b=>{b.ok&&this.eventManager.fireEvent(_eventManager.EventType.ConfigurationUpdate,{timestamp:a})})};this.eventSource.open(a)}handlePollingUpdates(){this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(this.updateClientConfiguration.bind(this),this.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}get featureFlags(){return this.featureFlagsData}get configuration(){return this.configurationData.configuration}get segments(){if(this.segmentsData)return this.segmentsData;const a=new Map;return this.featureFlagsData.forEach(b=>{b.rules.forEach(b=>{b.segment&&!a.has(b.segment.id)&&a.set(b.segment.id,b.segment)})}),this.segmentsData=a,a}get ruleMap(){var a;if(null!==(a=this.mappedRules)&&void 0!==a&&a.size)return this.mappedRules;const b=new Map;for(const a of this.featureFlags.values())for(const c of a.rules){const{id:d,experimentId:e,variationByExposition:f}=c,g=new Map;f.forEach(a=>{let{variationKey:b,variationId:c}=a;"number"==typeof c&&g.set(b,c)}),b.set(d,{featureId:a.id,experimentId:e,variations:g})}return this.mappedRules=b,b}get isConsentRequired(){return this.configuration.consentType===_types.ConsentType.Required}get hasAnyTargetedDeliveryRule(){if(null!==this.isTargetedDeliveryRule)return this.isTargetedDeliveryRule;for(const a of this.featureFlags.values())if(a.environmentEnabled&&a.rules.some(a=>a.type===_types.RuleType.TARGETED_DELIVERY))return!0;return!1}checkShouldUpdate(){const{configuration:a}=this.configurationData;if(this.updateType=a.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!this.featureFlags.size)return!0;const b=this.lastUpdate.getTime(),c=Date.now()-this.updateInterval;return b<c}readStorageData(){const a=this.storage.read();if(a.ok){const{data:b,lastUpdate:c}=a.data;this.urlProvider.dataApiDomain=b.configuration.dataApiDomain;const{featureFlags:d,customData:e}=b;null!==e&&void 0!==e&&e.length&&(this.dataManager.customDataIndexes=e);for(const a of d)this.featureFlagsData.set(a.featureKey,a);this.configurationData=b,this.lastUpdate=new Date(Date.parse(c))}}async updateClientConfiguration(a){var b;const c=await this.requester.getClientConfiguration(a);if(!c.ok)return this.featureFlags.size?(0,_tsRes.Ok)(!0):c;const{configuration:d,customData:e,featureFlags:f}=c.data;this.configurationData={configuration:d,customData:e};for(const b of f)this.featureFlagsData.set(b.featureKey,b);null!==e&&void 0!==e&&e.length&&(this.dataManager.customDataIndexes=e),this.dataManager.clearTrees(),null===(b=this.mappedRules)||void 0===b?void 0:b.clear(),this.isTargetedDeliveryRule=null,this.segmentsData=null;const g=this.updateStorageData();if(!g.ok)return g;const h=d.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,i=h!==this.updateType;i&&(this.updateType=h,await this.initialize());const j=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule;return this.visitorCodeManager.consentRequired=j,(0,_tsRes.Ok)(i)}updateStorageData(){this.lastUpdate=new Date;const a=_objectSpread(_objectSpread({},this.configurationData),{},{featureFlags:Array.from(this.featureFlags.values())}),b={data:a,lastUpdate:this.lastUpdate.toString()};return this.urlProvider.dataApiDomain=this.configurationData.configuration.dataApiDomain,this.storage.write(b)}}exports.ClientConfiguration=ClientConfiguration;
|
|
2
2
|
//# sourceMappingURL=clientConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","constructor","a","updateInterval","urlProvider","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","eventSource","externalVisitorCodeManager","eventManager","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","visitorCodeManager","initialize","readStorageData","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateResult","updateClientConfiguration","ok","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","isOpen","Polling","handlePollingUpdates","handleRealTimeUpdates","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","customData","configuration","featureFlags","configurationData","featureFlag","featureFlagsData","set","featureKey","updateEventCallback","timestamp","then","fireEvent","EventType","ConfigurationUpdate","open","setInterval","bind","err","segments","segmentsData","forEach","flag","rules","rule","segment","has","id","ruleMap","mappedRules","size","values","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","isConsentRequired","consentType","ConsentType","Required","hasAnyTargetedDeliveryRule","isTargetedDeliveryRule","environmentEnabled","some","type","RuleType","TARGETED_DELIVERY","checkIntegrity","fields","Object","keys","length","requiredFields","DEFAULT_CLIENT_CONFIGURATION","sort","join","skipChecks","arguments","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","isStorageValid","dataApiDomain","_objectSpread","write","toString","customDataIndexes","parse","b","clientConfigurationResult","getClientConfiguration","Utilities","sendOfflineTracking","clearTrees","clear","updateStorageData","toggleUpdateType","consentRequired","Array","from","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { ClientDataType } from 'src/storage';\nimport { IEventSource } from 'src/eventSource';\nimport {\n DEFAULT_CLIENT_CONFIGURATION,\n DEFAULT_CONFIGURATION_DATA,\n} from './constants';\nimport {\n ClientConfigurationDataType,\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { EventManager, EventType } from 'src/eventManager';\nimport { IUrlProvider } from 'src/requester/urlProvider';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n readonly featureFlags: Map<string, FeatureFlagType>;\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private updateConfigurationIntervalId: NodeJS.Timeout | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ClientConfigurationDataType =\n DEFAULT_CONFIGURATION_DATA;\n private featureFlagsData: Map<string, FeatureFlagType> = new Map();\n private isTargetedDeliveryRule: boolean | null = null;\n private segmentsData: Map<string, SegmentType> | null = null;\n private updateInterval: number;\n private lastUpdate: Date;\n private storage: IStorage<ClientDataType>;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource: IEventSource;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> | null = null;\n private dataManager: DataManager;\n private visitorCodeManager: IVisitorCodeManager;\n private eventManager: EventManager;\n private urlProvider: IUrlProvider;\n\n constructor({\n updateInterval,\n urlProvider,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n eventManager,\n }: ClientConfigurationParametersType) {\n this.urlProvider = urlProvider;\n this.requester = requester;\n this.updateInterval = updateInterval;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.eventManager = eventManager;\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventSource = eventSource;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource.isOpen) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource.isOpen) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n const { customData, configuration, featureFlags } =\n this.externalClientConfiguration!;\n this.configurationData = { customData, configuration };\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok) {\n this.eventManager.fireEvent(EventType.ConfigurationUpdate, {\n timestamp,\n });\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n get featureFlags(): Map<string, FeatureFlagType> {\n return this.featureFlagsData;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n if (this.segmentsData) {\n return this.segmentsData;\n }\n\n const segmentsData = new Map<string, SegmentType>();\n\n this.featureFlagsData.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segmentsData.has(rule.segment.id)) {\n segmentsData.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n this.segmentsData = segmentsData;\n\n return segmentsData;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules?.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags.values()) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n if (this.isTargetedDeliveryRule !== null) {\n return this.isTargetedDeliveryRule;\n }\n\n for (const featureFlag of this.featureFlags.values()) {\n if (\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n )\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n // --- Note ---\n // Integrity check covers most of the migration scenarios\n // however in the future it will be changed to a dedicate migration\n // block that can handle all versions migrations\n private checkIntegrity(data: ConfigurationDataType | undefined): boolean {\n if (!data) {\n return false;\n }\n\n const fields = Object.keys(data);\n\n if (!fields.length) {\n return false;\n }\n\n const requiredFields = Object.keys(DEFAULT_CLIENT_CONFIGURATION);\n\n return fields.sort().join() === requiredFields.sort().join();\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { configuration } = this.configurationData;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!this.featureFlags.size) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - this.updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n const isStorageValid = this.checkIntegrity(data);\n\n // --- Note ---\n // Cleaning up storage if it's not valid for migration purposes\n if (!isStorageValid) {\n this.urlProvider.dataApiDomain =\n DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain;\n\n const data = {\n ...DEFAULT_CONFIGURATION_DATA,\n featureFlags: [],\n };\n\n this.storage.write({\n data,\n lastUpdate: this.lastUpdate.toString(),\n });\n\n this.configurationData = DEFAULT_CONFIGURATION_DATA;\n } else {\n this.urlProvider.dataApiDomain = data.configuration.dataApiDomain;\n\n const { featureFlags, customData } = data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n if (this.featureFlags.size) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData, featureFlags } =\n clientConfigurationResult.data;\n\n this.configurationData = { configuration, customData };\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules?.clear();\n this.isTargetedDeliveryRule = null;\n this.segmentsData = null;\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.consentRequired = consentRequired;\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const configurationData = {\n ...this.configurationData,\n featureFlags: Array.from(this.featureFlags.values()),\n };\n\n const data: ClientDataType = {\n data: configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n this.urlProvider.dataApiDomain =\n this.configurationData.configuration.dataApiDomain;\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"i3CAoCO,KAAM,CAAAA,mBAAoD,CAqB/DC,WAAWA,CAAAC,CAAA,CAW2B,IAX1B,CACVC,cAAc,CAAdA,CAAc,CACdC,WAAW,CAAXA,CAAW,CACXC,OAAO,CAAPA,CAAO,CACPC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAXA,CAAW,CACXC,2BAA2B,CAA3BA,CAA2B,CAC3BC,sBAAsB,CAAtBA,CAAsB,CACtBC,WAAW,CAAXA,CAAW,CACXC,0BAA0B,CAA1BA,CAA0B,CAC1BC,YAAY,CAAZA,CACiC,CAAC,CAAAV,CAAA,CAAAW,eAAA,sCA/B2B,IAAI,EAAAA,eAAA,mBAClCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BAE9CG,qCAA0B,EAAAH,eAAA,yBAC6B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,+BACjB,IAAI,EAAAA,eAAA,qBACG,IAAI,EAAAA,eAAA,+BAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,4CAAAA,eAAA,oBAQF,IAAI,EAAAA,eAAA,4BAAAA,eAAA,mCAAAA,eAAA,6BAAAA,eAAA,4BAkB5D,IAAI,CAACT,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACH,cAAc,CAAGA,CAAc,CACpC,IAAI,CAACe,UAAU,CAAG,GAAI,CA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BAA0B,CAG5D,MAFA,KAAI,CAACjE,kBAAkB,CAAC0G,eAAe,CAAGA,CAAe,CAElD,GAAA/F,SAAE,EAAC8F,CAAgB,CAC5B,CAEQD,iBAAiBA,CAAA,CAAiC,CACxD,IAAI,CAAC1G,UAAU,CAAG,GAAI,CAAAC,IAAM,MAEtB,CAAA2B,CAAiB,CAAAkE,aAAA,CAAAA,aAAA,IAClB,IAAI,CAAClE,iBAAiB,MACzBD,YAAY,CAAEkF,KAAK,CAACC,IAAI,CAAC,IAAI,CAACnF,YAAY,CAAC4B,MAAM,CAAC,CAAC,CAAC,EACrD,CAEK3C,CAAoB,CAAG,CAC3BA,IAAI,CAAEgB,CAAiB,CACvB5B,UAAU,CAAE,IAAI,CAACA,UAAU,CAACgG,QAAQ,CAAC,CACvC,CAAC,CAKD,MAHA,KAAI,CAAC9G,WAAW,CAAC2G,aAAa,CAC5B,IAAI,CAACjE,iBAAiB,CAACF,aAAa,CAACmE,aAAa,CAE7C,IAAI,CAAC1G,OAAO,CAAC4G,KAAK,CAACnF,CAAI,CAChC,CACF,CAACmG,OAAA,CAAAjI,mBAAA,CAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","constructor","a","updateInterval","urlProvider","storage","requester","dataManager","eventSource","externalVisitorCodeManager","eventManager","_defineProperty","UpdateType","Polling","DEFAULT_CLIENT_CONFIGURATION","Map","lastUpdate","Date","visitorCodeManager","initialize","readStorageData","shouldUpdate","checkShouldUpdate","updateResult","updateClientConfiguration","ok","isUpdateTypeToggled","data","Ok","updateType","RealTime","isOpen","handlePollingUpdates","handleRealTimeUpdates","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","updateEventCallback","timestamp","then","fireEvent","EventType","ConfigurationUpdate","open","setInterval","bind","err","featureFlags","featureFlagsData","configuration","configurationData","segments","segmentsData","forEach","flag","rules","rule","segment","has","id","set","ruleMap","mappedRules","size","featureFlag","values","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","isConsentRequired","consentType","ConsentType","Required","hasAnyTargetedDeliveryRule","isTargetedDeliveryRule","environmentEnabled","some","type","RuleType","TARGETED_DELIVERY","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","dataApiDomain","customData","length","customDataIndexes","featureKey","parse","b","clientConfigurationResult","getClientConfiguration","clearTrees","clear","updateStorageData","toggleUpdateType","consentRequired","_objectSpread","Array","from","toString","write","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { ClientDataType } from 'src/storage';\nimport { IEventSource } from 'src/eventSource';\nimport {\n ClientConfigurationDataType,\n ClientConfigurationParametersType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { IStorage } from 'src/storage/types';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { EventManager, EventType } from 'src/eventManager';\nimport { IUrlProvider } from 'src/requester/urlProvider';\nimport { DEFAULT_CLIENT_CONFIGURATION } from './constants';\n\ninterface IClientConfiguration {\n initialize: () => Promise<Result<void, KameleoonError>>;\n readonly featureFlags: Map<string, FeatureFlagType>;\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private updateConfigurationIntervalId: NodeJS.Timeout | null = null;\n private updateType: UpdateType = UpdateType.Polling;\n private configurationData: ClientConfigurationDataType =\n DEFAULT_CLIENT_CONFIGURATION;\n private featureFlagsData: Map<string, FeatureFlagType> = new Map();\n private isTargetedDeliveryRule: boolean | null = null;\n private segmentsData: Map<string, SegmentType> | null = null;\n private updateInterval: number;\n private lastUpdate: Date;\n private storage: IStorage<ClientDataType>;\n private requester: Requester;\n private eventSource: IEventSource;\n private mappedRules: Map<number, MappedRuleType> | null = null;\n private dataManager: DataManager;\n private visitorCodeManager: IVisitorCodeManager;\n private eventManager: EventManager;\n private urlProvider: IUrlProvider;\n\n constructor({\n updateInterval,\n urlProvider,\n storage,\n requester,\n dataManager,\n eventSource,\n externalVisitorCodeManager,\n eventManager,\n }: ClientConfigurationParametersType) {\n this.urlProvider = urlProvider;\n this.requester = requester;\n this.updateInterval = updateInterval;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.eventManager = eventManager;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventSource = eventSource;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const shouldUpdate = this.checkShouldUpdate();\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource.isOpen) {\n this.updateType = UpdateType.Polling;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource.isOpen) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok) {\n this.eventManager.fireEvent(EventType.ConfigurationUpdate, {\n timestamp,\n });\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n get featureFlags(): Map<string, FeatureFlagType> {\n return this.featureFlagsData;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n if (this.segmentsData) {\n return this.segmentsData;\n }\n\n const segmentsData = new Map<string, SegmentType>();\n\n this.featureFlagsData.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segmentsData.has(rule.segment.id)) {\n segmentsData.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n this.segmentsData = segmentsData;\n\n return segmentsData;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules?.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags.values()) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n if (this.isTargetedDeliveryRule !== null) {\n return this.isTargetedDeliveryRule;\n }\n\n for (const featureFlag of this.featureFlags.values()) {\n if (\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n )\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n private checkShouldUpdate(): boolean {\n const { configuration } = this.configurationData;\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!this.featureFlags.size) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - this.updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n this.urlProvider.dataApiDomain = data.configuration.dataApiDomain;\n\n const { featureFlags, customData } = data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n if (this.featureFlags.size) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n const { configuration, customData, featureFlags } =\n clientConfigurationResult.data;\n\n this.configurationData = { configuration, customData };\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules?.clear();\n this.isTargetedDeliveryRule = null;\n this.segmentsData = null;\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // According to GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.consentRequired = consentRequired;\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const configurationData = {\n ...this.configurationData,\n featureFlags: Array.from(this.featureFlags.values()),\n };\n\n const data: ClientDataType = {\n data: configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n this.urlProvider.dataApiDomain =\n this.configurationData.configuration.dataApiDomain;\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"40CA+BO,KAAM,CAAAA,mBAAoD,CAmB/DC,WAAWA,CAAAC,CAAA,CAS2B,IAT1B,CACVC,cAAc,CAAdA,CAAc,CACdC,WAAW,CAAXA,CAAW,CACXC,OAAO,CAAPA,CAAO,CACPC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAAW,CACXC,0BAA0B,CAA1BA,CAA0B,CAC1BC,YAAY,CAAZA,CACiC,CAAC,CAAAR,CAAA,CAAAS,eAAA,sCA3B2B,IAAI,EAAAA,eAAA,mBAClCC,iBAAU,CAACC,OAAO,EAAAF,eAAA,0BAEjDG,uCAA4B,EAAAH,eAAA,yBAC2B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,+BACjB,IAAI,EAAAA,eAAA,qBACG,IAAI,EAAAA,eAAA,+BAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,oBAMF,IAAI,EAAAA,eAAA,4BAAAA,eAAA,mCAAAA,eAAA,6BAAAA,eAAA,4BAgB5D,IAAI,CAACP,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACH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ACzG,WAAW,CAACwF,aAAa,CAC5B,IAAI,CAACzC,iBAAiB,CAACD,aAAa,CAAC0C,aAAa,CAE7C,IAAI,CAACvF,OAAO,CAACyG,KAAK,CAACnF,CAAI,CAChC,CACF,CAACoF,OAAA,CAAA/G,mBAAA,CAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["_types","require","Object","defineProperty","exports","value","DEFAULT_CONFIGURATION_DATA","DEFAULT_CLIENT_CONFIGURATION","customData","configuration","realTimeUpdate","consentType","ConsentType","NotRequired","dataApiDomain","featureFlags"],"sources":["../../src/clientConfiguration/constants.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n} from 'src/clientConfiguration';\nimport { ConsentType } from './types';\n\nexport const DEFAULT_CONFIGURATION_DATA: ClientConfigurationDataType = {\n customData: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: 'data.kameleoon.io',\n },\n};\n\nexport const DEFAULT_CLIENT_CONFIGURATION: ConfigurationDataType = {\n customData: [],\n featureFlags: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: 'data.kameleoon.io',\n },\n};\n"],"mappings":"aAIA,IAAAA,MAAA,CAAAC,OAAA,YAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,0BAAA,CAAAF,OAAA,CAAAG,4BAAA,aAEzB,CAAAD,0BAAuD,CAAAF,OAAA,CAAAE,0BAAA,CAAG,CACrEE,UAAU,CAAE,EAAE,CACdC,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAE,mBACjB,CACF,CAAC,CAEYP,4BAAmD,CAAAH,OAAA,CAAAG,4BAAA,CAAG,CACjEC,UAAU,CAAE,EAAE,CACdO,YAAY,CAAE,EAAE,CAChBN,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAE,mBACjB,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["_types","require","Object","defineProperty","exports","value","DEFAULT_CONFIGURATION_DATA","DEFAULT_CLIENT_CONFIGURATION","customData","configuration","realTimeUpdate","consentType","ConsentType","NotRequired","dataApiDomain","featureFlags"],"sources":["../../src/clientConfiguration/constants.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n} from 'src/clientConfiguration';\nimport { ConsentType } from './types';\n\nexport const DEFAULT_CONFIGURATION_DATA: ClientConfigurationDataType = {\n customData: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: 'data.kameleoon.io',\n },\n};\n\nexport const DEFAULT_CLIENT_CONFIGURATION: ConfigurationDataType = {\n customData: [],\n featureFlags: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: 'data.kameleoon.io',\n },\n};\n"],"mappings":"aAIA,IAAAA,MAAA,CAAAC,OAAA,YAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,0BAAA,CAAAF,OAAA,CAAAG,4BAAA,aAEzB,CAAAD,0BAAuD,CAAAF,OAAA,CAAAE,0BAAA,CAAG,CACrEE,UAAU,CAAE,EAAE,CACdC,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAE,mBACjB,CACF,CAAC,CAEYP,4BAAmD,CAAAH,OAAA,CAAAG,4BAAA,CAAG,CACjEC,UAAU,CAAE,EAAE,CACdO,YAAY,CAAE,EAAE,CAChBN,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAE,mBACjB,CACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/clientConfiguration/index.ts"],"sourcesContent":["export {\n ConfigurationDataType,\n CustomDataConfigurationType,\n ClientConfigurationDataType,\n CustomDataScope,\n VariationByExpositionType,\n FeatureVariableType,\n FeatureFlagType,\n ConsentType,\n RuleItemType,\n JSONValue,\n RuleType,\n JSONType,\n} from './types';\nexport { ClientConfiguration } from './clientConfiguration';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/clientConfiguration/index.ts"],"sourcesContent":["export {\n ConfigurationDataType,\n CustomDataConfigurationType,\n ClientConfigurationDataType,\n CustomDataScope,\n VariationByExpositionType,\n FeatureVariableType,\n FeatureFlagType,\n ConsentType,\n RuleItemType,\n JSONValue,\n RuleType,\n JSONType,\n} from './types';\nexport { ClientConfiguration } from './clientConfiguration';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { IEventSource } from '../eventSource';
|
|
|
2
2
|
import { DataManager } from '../kameleoonData';
|
|
3
3
|
import { Requester } from '../requester';
|
|
4
4
|
import { IVisitorCodeManager } from '../visitorCodeManager';
|
|
5
|
-
import { ClientDataType, IStorage
|
|
5
|
+
import { ClientDataType, IStorage } from '../storage';
|
|
6
6
|
import { SegmentType } from '../targeting';
|
|
7
7
|
import { VariableType } from '../types';
|
|
8
8
|
import { EventManager } from '../eventManager';
|
|
@@ -13,8 +13,7 @@ export type ScheduleType = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare enum UpdateType {
|
|
15
15
|
Polling = 0,
|
|
16
|
-
RealTime = 1
|
|
17
|
-
Idle = 2
|
|
16
|
+
RealTime = 1
|
|
18
17
|
}
|
|
19
18
|
export type JSONValue = string | number | boolean | {
|
|
20
19
|
[x: string]: JSONValue;
|
|
@@ -116,7 +115,5 @@ export type ClientConfigurationParametersType = {
|
|
|
116
115
|
requester: Requester;
|
|
117
116
|
eventSource: IEventSource;
|
|
118
117
|
eventManager: EventManager;
|
|
119
|
-
offlineTrackingStorage: IStorage<OfflineTracking>;
|
|
120
|
-
externalClientConfiguration?: ConfigurationDataType;
|
|
121
118
|
externalVisitorCodeManager: IVisitorCodeManager;
|
|
122
119
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UpdateType=exports.RuleType=exports.FeatureStatus=exports.FeatureFlagSdkLanguageType=exports.CustomDataScope=exports.ConsentType=void 0;let UpdateType=exports.UpdateType=function(a){return a[a.Polling=0]="Polling",a[a.RealTime=1]="RealTime",a
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UpdateType=exports.RuleType=exports.FeatureStatus=exports.FeatureFlagSdkLanguageType=exports.CustomDataScope=exports.ConsentType=void 0;let UpdateType=exports.UpdateType=function(a){return a[a.Polling=0]="Polling",a[a.RealTime=1]="RealTime",a}({}),RuleType=exports.RuleType=function(a){return a.TARGETED_DELIVERY="TARGETED_DELIVERY",a.EXPERIMENTATION="EXPERIMENTATION",a}({}),FeatureFlagSdkLanguageType=exports.FeatureFlagSdkLanguageType=function(a){return a.ANDROID="ANDROID",a.SWIFT="SWIFT",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACTJS="REACTJS",a}({}),FeatureStatus=exports.FeatureStatus=function(a){return a.ACTIVATED="ACTIVATED",a.DEACTIVATED="DEACTIVATED",a.SCHEDULED="SCHEDULED",a}({}),CustomDataScope=exports.CustomDataScope=function(a){return a.Visit="VISIT",a.Visitor="VISITOR",a.Page="Page",a}({}),ConsentType=exports.ConsentType=function(a){return a.Required="REQUIRED",a.NotRequired="NOT_REQUIRED",a}({});
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["UpdateType","exports","Polling","RealTime","
|
|
1
|
+
{"version":3,"file":"types.js","names":["UpdateType","exports","Polling","RealTime","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 { IEventSource } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { ClientDataType, IStorage } from 'src/storage';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\nimport { EventManager } from 'src/eventManager';\nimport { IUrlProvider } from 'src/requester/urlProvider';\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\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 ClientConfigurationDataType = Omit<\n ConfigurationDataType,\n 'featureFlags'\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 consentType: ConsentType;\n dataApiDomain: string;\n};\n\nexport type ClientConfigurationParametersType = {\n urlProvider: IUrlProvider;\n updateInterval: number;\n storage: IStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n eventSource: IEventSource;\n eventManager: EventManager;\n externalVisitorCodeManager: IVisitorCodeManager;\n};\n"],"mappings":"uNAeY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAE,OAAA,cAAVF,CAAU,CAAVA,CAAU,CAAAG,QAAA,eAAVH,CAAU,MAcVI,QAAQ,CAAAH,OAAA,CAAAG,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAKRG,0BAA0B,CAAAN,OAAA,CAAAM,0BAAA,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,MAa1BW,aAAa,CAAAjB,OAAA,CAAAiB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAMbI,eAAe,CAAArB,OAAA,CAAAqB,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAMfI,WAAW,CAAAzB,OAAA,CAAAyB,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW","ignoreList":[]}
|
|
@@ -10,9 +10,10 @@ export declare class ClientSettings implements IClientSettings {
|
|
|
10
10
|
private requestTimeout;
|
|
11
11
|
private siteCode;
|
|
12
12
|
private cleanupInterval;
|
|
13
|
-
private configuration?;
|
|
14
13
|
private trackRetryDelay;
|
|
14
|
+
private trackingInterval;
|
|
15
15
|
constructor(siteCode: string, configuration?: Partial<SDKConfigurationType>);
|
|
16
|
+
private getTrackingInterval;
|
|
16
17
|
private getEnvironment;
|
|
17
18
|
private getCleanupInterval;
|
|
18
19
|
private getUpdateInterval;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class ClientSettings{constructor(a,b){_defineProperty(this,"updateInterval",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"networkDomain",void 0),_defineProperty(this,"requestTimeout",void 0),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"cleanupInterval",void 0),_defineProperty(this,"trackRetryDelay",void 0),_defineProperty(this,"trackingInterval",void 0),this.siteCode=a,this.environment=this.getEnvironment(b),this.networkDomain=this.getNetworkDomain(b),this.updateInterval=this.getUpdateInterval(b),this.cleanupInterval=this.getCleanupInterval(b),this.requestTimeout=this.getRequestTimeout(b),this.trackingInterval=this.getTrackingInterval(b),this.trackRetryDelay=5*_types.Milliseconds.Second}getTrackingInterval(a){return"number"==typeof(null===a||void 0===a?void 0:a.trackingInterval)?100>a.trackingInterval?100:1e3<a.trackingInterval?1e3:a.trackingInterval:1e3}getEnvironment(a){return null!==a&&void 0!==a&&a.environment?a.environment:_types.Environment.Production}getCleanupInterval(a){return"number"==typeof(null===a||void 0===a?void 0:a.targetingDataCleanupInterval)?1>a.targetingDataCleanupInterval?1*_types.Milliseconds.Minute:a.targetingDataCleanupInterval*_types.Milliseconds.Minute:null}getUpdateInterval(a){return"number"==typeof(null===a||void 0===a?void 0:a.updateInterval)?1>a.updateInterval?1*_types.Milliseconds.Minute:a.updateInterval*_types.Milliseconds.Minute:60*_types.Milliseconds.Minute}getNetworkDomain(a){if(null!==a&&void 0!==a&&a.networkDomain){const b=a.networkDomain.split(".");return 2===b.length?a.networkDomain:null}return null}getRequestTimeout(a){return"number"==typeof(null===a||void 0===a?void 0:a.requestTimeout)?a.requestTimeout:10*_types.Milliseconds.Second}get settings(){return{trackRetryDelay:this.trackRetryDelay,cleanupInterval:this.cleanupInterval,updateInterval:this.updateInterval,requestTimeout:this.requestTimeout,networkDomain:this.networkDomain,trackingInterval:this.trackingInterval,environment:this.environment,siteCode:this.siteCode}}}exports.ClientSettings=ClientSettings;
|
|
2
2
|
//# sourceMappingURL=clientSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSettings.js","names":["_types","require","Object","defineProperty","exports","value","ClientSettings","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","siteCode","configuration","environment","getEnvironment","networkDomain","getNetworkDomain","updateInterval","getUpdateInterval","cleanupInterval","getCleanupInterval","requestTimeout","getRequestTimeout","trackRetryDelay","Milliseconds","Second","Environment","Production","targetingDataCleanupInterval","Minute","parts","split","length","settings"],"sources":["../../src/clientSettings/clientSettings.ts"],"sourcesContent":["import { Environment, Milliseconds, SDKConfigurationType } from 'src/types';\nimport { ClientSettingsType } from './types';\n\nexport interface IClientSettings {\n readonly settings: ClientSettingsType;\n}\n\nexport class ClientSettings implements IClientSettings {\n private updateInterval: number;\n private environment: Environment;\n private networkDomain: string | null;\n private requestTimeout: number;\n private siteCode: string;\n private cleanupInterval: number | null;\n private
|
|
1
|
+
{"version":3,"file":"clientSettings.js","names":["_types","require","Object","defineProperty","exports","value","ClientSettings","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","siteCode","configuration","environment","getEnvironment","networkDomain","getNetworkDomain","updateInterval","getUpdateInterval","cleanupInterval","getCleanupInterval","requestTimeout","getRequestTimeout","trackingInterval","getTrackingInterval","trackRetryDelay","Milliseconds","Second","Environment","Production","targetingDataCleanupInterval","Minute","parts","split","length","settings"],"sources":["../../src/clientSettings/clientSettings.ts"],"sourcesContent":["import { Environment, Milliseconds, SDKConfigurationType } from 'src/types';\nimport { ClientSettingsType } from './types';\n\nexport interface IClientSettings {\n readonly settings: ClientSettingsType;\n}\n\nexport class ClientSettings implements IClientSettings {\n private updateInterval: number;\n private environment: Environment;\n private networkDomain: string | null;\n private requestTimeout: number;\n private siteCode: string;\n private cleanupInterval: number | null;\n private trackRetryDelay: number;\n private trackingInterval: number;\n\n constructor(siteCode: string, configuration?: Partial<SDKConfigurationType>) {\n this.siteCode = siteCode;\n\n this.environment = this.getEnvironment(configuration);\n this.networkDomain = this.getNetworkDomain(configuration);\n this.updateInterval = this.getUpdateInterval(configuration);\n this.cleanupInterval = this.getCleanupInterval(configuration);\n this.requestTimeout = this.getRequestTimeout(configuration);\n this.trackingInterval = this.getTrackingInterval(configuration);\n\n this.trackRetryDelay = 5 * Milliseconds.Second;\n }\n\n private getTrackingInterval(\n configuration?: Partial<SDKConfigurationType>,\n ): number {\n if (typeof configuration?.trackingInterval === 'number') {\n if (configuration.trackingInterval < 100) {\n return 100;\n }\n\n if (configuration.trackingInterval > 1_000) {\n return 1_000;\n }\n\n return configuration.trackingInterval;\n }\n\n return 1_000;\n }\n\n private getEnvironment(\n configuration?: Partial<SDKConfigurationType>,\n ): Environment {\n if (configuration?.environment) {\n return configuration.environment;\n }\n\n return Environment.Production;\n }\n\n private getCleanupInterval(\n configuration?: Partial<SDKConfigurationType>,\n ): number | null {\n if (typeof configuration?.targetingDataCleanupInterval === 'number') {\n if (configuration.targetingDataCleanupInterval < 1) {\n return 1 * Milliseconds.Minute;\n }\n\n return configuration.targetingDataCleanupInterval * Milliseconds.Minute;\n }\n\n return null;\n }\n\n private getUpdateInterval(\n configuration?: Partial<SDKConfigurationType>,\n ): number {\n if (typeof configuration?.updateInterval === 'number') {\n if (configuration.updateInterval < 1) {\n return 1 * Milliseconds.Minute;\n }\n\n return configuration.updateInterval * Milliseconds.Minute;\n }\n\n return 60 * Milliseconds.Minute;\n }\n\n private getNetworkDomain(\n configuration?: Partial<SDKConfigurationType>,\n ): string | null {\n if (configuration?.networkDomain) {\n const parts = configuration.networkDomain.split('.');\n\n if (parts.length !== 2) {\n return null;\n }\n\n return configuration.networkDomain;\n }\n\n return null;\n }\n\n private getRequestTimeout(\n configuration?: Partial<SDKConfigurationType>,\n ): number {\n if (typeof configuration?.requestTimeout === 'number') {\n return configuration.requestTimeout;\n }\n\n return 10 * Milliseconds.Second;\n }\n\n get settings(): ClientSettingsType {\n return {\n trackRetryDelay: this.trackRetryDelay,\n cleanupInterval: this.cleanupInterval,\n updateInterval: this.updateInterval,\n requestTimeout: this.requestTimeout,\n networkDomain: this.networkDomain,\n trackingInterval: this.trackingInterval,\n environment: this.environment,\n siteCode: this.siteCode,\n };\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,aAA4EC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,cAAA,iBAAAC,gBAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAD,CAAA,CAAAE,cAAA,CAAAF,CAAA,KAAAD,CAAA,CAAAN,MAAA,CAAAC,cAAA,CAAAK,CAAA,CAAAC,CAAA,EAAAJ,KAAA,CAAAK,CAAA,CAAAE,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAN,CAAA,CAAAC,CAAA,EAAAC,CAAA,CAAAF,CAAA,UAAAG,eAAAH,CAAA,MAAAC,CAAA,CAAAM,YAAA,CAAAP,CAAA,kCAAAC,CAAA,CAAAA,CAAA,CAAAA,CAAA,aAAAM,aAAAP,CAAA,CAAAC,CAAA,sBAAAD,CAAA,GAAA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MAAO,CACLV,eAAe,CAAE,IAAI,CAACA,eAAe,CACrCN,eAAe,CAAE,IAAI,CAACA,eAAe,CACrCF,cAAc,CAAE,IAAI,CAACA,cAAc,CACnCI,cAAc,CAAE,IAAI,CAACA,cAAc,CACnCN,aAAa,CAAE,IAAI,CAACA,aAAa,CACjCQ,gBAAgB,CAAE,IAAI,CAACA,gBAAgB,CACvCV,WAAW,CAAE,IAAI,CAACA,WAAW,CAC7BF,QAAQ,CAAE,IAAI,CAACA,QACjB,CACF,CACF,CAACpB,OAAA,CAAAE,cAAA,CAAAA,cAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/clientSettings/index.ts"],"sourcesContent":["export { ClientSettings } from './clientSettings';\nexport { ClientSettingsType } from './types';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/clientSettings/index.ts"],"sourcesContent":["export { ClientSettings } from './clientSettings';\nexport { ClientSettingsType } from './types';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/clientSettings/types.ts"],"sourcesContent":["import { Environment } from 'src/types';\n\nexport type ClientSettingsType = {\n updateInterval: number;\n environment: Environment;\n siteCode: string;\n cleanupInterval: number | null;\n networkDomain: string | null;\n requestTimeout: number;\n trackRetryDelay: number;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/clientSettings/types.ts"],"sourcesContent":["import { Environment } from 'src/types';\n\nexport type ClientSettingsType = {\n updateInterval: number;\n environment: Environment;\n siteCode: string;\n cleanupInterval: number | null;\n networkDomain: string | null;\n requestTimeout: number;\n trackRetryDelay: number;\n trackingInterval: number;\n};\n"],"mappings":"","ignoreList":[]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { VisitorDataFiltersType } from './utilities/types';
|
|
2
2
|
export declare const OFF_VARIATION_KEY = "off";
|
|
3
3
|
export declare const WAREHOUSE_AUDIENCE_KEY = "warehouseAudiences";
|
|
4
|
-
export declare const VISITOR_CODE_LENGTH = 16;
|
|
5
4
|
export declare const CACHE_CLEANUP_TIMEOUT = 10;
|
|
6
5
|
export declare const CACHE_ITEM_LIFETIME = 5;
|
|
7
6
|
/**
|
package/dist/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.DEFAULT_VISITOR_DATA_FILTERS=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;const OFF_VARIATION_KEY=exports.OFF_VARIATION_KEY="off",WAREHOUSE_AUDIENCE_KEY=exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences",CACHE_CLEANUP_TIMEOUT=exports.CACHE_CLEANUP_TIMEOUT=10,CACHE_ITEM_LIFETIME=exports.CACHE_ITEM_LIFETIME=5;let SdkLanguageType=exports.SdkLanguageType=function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});const DEFAULT_VISITOR_DATA_FILTERS=exports.DEFAULT_VISITOR_DATA_FILTERS={previousVisitAmount:1,currentVisit:!0,customData:!0,pageViews:!1,geolocation:!1,device:!1,browser:!1,operatingSystem:!1,conversions:!1,experiments:!1,kcs:!1};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","WAREHOUSE_AUDIENCE_KEY","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","WAREHOUSE_AUDIENCE_KEY","CACHE_CLEANUP_TIMEOUT","CACHE_ITEM_LIFETIME","SdkLanguageType","ANDROID","IOS","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACT","PYTHON","JAVASCRIPT","RUST","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","currentVisit","customData","pageViews","geolocation","device","browser","operatingSystem","conversions","experiments","kcs"],"sources":["../src/constants.ts"],"sourcesContent":["import { VisitorDataFiltersType } from './utilities/types';\n\nexport const OFF_VARIATION_KEY = 'off';\nexport const WAREHOUSE_AUDIENCE_KEY = 'warehouseAudiences';\nexport const CACHE_CLEANUP_TIMEOUT = 10;\nexport const CACHE_ITEM_LIFETIME = 5;\n\n/**\n * @readonly\n * @enum {string} an Enum of all the possible Kameleoon SDK types\n * */\nexport enum SdkLanguageType {\n ANDROID = 'ANDROID',\n IOS = 'IOS',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACT = 'REACT',\n PYTHON = 'PYTHON',\n JAVASCRIPT = 'JAVASCRIPT',\n RUST = 'RUST',\n}\n\nexport const DEFAULT_VISITOR_DATA_FILTERS: VisitorDataFiltersType = {\n previousVisitAmount: 1,\n currentVisit: true,\n customData: true,\n pageViews: false,\n geolocation: false,\n device: false,\n browser: false,\n operatingSystem: false,\n conversions: false,\n experiments: false,\n kcs: false,\n};\n"],"mappings":"gQAEa,CAAAA,iBAAiB,CAAAC,OAAA,CAAAD,iBAAA,CAAG,KAAK,CACzBE,sBAAsB,CAAAD,OAAA,CAAAC,sBAAA,CAAG,oBAAoB,CAC7CC,qBAAqB,CAAAF,OAAA,CAAAE,qBAAA,CAAG,EAAE,CAC1BC,mBAAmB,CAAAH,OAAA,CAAAG,mBAAA,CAAG,CAAC,IAMxB,CAAAC,eAAe,CAAAJ,OAAA,CAAAI,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,OAAA,WAAfD,CAAe,CAAAE,GAAA,OAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,CAAAI,MAAA,UAAfJ,CAAe,CAAAK,MAAA,UAAfL,CAAe,CAAAM,GAAA,OAAfN,CAAe,CAAAO,IAAA,QAAfP,CAAe,CAAAQ,EAAA,MAAfR,CAAe,CAAAS,OAAA,WAAfT,CAAe,CAAAU,KAAA,SAAfV,CAAe,CAAAW,MAAA,UAAfX,CAAe,CAAAY,UAAA,cAAfZ,CAAe,CAAAa,IAAA,QAAfb,CAAe,MAgBpB,KAAM,CAAAc,4BAAoD,CAAAlB,OAAA,CAAAkB,4BAAA,CAAG,CAClEC,mBAAmB,CAAE,CAAC,CACtBC,YAAY,GAAM,CAClBC,UAAU,GAAM,CAChBC,SAAS,GAAO,CAChBC,WAAW,GAAO,CAClBC,MAAM,GAAO,CACbC,OAAO,GAAO,CACdC,eAAe,GAAO,CACtBC,WAAW,GAAO,CAClBC,WAAW,GAAO,CAClBC,GAAG,GACL,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventManager=void 0;function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventManager=void 0;function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class EventManager{constructor(){_defineProperty(this,"eventHandlers",void 0)}addEventHandler(a,b){this.eventHandlers||(this.eventHandlers=new Map),this.eventHandlers.set(a,b)}fireEvent(a,b){var c;const d=null===(c=this.eventHandlers)||void 0===c?void 0:c.get(a);d&&b&&d(b)}}exports.EventManager=EventManager;
|
|
2
2
|
//# sourceMappingURL=eventManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventManager.js","names":["EventManager","constructor","_defineProperty","addEventHandler","eventType","callback","eventHandlers","Map","set","fireEvent","data","c","eventHandler","get","exports"],"sources":["../../src/eventManager/eventManager.ts"],"sourcesContent":["import { EventCallbackType, EventDataType, EventType } from './types';\n\ninterface IEventManager<E extends EventType = EventType> {\n addEventHandler(eventType: E, callback: EventCallbackType<E>): void;\n fireEvent(eventType: E, data: EventDataType[E]): void;\n}\n\nexport class EventManager implements IEventManager {\n private eventHandlers?: Map<EventType, EventCallbackType<EventType>>;\n\n public addEventHandler<E extends EventType>(\n eventType: E,\n callback: EventCallbackType<E>,\n ): void {\n if (!this.eventHandlers) {\n this.eventHandlers = new Map();\n }\n\n this.eventHandlers.set(eventType, callback as EventCallbackType<EventType>);\n }\n\n public fireEvent<E extends EventType>(\n eventType: E,\n data: EventDataType[E],\n ): void {\n const eventHandler = this.eventHandlers?.get(eventType);\n\n if (eventHandler && data) {\n eventHandler(data);\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventManager.js","names":["EventManager","constructor","_defineProperty","addEventHandler","eventType","callback","eventHandlers","Map","set","fireEvent","data","c","eventHandler","get","exports"],"sources":["../../src/eventManager/eventManager.ts"],"sourcesContent":["import { EventCallbackType, EventDataType, EventType } from './types';\n\ninterface IEventManager<E extends EventType = EventType> {\n addEventHandler(eventType: E, callback: EventCallbackType<E>): void;\n fireEvent(eventType: E, data: EventDataType[E]): void;\n}\n\nexport class EventManager implements IEventManager {\n private eventHandlers?: Map<EventType, EventCallbackType<EventType>>;\n\n public addEventHandler<E extends EventType>(\n eventType: E,\n callback: EventCallbackType<E>,\n ): void {\n if (!this.eventHandlers) {\n this.eventHandlers = new Map();\n }\n\n this.eventHandlers.set(eventType, callback as EventCallbackType<EventType>);\n }\n\n public fireEvent<E extends EventType>(\n eventType: E,\n data: EventDataType[E],\n ): void {\n const eventHandler = this.eventHandlers?.get(eventType);\n\n if (eventHandler && data) {\n eventHandler(data);\n }\n }\n}\n"],"mappings":"imBAOO,KAAM,CAAAA,YAAsC,CAAAC,YAAA,EAAAC,eAAA,8BAG1CC,eAAeA,CACpBC,CAAY,CACZC,CAA8B,CACxB,CACD,IAAI,CAACC,aAAa,GACrB,IAAI,CAACA,aAAa,CAAG,GAAI,CAAAC,GAAK,EAGhC,IAAI,CAACD,aAAa,CAACE,GAAG,CAACJ,CAAS,CAAEC,CAAwC,CAC5E,CAEOI,SAASA,CACdL,CAAY,CACZM,CAAsB,CAChB,KAAAC,CAAA,CACN,KAAM,CAAAC,CAAY,SAAAD,CAAA,CAAG,IAAI,CAACL,aAAa,YAAAK,CAAA,QAAlBA,CAAA,CAAoBE,GAAG,CAACT,CAAS,CAAC,CAEnDQ,CAAY,EAAIF,CAAI,EACtBE,CAAY,CAACF,CAAI,CAErB,CACF,CAACI,OAAA,CAAAd,YAAA,CAAAA,YAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/eventManager/index.ts"],"sourcesContent":["export { EventManager } from './eventManager';\nexport {\n EventType,\n EventDataType,\n EventCallbackType,\n EvaluationEventDataType,\n ConfigurationUpdateEventDataType,\n} from './types';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/eventManager/index.ts"],"sourcesContent":["export { EventManager } from './eventManager';\nexport {\n EventType,\n EventDataType,\n EventCallbackType,\n EvaluationEventDataType,\n ConfigurationUpdateEventDataType,\n} from './types';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["EventType","exports","Evaluation","ConfigurationUpdate"],"sources":["../../src/eventManager/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of event types\n * */\nexport enum EventType {\n Evaluation = 'evaluation',\n ConfigurationUpdate = 'configurationUpdate',\n}\n\n/**\n * @type EvaluationEventDataType - object containing information about the evaluation event data\n * */\nexport type EvaluationEventDataType = {\n featureKey: string;\n variation: {\n experimentId: number | null;\n id: number | null;\n key: string;\n };\n};\n\n/**\n * @type ConfigurationUpdateEventDataType - object containing information about the configuration update event data\n * */\nexport type ConfigurationUpdateEventDataType = {\n timestamp: number;\n};\n\n/**\n * @type EventDataType - mapped type containing the link between `EventType` and the corresponding data type\n * */\nexport type EventDataType = {\n [EventType.Evaluation]: EvaluationEventDataType;\n [EventType.ConfigurationUpdate]: ConfigurationUpdateEventDataType;\n};\n\n/**\n * @type EventCallbackType - a function that takes `EventDataType<EventType>` as an argument and returns `void`\n * */\nexport type EventCallbackType<E extends EventType> = (\n eventData: EventDataType[E],\n) => void;\n"],"mappings":"gGAIY,CAAAA,SAAS,CAAAC,OAAA,CAAAD,SAAA,UAATA,CAAS,QAAT,CAAAA,CAAS,CAAAE,UAAA,cAATF,CAAS,CAAAG,mBAAA,uBAATH,CAAS"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["EventType","exports","Evaluation","ConfigurationUpdate"],"sources":["../../src/eventManager/types.ts"],"sourcesContent":["/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of event types\n * */\nexport enum EventType {\n Evaluation = 'evaluation',\n ConfigurationUpdate = 'configurationUpdate',\n}\n\n/**\n * @type EvaluationEventDataType - object containing information about the evaluation event data\n * */\nexport type EvaluationEventDataType = {\n featureKey: string;\n variation: {\n experimentId: number | null;\n id: number | null;\n key: string;\n };\n};\n\n/**\n * @type ConfigurationUpdateEventDataType - object containing information about the configuration update event data\n * */\nexport type ConfigurationUpdateEventDataType = {\n timestamp: number;\n};\n\n/**\n * @type EventDataType - mapped type containing the link between `EventType` and the corresponding data type\n * */\nexport type EventDataType = {\n [EventType.Evaluation]: EvaluationEventDataType;\n [EventType.ConfigurationUpdate]: ConfigurationUpdateEventDataType;\n};\n\n/**\n * @type EventCallbackType - a function that takes `EventDataType<EventType>` as an argument and returns `void`\n * */\nexport type EventCallbackType<E extends EventType> = (\n eventData: EventDataType[E],\n) => void;\n"],"mappings":"gGAIY,CAAAA,SAAS,CAAAC,OAAA,CAAAD,SAAA,UAATA,CAAS,QAAT,CAAAA,CAAS,CAAAE,UAAA,cAATF,CAAS,CAAAG,mBAAA,uBAATH,CAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["REAL_TIME_EVENT","exports"],"sources":["../../src/eventSource/constants.ts"],"sourcesContent":["export const REAL_TIME_EVENT = 'configuration-update-event';\n"],"mappings":"mGAAO,KAAM,CAAAA,eAAe,CAAAC,OAAA,CAAAD,eAAA,CAAG,4BAA4B"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["REAL_TIME_EVENT","exports"],"sources":["../../src/eventSource/constants.ts"],"sourcesContent":["export const REAL_TIME_EVENT = 'configuration-update-event';\n"],"mappings":"mGAAO,KAAM,CAAAA,eAAe,CAAAC,OAAA,CAAAD,eAAA,CAAG,4BAA4B","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _constants=require("./constants");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonEventSource=void 0;function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";var _constants=require("./constants");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonEventSource=void 0;function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class KameleoonEventSource{constructor(a){let{siteCode:b,externalEventSource:c,urlProvider:d}=a;_defineProperty(this,"eventSource",void 0),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"isConnectionOpen",void 0),this.url=d.getEventSourceUrl(),this.siteCode=b,this.eventSource=c,this.isConnectionOpen=!1}get isOpen(){return this.isConnectionOpen}open(a){this.eventSource.open({onEvent:this.handleMessage(a),url:this.url,eventType:_constants.REAL_TIME_EVENT}),this.isConnectionOpen=!0}close(){this.eventSource.close(),this.isConnectionOpen=!1}handleMessage(a){const b=b=>{const c=JSON.parse(b.data),{siteCode:d,ts:e}=c;this.siteCode===d&&a(e)};return b}}exports.KameleoonEventSource=KameleoonEventSource;
|
|
2
2
|
//# sourceMappingURL=eventSource.js.map
|