@kameleoon/javascript-sdk-core 4.4.7 → 5.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 +38 -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 +3 -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 +4 -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.d.ts +2 -2
- 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.d.ts +6 -0
- 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 +7 -14
- 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.d.ts +2 -1
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +3 -2
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +6 -7
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +10 -30
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +26 -18
- 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/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 +54 -17
- 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":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","RANGE","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type VisitorReference = string;\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType | VisitorReference;\n};\n\nexport type DereferencedTargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n RANGE = 'RANGE',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SEGMENT = 'SEGMENT',\n YSANCE_ATTRIBUT = 'YSANCE_ATTRIBUT',\n TEALIUM_BADGE = 'TEALIUM_BADGE',\n TEALIUM_AUDIENCE = 'TEALIUM_AUDIENCE',\n PRICE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version":3,"file":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","RANGE","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type VisitorReference = string;\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType | VisitorReference;\n};\n\nexport type DereferencedTargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n RANGE = 'RANGE',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SEGMENT = 'SEGMENT',\n YSANCE_ATTRIBUT = 'YSANCE_ATTRIBUT',\n TEALIUM_BADGE = 'TEALIUM_BADGE',\n TEALIUM_AUDIENCE = 'TEALIUM_AUDIENCE',\n PRICE_OF_DISPLAYED_PAGE = 'PRICE_OF_DISPLAY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from 'ts-res';
|
|
2
|
+
import { IExternalPRNG } from '../utilities';
|
|
3
|
+
import { AddDataParametersType, GetTrackingBodyResultType } from './types';
|
|
4
|
+
interface IBodyProvider {
|
|
5
|
+
getTrackingBody: (visitorCode: string) => GetTrackingBodyResultType;
|
|
6
|
+
addData: ({ visitorCode, variationData, visitorData, userAgent, isConsentProvided, isMappingIdentifier, }: AddDataParametersType) => Result<void, void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class BodyProvider implements IBodyProvider {
|
|
9
|
+
private prng;
|
|
10
|
+
private currentSize;
|
|
11
|
+
private resultBody;
|
|
12
|
+
private hasUserAgent;
|
|
13
|
+
private trackingVisitors;
|
|
14
|
+
constructor(prng: IExternalPRNG);
|
|
15
|
+
getTrackingBody(): GetTrackingBodyResultType;
|
|
16
|
+
addData({ visitorCode, variationData, visitorData, userAgent, isConsentProvided, isMappingIdentifier, }: AddDataParametersType): Result<void, void>;
|
|
17
|
+
private getVisitorDataLines;
|
|
18
|
+
private getVariationDataLines;
|
|
19
|
+
private prepareVisitorBody;
|
|
20
|
+
private cleanup;
|
|
21
|
+
private checkSize;
|
|
22
|
+
private addVisitorTrackingLines;
|
|
23
|
+
private getActivityLine;
|
|
24
|
+
private getIdentifier;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BodyProvider=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../kameleoonData"),_requester=require("../requester"),_utilities=require("../utilities"),_constants=require("./constants");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 BodyProvider{constructor(a){_defineProperty(this,"prng",void 0),_defineProperty(this,"currentSize",0),_defineProperty(this,"resultBody",[]),_defineProperty(this,"hasUserAgent",!1),_defineProperty(this,"trackingVisitors",{}),this.prng=a}getTrackingBody(){const a={body:this.resultBody.join("\n"),hasUserAgent:this.hasUserAgent};return this.cleanup(),a}addData(a){let{visitorCode:b,variationData:c,visitorData:d,userAgent:e,isConsentProvided:f,isMappingIdentifier:g}=a;const h=[],i=this.getVariationDataLines(c),j=this.getVisitorDataLines(d);return h.push(...j,...i),this.addVisitorTrackingLines({visitorCode:b,lines:h,userAgent:e,isConsentProvided:f,isMappingIdentifier:g})}getVisitorDataLines(a){const b=[];for(const c of a){let a;if(c.data.type===_kameleoonData.KameleoonData.Conversion||c.data.type===_kameleoonData.KameleoonData.PageView){const b=c.data.nonce;b?a=b:(a=_utilities.Utilities.getNonce(this.prng),c.data.nonce=a)}a||(a=_utilities.Utilities.getNonce(this.prng)),b.push(c.url+_requester.UrlParameter.Nonce+a)}return b}getVariationDataLines(a){const b=[];return a.forEach(a=>{b.push(_requester.UrlEventType.Experiment+_requester.UrlParameter.Id+a.experimentId+_requester.UrlParameter.VariationId+a.variationId+_requester.UrlParameter.Nonce+_utilities.Utilities.getNonce(this.prng))}),b}prepareVisitorBody(a){const b=this.trackingVisitors[a];if(!b)return(0,_tsRes.Err)();const{lines:c,userAgent:d,isMappingIdentifier:e,isConsentProvided:f}=b,g=this.getIdentifier(a,e);if(c.length)c.forEach((a,b)=>{c[b]=a+g});else if(f){const a=this.getActivityLine();c.push(a+g)}d&&c.length&&(c[0]+=_requester.UrlParameter.UserAgent+d,this.hasUserAgent=!0);const h=this.checkSize(c);return h.ok&&this.resultBody.push(...c),h}cleanup(){this.currentSize=0,this.resultBody=[],this.hasUserAgent=!1,this.trackingVisitors={}}checkSize(a){let b=0;return(b+=a.reduce((a,b)=>a+b.length*_constants.SYMBOL_SIZE,0),b+this.currentSize>_constants.MAX_BODY_SIZE)?(0,_tsRes.Err)():(this.currentSize+=b,(0,_tsRes.Ok)())}addVisitorTrackingLines(a){let{visitorCode:b,lines:c,userAgent:d,isConsentProvided:e,isMappingIdentifier:f}=a;return this.trackingVisitors[b]?(d&&(this.trackingVisitors[b].userAgent=d),this.trackingVisitors[b].lines.push(...c)):this.trackingVisitors[b]={isMappingIdentifier:f,isConsentProvided:e,userAgent:d,lines:c},this.prepareVisitorBody(b)}getActivityLine(){return _requester.UrlEventType.Activity+_requester.UrlParameter.Nonce+_utilities.Utilities.getNonce(this.prng)}getIdentifier(a,b){const c=b?_requester.UrlParameter.MappingValue:_requester.UrlParameter.VisitorCode;return c+a}}exports.BodyProvider=BodyProvider;
|
|
2
|
+
//# sourceMappingURL=bodyProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodyProvider.js","names":["BodyProvider","constructor","prng","_defineProperty","getTrackingBody","result","body","resultBody","join","hasUserAgent","cleanup","addData","a","visitorCode","variationData","visitorData","userAgent","isConsentProvided","isMappingIdentifier","lines","variationDataLines","getVariationDataLines","visitorDataLines","getVisitorDataLines","push","addVisitorTrackingLines","data","nonce","type","KameleoonData","Conversion","PageView","nonceValue","Utilities","getNonce","url","UrlParameter","Nonce","forEach","item","UrlEventType","Experiment","Id","experimentId","VariationId","variationId","prepareVisitorBody","trackingVisitors","Err","identifier","getIdentifier","length","value","index","activityLine","getActivityLine","UserAgent","checkSize","ok","currentSize","size","reduce","acc","line","SYMBOL_SIZE","MAX_BODY_SIZE","Ok","Activity","MappingValue","VisitorCode","exports"],"sources":["../../src/tracking/bodyProvider.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport {\n Conversion,\n KameleoonData,\n KameleoonDataType,\n PageView,\n} from 'src/kameleoonData';\nimport { UrlEventType, UrlParameter } from 'src/requester';\nimport { IExternalPRNG, Utilities } from 'src/utilities';\nimport {\n AddDataParametersType,\n AddVisitorTrackingLineParametersType,\n GetTrackingBodyResultType,\n VisitorTrackingDataType,\n} from './types';\nimport { MAX_BODY_SIZE, SYMBOL_SIZE } from './constants';\nimport { BaseVariationDataType } from 'src/variationConfiguration/types';\n\ninterface IBodyProvider {\n getTrackingBody: (visitorCode: string) => GetTrackingBodyResultType;\n addData: ({\n visitorCode,\n variationData,\n visitorData,\n userAgent,\n isConsentProvided,\n isMappingIdentifier,\n }: AddDataParametersType) => Result<void, void>;\n}\n\nexport class BodyProvider implements IBodyProvider {\n private prng: IExternalPRNG;\n private currentSize = 0;\n private resultBody: string[] = [];\n private hasUserAgent = false;\n private trackingVisitors: {\n [visitorCode: string]: VisitorTrackingDataType;\n } = {};\n\n constructor(prng: IExternalPRNG) {\n this.prng = prng;\n }\n\n public getTrackingBody(): GetTrackingBodyResultType {\n const result = {\n body: this.resultBody.join('\\n'),\n hasUserAgent: this.hasUserAgent,\n };\n\n this.cleanup();\n\n return result;\n }\n\n public addData({\n visitorCode,\n variationData,\n visitorData,\n userAgent,\n isConsentProvided,\n isMappingIdentifier,\n }: AddDataParametersType): Result<void, void> {\n const lines: string[] = [];\n\n const variationDataLines = this.getVariationDataLines(variationData);\n const visitorDataLines = this.getVisitorDataLines(visitorData);\n\n lines.push(...visitorDataLines, ...variationDataLines);\n\n return this.addVisitorTrackingLines({\n visitorCode,\n lines,\n userAgent,\n isConsentProvided,\n isMappingIdentifier,\n });\n }\n\n private getVisitorDataLines(visitorData: KameleoonDataType[]): string[] {\n const lines: string[] = [];\n\n for (const data of visitorData) {\n let nonce;\n\n if (\n data.data.type === KameleoonData.Conversion ||\n data.data.type === KameleoonData.PageView\n ) {\n const nonceValue = (data as Conversion | PageView).data.nonce;\n\n if (nonceValue) {\n nonce = nonceValue;\n } else {\n nonce = Utilities.getNonce(this.prng);\n (data as Conversion | PageView).data.nonce = nonce;\n }\n }\n\n if (!nonce) {\n nonce = Utilities.getNonce(this.prng);\n }\n\n lines.push(data.url + UrlParameter.Nonce + nonce);\n }\n\n return lines;\n }\n\n private getVariationDataLines(\n variationData: BaseVariationDataType[],\n ): string[] {\n const lines: string[] = [];\n\n variationData.forEach((item) => {\n lines.push(\n UrlEventType.Experiment +\n UrlParameter.Id +\n item.experimentId +\n UrlParameter.VariationId +\n item.variationId +\n UrlParameter.Nonce +\n Utilities.getNonce(this.prng),\n );\n });\n\n return lines;\n }\n\n private prepareVisitorBody(visitorCode: string): Result<void, void> {\n const visitorData = this.trackingVisitors[visitorCode];\n\n if (!visitorData) {\n return Err();\n }\n\n const { lines, userAgent, isMappingIdentifier, isConsentProvided } =\n visitorData;\n\n const identifier = this.getIdentifier(visitorCode, isMappingIdentifier);\n\n if (lines.length) {\n lines.forEach((value, index) => {\n lines[index] = value + identifier;\n });\n } else if (isConsentProvided) {\n const activityLine = this.getActivityLine();\n\n lines.push(activityLine + identifier);\n }\n\n if (userAgent && lines.length) {\n lines[0] += UrlParameter.UserAgent + userAgent;\n this.hasUserAgent = true;\n }\n\n // --- Note ---\n // Improve after `ts-res` chaining update\n const result = this.checkSize(lines);\n\n if (result.ok) {\n this.resultBody.push(...lines);\n }\n\n return result;\n }\n\n private cleanup(): void {\n this.currentSize = 0;\n this.resultBody = [];\n this.hasUserAgent = false;\n this.trackingVisitors = {};\n }\n\n private checkSize(lines: string[]): Result<void, void> {\n let size = 0;\n size += lines.reduce((acc, line) => acc + line.length * SYMBOL_SIZE, 0);\n\n if (size + this.currentSize > MAX_BODY_SIZE) {\n return Err();\n }\n\n this.currentSize += size;\n\n return Ok();\n }\n\n private addVisitorTrackingLines({\n visitorCode,\n lines,\n userAgent,\n isConsentProvided,\n isMappingIdentifier,\n }: AddVisitorTrackingLineParametersType): Result<void, void> {\n if (!this.trackingVisitors[visitorCode]) {\n this.trackingVisitors[visitorCode] = {\n isMappingIdentifier,\n isConsentProvided,\n userAgent,\n lines,\n };\n } else {\n if (userAgent) {\n this.trackingVisitors[visitorCode].userAgent = userAgent;\n }\n\n this.trackingVisitors[visitorCode].lines.push(...lines);\n }\n\n return this.prepareVisitorBody(visitorCode);\n }\n\n private getActivityLine(): string {\n return (\n UrlEventType.Activity + UrlParameter.Nonce + Utilities.getNonce(this.prng)\n );\n }\n\n private getIdentifier(\n visitorCode: string,\n isMappingIdentifier: boolean,\n ): string {\n const identifier = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return identifier + visitorCode;\n }\n}\n"],"mappings":"ixBA8BO,KAAM,CAAAA,YAAsC,CASjDC,WAAWA,CAACC,CAAmB,CAAE,CAAAC,eAAA,qBAAAA,eAAA,oBAPX,CAAC,EAAAA,eAAA,mBACQ,EAAE,EAAAA,eAAA,yBAAAA,eAAA,yBAI7B,CAAC,CAAC,EAGJ,IAAI,CAACD,IAAI,CAAGA,CACd,CAEOE,eAAeA,CAAA,CAA8B,CAClD,KAAM,CAAAC,CAAM,CAAG,CACbC,IAAI,CAAE,IAAI,CAACC,UAAU,CAACC,IAAI,CAAC,IAAI,CAAC,CAChCC,YAAY,CAAE,IAAI,CAACA,YACrB,CAAC,CAID,MAFA,KAAI,CAACC,OAAO,CAAC,CAAC,CAEPL,CACT,CAEOM,OAAOA,CAAAC,CAAA,CAOgC,IAP/B,CACbC,WAAW,CAAXA,CAAW,CACXC,aAAa,CAAbA,CAAa,CACbC,WAAW,CAAXA,CAAW,CACXC,SAAS,CAATA,CAAS,CACTC,iBAAiB,CAAjBA,CAAiB,CACjBC,mBAAmB,CAAnBA,CACqB,CAAC,CAAAN,CAAA,MAChB,CAAAO,CAAe,CAAG,EAAE,CAEpBC,CAAkB,CAAG,IAAI,CAACC,qBAAqB,CAACP,CAAa,CAAC,CAC9DQ,CAAgB,CAAG,IAAI,CAACC,mBAAmB,CAACR,CAAW,CAAC,CAI9D,MAFA,CAAAI,CAAK,CAACK,IAAI,CAAC,GAAGF,CAAgB,CAAE,GAAGF,CAAkB,CAAC,CAE/C,IAAI,CAACK,uBAAuB,CAAC,CAClCZ,WAAW,CAAXA,CAAW,CACXM,KAAK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D,aAAaA,CACnBrC,CAAmB,CACnBK,CAA4B,CACpB,CACR,KAAM,CAAA+B,CAAU,CAAG/B,CAAmB,CAClCkB,uBAAY,CAACgC,YAAY,CACzBhC,uBAAY,CAACiC,WAAW,CAE5B,MAAO,CAAApB,CAAU,CAAGpC,CACtB,CACF,CAACyD,OAAA,CAAAtE,YAAA,CAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SYMBOL_SIZE=exports.MAX_BODY_SIZE=void 0;var Byte=function(a){return a[a.Kb=1000]="Kb",a[a.Mb=1e3*a.Kb]="Mb",a[a.Gb=1e3*a.Mb]="Gb",a}(Byte||{});const MAX_BODY_SIZE=exports.MAX_BODY_SIZE=10*Byte.Mb,SYMBOL_SIZE=exports.SYMBOL_SIZE=4;
|
|
2
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["Byte","Kb","Mb","Gb","MAX_BODY_SIZE","exports","SYMBOL_SIZE"],"sources":["../../src/tracking/constants.ts"],"sourcesContent":["enum Byte {\n Kb = 1_000,\n Mb = 1_000 * Byte.Kb,\n Gb = 1_000 * Byte.Mb,\n}\n\nexport const MAX_BODY_SIZE = 10 * Byte.Mb;\nexport const SYMBOL_SIZE = 4;\n"],"mappings":"wHAAK,CAAAA,IAAI,UAAJA,CAAI,QAAJ,CAAAA,CAAI,CAAJA,CAAI,CAAAC,EAAA,YAAJD,CAAI,CAAJA,CAAI,CAAAE,EAAA,CAEF,GAAK,CAAGF,CAAI,CAACC,EAAE,OAFjBD,CAAI,CAAJA,CAAI,CAAAG,EAAA,CAGF,GAAK,CAAGH,CAAI,CAACE,EAAE,OAHjBF,CAAI,EAAJA,IAAI,WAMI,CAAAI,aAAa,CAAAC,OAAA,CAAAD,aAAA,CAAG,EAAE,CAAGJ,IAAI,CAACE,EAAE,CAC5BI,WAAW,CAAAD,OAAA,CAAAC,WAAA,CAAG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tracker } from './tracker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_tracker","require","Object","defineProperty","exports","value","enumerable","get","Tracker"],"sources":["../../src/tracking/index.ts"],"sourcesContent":["export { Tracker } from './tracker';\n"],"mappings":"aAAA,IAAAA,QAAA,CAAAC,OAAA,cAAoCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAH,MAAA,CAAAC,cAAA,CAAAC,OAAA,YAAAE,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAP,QAAA,CAAAQ,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TrackerParametersType } from './types';
|
|
2
|
+
interface ITracker {
|
|
3
|
+
scheduleVisitor: (visitorCode: string, isConsentProvided: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class Tracker implements ITracker {
|
|
6
|
+
private dataManager;
|
|
7
|
+
private variationConfiguration;
|
|
8
|
+
private requester;
|
|
9
|
+
private bodyProvider;
|
|
10
|
+
private intervalId;
|
|
11
|
+
private trackingStorage;
|
|
12
|
+
constructor({ dataManager, trackingStorage, variationConfiguration, trackingInterval, requester, prng, }: TrackerParametersType);
|
|
13
|
+
scheduleVisitor(visitorCode: string, isConsentProvided: boolean): void;
|
|
14
|
+
private checkIsIdentifier;
|
|
15
|
+
private getUserAgent;
|
|
16
|
+
private sendData;
|
|
17
|
+
private updateDataStatus;
|
|
18
|
+
private getUnsentVisitorData;
|
|
19
|
+
private getUnsentVariationData;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Tracker=void 0;var _kameleoonData=require("../kameleoonData"),_types=require("../types"),_bodyProvider=require("./bodyProvider");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 Tracker{constructor(a){let{dataManager:b,trackingStorage:c,variationConfiguration:d,trackingInterval:e,requester:f,prng:g}=a;_defineProperty(this,"dataManager",void 0),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"bodyProvider",void 0),_defineProperty(this,"intervalId",null),_defineProperty(this,"trackingStorage",void 0),this.dataManager=b,this.trackingStorage=c,this.variationConfiguration=d,this.requester=f,this.bodyProvider=new _bodyProvider.BodyProvider(g);try{this.intervalId=setInterval(()=>{this.sendData()},e)}catch(a){throw this.intervalId&&clearInterval(this.intervalId),a}}scheduleVisitor(a,b){this.trackingStorage.read().and(c=>{c.scheduledVisitors[a]={isConsentProvided:b},this.trackingStorage.write(c)})}checkIsIdentifier(a){const b=this.dataManager.isUniqueIdentifier(a);let c=!1;if(b){const b=this.dataManager.getLinkedVisitor(a),d=this.dataManager.identifierCustomDataIndex;b||"number"!=typeof d?c=!0:this.dataManager.storeData(a,new _kameleoonData.CustomData(d,a))}return c}getUserAgent(a){const b=this.dataManager.getVisitorData(a);if(b){const a=b[_kameleoonData.KameleoonData.UserAgent];if(a)return a.value}}async sendData(){const a={},b=this.trackingStorage.read();if(!b.ok)return;const{scheduledVisitors:c}=b.data,d=[];for(const[b,{isConsentProvided:e}]of Object.entries(c)){const c=this.checkIsIdentifier(b),f=this.getUserAgent(b),g=this.getUnsentVisitorData(b,e),h=this.getUnsentVariationData(b,e),i=this.bodyProvider.addData({visitorCode:b,variationData:h,visitorData:g,userAgent:f,isConsentProvided:e,isMappingIdentifier:c});if(i.ok)a[b]={visitorData:g,variationData:h},d.push(b);else break}const{body:e,hasUserAgent:f}=this.bodyProvider.getTrackingBody();if(e){const b=await this.requester.track(e,f);b.ok?(this.updateDataStatus(a,_types.TrackingStatus.Sent),d.forEach(a=>{delete c[a]}),this.trackingStorage.write({scheduledVisitors:c})):this.updateDataStatus(a,_types.TrackingStatus.Unsent)}}updateDataStatus(a,b){let c={};for(const[d,{visitorData:e,variationData:f}]of Object.entries(a)){c[d]=e.map(a=>(a.status=b,a));const a=f.map(a=>a.experimentId+"");this.variationConfiguration.updateDataStatus({visitorCode:d,experimentIdList:a,status:b})}b===_types.TrackingStatus.Sent?this.dataManager.storeTrackedData(c):this.dataManager.storeData(c)}getUnsentVisitorData(a,b){const c=this.dataManager.getUnsentData(a),d=[];if(!c.length)return[];for(const e of c)e.url&&(e.data.type===_kameleoonData.KameleoonData.Conversion||b)&&d.push(e);if(d.length){const b=d.map(a=>(a.status=_types.TrackingStatus.Pending,a));this.dataManager.storeTrackedData({[a]:b})}return d}getUnsentVariationData(a,b){const c=this.variationConfiguration.getUnsentData(a),d=new Set;if(!c.length)return[];const e=c.filter(a=>{const c=a.isTargetedRule||b;return c&&d.add(a.experimentId+""),c});return this.variationConfiguration.updateDataStatus({visitorCode:a,experimentIdList:Array.from(d),status:_types.TrackingStatus.Pending}),e}}exports.Tracker=Tracker;
|
|
2
|
+
//# sourceMappingURL=tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker.js","names":["Tracker","constructor","a","dataManager","trackingStorage","variationConfiguration","trackingInterval","requester","prng","_defineProperty","bodyProvider","BodyProvider","intervalId","setInterval","sendData","err","clearInterval","scheduleVisitor","visitorCode","isConsentProvided","read","and","trackingData","scheduledVisitors","write","checkIsIdentifier","isUniqueIdentifier","isMappingIdentifier","linkedVisitor","getLinkedVisitor","index","identifierCustomDataIndex","storeData","CustomData","getUserAgent","targetingData","getVisitorData","userAgentData","KameleoonData","UserAgent","value","pendingData","storageResult","ok","data","trackedVisitors","Object","entries","userAgent","visitorData","getUnsentVisitorData","variationData","getUnsentVariationData","result","addData","push","body","hasUserAgent","getTrackingBody","track","updateDataStatus","TrackingStatus","Sent","forEach","Unsent","status","updatedData","map","dataItem","experimentIdList","experimentId","storeTrackedData","unsentData","getUnsentData","resultData","length","url","type","Conversion","Pending","sentExperimentIds","Set","filter","item","isIncluded","isTargetedRule","add","Array","from","exports"],"sources":["../../src/tracking/tracker.ts"],"sourcesContent":["import {\n CustomData,\n DataManager,\n KameleoonData,\n KameleoonDataType,\n} from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { VariationConfiguration } from 'src/variationConfiguration';\nimport { PendingDataType, TrackerParametersType } from './types';\nimport { TrackingStatus } from 'src/types';\nimport { BaseVariationDataType } from 'src/variationConfiguration/types';\nimport { BodyProvider } from './bodyProvider';\nimport { IStorage, TrackingDataType } from 'src/storage';\n\ninterface ITracker {\n scheduleVisitor: (visitorCode: string, isConsentProvided: boolean) => void;\n}\n\nexport class Tracker implements ITracker {\n private dataManager: DataManager;\n private variationConfiguration: VariationConfiguration;\n private requester: Requester;\n private bodyProvider: BodyProvider;\n private intervalId: NodeJS.Timeout | null = null;\n private trackingStorage: IStorage<TrackingDataType>;\n\n constructor({\n dataManager,\n trackingStorage,\n variationConfiguration,\n trackingInterval,\n requester,\n prng,\n }: TrackerParametersType) {\n this.dataManager = dataManager;\n this.trackingStorage = trackingStorage;\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.bodyProvider = new BodyProvider(prng);\n\n try {\n this.intervalId = setInterval(() => {\n this.sendData();\n }, trackingInterval);\n } catch (err) {\n this.intervalId && clearInterval(this.intervalId);\n\n throw err;\n }\n }\n\n public scheduleVisitor(\n visitorCode: string,\n isConsentProvided: boolean,\n ): void {\n this.trackingStorage.read().and((trackingData) => {\n trackingData.scheduledVisitors[visitorCode] = { isConsentProvided };\n this.trackingStorage.write(trackingData);\n });\n }\n\n private checkIsIdentifier(visitorCode: string): boolean {\n const isUniqueIdentifier = this.dataManager.isUniqueIdentifier(visitorCode);\n let isMappingIdentifier = false;\n\n // --- Note ---\n // This part is a workaround for Data API\n // If there's is no unique identifier for the visitor\n // We do reconciliation for visitor with himself\n if (isUniqueIdentifier) {\n const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);\n const index = this.dataManager.identifierCustomDataIndex;\n\n if (!linkedVisitor && typeof index === 'number') {\n this.dataManager.storeData(\n visitorCode,\n new CustomData(index, visitorCode),\n );\n } else {\n isMappingIdentifier = true;\n }\n }\n\n return isMappingIdentifier;\n }\n\n private getUserAgent(visitorCode: string): string | undefined {\n const targetingData = this.dataManager.getVisitorData(visitorCode);\n\n if (targetingData) {\n const userAgentData = targetingData[KameleoonData.UserAgent];\n\n if (userAgentData) {\n return userAgentData.value;\n }\n }\n\n return undefined;\n }\n\n private async sendData(): Promise<void> {\n const pendingData: PendingDataType = {};\n const storageResult = this.trackingStorage.read();\n\n if (!storageResult.ok) {\n return;\n }\n\n const { scheduledVisitors } = storageResult.data;\n\n const trackedVisitors = [];\n\n for (const [visitorCode, { isConsentProvided }] of Object.entries(\n scheduledVisitors,\n )) {\n const isMappingIdentifier = this.checkIsIdentifier(visitorCode);\n const userAgent = this.getUserAgent(visitorCode);\n\n const visitorData = this.getUnsentVisitorData(\n visitorCode,\n isConsentProvided,\n );\n const variationData = this.getUnsentVariationData(\n visitorCode,\n isConsentProvided,\n );\n\n const result = this.bodyProvider.addData({\n visitorCode,\n variationData,\n visitorData,\n userAgent,\n isConsentProvided,\n isMappingIdentifier,\n });\n\n if (result.ok) {\n pendingData[visitorCode] = {\n visitorData,\n variationData,\n };\n trackedVisitors.push(visitorCode);\n } else {\n break;\n }\n }\n\n const { body, hasUserAgent } = this.bodyProvider.getTrackingBody();\n\n if (!body) {\n return;\n }\n\n const result = await this.requester.track(body, hasUserAgent);\n\n if (result.ok) {\n this.updateDataStatus(pendingData, TrackingStatus.Sent);\n trackedVisitors.forEach((visitorCode) => {\n delete scheduledVisitors[visitorCode];\n });\n this.trackingStorage.write({ scheduledVisitors });\n } else {\n this.updateDataStatus(pendingData, TrackingStatus.Unsent);\n }\n }\n\n private updateDataStatus(\n data: PendingDataType,\n status: TrackingStatus,\n ): void {\n let updatedData: { [visitorCode: string]: KameleoonDataType[] } = {};\n\n for (const [visitorCode, { visitorData, variationData }] of Object.entries(\n data,\n )) {\n updatedData[visitorCode] = visitorData.map((dataItem) => {\n dataItem.status = status;\n return dataItem;\n });\n\n const experimentIdList = variationData.map((dataItem) =>\n String(dataItem.experimentId),\n );\n\n this.variationConfiguration.updateDataStatus({\n visitorCode,\n experimentIdList,\n status,\n });\n }\n\n if (status === TrackingStatus.Sent) {\n this.dataManager.storeTrackedData(updatedData);\n } else {\n this.dataManager.storeData(updatedData);\n }\n }\n\n private getUnsentVisitorData(\n visitorCode: string,\n isConsentProvided: boolean,\n ): KameleoonDataType[] {\n const unsentData = this.dataManager.getUnsentData(visitorCode);\n const resultData: KameleoonDataType[] = [];\n\n if (!unsentData.length) {\n return [];\n }\n\n for (const data of unsentData) {\n if (\n !data.url ||\n (data.data.type !== KameleoonData.Conversion && !isConsentProvided)\n ) {\n continue;\n }\n\n resultData.push(data);\n }\n\n if (resultData.length) {\n const pendingData: KameleoonDataType[] = resultData.map(\n (data: KameleoonDataType) => {\n data.status = TrackingStatus.Pending;\n return data;\n },\n );\n\n this.dataManager.storeTrackedData({\n [visitorCode]: pendingData,\n });\n }\n\n return resultData;\n }\n\n private getUnsentVariationData(\n visitorCode: string,\n isConsentProvided: boolean,\n ): BaseVariationDataType[] {\n const unsentData = this.variationConfiguration.getUnsentData(visitorCode);\n const sentExperimentIds = new Set<string>();\n\n if (!unsentData.length) {\n return [];\n }\n\n const resultData = unsentData.filter((item) => {\n const isIncluded = item.isTargetedRule || isConsentProvided;\n\n if (isIncluded) {\n sentExperimentIds.add(String(item.experimentId));\n }\n\n return isIncluded;\n });\n\n this.variationConfiguration.updateDataStatus({\n visitorCode,\n experimentIdList: Array.from(sentExperimentIds),\n status: TrackingStatus.Pending,\n });\n\n return resultData;\n }\n}\n"],"mappings":"8sBAkBO,KAAM,CAAAA,OAA4B,CAQvCC,WAAWA,CAAAC,CAAA,CAOe,IAPd,CACVC,WAAW,CAAXA,CAAW,CACXC,eAAe,CAAfA,CAAe,CACfC,sBAAsB,CAAtBA,CAAsB,CACtBC,gBAAgB,CAAhBA,CAAgB,CAChBC,SAAS,CAATA,CAAS,CACTC,IAAI,CAAJA,CACqB,CAAC,CAAAN,CAAA,CAAAO,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,6BAAAA,eAAA,mBAVoB,IAAI,EAAAA,eAAA,gCAW9C,IAAI,CAACN,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACC,eAAe,CAAGA,CAAe,CACtC,IAAI,CAACC,sBAAsB,CAAGA,CAAsB,CACpD,IAAI,CAACE,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,YAAY,CAAG,GAAI,CAAAC,0BAAY,CAACH,CAAI,CAAC,CAE1C,GAAI,CACF,IAAI,CAACI,UAAU,CAAGC,WAAW,CAAC,IAAM,CAClC,IAAI,CAACC,QAAQ,CAAC,CAChB,CAAC,CAAER,CAAgB,CACrB,CAAE,MAAOS,CAAG,CAAE,CAGZ,KAFA,KAAI,CAACH,UAAU,EAAII,aAAa,CAAC,IAAI,CAACJ,UAAU,CAAC,CAE3CG,CACR,CACF,CAEOE,eAAeA,CACpBC,CAAmB,CACnBC,CAA0B,CACpB,CACN,IAAI,CAACf,eAAe,CAACgB,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,CAAY,EAAK,CAChDA,CAAY,CAACC,iBAAiB,CAACL,CAAW,CAAC,CAAG,CAAEC,iBAAiB,CAAjBA,CAAkB,CAAC,CACnE,IAAI,CAACf,eAAe,CAACoB,KAAK,CAACF,CAAY,CACzC,CAAC,CACH,CAEQG,iBAAiBA,CAACP,CAAmB,CAAW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import { Requester } from '../requester';
|
|
3
|
+
import { IStorage, TrackingDataType } from '../storage';
|
|
4
|
+
import { IExternalPRNG } from '../utilities';
|
|
5
|
+
import { VariationConfiguration } from '../variationConfiguration';
|
|
6
|
+
import { BaseVariationDataType } from '../variationConfiguration/types';
|
|
7
|
+
export type PendingDataType = {
|
|
8
|
+
[visitorCode: string]: {
|
|
9
|
+
visitorData: KameleoonDataType[];
|
|
10
|
+
variationData: BaseVariationDataType[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type VisitorTrackingDataType = {
|
|
14
|
+
isConsentProvided: boolean;
|
|
15
|
+
userAgent: string | undefined;
|
|
16
|
+
isMappingIdentifier: boolean;
|
|
17
|
+
lines: string[];
|
|
18
|
+
};
|
|
19
|
+
export type TrackerParametersType = {
|
|
20
|
+
trackingStorage: IStorage<TrackingDataType>;
|
|
21
|
+
trackingInterval: number;
|
|
22
|
+
dataManager: DataManager;
|
|
23
|
+
variationConfiguration: VariationConfiguration;
|
|
24
|
+
requester: Requester;
|
|
25
|
+
prng: IExternalPRNG;
|
|
26
|
+
};
|
|
27
|
+
export type AddDataParametersType = {
|
|
28
|
+
visitorCode: string;
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
isConsentProvided: boolean;
|
|
31
|
+
variationData: BaseVariationDataType[];
|
|
32
|
+
visitorData: KameleoonDataType[];
|
|
33
|
+
isMappingIdentifier: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type GetTrackingBodyResultType = {
|
|
36
|
+
body: string;
|
|
37
|
+
hasUserAgent: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type AddVisitorTrackingLineParametersType = {
|
|
40
|
+
isConsentProvided: boolean;
|
|
41
|
+
isMappingIdentifier: boolean;
|
|
42
|
+
visitorCode: string;
|
|
43
|
+
lines: string[];
|
|
44
|
+
userAgent?: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/tracking/types.ts"],"sourcesContent":["import { DataManager, KameleoonDataType } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { IStorage, TrackingDataType } from 'src/storage';\nimport { IExternalPRNG } from 'src/utilities';\nimport { VariationConfiguration } from 'src/variationConfiguration';\nimport { BaseVariationDataType } from 'src/variationConfiguration/types';\n\nexport type PendingDataType = {\n [visitorCode: string]: {\n visitorData: KameleoonDataType[];\n variationData: BaseVariationDataType[];\n };\n};\n\nexport type VisitorTrackingDataType = {\n isConsentProvided: boolean;\n userAgent: string | undefined;\n isMappingIdentifier: boolean;\n lines: string[];\n};\n\nexport type TrackerParametersType = {\n trackingStorage: IStorage<TrackingDataType>;\n trackingInterval: number;\n dataManager: DataManager;\n variationConfiguration: VariationConfiguration;\n requester: Requester;\n prng: IExternalPRNG;\n};\n\nexport type AddDataParametersType = {\n visitorCode: string;\n userAgent?: string;\n isConsentProvided: boolean;\n variationData: BaseVariationDataType[];\n visitorData: KameleoonDataType[];\n isMappingIdentifier: boolean;\n};\n\nexport type GetTrackingBodyResultType = { body: string; hasUserAgent: boolean };\n\nexport type AddVisitorTrackingLineParametersType = {\n isConsentProvided: boolean;\n isMappingIdentifier: boolean;\n visitorCode: string;\n lines: string[];\n userAgent?: string;\n};\n"],"mappings":"","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClientConfigurationDataType,
|
|
1
|
+
import { ClientConfigurationDataType, JSONType } from './clientConfiguration/types';
|
|
2
2
|
import { SdkLanguageType } from './constants';
|
|
3
3
|
import { IExternalEventSource } from './eventSource';
|
|
4
|
-
import { IExternalRequester, RequestType } from './requester';
|
|
4
|
+
import { IExternalRequester, IUrlProvider, RequestType } from './requester';
|
|
5
5
|
import { IExternalStorage } from './storage';
|
|
6
6
|
import { IExternalPRNG, VisitorDataFiltersType } from './utilities';
|
|
7
7
|
import { IVisitorCodeManager } from './visitorCodeManager';
|
|
@@ -19,30 +19,39 @@ import { IVisitorCodeManager } from './visitorCodeManager';
|
|
|
19
19
|
* - React/React Native SDK: `undefined` (no cleanup)
|
|
20
20
|
* - NodeJS SDK: `30`
|
|
21
21
|
*
|
|
22
|
-
* @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead
|
|
23
22
|
* @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to
|
|
24
23
|
* @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used
|
|
25
24
|
* @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests
|
|
26
25
|
* @defaultvalue `10_000` (10 seconds)
|
|
26
|
+
* @param {number | undefined} trackingInterval - interval in _milliseconds_ for performing background tracking requests, must be a value between `100` to `1_000` milliseconds
|
|
27
|
+
* @defaultvalue `1_000` (1 second)
|
|
27
28
|
* */
|
|
28
29
|
export type SDKConfigurationType = {
|
|
29
30
|
updateInterval?: number;
|
|
30
31
|
environment?: Environment;
|
|
31
32
|
targetingDataCleanupInterval?: number;
|
|
32
33
|
requestTimeout?: number;
|
|
33
|
-
domain?: string;
|
|
34
34
|
networkDomain?: string;
|
|
35
35
|
cookieDomain?: string;
|
|
36
|
+
trackingInterval?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} urlProvider - main source for all URLs used in the SDK
|
|
40
|
+
* */
|
|
41
|
+
export type DependenciesType = {
|
|
42
|
+
urlProvider?: IUrlProvider;
|
|
36
43
|
};
|
|
37
44
|
/**
|
|
38
45
|
* @param {string} siteCode - client's siteCode defined on Kameleoon platform
|
|
39
46
|
* @param {Partial<SDKConfigurationType>} configuration - client's configuration
|
|
40
47
|
* @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK
|
|
48
|
+
* @param {DependenciesType | undefined} dependencies - internal dependencies meant primarily for testing purposes
|
|
41
49
|
* */
|
|
42
50
|
export type SDKCoreParameters = {
|
|
43
51
|
siteCode: string;
|
|
44
|
-
configuration?: Partial<SDKConfigurationType>;
|
|
45
52
|
internalConfiguration: InternalSDKConfigurationType;
|
|
53
|
+
configuration?: Partial<SDKConfigurationType>;
|
|
54
|
+
dependencies?: DependenciesType;
|
|
46
55
|
};
|
|
47
56
|
/**
|
|
48
57
|
* @param {SdkLanguageType} type - type of the SDK
|
|
@@ -64,20 +73,30 @@ export type InternalsType = {
|
|
|
64
73
|
* @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization
|
|
65
74
|
* @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation
|
|
66
75
|
* @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name
|
|
67
|
-
* @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration
|
|
68
|
-
* Note: _Deprecated_ - to be removed in the next major update
|
|
69
76
|
* @param {IExternalRequester} externalRequester - external requester , used to track or get data
|
|
70
77
|
* @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code
|
|
71
|
-
* @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute
|
|
72
78
|
* */
|
|
73
|
-
export type
|
|
79
|
+
export type ExternalsType = {
|
|
74
80
|
externalStorage: IExternalStorage;
|
|
75
81
|
externalEventSource: IExternalEventSource;
|
|
76
82
|
externalVisitorCodeManager: IVisitorCodeManager;
|
|
77
83
|
externalPackageInfo: ExternalPackageInfoType;
|
|
78
84
|
externalRequester: IExternalRequester;
|
|
79
85
|
externalPRNG: IExternalPRNG;
|
|
80
|
-
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* @param {boolean} useAbortController - a flag to enable or disable usage of `AbortController` for requests allowing for `requestTimeout` to be respected
|
|
89
|
+
* */
|
|
90
|
+
export type InternalSettingsType = {
|
|
91
|
+
useAbortController: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* @param {ExternalsType} externals - external dependencies for the SDK
|
|
95
|
+
* @param {InternalSettingsType} settings - internal settings for the SDK
|
|
96
|
+
* */
|
|
97
|
+
export type InternalSDKConfigurationType = {
|
|
98
|
+
externals: ExternalsType;
|
|
99
|
+
settings: InternalSettingsType;
|
|
81
100
|
};
|
|
82
101
|
/**
|
|
83
102
|
* @readonly
|
|
@@ -96,7 +115,18 @@ export declare enum VariableType {
|
|
|
96
115
|
BOOLEAN = "BOOLEAN",
|
|
97
116
|
NUMBER = "NUMBER",
|
|
98
117
|
STRING = "STRING",
|
|
99
|
-
JSON = "JSON"
|
|
118
|
+
JSON = "JSON",
|
|
119
|
+
JS = "JS",
|
|
120
|
+
CSS = "CSS"
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @readonly
|
|
124
|
+
* @enum {string} an Enum containing all possible variants for data status
|
|
125
|
+
* */
|
|
126
|
+
export declare enum TrackingStatus {
|
|
127
|
+
Sent = "sent",
|
|
128
|
+
Unsent = "unsent",
|
|
129
|
+
Pending = "pending"
|
|
100
130
|
}
|
|
101
131
|
export type BooleanVariableType = {
|
|
102
132
|
key: string;
|
|
@@ -118,10 +148,20 @@ export type JSONVariableType = {
|
|
|
118
148
|
type: VariableType.JSON;
|
|
119
149
|
value: JSONType;
|
|
120
150
|
};
|
|
151
|
+
export type JSVariableType = {
|
|
152
|
+
key: string;
|
|
153
|
+
type: VariableType.JS;
|
|
154
|
+
value: string;
|
|
155
|
+
};
|
|
156
|
+
export type CSSVariableType = {
|
|
157
|
+
key: string;
|
|
158
|
+
type: VariableType.CSS;
|
|
159
|
+
value: string;
|
|
160
|
+
};
|
|
121
161
|
/**
|
|
122
162
|
* @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
|
|
123
163
|
* */
|
|
124
|
-
export type FeatureVariableResultType = BooleanVariableType | NumberVariableType | StringVariableType | JSONVariableType;
|
|
164
|
+
export type FeatureVariableResultType = BooleanVariableType | NumberVariableType | JSVariableType | CSSVariableType | StringVariableType | JSONVariableType;
|
|
125
165
|
/**
|
|
126
166
|
* @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
|
|
127
167
|
* */
|
|
@@ -129,7 +169,7 @@ export type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;
|
|
|
129
169
|
/**
|
|
130
170
|
* @readonly
|
|
131
171
|
* @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.
|
|
132
|
-
* Month is considered
|
|
172
|
+
* Month is considered as an average of 30 days
|
|
133
173
|
* */
|
|
134
174
|
export declare enum Milliseconds {
|
|
135
175
|
Second = 1000,
|
|
@@ -143,25 +183,21 @@ export declare enum Milliseconds {
|
|
|
143
183
|
* @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
|
|
144
184
|
* @param {number} goalId - an id of a goal to track
|
|
145
185
|
* @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`
|
|
146
|
-
* @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
|
|
147
186
|
* */
|
|
148
187
|
export type TrackConversionParamsType = {
|
|
149
188
|
visitorCode: string;
|
|
150
189
|
goalId: number;
|
|
151
190
|
revenue?: number;
|
|
152
|
-
isUniqueIdentifier?: boolean;
|
|
153
191
|
};
|
|
154
192
|
/**
|
|
155
193
|
* @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
|
|
156
194
|
* @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
|
|
157
195
|
* @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved
|
|
158
|
-
* @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
|
|
159
196
|
* */
|
|
160
197
|
export type RemoteVisitorDataParamsType = {
|
|
161
198
|
visitorCode: string;
|
|
162
199
|
shouldAddData?: boolean;
|
|
163
200
|
filters?: VisitorDataFiltersType;
|
|
164
|
-
isUniqueIdentifier?: boolean;
|
|
165
201
|
};
|
|
166
202
|
export type GetFeatureVariablesParamsType = {
|
|
167
203
|
visitorCode: string;
|
|
@@ -217,6 +253,7 @@ export type TrackingCacheItemType = {
|
|
|
217
253
|
[experimentId: number]: {
|
|
218
254
|
variationId: number;
|
|
219
255
|
expirationTime: number;
|
|
256
|
+
hasJsCssVariables: boolean;
|
|
220
257
|
};
|
|
221
258
|
};
|
|
222
259
|
export type SetDataCallbackParametersType = {
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.Milliseconds=exports.Environment=void 0;let Environment=exports.Environment=function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({}),VariableType=exports.VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a}({}),Milliseconds=exports.Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});
|
|
1
|
+
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.TrackingStatus=exports.Milliseconds=exports.Environment=void 0;let Environment=exports.Environment=function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({}),VariableType=exports.VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a.JS="JS",a.CSS="CSS",a}({}),TrackingStatus=exports.TrackingStatus=function(a){return a.Sent="sent",a.Unsent="unsent",a.Pending="pending",a}({}),Milliseconds=exports.Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["_requester","require","Object","defineProperty","exports","value","VariableType","Milliseconds","Environment","Production","Staging","Development","BOOLEAN","NUMBER","STRING","JSON","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n JSONType,\n} from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequester, RequestType } from './requester';\nimport { IExternalStorage } from './storage';\nimport { IExternalPRNG, VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead\n * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to\n * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n networkDomain?: string;\n cookieDomain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {ExternalPackageInfoType} packageInfo - external package info, used to get package version and name\n * @param {IExternalPRNG | undefined} prng - external PRNG implementation\n * */\nexport type InternalsType = {\n packageInfo: ExternalPackageInfoType;\n prng?: IExternalPRNG;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * Note: _Deprecated_ - to be removed in the next major update\n * @param {IExternalRequester} externalRequester - external requester , used to track or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequester: IExternalRequester;\n externalPRNG: IExternalPRNG;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n\n/**\n * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`\n * */\nexport type SimulateRequestDataType = {\n [RequestType.Configuration]: ClientConfigurationDataType;\n [RequestType.RemoteData]: JSONType;\n [RequestType.Tracking]: null;\n};\n"],"mappings":"aAOA,IAAAA,UAAA,CAAAC,OAAA,gBAA8DC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,CAAAF,OAAA,CAAAG,YAAA,CAAAH,OAAA,CAAAI,WAAA,WAwFlD,CAAAA,WAAW,CAAAJ,OAAA,CAAAI,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAUXF,YAAY,CAAAF,OAAA,CAAAE,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAM,OAAA,WAAZN,CAAY,CAAAO,MAAA,UAAZP,CAAY,CAAAQ,MAAA,UAAZR,CAAY,CAAAS,IAAA,QAAZT,CAAY,MAkDZC,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAS,MAAA,gBAAZT,CAAY,CAAZA,CAAY,CAAAU,MAAA,CAEb,EAAE,CAAGV,CAAY,CAACS,MAAM,WAFvBT,CAAY,CAAZA,CAAY,CAAAW,IAAA,CAGf,EAAE,CAAGX,CAAY,CAACU,MAAM,SAHrBV,CAAY,CAAZA,CAAY,CAAAY,GAAA,CAIhB,EAAE,CAAGZ,CAAY,CAACW,IAAI,QAJlBX,CAAY,CAAZA,CAAY,CAAAa,IAAA,CAKf,CAAC,CAAGb,CAAY,CAACY,GAAG,SALjBZ,CAAY,CAAZA,CAAY,CAAAc,KAAA,CAMd,EAAE,CAAGd,CAAY,CAACY,GAAG,UANnBZ,CAAY"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["_requester","require","Object","defineProperty","exports","value","VariableType","TrackingStatus","Milliseconds","Environment","Production","Staging","Development","BOOLEAN","NUMBER","STRING","JSON","JS","CSS","Sent","Unsent","Pending","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n JSONType,\n} from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequester, IUrlProvider, RequestType } from './requester';\nimport { IExternalStorage } from './storage';\nimport { IExternalPRNG, VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to\n * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * @param {number | undefined} trackingInterval - interval in _milliseconds_ for performing background tracking requests, must be a value between `100` to `1_000` milliseconds\n * @defaultvalue `1_000` (1 second)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n networkDomain?: string;\n cookieDomain?: string;\n trackingInterval?: number;\n};\n\n/**\n * @param {string} urlProvider - main source for all URLs used in the SDK\n * */\nexport type DependenciesType = {\n urlProvider?: IUrlProvider;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * @param {DependenciesType | undefined} dependencies - internal dependencies meant primarily for testing purposes\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n internalConfiguration: InternalSDKConfigurationType;\n configuration?: Partial<SDKConfigurationType>;\n dependencies?: DependenciesType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {ExternalPackageInfoType} packageInfo - external package info, used to get package version and name\n * @param {IExternalPRNG | undefined} prng - external PRNG implementation\n * */\nexport type InternalsType = {\n packageInfo: ExternalPackageInfoType;\n prng?: IExternalPRNG;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {IExternalRequester} externalRequester - external requester , used to track or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * */\nexport type ExternalsType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequester: IExternalRequester;\n externalPRNG: IExternalPRNG;\n};\n\n/**\n * @param {boolean} useAbortController - a flag to enable or disable usage of `AbortController` for requests allowing for `requestTimeout` to be respected\n * */\nexport type InternalSettingsType = {\n useAbortController: boolean;\n};\n\n/**\n * @param {ExternalsType} externals - external dependencies for the SDK\n * @param {InternalSettingsType} settings - internal settings for the SDK\n * */\nexport type InternalSDKConfigurationType = {\n externals: ExternalsType;\n settings: InternalSettingsType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n JS = 'JS',\n CSS = 'CSS',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants for data status\n * */\nexport enum TrackingStatus {\n Sent = 'sent',\n Unsent = 'unsent',\n Pending = 'pending',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\nexport type JSVariableType = {\n key: string;\n type: VariableType.JS;\n value: string;\n};\n\nexport type CSSVariableType = {\n key: string;\n type: VariableType.CSS;\n value: string;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | JSVariableType\n | CSSVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered as an average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: {\n variationId: number;\n expirationTime: number;\n hasJsCssVariables: boolean;\n };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n\n/**\n * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`\n * */\nexport type SimulateRequestDataType = {\n [RequestType.Configuration]: ClientConfigurationDataType;\n [RequestType.RemoteData]: JSONType;\n [RequestType.Tracking]: null;\n};\n"],"mappings":"aAOA,IAAAA,UAAA,CAAAC,OAAA,gBAA4EC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,CAAAF,OAAA,CAAAG,cAAA,CAAAH,OAAA,CAAAI,YAAA,CAAAJ,OAAA,CAAAK,WAAA,WA8GhE,CAAAA,WAAW,CAAAL,OAAA,CAAAK,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAUXH,YAAY,CAAAF,OAAA,CAAAE,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAO,OAAA,WAAZP,CAAY,CAAAQ,MAAA,UAAZR,CAAY,CAAAS,MAAA,UAAZT,CAAY,CAAAU,IAAA,QAAZV,CAAY,CAAAW,EAAA,MAAZX,CAAY,CAAAY,GAAA,OAAZZ,CAAY,MAaZC,cAAc,CAAAH,OAAA,CAAAG,cAAA,UAAdA,CAAc,QAAd,CAAAA,CAAc,CAAAY,IAAA,QAAdZ,CAAc,CAAAa,MAAA,UAAdb,CAAc,CAAAc,OAAA,WAAdd,CAAc,MA+DdC,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAc,MAAA,gBAAZd,CAAY,CAAZA,CAAY,CAAAe,MAAA,CAEb,EAAE,CAAGf,CAAY,CAACc,MAAM,WAFvBd,CAAY,CAAZA,CAAY,CAAAgB,IAAA,CAGf,EAAE,CAAGhB,CAAY,CAACe,MAAM,SAHrBf,CAAY,CAAZA,CAAY,CAAAiB,GAAA,CAIhB,EAAE,CAAGjB,CAAY,CAACgB,IAAI,QAJlBhB,CAAY,CAAZA,CAAY,CAAAkB,IAAA,CAKf,CAAC,CAAGlB,CAAY,CAACiB,GAAG,SALjBjB,CAAY,CAAZA,CAAY,CAAAmB,KAAA,CAMd,EAAE,CAAGnB,CAAY,CAACiB,GAAG,UANnBjB,CAAY","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NONCE_LENGTH=exports.HEX_CHARACTERS=void 0;const HEX_CHARACTERS=exports.HEX_CHARACTERS="0123456789ABCDEF",NONCE_LENGTH=exports.NONCE_LENGTH=16;
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["
|
|
1
|
+
{"version":3,"file":"constants.js","names":["HEX_CHARACTERS","exports","NONCE_LENGTH"],"sources":["../../src/utilities/constants.ts"],"sourcesContent":["export const HEX_CHARACTERS = '0123456789ABCDEF';\nexport const NONCE_LENGTH = 16;\n"],"mappings":"4HAAa,CAAAA,cAAc,CAAAC,OAAA,CAAAD,cAAA,CAAG,kBAAkB,CACnCE,YAAY,CAAAD,OAAA,CAAAC,YAAA,CAAG,EAAE","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Utilities } from './utilities';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { Parser } from './parser';
|
|
3
|
+
export { Validator } from './validator';
|
|
4
|
+
export { VisitorDataFiltersType, TimeUnit, Order, IExternalPRNG, } from './types';
|
package/dist/utilities/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"IExternalPRNG",{enumerable:!0,get:function(){return _types.IExternalPRNG}}),Object.defineProperty(exports,"Order",{enumerable:!0,get:function(){return _types.Order}}),Object.defineProperty(exports,"Parser",{enumerable:!0,get:function(){return _parser.Parser}}),Object.defineProperty(exports,"TimeUnit",{enumerable:!0,get:function(){return _types.TimeUnit}}),Object.defineProperty(exports,"Utilities",{enumerable:!0,get:function(){return _utilities.Utilities}}),Object.defineProperty(exports,"Validator",{enumerable:!0,get:function(){return _validator.Validator}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _types.VisitorDataFiltersType}});var _utilities=require("./utilities"),_parser=require("./parser"),_validator=require("./validator"),_types=require("./types");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/utilities/index.ts"],"sourcesContent":["export { Utilities } from './utilities';\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/utilities/index.ts"],"sourcesContent":["export { Utilities } from './utilities';\nexport { Parser } from './parser';\nexport { Validator } from './validator';\nexport {\n VisitorDataFiltersType,\n TimeUnit,\n Order,\n IExternalPRNG,\n} from './types';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Result } from 'ts-res';
|
|
2
|
+
import { FeatureVariableType } from '../clientConfiguration';
|
|
3
|
+
import { KameleoonError } from '../kameleoonError';
|
|
4
|
+
import { FeatureVariableResultType } from '../types';
|
|
5
|
+
import { ParseVisitorDataParametersType, ParseVisitorDataResultType } from './types';
|
|
6
|
+
export declare class Parser {
|
|
7
|
+
static parseFeatureVariable(variable: FeatureVariableType): Result<FeatureVariableResultType, KameleoonError>;
|
|
8
|
+
static parseVisitorData({ data, filters, visitorCode, dataManager, variationConfiguration, }: ParseVisitorDataParametersType): ParseVisitorDataResultType;
|
|
9
|
+
static parseRegExp(value: string): RegExp;
|
|
10
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Parser=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_visitProcessor=require("../kameleoonData/visitProcessor");class Parser{static parseFeatureVariable(a){const{key:b,type:c,value:d}=a;switch(c){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({key:b,type:c,value:!!d});case _types.VariableType.JS:case _types.VariableType.CSS:case _types.VariableType.STRING:return(0,_tsRes.Ok)({key:b,type:c,value:d+""});case _types.VariableType.NUMBER:const e=+d;return Number.isNaN(e)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,d+"")):(0,_tsRes.Ok)({key:b,type:c,value:e});case _types.VariableType.JSON:try{const d=JSON.parse(a.value+"");return(0,_tsRes.Ok)({key:b,type:c,value:d})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(c)}}static parseVisitorData(a){let{data:b,filters:c,visitorCode:d,dataManager:e,variationConfiguration:f}=a;const g=new _visitProcessor.VisitProcessor({filters:c,dataManager:e,visitorCode:d}),{currentVisit:h,previousVisits:i,kcs:j}=b;let k=[];if(h&&k.push(h),i&&k.push(...i),!k.length)return{visitorData:[],storageVisitorData:[]};k.forEach(a=>{g.processVisit(a)}),g.processKcs(j),g.processMultipleDataTypes();const{visitorData:l,storageVisitorData:m,visitsData:n,experimentData:o}=g.data;return f.updateStoredVariations(d,o),{visitorData:l,storageVisitorData:m,visitsData:n}}static parseRegExp(a){if("/"===a[0]){const[_,b,c]=a.split("/");return new RegExp(b,c)}return new RegExp(a)}}exports.Parser=Parser;
|
|
2
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","names":["Parser","parseFeatureVariable","variable","key","type","value","VariableType","BOOLEAN","Ok","JS","CSS","STRING","NUMBER","numberValue","Number","isNaN","Err","KameleoonError","KameleoonException","NumberParse","JSON","jsonValue","parse","err","JSONParse","exhaustCheck","parseVisitorData","a","data","filters","visitorCode","dataManager","variationConfiguration","visitProcessor","VisitProcessor","currentVisit","previousVisits","kcs","visits","push","length","visitorData","storageVisitorData","forEach","visit","processVisit","processKcs","processMultipleDataTypes","visitsData","experimentData","updateStoredVariations","parseRegExp","_","expression","flags","split","RegExp","exports"],"sources":["../../src/utilities/parser.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { FeatureVariableType, JSONType } from 'src/clientConfiguration';\nimport {\n KameleoonError,\n KameleoonException,\n exhaustCheck,\n} from 'src/kameleoonError';\nimport { FeatureVariableResultType, VariableType } from 'src/types';\nimport {\n ParseVisitorDataParametersType,\n ParseVisitorDataResultType,\n} from './types';\nimport { VisitType } from 'src/requester';\nimport { VisitProcessor } from 'src/kameleoonData/visitProcessor';\n\nexport class Parser {\n static parseFeatureVariable(\n variable: FeatureVariableType,\n ): Result<FeatureVariableResultType, KameleoonError> {\n const { key, type, value } = variable;\n\n switch (type) {\n case VariableType.BOOLEAN:\n return Ok({\n key,\n type,\n value: Boolean(value),\n });\n case VariableType.JS:\n case VariableType.CSS:\n case VariableType.STRING:\n return Ok({\n key,\n type,\n value: String(value),\n });\n case VariableType.NUMBER:\n const numberValue = Number(value);\n\n if (Number.isNaN(numberValue)) {\n return Err(\n new KameleoonError(KameleoonException.NumberParse, String(value)),\n );\n }\n\n return Ok({\n key,\n type,\n value: numberValue,\n });\n case VariableType.JSON:\n try {\n const jsonValue: JSONType = JSON.parse(String(variable.value));\n\n return Ok({\n key,\n type,\n value: jsonValue,\n });\n } catch (err) {\n return Err(new KameleoonError(KameleoonException.JSONParse, err));\n }\n default:\n exhaustCheck(type);\n }\n }\n\n static parseVisitorData({\n data,\n filters,\n visitorCode,\n dataManager,\n variationConfiguration,\n }: ParseVisitorDataParametersType): ParseVisitorDataResultType {\n const visitProcessor = new VisitProcessor({\n filters,\n dataManager,\n visitorCode,\n });\n\n const { currentVisit, previousVisits, kcs } = data;\n\n let visits: VisitType[] = [];\n\n if (currentVisit) {\n visits.push(currentVisit);\n }\n\n if (previousVisits) {\n visits.push(...previousVisits);\n }\n\n if (!visits.length) {\n return { visitorData: [], storageVisitorData: [] };\n }\n\n visits.forEach((visit) => {\n visitProcessor.processVisit(visit);\n });\n\n visitProcessor.processKcs(kcs);\n visitProcessor.processMultipleDataTypes();\n\n const { visitorData, storageVisitorData, visitsData, experimentData } =\n visitProcessor.data;\n\n variationConfiguration.updateStoredVariations(visitorCode, experimentData);\n\n return {\n visitorData,\n storageVisitorData,\n visitsData,\n };\n }\n\n static parseRegExp(value: string): RegExp {\n if (value[0] === '/') {\n const [_, expression, flags] = value.split('/');\n\n return new RegExp(expression, flags);\n }\n\n return new RegExp(value);\n }\n}\n"],"mappings":"0PAeO,KAAM,CAAAA,MAAO,CAClB,MAAO,CAAAC,oBAAoBA,CACzBC,CAA6B,CACsB,CACnD,KAAM,CAAEC,GAAG,CAAHA,CAAG,CAAEC,IAAI,CAAJA,CAAI,CAAEC,KAAK,CAALA,CAAM,CAAC,CAAGH,CAAQ,CAErC,OAAQE,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