@kameleoon/javascript-sdk-core 4.4.8 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/cacheManager/cacheManager.js +1 -1
- package/dist/cacheManager/cacheManager.js.map +1 -1
- package/dist/cacheManager/index.js.map +1 -1
- package/dist/cacheManager/types.js.map +1 -1
- package/dist/clientConfiguration/clientConfiguration.d.ts +2 -6
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/index.js.map +1 -1
- package/dist/clientConfiguration/types.d.ts +2 -5
- package/dist/clientConfiguration/types.js +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/clientSettings/clientSettings.d.ts +2 -1
- package/dist/clientSettings/clientSettings.js +1 -1
- package/dist/clientSettings/clientSettings.js.map +1 -1
- package/dist/clientSettings/index.js.map +1 -1
- package/dist/clientSettings/types.d.ts +1 -0
- package/dist/clientSettings/types.js.map +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/eventManager/eventManager.js +1 -1
- package/dist/eventManager/eventManager.js.map +1 -1
- package/dist/eventManager/index.js.map +1 -1
- package/dist/eventManager/types.js.map +1 -1
- package/dist/eventSource/constants.js.map +1 -1
- package/dist/eventSource/eventSource.js +1 -1
- package/dist/eventSource/eventSource.js.map +1 -1
- package/dist/eventSource/index.js.map +1 -1
- package/dist/eventSource/types.js.map +1 -1
- package/dist/hasher/hasher.js.map +1 -1
- package/dist/hasher/index.js.map +1 -1
- package/dist/hasher/types.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +6 -13
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +18 -16
- package/dist/kameleoonClientInterface.js.map +1 -1
- package/dist/kameleoonData/applicationVersion.d.ts +2 -3
- package/dist/kameleoonData/applicationVersion.js +1 -1
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +9 -3
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/conversion.d.ts +12 -3
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.d.ts +2 -3
- package/dist/kameleoonData/cookie.js +1 -1
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.d.ts +11 -3
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.d.ts +34 -23
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +22 -24
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.d.ts +9 -3
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.d.ts +9 -3
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/helpers.js.map +1 -1
- package/dist/kameleoonData/index.d.ts +2 -1
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/index.js.map +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.d.ts +2 -1
- package/dist/kameleoonData/kameleoonConversionScore.js +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.js.map +1 -1
- package/dist/kameleoonData/operatingSystem.d.ts +9 -3
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.d.ts +12 -8
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +97 -31
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/uniqueIdentifier.d.ts +19 -0
- package/dist/kameleoonData/uniqueIdentifier.js +2 -0
- package/dist/kameleoonData/uniqueIdentifier.js.map +1 -0
- package/dist/kameleoonData/userAgent.d.ts +2 -3
- package/dist/kameleoonData/userAgent.js +1 -1
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitProcessor.d.ts +3 -4
- package/dist/kameleoonData/visitProcessor.js +1 -1
- package/dist/kameleoonData/visitProcessor.js.map +1 -1
- package/dist/kameleoonData/visitsData.d.ts +2 -0
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/kameleoonError/constants.js +1 -1
- package/dist/kameleoonError/constants.js.map +1 -1
- package/dist/kameleoonError/helpers.js +1 -1
- package/dist/kameleoonError/helpers.js.map +1 -1
- package/dist/kameleoonError/index.js.map +1 -1
- package/dist/kameleoonError/kameleoonError.js +1 -1
- package/dist/kameleoonError/kameleoonError.js.map +1 -1
- package/dist/kameleoonError/types.js.map +1 -1
- package/dist/kameleoonUtils.d.ts +1 -11
- package/dist/kameleoonUtils.js +1 -1
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +5 -7
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +7 -26
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +2 -2
- package/dist/requester/urlProvider.js +1 -1
- package/dist/requester/urlProvider.js.map +1 -1
- package/dist/storage/constants.d.ts +6 -2
- package/dist/storage/constants.js +1 -1
- package/dist/storage/constants.js.map +1 -1
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/integrityChecker.d.ts +20 -0
- package/dist/storage/integrityChecker.js +2 -0
- package/dist/storage/integrityChecker.js.map +1 -0
- package/dist/storage/storage.d.ts +0 -1
- package/dist/storage/storage.js +1 -1
- package/dist/storage/storage.js.map +1 -1
- package/dist/storage/types.d.ts +25 -17
- package/dist/storage/types.js.map +1 -1
- package/dist/targeting/conditions/applicationVersion.js +1 -1
- package/dist/targeting/conditions/applicationVersion.js.map +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/browser.js.map +1 -1
- package/dist/targeting/conditions/conditionFactory.js.map +1 -1
- package/dist/targeting/conditions/conversion.js +1 -1
- package/dist/targeting/conditions/conversion.js.map +1 -1
- package/dist/targeting/conditions/conversionLikelihood.js +1 -1
- package/dist/targeting/conditions/conversionLikelihood.js.map +1 -1
- package/dist/targeting/conditions/cookie.js +1 -1
- package/dist/targeting/conditions/cookie.js.map +1 -1
- package/dist/targeting/conditions/customData.js +1 -1
- package/dist/targeting/conditions/customData.js.map +1 -1
- package/dist/targeting/conditions/device.js +1 -1
- package/dist/targeting/conditions/device.js.map +1 -1
- package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -1
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/firstVisit.js.map +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/geolocation.js.map +1 -1
- package/dist/targeting/conditions/index.js.map +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/lastVisit.js.map +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/newVisitor.js.map +1 -1
- package/dist/targeting/conditions/operatingSystem.js +1 -1
- package/dist/targeting/conditions/operatingSystem.js.map +1 -1
- package/dist/targeting/conditions/pageTitle.js +1 -1
- package/dist/targeting/conditions/pageTitle.js.map +1 -1
- package/dist/targeting/conditions/pageUrl.js +1 -1
- package/dist/targeting/conditions/pageUrl.js.map +1 -1
- package/dist/targeting/conditions/previousPage.js +1 -1
- package/dist/targeting/conditions/previousPage.js.map +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
- package/dist/targeting/conditions/sdkLanguage.js +1 -1
- package/dist/targeting/conditions/sdkLanguage.js.map +1 -1
- package/dist/targeting/conditions/segment.js +1 -1
- package/dist/targeting/conditions/segment.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -1
- package/dist/targeting/conditions/types.js.map +1 -1
- package/dist/targeting/conditions/utilities.d.ts +5 -0
- package/dist/targeting/conditions/utilities.js +2 -0
- package/dist/targeting/conditions/utilities.js.map +1 -0
- package/dist/targeting/conditions/visitedPages.js +1 -1
- package/dist/targeting/conditions/visitedPages.js.map +1 -1
- package/dist/targeting/conditions/visitorCode.js +1 -1
- package/dist/targeting/conditions/visitorCode.js.map +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/conditions/visits.js.map +1 -1
- package/dist/targeting/index.d.ts +1 -1
- package/dist/targeting/index.js.map +1 -1
- package/dist/targeting/node.js +1 -1
- package/dist/targeting/node.js.map +1 -1
- package/dist/targeting/tree.js +1 -1
- package/dist/targeting/tree.js.map +1 -1
- package/dist/targeting/types.js.map +1 -1
- package/dist/tracking/bodyProvider.d.ts +26 -0
- package/dist/tracking/bodyProvider.js +2 -0
- package/dist/tracking/bodyProvider.js.map +1 -0
- package/dist/tracking/constants.d.ts +2 -0
- package/dist/tracking/constants.js +2 -0
- package/dist/tracking/constants.js.map +1 -0
- package/dist/tracking/index.d.ts +1 -0
- package/dist/tracking/index.js +2 -0
- package/dist/tracking/index.js.map +1 -0
- package/dist/tracking/tracker.d.ts +21 -0
- package/dist/tracking/tracker.js +2 -0
- package/dist/tracking/tracker.js.map +1 -0
- package/dist/tracking/types.d.ts +45 -0
- package/dist/tracking/types.js +2 -0
- package/dist/tracking/types.js.map +1 -0
- package/dist/types.d.ts +44 -15
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.d.ts +0 -1
- package/dist/utilities/constants.js +1 -1
- package/dist/utilities/constants.js.map +1 -1
- package/dist/utilities/index.d.ts +3 -2
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/parser.d.ts +10 -0
- package/dist/utilities/parser.js +2 -0
- package/dist/utilities/parser.js.map +1 -0
- package/dist/utilities/types.d.ts +3 -40
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.d.ts +5 -21
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/utilities/validator.d.ts +5 -0
- package/dist/utilities/validator.js +2 -0
- package/dist/utilities/validator.js.map +1 -0
- package/dist/variationConfiguration/index.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +7 -2
- package/dist/variationConfiguration/types.js.map +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +15 -7
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/dist/visitorCodeManager/constants.d.ts +2 -0
- package/dist/visitorCodeManager/constants.js +1 -1
- package/dist/visitorCodeManager/constants.js.map +1 -1
- package/dist/visitorCodeManager/index.js.map +1 -1
- package/dist/visitorCodeManager/types.d.ts +3 -0
- package/dist/visitorCodeManager/types.js.map +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.d.ts +4 -0
- package/dist/visitorCodeManager/visitorCodeManager.js +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { EventCallbackType, EventType } from './eventManager';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n KameleoonVariationType,\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 *\n * Triggered Events: `EventType.ConfigurationUpdate` (On each successful configuration update while using Real Time Update)\n *\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`, `filters` and `isUniqueIdentifier` 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 isUniqueIdentifier,\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 *\n * Note: This method **doesn't send** tracking data\n *\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 *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\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 getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\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.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 * @method onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.\n *\n * Note: SDK methods are marked with the `EventType` they trigger if any.\n *\n * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event\n *\n * Parameter type depends on the `EventType` passed:\n * - `EventType.Evaluation` - `EvaluationEventDataType`\n * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`\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 onEvent: <E extends EventType>(\n event: E,\n callback: EventCallbackType<E>,\n ) => void;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { EventCallbackType, EventType } from './eventManager';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n KameleoonVariationType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @deprecated - this overload is deprecated and will be removed in the future, data caching is now done automatically\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 *\n * Triggered Events: `EventType.ConfigurationUpdate` (On each successful configuration update while using Real Time Update)\n *\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(): Promise<boolean>;\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 *\n * Triggered Events: `EventType.ConfigurationUpdate` (On each successful configuration update while using Real Time Update)\n *\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(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n *\n * Note: This method **doesn't send** tracking data\n *\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 *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\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 getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\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.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\n *\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 onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.\n *\n * Note: SDK methods are marked with the `EventType` they trigger if any.\n *\n * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event\n *\n * Parameter type depends on the `EventType` passed:\n * - `EventType.Evaluation` - `EvaluationEventDataType`\n * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`\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 onEvent: <E extends EventType>(\n event: E,\n callback: EventCallbackType<E>,\n ) => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { TrackingStatus } from '../types';
|
|
1
2
|
import { IKameleoonData, ApplicationVersionDataType } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* @class
|
|
4
5
|
* ApplicationVersion - a class for creating an instance for app version
|
|
5
6
|
* */
|
|
6
7
|
export declare class ApplicationVersion implements IKameleoonData {
|
|
8
|
+
status: TrackingStatus;
|
|
7
9
|
private version;
|
|
8
|
-
private sent;
|
|
9
10
|
/**
|
|
10
11
|
* @param {string} version - version of mobile application
|
|
11
12
|
* */
|
|
12
13
|
constructor(version: string);
|
|
13
14
|
get url(): string;
|
|
14
15
|
get data(): ApplicationVersionDataType;
|
|
15
|
-
get isSent(): boolean;
|
|
16
|
-
set isSent(value: boolean);
|
|
17
16
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApplicationVersion=void 0;var _types=require("../types"),_types2=require("./types");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 ApplicationVersion{constructor(a){_defineProperty(this,"status",void 0),_defineProperty(this,"version",void 0),this.version=a,this.status=_types.TrackingStatus.Sent}get url(){return""}get data(){return{version:this.version,type:_types2.KameleoonData.ApplicationVersion,status:this.status}}}exports.ApplicationVersion=ApplicationVersion;
|
|
2
2
|
//# sourceMappingURL=applicationVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationVersion.js","names":["
|
|
1
|
+
{"version":3,"file":"applicationVersion.js","names":["ApplicationVersion","constructor","version","_defineProperty","status","TrackingStatus","Sent","url","data","type","KameleoonData","exports"],"sources":["../../src/kameleoonData/applicationVersion.ts"],"sourcesContent":["import { TrackingStatus } from 'src/types';\nimport {\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 public status: TrackingStatus;\n\n private version: string;\n\n /**\n * @param {string} version - version of mobile application\n * */\n constructor(version: string) {\n this.version = version;\n this.status = TrackingStatus.Sent;\n }\n\n get url(): string {\n return '';\n }\n\n get data(): ApplicationVersionDataType {\n return {\n version: this.version,\n type: KameleoonData.ApplicationVersion,\n status: this.status,\n };\n }\n}\n"],"mappings":"iqBAWO,KAAM,CAAAA,kBAA6C,CAQxDC,WAAWA,CAACC,CAAe,CAAE,CAAAC,eAAA,uBAAAA,eAAA,wBAC3B,IAAI,CAACD,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACE,MAAM,CAAGC,qBAAc,CAACC,IAC/B,CAEA,GAAI,CAAAC,GAAGA,CAAA,CAAW,CAChB,MAAO,EACT,CAEA,GAAI,CAAAC,IAAIA,CAAA,CAA+B,CACrC,MAAO,CACLN,OAAO,CAAE,IAAI,CAACA,OAAO,CACrBO,IAAI,CAAEC,qBAAa,CAACV,kBAAkB,CACtCI,MAAM,CAAE,IAAI,CAACA,MACf,CACF,CACF,CAACO,OAAA,CAAAX,kBAAA,CAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { VisitType } from '../requester';
|
|
2
2
|
import { BrowserDataType, BrowserType, IKameleoonData } from './types';
|
|
3
|
+
import { TrackingStatus } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* @class
|
|
5
6
|
* Browser - a class for creating an instance for browser of a certain type
|
|
6
7
|
* */
|
|
7
8
|
export declare class Browser implements IKameleoonData {
|
|
9
|
+
status: TrackingStatus;
|
|
8
10
|
private browser;
|
|
9
11
|
private version?;
|
|
10
|
-
private sent;
|
|
11
12
|
/**
|
|
12
13
|
* @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`
|
|
13
14
|
* @param {number | undefined} version - version of the browser, floating point number represents major and minor version of the browser
|
|
@@ -20,8 +21,13 @@ export declare class Browser implements IKameleoonData {
|
|
|
20
21
|
constructor(browser: BrowserType, version?: number);
|
|
21
22
|
get url(): string;
|
|
22
23
|
get data(): BrowserDataType;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @method _fromRaw - an internal method for creating a Browser instance from raw data
|
|
27
|
+
* @param {BrowserDataType} data - a raw data
|
|
28
|
+
* @return {Browser} a Browser instance
|
|
29
|
+
* */
|
|
30
|
+
static _fromRaw(data: BrowserDataType): Browser;
|
|
25
31
|
/**
|
|
26
32
|
* @private
|
|
27
33
|
* @method _fromVisit - an internal method for creating an instance of Browser class from a visit
|
|
@@ -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 _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _requester=require("../requester"),_types=require("./types"),_types2=require("../types");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 Browser{constructor(a,b){_defineProperty(this,"status",void 0),_defineProperty(this,"browser",void 0),_defineProperty(this,"version",void 0),this.browser=a,this.version=b,this.status=_types2.TrackingStatus.Unsent}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,status:this.status}}static _fromRaw(a){const{browser:b,version:c,status:d}=a,e=new Browser(b,c);return e.status=d,e}static _fromVisit(a){if(a.staticDataEvent){const{browser:b,browserIndex:c,browserVersion:d}=a.staticDataEvent.data;if(b||"number"==typeof c){const a=b??_types.BrowserTypeMap[c];return d?new Browser(a,d):new Browser(a)}}}}exports.Browser=Browser;
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":["Browser","constructor","browser","version","_defineProperty","
|
|
1
|
+
{"version":3,"file":"browser.js","names":["Browser","constructor","browser","version","_defineProperty","status","TrackingStatus","Unsent","url","browserVersion","UrlParameter","BrowserVersion","UrlEventType","StaticData","BrowserIndex","BrowserIndexMap","data","type","KameleoonData","_fromRaw","browserType","_fromVisit","visit","staticDataEvent","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';\nimport { TrackingStatus } from 'src/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 public status: TrackingStatus;\n\n private browser: BrowserType;\n private version?: number;\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.status = TrackingStatus.Unsent;\n }\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 get data(): BrowserDataType {\n return {\n browser: this.browser,\n type: KameleoonData.Browser,\n version: this.version,\n status: this.status,\n };\n }\n\n /**\n * @private\n * @method _fromRaw - an internal method for creating a Browser instance from raw data\n * @param {BrowserDataType} data - a raw data\n * @return {Browser} a Browser instance\n * */\n public static _fromRaw(data: BrowserDataType): Browser {\n const { browser: browserType, version, status } = data;\n const browser = new Browser(browserType, version);\n\n browser.status = status;\n\n return browser;\n }\n\n /**\n * @private\n * @method _fromVisit - an internal method for creating an instance of Browser class from a visit\n * @param {VisitType} visit - a visit\n * @returns {Browser | undefined} an instance of Browser class or undefined if browser can not be found among visits\n * */\n public static _fromVisit(visit: VisitType): Browser | undefined {\n if (!visit.staticDataEvent) {\n return undefined;\n }\n\n const {\n browser: browserType,\n browserIndex,\n browserVersion,\n } = visit.staticDataEvent.data;\n\n if (browserType || typeof browserIndex === 'number') {\n const browser = browserType ?? 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 return undefined;\n }\n}\n"],"mappings":"yrBAeO,KAAM,CAAAA,OAAkC,CAe7CC,WAAWA,CAACC,CAAoB,CAAEC,CAAgB,CAAE,CAAAC,eAAA,uBAAAA,eAAA,wBAAAA,eAAA,wBAClD,IAAI,CAACF,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACC,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACE,MAAM,CAAGC,sBAAc,CAACC,MAC/B,CAEA,GAAI,CAAAC,GAAGA,CAAA,CAAW,CAIhB,GAAI,CAAC,IAAI,CAACN,OAAO,CACf,MAAO,EAAE,CAGX,KAAM,CAAAO,CAAc,CAAG,IAAI,CAACN,OAAO,CAC/BO,uBAAY,CAACC,cAAc,CAAG,IAAI,CAACR,OAAO,CAC1C,EAAE,CAEN,MACE,CAAAS,uBAAY,CAACC,UAAU,CACvBH,uBAAY,CAACV,OAAO,CACpB,IAAI,CAACE,OAAO,CACZQ,uBAAY,CAACI,YAAY,CACzBC,sBAAe,CAAC,IAAI,CAACb,OAAO,CAAC,CAC7BO,CAEJ,CAEA,GAAI,CAAAO,IAAIA,CAAA,CAAoB,CAC1B,MAAO,CACLd,OAAO,CAAE,IAAI,CAACA,OAAO,CACrBe,IAAI,CAAEC,oBAAa,CAAClB,OAAO,CAC3BG,OAAO,CAAE,IAAI,CAACA,OAAO,CACrBE,MAAM,CAAE,IAAI,CAACA,MACf,CACF,CAQA,MAAc,CAAAc,QAAQA,CAACH,CAAqB,CAAW,MAC/C,CAAEd,OAAO,CAAEkB,CAAW,CAAEjB,OAAO,CAAPA,CAAO,CAAEE,MAAM,CAANA,CAAO,CAAC,CAAGW,CAAI,CAChDd,CAAO,CAAG,GAAI,CAAAF,OAAO,CAACoB,CAAW,CAAEjB,CAAO,CAAC,CAIjD,MAFA,CAAAD,CAAO,CAACG,MAAM,CAAGA,CAAM,CAEhBH,CACT,CAQA,MAAc,CAAAmB,UAAUA,CAACC,CAAgB,CAAuB,CAC9D,GAAKA,CAAK,CAACC,eAAe,EAI1B,KAAM,CACJrB,OAAO,CAAEkB,CAAW,CACpBI,YAAY,CAAZA,CAAY,CACZf,cAAc,CAAdA,CACF,CAAC,CAAGa,CAAK,CAACC,eAAe,CAACP,IAAI,CAE9B,GAAII,CAAW,EAA4B,QAAQ,EAAhC,MAAO,CAAAI,CAAyB,CAAE,CACnD,KAAM,CAAAtB,CAAO,CAAGkB,CAAW,EAAIK,qBAAc,CAACD,CAAY,CAAW,CAAC,MAElE,CAAAf,CAAc,CACT,GAAI,CAAAT,OAAO,CAACE,CAAO,CAAEO,CAAc,CAAC,CAEpC,GAAI,CAAAT,OAAO,CAACE,CAAO,CAE9B,CAAC,CAGH,CACF,CAACwB,OAAA,CAAA1B,OAAA,CAAAA,OAAA","ignoreList":[]}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { VisitType } from '../requester';
|
|
2
2
|
import { ConversionDataType, ConversionParametersType, IKameleoonData } from './types';
|
|
3
|
+
import { TrackingStatus } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* @class
|
|
5
6
|
* Conversion - a class for creating an instance for conversion tracking
|
|
6
7
|
* */
|
|
7
8
|
export declare class Conversion implements IKameleoonData {
|
|
9
|
+
status: TrackingStatus;
|
|
8
10
|
private goalId;
|
|
9
11
|
private revenue;
|
|
10
12
|
private negative;
|
|
11
|
-
private
|
|
13
|
+
private id;
|
|
12
14
|
private nonce;
|
|
13
15
|
/**
|
|
14
16
|
* @param {ConversionParametersType} conversionParameters - an object with conversion parameters
|
|
15
17
|
* */
|
|
16
18
|
constructor({ goalId, revenue, negative, }: ConversionParametersType);
|
|
19
|
+
set _id(id: number);
|
|
20
|
+
set _nonce(nonce: string);
|
|
17
21
|
get url(): string;
|
|
18
22
|
get data(): ConversionDataType;
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @method _fromRaw - an internal method for creating a Conversion instance from raw data
|
|
26
|
+
* @param {ConversionDataType} data - a raw data
|
|
27
|
+
* @return {Conversion} a Conversion instance
|
|
28
|
+
* */
|
|
29
|
+
static _fromRaw(data: ConversionDataType): Conversion;
|
|
21
30
|
/**
|
|
22
31
|
* @private
|
|
23
32
|
* @method _listFromVisit - an internal method for returning a list of all Conversion instances
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),_types=require("./types"),_types2=require("../types");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 Conversion{constructor(a){let{goalId:b,revenue:c=0,negative:d=!1}=a;_defineProperty(this,"status",void 0),_defineProperty(this,"goalId",void 0),_defineProperty(this,"revenue",void 0),_defineProperty(this,"negative",void 0),_defineProperty(this,"id",void 0),_defineProperty(this,"nonce",void 0),this.goalId=b,this.revenue=c,this.negative=d,this.status=_types2.TrackingStatus.Unsent,this.id=Math.floor(1e6*Math.random())}set _id(a){this.id=a}set _nonce(a){this.nonce=a}get url(){return _requester.UrlEventType.Conversion+_requester.UrlParameter.GoalId+(this.goalId+"")+_requester.UrlParameter.Revenue+(this.revenue+"")+_requester.UrlParameter.Negative+(this.negative+"")}get data(){return{goalId:this.goalId,nonce:this.nonce,revenue:this.revenue,negative:this.negative,type:_types.KameleoonData.Conversion,status:this.status,id:this.id}}static _fromRaw(a){const{goalId:b,revenue:c,negative:d,status:e,id:f,nonce:g}=a,h=new Conversion({goalId:b,revenue:c,negative:d});return h._id=f,h.status=e,g&&(h._nonce=g),h}static _listFromVisit(a){var b,c;const d=[];if(!(null!==(b=a.conversionEvents)&&void 0!==b&&b.length))return[];if(null!==(c=a.conversionEvents)&&void 0!==c&&c.length)for(const b of a.conversionEvents){const{goalId:a,revenue:c,negative:e}=b.data,f=new Conversion({goalId:a,revenue:c,negative:e});f.status=_types2.TrackingStatus.Sent,d.push(f)}return d}static _updateFromVisit(a,b){var c;if(null!==(c=a.conversionEvents)&&void 0!==c&&c.length)for(const c of a.conversionEvents){const{goalId:a}=c.data;if(!b.has(a)){const c=new Conversion({goalId:a});c.status=_types2.TrackingStatus.Sent,b.set(a,c)}}}}exports.Conversion=Conversion;
|
|
2
2
|
//# sourceMappingURL=conversion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.js","names":["Conversion","constructor","a","goalId","revenue","negative","_defineProperty","
|
|
1
|
+
{"version":3,"file":"conversion.js","names":["Conversion","constructor","a","goalId","revenue","negative","_defineProperty","status","TrackingStatus","Unsent","id","Math","floor","random","_id","_nonce","nonce","url","UrlEventType","UrlParameter","GoalId","Revenue","Negative","data","type","KameleoonData","_fromRaw","conversion","_listFromVisit","visit","b","c","conversions","conversionEvents","length","conversionEvent","Sent","push","_updateFromVisit","dataMap","has","set","exports"],"sources":["../../src/kameleoonData/conversion.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport {\n ConversionDataType,\n ConversionParametersType,\n IKameleoonData,\n KameleoonData,\n} from './types';\nimport { TrackingStatus } from 'src/types';\n\n/**\n * @class\n * Conversion - a class for creating an instance for conversion tracking\n * */\nexport class Conversion implements IKameleoonData {\n public status: TrackingStatus;\n\n private goalId: number;\n private revenue: number;\n private negative: boolean;\n private id: number;\n private nonce: string | undefined;\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.status = TrackingStatus.Unsent;\n this.id = Math.floor(Math.random() * 1_000_000);\n }\n\n set _id(id: number) {\n this.id = id;\n }\n\n set _nonce(nonce: string) {\n this.nonce = nonce;\n }\n\n get url(): string {\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 );\n }\n\n get data(): ConversionDataType {\n return {\n goalId: this.goalId,\n nonce: this.nonce,\n revenue: this.revenue,\n negative: this.negative,\n type: KameleoonData.Conversion,\n status: this.status,\n id: this.id,\n };\n }\n\n /**\n * @private\n * @method _fromRaw - an internal method for creating a Conversion instance from raw data\n * @param {ConversionDataType} data - a raw data\n * @return {Conversion} a Conversion instance\n * */\n public static _fromRaw(data: ConversionDataType): Conversion {\n const { goalId, revenue, negative, status, id, nonce } = data;\n const conversion = new Conversion({ goalId, revenue, negative });\n\n conversion._id = id;\n conversion.status = status;\n\n if (nonce) {\n conversion._nonce = nonce;\n }\n\n return conversion;\n }\n\n /**\n * @private\n * @method _listFromVisit - an internal method for returning a list of all Conversion instances\n * @param {VisitType} visit - a visits\n * @return {Conversion[]} - a list of Conversion instances\n * */\n public static _listFromVisit(visit: VisitType): Conversion[] {\n const conversions: Conversion[] = [];\n\n if (!visit.conversionEvents?.length) {\n return [];\n }\n\n if (visit.conversionEvents?.length) {\n for (const conversionEvent of visit.conversionEvents) {\n const { goalId, revenue, negative } = conversionEvent.data;\n const conversion = new Conversion({ goalId, revenue, negative });\n\n // --- Note ---\n // Conversion is marked as sent, so the visitor won't be converted again just\n // by pulling visits data\n conversion.status = TrackingStatus.Sent;\n conversions.push(conversion);\n }\n }\n\n return conversions;\n }\n\n /**\n * @private\n * @method _updateFromVisit - an internal method for updating a list of Conversion instances with only goalId\n * @param {VisitType} visit - a visits\n * @param {Map<number, Conversion>} dataMap - a map of Conversion instances\n * */\n public static _updateFromVisit(\n visit: VisitType,\n dataMap: Map<number, Conversion>,\n ): void {\n if (visit.conversionEvents?.length) {\n for (const conversionEvent of visit.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 (!dataMap.has(goalId)) {\n const conversion = new Conversion({ goalId });\n\n conversion.status = TrackingStatus.Sent;\n dataMap.set(goalId, conversion);\n }\n }\n }\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CookieDataType, CookieType, IKameleoonData } from './types';
|
|
2
|
+
import { TrackingStatus } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* @class
|
|
4
5
|
* Cookie - a class for creating an instance for defining user's cookie
|
|
5
6
|
* */
|
|
6
7
|
export declare class Cookie implements IKameleoonData {
|
|
8
|
+
status: TrackingStatus;
|
|
7
9
|
private cookie;
|
|
8
|
-
private sent;
|
|
9
10
|
/**
|
|
10
11
|
* @param {CookieType[]} cookie - a list of cookies
|
|
11
12
|
* */
|
|
@@ -19,6 +20,4 @@ export declare class Cookie implements IKameleoonData {
|
|
|
19
20
|
static fromString(cookieString: string): Cookie;
|
|
20
21
|
get url(): string;
|
|
21
22
|
get data(): CookieDataType;
|
|
22
|
-
get isSent(): boolean;
|
|
23
|
-
set isSent(value: boolean);
|
|
24
23
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cookie=void 0;var _kameleoonError=require("../kameleoonError"),_types=require("./types"),_types2=require("../types");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 Cookie{constructor(a){_defineProperty(this,"status",void 0),_defineProperty(this,"cookie",void 0),this.cookie=a,this.status=_types2.TrackingStatus.Sent}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,status:this.status}}}exports.Cookie=Cookie;
|
|
2
2
|
//# sourceMappingURL=cookie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","names":["Cookie","constructor","cookie","_defineProperty","
|
|
1
|
+
{"version":3,"file":"cookie.js","names":["Cookie","constructor","cookie","_defineProperty","status","TrackingStatus","Sent","fromString","cookieString","KameleoonError","KameleoonException","CookieParse","pairs","split","map","item","key","value","trim","url","data","type","KameleoonData","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';\nimport { TrackingStatus } from 'src/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 public status: TrackingStatus;\n\n private cookie: CookieType[];\n\n /**\n * @param {CookieType[]} cookie - a list of cookies\n * */\n constructor(cookie: CookieType[]) {\n this.cookie = cookie;\n this.status = TrackingStatus.Sent;\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 get url(): string {\n return '';\n }\n\n get data(): CookieDataType {\n return {\n cookie: this.cookie,\n type: KameleoonData.Cookie,\n status: this.status,\n };\n }\n}\n"],"mappings":"ksBAaO,KAAM,CAAAA,MAAiC,CAQ5CC,WAAWA,CAACC,CAAoB,CAAE,CAAAC,eAAA,uBAAAA,eAAA,uBAChC,IAAI,CAACD,MAAM,CAAGA,CAAM,CACpB,IAAI,CAACE,MAAM,CAAGC,sBAAc,CAACC,IAC/B,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/BX,CAAM,CAAGU,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,CAAAjB,MAAM,CAACE,CAAM,CAC1B,CAEA,GAAI,CAAAiB,GAAGA,CAAA,CAAW,CAChB,MAAO,EACT,CAEA,GAAI,CAAAC,IAAIA,CAAA,CAAmB,CACzB,MAAO,CACLlB,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBmB,IAAI,CAAEC,oBAAa,CAACtB,MAAM,CAC1BI,MAAM,CAAE,IAAI,CAACA,MACf,CACF,CACF,CAACmB,OAAA,CAAAvB,MAAA,CAAAA,MAAA","ignoreList":[]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { VisitType } from '../requester';
|
|
2
2
|
import { CustomDataType, IKameleoonData } from './types';
|
|
3
|
+
import { TrackingStatus } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* @class
|
|
5
6
|
* CustomData - a class for creating an instance for user's custom data
|
|
6
7
|
* */
|
|
7
8
|
export declare class CustomData implements IKameleoonData {
|
|
9
|
+
private _status;
|
|
8
10
|
private index;
|
|
9
11
|
private value;
|
|
10
|
-
private sent;
|
|
11
12
|
private isIdentifier;
|
|
12
13
|
/**
|
|
13
14
|
* @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
|
|
@@ -26,13 +27,20 @@ export declare class CustomData implements IKameleoonData {
|
|
|
26
27
|
constructor(index: number, ...value: string[]);
|
|
27
28
|
get url(): string;
|
|
28
29
|
get data(): CustomDataType;
|
|
29
|
-
get
|
|
30
|
-
|
|
30
|
+
get status(): TrackingStatus;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @method _fromRaw - an internal method for creating a CustomData instance from raw data
|
|
34
|
+
* @param {CustomDataType} data - a raw data
|
|
35
|
+
* @return {CustomData} a CustomData instance
|
|
36
|
+
* */
|
|
37
|
+
static _fromRaw(data: CustomDataType): CustomData;
|
|
31
38
|
/**
|
|
32
39
|
* @property isMappingIdentifier - signifying if the data is a mapping identifier
|
|
33
40
|
* @private
|
|
34
41
|
* */
|
|
35
42
|
set _isMappingIdentifier(value: boolean);
|
|
43
|
+
set status(status: TrackingStatus);
|
|
36
44
|
/**
|
|
37
45
|
* @private
|
|
38
46
|
* @method _updateFromVisit - an internal method for updating a list of custom data from a visit
|
|
@@ -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 _defineProperty(a,b,c){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_types=require("./types"),_types2=require("../types");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 CustomData{constructor(a){_defineProperty(this,"_status",void 0),_defineProperty(this,"index",void 0),_defineProperty(this,"value",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._status=_types2.TrackingStatus.Unsent,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,status:this.status}}get status(){return this._isMappingIdentifier?_types2.TrackingStatus.Unsent:this._status}static _fromRaw(a){const{index:b,value:c,status:d,isIdentifier:e}=a,f=new CustomData(b,...c);return f.status=d,f._isMappingIdentifier=e,f}set _isMappingIdentifier(a){this.isIdentifier=a}set status(a){this._status=a}static _updateFromVisit(a,b){var c;if(null!==(c=a.customDataEvents)&&void 0!==c&&c.length)for(let c=a.customDataEvents.length-1;0<=c;c--){const{index:d,valuesCountMap:e}=a.customDataEvents[c].data;b.has(d)||b.set(d,new CustomData(d,...Object.keys(e)))}}}exports.CustomData=CustomData;
|
|
2
2
|
//# sourceMappingURL=customData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customData.js","names":["CustomData","constructor","index","_defineProperty","b","arguments","length","value","Array","d","
|
|
1
|
+
{"version":3,"file":"customData.js","names":["CustomData","constructor","index","_defineProperty","b","arguments","length","value","Array","d","_status","TrackingStatus","Unsent","isIdentifier","url","uniqueValues","Set","resultValue","forEach","Object","keys","identifierParameter","UrlParameter","MappingIdentifier","UrlEventType","Index","ValuesCountMap","encodeURIComponent","JSON","stringify","Overwrite","data","type","KameleoonData","status","_isMappingIdentifier","_fromRaw","customData","_updateFromVisit","visit","dataMap","c","customDataEvents","i","valuesCountMap","has","set","exports"],"sources":["../../src/kameleoonData/customData.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { CustomDataType, IKameleoonData, KameleoonData } from './types';\nimport { TrackingStatus } from 'src/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 _status: TrackingStatus;\n private index: number;\n private value: string[];\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._status = TrackingStatus.Unsent;\n this.isIdentifier = false;\n }\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 get data(): CustomDataType {\n return {\n index: this.index,\n value: this.value,\n type: KameleoonData.CustomData,\n isIdentifier: this.isIdentifier,\n status: this.status,\n };\n }\n\n get status(): TrackingStatus {\n if (this._isMappingIdentifier) {\n return TrackingStatus.Unsent;\n }\n\n return this._status;\n }\n\n /**\n * @private\n * @method _fromRaw - an internal method for creating a CustomData instance from raw data\n * @param {CustomDataType} data - a raw data\n * @return {CustomData} a CustomData instance\n * */\n public static _fromRaw(data: CustomDataType): CustomData {\n const { index, value, status, isIdentifier } = data;\n const customData = new CustomData(index, ...value);\n\n customData.status = status;\n customData._isMappingIdentifier = isIdentifier;\n\n return customData;\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 set status(status: TrackingStatus) {\n this._status = status;\n }\n\n /**\n * @private\n * @method _updateFromVisit - an internal method for updating a list of custom data from a visit\n * @param {VisitType} visit - a visit\n * */\n public static _updateFromVisit(\n visit: VisitType,\n dataMap: Map<number, CustomData>,\n ): void {\n if (visit.customDataEvents?.length) {\n for (let i = visit.customDataEvents.length - 1; i >= 0; i--) {\n const { index, valuesCountMap } = visit.customDataEvents[i].data;\n\n if (!dataMap.has(index)) {\n dataMap.set(\n index,\n new CustomData(index, ...Object.keys(valuesCountMap)),\n );\n }\n }\n }\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,46 +1,57 @@
|
|
|
1
1
|
import { Result } from 'ts-res';
|
|
2
2
|
import { KameleoonError } from '../kameleoonError';
|
|
3
3
|
import { SegmentType, Tree } from '../targeting';
|
|
4
|
-
import { CustomDataConfigurationType } from '../clientConfiguration';
|
|
5
4
|
import { CustomData } from './customData';
|
|
6
|
-
import { DataManagerParametersType, KameleoonData, KameleoonDataType, KameleoonVisitorDataType,
|
|
5
|
+
import { DataManagerParametersType, KameleoonData, KameleoonDataType, KameleoonVisitorDataType, VisitorsDataType } from './types';
|
|
6
|
+
import { CustomDataConfigurationType } from '../clientConfiguration';
|
|
7
7
|
interface IDataManager {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
storeData(data: VisitorsDataType): Result<void, KameleoonError>;
|
|
9
|
+
storeTrackedData(data: VisitorsDataType): void;
|
|
10
10
|
getTree(segment: SegmentType): Tree;
|
|
11
11
|
clearTrees(): void;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getLinkedVisitor
|
|
15
|
-
|
|
12
|
+
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
13
|
+
isUniqueIdentifier(visitorCode: string): boolean;
|
|
14
|
+
getLinkedVisitor(visitorCode: string, index: number | null): string | null;
|
|
15
|
+
getVisitorData(visitorCode: string): KameleoonVisitorDataType | undefined;
|
|
16
|
+
getVisitorIdentifier(visitorCode: string): string;
|
|
17
|
+
getPendingData(visitorCode: string): KameleoonDataType[];
|
|
18
|
+
getUnsentData(visitorCode: string): KameleoonDataType[];
|
|
19
|
+
getVisitorStoredDataTypes(visitorCode: string): Set<KameleoonData>;
|
|
20
|
+
readonly identifierCustomDataIndex: number | null;
|
|
21
|
+
readonly storedCustomDataIndexes: Set<number>;
|
|
16
22
|
readonly trees: Map<string, Tree>;
|
|
17
23
|
readonly unsentDataVisitors: string[];
|
|
18
|
-
readonly identifierCustomDataIndex: number | null;
|
|
19
24
|
}
|
|
20
25
|
export declare class DataManager implements IDataManager {
|
|
26
|
+
private dataStorage;
|
|
27
|
+
private infoStorage;
|
|
28
|
+
private dataProcessor;
|
|
21
29
|
private targetingTrees;
|
|
22
|
-
private localCustomDataIndexes;
|
|
23
|
-
private persistentCustomDataIndexes;
|
|
24
30
|
private mappingIdentifierCustomDataIndex;
|
|
31
|
+
private persistentCustomDataIndexes;
|
|
32
|
+
private localCustomDataIndexes;
|
|
25
33
|
private cleanupIntervalId;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
constructor({ dataStorage, infoStorage, cleanupInterval, }: DataManagerParametersType);
|
|
35
|
+
getUnsentData(visitorCode: string): KameleoonDataType[];
|
|
36
|
+
getPendingData(visitorCode: string): KameleoonDataType[];
|
|
37
|
+
private getDataFromRaw;
|
|
38
|
+
storeTrackedData(data: VisitorsDataType): void;
|
|
39
|
+
storeData(data: VisitorsDataType): Result<void, KameleoonError>;
|
|
40
|
+
storeData(visitorCode: string, ...data: KameleoonDataType[]): Result<void, KameleoonError>;
|
|
31
41
|
getTree(segment: SegmentType): Tree;
|
|
32
42
|
clearTrees(): void;
|
|
33
|
-
getUnsentData(visitorCode: string): UnsentTargetingDataType[string] | undefined;
|
|
34
|
-
clearUnsentData(visitorCode: string): void;
|
|
35
|
-
clearUnsentDataByKey(visitorCode: string, key: KameleoonData): void;
|
|
36
43
|
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
37
|
-
|
|
44
|
+
isUniqueIdentifier(visitorCode: string): boolean;
|
|
38
45
|
getVisitorIdentifier(visitorCode: string): string;
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
getVisitorData(visitorCode: string): KameleoonVisitorDataType | undefined;
|
|
47
|
+
getVisitorStoredDataTypes(visitorCode: string): Set<KameleoonData>;
|
|
48
|
+
getLinkedVisitor(visitorCode: string): string | null;
|
|
49
|
+
private mutUpdateTargetingData;
|
|
50
|
+
private cleanupData;
|
|
51
|
+
private processCustomData;
|
|
41
52
|
get unsentDataVisitors(): string[];
|
|
42
53
|
get identifierCustomDataIndex(): number | null;
|
|
43
|
-
get
|
|
54
|
+
get trees(): Map<string, Tree>;
|
|
44
55
|
get storedCustomDataIndexes(): Set<number>;
|
|
45
56
|
set customDataIndexes(customData: CustomDataConfigurationType[]);
|
|
46
57
|
}
|