@kameleoon/javascript-sdk-core 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +369 -0
- package/CHANGELOG_INTERNAL.md +3 -0
- package/dist/cacheManager/cacheManager.js +1 -1
- package/dist/cacheManager/cacheManager.js.map +1 -1
- package/dist/cacheManager/index.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.d.ts +2 -3
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/index.js +1 -1
- package/dist/clientConfiguration/types.d.ts +7 -8
- package/dist/clientConfiguration/types.js +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/clientSettings/clientSettings.js +1 -1
- package/dist/clientSettings/clientSettings.js.map +1 -1
- package/dist/clientSettings/index.js +1 -1
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/eventSource/constants.js +1 -1
- package/dist/eventSource/constants.js.map +1 -1
- package/dist/eventSource/eventSource.d.ts +17 -0
- package/dist/eventSource/eventSource.js +2 -0
- package/dist/eventSource/eventSource.js.map +1 -0
- package/dist/eventSource/index.d.ts +2 -2
- package/dist/eventSource/index.js +1 -1
- package/dist/eventSource/index.js.map +1 -1
- package/dist/eventSource/types.d.ts +8 -19
- package/dist/eventSource/types.js.map +1 -1
- package/dist/hasher/hasher.js +1 -1
- package/dist/hasher/hasher.js.map +1 -1
- package/dist/hasher/index.js +1 -1
- package/dist/hasher/index.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +2 -207
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +199 -0
- package/dist/kameleoonClientInterface.js +2 -0
- package/dist/kameleoonClientInterface.js.map +1 -0
- package/dist/kameleoonData/applicationVersion.js +1 -1
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/constants.js +1 -1
- package/dist/kameleoonData/constants.js.map +1 -1
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.js +1 -1
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +2 -2
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/helpers.js +1 -1
- package/dist/kameleoonData/helpers.js.map +1 -1
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +2 -2
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/userAgent.js +1 -1
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/kameleoonError/constants.d.ts +1 -0
- package/dist/kameleoonError/constants.js +1 -1
- package/dist/kameleoonError/constants.js.map +1 -1
- package/dist/kameleoonError/helpers.js.map +1 -1
- package/dist/kameleoonError/index.js +1 -1
- package/dist/kameleoonError/kameleoonError.d.ts +1 -1
- package/dist/kameleoonError/kameleoonError.js +1 -1
- package/dist/kameleoonError/kameleoonError.js.map +1 -1
- package/dist/kameleoonError/types.d.ts +1 -0
- package/dist/kameleoonError/types.js +1 -1
- package/dist/kameleoonError/types.js.map +1 -1
- 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.js +1 -1
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/constants.js.map +1 -1
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/storage.d.ts +13 -0
- package/dist/storage/storage.js +2 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/storage/types.d.ts +15 -30
- 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 +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/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 +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 +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/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.js +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 +1 -1
- package/dist/targeting/types.js.map +1 -1
- package/dist/types.d.ts +14 -26
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.js +1 -1
- package/dist/utilities/constants.js.map +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/types.d.ts +7 -7
- package/dist/utilities/types.js +1 -1
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/variationConfiguration/index.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +3 -3
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/dist/visitorCodeManager/constants.d.ts +3 -0
- package/dist/visitorCodeManager/constants.js +2 -0
- package/dist/visitorCodeManager/constants.js.map +1 -0
- package/dist/visitorCodeManager/index.d.ts +2 -0
- package/dist/visitorCodeManager/index.js +1 -1
- package/dist/visitorCodeManager/index.js.map +1 -1
- package/dist/visitorCodeManager/types.d.ts +7 -0
- package/dist/visitorCodeManager/types.js +2 -0
- package/dist/visitorCodeManager/types.js.map +1 -0
- package/dist/visitorCodeManager/visitorCodeManager.d.ts +11 -8
- package/dist/visitorCodeManager/visitorCodeManager.js +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -1
- package/package.json +4 -8
- package/dist/eventSource/externalEventSource.d.ts +0 -12
- package/dist/eventSource/externalEventSource.js +0 -2
- package/dist/eventSource/externalEventSource.js.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { JSONType } from './clientConfiguration';
|
|
2
|
+
import { CustomData, KameleoonDataType } from './kameleoonData';
|
|
3
|
+
import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, RemoteVisitorDataParamsType, TrackConversionParamsType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @interface an interface of KameleoonClient instance
|
|
6
|
+
*/
|
|
7
|
+
export interface IKameleoonClient {
|
|
8
|
+
/**
|
|
9
|
+
* @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
|
|
10
|
+
* @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.
|
|
11
|
+
* @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail
|
|
12
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
13
|
+
*
|
|
14
|
+
* - `KameleoonException.StorageWrite` Couldn't update storage data
|
|
15
|
+
* - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api
|
|
16
|
+
* - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed
|
|
17
|
+
*/
|
|
18
|
+
initialize(useCache?: boolean): Promise<boolean>;
|
|
19
|
+
initialize(): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.
|
|
22
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
23
|
+
* @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments
|
|
24
|
+
* @returns {void}
|
|
25
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
26
|
+
*
|
|
27
|
+
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
|
|
28
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
29
|
+
* - `KameleoonException.StorageWrite` Couldn't update storage data
|
|
30
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
31
|
+
*/
|
|
32
|
+
addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
|
|
35
|
+
* @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
|
|
36
|
+
* @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data
|
|
37
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
38
|
+
*
|
|
39
|
+
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
|
|
40
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
41
|
+
* - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
|
|
42
|
+
* - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
|
|
43
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
44
|
+
*/
|
|
45
|
+
getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
|
|
46
|
+
/**
|
|
47
|
+
* @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter
|
|
48
|
+
* @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking
|
|
49
|
+
* @returns {void}
|
|
50
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
51
|
+
*
|
|
52
|
+
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
|
|
53
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
54
|
+
* - `KameleoonException.StorageWrite` Couldn't update storage data
|
|
55
|
+
*/
|
|
56
|
+
trackConversion: ({ visitorCode, goalId, revenue, isUniqueIdentifier, }: TrackConversionParamsType) => void;
|
|
57
|
+
/**
|
|
58
|
+
* @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,
|
|
59
|
+
* sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,
|
|
60
|
+
* then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input
|
|
61
|
+
* the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.
|
|
62
|
+
* @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
63
|
+
* @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
|
|
64
|
+
* @returns {void}
|
|
65
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
66
|
+
*
|
|
67
|
+
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
|
|
68
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
69
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
70
|
+
*/
|
|
71
|
+
flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;
|
|
72
|
+
/**
|
|
73
|
+
* @method getFeatureFlags - returns a list of feature flags stored in the client configuration
|
|
74
|
+
* @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
|
|
75
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
76
|
+
*
|
|
77
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
78
|
+
*/
|
|
79
|
+
getFeatureFlags: () => FeatureFlagType[];
|
|
80
|
+
/**
|
|
81
|
+
* @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).
|
|
82
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
83
|
+
* @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
|
|
84
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
85
|
+
*
|
|
86
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
87
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
88
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
|
|
89
|
+
* - `KameleoonException.StorageRead` - Couldn't read storage data
|
|
90
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted
|
|
91
|
+
*/
|
|
92
|
+
getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];
|
|
93
|
+
/**
|
|
94
|
+
* @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
95
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
96
|
+
* @param {string} featureKey - a unique key for feature flag
|
|
97
|
+
* @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`
|
|
98
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
99
|
+
*
|
|
100
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
101
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
102
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
103
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
|
|
104
|
+
* - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.
|
|
105
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted
|
|
106
|
+
*/
|
|
107
|
+
isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
110
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
111
|
+
* @param {string} featureKey - a unique key for feature flag
|
|
112
|
+
* @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor
|
|
113
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
114
|
+
*
|
|
115
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
116
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
117
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
118
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
|
|
119
|
+
* - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
|
|
120
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted
|
|
121
|
+
*/
|
|
122
|
+
getFeatureFlagVariationKey: (visitorCode: string, featureKey: string) => string;
|
|
123
|
+
/**
|
|
124
|
+
* @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
125
|
+
* @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
|
|
126
|
+
* @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
|
|
127
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
128
|
+
*
|
|
129
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
130
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
131
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
132
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
|
|
133
|
+
* - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`
|
|
134
|
+
* - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
|
|
135
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted
|
|
136
|
+
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
|
|
137
|
+
* - `KameleoonException.NumberParse` - Couldn't parse Number value
|
|
138
|
+
*/
|
|
139
|
+
getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;
|
|
140
|
+
/**
|
|
141
|
+
* @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
142
|
+
* @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
|
|
143
|
+
* @param {string} featureKey - a unique key for feature flag
|
|
144
|
+
* @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
|
|
145
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
146
|
+
*
|
|
147
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
148
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
149
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
150
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
|
|
151
|
+
* - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`
|
|
152
|
+
* - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
|
|
153
|
+
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
|
|
154
|
+
* - `KameleoonException.NumberParse` - Couldn't parse Number value
|
|
155
|
+
*/
|
|
156
|
+
getFeatureFlagVariables: (visitorCode: string, featureKey: string) => FeatureVariableResultType[];
|
|
157
|
+
/**
|
|
158
|
+
* @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.
|
|
159
|
+
* @param {string} key - unique key that the data you try to get is associated with.
|
|
160
|
+
* @returns {JSONType} - promise with retrieving data for specific key.
|
|
161
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
162
|
+
*
|
|
163
|
+
* - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
|
|
164
|
+
*/
|
|
165
|
+
getRemoteData: (key: string) => Promise<JSONType>;
|
|
166
|
+
/**
|
|
167
|
+
* @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences
|
|
168
|
+
* which is stored for specified visitorCode on a remote Kameleoon server.
|
|
169
|
+
* Retrieved data will be added to storage under the specified `customDataIndex`
|
|
170
|
+
* @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.
|
|
171
|
+
* @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`
|
|
172
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
173
|
+
*
|
|
174
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
175
|
+
* - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty
|
|
176
|
+
* - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
|
|
177
|
+
*/
|
|
178
|
+
getVisitorWarehouseAudience: ({ visitorCode, customDataIndex, warehouseKey, }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;
|
|
179
|
+
/**
|
|
180
|
+
* @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds
|
|
181
|
+
* See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details
|
|
182
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
183
|
+
* @returns {string} Kameleoon tracking code
|
|
184
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
185
|
+
*
|
|
186
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
187
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
188
|
+
*/
|
|
189
|
+
getEngineTrackingCode: (visitorCode: string) => string;
|
|
190
|
+
/**
|
|
191
|
+
* @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.
|
|
192
|
+
* @param {() => void} callback - callback function with no parameters that will be called upon configuration update
|
|
193
|
+
* @returns {void}
|
|
194
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
195
|
+
*
|
|
196
|
+
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
197
|
+
*/
|
|
198
|
+
onConfigurationUpdate: (callback: () => void) => void;
|
|
199
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApplicationVersion=void 0;function
|
|
1
|
+
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApplicationVersion=void 0;function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class ApplicationVersion{constructor(a){_defineProperty(this,"version",void 0),_defineProperty(this,"sent",void 0),this.version=a,this.sent=!1}get url(){return""}get data(){return{version:this.version,type:_types.KameleoonData.ApplicationVersion,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}}exports.ApplicationVersion=ApplicationVersion;
|
|
2
2
|
//# sourceMappingURL=applicationVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationVersion.js","names":["_types","require","Object","defineProperty","exports","value","ApplicationVersion","
|
|
1
|
+
{"version":3,"file":"applicationVersion.js","names":["_types","require","Object","defineProperty","exports","value","ApplicationVersion","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","version","sent","url","data","type","KameleoonData","isSent"],"sources":["../../src/kameleoonData/applicationVersion.ts"],"sourcesContent":["import {\n IKameleoonData,\n KameleoonData,\n ApplicationVersionDataType,\n} from './types';\n\n/**\n * @class\n * ApplicationVersion - a class for creating an instance for app version\n * */\nexport class ApplicationVersion implements IKameleoonData {\n private version: string;\n private sent: boolean;\n\n /**\n * @param {string} version - version of mobile application\n * */\n constructor(version: string) {\n this.version = version;\n this.sent = false;\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n return '';\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): ApplicationVersionDataType {\n return {\n version: this.version,\n type: KameleoonData.ApplicationVersion,\n sent: this.sent,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n}\n"],"mappings":"aAAA,IAAAA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AAO,KAAI,CAACL,IACd,CAEA,GAAI,CAAAK,MAAMA,CAACzB,CAAc,CAAE,CACzB,IAAI,CAACoB,IAAI,CAAGpB,CACd,CACF,CAACD,OAAA,CAAAE,kBAAA,CAAAA,kBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _requester=require("../requester"),_types=require("./types");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _requester=require("../requester"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class Browser{constructor(a,b){_defineProperty(this,"browser",void 0),_defineProperty(this,"version",void 0),_defineProperty(this,"sent",void 0),this.browser=a,this.version=b,this.sent=!1}get url(){if(!this.browser)return"";const a=this.version?_requester.UrlParameter.BrowserVersion+this.version:"";return _requester.UrlEventType.StaticData+_requester.UrlParameter.Browser+this.browser+_requester.UrlParameter.BrowserIndex+_types.BrowserIndexMap[this.browser]+a}get data(){return{browser:this.browser,type:_types.KameleoonData.Browser,version:this.version,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static _fromVisits(a){let b={};for(let c=a.length-1;0<=c;c--){const d=a[c];if(!d.staticDataEvent)continue;const{browser:e,browserIndex:f,browserVersion:g}=d.staticDataEvent.data;(e||null!==f)&&(b={browserType:e,browserIndex:f,browserVersion:g})}const{browserType:c,browserIndex:d,browserVersion:e}=b;if(c||"number"==typeof d){const a=c?c:_types.BrowserTypeMap[d];return e?new Browser(a,e):new Browser(a)}}}exports.Browser=Browser;
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":["Browser","
|
|
1
|
+
{"version":3,"file":"browser.js","names":["Browser","constructor","browser","version","_defineProperty","sent","url","browserVersion","UrlParameter","BrowserVersion","UrlEventType","StaticData","BrowserIndex","BrowserIndexMap","data","type","KameleoonData","isSent","value","_fromVisits","visits","browserData","i","length","visit","staticDataEvent","browserType","browserIndex","BrowserTypeMap","exports"],"sources":["../../src/kameleoonData/browser.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport {\n BrowserDataType,\n BrowserType,\n BrowserIndexMap,\n IKameleoonData,\n KameleoonData,\n BrowserTypeMap,\n} from './types';\n\n/**\n * @class\n * Browser - a class for creating an instance for browser of a certain type\n * */\nexport class Browser implements IKameleoonData {\n private browser: BrowserType;\n private version?: number;\n private sent: boolean;\n\n /**\n * @param {BrowserType} browser - one of the browser types available for data, if browser can not be found in a list, it can be marked as `BrowserType.Other`\n * @param {number | undefined} version - version of the browser, floating point number represents major and minor version of the browser\n * @example\n * ```ts\n * const browser = new Browser(BrowserType.Chrome, 86);\n * const browser = new Browser(BrowserType.Safari, 14.1);\n * ```\n * */\n constructor(browser: BrowserType, version?: number) {\n this.browser = browser;\n this.version = version;\n this.sent = false;\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.browser) {\n return '';\n }\n\n const browserVersion = this.version\n ? UrlParameter.BrowserVersion + this.version\n : '';\n\n return (\n UrlEventType.StaticData +\n UrlParameter.Browser +\n this.browser +\n UrlParameter.BrowserIndex +\n BrowserIndexMap[this.browser] +\n browserVersion\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): BrowserDataType {\n return {\n browser: this.browser,\n type: KameleoonData.Browser,\n version: this.version,\n sent: this.sent,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @private\n * @method _fromVisits - an internal method for creating an instance of Browser class from a list of visits\n * @param {VisitType[]} visits - a list of visits\n * @returns {Browser | undefined} an instance of Browser class or undefined if browser can not be found among visits\n * */\n public static _fromVisits(visits: VisitType[]): Browser | undefined {\n let browserData: {\n browserType?: BrowserType | null;\n browserIndex?: number | null;\n browserVersion?: number | null;\n } = {};\n\n // --- Note ---\n // Going backwards to get the latest visit data\n for (let i = visits.length - 1; i >= 0; i--) {\n const visit = visits[i];\n if (!visit.staticDataEvent) {\n continue;\n }\n\n const {\n browser: browserType,\n browserIndex,\n browserVersion,\n } = visit.staticDataEvent.data;\n\n if (browserType || browserIndex !== null) {\n browserData = { browserType, browserIndex, browserVersion };\n }\n }\n\n const { browserType, browserIndex, browserVersion } = browserData;\n\n if (browserType || typeof browserIndex === 'number') {\n const browser = browserType\n ? browserType\n : BrowserTypeMap[browserIndex as number];\n\n if (browserVersion) {\n return new Browser(browser, browserVersion);\n } else {\n return new Browser(browser);\n }\n }\n }\n}\n"],"mappings":"+pBAcO,KAAM,CAAAA,OAAkC,CAc7CC,WAAWA,CAACC,CAAoB,CAAEC,CAAgB,CAAE,CAAAC,eAAA,wBAAAA,eAAA,wBAAAA,eAAA,qBAClD,IAAI,CAACF,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACC,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACE,IAAI,GACX,CAKA,GAAI,CAAAC,GAAGA,CAAA,CAAW,CAIhB,GAAI,CAAC,IAAI,CAACJ,OAAO,CACf,MAAO,EAAE,CAGX,KAAM,CAAAK,CAAc,CAAG,IAAI,CAACJ,OAAO,CAC/BK,uBAAY,CAACC,cAAc,CAAG,IAAI,CAACN,OAAO,CAC1C,EAAE,CAEN,MACE,CAAAO,uBAA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EjE,GAAIK,CAAW,EAA4B,QAAQ,EAAhC,MAAO,CAAAC,CAAyB,CAAE,CACnD,KAAM,CAAAzB,CAAO,CAAGwB,CAAW,CACvBA,CAAW,CACXE,qBAAc,CAACD,CAAY,CAAW,CAAC,MAEvC,CAAApB,CAAc,CACT,GAAI,CAAAP,OAAO,CAACE,CAAO,CAAEK,CAAc,CAAC,CAEpC,GAAI,CAAAP,OAAO,CAACE,CAAO,CAE9B,CACF,CACF,CAAC2B,OAAA,CAAA7B,OAAA,CAAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CLEANUP_INTERVAL=void 0;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CLEANUP_INTERVAL=void 0;const DEFAULT_CLEANUP_INTERVAL=exports.DEFAULT_CLEANUP_INTERVAL=30;
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DEFAULT_CLEANUP_INTERVAL","exports"],"sources":["../../src/kameleoonData/constants.ts"],"sourcesContent":["/**\n * @constant default cleanup interval in minutes\n * */\nexport const DEFAULT_CLEANUP_INTERVAL = 30;\n"],"mappings":"4GAGO,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["DEFAULT_CLEANUP_INTERVAL","exports"],"sources":["../../src/kameleoonData/constants.ts"],"sourcesContent":["/**\n * @constant default cleanup interval in minutes\n * */\nexport const DEFAULT_CLEANUP_INTERVAL = 30;\n"],"mappings":"4GAGO,KAAM,CAAAA,wBAAwB,CAAAC,OAAA,CAAAD,wBAAA,CAAG,EAAE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class Conversion{constructor(a){let{goalId:b,revenue:c=0,negative:d=!1}=a;_defineProperty(this,"goalId",void 0),_defineProperty(this,"revenue",void 0),_defineProperty(this,"negative",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"nonce",void 0),this.goalId=b,this.revenue=c,this.negative=d,this.sent=!1,this.nonce=_utilities.Utilities.getNonce()}get url(){return this.goalId?_requester.UrlEventType.Conversion+_requester.UrlParameter.GoalId+(this.goalId+"")+_requester.UrlParameter.Revenue+(this.revenue+"")+_requester.UrlParameter.Negative+(this.negative+"")+_requester.UrlParameter.Nonce+this.nonce:""}get data(){return{goalId:this.goalId,revenue:this.revenue,negative:this.negative,type:_types.KameleoonData.Conversion,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static _listFromVisits(a){const b=[],c=new Map;for(const d of a){if(!d.conversionEvents)continue;const a=d.conversionEvents;for(const d of a){const{goalId:a}=d.data;if(!c.has(a)){c.set(a,!0);const d=new Conversion({goalId:a});d.isSent=!0,b.push(d)}}}return b}}exports.Conversion=Conversion;
|
|
2
2
|
//# sourceMappingURL=conversion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.js","names":["Conversion","
|
|
1
|
+
{"version":3,"file":"conversion.js","names":["Conversion","constructor","a","goalId","revenue","negative","_defineProperty","sent","nonce","Utilities","getNonce","url","UrlEventType","UrlParameter","GoalId","Revenue","Negative","Nonce","data","type","KameleoonData","isSent","value","_listFromVisits","visits","resultConversions","goalIdMap","Map","visit","conversionEvents","conversionEvent","has","set","conversion","push","exports"],"sources":["../../src/kameleoonData/conversion.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { Utilities } from 'src/utilities';\nimport {\n ConversionDataType,\n ConversionParametersType,\n IKameleoonData,\n KameleoonData,\n} from './types';\n\n/**\n * @class\n * Conversion - a class for creating an instance for conversion tracking\n * */\nexport class Conversion implements IKameleoonData {\n private goalId: number;\n private revenue: number;\n private negative: boolean;\n private sent: boolean;\n private nonce: string;\n\n /**\n * @param {ConversionParametersType} conversionParameters - an object with conversion parameters\n * */\n constructor({\n goalId,\n revenue = 0,\n negative = false,\n }: ConversionParametersType) {\n this.goalId = goalId;\n this.revenue = revenue;\n this.negative = negative;\n this.sent = false;\n this.nonce = Utilities.getNonce();\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.goalId) {\n return '';\n }\n\n return (\n UrlEventType.Conversion +\n UrlParameter.GoalId +\n String(this.goalId) +\n UrlParameter.Revenue +\n String(this.revenue) +\n UrlParameter.Negative +\n String(this.negative) +\n UrlParameter.Nonce +\n this.nonce\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): ConversionDataType {\n return {\n goalId: this.goalId,\n revenue: this.revenue,\n negative: this.negative,\n type: KameleoonData.Conversion,\n sent: this.sent,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @private\n * @method _listFromVisits - an internal method for creating a list of Conversion instances\n * @param {VisitType[]} visits - a list of visits\n * @returns {Conversion[]} a list of Conversion instances\n * */\n public static _listFromVisits(visits: VisitType[]): Conversion[] {\n const resultConversions: Conversion[] = [];\n const goalIdMap = new Map();\n\n for (const visit of visits) {\n if (!visit.conversionEvents) {\n continue;\n }\n\n const conversionEvents = visit.conversionEvents;\n\n for (const conversionEvent of conversionEvents) {\n const { goalId } = conversionEvent.data;\n\n // --- Note ---\n // - We only take unique `goalId`s as and don't use `revenue` and `negative`\n // because we only utilize it for Conversion Condition and don't re-sent this data tracking\n // not to break server `revenue` calculations and not to cause extra conversions\n // - Moreover conversion is marked as sent, so the visitor won't be converted again just\n // by pulling visits data\n if (!goalIdMap.has(goalId)) {\n goalIdMap.set(goalId, true);\n\n const conversion = new Conversion({ goalId });\n conversion.isSent = true;\n\n resultConversions.push(conversion);\n }\n }\n }\n\n return resultConversions;\n }\n}\n"],"mappings":"qsBAaO,KAAM,CAAAA,UAAqC,CAUhDC,WAAWA,CAAAC,CAAA,CAIkB,IAJjB,CACVC,MAAM,CAANA,CAAM,CACNC,OAAO,CAAPA,CAAO,CAAG,CAAC,CACXC,QAAQ,CAARA,CAAQ,GACgB,CAAC,CAAAH,CAAA,CAAAI,eAAA,uBAAAA,eAAA,wBAAAA,eAAA,yBAAAA,eAAA,qBAAAA,eAAA,sBACzB,IAAI,CAACH,MAAM,CAAGA,CAAM,CACpB,IAAI,CAACC,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACC,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACE,IAAI,GAAQ,CACjB,IAAI,CAACC,KAAK,CAAGC,oBAAS,CAACC,QAAQ,CAAC,CAClC,CAKA,GAAI,CAAAC,GAAGA,CAAA,CAAW,OAIX,KAAI,CAACR,MAAM,CAKdS,uBAAY,CAACZ,UAAU,CACvBa,uBAAY,CAACC,MAAM,EACZ,IAAI,CAACX,MAAM,IAAC,CACnBU,uBAAY,CAACE,OAAO,EACb,IAAI,CAACX,OAAO,IAAC,CACpBS,uBAAY,CAACG,QAAQ,EACd,IAAI,CAACX,QAAQ,IAAC,CACrBQ,uBAAY,CAACI,KAAK,CAClB,I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@@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _kameleoonError=require("../kameleoonError"),_types=require("./types");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _kameleoonError=require("../kameleoonError"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class Cookie{constructor(a){_defineProperty(this,"cookie",void 0),_defineProperty(this,"sent",void 0),this.cookie=a,this.sent=!1}static fromString(a){if(!a)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.CookieParse,"Cookie string can't be empty");const b=a.split(";"),c=b.map(a=>{const[b,c]=a.trim().split("=");if(!b||!c)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.CookieParse,"Cookie string is not valid");return{key:b,value:c}});return new Cookie(c)}get url(){return""}get data(){return{cookie:this.cookie,type:_types.KameleoonData.Cookie,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}}exports.Cookie=Cookie;
|
|
2
2
|
//# sourceMappingURL=cookie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","names":["Cookie","
|
|
1
|
+
{"version":3,"file":"cookie.js","names":["Cookie","constructor","cookie","_defineProperty","sent","fromString","cookieString","KameleoonError","KameleoonException","CookieParse","pairs","split","map","item","key","value","trim","url","data","type","KameleoonData","isSent","exports"],"sources":["../../src/kameleoonData/cookie.ts"],"sourcesContent":["import { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport {\n CookieDataType,\n CookieType,\n IKameleoonData,\n KameleoonData,\n} from './types';\n\n/**\n * @class\n * Cookie - a class for creating an instance for defining user's cookie\n * */\nexport class Cookie implements IKameleoonData {\n private cookie: CookieType[];\n private sent: boolean;\n\n /**\n * @param {CookieType[]} cookie - a list of cookies\n * */\n constructor(cookie: CookieType[]) {\n this.cookie = cookie;\n this.sent = false;\n }\n\n /**\n * @method fromString - a static method for creating an instance of `Cookie` from a string\n * @param {string} cookieString - a string containing a list of cookies\n * @throws {KameleoonError} throws an error if the string is not valid cookie\n * @returns {Cookie} an instance of `Cookie`\n * */\n static fromString(cookieString: string): Cookie {\n if (!cookieString) {\n throw new KameleoonError(\n KameleoonException.CookieParse,\n \"Cookie string can't be empty\",\n );\n }\n\n const pairs = cookieString.split(';');\n\n const cookie = pairs.map((item) => {\n const [key, value] = item.trim().split('=');\n\n if (!key || !value) {\n throw new KameleoonError(\n KameleoonException.CookieParse,\n 'Cookie string is not valid',\n );\n }\n\n return { key, value };\n });\n\n return new Cookie(cookie);\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n return '';\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): CookieDataType {\n return {\n cookie: this.cookie,\n type: KameleoonData.Cookie,\n sent: this.sent,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n}\n"],"mappings":"wqBAYO,KAAM,CAAAA,MAAiC,CAO5CC,WAAWA,CAACC,CAAoB,CAAE,CAAAC,eAAA,uBAAAA,eAAA,qBAChC,IAAI,CAACD,MAAM,CAAGA,CAAM,CACpB,IAAI,CAACE,IAAI,GACX,CAQA,MAAO,CAAAC,UAAUA,CAACC,CAAoB,CAAU,CAC9C,GAAI,CAACA,CAAY,CACf,KAAM,IAAI,CAAAC,8BAAc,CACtBC,kCAAkB,CAACC,WAAW,CAC9B,8BACF,CAAC,CACF,KAEK,CAAAC,CAAK,CAAGJ,CAAY,CAACK,KAAK,CAAC,GAAG,CAAC,CAE/BT,CAAM,CAAGQ,CAAK,CAACE,GAAG,CAAEC,CAAI,EAAK,CACjC,KAAM,CAACC,CAAG,CAAEC,CAAK,CAAC,CAAGF,CAAI,CAACG,IAAI,CAAC,CAAC,CAACL,KAAK,CAAC,GAAG,CAAC,CAE3C,GAAI,CAACG,CAAG,EAAI,CAACC,CAAK,CAChB,KAAM,IAAI,CAAAR,8BAAc,CACtBC,kCAAkB,CAACC,WAAW,CAC9B,4BACF,CAAC,CAGH,MAAO,CAAEK,GAAG,CAAHA,CAAG,CAAEC,KAAK,CAALA,CAAM,CACtB,CAAC,CAAC,CAEF,MAAO,IAAI,CAAAf,MAAM,CAACE,CAAM,CAC1B,CAKA,GAAI,CAAAe,GAAGA,CAAA,CAAW,CAChB,MAAO,EACT,CAKA,GAAI,CAAAC,IAAIA,CAAA,CAAmB,CACzB,MAAO,CACLhB,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBiB,IAAI,CAAEC,oBAAa,CAACpB,MAAM,CAC1BI,IAAI,CAAE,IAAI,CAACA,IACb,CACF,CAKA,GAAI,CAAAiB,MAAMA,CAAA,CAAY,CACpB,MAAO,KAAI,CAACjB,IACd,CAEA,GAAI,CAAAiB,MAAMA,CAACN,CAAc,CAAE,CACzB,IAAI,CAACX,IAAI,CAAGW,CACd,CACF,CAACO,OAAA,CAAAtB,MAAA,CAAAA,MAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_types=require("./types");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_types=require("./types");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class CustomData{constructor(a){_defineProperty(this,"index",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"isIdentifier",void 0),this.index=a;for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.value=c,this.sent=!1,this.isIdentifier=!1}get url(){if("number"!=typeof this.index)return"";const a=[...new Set(this.value)];let b={};if(a.forEach(a=>{b[a]=1}),!Object.keys(b).length)return"";let c="";return this.isIdentifier&&(c=_requester.UrlParameter.MappingIdentifier+"true"),_requester.UrlEventType.CustomData+_requester.UrlParameter.Index+this.index+_requester.UrlParameter.ValuesCountMap+encodeURIComponent(JSON.stringify(b))+_requester.UrlParameter.Overwrite+"true"+c}get data(){return{index:this.index,value:this.value,type:_types.KameleoonData.CustomData,isIdentifier:this.isIdentifier,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}set _isMappingIdentifier(a){this.isIdentifier=a}static _listFromVisits(a){const b=[],c=new Map;for(let b=a.length-1;0<=b;b--){const d=a[b];if(!d.customDataEvents)continue;const e=d.customDataEvents;for(const a of e){const{index:b,valuesCountMap:d}=a.data;c.set(b,Object.keys(d))}}for(const[d,e]of c)b.push(new CustomData(d,...e));return b}}exports.CustomData=CustomData;
|
|
2
2
|
//# sourceMappingURL=customData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customData.js","names":["CustomData","
|
|
1
|
+
{"version":3,"file":"customData.js","names":["CustomData","constructor","index","_defineProperty","b","arguments","length","value","Array","d","sent","isIdentifier","url","uniqueValues","Set","resultValue","forEach","Object","keys","identifierParameter","UrlParameter","MappingIdentifier","UrlEventType","Index","ValuesCountMap","encodeURIComponent","JSON","stringify","Overwrite","data","type","KameleoonData","isSent","_isMappingIdentifier","_listFromVisits","visits","resultData","customDataMap","Map","i","visit","customDataEvents","customDataEvent","valuesCountMap","set","push","exports"],"sources":["../../src/kameleoonData/customData.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { CustomDataType, IKameleoonData, KameleoonData } from './types';\n\n/**\n * @class\n * CustomData - a class for creating an instance for user's custom data\n * */\nexport class CustomData implements IKameleoonData {\n private index: number;\n private value: string[];\n private sent: boolean;\n private isIdentifier: boolean;\n\n /**\n * @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application\n * @param {string[]} value - custom value to store under the specified id, value can be anything but has to be stringified to match the `string` type. *Note* value is variadic parameter and can be used as follows\n * @example\n * ```ts\n * // - Single value\n * const customData = new CustomData(0, 'value_1');\n * // - Variadic number of values\n * const customData = new CustomData(0, 'value_1', 'value_2', 'value_3');\n * // - Array of values\n * const values = ['value_1', 'value_2', 'value_3'];\n * const customData = new CustomData(0, ...values);\n * ```\n * */\n constructor(index: number, ...value: string[]) {\n this.index = index;\n this.value = value;\n this.sent = false;\n this.isIdentifier = false;\n }\n\n /**\n * @property url - url for the current data type used for events tracking\n * */\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (typeof this.index !== 'number') {\n return '';\n }\n\n const uniqueValues = [...new Set(this.value)];\n let resultValue: Record<string, 1> = {};\n\n // --- Note ---\n // Final value should look like this `{ \"value_1\": 1, \"value_2\": 1, \"value_3\": 1}`\n // With no duplicates\n uniqueValues.forEach((value) => {\n resultValue[value] = 1;\n });\n\n if (!Object.keys(resultValue).length) {\n return '';\n }\n\n let identifierParameter = '';\n\n if (this.isIdentifier) {\n identifierParameter = UrlParameter.MappingIdentifier + String(true);\n }\n\n return (\n UrlEventType.CustomData +\n UrlParameter.Index +\n this.index +\n UrlParameter.ValuesCountMap +\n encodeURIComponent(JSON.stringify(resultValue)) +\n UrlParameter.Overwrite +\n String(true) +\n identifierParameter\n );\n }\n\n /**\n * @property data - data of the current class instance\n * */\n get data(): CustomDataType {\n return {\n index: this.index,\n value: this.value,\n type: KameleoonData.CustomData,\n isIdentifier: this.isIdentifier,\n sent: this.sent,\n };\n }\n\n /**\n * @property isSent - signifying if the data was sent already tracked\n * */\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @property isMappingIdentifier - signifying if the data is a mapping identifier\n * @private\n * */\n set _isMappingIdentifier(value: boolean) {\n this.isIdentifier = value;\n }\n\n /**\n * @private\n * @method _listFromVisits - an internal method for creating a list of custom data from a list of visits\n * @param {VisitType[]} visits - a list of visits\n * @returns {CustomData[]} a list of custom data\n * */\n public static _listFromVisits(visits: VisitType[]): CustomData[] {\n const resultData: CustomData[] = [];\n const customDataMap = new Map<number, string[]>();\n\n // --- Note ---\n // Going backwards to get the latest visit data\n for (let i = visits.length - 1; i >= 0; i--) {\n const visit = visits[i];\n\n if (!visit.customDataEvents) {\n continue;\n }\n\n const customDataEvents = visit.customDataEvents;\n\n for (const customDataEvent of customDataEvents) {\n const { index, valuesCountMap } = customDataEvent.data;\n\n customDataMap.set(index, Object.keys(valuesCountMap));\n }\n }\n\n for (const [index, data] of customDataMap) {\n resultData.push(new CustomData(index, ...data));\n }\n\n return resultData;\n }\n}\n"],"mappings":"kqBAOO,KAAM,CAAAA,UAAqC,CAoBhDC,WAAWA,CAACC,CAAa,CAAsB,CAAAC,eAAA,sBAAAA,eAAA,sBAAAA,eAAA,qBAAAA,eAAA,6BAC7C,IAAI,CAACD,KAAK,CAAGA,CAAK,SAAAE,CAAA,CAAAC,SAAA,CAAAC,MAAA,CADUC,CAAK,CAAAC,KAAA,GAAAJ,CAAA,CAAAA,CAAA,MAAAK,CAAA,GAAAA,CAAA,CAAAL,CAAA,CAAAK,CAAA,GAALF,CAAK,CAAAE,CAA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