@kameleoon/javascript-sdk 3.4.7 → 4.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 +45 -0
- package/dist/constants.js.map +1 -1
- package/dist/eventSource.js +1 -1
- package/dist/eventSource.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +0 -12
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/prng.js.map +1 -1
- package/dist/requester.js.map +1 -1
- package/dist/storage.js +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/visitorCodeManager.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.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
|
+
- Updated dependencies
|
|
10
|
+
- @kameleoon/javascript-sdk-core@5.0.1
|
|
11
|
+
|
|
12
|
+
[Targeting Conditions]: https://developers.kameleoon.com/feature-management-and-experimentation/using-visit-history-in-feature-flags-and-experiments#benefits-of-calling-getremotevisitordata
|
|
13
|
+
|
|
14
|
+
## 4.0.0 (2024-10-03)
|
|
15
|
+
|
|
16
|
+
### Breaking Changes
|
|
17
|
+
|
|
18
|
+
- `isUniqueIdentifier` parameter has been removed from methods [`flush`][flush], [`getRemoteVisitorData`][getremotevisitordata] and [`trackConversion`][trackconversion]
|
|
19
|
+
- Previously deprecated method [`onConfigurationUpdate`][onconfigurationupdate] has been removed from SDKs. Use [`onEvent`][onevent] method with `EventType.ConfigurationUpdate` to achieve the same effect.
|
|
20
|
+
- Previously deprecated field [`domain`][domain] of `SDKConfiguration` has been removed from SDKs. Use [`cookieDomain`][domain] field of `SDKConfiguration` instead.
|
|
21
|
+
- 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.
|
|
22
|
+
- Method [`initialize`][initialize] no more accepts `useCache` boolean parameter. Using storage cached client configuration on failed configuration request is now default behavior.
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
- Added new [`UniqueIdentifier`][uniqueidentifier] data to be used instead of removed `isUniqueIdentifier` parameters in some methods
|
|
27
|
+
- 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
|
|
28
|
+
- `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
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [`getEngineTrackingCode`][getenginetrackingcode] method now correctly sets `triggerExperiment` parameter based on variable types
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @kameleoon/javascript-sdk-core@5.0.0
|
|
35
|
+
|
|
36
|
+
[uniqueidentifier]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#uniqueidentifier
|
|
37
|
+
[sdkconfiguration]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#arguments
|
|
38
|
+
[flush]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#flush
|
|
39
|
+
[getremotevisitordata]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getremotevisitordata
|
|
40
|
+
[trackconversion]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#trackconversion
|
|
41
|
+
[onconfigurationupdate]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#onconfigurationupdate
|
|
42
|
+
[onevent]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#onevent
|
|
43
|
+
[domain]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#configuration-parameters
|
|
44
|
+
[requester]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#requester
|
|
45
|
+
[initialize]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#initialize
|
|
46
|
+
[getenginetrackingcode]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getenginetrackingcode
|
|
47
|
+
|
|
3
48
|
## 3.4.7 (2024-08-30)
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["CookieParameter","exports","PairsDelimiter","KeyValueDelimiter","MaxAge","Path","Domain"],"sources":["../src/constants.ts"],"sourcesContent":["export enum CookieParameter {\n PairsDelimiter = '; ',\n KeyValueDelimiter = '=',\n MaxAge = 'Max-Age',\n Path = 'Path',\n Domain = 'Domain',\n}\n"],"mappings":"sGAAY,CAAAA,eAAe,CAAAC,OAAA,CAAAD,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAE,cAAA,MAAfF,CAAe,CAAAG,iBAAA,KAAfH,CAAe,CAAAI,MAAA,WAAfJ,CAAe,CAAAK,IAAA,QAAfL,CAAe,CAAAM,MAAA,UAAfN,CAAe"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["CookieParameter","exports","PairsDelimiter","KeyValueDelimiter","MaxAge","Path","Domain"],"sources":["../src/constants.ts"],"sourcesContent":["export enum CookieParameter {\n PairsDelimiter = '; ',\n KeyValueDelimiter = '=',\n MaxAge = 'Max-Age',\n Path = 'Path',\n Domain = 'Domain',\n}\n"],"mappings":"sGAAY,CAAAA,eAAe,CAAAC,OAAA,CAAAD,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAE,cAAA,MAAfF,CAAe,CAAAG,iBAAA,KAAfH,CAAe,CAAAI,MAAA,WAAfJ,CAAe,CAAAK,IAAA,QAAfL,CAAe,CAAAM,MAAA,UAAfN,CAAe","ignoreList":[]}
|
package/dist/eventSource.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonEventSource=void 0;function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";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(){_defineProperty(this,"eventSource",void 0)}open(a){let{eventType:b,onEvent:c,url:d}=a;const e=new EventSource(d);this.eventSource=e,this.eventSource.addEventListener(b,c)}close(){this.eventSource&&this.eventSource.close()}}exports.KameleoonEventSource=KameleoonEventSource;
|
|
2
2
|
//# sourceMappingURL=eventSource.js.map
|
package/dist/eventSource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventSource.js","names":["KameleoonEventSource","constructor","_defineProperty","open","a","eventType","onEvent","url","eventSource","EventSource","addEventListener","close","exports"],"sources":["../src/eventSource.ts"],"sourcesContent":["import {\n IExternalEventSource,\n EventSourceOpenParametersType,\n} from '@kameleoon/javascript-sdk-core';\n\n// --- Note ---\n// Named `KameleoonEventSource` to avoid collision with native `EventSource`\nexport class KameleoonEventSource implements IExternalEventSource {\n private eventSource?: EventSource;\n\n public open({\n eventType,\n onEvent,\n url,\n }: EventSourceOpenParametersType): void {\n const eventSource = new EventSource(url);\n\n this.eventSource = eventSource;\n this.eventSource.addEventListener(eventType, onEvent);\n }\n\n public close(): void {\n if (this.eventSource) {\n this.eventSource.close();\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventSource.js","names":["KameleoonEventSource","constructor","_defineProperty","open","a","eventType","onEvent","url","eventSource","EventSource","addEventListener","close","exports"],"sources":["../src/eventSource.ts"],"sourcesContent":["import {\n IExternalEventSource,\n EventSourceOpenParametersType,\n} from '@kameleoon/javascript-sdk-core';\n\n// --- Note ---\n// Named `KameleoonEventSource` to avoid collision with native `EventSource`\nexport class KameleoonEventSource implements IExternalEventSource {\n private eventSource?: EventSource;\n\n public open({\n eventType,\n onEvent,\n url,\n }: EventSourceOpenParametersType): void {\n const eventSource = new EventSource(url);\n\n this.eventSource = eventSource;\n this.eventSource.addEventListener(eventType, onEvent);\n }\n\n public close(): void {\n if (this.eventSource) {\n this.eventSource.close();\n }\n }\n}\n"],"mappings":"ymBAOO,KAAM,CAAAA,oBAAqD,CAAAC,YAAA,EAAAC,eAAA,4BAGzDC,IAAIA,CAAAC,CAAA,CAI6B,IAJ5B,CACVC,SAAS,CAATA,CAAS,CACTC,OAAO,CAAPA,CAAO,CACPC,GAAG,CAAHA,CAC6B,CAAC,CAAAH,CAAA,CAC9B,KAAM,CAAAI,CAAW,CAAG,GAAI,CAAAC,WAAW,CAACF,CAAG,CAAC,CAExC,IAAI,CAACC,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACA,WAAW,CAACE,gBAAgB,CAACL,CAAS,CAAEC,CAAO,CACtD,CAEOK,KAAKA,CAAA,CAAS,CACf,IAAI,CAACH,WAAW,EAClB,IAAI,CAACA,WAAW,CAACG,KAAK,CAAC,CAE3B,CACF,CAACC,OAAA,CAAAZ,oBAAA,CAAAA,oBAAA","ignoreList":[]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_javascriptSdkCore","require","_kameleoonClient","Object","defineProperty","exports","value","enumerable","get","KameleoonClient","keys","forEach","a","prototype","hasOwnProperty","call","_exportNames"],"sources":["../src/index.ts"],"sourcesContent":["export * from '@kameleoon/javascript-sdk-core';\nexport type {\n ExternalsType,\n SDKParameters,\n SetDataParametersType,\n IExternalVisitorCodeManager,\n} from './types';\nexport { KameleoonClient } from './kameleoonClient';\n"],"mappings":"mDAAA,IAAAA,kBAAA,CAAAC,OAAA,mCAOA,IAAAC,gBAAA,CAAAD,OAAA,sBAAoDE,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAH,MAAA,CAAAC,cAAA,CAAAC,OAAA,oBAAAE,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAN,gBAAA,CAAAO,eAAA,IAAAN,MAAA,CAAAO,IAAA,CAAAV,kBAAA,EAAAW,OAAA,UAAAC,CAAA,cAAAA,CAAA,iBAAAA,CAAA,EAAAT,MAAA,CAAAU,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,CAAAJ,CAAA,GAAAA,CAAA,IAAAP,OAAA,EAAAA,OAAA,CAAAO,CAAA,IAAAZ,kBAAA,CAAAY,CAAA,GAAAT,MAAA,CAAAC,cAAA,CAAAC,OAAA,CAAAO,CAAA,EAAAL,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAR,kBAAA,CAAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_javascriptSdkCore","require","_kameleoonClient","Object","defineProperty","exports","value","enumerable","get","KameleoonClient","keys","forEach","a","prototype","hasOwnProperty","call","_exportNames"],"sources":["../src/index.ts"],"sourcesContent":["export * from '@kameleoon/javascript-sdk-core';\nexport type {\n ExternalsType,\n SDKParameters,\n SetDataParametersType,\n IExternalVisitorCodeManager,\n} from './types';\nexport { KameleoonClient } from './kameleoonClient';\n"],"mappings":"mDAAA,IAAAA,kBAAA,CAAAC,OAAA,mCAOA,IAAAC,gBAAA,CAAAD,OAAA,sBAAoDE,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAH,MAAA,CAAAC,cAAA,CAAAC,OAAA,oBAAAE,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAN,gBAAA,CAAAO,eAAA,IAAAN,MAAA,CAAAO,IAAA,CAAAV,kBAAA,EAAAW,OAAA,UAAAC,CAAA,cAAAA,CAAA,iBAAAA,CAAA,EAAAT,MAAA,CAAAU,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,CAAAJ,CAAA,GAAAA,CAAA,IAAAP,OAAA,EAAAA,OAAA,CAAAO,CAAA,IAAAZ,kBAAA,CAAAY,CAAA,GAAAT,MAAA,CAAAC,cAAA,CAAAC,OAAA,CAAAO,CAAA,EAAAL,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAR,kBAAA,CAAAY,CAAA","ignoreList":[]}
|
|
@@ -9,18 +9,6 @@ export declare class KameleoonClient extends KameleoonCore {
|
|
|
9
9
|
private internalVisitorCodeManager;
|
|
10
10
|
private externalVisitorCodeManager;
|
|
11
11
|
constructor({ siteCode, configuration, externals, _internals, }: SDKParameters);
|
|
12
|
-
/**
|
|
13
|
-
* @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached
|
|
14
|
-
* @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.
|
|
15
|
-
* @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail
|
|
16
|
-
* @throws `KameleoonError` with one of the following `type` s:
|
|
17
|
-
*
|
|
18
|
-
* - `KameleoonException.StorageWrite` - Couldn't update storage data
|
|
19
|
-
* - `KameleoonException.StorageRead` - Couldn't read storage data
|
|
20
|
-
* - `KameleoonException.ClientConfiguration` - Couldn't retrieve client configuration from Kameleoon Api
|
|
21
|
-
* - `KameleoonException.MaximumRetriesReached` - Maximum retries reached, request failed
|
|
22
|
-
*/
|
|
23
|
-
initialize(useCache?: boolean): Promise<boolean>;
|
|
24
12
|
/**
|
|
25
13
|
* @method getVisitorCode - obtains visitor code from the browser cookie, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default) and sets a new visitor code to cookie
|
|
26
14
|
* @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated
|
package/dist/kameleoonClient.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_requester=require("./requester"),_storage=require("./storage"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager"),_prng=require("./prng");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
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_requester=require("./requester"),_storage=require("./storage"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager"),_prng=require("./prng");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 KameleoonClient extends _javascriptSdkCore.KameleoonCore{constructor(a){let{siteCode:b,configuration:c,externals:d,_internals:e}=a;const f=(null===e||void 0===e?void 0:e.prng)||new _prng.KameleoonPRNG,g=(null===d||void 0===d?void 0:d.storage)||new _storage.DataStorage,h=(null===d||void 0===d?void 0:d.requester)||new _requester.Requester,i=(null===d||void 0===d?void 0:d.eventSource)||new _eventSource.KameleoonEventSource,j=new _javascriptSdkCore.VisitorCodeManager,k=(null===d||void 0===d?void 0:d.visitorCodeManager)||new _visitorCodeManager.KameleoonVisitorCodeManager,l=(null===e||void 0===e?void 0:e.packageInfo)||{type:_javascriptSdkCore.SdkLanguageType.JAVASCRIPT,version:"4.0.1"};super({siteCode:b,configuration:c,internalConfiguration:{externals:{externalPRNG:f,externalStorage:g,externalRequester:h,externalEventSource:i,externalVisitorCodeManager:j,externalPackageInfo:l},settings:{useAbortController:!0}}}),_defineProperty(this,"domain",void 0),_defineProperty(this,"internalVisitorCodeManager",void 0),_defineProperty(this,"externalVisitorCodeManager",void 0),this.domain=null===c||void 0===c?void 0:c.cookieDomain,this.internalVisitorCodeManager=j,this.externalVisitorCodeManager=k}getVisitorCode(a){return this.internalVisitorCodeManager.getData=a=>this.externalVisitorCodeManager.getData(a),this.internalVisitorCodeManager.setData=a=>{this.externalVisitorCodeManager.setData(_objectSpread(_objectSpread({},a),{},{domain:this.domain}))},this.internalVisitorCodeManager.getVisitorCode(a)}setLegalConsent(a,b){super.setUserConsent({visitorCode:a,consent:b,setData:a=>{this.externalVisitorCodeManager.setData(_objectSpread(_objectSpread({},a),{},{domain:this.domain}))}})}}exports.KameleoonClient=KameleoonClient;
|
|
2
2
|
//# sourceMappingURL=kameleoonClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","KameleoonCore","constructor","a","siteCode","configuration","externals","_internals","prng","KameleoonPRNG","storage","DataStorage","requester","Requester","eventSource","KameleoonEventSource","visitorCodeManager","VisitorCodeManager","externalVisitorCodeManager","KameleoonVisitorCodeManager","packageInfo","type","SdkLanguageType","JAVASCRIPT","version","internalConfiguration","externalPRNG","externalStorage","externalRequester","externalEventSource","externalPackageInfo","
|
|
1
|
+
{"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","KameleoonCore","constructor","a","siteCode","configuration","externals","_internals","prng","KameleoonPRNG","storage","DataStorage","requester","Requester","eventSource","KameleoonEventSource","visitorCodeManager","VisitorCodeManager","externalVisitorCodeManager","KameleoonVisitorCodeManager","packageInfo","type","SdkLanguageType","JAVASCRIPT","version","internalConfiguration","externalPRNG","externalStorage","externalRequester","externalEventSource","externalPackageInfo","settings","useAbortController","_defineProperty","domain","cookieDomain","internalVisitorCodeManager","getVisitorCode","defaultVisitorCode","getData","key","setData","parameters","_objectSpread","setLegalConsent","visitorCode","consent","setUserConsent","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import {\n SdkLanguageType,\n KameleoonCore,\n VisitorCodeManager,\n IVisitorCodeManager,\n SetDataCallbackParametersType,\n} from '@kameleoon/javascript-sdk-core';\nimport { Requester } from './requester';\nimport { DataStorage } from './storage';\nimport { KameleoonEventSource } from './eventSource';\nimport { KameleoonVisitorCodeManager } from './visitorCodeManager';\nimport { IExternalVisitorCodeManager, SDKParameters } from './types';\nimport { KameleoonPRNG } from './prng';\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * */\nexport class KameleoonClient extends KameleoonCore {\n private domain?: string;\n private internalVisitorCodeManager: IVisitorCodeManager;\n private externalVisitorCodeManager: IExternalVisitorCodeManager;\n\n constructor({\n siteCode,\n configuration,\n externals,\n _internals,\n }: SDKParameters) {\n const prng = _internals?.prng || new KameleoonPRNG();\n const storage = externals?.storage || new DataStorage();\n const requester = externals?.requester || new Requester();\n const eventSource = externals?.eventSource || new KameleoonEventSource();\n const visitorCodeManager = new VisitorCodeManager();\n const externalVisitorCodeManager =\n externals?.visitorCodeManager || new KameleoonVisitorCodeManager();\n\n const packageInfo = _internals?.packageInfo || {\n type: SdkLanguageType.JAVASCRIPT,\n version: process.env.npm_package_version as string,\n };\n\n const dependencies = {\n externalPRNG: prng,\n externalStorage: storage,\n externalRequester: requester,\n externalEventSource: eventSource,\n externalVisitorCodeManager: visitorCodeManager,\n externalPackageInfo: packageInfo,\n };\n\n const settings = {\n useAbortController: true,\n };\n\n super({\n siteCode,\n configuration,\n internalConfiguration: {\n externals: dependencies,\n settings,\n },\n });\n\n this.domain = configuration?.cookieDomain;\n this.internalVisitorCodeManager = visitorCodeManager;\n this.externalVisitorCodeManager = externalVisitorCodeManager;\n }\n\n /**\n * @method getVisitorCode - obtains visitor code from the browser cookie, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default) and sets a new visitor code to cookie\n * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated\n * @returns {string} result visitor code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n */\n public getVisitorCode(defaultVisitorCode?: string): string {\n this.internalVisitorCodeManager.getData = (key: string) =>\n this.externalVisitorCodeManager.getData(key);\n\n this.internalVisitorCodeManager.setData = (\n parameters: SetDataCallbackParametersType,\n ) => {\n this.externalVisitorCodeManager.setData({\n ...parameters,\n domain: this.domain,\n });\n };\n\n return this.internalVisitorCodeManager.getVisitorCode(defaultVisitorCode);\n }\n\n /**\n * @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n */\n public setLegalConsent(visitorCode: string, consent: boolean): void {\n super.setUserConsent({\n visitorCode,\n consent,\n setData: (parameters: SetDataCallbackParametersType): void => {\n this.externalVisitorCodeManager.setData({\n ...parameters,\n domain: this.domain,\n });\n },\n });\n }\n}\n"],"mappings":"y7CAkBO,KAAM,CAAAA,eAAe,QAAS,CAAAC,gCAAc,CAKjDC,WAAWA,CAAAC,CAAA,CAKO,IALN,CACVC,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbC,SAAS,CAATA,CAAS,CACTC,UAAU,CAAVA,CACa,CAAC,CAAAJ,CAAA,MACR,CAAAK,CAAI,CAAG,QAAAD,CAAU,WAAVA,CAAU,QAAVA,CAAU,CAAEC,IAAI,GAAI,GAAI,CAAAC,mBAAe,CAC9CC,CAAO,CAAG,QAAAJ,CAAS,WAATA,CAAS,QAATA,CAAS,CAAEI,OAAO,GAAI,GAAI,CAAAC,oBAAa,CACjDC,CAAS,CAAG,QAAAN,CAAS,WAATA,CAAS,QAATA,CAAS,CAAEM,SAAS,GAAI,GAAI,CAAAC,oBAAW,CACnDC,CAAW,CAAG,QAAAR,CAAS,WAATA,CAAS,QAATA,CAAS,CAAEQ,WAAW,GAAI,GAAI,CAAAC,iCAAsB,CAClEC,CAAkB,CAAG,GAAI,CAAAC,qCAAoB,CAC7CC,CAA0B,CAC9B,QAAAZ,CAAS,WAATA,CAAS,QAATA,CAAS,CAAEU,kBAAkB,GAAI,GAAI,CAAAG,+CAA6B,CAE9DC,CAAW,CAAG,QAAAb,CAAU,WAAVA,CAAU,QAAVA,CAAU,CAAEa,WAAW,GAAI,CAC7CC,IAAI,CAAEC,kCAAe,CAACC,UAAU,CAChCC,OAAO,QACT,CAAC,CAeD,KAAK,CAAC,CACJpB,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACboB,qBAAqB,CAAE,CACrBnB,SAAS,CAjBQ,CACnBoB,YAAY,CAAElB,CAAI,CAClBmB,eAAe,CAAEjB,CAAO,CACxBkB,iBAAiB,CAAEhB,CAAS,CAC5BiB,mBAAmB,CAAEf,CAAW,CAChCI,0BAA0B,CAAEF,CAAkB,CAC9Cc,mBAAmB,CAAEV,CACvB,CAU2B,CACvBW,QAAQ,CATK,CACfC,kBAAkB,GACpB,CAQE,CACF,CAAC,CAAC,CAAAC,eAAA,uBAAAA,eAAA,2CAAAA,eAAA,2CAEF,IAAI,CAACC,MAAM,QAAG7B,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAE8B,YAAY,CACzC,IAAI,CAACC,0BAA0B,CAAGpB,CAAkB,CACpD,IAAI,CAACE,0BAA0B,CAAGA,CACpC,CAWOmB,cAAcA,CAACC,CAA2B,CAAU,CAazD,MAZA,KAAI,CAACF,0BAA0B,CAACG,OAAO,CAAIC,CAAW,EACpD,IAAI,CAACtB,0BAA0B,CAACqB,OAAO,CAACC,CAAG,CAAC,CAE9C,IAAI,CAACJ,0BAA0B,CAACK,OAAO,CACrCC,CAAyC,EACtC,CACH,IAAI,CAACxB,0BAA0B,CAACuB,OAAO,CAAAE,aAAA,CAAAA,aAAA,IAClCD,CAAU,MACbR,MAAM,CAAE,IAAI,CAACA,MAAM,EACpB,CACH,CAAC,CAEM,IAAI,CAACE,0BAA0B,CAACC,cAAc,CAACC,CAAkB,CAC1E,CAcOM,eAAeA,CAACC,CAAmB,CAAEC,CAAgB,CAAQ,CAClE,KAAK,CAACC,cAAc,CAAC,CACnBF,WAAW,CAAXA,CAAW,CACXC,OAAO,CAAPA,CAAO,CACPL,OAAO,CAAGC,CAAyC,EAAW,CAC5D,IAAI,CAACxB,0BAA0B,CAACuB,OAAO,CAAAE,aAAA,CAAAA,aAAA,IAClCD,CAAU,MACbR,MAAM,CAAE,IAAI,CAACA,MAAM,EACpB,CACH,CACF,CAAC,CACH,CACF,CAACc,OAAA,CAAAhD,eAAA,CAAAA,eAAA","ignoreList":[]}
|
package/dist/prng.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prng.js","names":["KameleoonPRNG","getRandomNumber","a","window","crypto","arr","Uint32Array","getRandomValues","Math","random","exports"],"sources":["../src/prng.ts"],"sourcesContent":["import { IExternalPRNG } from '@kameleoon/javascript-sdk-core';\n\nexport class KameleoonPRNG implements IExternalPRNG {\n public getRandomNumber(): number {\n if (typeof window !== 'undefined' && window?.crypto) {\n const arr = new Uint32Array(1);\n const uint32Max = 0xffffffff + 1;\n\n window.crypto.getRandomValues(arr);\n\n return arr[0] / uint32Max;\n }\n\n return Math.random();\n }\n}\n"],"mappings":"iGAEO,KAAM,CAAAA,aAAuC,CAC3CC,eAAeA,CAAA,CAAW,KAAAC,CAAA,CAC/B,GAAsB,WAAW,EAA7B,MAAO,CAAAC,MAAsB,UAAAD,CAAA,CAAIC,MAAM,YAAAD,CAAA,EAANA,CAAA,CAAQE,MAAM,CAAE,MAC7C,CAAAC,CAAG,CAAG,GAAI,CAAAC,WAAW,CAAC,CAAC,CAAC,CAK9B,MAFA,CAAAH,MAAM,CAACC,MAAM,CAACG,eAAe,CAACF,CAAG,CAAC,CAE3BA,CAAG,CAAC,CAAC,CAAC,WACf,CAEA,MAAO,CAAAG,IAAI,CAACC,MAAM,CAAC,CACrB,CACF,CAACC,OAAA,CAAAV,aAAA,CAAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"prng.js","names":["KameleoonPRNG","getRandomNumber","a","window","crypto","arr","Uint32Array","getRandomValues","Math","random","exports"],"sources":["../src/prng.ts"],"sourcesContent":["import { IExternalPRNG } from '@kameleoon/javascript-sdk-core';\n\nexport class KameleoonPRNG implements IExternalPRNG {\n public getRandomNumber(): number {\n if (typeof window !== 'undefined' && window?.crypto) {\n const arr = new Uint32Array(1);\n const uint32Max = 0xffffffff + 1;\n\n window.crypto.getRandomValues(arr);\n\n return arr[0] / uint32Max;\n }\n\n return Math.random();\n }\n}\n"],"mappings":"iGAEO,KAAM,CAAAA,aAAuC,CAC3CC,eAAeA,CAAA,CAAW,KAAAC,CAAA,CAC/B,GAAsB,WAAW,EAA7B,MAAO,CAAAC,MAAsB,UAAAD,CAAA,CAAIC,MAAM,YAAAD,CAAA,EAANA,CAAA,CAAQE,MAAM,CAAE,MAC7C,CAAAC,CAAG,CAAG,GAAI,CAAAC,WAAW,CAAC,CAAC,CAAC,CAK9B,MAFA,CAAAH,MAAM,CAACC,MAAM,CAACG,eAAe,CAACF,CAAG,CAAC,CAE3BA,CAAG,CAAC,CAAC,CAAC,WACf,CAEA,MAAO,CAAAG,IAAI,CAACC,MAAM,CAAC,CACrB,CACF,CAACC,OAAA,CAAAV,aAAA,CAAAA,aAAA","ignoreList":[]}
|
package/dist/requester.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requester.js","names":["Requester","sendRequest","a","url","parameters","fetch","exports"],"sources":["../src/requester.ts"],"sourcesContent":["import {\n RequestType,\n IExternalRequester,\n KameleoonResponseType,\n SendRequestParametersType,\n} from '@kameleoon/javascript-sdk-core';\n\nexport class Requester implements IExternalRequester {\n public async sendRequest({\n url,\n parameters,\n }: SendRequestParametersType<RequestType>): Promise<KameleoonResponseType> {\n return await fetch(url, parameters);\n }\n}\n"],"mappings":"6FAOO,KAAM,CAAAA,SAAwC,CACnD,KAAa,CAAAC,WAAWA,CAAAC,CAAA,CAGmD,IAHlD,CACvBC,GAAG,CAAHA,CAAG,CACHC,UAAU,CAAVA,CACsC,CAAC,CAAAF,CAAA,CACvC,MAAO,MAAM,CAAAG,KAAK,CAACF,CAAG,CAAEC,CAAU,CACpC,CACF,CAACE,OAAA,CAAAN,SAAA,CAAAA,SAAA"}
|
|
1
|
+
{"version":3,"file":"requester.js","names":["Requester","sendRequest","a","url","parameters","fetch","exports"],"sources":["../src/requester.ts"],"sourcesContent":["import {\n RequestType,\n IExternalRequester,\n KameleoonResponseType,\n SendRequestParametersType,\n} from '@kameleoon/javascript-sdk-core';\n\nexport class Requester implements IExternalRequester {\n public async sendRequest({\n url,\n parameters,\n }: SendRequestParametersType<RequestType>): Promise<KameleoonResponseType> {\n return await fetch(url, parameters);\n }\n}\n"],"mappings":"6FAOO,KAAM,CAAAA,SAAwC,CACnD,KAAa,CAAAC,WAAWA,CAAAC,CAAA,CAGmD,IAHlD,CACvBC,GAAG,CAAHA,CAAG,CACHC,UAAU,CAAVA,CACsC,CAAC,CAAAF,CAAA,CACvC,MAAO,MAAM,CAAAG,KAAK,CAACF,CAAG,CAAEC,CAAU,CACpC,CACF,CAACE,OAAA,CAAAN,SAAA,CAAAA,SAAA","ignoreList":[]}
|
package/dist/storage.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataStorage=void 0;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_visitorCodeManager=require("./visitorCodeManager");function _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataStorage=void 0;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_visitorCodeManager=require("./visitorCodeManager");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 DataStorage{constructor(){_defineProperty(this,"visitorCodeManager",void 0)}read(a){const b=localStorage.getItem(a);if(!b){if(a===_javascriptSdkCore.KameleoonStorageKey.ConsentData){const a=this.getEngineConsentData();if(a)return a}return null}return JSON.parse(b)}write(a,b){localStorage.setItem(a,JSON.stringify(b))}getEngineConsentData(){this.visitorCodeManager||(this.visitorCodeManager=new _visitorCodeManager.KameleoonVisitorCodeManager);const a=this.visitorCodeManager.getData(_javascriptSdkCore.KameleoonStorageKey.VisitorCode);if(!a)return null;try{var b;const c=localStorage.getItem("kameleoonLegalConsent");if(!c)return null;const d=JSON.parse(c);return"boolean"==typeof(null===d||void 0===d||null===(b=d.value)||void 0===b?void 0:b.AB_TESTING)?{[a]:d.value.AB_TESTING}:null}catch(_){return null}}}exports.DataStorage=DataStorage;
|
|
2
2
|
//# sourceMappingURL=storage.js.map
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","names":["DataStorage","constructor","_defineProperty","read","key","data","localStorage","getItem","KameleoonStorageKey","ConsentData","engineConsent","getEngineConsentData","JSON","parse","write","setItem","stringify","visitorCodeManager","KameleoonVisitorCodeManager","visitorCode","getData","VisitorCode","b","engineConsentData","value","AB_TESTING","_","exports"],"sources":["../src/storage.ts"],"sourcesContent":["import {\n IExternalStorage,\n KameleoonStorageKey,\n} from '@kameleoon/javascript-sdk-core';\nimport { KameleoonVisitorCodeManager } from './visitorCodeManager';\nimport { EngineConsentDataType } from './types';\n\n// --- Note ---\n// Named `DataStorage` to avoid collision with `Storage` from `window` API\nexport class DataStorage<T> implements IExternalStorage<T> {\n private visitorCodeManager?: KameleoonVisitorCodeManager;\n\n public read(key: string): T | null {\n const data = localStorage.getItem(key);\n\n if (!data) {\n if (key === KameleoonStorageKey.ConsentData) {\n const engineConsent = this.getEngineConsentData();\n\n if (engineConsent) {\n return engineConsent;\n }\n }\n\n return null;\n }\n\n return JSON.parse(data);\n }\n\n public write(key: string, data: T): void {\n localStorage.setItem(key, JSON.stringify(data));\n }\n\n private getEngineConsentData(): T | null {\n if (!this.visitorCodeManager) {\n this.visitorCodeManager = new KameleoonVisitorCodeManager();\n }\n\n const visitorCode = this.visitorCodeManager.getData(\n KameleoonStorageKey.VisitorCode,\n );\n\n if (!visitorCode) {\n return null;\n }\n\n try {\n const engineConsentData = localStorage.getItem('kameleoonLegalConsent');\n\n if (!engineConsentData) {\n return null;\n }\n\n const engineConsent: EngineConsentDataType =\n JSON.parse(engineConsentData);\n\n if (typeof engineConsent?.value?.AB_TESTING === 'boolean') {\n return { [visitorCode]: engineConsent.value.AB_TESTING } as T;\n }\n\n return null;\n } catch (_) {\n return null;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.js","names":["DataStorage","constructor","_defineProperty","read","key","data","localStorage","getItem","KameleoonStorageKey","ConsentData","engineConsent","getEngineConsentData","JSON","parse","write","setItem","stringify","visitorCodeManager","KameleoonVisitorCodeManager","visitorCode","getData","VisitorCode","b","engineConsentData","value","AB_TESTING","_","exports"],"sources":["../src/storage.ts"],"sourcesContent":["import {\n IExternalStorage,\n KameleoonStorageKey,\n} from '@kameleoon/javascript-sdk-core';\nimport { KameleoonVisitorCodeManager } from './visitorCodeManager';\nimport { EngineConsentDataType } from './types';\n\n// --- Note ---\n// Named `DataStorage` to avoid collision with `Storage` from `window` API\nexport class DataStorage<T> implements IExternalStorage<T> {\n private visitorCodeManager?: KameleoonVisitorCodeManager;\n\n public read(key: string): T | null {\n const data = localStorage.getItem(key);\n\n if (!data) {\n if (key === KameleoonStorageKey.ConsentData) {\n const engineConsent = this.getEngineConsentData();\n\n if (engineConsent) {\n return engineConsent;\n }\n }\n\n return null;\n }\n\n return JSON.parse(data);\n }\n\n public write(key: string, data: T): void {\n localStorage.setItem(key, JSON.stringify(data));\n }\n\n private getEngineConsentData(): T | null {\n if (!this.visitorCodeManager) {\n this.visitorCodeManager = new KameleoonVisitorCodeManager();\n }\n\n const visitorCode = this.visitorCodeManager.getData(\n KameleoonStorageKey.VisitorCode,\n );\n\n if (!visitorCode) {\n return null;\n }\n\n try {\n const engineConsentData = localStorage.getItem('kameleoonLegalConsent');\n\n if (!engineConsentData) {\n return null;\n }\n\n const engineConsent: EngineConsentDataType =\n JSON.parse(engineConsentData);\n\n if (typeof engineConsent?.value?.AB_TESTING === 'boolean') {\n return { [visitorCode]: engineConsent.value.AB_TESTING } as T;\n }\n\n return null;\n } catch (_) {\n return null;\n }\n }\n}\n"],"mappings":"qtBASO,KAAM,CAAAA,WAA8C,CAAAC,YAAA,EAAAC,eAAA,mCAGlDC,IAAIA,CAACC,CAAW,CAAY,CACjC,KAAM,CAAAC,CAAI,CAAGC,YAAY,CAACC,OAAO,CAACH,CAAG,CAAC,CAEtC,GAAI,CAACC,CAAI,CAAE,CACT,GAAID,CAAG,GAAKI,sCAAmB,CAACC,WAAW,CAAE,CAC3C,KAAM,CAAAC,CAAa,CAAG,IAAI,CAACC,oBAAoB,CAAC,CAAC,CAEjD,GAAID,CAAa,CACf,MAAO,CAAAA,CAEX,CAEA,MAAO,KACT,CAEA,MAAO,CAAAE,IAAI,CAACC,KAAK,CAACR,CAAI,CACxB,CAEOS,KAAKA,CAACV,CAAW,CAAEC,CAAO,CAAQ,CACvCC,YAAY,CAACS,OAAO,CAACX,CAAG,CAAEQ,IAAI,CAACI,SAAS,CAACX,CAAI,CAAC,CAChD,CAEQM,oBAAoBA,CAAA,CAAa,CAClC,IAAI,CAACM,kBAAkB,GAC1B,IAAI,CAACA,kBAAkB,CAAG,GAAI,CAAAC,+CAA6B,EAG7D,KAAM,CAAAC,CAAW,CAAG,IAAI,CAACF,kBAAkB,CAACG,OAAO,CACjDZ,sCAAmB,CAACa,WACtB,CAAC,CAED,GAAI,CAACF,CAAW,CACd,MAAO,KAAI,CAGb,GAAI,KAAAG,CAAA,CACF,KAAM,CAAAC,CAAiB,CAAGjB,YAAY,CAACC,OAAO,CAAC,uBAAuB,CAAC,CAEvE,GAAI,CAACgB,CAAiB,CACpB,MAAO,KAAI,CAGb,KAAM,CAAAb,CAAoC,CACxCE,IAAI,CAACC,KAAK,CAACU,CAAiB,CAAC,CAAC,MAEgB,SAAS,EAArD,cAAOb,CAAa,WAAbA,CAAa,UAAAY,CAAA,CAAbZ,CAAa,CAAEc,KAAK,YAAAF,CAAA,QAApBA,CAAA,CAAsBG,UAAU,CAAc,CAChD,CAAE,CAACN,CAAW,EAAGT,CAAa,CAACc,KAAK,CAACC,UAAW,CAAC,CAGnD,IACT,CAAE,MAAOC,CAAC,CAAE,CACV,MAAO,KACT,CACF,CACF,CAACC,OAAA,CAAA3B,WAAA,CAAAA,WAAA","ignoreList":[]}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import {\n InternalsType,\n IExternalEventSource,\n IExternalRequester,\n IExternalStorage,\n SDKConfigurationType,\n} from '@kameleoon/javascript-sdk-core';\n\n/**\n * @param {IExternalStorage | undefined} storage - external storage implementation\n * @param {IExternalEventSource | undefined} eventSource - external event source implementation\n * @param {IExternalVisitorCodeManager | undefined} visitorCodeManager - external visitor code manager implementation\n * @param {IExternalRequester | undefined} requester - external requester implementation\n * */\nexport type ExternalsType = {\n storage?: IExternalStorage;\n requester?: IExternalRequester;\n eventSource?: IExternalEventSource;\n visitorCodeManager?: IExternalVisitorCodeManager;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType> | undefined} configuration - client's configuration\n * @param {ExternalsType | undefined} externals - external dependencies\n * @param {InternalsType | undefined} _internals - internal dependencies used by consumer packages (React/React Native SDK)\n * */\nexport type SDKParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n externals?: ExternalsType;\n _internals?: InternalsType;\n};\n\nexport type SetDataParametersType = {\n visitorCode: string;\n key: string;\n domain?: string;\n maxAge: number;\n path: string;\n};\n\nexport interface IExternalVisitorCodeManager {\n getData: (key: string) => string | null;\n setData: (params: SetDataParametersType) => void;\n}\n\nexport type EngineConsentDataType = {\n value?: { AB_TESTING?: boolean };\n};\n\nexport type GetResultCookieParametersType = {\n visitorCode: string;\n domain?: string;\n key: string;\n maxAge: number;\n path: string;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import {\n InternalsType,\n IExternalEventSource,\n IExternalRequester,\n IExternalStorage,\n SDKConfigurationType,\n} from '@kameleoon/javascript-sdk-core';\n\n/**\n * @param {IExternalStorage | undefined} storage - external storage implementation\n * @param {IExternalEventSource | undefined} eventSource - external event source implementation\n * @param {IExternalVisitorCodeManager | undefined} visitorCodeManager - external visitor code manager implementation\n * @param {IExternalRequester | undefined} requester - external requester implementation\n * */\nexport type ExternalsType = {\n storage?: IExternalStorage;\n requester?: IExternalRequester;\n eventSource?: IExternalEventSource;\n visitorCodeManager?: IExternalVisitorCodeManager;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType> | undefined} configuration - client's configuration\n * @param {ExternalsType | undefined} externals - external dependencies\n * @param {InternalsType | undefined} _internals - internal dependencies used by consumer packages (React/React Native SDK)\n * */\nexport type SDKParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n externals?: ExternalsType;\n _internals?: InternalsType;\n};\n\nexport type SetDataParametersType = {\n visitorCode: string;\n key: string;\n domain?: string;\n maxAge: number;\n path: string;\n};\n\nexport interface IExternalVisitorCodeManager {\n getData: (key: string) => string | null;\n setData: (params: SetDataParametersType) => void;\n}\n\nexport type EngineConsentDataType = {\n value?: { AB_TESTING?: boolean };\n};\n\nexport type GetResultCookieParametersType = {\n visitorCode: string;\n domain?: string;\n key: string;\n maxAge: number;\n path: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitorCodeManager.js","names":["VisitorCodeManager","getData","key","cookie","document","KameleoonUtils","getCookieValue","setData","a","visitorCode","domain","maxAge","path","resultCookie","getResultCookie","cookieArray","CookieParameter","KeyValueDelimiter","MaxAge","Path","push","Domain","join","PairsDelimiter","exports","KameleoonVisitorCodeManager"],"sources":["../src/visitorCodeManager.ts"],"sourcesContent":["import {\n GetResultCookieParametersType,\n IExternalVisitorCodeManager,\n SetDataParametersType,\n} from './types';\nimport { CookieParameter } from './constants';\nimport { KameleoonUtils } from '@kameleoon/javascript-sdk-core';\n\nclass VisitorCodeManager implements IExternalVisitorCodeManager {\n public getData(key: string): string | null {\n const cookie = document.cookie;\n\n if (cookie) {\n return KameleoonUtils.getCookieValue(cookie, key);\n }\n\n return null;\n }\n\n public setData({\n visitorCode,\n domain,\n maxAge,\n key,\n path,\n }: SetDataParametersType): void {\n const resultCookie = this.getResultCookie({\n domain,\n visitorCode,\n key,\n maxAge,\n path,\n });\n\n document.cookie = resultCookie;\n }\n\n private getResultCookie({\n domain,\n visitorCode,\n maxAge,\n key,\n path,\n }: GetResultCookieParametersType): string {\n const cookieArray = [\n key + CookieParameter.KeyValueDelimiter + visitorCode,\n CookieParameter.MaxAge + CookieParameter.KeyValueDelimiter + maxAge,\n CookieParameter.Path + CookieParameter.KeyValueDelimiter + path,\n ];\n\n if (domain) {\n cookieArray.push(\n CookieParameter.Domain + CookieParameter.KeyValueDelimiter + domain,\n );\n }\n\n return cookieArray.join(CookieParameter.PairsDelimiter);\n }\n}\n\nexport { VisitorCodeManager as KameleoonVisitorCodeManager };\n"],"mappings":"kNAQA,KAAM,CAAAA,kBAA0D,CACvDC,OAAOA,CAACC,CAAW,CAAiB,CACzC,KAAM,CAAAC,CAAM,CAAGC,QAAQ,CAACD,MAAM,CAAC,MAE3B,CAAAA,CAAM,CACDE,iCAAc,CAACC,cAAc,CAACH,CAAM,CAAED,CAAG,CAAC,CAG5C,IACT,CAEOK,OAAOA,CAAAC,CAAA,CAMkB,IANjB,CACbC,WAAW,CAAXA,CAAW,CACXC,MAAM,CAANA,CAAM,CACNC,MAAM,CAANA,CAAM,CACNT,GAAG,CAAHA,CAAG,CACHU,IAAI,CAAJA,CACqB,CAAC,CAAAJ,CAAA,CACtB,KAAM,CAAAK,CAAY,CAAG,IAAI,CAACC,eAAe,CAAC,CACxCJ,MAAM,CAANA,CAAM,CACND,WAAW,CAAXA,CAAW,CACXP,GAAG,CAAHA,CAAG,CACHS,MAAM,CAANA,CAAM,CACNC,IAAI,CAAJA,CACF,CAAC,CAAC,CAEFR,QAAQ,CAACD,MAAM,CAAGU,CACpB,CAEQC,eAAeA,CAAAN,CAAA,CAMmB,IANlB,CACtBE,MAAM,CAANA,CAAM,CACND,WAAW,CAAXA,CAAW,CACXE,MAAM,CAANA,CAAM,CACNT,GAAG,CAAHA,CAAG,CACHU,IAAI,CAAJA,CAC6B,CAAC,CAAAJ,CAAA,CAC9B,KAAM,CAAAO,CAAW,CAAG,CAClBb,CAAG,CAAGc,0BAAe,CAACC,iBAAiB,CAAGR,CAAW,CACrDO,0BAAe,CAACE,MAAM,CAAGF,0BAAe,CAACC,iBAAiB,CAAGN,CAAM,CACnEK,0BAAe,CAACG,IAAI,CAAGH,0BAAe,CAACC,iBAAiB,CAAGL,CAAI,CAChE,CAQD,MANI,CAAAF,CAAM,EACRK,CAAW,CAACK,IAAI,CACdJ,0BAAe,CAACK,MAAM,CAAGL,0BAAe,CAACC,iBAAiB,CAAGP,CAC/D,CAAC,CAGIK,CAAW,CAACO,IAAI,CAACN,0BAAe,CAACO,cAAc,CACxD,CACF,CAACC,OAAA,CAAAC,2BAAA,CAAAzB,kBAAA"}
|
|
1
|
+
{"version":3,"file":"visitorCodeManager.js","names":["VisitorCodeManager","getData","key","cookie","document","KameleoonUtils","getCookieValue","setData","a","visitorCode","domain","maxAge","path","resultCookie","getResultCookie","cookieArray","CookieParameter","KeyValueDelimiter","MaxAge","Path","push","Domain","join","PairsDelimiter","exports","KameleoonVisitorCodeManager"],"sources":["../src/visitorCodeManager.ts"],"sourcesContent":["import {\n GetResultCookieParametersType,\n IExternalVisitorCodeManager,\n SetDataParametersType,\n} from './types';\nimport { CookieParameter } from './constants';\nimport { KameleoonUtils } from '@kameleoon/javascript-sdk-core';\n\nclass VisitorCodeManager implements IExternalVisitorCodeManager {\n public getData(key: string): string | null {\n const cookie = document.cookie;\n\n if (cookie) {\n return KameleoonUtils.getCookieValue(cookie, key);\n }\n\n return null;\n }\n\n public setData({\n visitorCode,\n domain,\n maxAge,\n key,\n path,\n }: SetDataParametersType): void {\n const resultCookie = this.getResultCookie({\n domain,\n visitorCode,\n key,\n maxAge,\n path,\n });\n\n document.cookie = resultCookie;\n }\n\n private getResultCookie({\n domain,\n visitorCode,\n maxAge,\n key,\n path,\n }: GetResultCookieParametersType): string {\n const cookieArray = [\n key + CookieParameter.KeyValueDelimiter + visitorCode,\n CookieParameter.MaxAge + CookieParameter.KeyValueDelimiter + maxAge,\n CookieParameter.Path + CookieParameter.KeyValueDelimiter + path,\n ];\n\n if (domain) {\n cookieArray.push(\n CookieParameter.Domain + CookieParameter.KeyValueDelimiter + domain,\n );\n }\n\n return cookieArray.join(CookieParameter.PairsDelimiter);\n }\n}\n\nexport { VisitorCodeManager as KameleoonVisitorCodeManager };\n"],"mappings":"kNAQA,KAAM,CAAAA,kBAA0D,CACvDC,OAAOA,CAACC,CAAW,CAAiB,CACzC,KAAM,CAAAC,CAAM,CAAGC,QAAQ,CAACD,MAAM,CAAC,MAE3B,CAAAA,CAAM,CACDE,iCAAc,CAACC,cAAc,CAACH,CAAM,CAAED,CAAG,CAAC,CAG5C,IACT,CAEOK,OAAOA,CAAAC,CAAA,CAMkB,IANjB,CACbC,WAAW,CAAXA,CAAW,CACXC,MAAM,CAANA,CAAM,CACNC,MAAM,CAANA,CAAM,CACNT,GAAG,CAAHA,CAAG,CACHU,IAAI,CAAJA,CACqB,CAAC,CAAAJ,CAAA,CACtB,KAAM,CAAAK,CAAY,CAAG,IAAI,CAACC,eAAe,CAAC,CACxCJ,MAAM,CAANA,CAAM,CACND,WAAW,CAAXA,CAAW,CACXP,GAAG,CAAHA,CAAG,CACHS,MAAM,CAANA,CAAM,CACNC,IAAI,CAAJA,CACF,CAAC,CAAC,CAEFR,QAAQ,CAACD,MAAM,CAAGU,CACpB,CAEQC,eAAeA,CAAAN,CAAA,CAMmB,IANlB,CACtBE,MAAM,CAANA,CAAM,CACND,WAAW,CAAXA,CAAW,CACXE,MAAM,CAANA,CAAM,CACNT,GAAG,CAAHA,CAAG,CACHU,IAAI,CAAJA,CAC6B,CAAC,CAAAJ,CAAA,CAC9B,KAAM,CAAAO,CAAW,CAAG,CAClBb,CAAG,CAAGc,0BAAe,CAACC,iBAAiB,CAAGR,CAAW,CACrDO,0BAAe,CAACE,MAAM,CAAGF,0BAAe,CAACC,iBAAiB,CAAGN,CAAM,CACnEK,0BAAe,CAACG,IAAI,CAAGH,0BAAe,CAACC,iBAAiB,CAAGL,CAAI,CAChE,CAQD,MANI,CAAAF,CAAM,EACRK,CAAW,CAACK,IAAI,CACdJ,0BAAe,CAACK,MAAM,CAAGL,0BAAe,CAACC,iBAAiB,CAAGP,CAC/D,CAAC,CAGIK,CAAW,CAACO,IAAI,CAACN,0BAAe,CAACO,cAAc,CACxD,CACF,CAACC,OAAA,CAAAC,2BAAA,CAAAzB,kBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/javascript-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Kameleoon JavaScript SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"license": "ISC",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@kameleoon/javascript-sdk-core": "
|
|
38
|
+
"@kameleoon/javascript-sdk-core": "5.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/crypto-js": "^4.1.1",
|