@kameleoon/javascript-sdk-core 3.2.1 → 3.4.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.
Files changed (60) hide show
  1. package/dist/clientConfiguration/clientConfiguration.d.ts +2 -2
  2. package/dist/clientConfiguration/clientConfiguration.js +1 -1
  3. package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
  4. package/dist/clientConfiguration/types.d.ts +2 -2
  5. package/dist/clientConfiguration/types.js.map +1 -1
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/kameleoonClient.d.ts +15 -27
  10. package/dist/kameleoonClient.js +1 -1
  11. package/dist/kameleoonClient.js.map +1 -1
  12. package/dist/kameleoonData/dataManager.js +1 -1
  13. package/dist/kameleoonData/dataManager.js.map +1 -1
  14. package/dist/kameleoonData/dataProcessor.js +1 -1
  15. package/dist/kameleoonData/dataProcessor.js.map +1 -1
  16. package/dist/kameleoonError/constants.js +1 -1
  17. package/dist/kameleoonError/constants.js.map +1 -1
  18. package/dist/kameleoonUtils.js +1 -1
  19. package/dist/kameleoonUtils.js.map +1 -1
  20. package/dist/requester/constants.d.ts +3 -1
  21. package/dist/requester/constants.js +1 -1
  22. package/dist/requester/constants.js.map +1 -1
  23. package/dist/requester/index.d.ts +2 -2
  24. package/dist/requester/index.js +1 -1
  25. package/dist/requester/index.js.map +1 -1
  26. package/dist/requester/requester.d.ts +4 -4
  27. package/dist/requester/requester.js +1 -1
  28. package/dist/requester/requester.js.map +1 -1
  29. package/dist/requester/types.d.ts +11 -7
  30. package/dist/requester/types.js +1 -1
  31. package/dist/requester/types.js.map +1 -1
  32. package/dist/storage/types.d.ts +5 -1
  33. package/dist/storage/types.js.map +1 -1
  34. package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
  35. package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -1
  36. package/dist/types.d.ts +26 -48
  37. package/dist/types.js.map +1 -1
  38. package/dist/utilities/types.d.ts +7 -0
  39. package/dist/utilities/types.js.map +1 -1
  40. package/dist/utilities/utilities.d.ts +5 -9
  41. package/dist/utilities/utilities.js +1 -1
  42. package/dist/utilities/utilities.js.map +1 -1
  43. package/dist/variationConfiguration/types.d.ts +6 -1
  44. package/dist/variationConfiguration/types.js.map +1 -1
  45. package/dist/variationConfiguration/variationConfiguration.d.ts +11 -1
  46. package/dist/variationConfiguration/variationConfiguration.js +1 -1
  47. package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
  48. package/dist/visitorCodeManager/index.d.ts +1 -0
  49. package/dist/visitorCodeManager/index.js +2 -0
  50. package/dist/visitorCodeManager/index.js.map +1 -0
  51. package/dist/visitorCodeManager/visitorCodeManager.d.ts +14 -0
  52. package/dist/visitorCodeManager/visitorCodeManager.js +2 -0
  53. package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -0
  54. package/package.json +1 -1
  55. package/dist/cookieManager/cookieManager.d.ts +0 -16
  56. package/dist/cookieManager/cookieManager.js +0 -2
  57. package/dist/cookieManager/cookieManager.js.map +0 -1
  58. package/dist/cookieManager/index.d.ts +0 -1
  59. package/dist/cookieManager/index.js +0 -2
  60. package/dist/cookieManager/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"requester.js","names":["Requester","a","b","siteCode","environment","packageInfo","requestDispatcher","_classCallCheck","_defineProperty","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","timeStamp","c","d","e","f","wrap","g","prev","next","environmentParam","UrlFirstParameter","Environment","timeStampParam","UrlParameter","Ts","requestUrl","getClientConfigurationUrl","getClientConfiguration","response","sent","abrupt","Ok","Err","KameleoonError","KameleoonException","MaximumRetriesReached","t0","stop","URL","DATA_MAP","Key","encodeURI","getRemoteData","visitorCode","filters","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","VISIT_DATA","VisitorCode","MaxNumberPreviousVisits","variationId","experimentId","isUnallocated","body","userAgent","isTargetedRule","isConsentProvided","url","getTrackingUrl","unallocatedAddition","UrlEventType","Activity","Nonce","Utilities","getNonce","bodyAddition","Id","VariationId","extendedBody","headers","Header","UserAgent","track","requestBody","type","version","VISIT_EVENT","SdkName","toLowerCase","SdkVersion","exports"],"sources":["../../src/requester/requester.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { ConfigurationDataType, JSONType } from 'src/clientConfiguration';\nimport { Utilities, VisitorDataFiltersType } from 'src/utilities';\nimport {\n URL,\n UrlParameter,\n Header,\n UrlEventType,\n getClientConfigurationUrl,\n UrlFirstParameter,\n} from './constants';\nimport {\n RequesterParamsType,\n TrackDataParamsType,\n IExternalRequestDispatcher,\n GetVisitorDataResultType,\n TrackExperimentParamsType,\n} from './types';\n\nexport interface IRequester {\n getClientConfiguration: () => Promise<\n Result<ConfigurationDataType, KameleoonError>\n >;\n getRemoteData: (key: string) => Promise<Result<JSONType, KameleoonError>>;\n trackData: ({\n visitorCode,\n body,\n }: TrackDataParamsType) => Promise<Result<boolean, KameleoonError>>;\n trackExperiment: ({\n variationId,\n visitorCode,\n experimentId,\n isUnallocated,\n body,\n }: TrackExperimentParamsType) => Promise<Result<boolean, KameleoonError>>;\n}\n\nexport class Requester implements IRequester {\n private siteCode: string;\n private environment?: Environment;\n private requestDispatcher: IExternalRequestDispatcher;\n private packageInfo: ExternalPackageInfoType;\n\n constructor({\n siteCode,\n environment,\n packageInfo,\n requestDispatcher,\n }: RequesterParamsType) {\n this.requestDispatcher = requestDispatcher;\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n }\n\n public async getClientConfiguration(\n timeStamp?: number,\n ): Promise<Result<ConfigurationDataType, KameleoonError>> {\n const environmentParam = this.environment\n ? UrlFirstParameter.Environment + this.environment\n : '';\n let timeStampParam = '';\n\n if (timeStamp) {\n if (environmentParam) {\n timeStampParam = UrlParameter.Ts + timeStamp;\n } else {\n timeStampParam = UrlFirstParameter.Ts + timeStamp;\n }\n }\n\n const requestUrl =\n getClientConfigurationUrl(this.siteCode) +\n environmentParam +\n timeStampParam;\n\n try {\n const response = await this.requestDispatcher.getClientConfiguration(\n requestUrl,\n );\n\n if (response) {\n return Ok(response as ConfigurationDataType);\n }\n\n return Err(new KameleoonError(KameleoonException.MaximumRetriesReached));\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async getRemoteData(\n key: string,\n ): Promise<Result<JSONType, KameleoonError>> {\n const requestUrl: string =\n URL.DATA_MAP + this.siteCode + UrlParameter.Key + encodeURI(key);\n\n try {\n const response = await this.requestDispatcher.getRemoteData(requestUrl);\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async getVisitorData(\n visitorCode: string,\n filters: VisitorDataFiltersType,\n ): Promise<Result<GetVisitorDataResultType, KameleoonError>> {\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n } = filters;\n\n const customDataParameter = customData\n ? UrlParameter.CustomData + true\n : '';\n const conversionsParameter = conversions\n ? UrlParameter.Conversion + true\n : '';\n const geolocationParameter = geolocation\n ? UrlParameter.Geolocation + true\n : '';\n const experimentsParameter = experiments\n ? UrlParameter.Experiment + true\n : '';\n const pageViewsParameter = pageViews ? UrlParameter.Page + true : '';\n const staticDataParameter = Boolean(device || browser || operatingSystem)\n ? UrlParameter.StaticData + true\n : '';\n const currentVisitParameter = currentVisit\n ? UrlParameter.CurrentVisit + true\n : '';\n\n const requestUrl: string =\n URL.VISIT_DATA +\n this.siteCode +\n UrlParameter.VisitorCode +\n visitorCode +\n UrlParameter.MaxNumberPreviousVisits +\n previousVisitAmount +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter;\n\n try {\n const response = await this.requestDispatcher.getRemoteData(requestUrl);\n return Ok(response as GetVisitorDataResultType);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async trackExperiment({\n variationId,\n visitorCode,\n experimentId,\n isUnallocated,\n body,\n userAgent,\n isTargetedRule,\n isConsentProvided,\n }: TrackExperimentParamsType): Promise<Result<boolean, KameleoonError>> {\n const url = this.getTrackingUrl(visitorCode);\n\n const unallocatedAddition = !body\n ? UrlEventType.Activity + UrlParameter.Nonce + Utilities.getNonce()\n : '';\n const bodyAddition = isUnallocated\n ? unallocatedAddition\n : isConsentProvided || (!isConsentProvided && isTargetedRule)\n ? UrlEventType.Experiment +\n UrlParameter.Id +\n experimentId +\n UrlParameter.VariationId +\n variationId +\n UrlParameter.Nonce +\n Utilities.getNonce()\n : '';\n\n const extendedBody = bodyAddition ? body + '\\n' + bodyAddition : body;\n\n const headers = userAgent\n ? {\n [Header.UserAgent]: userAgent,\n }\n : undefined;\n\n try {\n const response = await this.requestDispatcher.track({\n url,\n headers,\n body: extendedBody,\n });\n\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async trackData({\n visitorCode,\n body,\n userAgent,\n }: TrackDataParamsType): Promise<Result<boolean, KameleoonError>> {\n const url = this.getTrackingUrl(visitorCode);\n\n const headers = userAgent\n ? {\n [Header.UserAgent]: userAgent,\n }\n : undefined;\n\n const requestBody =\n body || UrlEventType.Activity + UrlParameter.Nonce + Utilities.getNonce();\n\n try {\n const response = await this.requestDispatcher.track({\n url,\n headers,\n body: requestBody,\n });\n\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n private getTrackingUrl(visitorCode: string): string {\n const { type, version } = this.packageInfo;\n\n return (\n URL.VISIT_EVENT +\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CAAW,CACXpB,uBAAY,CAAC4F,OAAO,CACpBH,CAAI,CAACI,WAAW,EAAE,CAClB7F,uBAAY,CAAC8F,UAAU,CACvBJ,CAEJ,CAAC,IAAAvH,CAAA,IAAA4H,OAAA,CAAA7H,SAAA,CAAAA,SAAA"}
1
+ {"version":3,"file":"requester.js","names":["Requester","a","b","siteCode","environment","packageInfo","requestDispatcher","_classCallCheck","_defineProperty","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","timeStamp","c","d","e","f","g","h","wrap","i","prev","next","environmentParam","UrlFirstParameter","Environment","timeStampParam","UrlParameter","Ts","requestUrl","URL","CLIENT_CONFIGURATION","headers","Header","SdkType","type","toLowerCase","SdkVersion","version","getClientConfiguration","response","sent","abrupt","Ok","Err","KameleoonError","KameleoonException","MaximumRetriesReached","t0","stop","DATA_MAP","Key","encodeURI","getRemoteData","visitorCode","filters","j","k","l","m","n","o","p","q","r","s","t","u","v","w","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","VISIT_DATA","VisitorCode","MaxNumberPreviousVisits","dataUrl","variationDataUrl","userAgent","isUnallocated","url","getTrackingUrl","unallocatedAddition","UrlEventType","Activity","Nonce","Utilities","getNonce","bodyAddition","extendedBody","UserAgent","track","body","isMappingIdentifier","requestBody","versionWithCore","encodeURIComponent","concat","identifierParameter","MappingValue","VISIT_EVENT","SdkName","exports"],"sources":["../../src/requester/requester.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport { KameleoonError, KameleoonException } from 'src/kameleoonError';\nimport { ConfigurationDataType, JSONType } from 'src/clientConfiguration';\nimport { Utilities, VisitorDataFiltersType } from 'src/utilities';\nimport {\n URL,\n UrlParameter,\n Header,\n UrlEventType,\n UrlFirstParameter,\n} from './constants';\nimport {\n RequesterParamsType,\n TrackDataParamsType,\n IExternalRequestDispatcher,\n GetVisitorDataResultType,\n TrackExperimentParamsType,\n HeadersType,\n} from './types';\n\nexport interface IRequester {\n getClientConfiguration: () => Promise<\n Result<ConfigurationDataType, KameleoonError>\n >;\n getRemoteData: (key: string) => Promise<Result<JSONType, KameleoonError>>;\n trackData: ({\n visitorCode,\n body,\n userAgent,\n }: TrackDataParamsType) => Promise<Result<boolean, KameleoonError>>;\n trackExperiment: ({\n visitorCode,\n dataUrl,\n variationDataUrl,\n isUnallocated,\n isTargetedRule,\n userAgent,\n }: TrackExperimentParamsType) => Promise<Result<boolean, KameleoonError>>;\n}\n\nexport class Requester implements IRequester {\n private siteCode: string;\n private environment?: Environment;\n private requestDispatcher: IExternalRequestDispatcher;\n private packageInfo: ExternalPackageInfoType;\n\n constructor({\n siteCode,\n environment,\n packageInfo,\n requestDispatcher,\n }: RequesterParamsType) {\n this.requestDispatcher = requestDispatcher;\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n }\n\n public async getClientConfiguration(\n timeStamp?: number,\n ): Promise<Result<ConfigurationDataType, KameleoonError>> {\n const environmentParam = this.environment\n ? UrlFirstParameter.Environment + this.environment\n : '';\n let timeStampParam = '';\n\n if (timeStamp) {\n if (environmentParam) {\n timeStampParam = UrlParameter.Ts + timeStamp;\n } else {\n timeStampParam = UrlFirstParameter.Ts + timeStamp;\n }\n }\n\n const requestUrl =\n URL.CLIENT_CONFIGURATION +\n this.siteCode +\n environmentParam +\n timeStampParam;\n\n const headers: HeadersType = {\n [Header.SdkType]: this.packageInfo.type.toLowerCase(),\n [Header.SdkVersion]: this.packageInfo.version,\n };\n\n try {\n const response = await this.requestDispatcher.getClientConfiguration(\n requestUrl,\n headers,\n );\n\n if (response) {\n return Ok(response as ConfigurationDataType);\n }\n\n return Err(new KameleoonError(KameleoonException.MaximumRetriesReached));\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async getRemoteData(\n key: string,\n ): Promise<Result<JSONType, KameleoonError>> {\n const requestUrl: string =\n URL.DATA_MAP + this.siteCode + UrlParameter.Key + encodeURI(key);\n\n try {\n const response = await this.requestDispatcher.getRemoteData(requestUrl);\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async getVisitorData(\n visitorCode: string,\n filters: VisitorDataFiltersType,\n ): Promise<Result<GetVisitorDataResultType, KameleoonError>> {\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n } = filters;\n\n const customDataParameter = customData\n ? UrlParameter.CustomData + true\n : '';\n const conversionsParameter = conversions\n ? UrlParameter.Conversion + true\n : '';\n const geolocationParameter = geolocation\n ? UrlParameter.Geolocation + true\n : '';\n const experimentsParameter = experiments\n ? UrlParameter.Experiment + true\n : '';\n const pageViewsParameter = pageViews ? UrlParameter.Page + true : '';\n const staticDataParameter = Boolean(device || browser || operatingSystem)\n ? UrlParameter.StaticData + true\n : '';\n const currentVisitParameter = currentVisit\n ? UrlParameter.CurrentVisit + true\n : '';\n\n const requestUrl: string =\n URL.VISIT_DATA +\n this.siteCode +\n UrlParameter.VisitorCode +\n visitorCode +\n UrlParameter.MaxNumberPreviousVisits +\n previousVisitAmount +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter;\n\n try {\n const response = await this.requestDispatcher.getRemoteData(requestUrl);\n return Ok(response as GetVisitorDataResultType);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async trackExperiment({\n visitorCode,\n dataUrl,\n variationDataUrl,\n userAgent,\n isUnallocated,\n }: TrackExperimentParamsType): Promise<Result<boolean, KameleoonError>> {\n const url = this.getTrackingUrl(visitorCode);\n\n const unallocatedAddition = !dataUrl\n ? UrlEventType.Activity + UrlParameter.Nonce + Utilities.getNonce()\n : '';\n\n const bodyAddition = isUnallocated ? unallocatedAddition : variationDataUrl;\n\n const extendedBody = bodyAddition ? dataUrl + '\\n' + bodyAddition : dataUrl;\n\n const headers: HeadersType | undefined = userAgent\n ? {\n [Header.UserAgent]: userAgent,\n }\n : undefined;\n\n try {\n const response = await this.requestDispatcher.track({\n url,\n headers,\n body: extendedBody,\n });\n\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n public async trackData({\n visitorCode,\n body,\n userAgent,\n isMappingIdentifier,\n }: TrackDataParamsType): Promise<Result<boolean, KameleoonError>> {\n const url = this.getTrackingUrl(visitorCode, isMappingIdentifier);\n\n const requestBody =\n body || UrlEventType.Activity + UrlParameter.Nonce + Utilities.getNonce();\n\n const headers = userAgent\n ? {\n [Header.UserAgent]: userAgent,\n }\n : undefined;\n\n try {\n const response = await this.requestDispatcher.track({\n url,\n headers,\n body: requestBody,\n });\n\n return Ok(response);\n } catch (error) {\n return Err(error as KameleoonError);\n }\n }\n\n private getTrackingUrl(\n visitorCode: string,\n isMappingIdentifier?: boolean,\n ): string {\n const { type, version } = this.packageInfo;\n\n const versionWithCore = encodeURIComponent(\n `${version}/${process.env.npm_package_version}`,\n );\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return (\n URL.VISIT_EVENT +\n this.siteCode +\n identifierParameter +\n visitorCode +\n UrlParameter.SdkName +\n type.toLowerCase() +\n UrlParameter.SdkVersion +\n versionWithCore\n );\n }\n}\n"],"mappings":"+1QAyCa,CAAAA,SAAS,YAMpB,SAAAC,EAAAC,CAAA,CAKwB,IAJtB,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAW,CAAAF,CAAA,CAAXE,WAAW,CACXC,CAAW,CAAAH,CAAA,CAAXG,WAAW,CACXC,CAAiB,CAAAJ,CAAA,CAAjBI,iBAAiB,CAAAC,eAAA,MAAAN,CAAA,EAAAO,eAAA,yBAAAA,eAAA,4B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12
  export type TrackExperimentParamsType = {
13
- body: string;
14
- variationId: number;
13
+ dataUrl: string;
14
+ variationDataUrl: string;
15
15
  visitorCode: string;
16
- experimentId: number;
17
16
  isUnallocated: boolean;
18
- isConsentProvided: boolean;
19
17
  userAgent?: string;
20
18
  isTargetedRule?: boolean;
21
19
  };
@@ -23,6 +21,7 @@ export type TrackDataParamsType = {
23
21
  visitorCode: string;
24
22
  body: string;
25
23
  userAgent?: string;
24
+ isMappingIdentifier?: boolean;
26
25
  };
27
26
  type EventDataType = {
28
27
  sdk?: {
@@ -117,7 +116,7 @@ export declare enum HttpMethod {
117
116
  Post = "POST"
118
117
  }
119
118
  declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "geolocation", "activity", "experiment"];
120
- declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "country", "environment", "city", "region", "latitude", "geolocation", "longitude", "mappingIdentifier", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
119
+ declare const PARAMETER_KEYS: readonly ["valuesCountMap", "mappingValue", "id", "nonce", "country", "environment", "city", "region", "latitude", "geolocation", "longitude", "mappingIdentifier", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
121
120
  declare const TRACKING_KEYS: readonly ["visit", "map"];
122
121
  declare const QUERY_KEYS: readonly ["sse", "visitor", "map", "events"];
123
122
  export type TrackingType = Record<Capitalize<(typeof TRACKING_KEYS)[number]>, string>;
@@ -139,9 +138,13 @@ export type StrictParameterRecord<T> = {
139
138
  export type StrictFirstParameterRecord<T> = {
140
139
  [K in keyof T]: `?${Uncapitalize<K & string>}=`;
141
140
  };
141
+ /**
142
+ * @type HeadersType - a type of headers available in the request
143
+ * */
144
+ export type HeadersType = Partial<Record<Header, string>>;
142
145
  export type TrackParametersType = {
143
146
  url: string;
144
- headers?: Partial<Record<Header, string>>;
147
+ headers?: HeadersType;
145
148
  body: string;
146
149
  };
147
150
  /**
@@ -156,8 +159,9 @@ export interface IExternalRequestDispatcher {
156
159
  /**
157
160
  * @method getClientConfiguration - get client configuration
158
161
  * @param {string} url - url address
162
+ * @param {HeadersType} headers - headers
159
163
  * */
160
- getClientConfiguration: (url: string) => Promise<JSONType>;
164
+ getClientConfiguration: (url: string, headers: HeadersType) => Promise<JSONType>;
161
165
  /**
162
166
  * @method getRemoteData - get data from remote server of Kameleoon
163
167
  * @param {string} url - url address
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","country","environment","city","region","latitude","geolocation","longitude","mappingIdentifier","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","map","events"];
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","mappingValue","id","nonce","country","environment","city","region","latitude","geolocation","longitude","mappingIdentifier","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","map","events"];
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport { Header } from './constants';\nimport { DeviceType, OperatingSystemIndexMap } from 'src/kameleoonData/types';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n body: string;\n variationId: number;\n visitorCode: string;\n experimentId: number;\n isUnallocated: boolean;\n isConsentProvided: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'mappingIdentifier',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\nexport type TrackParametersType = {\n url: string;\n headers?: Partial<Record<Header, string>>;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * */\n getClientConfiguration: (url: string) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGAqIY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,mBAAmB,CACnB,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
1
+ {"version":3,"file":"types.js","names":["HttpMethod","Get","Post","exports","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport { Header } from './constants';\nimport { DeviceType, OperatingSystemIndexMap } from 'src/kameleoonData/types';\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n dataUrl: string;\n variationDataUrl: string;\n visitorCode: string;\n isUnallocated: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n isMappingIdentifier?: boolean;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'mappingValue',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'mappingIdentifier',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\n/**\n * @type HeadersType - a type of headers available in the request\n * */\nexport type HeadersType = Partial<Record<Header, string>>;\n\nexport type TrackParametersType = {\n url: string;\n headers?: HeadersType;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * @param {HeadersType} headers - headers\n * */\n getClientConfiguration: (\n url: string,\n headers: HeadersType,\n ) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"iGAoIY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAC,GAAA,OAAVD,CAAU,CAAAE,IAAA,QAAVF,CAAU,MAAAG,OAAA,CAAAH,UAAA,CAAAA,UAAA,IAKhB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,cAAc,CACd,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,mBAAmB,CACnB,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
@@ -8,7 +8,11 @@ export type ClientDataType = {
8
8
  lastUpdate: string;
9
9
  };
10
10
  export type FeatureFlagVariationsType = {
11
- [experimentId: string]: number;
11
+ [experimentId: string]: {
12
+ variationId: number;
13
+ isTargetedRule: boolean;
14
+ isSent: boolean;
15
+ };
12
16
  };
13
17
  export type VariationDataType = {
14
18
  [visitorCode: string]: FeatureFlagVariationsType;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/clientConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { KameleoonStorageKey } from './constants';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n data: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type FeatureFlagVariationsType = {\n [experimentId: string]: number;\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: FeatureFlagVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\nexport type ConsentDataType = {\n [visitorCode: string]: boolean;\n};\n\n/**\n * @type StorageDataType - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | ConsentDataType\n | string;\n\n/**\n * @interface an interface of External Constructor for Storage which must be implemented by the wrapper constructor to initialize new `IExternalStorage` in order to be able to pass necessary initialization parameters\n * */\nexport interface IExternalStorageConstructor {\n /**\n * @method initialize - creates and instance of `IExternalStorage<StorageDataType>` and returns it\n *\n * Generic needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * @param {KameleoonStorageKey} key - an enum variant containing keys for Kameleoon SDK related data stored on storage\n * @returns {IExternalStorage<StorageDataType>} an initialized instance of `IExternalStorage<StorageDataType>`\n * */\n initialize: <T extends StorageDataType>(\n key: KameleoonStorageKey,\n ) => IExternalStorage<T>;\n}\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage for initialized JS SDK Core.\n *\n * Generic `StorageDataType` needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * However it's not constrained strictly by `StorageDataType` to let implementer use storage as a generic for other types\n * */\nexport interface IExternalStorage<T> {\n /**\n * @property key - an Enum `KameleoonStorageKey` variant containing a key for Kameleoon SDK related data stored on storage\n * */\n readonly key: KameleoonStorageKey;\n /**\n * @method read - reads data from the storage\n * @returns {Result<T, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains `data` field with a type `T`, if not contains `error` field with a type of `KameleoonError`\n * */\n read: () => Result<T, KameleoonError>;\n /**\n * @method write - writes data to storage\n * @param {T} data - representation of any generic data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n write: (data: T) => Result<void, KameleoonError>;\n /**\n * @method update - adds new data to existing data in storage\n * @param {Partial<T>} data - representation of any generic partial data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n update: (data: Partial<T>) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/clientConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { KameleoonStorageKey } from './constants';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n data: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type FeatureFlagVariationsType = {\n [experimentId: string]: {\n variationId: number;\n isTargetedRule: boolean;\n isSent: boolean;\n };\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: FeatureFlagVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\nexport type ConsentDataType = {\n [visitorCode: string]: boolean;\n};\n\n/**\n * @type StorageDataType - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | ConsentDataType\n | string;\n\n/**\n * @interface an interface of External Constructor for Storage which must be implemented by the wrapper constructor to initialize new `IExternalStorage` in order to be able to pass necessary initialization parameters\n * */\nexport interface IExternalStorageConstructor {\n /**\n * @method initialize - creates and instance of `IExternalStorage<StorageDataType>` and returns it\n *\n * Generic needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * @param {KameleoonStorageKey} key - an enum variant containing keys for Kameleoon SDK related data stored on storage\n * @returns {IExternalStorage<StorageDataType>} an initialized instance of `IExternalStorage<StorageDataType>`\n * */\n initialize: <T extends StorageDataType>(\n key: KameleoonStorageKey,\n ) => IExternalStorage<T>;\n}\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage for initialized JS SDK Core.\n *\n * Generic `StorageDataType` needs to be specified with a type for TypeScript to be able to infer concrete type based on enum variant\n * However it's not constrained strictly by `StorageDataType` to let implementer use storage as a generic for other types\n * */\nexport interface IExternalStorage<T> {\n /**\n * @property key - an Enum `KameleoonStorageKey` variant containing a key for Kameleoon SDK related data stored on storage\n * */\n readonly key: KameleoonStorageKey;\n /**\n * @method read - reads data from the storage\n * @returns {Result<T, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains `data` field with a type `T`, if not contains `error` field with a type of `KameleoonError`\n * */\n read: () => Result<T, KameleoonError>;\n /**\n * @method write - writes data to storage\n * @param {T} data - representation of any generic data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n write: (data: T) => Result<void, KameleoonError>;\n /**\n * @method update - adds new data to existing data in storage\n * @param {Partial<T>} data - representation of any generic partial data type\n * @returns {Result<void, KameleoonError>} result with an `ok` boolean field indicated success or error. If result is ok contains an empty `data`, if not contains `error` field with a type of `KameleoonError`\n * */\n update: (data: Partial<T>) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetFeatureFlag=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var TargetFeatureFlag=function(){function a(b){var c=b.featureFlagId,d=b.variationKey,e=b.ruleId;_classCallCheck(this,a),_defineProperty(this,"featureId",void 0),_defineProperty(this,"ruleId",void 0),_defineProperty(this,"variationKey",void 0),this.featureId=c,this.ruleId=e,this.variationKey=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.variationData,c=a.ruleMap;if(!this.featureId||!c)return(0,_tsRes.Ok)(!1);if(this.featureId&&!this.ruleId&&!this.variationKey){var d,e=_createForOfIteratorHelper(c);try{for(e.s();!(d=e.n()).done;){var f=_slicedToArray(d.value,2),g=f[0],h=f[1],i=h.featureId,j=h.experimentId;if(i===this.featureId&&"number"==typeof b[j])return(0,_tsRes.Ok)(!0)}}catch(a){e.e(a)}finally{e.f()}return(0,_tsRes.Ok)(!1)}if(this.featureId&&this.ruleId){var k=c.get(this.ruleId);if(!k)return(0,_tsRes.Ok)(!1);var l=k.experimentId,m=k.variations;if(this.variationKey){var n=m.get(this.variationKey);return(0,_tsRes.Ok)(!!n&&b[l]===n)}return(0,_tsRes.Ok)(!!b[k.experimentId])}if(this.featureId&&!this.ruleId&&this.variationKey){var o,p=_createForOfIteratorHelper(c);try{for(p.s();!(o=p.n()).done;){var q=_slicedToArray(o.value,2),r=q[0],s=q[1],t=s.featureId,u=s.experimentId,v=s.variations;if(t===this.featureId&&v.has(this.variationKey)){var w=v.get(this.variationKey);return(0,_tsRes.Ok)(!!w&&b[u]===w)}}}catch(a){p.e(a)}finally{p.f()}}return(0,_tsRes.Ok)(!1)}}]),a}();exports.TargetFeatureFlag=TargetFeatureFlag;
1
+ "use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetFeatureFlag=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}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)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){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)}var TargetFeatureFlag=function(){function a(b){var c=b.featureFlagId,d=b.variationKey,e=b.ruleId;_classCallCheck(this,a),_defineProperty(this,"featureId",void 0),_defineProperty(this,"ruleId",void 0),_defineProperty(this,"variationKey",void 0),this.featureId=c,this.ruleId=e,this.variationKey=d}return _createClass(a,[{key:"evaluate",value:function evaluate(a){var b=a.variationData,c=a.ruleMap;if(!this.featureId||!c)return(0,_tsRes.Ok)(!1);if(this.featureId&&!this.ruleId&&!this.variationKey){var d,e=_createForOfIteratorHelper(c);try{for(e.s();!(d=e.n()).done;){var f,g=_slicedToArray(d.value,2),h=g[0],i=g[1],j=i.featureId,k=i.experimentId;if(j===this.featureId&&"number"==typeof(null===(f=b[k])||void 0===f?void 0:f.variationId))return(0,_tsRes.Ok)(!0)}}catch(a){e.e(a)}finally{e.f()}return(0,_tsRes.Ok)(!1)}if(this.featureId&&this.ruleId){var l,m=c.get(this.ruleId);if(!m)return(0,_tsRes.Ok)(!1);var n=m.experimentId,o=m.variations;if(this.variationKey){var p,q=o.get(this.variationKey);return(0,_tsRes.Ok)(!!q&&(null===(p=b[n])||void 0===p?void 0:p.variationId)===q)}return(0,_tsRes.Ok)(null!==(l=b[m.experimentId])&&void 0!==l&&l.variationId)}if(this.featureId&&!this.ruleId&&this.variationKey){var r,s=_createForOfIteratorHelper(c);try{for(s.s();!(r=s.n()).done;){var t=_slicedToArray(r.value,2),u=t[0],v=t[1],w=v.featureId,x=v.experimentId,y=v.variations;if(w===this.featureId&&y.has(this.variationKey)){var z,A=y.get(this.variationKey);return(0,_tsRes.Ok)(!!A&&(null===(z=b[x])||void 0===z?void 0:z.variationId)===A)}}}catch(a){s.e(a)}finally{s.f()}}return(0,_tsRes.Ok)(!1)}}]),a}();exports.TargetFeatureFlag=TargetFeatureFlag;
2
2
  //# sourceMappingURL=targetFeatureFlag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"targetFeatureFlag.js","names":["_tsRes","require","Object","defineProperty","exports","value","TargetFeatureFlag","_typeof","a","Symbol","iterator","constructor","prototype","_slicedToArray","b","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","c","d","e","f","g","h","i","j","call","next","done","push","length","return","Array","isArray","_createForOfIteratorHelper","s","n","_arrayLikeToArray","toString","slice","name","from","test","_classCallCheck","_defineProperties","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_defineProperty","_toPrimitive","toPrimitive","String","Number","featureFlagId","variationKey","ruleId","featureId","evaluate","variationData","ruleMap","Ok","_","rule","experimentId","get","variations","variationId","o","p","q","has"],"sources":["../../../src/targeting/conditions/targetFeatureFlag.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class TargetFeatureFlag implements ICondition {\n private featureId?: number | null;\n private ruleId?: number | null;\n private variationKey?: string | null;\n\n constructor({ featureFlagId, variationKey, ruleId }: ConditionDataType) {\n this.featureId = featureFlagId;\n this.ruleId = ruleId;\n this.variationKey = variationKey;\n }\n\n public evaluate({\n variationData,\n ruleMap,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (!this.featureId || !ruleMap) {\n return Ok(false);\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with any variation\n if (this.featureId && !this.ruleId && !this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId } = rule;\n\n if (\n featureId === this.featureId &&\n typeof variationData[experimentId] === 'number'\n ) {\n return Ok(true);\n }\n }\n\n return Ok(false);\n }\n\n // -- Visitor took part in certain experiment of the feature flag\n // with any/exact variation\n if (this.featureId && this.ruleId) {\n const rule = ruleMap.get(this.ruleId);\n\n if (!rule) {\n return Ok(false);\n }\n\n const { experimentId, variations } = rule;\n\n if (this.variationKey) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) && variationData[experimentId] === variationId,\n );\n }\n\n return Ok(Boolean(variationData[rule.experimentId]));\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with certain variation\n if (this.featureId && !this.ruleId && this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId, variations } = rule;\n\n if (featureId === this.featureId && variations.has(this.variationKey)) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) && variationData[experimentId] === variationId,\n );\n }\n }\n }\n\n return Ok(false);\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,WAAoCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,iBAAA,iBAAAC,QAAAC,CAAA,mCAAAD,OAAA,oBAAAE,MAAA,mBAAAA,MAAA,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BAAA,CAAAA,iBAAA"}
1
+ {"version":3,"file":"targetFeatureFlag.js","names":["_tsRes","require","Object","defineProperty","exports","value","TargetFeatureFlag","_typeof","a","Symbol","iterator","constructor","prototype","_slicedToArray","b","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","c","d","e","f","g","h","i","j","call","next","done","push","length","return","Array","isArray","_createForOfIteratorHelper","s","n","_arrayLikeToArray","toString","slice","name","from","test","_classCallCheck","_defineProperties","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_defineProperty","_toPrimitive","toPrimitive","String","Number","featureFlagId","variationKey","ruleId","featureId","evaluate","variationData","ruleMap","Ok","_","rule","experimentId","variationId","l","get","variations","p","r","t","has","z"],"sources":["../../../src/targeting/conditions/targetFeatureFlag.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class TargetFeatureFlag implements ICondition {\n private featureId?: number | null;\n private ruleId?: number | null;\n private variationKey?: string | null;\n\n constructor({ featureFlagId, variationKey, ruleId }: ConditionDataType) {\n this.featureId = featureFlagId;\n this.ruleId = ruleId;\n this.variationKey = variationKey;\n }\n\n public evaluate({\n variationData,\n ruleMap,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n if (!this.featureId || !ruleMap) {\n return Ok(false);\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with any variation\n if (this.featureId && !this.ruleId && !this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId } = rule;\n\n if (\n featureId === this.featureId &&\n typeof variationData[experimentId]?.variationId === 'number'\n ) {\n return Ok(true);\n }\n }\n\n return Ok(false);\n }\n\n // -- Visitor took part in certain experiment of the feature flag\n // with any/exact variation\n if (this.featureId && this.ruleId) {\n const rule = ruleMap.get(this.ruleId);\n\n if (!rule) {\n return Ok(false);\n }\n\n const { experimentId, variations } = rule;\n\n if (this.variationKey) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) &&\n variationData[experimentId]?.variationId === variationId,\n );\n }\n\n return Ok(Boolean(variationData[rule.experimentId]?.variationId));\n }\n\n // -- Visitor took part in any experiment of the feature flag\n // with certain variation\n if (this.featureId && !this.ruleId && this.variationKey) {\n for (const [_, rule] of ruleMap) {\n const { featureId, experimentId, variations } = rule;\n\n if (featureId === this.featureId && variations.has(this.variationKey)) {\n const variationId = variations.get(this.variationKey);\n\n return Ok(\n Boolean(variationId) &&\n variationData[experimentId]?.variationId === variationId,\n );\n }\n }\n }\n\n return Ok(false);\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,WAAoCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,iBAAA,iBAAAC,QAAAC,CAAA,mCAAAD,OAAA,oBAAAE,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAF,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAC,MAAA,EAAAD,CAAA,CAAAG,WAAA,GAAAF,MAAA,EAAAD,CAAA,GAAAC,MAAA,CAAAG,SAAA,iBAAAJ,CAAA,EAAAD,OAAA,CAAAC,CAAA,WAAAK,eAAAL,CAAA,CAAAM,CAAA,SAAAC,eAAA,CAAAP,CAAA,GAAAQ,qBAAA,CAAAR,CAAA,CAAAM,CAAA,GAAAG,2BAAA,CAAAT,CAAA,CAAAM,CAAA,GAAAI,gBAAA,YAAAA,iBAAA,YAAAC,SAAA,uJAAAH,sBAAAR,CAAA,CAAAM,CAAA,MAAAM,CAAA,OAAAZ,CAAA,0BAAAC,MAAA,EAAAD,CAAA,CAAAC,MAAA,CAAAC,QAAA,GAAAF,CAAA,wBAAAY,CAAA,MAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAC,CAAA,IAAAC,CAAA,IAAAC,CAAA,WAAAJ,CAA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,MAA/B,IAAA3B,CAAA,CAAAA,CAAA,KAAAqC,CAAA,CAAArC,CAAA,CAAAC,CAAA,IAAAR,IAAA,EAAiC,KAAA6C,CAAA,CAAA9D,cAAA,CAAA6D,CAAA,CAAArE,KAAA,IAArB6D,CAAC,CAAAS,CAAA,IAAER,CAAI,CAAAQ,CAAA,IACTd,CAAS,CAA+BM,CAAI,CAA5CN,SAAS,CAAEO,CAAY,CAAiBD,CAAI,CAAjCC,YAAY,CAAEI,CAAU,CAAKL,CAAI,CAAnBK,UAAU,CAE3C,GAAIX,CAAS,GAAK,IAAI,CAACA,SAAS,EAAIW,CAAU,CAACI,GAAG,CAAC,IAAI,CAACjB,YAAY,CAAC,CAAE,KAAAkB,CAAA,CAC/DR,CAAW,CAAGG,CAAU,CAACD,GAAG,CAAC,IAAI,CAACZ,YAAY,CAAC,CAErD,MAAO,GAAAM,SAAE,EACP,EAAQI,CAAW,EACjB,SAAAQ,CAAA,CAAAd,CAAa,CAACK,CAAY,CAAC,YAAAS,CAAA,QAA3BA,CAAA,CAA6BR,WAAW,IAAKA,CAAW,CAE9D,CACF,CAAC,OAAA7D,CAAA,EAAA6B,CAAA,CAAAf,CAAA,CAAAd,CAAA,UAAA6B,CAAA,CAAAd,CAAA,GACH,CAEA,MAAO,GAAA0C,SAAE,KACX,CAAC,IAAAzD,CAAA,IAAAJ,OAAA,CAAAE,iBAAA,CAAAA,iBAAA"}
package/dist/types.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage, ServerResponse } from 'http';
3
1
  import { ConfigurationDataType, JSONType } from './clientConfiguration/types';
4
2
  import { SdkLanguageType } from './constants';
5
3
  import { IExternalEventSourceConstructor } from './eventSource';
6
4
  import { IExternalStorageConstructor } from './storage';
7
5
  import { IExternalRequestDispatcher } from './requester';
8
6
  import { VisitorDataFiltersType } from './utilities';
9
- import { CookieManager } from './cookieManager';
7
+ import { VisitorCodeManager } from './visitorCodeManager';
10
8
  /**
11
9
  * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute
12
10
  * @defaultvalue 60
@@ -53,13 +51,13 @@ export type ExternalPackageInfoType = {
53
51
  * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name
54
52
  * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration
55
53
  * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data
56
- * @param {CookieManager} externalCookieManager - external cookie manager, used to get or generate visitor code
54
+ * @param {VisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code
57
55
  * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute
58
56
  * */
59
57
  export type InternalSDKConfigurationType = {
60
58
  externalStorage: IExternalStorageConstructor;
61
59
  externalEventSource: IExternalEventSourceConstructor;
62
- externalCookieManager: CookieManager;
60
+ externalVisitorCodeManager: VisitorCodeManager;
63
61
  externalPackageInfo: ExternalPackageInfoType;
64
62
  externalRequestDispatcher: IExternalRequestDispatcher;
65
63
  externalClientConfiguration?: ConfigurationDataType;
@@ -84,25 +82,33 @@ export declare enum VariableType {
84
82
  JSON = "JSON"
85
83
  }
86
84
  export type BooleanVariableType = {
85
+ key: string;
87
86
  type: VariableType.BOOLEAN;
88
87
  value: boolean;
89
88
  };
90
89
  export type NumberVariableType = {
90
+ key: string;
91
91
  type: VariableType.NUMBER;
92
92
  value: number;
93
93
  };
94
94
  export type StringVariableType = {
95
+ key: string;
95
96
  type: VariableType.STRING;
96
97
  value: string;
97
98
  };
98
99
  export type JSONVariableType = {
100
+ key: string;
99
101
  type: VariableType.JSON;
100
102
  value: JSONType;
101
103
  };
102
104
  /**
103
- * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
105
+ * @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.
104
106
  * */
105
107
  export type FeatureVariableResultType = BooleanVariableType | NumberVariableType | StringVariableType | JSONVariableType;
108
+ /**
109
+ * @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.
110
+ * */
111
+ export type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;
106
112
  /**
107
113
  * @readonly
108
114
  * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.
@@ -120,11 +126,13 @@ export declare enum Milliseconds {
120
126
  * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
121
127
  * @param {number} goalId - an id of a goal to track
122
128
  * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`
129
+ * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
123
130
  * */
124
131
  export type TrackConversionParamsType = {
125
132
  visitorCode: string;
126
133
  goalId: number;
127
134
  revenue?: number;
135
+ isUniqueIdentifier?: boolean;
128
136
  };
129
137
  /**
130
138
  * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
@@ -165,42 +173,12 @@ export type WarehouseAudienceType = {
165
173
  warehouseAudiences: Record<string, unknown>;
166
174
  };
167
175
  /**
168
- * @param {string} domain - domain which cookie belongs to
169
176
  * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
177
+ * @param {string | undefined} domain - domain which cookie belongs to
170
178
  * */
171
179
  export type GetResultCookieParametersType = {
172
- domain?: string;
173
- visitorCode?: string;
174
- };
175
- /**
176
- * @param {Request} request - request object to get the cookie from
177
- * @param {Response} response - response object to write the updated cookie to
178
- * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated
179
- * */
180
- export type ServerGetVisitorCodeParametersType = {
181
- request: IncomingMessage;
182
- response: ServerResponse;
183
- defaultVisitorCode?: string;
184
- };
185
- /**
186
- * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated
187
- * */
188
- export type ClientGetVisitorCodeParametersType = {
189
- defaultVisitorCode?: string;
190
- };
191
- /**
192
- * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
193
- * @param {ServerResponse} response - response object to write the updated cookie to
194
- * */
195
- export type ServerSetCookieParametersType = {
196
- visitorCode: string;
197
- response: ServerResponse;
198
- };
199
- /**
200
- * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
201
- * */
202
- export type ClientSetCookieParametersType = {
203
180
  visitorCode: string;
181
+ domain?: string;
204
182
  };
205
183
  export type TrackingCacheItemType = {
206
184
  [experimentId: number]: {
@@ -210,23 +188,23 @@ export type TrackingCacheItemType = {
210
188
  };
211
189
  /**
212
190
  * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
213
- * @param {ServerResponse} response - response object to write the updated cookie to
214
191
  * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the
215
192
  * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not
216
193
  * provided legal consent.
194
+ * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie
217
195
  * */
218
- export type ServerSetLegalConsentParametersType = {
196
+ export type SetUserConsentParametersType = {
219
197
  visitorCode: string;
220
198
  consent: boolean;
221
- response: ServerResponse;
199
+ setData: (visitorCode: string) => void;
222
200
  };
223
201
  /**
224
- * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
225
- * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the
226
- * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not
227
- * provided legal consent.
202
+ * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies
203
+ * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie
204
+ * @param {() => string} getData - a callback to get a visitor code from cookie
228
205
  * */
229
- export type ClientSetLegalConsentParametersType = {
230
- visitorCode: string;
231
- consent: boolean;
206
+ export type GetVisitorCodeParamtersType = {
207
+ defaultVisitorCode?: string;
208
+ setData: (visitorCode: string) => void;
209
+ getData: () => string;
232
210
  };
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["Environment","Production","Staging","Development","exports","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { IncomingMessage, ServerResponse } from 'http';\nimport { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSourceConstructor } from './eventSource';\nimport { IExternalStorageConstructor } from './storage';\nimport { IExternalRequestDispatcher } from './requester';\nimport { VisitorDataFiltersType } from './utilities';\nimport { CookieManager } from './cookieManager';\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 belongs to\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n domain?: 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 {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 * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {CookieManager} externalCookieManager - external cookie 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: IExternalStorageConstructor;\n externalEventSource: IExternalEventSourceConstructor;\n externalCookieManager: CookieManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\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 type: VariableType.BOOLEAN;\n value: boolean;\n};\nexport type NumberVariableType = { type: VariableType.NUMBER; value: number };\nexport type StringVariableType = { type: VariableType.STRING; value: string };\nexport type JSONVariableType = { type: VariableType.JSON; value: JSONType };\n\n/**\n * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.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 * @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 * */\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 FeatureFlagType = {\n id: number;\n key: string;\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\n/**\n * @param {string} domain - domain which cookie belongs to\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * */\nexport type GetResultCookieParametersType = {\n domain?: string;\n visitorCode?: string;\n};\n\n/**\n * @param {Request} request - request object to get the cookie from\n * @param {Response} response - response object to write the updated cookie to\n * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated\n * */\nexport type ServerGetVisitorCodeParametersType = {\n request: IncomingMessage;\n response: ServerResponse;\n defaultVisitorCode?: string;\n};\n\n/**\n * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated\n * */\nexport type ClientGetVisitorCodeParametersType = {\n defaultVisitorCode?: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {ServerResponse} response - response object to write the updated cookie to\n * */\nexport type ServerSetCookieParametersType = {\n visitorCode: string;\n response: ServerResponse;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * */\nexport type ClientSetCookieParametersType = {\n visitorCode: string;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {ServerResponse} response - response object to write the updated cookie to\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 * */\nexport type ServerSetLegalConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n response: ServerResponse;\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 * */\nexport type ClientSetLegalConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n};\n"],"mappings":"4IA0EY,CAAAA,WAAW,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAAAI,OAAA,CAAAJ,WAAA,CAAAA,WAAA,IAUX,CAAAK,YAAY,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAAAD,OAAA,CAAAC,YAAA,CAAAA,YAAA,IA6BZ,CAAAK,YAAY,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,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY,MAAAN,OAAA,CAAAM,YAAA,CAAAA,YAAA"}
1
+ {"version":3,"file":"types.js","names":["Environment","Production","Staging","Development","exports","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSourceConstructor } from './eventSource';\nimport { IExternalStorageConstructor } from './storage';\nimport { IExternalRequestDispatcher } from './requester';\nimport { VisitorDataFiltersType } from './utilities';\nimport { VisitorCodeManager } 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 belongs to\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n domain?: 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 {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 * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {VisitorCodeManager} 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: IExternalStorageConstructor;\n externalEventSource: IExternalEventSourceConstructor;\n externalVisitorCodeManager: VisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\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 * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\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\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string | undefined} domain - domain which cookie belongs to\n * */\nexport type GetResultCookieParametersType = {\n visitorCode: string;\n domain?: string;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\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: (visitorCode: string) => void;\n};\n\n/**\n * @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * @param {() => string} getData - a callback to get a visitor code from cookie\n * */\nexport type GetVisitorCodeParamtersType = {\n defaultVisitorCode?: string;\n setData: (visitorCode: string) => void;\n getData: () => string;\n};\n"],"mappings":"4IAyEY,CAAAA,WAAW,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAAAI,OAAA,CAAAJ,WAAA,CAAAA,WAAA,IAUX,CAAAK,YAAY,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAAAD,OAAA,CAAAC,YAAA,CAAAA,YAAA,IAkDZ,CAAAK,YAAY,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,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY,MAAAN,OAAA,CAAAM,YAAA,CAAAA,YAAA"}
@@ -53,6 +53,7 @@ export type TrackRuleParametersType = {
53
53
  userAgent?: string;
54
54
  isOfflineModeOn?: boolean;
55
55
  offlineTrackingStorage: IExternalStorage<OfflineTracking>;
56
+ variationConfiguration: VariationConfiguration;
56
57
  };
57
58
  export type ManageCacheParametersType = {
58
59
  cacheManager: CacheManager<TrackingCacheItemType>;
@@ -67,6 +68,7 @@ export type TrackDataParametersType = {
67
68
  isConsentProvided: boolean;
68
69
  isOfflineModeOn?: boolean;
69
70
  offlineTrackingStorage: IExternalStorage<OfflineTracking>;
71
+ isMappingIdentifier?: boolean;
70
72
  };
71
73
  export type TrackExperimentParametersType = {
72
74
  clientConfiguration: ClientConfiguration;
@@ -97,6 +99,11 @@ export type GetDataUrlParametersType = {
97
99
  dataManager: DataManager;
98
100
  isConsentProvided: boolean;
99
101
  };
102
+ export type GetVariationDataUrlParametersType = {
103
+ visitorCode: string;
104
+ isConsentProvided: boolean;
105
+ variationConfiguration: VariationConfiguration;
106
+ };
100
107
  /**
101
108
  * @param {number} previousVisitAmount - Number of previous visits to retrieve data from. Number between `1` and `25`
102
109
  * *Default*: `1`.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["TimeUnit","Minute","Hour","Day","Week","Month","exports","Order","Ascending","Descending"],"sources":["../../src/utilities/types.ts"],"sourcesContent":["import { CacheManager } from 'src/cacheManager';\nimport { ClientConfiguration } from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport {\n KameleoonDataType,\n KameleoonVisitorDataType,\n} from 'src/kameleoonData/types';\nimport { Requester } from 'src/requester';\nimport {\n GetVisitorDataResultType,\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\nimport { IExternalStorage, OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { ExternalPackageInfoType, TrackingCacheItemType } from 'src/types';\nimport {\n VariationConfiguration,\n FeatureFlagVariationType,\n} from 'src/variationConfiguration';\n\nexport type CheckTargetingParametersType = {\n segment: SegmentType | null;\n experimentId: number | null;\n visitorCode: string;\n packageInfo: ExternalPackageInfoType;\n targetingData: KameleoonVisitorDataType;\n clientConfiguration: ClientConfiguration;\n variationConfiguration?: VariationConfiguration;\n dataManager: DataManager;\n};\n\nexport enum TimeUnit {\n Minute = 'MINUTE',\n Hour = 'HOUR',\n Day = 'DAY',\n Week = 'WEEK',\n Month = 'MONTH',\n}\n\nexport enum Order {\n Ascending = 'asc',\n Descending = 'desc',\n}\n\nexport type InsertInOrderedListParametersType = {\n list: number[];\n element: number;\n order: Order;\n};\n\nexport type ParseVisitorDataParametersType = {\n data: GetVisitorDataResultType;\n filters: VisitorDataFiltersType;\n visitorCode: string;\n variationConfiguration: VariationConfiguration;\n};\n\nexport type ParseVisitorDataResultType = {\n visitorData: KameleoonDataType[];\n visitsData?: KameleoonDataType;\n};\n\nexport type TrackRuleParametersType = {\n featureFlagVariation: FeatureFlagVariationType;\n dataManager: DataManager;\n visitorCode: string;\n requester: Requester;\n isConsentProvided: boolean;\n userAgent?: string;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n};\n\nexport type ManageCacheParametersType = {\n cacheManager: CacheManager<TrackingCacheItemType>;\n visitorCode: string;\n experimentId: number;\n variationId: number;\n};\n\nexport type TrackDataParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n requester: Requester;\n isConsentProvided: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n};\n\nexport type TrackExperimentParametersType = {\n clientConfiguration: ClientConfiguration;\n visitorCode: string;\n requester: Requester;\n variationId: number;\n experimentId: number;\n isUnallocated: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n};\n\nexport type AddToOfflineTrackingParametersType = {\n item: TrackExperimentParamsType | TrackDataParamsType;\n isExperiment: boolean;\n storage: IExternalStorage<OfflineTracking>;\n onSuccess?: () => void;\n};\n\nexport type SendOfflineTrackingParametersType = {\n storage: IExternalStorage<OfflineTracking>;\n requester: Requester;\n};\n\nexport type DeleteFromOfflineTrackingParametersType = {\n timestamps: number[];\n storage: IExternalStorage<OfflineTracking>;\n};\n\nexport type GetDataUrlParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n isConsentProvided: boolean;\n};\n\n/**\n * @param {number} previousVisitAmount - Number of previous visits to retrieve data from. Number between `1` and `25`\n * *Default*: `1`.\n * @param {number} currentVisit - If true, current visit data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} customData - If true, custom data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} pageViews - If true, page data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} geolocation - If true, geolocation data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} device - If true, device data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} browser - If true, browser data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} operatingSystem - If true, operating system data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} conversions - If true, conversion data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} experiments - If true, experiment data will be retrieved.\n * *Default*: `false`.\n * */\nexport type VisitorDataFiltersType = {\n previousVisitAmount?: number;\n currentVisit?: boolean;\n pageViews?: boolean;\n geolocation?: boolean;\n device?: boolean;\n browser?: boolean;\n operatingSystem?: boolean;\n customData?: boolean;\n conversions?: boolean;\n experiments?: boolean;\n};\n"],"mappings":"6GAgCY,CAAAA,QAAQ,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,MAAA,UAARD,CAAQ,CAAAE,IAAA,QAARF,CAAQ,CAAAG,GAAA,OAARH,CAAQ,CAAAI,IAAA,QAARJ,CAAQ,CAAAK,KAAA,SAARL,CAAQ,MAAAM,OAAA,CAAAN,QAAA,CAAAA,QAAA,IAQR,CAAAO,KAAK,UAALA,CAAK,QAAL,CAAAA,CAAK,CAAAC,SAAA,OAALD,CAAK,CAAAE,UAAA,QAALF,CAAK,MAAAD,OAAA,CAAAC,KAAA,CAAAA,KAAA"}
1
+ {"version":3,"file":"types.js","names":["TimeUnit","Minute","Hour","Day","Week","Month","exports","Order","Ascending","Descending"],"sources":["../../src/utilities/types.ts"],"sourcesContent":["import { CacheManager } from 'src/cacheManager';\nimport { ClientConfiguration } from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport {\n KameleoonDataType,\n KameleoonVisitorDataType,\n} from 'src/kameleoonData/types';\nimport { Requester } from 'src/requester';\nimport {\n GetVisitorDataResultType,\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\nimport { IExternalStorage, OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { ExternalPackageInfoType, TrackingCacheItemType } from 'src/types';\nimport {\n VariationConfiguration,\n FeatureFlagVariationType,\n} from 'src/variationConfiguration';\n\nexport type CheckTargetingParametersType = {\n segment: SegmentType | null;\n experimentId: number | null;\n visitorCode: string;\n packageInfo: ExternalPackageInfoType;\n targetingData: KameleoonVisitorDataType;\n clientConfiguration: ClientConfiguration;\n variationConfiguration?: VariationConfiguration;\n dataManager: DataManager;\n};\n\nexport enum TimeUnit {\n Minute = 'MINUTE',\n Hour = 'HOUR',\n Day = 'DAY',\n Week = 'WEEK',\n Month = 'MONTH',\n}\n\nexport enum Order {\n Ascending = 'asc',\n Descending = 'desc',\n}\n\nexport type InsertInOrderedListParametersType = {\n list: number[];\n element: number;\n order: Order;\n};\n\nexport type ParseVisitorDataParametersType = {\n data: GetVisitorDataResultType;\n filters: VisitorDataFiltersType;\n visitorCode: string;\n variationConfiguration: VariationConfiguration;\n};\n\nexport type ParseVisitorDataResultType = {\n visitorData: KameleoonDataType[];\n visitsData?: KameleoonDataType;\n};\n\nexport type TrackRuleParametersType = {\n featureFlagVariation: FeatureFlagVariationType;\n dataManager: DataManager;\n visitorCode: string;\n requester: Requester;\n isConsentProvided: boolean;\n userAgent?: string;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n variationConfiguration: VariationConfiguration;\n};\n\nexport type ManageCacheParametersType = {\n cacheManager: CacheManager<TrackingCacheItemType>;\n visitorCode: string;\n experimentId: number;\n variationId: number;\n};\n\nexport type TrackDataParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n requester: Requester;\n isConsentProvided: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n isMappingIdentifier?: boolean;\n};\n\nexport type TrackExperimentParametersType = {\n clientConfiguration: ClientConfiguration;\n visitorCode: string;\n requester: Requester;\n variationId: number;\n experimentId: number;\n isUnallocated: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n};\n\nexport type AddToOfflineTrackingParametersType = {\n item: TrackExperimentParamsType | TrackDataParamsType;\n isExperiment: boolean;\n storage: IExternalStorage<OfflineTracking>;\n onSuccess?: () => void;\n};\n\nexport type SendOfflineTrackingParametersType = {\n storage: IExternalStorage<OfflineTracking>;\n requester: Requester;\n};\n\nexport type DeleteFromOfflineTrackingParametersType = {\n timestamps: number[];\n storage: IExternalStorage<OfflineTracking>;\n};\n\nexport type GetDataUrlParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n isConsentProvided: boolean;\n};\n\nexport type GetVariationDataUrlParametersType = {\n visitorCode: string;\n isConsentProvided: boolean;\n variationConfiguration: VariationConfiguration;\n};\n\n/**\n * @param {number} previousVisitAmount - Number of previous visits to retrieve data from. Number between `1` and `25`\n * *Default*: `1`.\n * @param {number} currentVisit - If true, current visit data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} customData - If true, custom data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} pageViews - If true, page data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} geolocation - If true, geolocation data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} device - If true, device data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} browser - If true, browser data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} operatingSystem - If true, operating system data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} conversions - If true, conversion data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} experiments - If true, experiment data will be retrieved.\n * *Default*: `false`.\n * */\nexport type VisitorDataFiltersType = {\n previousVisitAmount?: number;\n currentVisit?: boolean;\n pageViews?: boolean;\n geolocation?: boolean;\n device?: boolean;\n browser?: boolean;\n operatingSystem?: boolean;\n customData?: boolean;\n conversions?: boolean;\n experiments?: boolean;\n};\n"],"mappings":"6GAgCY,CAAAA,QAAQ,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,MAAA,UAARD,CAAQ,CAAAE,IAAA,QAARF,CAAQ,CAAAG,GAAA,OAARH,CAAQ,CAAAI,IAAA,QAARJ,CAAQ,CAAAK,KAAA,SAARL,CAAQ,MAAAM,OAAA,CAAAN,QAAA,CAAAA,QAAA,IAQR,CAAAO,KAAK,UAALA,CAAK,QAAL,CAAAA,CAAK,CAAAC,SAAA,OAALD,CAAK,CAAAE,UAAA,QAALF,CAAK,MAAAD,OAAA,CAAAC,KAAA,CAAAA,KAAA"}