@kameleoon/javascript-sdk-core 4.4.6 → 4.4.8

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.
@@ -1,20 +1,28 @@
1
1
  import { GetVisitorDataUrlParamsType, UrlProviderInitializeParamsType } from './types';
2
- export declare class UrlProvider {
3
- private static ready;
4
- private static siteCode;
5
- private static isCustomDomain;
6
- private static environment;
7
- private static packageInfo;
8
- private static domains;
9
- static dataApiTopLevelDomain?: string;
10
- static initialize({ siteCode, domain, packageInfo, environment, }: UrlProviderInitializeParamsType): void;
11
- static setDataApiDomain(domain: string): void;
12
- static getClientConfigurationUrl(timeStamp?: number): string;
13
- static getEventSourceUrl(): string;
14
- static getRemoteDataUrl(key: string): string;
15
- static getVisitorDataUrl({ visitorCode, filters, isMappingIdentifier, }: GetVisitorDataUrlParamsType): string;
16
- static getTrackingUrl(visitorCode: string, isMappingIdentifier?: boolean): string;
17
- private static isInitialized;
18
- private static getDataApiUrl;
19
- private static setDomains;
2
+ export interface IUrlProvider {
3
+ initialize(params: UrlProviderInitializeParamsType): void;
4
+ getClientConfigurationUrl(timeStamp?: number): string;
5
+ getEventSourceUrl(): string;
6
+ getRemoteDataUrl(key: string): string;
7
+ getVisitorDataUrl(params: GetVisitorDataUrlParamsType): string;
8
+ getTrackingUrl(visitorCode: string, isMappingIdentifier?: boolean): string;
9
+ dataApiDomain: string;
10
+ }
11
+ export declare class UrlProvider implements IUrlProvider {
12
+ private ready;
13
+ private isCustomDomain;
14
+ private domains;
15
+ private siteCode?;
16
+ private environment?;
17
+ private packageInfo?;
18
+ initialize({ domain, siteCode, packageInfo, environment, }: UrlProviderInitializeParamsType): void;
19
+ set dataApiDomain(domain: string);
20
+ getClientConfigurationUrl(timeStamp?: number): string;
21
+ getEventSourceUrl(): string;
22
+ getRemoteDataUrl(key: string): string;
23
+ getVisitorDataUrl({ visitorCode, filters, isMappingIdentifier, }: GetVisitorDataUrlParamsType): string;
24
+ getTrackingUrl(visitorCode: string, isMappingIdentifier?: boolean): string;
25
+ private isInitialized;
26
+ private getDataApiUrl;
27
+ private setDomains;
20
28
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlProvider=void 0;var _types=require("../types"),_constants=require("./constants"),_types2=require("./types");function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class UrlProvider{static initialize(a){let{siteCode:b,domain:c,packageInfo:d,environment:e}=a;this.siteCode=b,this.environment=e,this.packageInfo=d,this.ready=!0,this.setDomains(c)}static setDataApiDomain(a){var b;if(!this.isCustomDomain){const c=a.split(".");if(3===c.length){const[a,d,e]=c;this.domains[_types2.UrlType.DataApi]={subdomain:a,secondLevelDomain:d,topLevelDomain:null!==(b=this.dataApiTopLevelDomain)&&void 0!==b?b:e}}}}static getClientConfigurationUrl(a){this.isInitialized();const{subdomain:b,topLevelDomain:c,secondLevelDomain:d}=this.domains[_types2.UrlType.ClientConfiguration],e="https://".concat(b,".").concat(d,".").concat(c,"/"),f=this.environment===_types.Environment.Production?"":_constants.UrlFirstParameter.Environment+this.environment;let g="";return a&&(f?g=_constants.UrlParameter.Ts+a:g=_constants.UrlFirstParameter.Ts+a),e+this.siteCode+f+g}static getEventSourceUrl(){this.isInitialized();const{subdomain:a,topLevelDomain:b,secondLevelDomain:c}=this.domains[_types2.UrlType.Events];return"https://".concat(a,".").concat(c,".").concat(b,":8110/").concat(_constants.UrlQuery.Sse).concat(this.siteCode)}static getRemoteDataUrl(a){return this.isInitialized(),this.getDataApiUrl(_types2.DataApiQuery.DataMap)+this.siteCode+_constants.UrlParameter.Key+encodeURI(a)}static getVisitorDataUrl(a){let{visitorCode:b,filters:c,isMappingIdentifier:d}=a;this.isInitialized();const{customData:e,previousVisitAmount:f,currentVisit:g,conversions:h,geolocation:i,experiments:j,pageViews:k,device:l,browser:m,operatingSystem:n,kcs:o}=c,p=d?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode,q=e?_constants.UrlParameter.CustomData+!0:"",r=h?_constants.UrlParameter.Conversion+!0:"",s=i?_constants.UrlParameter.Geolocation+!0:"",t=j?_constants.UrlParameter.Experiment+!0:"",u=k?_constants.UrlParameter.Page+!0:"",v=!!(l||m||n)?_constants.UrlParameter.StaticData+!0:"",w=g?_constants.UrlParameter.CurrentVisit+!0:"",x=o?_constants.UrlParameter.Kcs+!0:"",y="number"==typeof f?_constants.UrlParameter.MaxNumberPreviousVisits+f:_constants.UrlParameter.MaxNumberPreviousVisits+1;return this.getDataApiUrl(_types2.DataApiQuery.VisitData)+this.siteCode+p+b+y+q+r+s+t+u+v+w+x}static getTrackingUrl(a,b){this.isInitialized();const{type:c,version:d}=this.packageInfo,e=b?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode;return this.getDataApiUrl(_types2.DataApiQuery.VisitEvent)+this.siteCode+e+a+_constants.UrlParameter.SdkName+c.toLowerCase()+_constants.UrlParameter.SdkVersion+d}static isInitialized(){if(!this.ready)throw new Error("UrlProvider is not initialized")}static getDataApiUrl(a){const{subdomain:b,topLevelDomain:c,secondLevelDomain:d}=this.domains[_types2.UrlType.DataApi];if(!b||!c||!d)throw new Error("Data API domain is not set");const e="https://".concat(b,".").concat(d,".").concat(c);return a===_types2.DataApiQuery.VisitEvent?"".concat(e,"/").concat(_constants.UrlTracking.Visit+_constants.UrlQuery.Events):a===_types2.DataApiQuery.VisitData?"".concat(e,"/").concat(_constants.UrlTracking.Visit+_constants.UrlQuery.Visitor):a===_types2.DataApiQuery.DataMap?"".concat(e,"/").concat(_constants.UrlTracking.Map+_constants.UrlQuery.Map):void 0}static setDomains(a){if(!a)return;this.isCustomDomain=!0;const b=a.split("."),[c,d]=b,e={secondLevelDomain:c,topLevelDomain:d};this.domains={[_types2.UrlType.DataApi]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.DataApi]),e),[_types2.UrlType.Events]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.Events]),e),[_types2.UrlType.ClientConfiguration]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.ClientConfiguration]),e)}}}exports.UrlProvider=UrlProvider,_defineProperty(UrlProvider,"ready",!1),_defineProperty(UrlProvider,"siteCode",void 0),_defineProperty(UrlProvider,"isCustomDomain",!1),_defineProperty(UrlProvider,"environment",void 0),_defineProperty(UrlProvider,"packageInfo",void 0),_defineProperty(UrlProvider,"domains",{[_types2.UrlType.DataApi]:{subdomain:"data",topLevelDomain:"io",secondLevelDomain:"kameleoon"},[_types2.UrlType.Events]:{subdomain:"events",topLevelDomain:"com",secondLevelDomain:"kameleoon"},[_types2.UrlType.ClientConfiguration]:{subdomain:"sdk-config",topLevelDomain:"eu",secondLevelDomain:"kameleoon"}}),_defineProperty(UrlProvider,"dataApiTopLevelDomain",void 0);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlProvider=void 0;var _types=require("../types"),_constants=require("./constants"),_types2=require("./types");function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class UrlProvider{constructor(){_defineProperty(this,"ready",!1),_defineProperty(this,"isCustomDomain",!1),_defineProperty(this,"domains",_constants.DEFAULT_DOMAINS),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"packageInfo",void 0)}initialize(a){let{domain:b,siteCode:c,packageInfo:d,environment:e}=a;this.siteCode=c,this.environment=e,this.packageInfo=d,this.ready=!0,this.setDomains(b)}set dataApiDomain(a){if(!this.isCustomDomain){const b=a.split(".");if(3===b.length){const[a,c,d]=b;this.domains[_types2.UrlType.DataApi]={subdomain:a,secondLevelDomain:c,topLevelDomain:d}}}}getClientConfigurationUrl(a){this.isInitialized();const{subdomain:b,topLevelDomain:c,secondLevelDomain:d}=this.domains[_types2.UrlType.ClientConfiguration],e="https://".concat(b,".").concat(d,".").concat(c,"/"),f=this.environment===_types.Environment.Production?"":_constants.UrlFirstParameter.Environment+this.environment;let g="";return a&&(f?g=_constants.UrlParameter.Ts+a:g=_constants.UrlFirstParameter.Ts+a),e+this.siteCode+f+g}getEventSourceUrl(){this.isInitialized();const{subdomain:a,topLevelDomain:b,secondLevelDomain:c}=this.domains[_types2.UrlType.Events];return"https://".concat(a,".").concat(c,".").concat(b,":8110/").concat(_constants.UrlQuery.Sse).concat(this.siteCode)}getRemoteDataUrl(a){return this.isInitialized(),this.getDataApiUrl(_types2.DataApiQuery.DataMap)+this.siteCode+_constants.UrlParameter.Key+encodeURI(a)}getVisitorDataUrl(a){let{visitorCode:b,filters:c,isMappingIdentifier:d}=a;this.isInitialized();const{customData:e,previousVisitAmount:f,currentVisit:g,conversions:h,geolocation:i,experiments:j,pageViews:k,device:l,browser:m,operatingSystem:n,kcs:o}=c,p=d?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode,q=e?_constants.UrlParameter.CustomData+!0:"",r=h?_constants.UrlParameter.Conversion+!0:"",s=i?_constants.UrlParameter.Geolocation+!0:"",t=j?_constants.UrlParameter.Experiment+!0:"",u=k?_constants.UrlParameter.Page+!0:"",v=!!(l||m||n)?_constants.UrlParameter.StaticData+!0:"",w=g?_constants.UrlParameter.CurrentVisit+!0:"",x=o?_constants.UrlParameter.Kcs+!0:"",y="number"==typeof f?_constants.UrlParameter.MaxNumberPreviousVisits+f:_constants.UrlParameter.MaxNumberPreviousVisits+1;return this.getDataApiUrl(_types2.DataApiQuery.VisitData)+this.siteCode+p+b+y+q+r+s+t+u+v+w+x}getTrackingUrl(a,b){this.isInitialized();const{type:c,version:d}=this.packageInfo,e=b?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode;return this.getDataApiUrl(_types2.DataApiQuery.VisitEvent)+this.siteCode+e+a+_constants.UrlParameter.SdkName+c.toLowerCase()+_constants.UrlParameter.SdkVersion+d}isInitialized(){if(!this.ready)throw new Error("UrlProvider is not initialized")}getDataApiUrl(a){const{subdomain:b,topLevelDomain:c,secondLevelDomain:d}=this.domains[_types2.UrlType.DataApi];if(!b||!c||!d)throw new Error("Data API domain is not set");const e="https://".concat(b,".").concat(d,".").concat(c);return a===_types2.DataApiQuery.VisitEvent?"".concat(e,"/").concat(_constants.UrlTracking.Visit+_constants.UrlQuery.Events):a===_types2.DataApiQuery.VisitData?"".concat(e,"/").concat(_constants.UrlTracking.Visit+_constants.UrlQuery.Visitor):a===_types2.DataApiQuery.DataMap?"".concat(e,"/").concat(_constants.UrlTracking.Map+_constants.UrlQuery.Map):void 0}setDomains(a){if(!a)return;this.isCustomDomain=!0;const b=a.split("."),[c,d]=b,e={secondLevelDomain:c,topLevelDomain:d};this.domains={[_types2.UrlType.DataApi]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.DataApi]),e),[_types2.UrlType.Events]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.Events]),e),[_types2.UrlType.ClientConfiguration]:_objectSpread(_objectSpread({},this.domains[_types2.UrlType.ClientConfiguration]),e)}}}exports.UrlProvider=UrlProvider;
2
2
  //# sourceMappingURL=urlProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"urlProvider.js","names":["UrlProvider","initialize","a","siteCode","domain","packageInfo","environment","ready","setDomains","setDataApiDomain","b","isCustomDomain","parts","split","length","subdomain","secondLevelDomain","topLevelDomain","domains","UrlType","DataApi","dataApiTopLevelDomain","getClientConfigurationUrl","timeStamp","isInitialized","ClientConfiguration","baseUrl","concat","environmentParam","Environment","Production","UrlFirstParameter","timeStampParam","UrlParameter","Ts","getEventSourceUrl","Events","UrlQuery","Sse","getRemoteDataUrl","key","getDataApiUrl","DataApiQuery","DataMap","Key","encodeURI","getVisitorDataUrl","visitorCode","filters","isMappingIdentifier","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","kcs","identifierParameter","MappingValue","VisitorCode","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","kcsParameter","Kcs","previousVisitAmountParam","MaxNumberPreviousVisits","VisitData","getTrackingUrl","type","version","VisitEvent","SdkName","toLowerCase","SdkVersion","Error","query","UrlTracking","Visit","Visitor","Map","domainData","_objectSpread","exports","_defineProperty"],"sources":["../../src/requester/urlProvider.ts"],"sourcesContent":["import { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n UrlFirstParameter,\n UrlParameter,\n UrlTracking,\n UrlQuery,\n} from './constants';\nimport {\n DataApiQuery,\n DomainsType,\n GetVisitorDataUrlParamsType,\n UrlProviderInitializeParamsType,\n UrlType,\n} from './types';\n\n// TODO: To be removed in favour of `DependencyManager`\n// which will use protected `KameleoonClient` method to be able to mock every dependency\n// for tests\nexport class UrlProvider {\n private static ready = false;\n private static siteCode: string;\n private static isCustomDomain = false;\n private static environment: Environment;\n private static packageInfo: ExternalPackageInfoType;\n private static domains: DomainsType = {\n [UrlType.DataApi]: {\n subdomain: 'data',\n topLevelDomain: 'io',\n secondLevelDomain: 'kameleoon',\n },\n [UrlType.Events]: {\n subdomain: 'events',\n topLevelDomain: 'com',\n secondLevelDomain: 'kameleoon',\n },\n [UrlType.ClientConfiguration]: {\n subdomain: 'sdk-config',\n topLevelDomain: 'eu',\n secondLevelDomain: 'kameleoon',\n },\n };\n\n // --- Note ---\n // Dirty workaround before the `DependencyManager` implementation\n // see a note above\n public static dataApiTopLevelDomain?: string;\n\n public static initialize({\n siteCode,\n domain,\n packageInfo,\n environment,\n }: UrlProviderInitializeParamsType) {\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n this.ready = true;\n\n this.setDomains(domain);\n }\n\n public static setDataApiDomain(domain: string): void {\n if (this.isCustomDomain) {\n return;\n }\n\n const parts = domain.split('.');\n\n if (parts.length !== 3) {\n return;\n }\n\n const [subdomain, secondLevelDomain, topLevelDomain] = parts;\n\n this.domains[UrlType.DataApi] = {\n subdomain,\n secondLevelDomain,\n topLevelDomain: this.dataApiTopLevelDomain ?? topLevelDomain,\n };\n }\n\n public static getClientConfigurationUrl(timeStamp?: number): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.ClientConfiguration];\n\n const baseUrl = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}/`;\n const environmentParam =\n this.environment === Environment.Production\n ? ''\n : UrlFirstParameter.Environment + this.environment;\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 return baseUrl + this.siteCode + environmentParam + timeStampParam;\n }\n\n public static getEventSourceUrl(): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.Events];\n\n return `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}:8110/${UrlQuery.Sse}${this.siteCode}`;\n }\n\n public static getRemoteDataUrl(key: string): string {\n this.isInitialized();\n\n return (\n this.getDataApiUrl(DataApiQuery.DataMap) +\n this.siteCode +\n UrlParameter.Key +\n encodeURI(key)\n );\n }\n\n public static getVisitorDataUrl({\n visitorCode,\n filters,\n isMappingIdentifier,\n }: GetVisitorDataUrlParamsType): string {\n this.isInitialized();\n\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n kcs,\n } = filters;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\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 const kcsParameter = kcs ? UrlParameter.Kcs + true : '';\n const previousVisitAmountParam =\n typeof previousVisitAmount !== 'number'\n ? UrlParameter.MaxNumberPreviousVisits + 1\n : UrlParameter.MaxNumberPreviousVisits + previousVisitAmount;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitData) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n previousVisitAmountParam +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter +\n kcsParameter\n );\n }\n\n public static getTrackingUrl(\n visitorCode: string,\n isMappingIdentifier?: boolean,\n ): string {\n this.isInitialized();\n\n const { type, version } = this.packageInfo;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitEvent) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n UrlParameter.SdkName +\n type.toLowerCase() +\n UrlParameter.SdkVersion +\n version\n );\n }\n\n private static isInitialized(): void {\n if (!this.ready) {\n throw new Error('UrlProvider is not initialized');\n }\n }\n\n private static getDataApiUrl(query: DataApiQuery): string {\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.DataApi];\n\n if (!subdomain || !topLevelDomain || !secondLevelDomain) {\n throw new Error('Data API domain is not set');\n }\n\n const domain = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}`;\n\n switch (query) {\n case DataApiQuery.VisitEvent:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Events}`;\n case DataApiQuery.VisitData:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Visitor}`;\n case DataApiQuery.DataMap:\n return `${domain}/${UrlTracking.Map + UrlQuery.Map}`;\n }\n }\n\n private static setDomains(domain: string | null): void {\n if (!domain) {\n return;\n }\n\n this.isCustomDomain = true;\n\n const parts = domain.split('.');\n\n const [secondLevelDomain, topLevelDomain] = parts;\n\n const domainData = {\n secondLevelDomain,\n topLevelDomain,\n };\n\n this.domains = {\n [UrlType.DataApi]: {\n ...this.domains[UrlType.DataApi],\n ...domainData,\n },\n [UrlType.Events]: {\n ...this.domains[UrlType.Events],\n ...domainData,\n },\n [UrlType.ClientConfiguration]: {\n ...this.domains[UrlType.ClientConfiguration],\n ...domainData,\n },\n };\n }\n}\n"],"mappings":"gyCAkBO,KAAM,CAAAA,WAAY,CA6BvB,MAAc,CAAAC,UAAUA,CAAAC,CAAA,CAKY,IALX,CACvBC,QAAQ,CAARA,CAAQ,CACRC,MAAM,CAANA,CAAM,CACNC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAC+B,CAAC,CAAAJ,CAAA,CAChC,IAAI,CAACC,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACG,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACD,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,KAAK,GAAO,CAEjB,IAAI,CAACC,UAAU,CAACJ,CAAM,CACxB,CAEA,MAAc,CAAAK,gBAAgBA,CAACL,CAAc,CAAQ,KAAAM,CAAA,CACnD,IAAI,IAAI,CAACC,cAAc,EAIvB,KAAM,CAAAC,CAAK,CAAGR,CAAM,CAACS,KAAK,CAAC,GAAG,CAAC,CAE/B,GAAqB,CAAC,GAAlBD,CAAK,CAACE,MAAY,EAItB,KAAM,CAACC,CAAS,CAAEC,CAAiB,CAAEC,CAAc,CAAC,CAAGL,CAAK,CAE5D,IAAI,CAACM,OAAO,CAACC,eAAO,CAACC,OAAO,CAAC,CAAG,CAC9BL,SAAS,CAATA,CAAS,CACTC,iBAAiB,CAAjBA,CAAiB,CACjBC,cAAc,SAAAP,CAAA,CAAE,IAAI,CAACW,qBAAqB,YAAAX,CAAA,CAAAA,CAAA,CAAIO,CAChD,CAAC,CARA,CASH,CAEA,MAAc,CAAAK,yBAAyBA,CAACC,CAAkB,CAAU,CAClE,IAAI,CAACC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,CACd,CACD,CAAC7E,eAAO,CAACiB,MAAM,EAAA6D,aAAA,CAAAA,aAAA,IACV,IAAI,CAAC/E,OAAO,CAACC,eAAO,CAACiB,MAAM,CAAC,EAC5B4D,CAAU,CACd,CACD,CAAC7E,eAAO,CAACM,mBAAmB,EAAAwE,aAAA,CAAAA,aAAA,IACvB,IAAI,CAAC/E,OAAO,CAACC,eAAO,CAACM,mBAAmB,CAAC,EACzCuE,CAAU,CAEjB,CACF,CACF,CAACE,OAAA,CAAAlG,WAAA,CAAAA,WAAA,CAAAmG,eAAA,CA9PYnG,WAAW,aAAAmG,eAAA,CAAXnG,WAAW,oBAAAmG,eAAA,CAAXnG,WAAW,sBAAAmG,eAAA,CAAXnG,WAAW,uBAAAmG,eAAA,CAAXnG,WAAW,uBAAAmG,eAAA,CAAXnG,WAAW,WAMgB,CACpC,CAACmB,eAAO,CAACC,OAAO,EAAG,CACjBL,SAAS,CAAE,MAAM,CACjBE,cAAc,CAAE,IAAI,CACpBD,iBAAiB,CAAE,WACrB,CAAC,CACD,CAACG,eAAO,CAACiB,MAAM,EAAG,CAChBrB,SAAS,CAAE,QAAQ,CACnBE,cAAc,CAAE,KAAK,CACrBD,iBAAiB,CAAE,WACrB,CAAC,CACD,CAACG,eAAO,CAACM,mBAAmB,EAAG,CAC7BV,SAAS,CAAE,YAAY,CACvBE,cAAc,CAAE,IAAI,CACpBD,iBAAiB,CAAE,WACrB,CACF,CAAC,EAAAmF,eAAA,CAtBUnG,WAAW"}
1
+ {"version":3,"file":"urlProvider.js","names":["UrlProvider","constructor","_defineProperty","DEFAULT_DOMAINS","initialize","a","domain","siteCode","packageInfo","environment","ready","setDomains","dataApiDomain","isCustomDomain","parts","split","length","subdomain","secondLevelDomain","topLevelDomain","domains","UrlType","DataApi","getClientConfigurationUrl","timeStamp","isInitialized","ClientConfiguration","baseUrl","concat","environmentParam","Environment","Production","UrlFirstParameter","timeStampParam","UrlParameter","Ts","getEventSourceUrl","Events","UrlQuery","Sse","getRemoteDataUrl","key","getDataApiUrl","DataApiQuery","DataMap","Key","encodeURI","getVisitorDataUrl","visitorCode","filters","isMappingIdentifier","customData","previousVisitAmount","currentVisit","conversions","geolocation","experiments","pageViews","device","browser","operatingSystem","kcs","identifierParameter","MappingValue","VisitorCode","customDataParameter","CustomData","conversionsParameter","Conversion","geolocationParameter","Geolocation","experimentsParameter","Experiment","pageViewsParameter","Page","staticDataParameter","StaticData","currentVisitParameter","CurrentVisit","kcsParameter","Kcs","previousVisitAmountParam","MaxNumberPreviousVisits","VisitData","getTrackingUrl","type","version","VisitEvent","SdkName","toLowerCase","SdkVersion","Error","query","UrlTracking","Visit","Visitor","Map","domainData","_objectSpread","exports"],"sources":["../../src/requester/urlProvider.ts"],"sourcesContent":["import { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n UrlFirstParameter,\n UrlParameter,\n UrlTracking,\n UrlQuery,\n DEFAULT_DOMAINS,\n} from './constants';\nimport {\n DataApiQuery,\n DomainsType,\n GetVisitorDataUrlParamsType,\n UrlProviderInitializeParamsType,\n UrlType,\n} from './types';\n\nexport interface IUrlProvider {\n initialize(params: UrlProviderInitializeParamsType): void;\n getClientConfigurationUrl(timeStamp?: number): string;\n getEventSourceUrl(): string;\n getRemoteDataUrl(key: string): string;\n getVisitorDataUrl(params: GetVisitorDataUrlParamsType): string;\n getTrackingUrl(visitorCode: string, isMappingIdentifier?: boolean): string;\n dataApiDomain: string;\n}\n\nexport class UrlProvider implements IUrlProvider {\n private ready = false;\n private isCustomDomain = false;\n private domains: DomainsType = DEFAULT_DOMAINS;\n private siteCode?: string;\n private environment?: Environment;\n private packageInfo?: ExternalPackageInfoType;\n\n public initialize({\n domain,\n siteCode,\n packageInfo,\n environment,\n }: UrlProviderInitializeParamsType) {\n this.siteCode = siteCode;\n this.environment = environment;\n this.packageInfo = packageInfo;\n this.ready = true;\n\n this.setDomains(domain);\n }\n\n set dataApiDomain(domain: string) {\n if (this.isCustomDomain) {\n return;\n }\n\n const parts = domain.split('.');\n\n if (parts.length !== 3) {\n return;\n }\n\n const [subdomain, secondLevelDomain, topLevelDomain] = parts;\n\n this.domains[UrlType.DataApi] = {\n subdomain,\n secondLevelDomain,\n topLevelDomain,\n };\n }\n\n public getClientConfigurationUrl(timeStamp?: number): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.ClientConfiguration];\n\n const baseUrl = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}/`;\n const environmentParam =\n this.environment === Environment.Production\n ? ''\n : UrlFirstParameter.Environment + this.environment;\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 return baseUrl + this.siteCode + environmentParam + timeStampParam;\n }\n\n public getEventSourceUrl(): string {\n this.isInitialized();\n\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.Events];\n\n return `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}:8110/${UrlQuery.Sse}${this.siteCode}`;\n }\n\n public getRemoteDataUrl(key: string): string {\n this.isInitialized();\n\n return (\n this.getDataApiUrl(DataApiQuery.DataMap) +\n this.siteCode +\n UrlParameter.Key +\n encodeURI(key)\n );\n }\n\n public getVisitorDataUrl({\n visitorCode,\n filters,\n isMappingIdentifier,\n }: GetVisitorDataUrlParamsType): string {\n this.isInitialized();\n\n const {\n customData,\n previousVisitAmount,\n currentVisit,\n conversions,\n geolocation,\n experiments,\n pageViews,\n device,\n browser,\n operatingSystem,\n kcs,\n } = filters;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\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 const kcsParameter = kcs ? UrlParameter.Kcs + true : '';\n const previousVisitAmountParam =\n typeof previousVisitAmount !== 'number'\n ? UrlParameter.MaxNumberPreviousVisits + 1\n : UrlParameter.MaxNumberPreviousVisits + previousVisitAmount;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitData) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n previousVisitAmountParam +\n customDataParameter +\n conversionsParameter +\n geolocationParameter +\n experimentsParameter +\n pageViewsParameter +\n staticDataParameter +\n currentVisitParameter +\n kcsParameter\n );\n }\n\n public getTrackingUrl(\n visitorCode: string,\n isMappingIdentifier?: boolean,\n ): string {\n this.isInitialized();\n\n const { type, version } = this.packageInfo!;\n\n const identifierParameter = isMappingIdentifier\n ? UrlParameter.MappingValue\n : UrlParameter.VisitorCode;\n\n return (\n this.getDataApiUrl(DataApiQuery.VisitEvent) +\n this.siteCode +\n identifierParameter +\n visitorCode +\n UrlParameter.SdkName +\n type.toLowerCase() +\n UrlParameter.SdkVersion +\n version\n );\n }\n\n private isInitialized(): void {\n if (!this.ready) {\n throw new Error('UrlProvider is not initialized');\n }\n }\n\n private getDataApiUrl(query: DataApiQuery): string {\n const { subdomain, topLevelDomain, secondLevelDomain } =\n this.domains[UrlType.DataApi];\n\n if (!subdomain || !topLevelDomain || !secondLevelDomain) {\n throw new Error('Data API domain is not set');\n }\n\n const domain = `https://${subdomain}.${secondLevelDomain}.${topLevelDomain}`;\n\n switch (query) {\n case DataApiQuery.VisitEvent:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Events}`;\n case DataApiQuery.VisitData:\n return `${domain}/${UrlTracking.Visit + UrlQuery.Visitor}`;\n case DataApiQuery.DataMap:\n return `${domain}/${UrlTracking.Map + UrlQuery.Map}`;\n }\n }\n\n private setDomains(domain: string | null): void {\n if (!domain) {\n return;\n }\n\n this.isCustomDomain = true;\n\n const parts = domain.split('.');\n\n const [secondLevelDomain, topLevelDomain] = parts;\n\n const domainData = {\n secondLevelDomain,\n topLevelDomain,\n };\n\n this.domains = {\n [UrlType.DataApi]: {\n ...this.domains[UrlType.DataApi],\n ...domainData,\n },\n [UrlType.Events]: {\n ...this.domains[UrlType.Events],\n ...domainData,\n },\n [UrlType.ClientConfiguration]: {\n ...this.domains[UrlType.ClientConfiguration],\n ...domainData,\n },\n };\n }\n}\n"],"mappings":"gyCA0BO,KAAM,CAAAA,WAAoC,CAAAC,YAAA,EAAAC,eAAA,kBAAAA,eAAA,2BAAAA,eAAA,gBAGhBC,0BAAe,EAAAD,eAAA,yBAAAA,eAAA,4BAAAA,eAAA,4BAKvCE,UAAUA,CAAAC,CAAA,CAKmB,IALlB,CAChBC,MAAM,CAANA,CAAM,CACNC,QAAQ,CAARA,CAAQ,CACRC,WAAW,CAAXA,CAAW,CACXC,WAAW,CAAXA,CAC+B,CAAC,CAAAJ,CAAA,CAChC,IAAI,CAACE,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACE,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACD,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,KAAK,GAAO,CAEjB,IAAI,CAACC,UAAU,CAACL,CAAM,CACxB,CAEA,GAAI,CAAAM,aAAaA,CAACN,CAAc,CAAE,CAChC,IAAI,IAAI,CAACO,cAAc,EAIvB,KAAM,CAAAC,CAAK,CAAGR,CAAM,CAACS,KAAK,CAAC,GAAG,CAAC,CAE/B,GAAqB,CAAC,GAAlBD,CAAK,CAACE,MAAY,EAItB,KAAM,CAACC,CAAS,CAAEC,CAAiB,CAAEC,CAAc,CAAC,CAAGL,CAAK,CAE5D,IAAI,CAACM,OAAO,CAACC,eAAO,CAACC,OAAO,CAAC,CAAG,CAC9BL,SAAS,CAATA,CAAS,CACTC,iBAAiB,CA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AC,EAC7B2E,CAAU,CACd,CACD,CAAC5E,eAAO,CAACgB,MAAM,EAAA6D,aAAA,CAAAA,aAAA,IACV,IAAI,CAAC9E,OAAO,CAACC,eAAO,CAACgB,MAAM,CAAC,EAC5B4D,CAAU,CACd,CACD,CAAC5E,eAAO,CAACK,mBAAmB,EAAAwE,aAAA,CAAAA,aAAA,IACvB,IAAI,CAAC9E,OAAO,CAACC,eAAO,CAACK,mBAAmB,CAAC,EACzCuE,CAAU,CAEjB,CACF,CACF,CAACE,OAAA,CAAAnG,WAAA,CAAAA,WAAA"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ClientConfigurationDataType, ConfigurationDataType, JSONType } from './clientConfiguration/types';
2
2
  import { SdkLanguageType } from './constants';
3
3
  import { IExternalEventSource } from './eventSource';
4
- import { IExternalRequester, RequestType } from './requester';
4
+ import { IExternalRequester, IUrlProvider, RequestType } from './requester';
5
5
  import { IExternalStorage } from './storage';
6
6
  import { IExternalPRNG, VisitorDataFiltersType } from './utilities';
7
7
  import { IVisitorCodeManager } from './visitorCodeManager';
@@ -34,15 +34,23 @@ export type SDKConfigurationType = {
34
34
  networkDomain?: string;
35
35
  cookieDomain?: string;
36
36
  };
37
+ /**
38
+ * @param {string} urlProvider - main source for all URLs used in the SDK
39
+ * */
40
+ export type DependenciesType = {
41
+ urlProvider?: IUrlProvider;
42
+ };
37
43
  /**
38
44
  * @param {string} siteCode - client's siteCode defined on Kameleoon platform
39
45
  * @param {Partial<SDKConfigurationType>} configuration - client's configuration
40
46
  * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK
47
+ * @param {DependenciesType | undefined} dependencies - internal dependencies meant primarily for testing purposes
41
48
  * */
42
49
  export type SDKCoreParameters = {
43
50
  siteCode: string;
44
- configuration?: Partial<SDKConfigurationType>;
45
51
  internalConfiguration: InternalSDKConfigurationType;
52
+ configuration?: Partial<SDKConfigurationType>;
53
+ dependencies?: DependenciesType;
46
54
  };
47
55
  /**
48
56
  * @param {SdkLanguageType} type - type of the SDK
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["_requester","require","Object","defineProperty","exports","value","VariableType","Milliseconds","Environment","Production","Staging","Development","BOOLEAN","NUMBER","STRING","JSON","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n JSONType,\n} from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequester, RequestType } from './requester';\nimport { IExternalStorage } from './storage';\nimport { IExternalPRNG, VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead\n * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to\n * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n networkDomain?: string;\n cookieDomain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {ExternalPackageInfoType} packageInfo - external package info, used to get package version and name\n * @param {IExternalPRNG | undefined} prng - external PRNG implementation\n * */\nexport type InternalsType = {\n packageInfo: ExternalPackageInfoType;\n prng?: IExternalPRNG;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * Note: _Deprecated_ - to be removed in the next major update\n * @param {IExternalRequester} externalRequester - external requester , used to track or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequester: IExternalRequester;\n externalPRNG: IExternalPRNG;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n\n/**\n * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`\n * */\nexport type SimulateRequestDataType = {\n [RequestType.Configuration]: ClientConfigurationDataType;\n [RequestType.RemoteData]: JSONType;\n [RequestType.Tracking]: null;\n};\n"],"mappings":"aAOA,IAAAA,UAAA,CAAAC,OAAA,gBAA8DC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,CAAAF,OAAA,CAAAG,YAAA,CAAAH,OAAA,CAAAI,WAAA,WAwFlD,CAAAA,WAAW,CAAAJ,OAAA,CAAAI,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAUXF,YAAY,CAAAF,OAAA,CAAAE,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAM,OAAA,WAAZN,CAAY,CAAAO,MAAA,UAAZP,CAAY,CAAAQ,MAAA,UAAZR,CAAY,CAAAS,IAAA,QAAZT,CAAY,MAkDZC,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAS,MAAA,gBAAZT,CAAY,CAAZA,CAAY,CAAAU,MAAA,CAEb,EAAE,CAAGV,CAAY,CAACS,MAAM,WAFvBT,CAAY,CAAZA,CAAY,CAAAW,IAAA,CAGf,EAAE,CAAGX,CAAY,CAACU,MAAM,SAHrBV,CAAY,CAAZA,CAAY,CAAAY,GAAA,CAIhB,EAAE,CAAGZ,CAAY,CAACW,IAAI,QAJlBX,CAAY,CAAZA,CAAY,CAAAa,IAAA,CAKf,CAAC,CAAGb,CAAY,CAACY,GAAG,SALjBZ,CAAY,CAAZA,CAAY,CAAAc,KAAA,CAMd,EAAE,CAAGd,CAAY,CAACY,GAAG,UANnBZ,CAAY"}
1
+ {"version":3,"file":"types.js","names":["_requester","require","Object","defineProperty","exports","value","VariableType","Milliseconds","Environment","Production","Staging","Development","BOOLEAN","NUMBER","STRING","JSON","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n JSONType,\n} from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequester, IUrlProvider, RequestType } from './requester';\nimport { IExternalStorage } from './storage';\nimport { IExternalPRNG, VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie which Kameleoon visitor code belongs to. Note: parameter `domain` is deprecated and will be removed in the next major update, use `cookieDomain` instead\n * @param {string | undefined} cookieDomain - domain which cookie which Kameleoon visitor code belongs to\n * @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n networkDomain?: string;\n cookieDomain?: string;\n};\n\n/**\n * @param {string} urlProvider - main source for all URLs used in the SDK\n * */\nexport type DependenciesType = {\n urlProvider?: IUrlProvider;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * @param {DependenciesType | undefined} dependencies - internal dependencies meant primarily for testing purposes\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n internalConfiguration: InternalSDKConfigurationType;\n configuration?: Partial<SDKConfigurationType>;\n dependencies?: DependenciesType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {ExternalPackageInfoType} packageInfo - external package info, used to get package version and name\n * @param {IExternalPRNG | undefined} prng - external PRNG implementation\n * */\nexport type InternalsType = {\n packageInfo: ExternalPackageInfoType;\n prng?: IExternalPRNG;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * Note: _Deprecated_ - to be removed in the next major update\n * @param {IExternalRequester} externalRequester - external requester , used to track or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequester: IExternalRequester;\n externalPRNG: IExternalPRNG;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n\n/**\n * @type `SimulateRequestDataType` a type of data provided to `simulateSuccessRequest` method depending on `RequestType`\n * */\nexport type SimulateRequestDataType = {\n [RequestType.Configuration]: ClientConfigurationDataType;\n [RequestType.RemoteData]: JSONType;\n [RequestType.Tracking]: null;\n};\n"],"mappings":"aAOA,IAAAA,UAAA,CAAAC,OAAA,gBAA4EC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,YAAA,CAAAF,OAAA,CAAAG,YAAA,CAAAH,OAAA,CAAAI,WAAA,WAiGhE,CAAAA,WAAW,CAAAJ,OAAA,CAAAI,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,UAAA,cAAXD,CAAW,CAAAE,OAAA,WAAXF,CAAW,CAAAG,WAAA,eAAXH,CAAW,MAUXF,YAAY,CAAAF,OAAA,CAAAE,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAM,OAAA,WAAZN,CAAY,CAAAO,MAAA,UAAZP,CAAY,CAAAQ,MAAA,UAAZR,CAAY,CAAAS,IAAA,QAAZT,CAAY,MAkDZC,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAS,MAAA,gBAAZT,CAAY,CAAZA,CAAY,CAAAU,MAAA,CAEb,EAAE,CAAGV,CAAY,CAACS,MAAM,WAFvBT,CAAY,CAAZA,CAAY,CAAAW,IAAA,CAGf,EAAE,CAAGX,CAAY,CAACU,MAAM,SAHrBV,CAAY,CAAZA,CAAY,CAAAY,GAAA,CAIhB,EAAE,CAAGZ,CAAY,CAACW,IAAI,QAJlBX,CAAY,CAAZA,CAAY,CAAAa,IAAA,CAKf,CAAC,CAAGb,CAAY,CAACY,GAAG,SALjBZ,CAAY,CAAZA,CAAY,CAAAc,KAAA,CAMd,EAAE,CAAGd,CAAY,CAACY,GAAG,UANnBZ,CAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/javascript-sdk-core",
3
- "version": "4.4.6",
3
+ "version": "4.4.8",
4
4
  "description": "Kameleoon JS SDK Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",