@kameleoon/javascript-sdk-core 3.6.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +375 -0
- package/CHANGELOG_INTERNAL.md +3 -0
- package/dist/cacheManager/cacheManager.js +1 -1
- package/dist/cacheManager/cacheManager.js.map +1 -1
- package/dist/cacheManager/index.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.d.ts +2 -3
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/index.js +1 -1
- package/dist/clientConfiguration/types.d.ts +8 -9
- package/dist/clientConfiguration/types.js +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/clientSettings/clientSettings.js +1 -1
- package/dist/clientSettings/clientSettings.js.map +1 -1
- package/dist/clientSettings/index.js +1 -1
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/eventSource/constants.js +1 -1
- package/dist/eventSource/constants.js.map +1 -1
- package/dist/eventSource/eventSource.d.ts +17 -0
- package/dist/eventSource/eventSource.js +2 -0
- package/dist/eventSource/eventSource.js.map +1 -0
- package/dist/eventSource/index.d.ts +2 -2
- package/dist/eventSource/index.js +1 -1
- package/dist/eventSource/index.js.map +1 -1
- package/dist/eventSource/types.d.ts +8 -19
- package/dist/eventSource/types.js.map +1 -1
- package/dist/hasher/hasher.js +1 -1
- package/dist/hasher/hasher.js.map +1 -1
- package/dist/hasher/index.js +1 -1
- package/dist/hasher/index.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +2 -207
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +199 -0
- package/dist/kameleoonClientInterface.js +2 -0
- package/dist/kameleoonClientInterface.js.map +1 -0
- package/dist/kameleoonData/applicationVersion.js +1 -1
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/constants.js +1 -1
- package/dist/kameleoonData/constants.js.map +1 -1
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.js +1 -1
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +2 -2
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/helpers.js +1 -1
- package/dist/kameleoonData/helpers.js.map +1 -1
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +2 -2
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/userAgent.js +1 -1
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/kameleoonError/constants.d.ts +1 -1
- package/dist/kameleoonError/constants.js +1 -1
- package/dist/kameleoonError/constants.js.map +1 -1
- package/dist/kameleoonError/helpers.js.map +1 -1
- package/dist/kameleoonError/index.js +1 -1
- package/dist/kameleoonError/kameleoonError.js +1 -1
- package/dist/kameleoonError/kameleoonError.js.map +1 -1
- package/dist/kameleoonError/types.d.ts +1 -1
- package/dist/kameleoonError/types.js +1 -1
- package/dist/kameleoonError/types.js.map +1 -1
- package/dist/kameleoonUtils.js +1 -1
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.d.ts +1 -3
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +0 -3
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +11 -1
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +18 -0
- package/dist/requester/urlProvider.js +2 -0
- package/dist/requester/urlProvider.js.map +1 -0
- package/dist/storage/constants.js +1 -1
- package/dist/storage/constants.js.map +1 -1
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/storage.d.ts +13 -0
- package/dist/storage/storage.js +2 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/storage/types.d.ts +15 -30
- package/dist/storage/types.js.map +1 -1
- package/dist/targeting/conditions/applicationVersion.js +1 -1
- package/dist/targeting/conditions/applicationVersion.js.map +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/browser.js.map +1 -1
- package/dist/targeting/conditions/conditionFactory.js +1 -1
- package/dist/targeting/conditions/conditionFactory.js.map +1 -1
- package/dist/targeting/conditions/conversion.js +1 -1
- package/dist/targeting/conditions/conversion.js.map +1 -1
- package/dist/targeting/conditions/cookie.js +1 -1
- package/dist/targeting/conditions/cookie.js.map +1 -1
- package/dist/targeting/conditions/customData.js +1 -1
- package/dist/targeting/conditions/customData.js.map +1 -1
- package/dist/targeting/conditions/device.js +1 -1
- package/dist/targeting/conditions/device.js.map +1 -1
- package/dist/targeting/conditions/exclusiveCampaign.js +1 -1
- package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -1
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/firstVisit.js.map +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/geolocation.js.map +1 -1
- package/dist/targeting/conditions/index.js +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/lastVisit.js.map +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/newVisitor.js.map +1 -1
- package/dist/targeting/conditions/operatingSystem.js +1 -1
- package/dist/targeting/conditions/operatingSystem.js.map +1 -1
- package/dist/targeting/conditions/pageTitle.js +1 -1
- package/dist/targeting/conditions/pageTitle.js.map +1 -1
- package/dist/targeting/conditions/pageUrl.js +1 -1
- package/dist/targeting/conditions/pageUrl.js.map +1 -1
- package/dist/targeting/conditions/previousPage.js +1 -1
- package/dist/targeting/conditions/previousPage.js.map +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
- package/dist/targeting/conditions/sdkLanguage.js +1 -1
- package/dist/targeting/conditions/sdkLanguage.js.map +1 -1
- package/dist/targeting/conditions/segment.js +1 -1
- package/dist/targeting/conditions/segment.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -1
- package/dist/targeting/conditions/visitedPages.js +1 -1
- package/dist/targeting/conditions/visitedPages.js.map +1 -1
- package/dist/targeting/conditions/visitorCode.js +1 -1
- package/dist/targeting/conditions/visitorCode.js.map +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/conditions/visits.js.map +1 -1
- package/dist/targeting/index.js +1 -1
- package/dist/targeting/node.js +1 -1
- package/dist/targeting/node.js.map +1 -1
- package/dist/targeting/tree.js +1 -1
- package/dist/targeting/tree.js.map +1 -1
- package/dist/targeting/types.js +1 -1
- package/dist/targeting/types.js.map +1 -1
- package/dist/types.d.ts +14 -26
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.js +1 -1
- package/dist/utilities/constants.js.map +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/types.d.ts +7 -7
- package/dist/utilities/types.js +1 -1
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/variationConfiguration/index.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +3 -3
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/dist/visitorCodeManager/constants.d.ts +3 -0
- package/dist/visitorCodeManager/constants.js +2 -0
- package/dist/visitorCodeManager/constants.js.map +1 -0
- package/dist/visitorCodeManager/index.d.ts +2 -0
- package/dist/visitorCodeManager/index.js +1 -1
- package/dist/visitorCodeManager/index.js.map +1 -1
- package/dist/visitorCodeManager/types.d.ts +7 -0
- package/dist/visitorCodeManager/types.js +2 -0
- package/dist/visitorCodeManager/types.js.map +1 -0
- package/dist/visitorCodeManager/visitorCodeManager.d.ts +11 -8
- package/dist/visitorCodeManager/visitorCodeManager.js +1 -1
- package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -1
- package/package.json +5 -5
- package/dist/eventSource/externalEventSource.d.ts +0 -12
- package/dist/eventSource/externalEventSource.js +0 -2
- package/dist/eventSource/externalEventSource.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","a","b","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","externalEventSource","externalVisitorCodeManager","_classCallCheck","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","visitorCodeManager","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","c","d","e","wrap","f","prev","next","readStorageData","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateClientConfiguration","updateResult","sent","ok","abrupt","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","eventSource","handleRealTimeUpdates","Polling","handlePollingUpdates","stop","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","configurationData","ExternalEventSource","siteCode","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","get","featureFlags","configuration","segments","forEach","flag","rules","rule","segment","has","id","set","mappedRules","size","_createForOfIteratorHelper","s","n","done","featureFlag","g","_loop","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","consentType","ConsentType","Required","some","environmentEnabled","type","RuleType","TARGETED_DELIVERY","checkIntegrity","fields","Object","keys","length","requiredFields","sort","join","skipChecks","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","isStorageValid","parse","write","toString","h","i","j","k","l","getClientConfiguration","clientConfigurationResult","Utilities","sendOfflineTracking","customData","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","initialize","consentRequired","isConsentRequired","hasAnyTargetedDeliveryRule","setConsentRequired","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { IExternalStorage, ClientDataType } from 'src/storage';\nimport {\n ExternalEventSource,\n IEventSource,\n IExternalEventSourceConstructor,\n} from 'src/eventSource';\nimport { DEFAULT_CONFIGURATION_DATA } from './constants';\nimport {\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { OfflineTracking } from 'src/storage/types';\nimport { VisitorCodeManager } from 'src/visitorCodeManager';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: FeatureFlagType[];\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ConfigurationDataType = DEFAULT_CONFIGURATION_DATA;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IExternalStorage<ClientDataType>;\n private offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource?: IEventSource;\n private externalEventSource: IExternalEventSourceConstructor;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> = new Map();\n private dataManager: DataManager;\n private visitorCodeManager: VisitorCodeManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n externalEventSource,\n externalVisitorCodeManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.externalEventSource = externalEventSource;\n this.visitorCodeManager = externalVisitorCodeManager;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n this.configurationData = this.externalClientConfiguration!;\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n this.eventSource = new ExternalEventSource(\n this.settings.siteCode,\n this.externalEventSource,\n );\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): FeatureFlagType[] {\n return this.configurationData.featureFlags;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n const segments = new Map();\n\n this.featureFlags.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segments.has(rule.segment.id)) {\n segments.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n return segments;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n return this.featureFlags.some(\n (featureFlag) =>\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n ),\n );\n }\n\n // --- Note ---\n // Integrity check covers most of the migration scenarios\n // however in the future it will be changed to a dedicate migration\n // block that can handle all versions migrations\n private checkIntegrity(data: ConfigurationDataType | undefined): boolean {\n if (!data) {\n return false;\n }\n\n const fields = Object.keys(data);\n\n if (!fields.length) {\n return false;\n }\n\n const requiredFields = Object.keys(DEFAULT_CONFIGURATION_DATA);\n\n return fields.sort().join() === requiredFields.sort().join();\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { featureFlags, configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!featureFlags.length) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n const isStorageValid = this.checkIntegrity(data);\n\n // --- Note ---\n // Cleaning up storage if it's not valid for migration purposes\n if (!isStorageValid) {\n this.storage.write({\n data: DEFAULT_CONFIGURATION_DATA,\n lastUpdate: this.lastUpdate.toString(),\n });\n\n this.configurationData = DEFAULT_CONFIGURATION_DATA;\n } else {\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n const { featureFlags } = this.configurationData;\n\n if (featureFlags.length) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData } = clientConfigurationResult.data;\n\n this.configurationData = clientConfigurationResult.data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules.clear();\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.setConsentRequired(consentRequired);\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const data: ClientDataType = {\n data: this.configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"4gTAoCa,CAAAA,mBAAmB,YAiB9B,SAAAC,EAAAC,CAAA,CASsC,IARpC,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CACPC,CAAS,CAAAH,CAAA,CAATG,SAAS,CACTC,CAAW,CAAAJ,CAAA,CAAXI,WAAW,CACXC,CAA2B,CAAAL,CAAA,CAA3BK,2BAA2B,CAC3BC,CAAsB,CAAAN,CAAA,CAAtBM,sBAAsB,CACtBC,CAAmB,CAAAP,CAAA,CAAnBO,mBAAmB,CACnBC,CAA0B,CAAAR,CAAA,CAA1BQ,0BAA0B,CAAAC,eAAA,MAAAV,CAAA,EAAAW,eAAA,4CAAAA,eAAA,sCAvBiC,IAAI,EAAAA,eAAA,mBAChCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BACGG,qCAA0B,EAAAH,eAAA,yBAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,oCAAAA,eAAA,4CAAAA,eAAA,oBAS1B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,4BAAAA,eAAA,mCAc1D,IAAI,CAACP,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACF,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACc,UAAU,CAAG,GAAI,CAAAC,IAAM,CAC5B,IAAI,CAACd,OAAO,CAAGA,CAAO,CACtB,IAAI,CA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AAK,CAAClF,CAAI,CAChC,CAAC,IAAA5C,CAAA,IAAAoJ,OAAA,CAAArJ,mBAAA,CAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","constructor","a","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","eventSource","externalVisitorCodeManager","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","visitorCodeManager","initialize","readStorageData","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateResult","updateClientConfiguration","ok","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","isOpen","Polling","handlePollingUpdates","handleRealTimeUpdates","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","configurationData","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","featureFlags","configuration","segments","forEach","flag","rules","rule","segment","has","id","set","ruleMap","mappedRules","size","featureFlag","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","isConsentRequired","consentType","ConsentType","Required","hasAnyTargetedDeliveryRule","some","environmentEnabled","type","RuleType","TARGETED_DELIVERY","checkIntegrity","fields","Object","keys","length","requiredFields","sort","join","skipChecks","arguments","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","isStorageValid","UrlProvider","setDataApiDomain","dataApiDomain","parse","write","toString","clientConfigurationResult","getClientConfiguration","Utilities","sendOfflineTracking","customData","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","consentRequired","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { ClientDataType } from 'src/storage';\nimport { IEventSource } from 'src/eventSource';\nimport { DEFAULT_CONFIGURATION_DATA } from './constants';\nimport {\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { UrlProvider } from 'src/requester/urlProvider';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: FeatureFlagType[];\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ConfigurationDataType = DEFAULT_CONFIGURATION_DATA;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IStorage<ClientDataType>;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource: IEventSource;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> = new Map();\n private dataManager: DataManager;\n private visitorCodeManager: IVisitorCodeManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventSource = eventSource;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource.isOpen) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource.isOpen) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n this.configurationData = this.externalClientConfiguration!;\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): FeatureFlagType[] {\n return this.configurationData.featureFlags;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n const segments = new Map();\n\n this.featureFlags.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segments.has(rule.segment.id)) {\n segments.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n return segments;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n return this.featureFlags.some(\n (featureFlag) =>\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n ),\n );\n }\n\n // --- Note ---\n // Integrity check covers most of the migration scenarios\n // however in the future it will be changed to a dedicate migration\n // block that can handle all versions migrations\n private checkIntegrity(data: ConfigurationDataType | undefined): boolean {\n if (!data) {\n return false;\n }\n\n const fields = Object.keys(data);\n\n if (!fields.length) {\n return false;\n }\n\n const requiredFields = Object.keys(DEFAULT_CONFIGURATION_DATA);\n\n return fields.sort().join() === requiredFields.sort().join();\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { featureFlags, configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!featureFlags.length) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n const isStorageValid = this.checkIntegrity(data);\n\n // --- Note ---\n // Cleaning up storage if it's not valid for migration purposes\n if (!isStorageValid) {\n UrlProvider.setDataApiDomain(\n DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain,\n );\n\n this.storage.write({\n data: DEFAULT_CONFIGURATION_DATA,\n lastUpdate: this.lastUpdate.toString(),\n });\n\n this.configurationData = DEFAULT_CONFIGURATION_DATA;\n } else {\n UrlProvider.setDataApiDomain(data.configuration.dataApiDomain);\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n const { featureFlags } = this.configurationData;\n\n if (featureFlags.length) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData } = clientConfigurationResult.data;\n\n this.configurationData = clientConfigurationResult.data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules.clear();\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.consentRequired = consentRequired;\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const data: ClientDataType = {\n data: this.configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n UrlProvider.setDataApiDomain(\n this.configurationData.configuration.dataApiDomain,\n );\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"uxBAiCO,KAAM,CAAAA,mBAAoD,CAgB/DC,WAAWA,CAAAC,CAAA,CAS2B,IAT1B,CACVC,QAAQ,CAARA,CAAQ,CACRC,OAAO,CAAPA,CAAO,CACPC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAXA,CAAW,CACXC,2BAA2B,CAA3BA,CAA2B,CAC3BC,sBAAsB,CAAtBA,CAAsB,CACtBC,WAAW,CAAXA,CAAW,CACXC,0BAA0B,CAA1BA,CACiC,CAAC,CAAAR,CAAA,CAAAS,eAAA,4CAAAA,eAAA,sCAvByB,IAAI,EAAAA,eAAA,mBAChCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BACGG,qCAA0B,EAAAH,eAAA,yBAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,4CAAAA,eAAA,oBAQ1B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,4BAAAA,eAAA,mCAc1D,IAAI,CAACN,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACF,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACa,UAAU,CAAG,GAAI,CAAAC,IAAM,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,CAACqG,eAAe,CAAGA,CAAe,CAElD,GAAA1F,SAAE,EAACyF,CAAgB,CAC5B,CAEQD,iBAAiBA,CAAA,CAAiC,CACxD,IAAI,CAACrG,UAAU,CAAG,GAAI,CAAAC,IAAM,CAE5B,KAAM,CAAAW,CAAoB,CAAG,CAC3BA,IAAI,CAAE,IAAI,CAACa,iBAAiB,CAC5BzB,UAAU,CAAE,IAAI,CAACA,UAAU,CAAC4F,QAAQ,CAAC,CACvC,CAAC,CAMD,MAJA,CAAAL,wBAAW,CAACC,gBAAgB,CAC1B,IAAI,CAAC/D,iBAAiB,CAACa,aAAa,CAACmD,aACvC,CAAC,CAEM,IAAI,CAACrG,OAAO,CAACuG,KAAK,CAAC/E,CAAI,CAChC,CACF,CAAC4F,OAAA,CAAAxH,mBAAA,CAAAA,mBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CONFIGURATION_DATA=void 0;var _types=require("./types"),DEFAULT_CONFIGURATION_DATA={featureFlags:[],customData:[],configuration:{realTimeUpdate:!1,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CONFIGURATION_DATA=void 0;var _types=require("./types"),_requester=require("../requester");const DEFAULT_CONFIGURATION_DATA=exports.DEFAULT_CONFIGURATION_DATA={featureFlags:[],customData:[],configuration:{realTimeUpdate:!1,consentType:_types.ConsentType.NotRequired,dataApiDomain:_requester.DATA_API_DOMAIN}};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DEFAULT_CONFIGURATION_DATA","featureFlags","customData","configuration","realTimeUpdate","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["DEFAULT_CONFIGURATION_DATA","exports","featureFlags","customData","configuration","realTimeUpdate","consentType","ConsentType","NotRequired","dataApiDomain","DATA_API_DOMAIN"],"sources":["../../src/clientConfiguration/constants.ts"],"sourcesContent":["import { ConfigurationDataType } from 'src/clientConfiguration';\nimport { ConsentType } from './types';\nimport { DATA_API_DOMAIN } from 'src/requester';\n\nexport const DEFAULT_CONFIGURATION_DATA: ConfigurationDataType = {\n featureFlags: [],\n customData: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: DATA_API_DOMAIN,\n },\n};\n"],"mappings":"+KAIO,KAAM,CAAAA,0BAAiD,CAAAC,OAAA,CAAAD,0BAAA,CAAG,CAC/DE,YAAY,CAAE,EAAE,CAChBC,UAAU,CAAE,EAAE,CACdC,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAEC,0BACjB,CACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientConfiguration",{enumerable:!0,get:function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientConfiguration",{enumerable:!0,get:function(){return _clientConfiguration.ClientConfiguration}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _types.ConfigurationDataType}}),Object.defineProperty(exports,"ConsentType",{enumerable:!0,get:function(){return _types.ConsentType}}),Object.defineProperty(exports,"CustomDataConfigurationType",{enumerable:!0,get:function(){return _types.CustomDataConfigurationType}}),Object.defineProperty(exports,"CustomDataScope",{enumerable:!0,get:function(){return _types.CustomDataScope}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureVariableType",{enumerable:!0,get:function(){return _types.FeatureVariableType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _types.JSONType}}),Object.defineProperty(exports,"JSONValue",{enumerable:!0,get:function(){return _types.JSONValue}}),Object.defineProperty(exports,"RuleItemType",{enumerable:!0,get:function(){return _types.RuleItemType}}),Object.defineProperty(exports,"RuleType",{enumerable:!0,get:function(){return _types.RuleType}}),Object.defineProperty(exports,"VariationByExpositionType",{enumerable:!0,get:function(){return _types.VariationByExpositionType}});var _types=require("./types"),_clientConfiguration=require("./clientConfiguration");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ClientSettingsType } from '../clientSettings';
|
|
2
|
-
import {
|
|
2
|
+
import { IEventSource } from '../eventSource';
|
|
3
3
|
import { DataManager } from '../kameleoonData';
|
|
4
4
|
import { Requester } from '../requester';
|
|
5
|
-
import {
|
|
6
|
-
import { ClientDataType,
|
|
7
|
-
import { OfflineTracking } from '../storage/types';
|
|
5
|
+
import { IVisitorCodeManager } from '../visitorCodeManager';
|
|
6
|
+
import { ClientDataType, IStorage, OfflineTracking } from '../storage';
|
|
8
7
|
import { SegmentType } from '../targeting';
|
|
9
8
|
import { VariableType } from '../types';
|
|
10
9
|
export type ScheduleType = {
|
|
@@ -104,16 +103,16 @@ export type CustomDataConfigurationType = {
|
|
|
104
103
|
};
|
|
105
104
|
export type ConfigurationType = {
|
|
106
105
|
realTimeUpdate: boolean;
|
|
107
|
-
projectEnabled: boolean;
|
|
108
106
|
consentType: ConsentType;
|
|
107
|
+
dataApiDomain: string;
|
|
109
108
|
};
|
|
110
109
|
export type ClientConfigurationParametersType = {
|
|
111
110
|
settings: ClientSettingsType;
|
|
112
|
-
storage:
|
|
111
|
+
storage: IStorage<ClientDataType>;
|
|
113
112
|
dataManager: DataManager;
|
|
114
113
|
requester: Requester;
|
|
115
|
-
|
|
114
|
+
eventSource: IEventSource;
|
|
115
|
+
offlineTrackingStorage: IStorage<OfflineTracking>;
|
|
116
116
|
externalClientConfiguration?: ConfigurationDataType;
|
|
117
|
-
|
|
118
|
-
externalVisitorCodeManager: VisitorCodeManager;
|
|
117
|
+
externalVisitorCodeManager: IVisitorCodeManager;
|
|
119
118
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UpdateType=exports.RuleType=exports.FeatureStatus=exports.FeatureFlagSdkLanguageType=exports.CustomDataScope=exports.ConsentType=void 0;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UpdateType=exports.RuleType=exports.FeatureStatus=exports.FeatureFlagSdkLanguageType=exports.CustomDataScope=exports.ConsentType=void 0;let UpdateType=exports.UpdateType=function(a){return a[a.Polling=0]="Polling",a[a.RealTime=1]="RealTime",a[a.Idle=2]="Idle",a}({}),RuleType=exports.RuleType=function(a){return a.TARGETED_DELIVERY="TARGETED_DELIVERY",a.EXPERIMENTATION="EXPERIMENTATION",a}({}),FeatureFlagSdkLanguageType=exports.FeatureFlagSdkLanguageType=function(a){return a.ANDROID="ANDROID",a.SWIFT="SWIFT",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACTJS="REACTJS",a}({}),FeatureStatus=exports.FeatureStatus=function(a){return a.ACTIVATED="ACTIVATED",a.DEACTIVATED="DEACTIVATED",a.SCHEDULED="SCHEDULED",a}({}),CustomDataScope=exports.CustomDataScope=function(a){return a.Visit="VISIT",a.Visitor="VISITOR",a.Page="Page",a}({}),ConsentType=exports.ConsentType=function(a){return a.Required="REQUIRED",a.NotRequired="NOT_REQUIRED",a}({});
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["UpdateType","Polling","RealTime","Idle","
|
|
1
|
+
{"version":3,"file":"types.js","names":["UpdateType","exports","Polling","RealTime","Idle","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IEventSource } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { ClientDataType, IStorage, OfflineTracking } from 'src/storage';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n isMappingIdentifier: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n consentType: ConsentType;\n dataApiDomain: string;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n eventSource: IEventSource;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalVisitorCodeManager: IVisitorCodeManager;\n};\n"],"mappings":"uNAcY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAE,OAAA,cAAVF,CAAU,CAAVA,CAAU,CAAAG,QAAA,eAAVH,CAAU,CAAVA,CAAU,CAAAI,IAAA,WAAVJ,CAAU,MAeVK,QAAQ,CAAAJ,OAAA,CAAAI,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAKRG,0BAA0B,CAAAP,OAAA,CAAAO,0BAAA,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAa1BW,aAAa,CAAAlB,OAAA,CAAAkB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAMbI,eAAe,CAAAtB,OAAA,CAAAsB,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAMfI,WAAW,CAAA1B,OAAA,CAAA0B,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function
|
|
1
|
+
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class ClientSettings{constructor(a,b){_defineProperty(this,"updateInterval",60*_types.Milliseconds.Minute),_defineProperty(this,"environment",void 0),_defineProperty(this,"siteCode",void 0),this.siteCode=a,null!==b&&void 0!==b&&b.environment&&(this.environment=b.environment),null!==b&&void 0!==b&&b.updateInterval&&(1>b.updateInterval&&(this.updateInterval=1*_types.Milliseconds.Minute),this.updateInterval=b.updateInterval*_types.Milliseconds.Minute)}get settings(){return{updateInterval:this.updateInterval,environment:this.environment,siteCode:this.siteCode}}}exports.ClientSettings=ClientSettings;
|
|
2
2
|
//# sourceMappingURL=clientSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSettings.js","names":["_types","require","Object","defineProperty","exports","value","ClientSettings","
|
|
1
|
+
{"version":3,"file":"clientSettings.js","names":["_types","require","Object","defineProperty","exports","value","ClientSettings","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","siteCode","configuration","Milliseconds","Minute","environment","updateInterval","settings"],"sources":["../../src/clientSettings/clientSettings.ts"],"sourcesContent":["import { Environment, Milliseconds, SDKConfigurationType } from 'src/types';\nimport { ClientSettingsType } from './types';\n\nexport interface IClientSettings {\n readonly settings: ClientSettingsType;\n}\n\nexport class ClientSettings implements IClientSettings {\n private updateInterval: number = 60 * Milliseconds.Minute;\n private environment?: Environment;\n private siteCode: string;\n\n constructor(siteCode: string, configuration?: Partial<SDKConfigurationType>) {\n this.siteCode = siteCode;\n\n if (configuration?.environment) {\n this.environment = configuration.environment;\n }\n\n if (configuration?.updateInterval) {\n if (configuration.updateInterval < 1) {\n this.updateInterval = 1 * Milliseconds.Minute;\n }\n\n this.updateInterval = configuration.updateInterval * Milliseconds.Minute;\n }\n }\n\n get settings(): ClientSettingsType {\n return {\n updateInterval: this.updateInterval,\n environment: this.environment,\n siteCode: this.siteCode,\n };\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,aAA4EC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,c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,CAACC,MAAM,CAE5E,CAEA,GAAI,CAAAG,QAAQA,CAAA,CAAuB,CACjC,MAAO,CACLD,cAAc,CAAE,IAAI,CAACA,cAAc,CACnCD,WAAW,CAAE,IAAI,CAACA,WAAW,CAC7BJ,QAAQ,CAAE,IAAI,CAACA,QACjB,CACF,CACF,CAACpB,OAAA,CAAAE,cAAA,CAAAA,cAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientSettings",{enumerable:!0,get:function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientSettings",{enumerable:!0,get:function(){return _clientSettings.ClientSettings}}),Object.defineProperty(exports,"ClientSettingsType",{enumerable:!0,get:function(){return _types.ClientSettingsType}});var _clientSettings=require("./clientSettings"),_types=require("./types");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { VisitorDataFiltersType } from './utilities/types';
|
|
2
2
|
export declare const OFF_VARIATION_KEY = "off";
|
|
3
|
-
export declare const KAMELEOON_COOKIE_KEY = "kameleoonVisitorCode";
|
|
4
3
|
export declare const WAREHOUSE_AUDIENCE_KEY = "warehouseAudiences";
|
|
5
4
|
export declare const VISITOR_CODE_LENGTH = 16;
|
|
6
5
|
export declare const CACHE_CLEANUP_TIMEOUT = 10;
|
|
7
6
|
export declare const CACHE_ITEM_LIFETIME = 5;
|
|
8
|
-
export declare enum CookieParameter {
|
|
9
|
-
PairsDelimiter = "; ",
|
|
10
|
-
KeyValueDelimiter = "=",
|
|
11
|
-
MaxAge = "Max-Age",
|
|
12
|
-
Path = "Path",
|
|
13
|
-
Domain = "Domain"
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* @readonly
|
|
17
9
|
* @enum {string} an Enum of all the possible Kameleoon SDK types
|
package/dist/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.DEFAULT_VISITOR_DATA_FILTERS=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;const OFF_VARIATION_KEY=exports.OFF_VARIATION_KEY="off",WAREHOUSE_AUDIENCE_KEY=exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences",VISITOR_CODE_LENGTH=exports.VISITOR_CODE_LENGTH=16,CACHE_CLEANUP_TIMEOUT=exports.CACHE_CLEANUP_TIMEOUT=10,CACHE_ITEM_LIFETIME=exports.CACHE_ITEM_LIFETIME=5;let SdkLanguageType=exports.SdkLanguageType=function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});const DEFAULT_VISITOR_DATA_FILTERS=exports.DEFAULT_VISITOR_DATA_FILTERS={previousVisitAmount:1,currentVisit:!0,customData:!0,pageViews:!1,geolocation:!1,device:!1,browser:!1,operatingSystem:!1,conversions:!1,experiments:!1};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","WAREHOUSE_AUDIENCE_KEY","VISITOR_CODE_LENGTH","CACHE_CLEANUP_TIMEOUT","CACHE_ITEM_LIFETIME","SdkLanguageType","ANDROID","IOS","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACT","PYTHON","JAVASCRIPT","RUST","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","currentVisit","customData","pageViews","geolocation","device","browser","operatingSystem","conversions","experiments"],"sources":["../src/constants.ts"],"sourcesContent":["import { VisitorDataFiltersType } from './utilities/types';\n\nexport const OFF_VARIATION_KEY = 'off';\nexport const WAREHOUSE_AUDIENCE_KEY = 'warehouseAudiences';\nexport const VISITOR_CODE_LENGTH = 16;\nexport const CACHE_CLEANUP_TIMEOUT = 10;\nexport const CACHE_ITEM_LIFETIME = 5;\n\n/**\n * @readonly\n * @enum {string} an Enum of all the possible Kameleoon SDK types\n * */\nexport enum SdkLanguageType {\n ANDROID = 'ANDROID',\n IOS = 'IOS',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACT = 'REACT',\n PYTHON = 'PYTHON',\n JAVASCRIPT = 'JAVASCRIPT',\n RUST = 'RUST',\n}\n\nexport const DEFAULT_VISITOR_DATA_FILTERS: VisitorDataFiltersType = {\n previousVisitAmount: 1,\n currentVisit: true,\n customData: true,\n pageViews: false,\n geolocation: false,\n device: false,\n browser: false,\n operatingSystem: false,\n conversions: false,\n experiments: false,\n};\n"],"mappings":"4RAEa,CAAAA,iBAAiB,CAAAC,OAAA,CAAAD,iBAAA,CAAG,KAAK,CACzBE,sBAAsB,CAAAD,OAAA,CAAAC,sBAAA,CAAG,oBAAoB,CAC7CC,mBAAmB,CAAAF,OAAA,CAAAE,mBAAA,CAAG,EAAE,CACxBC,qBAAqB,CAAAH,OAAA,CAAAG,qBAAA,CAAG,EAAE,CAC1BC,mBAAmB,CAAAJ,OAAA,CAAAI,mBAAA,CAAG,CAAC,IAMxB,CAAAC,eAAe,CAAAL,OAAA,CAAAK,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,OAAA,WAAfD,CAAe,CAAAE,GAAA,OAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,CAAAI,MAAA,UAAfJ,CAAe,CAAAK,MAAA,UAAfL,CAAe,CAAAM,GAAA,OAAfN,CAAe,CAAAO,IAAA,QAAfP,CAAe,CAAAQ,EAAA,MAAfR,CAAe,CAAAS,OAAA,WAAfT,CAAe,CAAAU,KAAA,SAAfV,CAAe,CAAAW,MAAA,UAAfX,CAAe,CAAAY,UAAA,cAAfZ,CAAe,CAAAa,IAAA,QAAfb,CAAe,MAgBpB,KAAM,CAAAc,4BAAoD,CAAAnB,OAAA,CAAAmB,4BAAA,CAAG,CAClEC,mBAAmB,CAAE,CAAC,CACtBC,YAAY,GAAM,CAClBC,UAAU,GAAM,CAChBC,SAAS,GAAO,CAChBC,WAAW,GAAO,CAClBC,MAAM,GAAO,CACbC,OAAO,GAAO,CACdC,eAAe,GAAO,CACtBC,WAAW,GAAO,CAClBC,WAAW,GACb,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REAL_TIME_EVENT=void 0;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REAL_TIME_EVENT=void 0;const REAL_TIME_EVENT=exports.REAL_TIME_EVENT="configuration-update-event";
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["REAL_TIME_EVENT","exports"],"sources":["../../src/eventSource/constants.ts"],"sourcesContent":["export const REAL_TIME_EVENT = 'configuration-update-event';\n"],"mappings":"mGAAO,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["REAL_TIME_EVENT","exports"],"sources":["../../src/eventSource/constants.ts"],"sourcesContent":["export const REAL_TIME_EVENT = 'configuration-update-event';\n"],"mappings":"mGAAO,KAAM,CAAAA,eAAe,CAAAC,OAAA,CAAAD,eAAA,CAAG,4BAA4B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventHandlerType, IExternalEventSource } from './types';
|
|
2
|
+
export interface IEventSource {
|
|
3
|
+
readonly isOpen: boolean;
|
|
4
|
+
open: (onEvent: EventHandlerType) => void;
|
|
5
|
+
close: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare class KameleoonEventSource implements IEventSource {
|
|
8
|
+
private eventSource;
|
|
9
|
+
private siteCode;
|
|
10
|
+
private url;
|
|
11
|
+
private isConnectionOpen;
|
|
12
|
+
constructor(siteCode: string, externalEventSource: IExternalEventSource);
|
|
13
|
+
get isOpen(): boolean;
|
|
14
|
+
open(onEvent: EventHandlerType): void;
|
|
15
|
+
close(): void;
|
|
16
|
+
private handleMessage;
|
|
17
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonEventSource=void 0;var _requester=require("../requester"),_constants=require("../requester/constants"),_constants2=require("./constants");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class KameleoonEventSource{constructor(a,b){_defineProperty(this,"eventSource",void 0),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"isConnectionOpen",void 0);const c=_requester.URL.SERVER_SENT_EVENTS+_constants.UrlQuery.Sse+a;this.url=c,this.siteCode=a,this.eventSource=b,this.isConnectionOpen=!1}get isOpen(){return this.isConnectionOpen}open(a){this.eventSource.open({onEvent:this.handleMessage(a),url:this.url,eventType:_constants2.REAL_TIME_EVENT}),this.isConnectionOpen=!0}close(){this.eventSource.close(),this.isConnectionOpen=!1}handleMessage(a){const b=b=>{const c=JSON.parse(b.data),{siteCode:d,ts:e}=c;this.siteCode===d&&a(e)};return b}}exports.KameleoonEventSource=KameleoonEventSource;
|
|
2
|
+
//# sourceMappingURL=eventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventSource.js","names":["KameleoonEventSource","constructor","siteCode","externalEventSource","_defineProperty","url","URL","SERVER_SENT_EVENTS","UrlQuery","Sse","eventSource","isConnectionOpen","isOpen","open","onEvent","handleMessage","eventType","REAL_TIME_EVENT","close","onMessage","message","event","JSON","parse","data","eventSiteCode","ts","exports"],"sources":["../../src/eventSource/eventSource.ts"],"sourcesContent":["import { URL } from 'src/requester';\nimport { UrlQuery } from 'src/requester/constants';\nimport { REAL_TIME_EVENT } from './constants';\nimport {\n EventHandlerType,\n IExternalEventSource,\n RealTimeEventType,\n} from './types';\n\nexport interface IEventSource {\n readonly isOpen: boolean;\n open: (onEvent: EventHandlerType) => void;\n close: () => void;\n}\n\n// --- Note ---\n// Named `KameleoonEventSource` to avoid collision with native `EventSource`\nexport class KameleoonEventSource implements IEventSource {\n private eventSource: IExternalEventSource;\n private siteCode: string;\n private url: string;\n private isConnectionOpen: boolean;\n\n constructor(siteCode: string, externalEventSource: IExternalEventSource) {\n const url = URL.SERVER_SENT_EVENTS + UrlQuery.Sse + siteCode;\n\n this.url = url;\n this.siteCode = siteCode;\n this.eventSource = externalEventSource;\n this.isConnectionOpen = false;\n }\n\n get isOpen(): boolean {\n return this.isConnectionOpen;\n }\n\n public open(onEvent: EventHandlerType): void {\n this.eventSource.open({\n onEvent: this.handleMessage(onEvent),\n url: this.url,\n eventType: REAL_TIME_EVENT,\n });\n this.isConnectionOpen = true;\n }\n\n public close(): void {\n this.eventSource.close();\n this.isConnectionOpen = false;\n }\n\n private handleMessage(\n onEvent: EventHandlerType,\n ): (message: MessageEvent) => void {\n const onMessage = (message: MessageEvent): void => {\n const event: RealTimeEventType = JSON.parse(message.data);\n const { siteCode: eventSiteCode, ts } = event;\n\n if (this.siteCode === eventSiteCode) {\n onEvent(ts);\n }\n };\n\n return onMessage;\n }\n}\n"],"mappings":"kuBAiBO,KAAM,CAAAA,oBAA6C,CAMxDC,WAAWA,CAACC,CAAgB,CAAEC,CAAyC,CAAE,CAAAC,eAAA,4BAAAA,eAAA,yBAAAA,eAAA,oBAAAA,eAAA,iCACvE,KAAM,CAAAC,CAAG,CAAGC,cAAG,CAACC,kBAAkB,CAAGC,mBAAQ,CAACC,GAAG,CAAGP,CAAQ,CAE5D,IAAI,CAACG,GAAG,CAAGA,CAAG,CACd,IAAI,CAACH,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACQ,WAAW,CAAGP,CAAmB,CACtC,IAAI,CAACQ,gBAAgB,GACvB,CAEA,GAAI,CAAAC,MAAMA,CAAA,CAAY,CACpB,MAAO,KAAI,CAACD,gBACd,CAEOE,IAAIA,CAACC,CAAyB,CAAQ,CAC3C,IAAI,CAACJ,WAAW,CAACG,IAAI,CAAC,CACpBC,OAAO,CAAE,IAAI,CAACC,aAAa,CAACD,CAAO,CAAC,CACpCT,GAAG,CAAE,IAAI,CAACA,GAAG,CACbW,SAAS,CAAEC,2BACb,CAAC,CAAC,CACF,IAAI,CAACN,gBAAgB,GACvB,CAEOO,KAAKA,CAAA,CAAS,CACnB,IAAI,CAACR,WAAW,CAACQ,KAAK,CAAC,CAAC,CACxB,IAAI,CAACP,gBAAgB,GACvB,CAEQI,aAAaA,CACnBD,CAAyB,CACQ,CACjC,KAAM,CAAAK,CAAS,CAAIC,CAAqB,EAAW,MAC3C,CAAAC,CAAwB,CAAGC,IAAI,CAACC,KAAK,CAACH,CAAO,CAACI,IAAI,CAAC,CACnD,CAAEtB,QAAQ,CAAEuB,CAAa,CAAEC,EAAE,CAAFA,CAAG,CAAC,CAAGL,CAAK,CAEzC,IAAI,CAACnB,QAAQ,GAAKuB,CAAa,EACjCX,CAAO,CAACY,CAAE,CAEd,CAAC,CAED,MAAO,CAAAP,CACT,CACF,CAACQ,OAAA,CAAA3B,oBAAA,CAAAA,oBAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { EventSourceOpenParametersType, IExternalEventSource, RealTimeEventType, } from './types';
|
|
2
|
+
export { KameleoonEventSource, IEventSource } from './eventSource';
|
|
3
3
|
export { REAL_TIME_EVENT } from './constants';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function(){return _types.EventSourceOpenParametersType}}),Object.defineProperty(exports,"IEventSource",{enumerable:!0,get:function(){return _eventSource.IEventSource}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function(){return _types.IExternalEventSource}}),Object.defineProperty(exports,"KameleoonEventSource",{enumerable:!0,get:function(){return _eventSource.KameleoonEventSource}}),Object.defineProperty(exports,"REAL_TIME_EVENT",{enumerable:!0,get:function(){return _constants.REAL_TIME_EVENT}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function(){return _types.RealTimeEventType}});var _types=require("./types"),_eventSource=require("./eventSource"),_constants=require("./constants");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/eventSource/index.ts"],"sourcesContent":["export {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/eventSource/index.ts"],"sourcesContent":["export {\n EventSourceOpenParametersType,\n IExternalEventSource,\n RealTimeEventType,\n} from './types';\nexport { KameleoonEventSource, IEventSource } from './eventSource';\nexport { REAL_TIME_EVENT } from './constants';\n"],"mappings":""}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @param {number} timestamp - timestamp of when the event has happened
|
|
3
3
|
* */
|
|
4
|
-
export
|
|
5
|
-
/**
|
|
6
|
-
* @method initialize - creates and instance of `IExternalEventSource` and returns it
|
|
7
|
-
* @param {string} url - url of server sent event server which will be pasted by consumer
|
|
8
|
-
* @returns {IExternalEventSource} an initialized instance of `IExternalEventSource`
|
|
9
|
-
* */
|
|
10
|
-
initialize: (url: string) => IExternalEventSource;
|
|
11
|
-
}
|
|
4
|
+
export type EventHandlerType = (timestamp: number) => void;
|
|
12
5
|
/**
|
|
13
|
-
* @param {string}
|
|
6
|
+
* @param {string} url - url of server sent event server which will be pasted by consumer
|
|
14
7
|
* @param {string} eventType - type of event to be listened for
|
|
15
|
-
* @param {(
|
|
8
|
+
* @param {(message: MessageEvent) => void} onEvent - callback to be executed when event fired
|
|
16
9
|
* */
|
|
17
10
|
export type EventSourceOpenParametersType = {
|
|
18
|
-
|
|
11
|
+
url: string;
|
|
19
12
|
eventType: string;
|
|
20
|
-
onEvent: (
|
|
13
|
+
onEvent: (message: MessageEvent) => void;
|
|
21
14
|
};
|
|
22
15
|
/**
|
|
23
16
|
* @interface an interface of External Event Source which will be used in server sent events operations
|
|
@@ -25,9 +18,9 @@ export type EventSourceOpenParametersType = {
|
|
|
25
18
|
export interface IExternalEventSource {
|
|
26
19
|
/**
|
|
27
20
|
* @method open - opens event source live connection
|
|
28
|
-
* @param {
|
|
21
|
+
* @param {OpenEventSourceParamsType} parameters - parameters to be passed to the event source
|
|
29
22
|
* */
|
|
30
|
-
open: ({
|
|
23
|
+
open: ({ url, eventType, onEvent }: EventSourceOpenParametersType) => void;
|
|
31
24
|
/**
|
|
32
25
|
* @method close - closes event source live connection
|
|
33
26
|
* */
|
|
@@ -41,7 +34,3 @@ export type RealTimeEventType = {
|
|
|
41
34
|
siteCode: string;
|
|
42
35
|
ts: number;
|
|
43
36
|
};
|
|
44
|
-
export type CreateEventSourceParamsType = {
|
|
45
|
-
siteCode: string;
|
|
46
|
-
externalEventSource?: IExternalEventSourceConstructor;
|
|
47
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/eventSource/types.ts"],"sourcesContent":["/**\n * @
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/eventSource/types.ts"],"sourcesContent":["/**\n * @param {number} timestamp - timestamp of when the event has happened\n * */\nexport type EventHandlerType = (timestamp: number) => void;\n\n/**\n * @param {string} url - url of server sent event server which will be pasted by consumer\n * @param {string} eventType - type of event to be listened for\n * @param {(message: MessageEvent) => void} onEvent - callback to be executed when event fired\n * */\nexport type EventSourceOpenParametersType = {\n url: string;\n eventType: string;\n onEvent: (message: MessageEvent) => void;\n};\n\n/**\n * @interface an interface of External Event Source which will be used in server sent events operations\n * */\nexport interface IExternalEventSource {\n /**\n * @method open - opens event source live connection\n * @param {OpenEventSourceParamsType} parameters - parameters to be passed to the event source\n * */\n open: ({ url, eventType, onEvent }: EventSourceOpenParametersType) => void;\n /**\n * @method close - closes event source live connection\n * */\n close: () => void;\n}\n\n/**\n * @param {string} siteCode - site code from the event\n * @param {number} ts - timestamp of when the event has happened\n * */\nexport type RealTimeEventType = {\n siteCode: string;\n ts: number;\n};\n"],"mappings":""}
|
package/dist/hasher/hasher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}
|
|
1
|
+
"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}class Hasher{static getHashDouble(a){let{visitorIdentifier:b,id:c,respoolTime:d}=a,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}static calculateHash(a){const b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}exports.Hasher=Hasher;
|
|
2
2
|
//# sourceMappingURL=hasher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","
|
|
1
|
+
{"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","getHashDouble","visitorIdentifier","id","respoolTime","suffix","calculateHash","seed","hashDigest","sha256","toString","parseInt","Math","pow"],"sources":["../../src/hasher/hasher.ts"],"sourcesContent":["import sha256 from 'crypto-js/sha256';\nimport { GetHashDoubleParamsType } from './types';\n\nexport class Hasher {\n static getHashDouble({\n visitorIdentifier,\n id,\n respoolTime,\n }: GetHashDoubleParamsType): number {\n let suffix = '';\n\n if (respoolTime) {\n suffix += String(respoolTime);\n }\n\n return this.calculateHash(visitorIdentifier + id + suffix);\n }\n\n // --- Note ---\n // `hashDouble` is a seeded pseudo-random number between 0 and 1\n // used for deciding what variation to assign\n // `calculateHash` algorithm is consistent between every SDK\n // and will always provide same pseudo-random value for the same input parameters\n static calculateHash(seed: string): number {\n const hashDigest = sha256(seed).toString();\n\n return parseInt(hashDigest, 16) / Math.pow(2, 256);\n }\n}\n"],"mappings":"aAAA,IAAAA,IAAA,CAAAC,sBAAA,CAAAC,OAAA,sBAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,MAAA,iBAAAN,uBAAAO,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,EAAAE,OAAA,CAAAF,CAAA,EAG/B,KAAM,CAAAD,MAAO,CAClB,MAAO,CAAAI,aAAaA,CAAAH,CAAA,CAIgB,IAJf,CACnBI,iBAAiB,CAAjBA,CAAiB,CACjBC,EAAE,CAAFA,CAAE,CACFC,WAAW,CAAXA,CACuB,CAAC,CAAAN,CAAA,CACpBO,CAAM,CAAG,EAAE,CAMf,MAJI,CAAAD,CAAW,GACbC,CAAM,EAAWD,CAAW,GAAC,EAGxB,IAAI,CAACE,aAAa,CAACJ,CAAiB,CAAGC,CAAE,CAAGE,CAAM,CAC3D,CAOA,MAAO,CAAAC,aAAaA,CAACC,CAAY,CAAU,CACzC,KAAM,CAAAC,CAAU,CAAG,GAAAC,YAAM,EAACF,CAAI,CAAC,CAACG,QAAQ,CAAC,CAAC,CAE1C,MAAO,CAAAC,QAAQ,CAACH,CAAU,CAAE,EAAE,CAAC,CAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,CAAE,GAAG,CACnD,CACF,CAAClB,OAAA,CAAAE,MAAA,CAAAA,MAAA"}
|
package/dist/hasher/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _hasher=require("./hasher");Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Hasher",{enumerable:!0,get:function
|
|
1
|
+
"use strict";var _hasher=require("./hasher");Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Hasher",{enumerable:!0,get:function(){return _hasher.Hasher}});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/hasher/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_hasher","require","Object","defineProperty","exports","value","enumerable","get","Hasher"],"sources":["../../src/hasher/index.ts"],"sourcesContent":["export { Hasher } from './hasher';\n"],"mappings":"aAAA,IAAAA,OAAA,CAAAC,OAAA,aAAkCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAH,MAAA,CAAAC,cAAA,CAAAC,OAAA,WAAAE,UAAA,IAAAC,GAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_hasher","require","Object","defineProperty","exports","value","enumerable","get","Hasher"],"sources":["../../src/hasher/index.ts"],"sourcesContent":["export { Hasher } from './hasher';\n"],"mappings":"aAAA,IAAAA,OAAA,CAAAC,OAAA,aAAkCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAH,MAAA,CAAAC,cAAA,CAAAC,OAAA,WAAAE,UAAA,IAAAC,GAAA,SAAAA,CAAA,SAAAP,OAAA,CAAAQ,MAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export { Ok, Result, Err } from 'ts-res';
|
|
2
|
-
export { KameleoonClient as KameleoonCore
|
|
2
|
+
export { KameleoonClient as KameleoonCore } from './kameleoonClient';
|
|
3
|
+
export { IKameleoonClient as IKameleoonCore } from './kameleoonClientInterface';
|
|
3
4
|
export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
|
|
4
5
|
export { KameleoonException, KameleoonError } from './kameleoonError';
|
|
5
6
|
export { VisitorDataFiltersType } from './utilities';
|
|
6
|
-
export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage,
|
|
7
|
-
export { VisitorCodeManager } from './visitorCodeManager';
|
|
8
|
-
export {
|
|
7
|
+
export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, } from './storage';
|
|
8
|
+
export { VisitorCodeManager, IVisitorCodeManager } from './visitorCodeManager';
|
|
9
|
+
export { VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';
|
|
9
10
|
export { JSONType, ConfigurationDataType } from './clientConfiguration';
|
|
10
|
-
export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, FeatureFlagVariableType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, Milliseconds, } from './types';
|
|
11
|
+
export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, FeatureFlagVariableType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, SetDataCallbackParametersType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, Milliseconds, } from './types';
|
|
11
12
|
export { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';
|
|
12
13
|
export { ApplicationVersion, CustomData, Conversion, Device, Cookie, Browser, UserAgent, DeviceType, CookieType, GeolocationData, GeolocationInfoType, OperatingSystemType, OperatingSystem, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './kameleoonData';
|
|
13
|
-
export {
|
|
14
|
+
export { IExternalEventSource, EventSourceOpenParametersType, } from './eventSource';
|
|
14
15
|
export { Header, HeadersType, HttpMethod, TrackParametersType, IExternalRequestDispatcher, DEFAULT_REQUEST_TIMEOUT, NUMBER_OF_RETRIES, RETRIES_DELAY, } from './requester';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _clientConfiguration.ConfigurationDataType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DEFAULT_REQUEST_TIMEOUT",{enumerable:!0,get:function(){return _requester.DEFAULT_REQUEST_TIMEOUT}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariableType",{enumerable:!0,get:function(){return _types.FeatureFlagVariableType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function(){return _requester.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function(){return _requester.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function(){return _kameleoonClientInterface.IKameleoonClient}}),Object.defineProperty(exports,"IVisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.IVisitorCodeManager}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function(){return _types.Milliseconds}}),Object.defineProperty(exports,"NUMBER_OF_RETRIES",{enumerable:!0,get:function(){return _requester.NUMBER_OF_RETRIES}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RETRIES_DELAY",{enumerable:!0,get:function(){return _requester.RETRIES_DELAY}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"SetDataCallbackParametersType",{enumerable:!0,get:function(){return _types.SetDataCallbackParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.VisitorCodeManager}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonClientInterface=require("./kameleoonClientInterface"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_visitorCodeManager=require("./visitorCodeManager"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|