@kameleoon/javascript-sdk-core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/types.d.ts +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/kameleoonClient.d.ts +2 -1
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +2 -2
- package/dist/kameleoonClientInterface.js.map +1 -1
- package/dist/kameleoonData/applicationVersion.d.ts +0 -9
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +3 -12
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/conversion.d.ts +11 -13
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.d.ts +0 -9
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.d.ts +3 -13
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.d.ts +11 -5
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +13 -6
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.d.ts +3 -12
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.d.ts +3 -12
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/index.d.ts +1 -0
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/index.js.map +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.d.ts +15 -0
- package/dist/kameleoonData/kameleoonConversionScore.js +2 -0
- package/dist/kameleoonData/kameleoonConversionScore.js.map +1 -0
- package/dist/kameleoonData/operatingSystem.d.ts +3 -12
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.d.ts +4 -13
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +54 -11
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/userAgent.d.ts +0 -9
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitProcessor.d.ts +34 -0
- package/dist/kameleoonData/visitProcessor.js +2 -0
- package/dist/kameleoonData/visitProcessor.js.map +1 -0
- package/dist/kameleoonData/visitsData.d.ts +7 -21
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/requester/constants.d.ts +1 -3
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +2 -6
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +24 -2
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +17 -0
- package/dist/requester/urlProvider.js +2 -0
- package/dist/requester/urlProvider.js.map +1 -0
- package/dist/storage/storage.js +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/browser.js.map +1 -1
- package/dist/targeting/conditions/conditionFactory.js +1 -1
- package/dist/targeting/conditions/conditionFactory.js.map +1 -1
- package/dist/targeting/conditions/conversionLikelihood.d.ts +12 -0
- package/dist/targeting/conditions/conversionLikelihood.js +2 -0
- package/dist/targeting/conditions/conversionLikelihood.js.map +1 -0
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/firstVisit.js.map +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/geolocation.js.map +1 -1
- package/dist/targeting/conditions/index.d.ts +1 -0
- package/dist/targeting/conditions/index.js +1 -1
- package/dist/targeting/conditions/index.js.map +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/lastVisit.js.map +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/newVisitor.js.map +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/types.d.ts +3 -0
- package/dist/targeting/conditions/types.js.map +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/conditions/visits.js.map +1 -1
- package/dist/targeting/index.d.ts +2 -2
- package/dist/targeting/index.js +1 -1
- package/dist/targeting/index.js.map +1 -1
- package/dist/targeting/types.d.ts +4 -0
- package/dist/targeting/types.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/types.d.ts +6 -1
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.d.ts +1 -1
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +1 -1
- package/dist/variationConfiguration/types.js.map +1 -1
- package/package.json +6 -2
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { Result } from 'ts-res';
|
|
2
2
|
import { IStorage } from '../storage';
|
|
3
|
-
import { TargetingDataType } from '../targeting';
|
|
3
|
+
import { TargetingDataType, VisitorReference } from '../targeting';
|
|
4
4
|
import { KameleoonError } from '../kameleoonError';
|
|
5
|
-
import { KameleoonDataType } from './types';
|
|
5
|
+
import { KameleoonData, KameleoonDataType, KameleoonVisitorDataType } from './types';
|
|
6
6
|
interface IDataProcessor {
|
|
7
7
|
updateData(visitorCode: string, dataItem: KameleoonDataType): Result<void, KameleoonError>;
|
|
8
|
-
|
|
8
|
+
createReference(visitorCode: string, linkedVisitor: VisitorReference): void;
|
|
9
9
|
cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void;
|
|
10
|
-
|
|
10
|
+
getTargetingData(visitorCode: string): Result<KameleoonVisitorDataType | null, KameleoonError>;
|
|
11
|
+
getLinkedVisitor(visitorCode: string, index: number): string | null;
|
|
11
12
|
}
|
|
12
13
|
export declare class DataProcessor implements IDataProcessor {
|
|
13
14
|
private storage;
|
|
15
|
+
private storedDataTypes;
|
|
16
|
+
private storedCustomDataIndexes;
|
|
14
17
|
constructor(storage: IStorage<TargetingDataType>);
|
|
15
18
|
updateData(visitorCode: string, dataItem: KameleoonDataType): Result<void, KameleoonError>;
|
|
16
|
-
|
|
19
|
+
createReference(visitorCode: string, linkedVisitor: VisitorReference): void;
|
|
20
|
+
getLinkedVisitor(visitorCode: string, index: number | null): string | null;
|
|
17
21
|
cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void;
|
|
18
|
-
|
|
22
|
+
getTargetingData(visitorCode: string): Result<KameleoonVisitorDataType | null, KameleoonError>;
|
|
23
|
+
private dereferenceTargetingData;
|
|
24
|
+
get storedDataTypeList(): Set<KameleoonData>;
|
|
25
|
+
get storedCustomDataIndexList(): Set<number>;
|
|
19
26
|
private updateField;
|
|
20
27
|
private createField;
|
|
21
28
|
private updateArrayField;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const _excluded=["customData","pageView","conversion"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataProcessor=void 0;var _tsRes=require("ts-res"),_utilities=require("../utilities"),_types=require("../utilities/types"),
|
|
1
|
+
"use strict";const _excluded=["customData","pageView","conversion"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataProcessor=void 0;var _tsRes=require("ts-res"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("../types"),_constants=require("./constants"),_types3=require("./types");function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}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 DataProcessor{constructor(a){_defineProperty(this,"storage",void 0),_defineProperty(this,"storedDataTypes",new Set([])),_defineProperty(this,"storedCustomDataIndexes",new Set([])),this.storage=a}updateData(a,b){const c=this.storage.read().or({}),d=this.dereferenceTargetingData(c,a),e=(null===d||void 0===d?void 0:d.visitorReference)||a;switch(b.data.type){case _types3.KameleoonData.CustomData:{const a=b.data,f=d&&_types3.KameleoonData.CustomData in d.data,g={visitorCode:e,data:c,key:_types3.KameleoonData.CustomData,nestedKey:a.index.toString(),value:a};f?this.updateNestedField(g):this.createNestedField(g),this.storedCustomDataIndexes.add(a.index);break}case _types3.KameleoonData.PageView:{var f;const a=b.data;a.timestamps.length||(a.timestamps=[Date.now()]);const g=d&&_types3.KameleoonData.PageView in d.data&&(null===(f=d.data[a.type])||void 0===f?void 0:f[a.urlAddress]),h={visitorCode:e,data:c,key:_types3.KameleoonData.PageView,nestedKey:a.urlAddress,value:a};g?(a.timestamps.forEach(a=>{_utilities.Utilities.insertInOrderedListMutably({list:g.timestamps,element:a,order:_types.Order.Ascending})}),[g.referrers,g.title]=[a.referrers,a.title],this.updateNestedField(_objectSpread(_objectSpread({},h),{},{value:g}))):this.createNestedField(h);break}case _types3.KameleoonData.Conversion:{const a=b.data,f=d&&_types3.KameleoonData.Conversion in d.data,g={visitorCode:e,data:c,key:_types3.KameleoonData.Conversion,value:a};f?this.updateArrayField(g):this.createArrayField(g);break}case _types3.KameleoonData.VisitsData:{const a=b.data,f=d&&_types3.KameleoonData.VisitsData in d.data,g={visitorCode:e,data:c,key:_types3.KameleoonData.VisitsData,value:a};if(f){const b=d.data[a.type];b.visits.forEach(b=>{_utilities.Utilities.insertInOrderedListMutably({list:a.visits,element:b,order:_types.Order.Ascending})}),this.updateField(_objectSpread(_objectSpread({},g),{},{value:_objectSpread(_objectSpread({},a),{},{visits:a.visits})}))}else this.createField(g);break}default:{const{data:a}=b,f=d&&a.type in d.data,g={visitorCode:e,data:c,key:a.type,value:a};f?this.updateField(g):this.createField(g),this.storedDataTypes.add(a.type)}}return this.storage.write(c)}createReference(a,b){const c=this.storage.read();c.ok&&(c.data[b]=a,this.storage.write(c.data))}getLinkedVisitor(a,b){const c=this.storage.read();if(!c.ok)return null;if("string"==typeof c.data[a])return c.data[a];if(null===b)return null;const d=c.data[a];if(!d)return null;const e=d[_types3.KameleoonData.CustomData];return e&&e[b]?e[b].value[0]:null}cleanupOutdatedTargetingData(a){const b=this.storage.read();if(!b.ok)return;const c=b.data,d=a?a*_types2.Milliseconds.Minute:_constants.DEFAULT_CLEANUP_INTERVAL*_types2.Milliseconds.Minute,e=Date.now();if(Object.keys(c).length){for(const[a,b]of Object.entries(c)){if("string"==typeof b){delete c[a];continue}const f=b,{customData:g,pageView:h,conversion:i}=f,j=_objectWithoutProperties(f,_excluded);if(g)for(const[a,b]of Object.entries(g))if(b){const g=b.lastActivityTime+d<e,h=f[_types3.KameleoonData.CustomData];g&&h&&(this.storedCustomDataIndexes.delete(+a),delete h[+a]),h&&!Object.keys(h).length&&(this.storedCustomDataIndexes.clear(),delete c[_types3.KameleoonData.CustomData])}if(h)for(const[a,b]of Object.entries(h)){const c=b.lastActivityTime+d<e,g=f[_types3.KameleoonData.PageView];c&&g&&delete g[a],g&&!Object.keys(g).length&&delete f[_types3.KameleoonData.PageView]}if(i)for(const a of i){const b=a.lastActivityTime+d<e,c=f[_types3.KameleoonData.Conversion];b&&c&&c.splice(c.indexOf(a),1),c&&!c.length&&delete f[_types3.KameleoonData.Conversion]}for(const[a,b]of Object.entries(j)){const c=b.lastActivityTime+d<e;c&&(delete f[a],this.storedDataTypes.delete(a))}Object.keys(c[a]).length||(this.storedDataTypes.clear(),this.storedCustomDataIndexes.clear(),delete c[a])}this.storage.write(c)}}getTargetingData(a){const b=this.storage.read();if(!b.ok)return(0,_tsRes.Err)(b.error);const c=this.dereferenceTargetingData(b.data,a);return c?(0,_tsRes.Ok)(c.data):(0,_tsRes.Ok)(null)}dereferenceTargetingData(a,b){if(!a[b])return null;if("string"==typeof a[b]){const c=a[b];return{data:a[c],visitorReference:c}}return{data:a[b],visitorReference:b}}get storedDataTypeList(){return this.storedDataTypes}get storedCustomDataIndexList(){return this.storedCustomDataIndexes}updateField(a){let{visitorCode:b,key:c,value:d,data:e}=a;e[b][c]=_objectSpread(_objectSpread({},d),{},{lastActivityTime:Date.now()})}createField(a){let{visitorCode:b,key:c,value:d,data:e}=a;e[b]=_objectSpread(_objectSpread({},e[b]),{},{[c]:_objectSpread(_objectSpread({},d),{},{lastActivityTime:Date.now()})})}updateArrayField(a){let{visitorCode:b,key:c,value:d,data:e}=a;e[b][c].push(_objectSpread(_objectSpread({},d),{},{lastActivityTime:Date.now()}))}createArrayField(a){let{visitorCode:b,key:c,value:d,data:e}=a;e[b]=_objectSpread(_objectSpread({},e[b]),{},{[c]:[_objectSpread(_objectSpread({},d),{},{lastActivityTime:Date.now()})]})}updateNestedField(a){let{visitorCode:b,key:c,nestedKey:d,value:e,data:f}=a;f[b][c][d]=_objectSpread(_objectSpread({},e),{},{lastActivityTime:Date.now()})}createNestedField(a){var b;let{visitorCode:c,key:d,nestedKey:e,value:f,data:g}=a;g[c]=null!==(b=g[c])&&void 0!==b&&b[d]?_objectSpread(_objectSpread({},g[c]),{},{[d]:_objectSpread(_objectSpread({},g[c][d]),{},{[e]:_objectSpread(_objectSpread({},f),{},{lastActivityTime:Date.now()})})}):_objectSpread(_objectSpread({},g[c]),{},{[d]:{[e]:_objectSpread(_objectSpread({},f),{},{lastActivityTime:Date.now()})}})}}exports.DataProcessor=DataProcessor;
|
|
2
2
|
//# sourceMappingURL=dataProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataProcessor.js","names":["DataProcessor","constructor","storage","_defineProperty","updateData","visitorCode","dataItem","targetingData","read","or","commonParameters","data","type","KameleoonData","CustomData","hasCustomDataKey","parameters","_objectSpread","key","nestedKey","index","toString","value","updateNestedField","createNestedField","PageView","e","timestamps","length","Date","now","existingData","urlAddress","forEach","timestamp","Utilities","insertInOrderedListMutably","list","element","order","Order","Ascending","referrers","title","Conversion","hasConversionDataKey","updateArrayField","createArrayField","VisitsData","hasVisitsKey","existingVisits","previousVisits","visit","currentVisit","updateField","createField","hasDataKey","write","createVisit","b","storageData","ok","Err","error","cleanupOutdatedTargetingData","targetingCleanupInterval","targetingDataLifetime","Milliseconds","Minute","DEFAULT_CLEANUP_INTERVAL","currentTime","Object","keys","kameleoonVisitorData","entries","customData","pageView","conversion","rest","_objectWithoutProperties","_excluded","isDataExpired","lastActivityTime","url","splice","indexOf","storedTargetingData","a","push","exports"],"sources":["../../src/kameleoonData/dataProcessor.ts"],"sourcesContent":["import { Err, Result } from 'ts-res';\nimport { IStorage } from 'src/storage';\nimport { TargetingDataType } from 'src/targeting';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { Order } from 'src/utilities/types';\nimport { VisitsData } from './visitsData';\nimport { Milliseconds } from 'src/types';\nimport { DEFAULT_CLEANUP_INTERVAL } from './constants';\nimport {\n ArrayFieldParametersType,\n ConversionDataType,\n CustomDataType,\n ExistingArrayDataType,\n ExistingDataType,\n ExistingNestedDataType,\n ExistingPageViewDataType,\n ExistingVisitsDataType,\n FieldParametersType,\n KameleoonData,\n KameleoonDataType,\n NestedFieldParametersType,\n PageViewDataType,\n VisitsDataType,\n} from './types';\n\ninterface IDataProcessor {\n updateData(\n visitorCode: string,\n dataItem: KameleoonDataType,\n ): Result<void, KameleoonError>;\n createVisit(visitorCode: string): void;\n cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void;\n readonly storedTargetingData: Result<TargetingDataType, KameleoonError>;\n}\n\nexport class DataProcessor implements IDataProcessor {\n private storage: IStorage<TargetingDataType>;\n\n constructor(storage: IStorage<TargetingDataType>) {\n this.storage = storage;\n }\n\n // --- Note ---\n // Following code is optimized for performance:\n // - We don't want to copy the whole object every time we add new data\n // - So we are manually checking the keys existence and mutating targeting data directly\n // - Numerous type casts are required because we can't narrow down nested `targetingData` types by using assertion functions\n public updateData(\n visitorCode: string,\n dataItem: KameleoonDataType,\n ): Result<void, KameleoonError> {\n const targetingData = this.storage.read().or({});\n const commonParameters: Pick<FieldParametersType, 'visitorCode' | 'data'> =\n {\n visitorCode,\n data: targetingData,\n };\n\n switch (dataItem.data.type) {\n case KameleoonData.CustomData: {\n const data = dataItem.data as CustomDataType;\n const hasCustomDataKey =\n targetingData[visitorCode] &&\n KameleoonData.CustomData in targetingData[visitorCode];\n const parameters: NestedFieldParametersType = {\n ...commonParameters,\n key: KameleoonData.CustomData,\n nestedKey: data.index.toString(),\n value: data,\n };\n\n if (hasCustomDataKey) {\n this.updateNestedField(parameters);\n } else {\n this.createNestedField(parameters);\n }\n\n break;\n }\n case KameleoonData.PageView: {\n const data = dataItem.data as PageViewDataType;\n\n // --- Note ---\n // We assign `timestamps` to `Date.now()` if it's empty\n // Not upon data item creation because it makes no sense in terms\n // of data flow to have some indication of data activity before it was added\n if (!data.timestamps.length) {\n data.timestamps = [Date.now()];\n }\n\n const existingData =\n targetingData[visitorCode] &&\n KameleoonData.PageView in targetingData[visitorCode] &&\n (targetingData[visitorCode][data.type] as ExistingPageViewDataType)?.[\n data.urlAddress\n ];\n\n const parameters: NestedFieldParametersType = {\n ...commonParameters,\n key: KameleoonData.PageView,\n nestedKey: data.urlAddress,\n value: data,\n };\n\n if (existingData) {\n // --- Note ---\n // Updating existing `PageView` properties by pushing new timestamps\n // and potentially changing referrers and title\n data.timestamps.forEach((timestamp) => {\n Utilities.insertInOrderedListMutably({\n list: existingData.timestamps,\n element: timestamp,\n order: Order.Ascending,\n });\n });\n\n [existingData.referrers, existingData.title] = [\n data.referrers,\n data.title,\n ];\n\n this.updateNestedField({ ...parameters, value: existingData });\n } else {\n this.createNestedField(parameters);\n }\n\n break;\n }\n case KameleoonData.Conversion: {\n const data = dataItem.data as ConversionDataType;\n const hasConversionDataKey =\n targetingData[visitorCode] &&\n KameleoonData.Conversion in targetingData[visitorCode];\n const parameters: ArrayFieldParametersType = {\n ...commonParameters,\n key: KameleoonData.Conversion,\n value: data,\n };\n\n if (hasConversionDataKey) {\n this.updateArrayField(parameters);\n } else {\n this.createArrayField(parameters);\n }\n\n break;\n }\n case KameleoonData.VisitsData: {\n const data = dataItem.data as VisitsDataType;\n const hasVisitsKey =\n targetingData[visitorCode] &&\n KameleoonData.VisitsData in targetingData[visitorCode];\n const parameters: FieldParametersType = {\n ...commonParameters,\n key: KameleoonData.VisitsData,\n value: data,\n };\n\n // -- Change directly if `[key]` exists\n if (hasVisitsKey) {\n const existingVisits = targetingData[visitorCode][\n data.type\n ] as ExistingVisitsDataType;\n\n // --- Note ---\n // We are preserving the order of visits\n existingVisits.previousVisits.forEach((visit) => {\n Utilities.insertInOrderedListMutably({\n list: data.previousVisits,\n element: visit,\n order: Order.Ascending,\n });\n });\n\n let currentVisit = existingVisits.currentVisit;\n\n // --- Note ---\n // We are using new current visit in two cases:\n // 1. If there is no current visit in existing data\n // 2. If existing current visit is older than new current visit\n if (\n (!currentVisit && data.currentVisit) ||\n (currentVisit &&\n data.currentVisit &&\n currentVisit < data.currentVisit)\n ) {\n currentVisit = data.currentVisit;\n }\n\n this.updateField({\n ...parameters,\n value: {\n ...data,\n previousVisits: data.previousVisits,\n currentVisit,\n },\n });\n } else {\n this.createField(parameters);\n }\n\n break;\n }\n default: {\n const { data } = dataItem;\n const hasDataKey =\n targetingData[visitorCode] && data.type in targetingData[visitorCode];\n const parameters: FieldParametersType = {\n ...commonParameters,\n key: data.type,\n // --- Note ---\n // At this point TypeScript can not infer that value is subset of only\n // what is left for `default` case\n value: data as FieldParametersType['value'],\n };\n\n if (hasDataKey) {\n this.updateField(parameters);\n } else {\n this.createField(parameters);\n }\n }\n }\n\n return this.storage.write(targetingData);\n }\n\n public createVisit(visitorCode: string): Result<void, KameleoonError> {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return Err(storageData.error);\n }\n\n const targetingData = storageData.data;\n\n // --- Note ---\n // Create new visit only if it doesn't exist\n if (!targetingData[visitorCode]?.[KameleoonData.VisitsData]) {\n this.updateField({\n visitorCode,\n key: KameleoonData.VisitsData,\n value: new VisitsData(Date.now(), []).data,\n data: targetingData,\n });\n }\n\n return this.storage.write(targetingData);\n }\n\n public cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return;\n }\n\n const targetingData = storageData.data;\n const targetingDataLifetime = targetingCleanupInterval\n ? targetingCleanupInterval * Milliseconds.Minute\n : DEFAULT_CLEANUP_INTERVAL * Milliseconds.Minute;\n\n const currentTime = Date.now();\n\n // --- Note (Weird Thing) ---\n // Generally the check is not needed\n // If the `targetingData` is empty the loop will not be executed\n // But here something weird happens and we'are getting `TypeError` here\n // Even logging `Object.keys().length` or `Object.entries().length` solves the issue somehow\n // You can see the issue by commenting the following `if` statement and waiting for a data cleanup\n // TODO: investigate it later (probably related to object copying?)\n if (!Object.keys(targetingData).length) {\n return;\n }\n\n for (const [visitorCode, kameleoonVisitorData] of Object.entries(\n targetingData,\n )) {\n const { customData, pageView, conversion, ...rest } =\n kameleoonVisitorData;\n\n // TODO: This way of cleaning up data is not optimal\n // And will be changed when sessions are introduced\n if (customData) {\n for (const [index, dataItem] of Object.entries(customData)) {\n if (dataItem) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = kameleoonVisitorData[KameleoonData.CustomData];\n\n if (isDataExpired && existingData) {\n delete existingData[Number(index)];\n }\n\n if (existingData && !Object.keys(existingData).length) {\n delete kameleoonVisitorData[KameleoonData.CustomData];\n }\n }\n }\n }\n\n if (pageView) {\n for (const [url, dataItem] of Object.entries(pageView)) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = kameleoonVisitorData[KameleoonData.PageView];\n\n if (isDataExpired && existingData) {\n delete existingData[url];\n }\n\n if (existingData && !Object.keys(existingData).length) {\n delete kameleoonVisitorData[KameleoonData.PageView];\n }\n }\n }\n\n if (conversion) {\n for (const dataItem of conversion) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = kameleoonVisitorData[KameleoonData.Conversion];\n\n if (isDataExpired && existingData) {\n existingData.splice(existingData.indexOf(dataItem), 1);\n }\n\n if (existingData && !existingData.length) {\n delete kameleoonVisitorData[KameleoonData.Conversion];\n }\n }\n }\n\n for (const [key, dataItem] of Object.entries(rest)) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n\n if (isDataExpired) {\n delete kameleoonVisitorData[key as KameleoonData];\n }\n }\n\n if (!Object.keys(targetingData[visitorCode]).length) {\n delete targetingData[visitorCode];\n }\n }\n\n this.storage.write(targetingData);\n }\n\n get storedTargetingData(): Result<TargetingDataType, KameleoonError> {\n return this.storage.read();\n }\n\n private updateField({\n visitorCode,\n key,\n value,\n data,\n }: FieldParametersType): void {\n (data[visitorCode][key] as ExistingDataType<typeof key>) = {\n ...value,\n lastActivityTime: Date.now(),\n };\n }\n\n private createField({\n visitorCode,\n key,\n value,\n data,\n }: FieldParametersType): void {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: { ...value, lastActivityTime: Date.now() },\n };\n }\n\n private updateArrayField({\n visitorCode,\n key,\n value,\n data,\n }: ArrayFieldParametersType): void {\n (data[visitorCode][key] as ExistingArrayDataType).push({\n ...value,\n lastActivityTime: Date.now(),\n });\n }\n\n private createArrayField({\n visitorCode,\n key,\n value,\n data,\n }: ArrayFieldParametersType): void {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: [{ ...value, lastActivityTime: Date.now() }],\n };\n }\n\n private updateNestedField({\n visitorCode,\n key,\n nestedKey,\n value,\n data,\n }: NestedFieldParametersType): void {\n (data[visitorCode][key] as ExistingNestedDataType)[nestedKey] = {\n ...value,\n lastActivityTime: Date.now(),\n };\n }\n\n private createNestedField({\n visitorCode,\n key,\n nestedKey,\n value,\n data,\n }: NestedFieldParametersType): void {\n if (!data[visitorCode]?.[key]) {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: {\n [nestedKey]: { ...value, lastActivityTime: Date.now() },\n },\n };\n } else {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: {\n ...data[visitorCode][key],\n [nestedKey]: { ...value, lastActivityTime: Date.now() },\n },\n };\n }\n }\n}\n"],"mappings":"q6DAoCO,KAAM,CAAAA,aAAwC,CAGnDC,WAAWA,CAACC,CAAoC,CAAE,CAAAC,eAAA,wBAChD,IAAI,CAACD,OAAO,CAAGA,CACjB,CAOOE,UAAUA,CACfC,CAAmB,CACnBC,CAA2B,CACG,MACxB,CAAAC,CAAa,CAAG,IAAI,CAACL,OAAO,CAACM,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC,CAAC,CAC1CC,CAAmE,CACvE,CACEL,WAAW,CAAXA,CAAW,CACXM,IAAI,CAAEJ,CACR,CAAC,CAEH,OAAQD,CAAQ,CAACK,IAAI,CAACC,IAAI,EACxB,IAAK,CAAAC,qBAAa,CAACC,UAAU,CAAE,MACvB,CAAAH,CAAI,CAAGL,CAAQ,CAACK,IAAsB,CACtCI,CAAgB,CACpBR,CAAa,CAACF,CAAW,CAAC,EAC1BQ,qBAAa,CAACC,UAAU,GAAI,CAAAP,CAAa,CAACF,CAAW,CAAC,CAClDW,CAAqC,CAAAC,aAAA,CAAAA,aAAA,IACtCP,CAAgB,MACnBQ,GAAG,CAAEL,qBAAa,CAACC,UAAU,CAC7BK,SAAS,CAAER,CAAI,CAACS,KAAK,CAACC,QAAQ,CAAC,CAAC,CAChCC,KAAK,CAAEX,CAAI,EACZ,CAEGI,CAAgB,CAClB,IAAI,CAACQ,iBAAiB,CAACP,CAAU,CAAC,CAElC,IAAI,CAACQ,iBAAiB,CAACR,CAAU,CAAC,CAGpC,KACF,CACA,IAAK,CAAAH,qBAAa,CAACY,QAAQ,CAAE,KAAAC,CAAA,CAC3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B,CAAC,CAAA4E,CAAA,CASxB5E,CAAI,CAACN,CAAW,CAAC,SAAAsD,CAAA,CARdhD,CAAI,CAACN,CAAW,CAAC,YAAAsD,CAAA,EAAjBA,CAAA,CAAoBzC,CAAG,CAAC,CAAAD,aAAA,CAAAA,aAAA,IAStBN,CAAI,CAACN,CAAW,CAAC,MACpB,CAACa,CAAG,EAAAD,aAAA,CAAAA,aAAA,IACCN,CAAI,CAACN,CAAW,CAAC,CAACa,CAAG,CAAC,MACzB,CAACC,CAAS,EAAAF,aAAA,CAAAA,aAAA,IAAQK,CAAK,MAAE4D,gBAAgB,CAAErD,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,EACxD,GAAAb,aAAA,CAAAA,aAAA,IAXEN,CAAI,CAACN,CAAW,CAAC,MACpB,CAACa,CAAG,EAAG,CACL,CAACC,CAAS,EAAAF,aAAA,CAAAA,aAAA,IAAQK,CAAK,MAAE4D,gBAAgB,CAAErD,IAAI,CAACC,GAAG,CAAC,CAAC,EACvD,CAAC,EAWP,CACF,CAAC2D,OAAA,CAAAzF,aAAA,CAAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"dataProcessor.js","names":["DataProcessor","constructor","storage","_defineProperty","Set","updateData","visitorCode","dataItem","storageData","read","or","dereferencedData","dereferenceTargetingData","visitorReference","data","type","KameleoonData","CustomData","hasCustomDataKey","parameters","key","nestedKey","index","toString","value","updateNestedField","createNestedField","storedCustomDataIndexes","add","PageView","f","timestamps","length","Date","now","existingData","urlAddress","forEach","timestamp","Utilities","insertInOrderedListMutably","list","element","order","Order","Ascending","referrers","title","_objectSpread","Conversion","hasConversionDataKey","updateArrayField","createArrayField","VisitsData","hasVisitsKey","existingVisits","visits","visit","updateField","createField","hasDataKey","storedDataTypes","write","createReference","linkedVisitor","ok","getLinkedVisitor","visitorData","customData","cleanupOutdatedTargetingData","targetingCleanupInterval","targetingData","targetingDataLifetime","Milliseconds","Minute","DEFAULT_CLEANUP_INTERVAL","currentTime","Object","keys","kameleoonVisitorData","entries","pageView","conversion","rest","_objectWithoutProperties","_excluded","isDataExpired","lastActivityTime","delete","clear","url","splice","indexOf","getTargetingData","Err","error","Ok","referredVisitorCode","storedDataTypeList","storedCustomDataIndexList","a","push","b","exports"],"sources":["../../src/kameleoonData/dataProcessor.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { IStorage } from 'src/storage';\nimport {\n DereferencedTargetingDataType,\n TargetingDataType,\n VisitorReference,\n} from 'src/targeting';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { Order } from 'src/utilities/types';\nimport { Milliseconds } from 'src/types';\nimport { DEFAULT_CLEANUP_INTERVAL } from './constants';\nimport {\n ArrayFieldParametersType,\n ConversionDataType,\n CustomDataType,\n DereferenceTargetingDataResultType,\n ExistingArrayDataType,\n ExistingDataType,\n ExistingNestedDataType,\n ExistingPageViewDataType,\n ExistingVisitsDataType,\n FieldParametersType,\n KameleoonData,\n KameleoonDataType,\n KameleoonVisitorDataType,\n NestedFieldParametersType,\n PageViewDataType,\n VisitsDataType,\n} from './types';\n\ninterface IDataProcessor {\n updateData(\n visitorCode: string,\n dataItem: KameleoonDataType,\n ): Result<void, KameleoonError>;\n createReference(visitorCode: string, linkedVisitor: VisitorReference): void;\n cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void;\n getTargetingData(\n visitorCode: string,\n ): Result<KameleoonVisitorDataType | null, KameleoonError>;\n getLinkedVisitor(visitorCode: string, index: number): string | null;\n}\n\nexport class DataProcessor implements IDataProcessor {\n private storage: IStorage<TargetingDataType>;\n private storedDataTypes: Set<KameleoonData> = new Set([]);\n private storedCustomDataIndexes: Set<number> = new Set([]);\n\n constructor(storage: IStorage<TargetingDataType>) {\n this.storage = storage;\n }\n\n // --- Note ---\n // Following code is optimized for performance:\n // - We don't want to copy the whole object every time we add new data\n // - So we are manually checking the keys existence and mutating targeting data directly\n // - Numerous type casts are required because we can't narrow down nested `targetingData` types by using assertion functions\n public updateData(\n visitorCode: string,\n dataItem: KameleoonDataType,\n ): Result<void, KameleoonError> {\n const storageData = this.storage.read().or({});\n const dereferencedData = this.dereferenceTargetingData(\n storageData,\n visitorCode,\n );\n const visitorReference = dereferencedData?.visitorReference || visitorCode;\n\n switch (dataItem.data.type) {\n case KameleoonData.CustomData: {\n const data = dataItem.data as CustomDataType;\n const hasCustomDataKey =\n dereferencedData && KameleoonData.CustomData in dereferencedData.data;\n const parameters: NestedFieldParametersType = {\n visitorCode: visitorReference,\n data: storageData as DereferencedTargetingDataType,\n key: KameleoonData.CustomData,\n nestedKey: data.index.toString(),\n value: data,\n };\n\n if (hasCustomDataKey) {\n this.updateNestedField(parameters);\n } else {\n this.createNestedField(parameters);\n }\n\n // --- Note ---\n // Here we add CustomData index to storedCustomDataIndexes to later track if it is added to storage\n this.storedCustomDataIndexes.add(data.index);\n\n break;\n }\n case KameleoonData.PageView: {\n const data = dataItem.data as PageViewDataType;\n\n // --- Note ---\n // We assign `timestamps` to `Date.now()` if it's empty\n // Not upon data item creation because it makes no sense in terms\n // of data flow to have some indication of data activity before it was added\n if (!data.timestamps.length) {\n data.timestamps = [Date.now()];\n }\n\n const existingData =\n dereferencedData &&\n KameleoonData.PageView in dereferencedData.data &&\n (dereferencedData.data[data.type] as ExistingPageViewDataType)?.[\n data.urlAddress\n ];\n\n const parameters: NestedFieldParametersType = {\n visitorCode: visitorReference,\n data: storageData as DereferencedTargetingDataType,\n key: KameleoonData.PageView,\n nestedKey: data.urlAddress,\n value: data,\n };\n\n if (existingData) {\n // --- Note ---\n // Updating existing `PageView` properties by pushing new timestamps\n // and potentially changing referrers and title\n data.timestamps.forEach((timestamp) => {\n Utilities.insertInOrderedListMutably({\n list: existingData.timestamps,\n element: timestamp,\n order: Order.Ascending,\n });\n });\n\n [existingData.referrers, existingData.title] = [\n data.referrers,\n data.title,\n ];\n\n this.updateNestedField({ ...parameters, value: existingData });\n } else {\n this.createNestedField(parameters);\n }\n\n break;\n }\n case KameleoonData.Conversion: {\n const data = dataItem.data as ConversionDataType;\n const hasConversionDataKey =\n dereferencedData && KameleoonData.Conversion in dereferencedData.data;\n const parameters: ArrayFieldParametersType = {\n visitorCode: visitorReference,\n data: storageData as DereferencedTargetingDataType,\n key: KameleoonData.Conversion,\n value: data,\n };\n\n if (hasConversionDataKey) {\n this.updateArrayField(parameters);\n } else {\n this.createArrayField(parameters);\n }\n\n break;\n }\n case KameleoonData.VisitsData: {\n const data = dataItem.data as VisitsDataType;\n const hasVisitsKey =\n dereferencedData && KameleoonData.VisitsData in dereferencedData.data;\n const parameters: FieldParametersType = {\n visitorCode: visitorReference,\n data: storageData as DereferencedTargetingDataType,\n key: KameleoonData.VisitsData,\n value: data,\n };\n\n // -- Change directly if `[key]` exists\n if (hasVisitsKey) {\n const existingVisits = dereferencedData.data[\n data.type\n ] as ExistingVisitsDataType;\n\n // --- Note ---\n // We are preserving the order of visits\n existingVisits.visits.forEach((visit) => {\n Utilities.insertInOrderedListMutably({\n list: data.visits,\n element: visit,\n order: Order.Ascending,\n });\n });\n\n this.updateField({\n ...parameters,\n value: {\n ...data,\n visits: data.visits,\n },\n });\n } else {\n this.createField(parameters);\n }\n\n break;\n }\n default: {\n const { data } = dataItem;\n const hasDataKey =\n dereferencedData && data.type in dereferencedData.data;\n const parameters: FieldParametersType = {\n visitorCode: visitorReference,\n data: storageData as DereferencedTargetingDataType,\n key: data.type,\n // --- Note ---\n // At this point TypeScript can not infer that value is subset of only\n // what is left for `default` case\n value: data as FieldParametersType['value'],\n };\n\n if (hasDataKey) {\n this.updateField(parameters);\n } else {\n this.createField(parameters);\n }\n\n // --- Note ---\n // Here we add Browser, Device, Geolocation, OperatingSystem, KameleoonConversionScore to storedDataTypes\n // Later track if it is added to storage\n this.storedDataTypes.add(data.type);\n }\n }\n\n return this.storage.write(storageData);\n }\n\n public createReference(\n visitorCode: string,\n linkedVisitor: VisitorReference,\n ): void {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return;\n }\n\n // --- Note ---\n // Provided(linked) visitor is now pointing to the visitor code\n storageData.data[linkedVisitor] = visitorCode;\n\n this.storage.write(storageData.data);\n }\n\n public getLinkedVisitor(\n visitorCode: string,\n index: number | null,\n ): string | null {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return null;\n }\n\n if (typeof storageData.data[visitorCode] === 'string') {\n return storageData.data[visitorCode] as string;\n }\n\n if (index === null) {\n return null;\n }\n\n const visitorData = storageData.data[\n visitorCode\n ] as KameleoonVisitorDataType;\n\n if (!visitorData) {\n return null;\n }\n\n const customData = visitorData[KameleoonData.CustomData];\n\n if (customData && customData[index]) {\n return (customData[index] as CustomDataType).value[0];\n }\n\n return null;\n }\n\n public cleanupOutdatedTargetingData(targetingCleanupInterval?: number): void {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return;\n }\n\n const targetingData = storageData.data;\n const targetingDataLifetime = targetingCleanupInterval\n ? targetingCleanupInterval * Milliseconds.Minute\n : DEFAULT_CLEANUP_INTERVAL * Milliseconds.Minute;\n\n const currentTime = Date.now();\n\n // --- Note (Weird Thing) ---\n // Generally the check is not needed\n // If the `targetingData` is empty the loop will not be executed\n // But here something weird happens and we'are getting `TypeError` here\n // Even logging `Object.keys().length` or `Object.entries().length` solves the issue somehow\n // You can see the issue by commenting the following `if` statement and waiting for a data cleanup\n // TODO: investigate it later (probably related to object copying?)\n if (!Object.keys(targetingData).length) {\n return;\n }\n\n for (const [visitorCode, kameleoonVisitorData] of Object.entries(\n targetingData,\n )) {\n if (typeof kameleoonVisitorData === 'string') {\n delete targetingData[visitorCode];\n continue;\n }\n\n const visitorData = kameleoonVisitorData;\n\n const { customData, pageView, conversion, ...rest } = visitorData;\n\n // TODO: This way of cleaning up data is not optimal\n // And will be changed when sessions are introduced\n if (customData) {\n for (const [index, dataItem] of Object.entries(customData)) {\n if (dataItem) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = visitorData[KameleoonData.CustomData];\n\n if (isDataExpired && existingData) {\n this.storedCustomDataIndexes.delete(Number(index));\n delete existingData[Number(index)];\n }\n\n if (existingData && !Object.keys(existingData).length) {\n this.storedCustomDataIndexes.clear();\n delete targetingData[KameleoonData.CustomData];\n }\n }\n }\n }\n\n if (pageView) {\n for (const [url, dataItem] of Object.entries(pageView)) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = visitorData[KameleoonData.PageView];\n\n if (isDataExpired && existingData) {\n delete existingData[url];\n }\n\n if (existingData && !Object.keys(existingData).length) {\n delete visitorData[KameleoonData.PageView];\n }\n }\n }\n\n if (conversion) {\n for (const dataItem of conversion) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n const existingData = visitorData[KameleoonData.Conversion];\n\n if (isDataExpired && existingData) {\n existingData.splice(existingData.indexOf(dataItem), 1);\n }\n\n if (existingData && !existingData.length) {\n delete visitorData[KameleoonData.Conversion];\n }\n }\n }\n\n for (const [key, dataItem] of Object.entries(rest)) {\n const isDataExpired =\n dataItem.lastActivityTime + targetingDataLifetime < currentTime;\n\n if (isDataExpired) {\n delete visitorData[key as KameleoonData];\n this.storedDataTypes.delete(key as KameleoonData);\n }\n }\n\n if (!Object.keys(targetingData[visitorCode]).length) {\n this.storedDataTypes.clear();\n this.storedCustomDataIndexes.clear();\n delete targetingData[visitorCode];\n }\n }\n\n this.storage.write(targetingData);\n }\n\n public getTargetingData(\n visitorCode: string,\n ): Result<KameleoonVisitorDataType | null, KameleoonError> {\n const storageData = this.storage.read();\n\n if (!storageData.ok) {\n return Err(storageData.error);\n }\n\n const dereferencedData = this.dereferenceTargetingData(\n storageData.data,\n visitorCode,\n );\n\n if (!dereferencedData) {\n return Ok(null);\n }\n\n return Ok(dereferencedData.data);\n }\n\n private dereferenceTargetingData(\n data: TargetingDataType,\n visitorCode: string,\n ): DereferenceTargetingDataResultType | null {\n if (!data[visitorCode]) {\n return null;\n }\n\n // --- Note ---\n // Visitor reference can not refer to another visitor reference\n if (typeof data[visitorCode] === 'string') {\n const referredVisitorCode = data[visitorCode] as VisitorReference;\n\n return {\n data: data[referredVisitorCode] as KameleoonVisitorDataType,\n visitorReference: referredVisitorCode,\n };\n }\n\n return {\n data: data[visitorCode] as KameleoonVisitorDataType,\n visitorReference: visitorCode,\n };\n }\n\n get storedDataTypeList(): Set<KameleoonData> {\n return this.storedDataTypes;\n }\n\n get storedCustomDataIndexList(): Set<number> {\n return this.storedCustomDataIndexes;\n }\n\n private updateField({\n visitorCode,\n key,\n value,\n data,\n }: FieldParametersType): void {\n (data[visitorCode][key] as ExistingDataType<typeof key>) = {\n ...value,\n lastActivityTime: Date.now(),\n };\n }\n\n private createField({\n visitorCode,\n key,\n value,\n data,\n }: FieldParametersType): void {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: { ...value, lastActivityTime: Date.now() },\n };\n }\n\n private updateArrayField({\n visitorCode,\n key,\n value,\n data,\n }: ArrayFieldParametersType): void {\n (data[visitorCode][key] as ExistingArrayDataType).push({\n ...value,\n lastActivityTime: Date.now(),\n });\n }\n\n private createArrayField({\n visitorCode,\n key,\n value,\n data,\n }: ArrayFieldParametersType): void {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: [{ ...value, lastActivityTime: Date.now() }],\n };\n }\n\n private updateNestedField({\n visitorCode,\n key,\n nestedKey,\n value,\n data,\n }: NestedFieldParametersType): void {\n (data[visitorCode][key] as ExistingNestedDataType)[nestedKey] = {\n ...value,\n lastActivityTime: Date.now(),\n };\n }\n\n private createNestedField({\n visitorCode,\n key,\n nestedKey,\n value,\n data,\n }: NestedFieldParametersType): void {\n if (!data[visitorCode]?.[key]) {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: {\n [nestedKey]: { ...value, lastActivityTime: Date.now() },\n },\n };\n } else {\n data[visitorCode] = {\n ...data[visitorCode],\n [key]: {\n ...data[visitorCode][key],\n [nestedKey]: { ...value, lastActivityTime: Date.now() },\n },\n };\n }\n }\n}\n"],"mappings":"i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BAAgB,CAAEtD,IAAI,CAACC,GAAG,CAAC,CAAC,EAEhC,CAEQR,iBAAiBA,CAAA0E,CAAA,CAMW,KAAAE,CAAA,IANV,CACxBhG,WAAW,CAAXA,CAAW,CACXc,GAAG,CAAHA,CAAG,CACHC,SAAS,CAATA,CAAS,CACTG,KAAK,CAALA,CAAK,CACLV,IAAI,CAAJA,CACyB,CAAC,CAAAsF,CAAA,CASxBtF,CAAI,CAACR,CAAW,CAAC,SAAAgG,CAAA,CARdxF,CAAI,CAACR,CAAW,CAAC,YAAAgG,CAAA,EAAjBA,CAAA,CAAoBlF,CAAG,CAAC,CAAA4B,aAAA,CAAAA,aAAA,IAStBlC,CAAI,CAACR,CAAW,CAAC,MACpB,CAACc,CAAG,EAAA4B,aAAA,CAAAA,aAAA,IACClC,CAAI,CAACR,CAAW,CAAC,CAACc,CAAG,CAAC,MACzB,CAACC,CAAS,EAAA2B,aAAA,CAAAA,aAAA,IAAQxB,CAAK,MAAE+D,gBAAgB,CAAEtD,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,EACxD,GAAAc,aAAA,CAAAA,aAAA,IAXElC,CAAI,CAACR,CAAW,CAAC,MACpB,CAACc,CAAG,EAAG,CACL,CAACC,CAAS,EAAA2B,aAAA,CAAAA,aAAA,IAAQxB,CAAK,MAAE+D,gBAAgB,CAAEtD,IAAI,CAACC,GAAG,CAAC,CAAC,EACvD,CAAC,EAWP,CACF,CAACqE,OAAA,CAAAvG,aAAA,CAAAA,aAAA"}
|
|
@@ -11,24 +11,15 @@ export declare class Device implements IKameleoonData {
|
|
|
11
11
|
* @param {DeviceType} device - one of the available device types from `DeviceType` enum
|
|
12
12
|
* */
|
|
13
13
|
constructor(device: DeviceType);
|
|
14
|
-
/**
|
|
15
|
-
* @property url - url for the current data type used for events tracking
|
|
16
|
-
* */
|
|
17
14
|
get url(): string;
|
|
18
|
-
/**
|
|
19
|
-
* @property data - data of the current class instance
|
|
20
|
-
* */
|
|
21
15
|
get data(): DeviceDataType;
|
|
22
|
-
/**
|
|
23
|
-
* @property isSent - signifying if the data was sent already tracked
|
|
24
|
-
* */
|
|
25
16
|
get isSent(): boolean;
|
|
26
17
|
set isSent(value: boolean);
|
|
27
18
|
/**
|
|
28
19
|
* @private
|
|
29
|
-
* @method
|
|
30
|
-
* @param {VisitType
|
|
20
|
+
* @method _fromVisit - an internal method for creating an instance of Device class from a visit
|
|
21
|
+
* @param {VisitType} visit - a visit
|
|
31
22
|
* @returns {Device | undefined} an instance of Device class or undefined if browser can not be found among visits
|
|
32
23
|
* */
|
|
33
|
-
static
|
|
24
|
+
static _fromVisit(visit: VisitType): Device | undefined;
|
|
34
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _requester=require("../requester"),_types=require("./types");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 Device{constructor(a){_defineProperty(this,"device",void 0),_defineProperty(this,"sent",void 0),this.device=a,this.sent=!1}get url(){return this.device?_requester.UrlEventType.StaticData+_requester.UrlParameter.DeviceType+this.device:""}get data(){return{device:this.device,type:_types.KameleoonData.Device,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _requester=require("../requester"),_types=require("./types");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 Device{constructor(a){_defineProperty(this,"device",void 0),_defineProperty(this,"sent",void 0),this.device=a,this.sent=!1}get url(){return this.device?_requester.UrlEventType.StaticData+_requester.UrlParameter.DeviceType+this.device:""}get data(){return{device:this.device,type:_types.KameleoonData.Device,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static _fromVisit(a){var b;return null!==(b=a.staticDataEvent)&&void 0!==b&&b.data.deviceType?new Device(a.staticDataEvent.data.deviceType):void 0}}exports.Device=Device;
|
|
2
2
|
//# sourceMappingURL=device.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","names":["Device","constructor","device","_defineProperty","sent","url","UrlEventType","StaticData","UrlParameter","DeviceType","data","type","KameleoonData","isSent","value","
|
|
1
|
+
{"version":3,"file":"device.js","names":["Device","constructor","device","_defineProperty","sent","url","UrlEventType","StaticData","UrlParameter","DeviceType","data","type","KameleoonData","isSent","value","_fromVisit","visit","b","staticDataEvent","deviceType","exports"],"sources":["../../src/kameleoonData/device.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport {\n DeviceDataType,\n DeviceType,\n IKameleoonData,\n KameleoonData,\n} from './types';\n\n/**\n * @class\n * Device - a class for creating an instance for device of a certain type\n * */\nexport class Device implements IKameleoonData {\n private device: DeviceType;\n private sent: boolean;\n\n /**\n * @param {DeviceType} device - one of the available device types from `DeviceType` enum\n * */\n constructor(device: DeviceType) {\n this.device = device;\n this.sent = false;\n }\n\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.device) {\n return '';\n }\n\n return UrlEventType.StaticData + UrlParameter.DeviceType + this.device;\n }\n\n get data(): DeviceDataType {\n return {\n device: this.device,\n type: KameleoonData.Device,\n sent: this.sent,\n };\n }\n\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @private\n * @method _fromVisit - an internal method for creating an instance of Device class from a visit\n * @param {VisitType} visit - a visit\n * @returns {Device | undefined} an instance of Device class or undefined if browser can not be found among visits\n * */\n public static _fromVisit(visit: VisitType): Device | undefined {\n if (visit.staticDataEvent?.data.deviceType) {\n return new Device(visit.staticDataEvent.data.deviceType);\n }\n\n return undefined;\n }\n}\n"],"mappings":"8pBAYO,KAAM,CAAAA,MAAiC,CAO5CC,WAAWA,CAACC,CAAkB,CAAE,CAAAC,eAAA,uBAAAA,eAAA,qBAC9B,IAAI,CAACD,MAAM,CAAGA,CAAM,CACpB,IAAI,CAACE,IAAI,GACX,CAEA,GAAI,CAAAC,GAAGA,CAAA,CAAW,OAIX,KAAI,CAACH,MAAM,CAITI,uBAAY,CAACC,UAAU,CAAGC,uBAAY,CAACC,UAAU,CAAG,IAAI,CAACP,MAAM,CAH7D,EAIX,CAEA,GAAI,CAAAQ,IAAIA,CAAA,CAAmB,CACzB,MAAO,CACLR,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBS,IAAI,CAAEC,oBAAa,CAACZ,MAAM,CAC1BI,IAAI,CAAE,IAAI,CAACA,IACb,CACF,CAEA,GAAI,CAAAS,MAAMA,CAAA,CAAY,CACpB,MAAO,KAAI,CAACT,IACd,CAEA,GAAI,CAAAS,MAAMA,CAACC,CAAc,CAAE,CACzB,IAAI,CAACV,IAAI,CAAGU,CACd,CAQA,MAAc,CAAAC,UAAUA,CAACC,CAAgB,CAAsB,KAAAC,CAAA,gBAAAA,CAAA,CACzDD,CAAK,CAACE,eAAe,YAAAD,CAAA,EAArBA,CAAA,CAAuBP,IAAI,CAACS,UAAU,CACjC,GAAI,CAAAnB,MAAM,CAACgB,CAAK,CAACE,eAAe,CAACR,IAAI,CAACS,UAAU,CAAC,OAI5D,CACF,CAACC,OAAA,CAAApB,MAAA,CAAAA,MAAA"}
|
|
@@ -29,24 +29,15 @@ export declare class GeolocationData implements IKameleoonData {
|
|
|
29
29
|
*
|
|
30
30
|
* */
|
|
31
31
|
constructor({ country, region, city, postalCode, coordinates, }: GeolocationInfoType);
|
|
32
|
-
/**
|
|
33
|
-
* @property url - url for the current data type used for events tracking
|
|
34
|
-
* */
|
|
35
32
|
get url(): string;
|
|
36
|
-
/**
|
|
37
|
-
* @property data - data of the current class instance
|
|
38
|
-
* */
|
|
39
33
|
get data(): GeolocationDataType;
|
|
40
|
-
/**
|
|
41
|
-
* @property isSent - signifying if the data was sent already tracked
|
|
42
|
-
* */
|
|
43
34
|
get isSent(): boolean;
|
|
44
35
|
set isSent(value: boolean);
|
|
45
36
|
/**
|
|
46
37
|
* @private
|
|
47
|
-
* @method
|
|
48
|
-
* @param {VisitType
|
|
38
|
+
* @method _fromVisit - an internal method for creating an instance of GeolocationData class from a visit
|
|
39
|
+
* @param {VisitType} visit - a visit
|
|
49
40
|
* @returns {GeolocationData | undefined} an instance of GeolocationData class or undefined if geolocation can not be found among visits
|
|
50
41
|
* */
|
|
51
|
-
static
|
|
42
|
+
static _fromVisit(visit: VisitType): GeolocationData | undefined;
|
|
52
43
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeolocationData=void 0;var _requester=require("../requester"),_types=require("./types");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 GeolocationData{constructor(a){let{country:b,region:c,city:d,postalCode:e,coordinates:f}=a;_defineProperty(this,"country",void 0),_defineProperty(this,"region",void 0),_defineProperty(this,"city",void 0),_defineProperty(this,"postalCode",void 0),_defineProperty(this,"coordinates",void 0),_defineProperty(this,"sent",void 0),this.country=b,this.region=c,this.city=d,this.postalCode=e,this.coordinates=f,this.sent=!1}get url(){const a=this.region?_requester.UrlParameter.Region+encodeURIComponent(this.region):"",b=this.city?_requester.UrlParameter.City+encodeURIComponent(this.city):"",c=this.postalCode?_requester.UrlParameter.PostalCode+encodeURIComponent(this.postalCode):"",d=this.coordinates?_requester.UrlParameter.Latitude+this.coordinates[0]+_requester.UrlParameter.Longitude+this.coordinates[1]:"";return _requester.UrlEventType.Geolocation+_requester.UrlParameter.Country+encodeURIComponent(this.country)+a+b+c+d}get data(){return{type:_types.KameleoonData.GeolocationData,country:this.country,region:this.region,city:this.city,postalCode:this.postalCode,coordinates:this.coordinates,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeolocationData=void 0;var _requester=require("../requester"),_types=require("./types");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 GeolocationData{constructor(a){let{country:b,region:c,city:d,postalCode:e,coordinates:f}=a;_defineProperty(this,"country",void 0),_defineProperty(this,"region",void 0),_defineProperty(this,"city",void 0),_defineProperty(this,"postalCode",void 0),_defineProperty(this,"coordinates",void 0),_defineProperty(this,"sent",void 0),this.country=b,this.region=c,this.city=d,this.postalCode=e,this.coordinates=f,this.sent=!1}get url(){const a=this.region?_requester.UrlParameter.Region+encodeURIComponent(this.region):"",b=this.city?_requester.UrlParameter.City+encodeURIComponent(this.city):"",c=this.postalCode?_requester.UrlParameter.PostalCode+encodeURIComponent(this.postalCode):"",d=this.coordinates?_requester.UrlParameter.Latitude+this.coordinates[0]+_requester.UrlParameter.Longitude+this.coordinates[1]:"";return _requester.UrlEventType.Geolocation+_requester.UrlParameter.Country+encodeURIComponent(this.country)+a+b+c+d}get data(){return{type:_types.KameleoonData.GeolocationData,country:this.country,region:this.region,city:this.city,postalCode:this.postalCode,coordinates:this.coordinates,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static _fromVisit(a){var b;if(!(null!==(b=a.geolocationEvents)&&void 0!==b&&b.length))return;let c;for(const b of a.geolocationEvents){const{data:a}=b;a.country&&(c=a)}const{country:d,region:e,city:f}=c||{};if(d)return e&&f?new GeolocationData({country:d,region:e,city:f}):e?new GeolocationData({country:d,region:e}):new GeolocationData({country:d})}}exports.GeolocationData=GeolocationData;
|
|
2
2
|
//# sourceMappingURL=geolocation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocation.js","names":["GeolocationData","constructor","a","country","region","city","postalCode","coordinates","_defineProperty","sent","url","UrlParameter","Region","encodeURIComponent","City","PostalCode","Latitude","Longitude","UrlEventType","Geolocation","Country","data","type","KameleoonData","isSent","value","
|
|
1
|
+
{"version":3,"file":"geolocation.js","names":["GeolocationData","constructor","a","country","region","city","postalCode","coordinates","_defineProperty","sent","url","UrlParameter","Region","encodeURIComponent","City","PostalCode","Latitude","Longitude","UrlEventType","Geolocation","Country","data","type","KameleoonData","isSent","value","_fromVisit","visit","b","geolocationEvents","length","geolocationData","geolocationEvent","exports"],"sources":["../../src/kameleoonData/geolocation.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport { GeolocationEventType } from 'src/requester/types';\nimport {\n IKameleoonData,\n KameleoonData,\n GeolocationInfoType,\n GeolocationDataType,\n} from './types';\n\n/**\n * @class\n * Geolocation - a class for creating an instance for geolocation data\n * */\nexport class GeolocationData implements IKameleoonData {\n private country: string;\n private region?: string;\n private city?: string;\n private postalCode?: string;\n private coordinates?: [number, number];\n private sent: boolean;\n\n /**\n * @param {GeolocationInfoType} geolocationInfo - an object containing information about geolocation of a visitor\n * @example\n * ```ts\n * // Visitor is located at Triumph Arch in Paris, France\n * const location: GeolocationDataType = {\n * country: 'France',\n * region: 'Île-de-France',\n * city: 'Paris',\n * postalCode: '75008',\n * coordinates: [48.8738, 2.295]\n * };\n *\n * const geolocation = new GeolocationData(location);\n * ```\n *\n * */\n constructor({\n country,\n region,\n city,\n postalCode,\n coordinates,\n }: GeolocationInfoType) {\n this.country = country;\n this.region = region;\n this.city = city;\n this.postalCode = postalCode;\n this.coordinates = coordinates;\n this.sent = false;\n }\n\n get url(): string {\n const region = this.region\n ? UrlParameter.Region + encodeURIComponent(this.region)\n : '';\n const city = this.city\n ? UrlParameter.City + encodeURIComponent(this.city)\n : '';\n const postalCode = this.postalCode\n ? UrlParameter.PostalCode + encodeURIComponent(this.postalCode)\n : '';\n const coordinates = this.coordinates\n ? UrlParameter.Latitude +\n this.coordinates[0] +\n UrlParameter.Longitude +\n this.coordinates[1]\n : '';\n\n return (\n UrlEventType.Geolocation +\n UrlParameter.Country +\n encodeURIComponent(this.country) +\n region +\n city +\n postalCode +\n coordinates\n );\n }\n\n get data(): GeolocationDataType {\n return {\n type: KameleoonData.GeolocationData,\n country: this.country,\n region: this.region,\n city: this.city,\n postalCode: this.postalCode,\n coordinates: this.coordinates,\n sent: this.sent,\n };\n }\n\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @private\n * @method _fromVisit - an internal method for creating an instance of GeolocationData class from a visit\n * @param {VisitType} visit - a visit\n * @returns {GeolocationData | undefined} an instance of GeolocationData class or undefined if geolocation can not be found among visits\n * */\n public static _fromVisit(visit: VisitType): GeolocationData | undefined {\n if (!visit.geolocationEvents?.length) {\n return undefined;\n }\n\n let geolocationData: GeolocationEventType['data'] | undefined = undefined;\n\n for (const geolocationEvent of visit.geolocationEvents) {\n const { data } = geolocationEvent;\n\n if (data.country) {\n geolocationData = data;\n }\n }\n\n // --- Note ---\n // We only take `country`, `region`, and `city` from geolocation event ignoring other fields\n // as they are not participating in targeting, and visits data won't be tracked again\n const { country, region, city } = geolocationData || {};\n\n if (country) {\n if (region && city) {\n return new GeolocationData({ country, region, city });\n } else if (region) {\n return new GeolocationData({ country, region });\n } else {\n return new GeolocationData({ country });\n }\n }\n }\n}\n"],"mappings":"uqBAaO,KAAM,CAAAA,eAA0C,CAyBrDC,WAAWA,CAAAC,CAAA,CAMa,IANZ,CACVC,OAAO,CAAPA,CAAO,CACPC,MAAM,CAANA,CAAM,CACNC,IAAI,CAAJA,CAAI,CACJC,UAAU,CAAVA,CAAU,CACVC,WAAW,CAAXA,CACmB,CAAC,CAAAL,CAAA,CAAAM,eAAA,wBAAAA,eAAA,uBAAAA,eAAA,qBAAAA,eAAA,2BAAAA,eAAA,4BAAAA,eAAA,qBACpB,IAAI,CAACL,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACC,MAAM,CAAGA,CAAM,CACpB,IAAI,CAACC,IAAI,CAAGA,CAAI,CAChB,IAAI,CAACC,UAAU,CAAGA,CAAU,CAC5B,IAAI,CAACC,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACE,IAAI,GACX,CAEA,GAAI,CAAAC,GAAGA,CAAA,CAAW,MACV,CAAAN,CAAM,CAAG,IAAI,CAACA,MAAM,CACtBO,uBAAY,CAACC,MAAM,CAAGC,kBAAkB,CAAC,IAAI,CAACT,MAAM,CAAC,CACrD,EAAE,CACAC,CAAI,CAAG,IAAI,CAACA,IAAI,CAClBM,uBAAY,CAACG,IAAI,CAAGD,kBAAkB,CAAC,IAAI,CAACR,IAAI,CAAC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IAAI,CAAJA,CAAK,CAAC,CAAGW,CAAgB,CAE7BX,CAAI,CAAClB,OAAO,GACd4B,CAAe,CAAGV,CAAI,CAE1B,CAKA,KAAM,CAAElB,OAAO,CAAPA,CAAO,CAAEC,MAAM,CAANA,CAAM,CAAEC,IAAI,CAAJA,CAAK,CAAC,CAAG0B,CAAe,EAAI,CAAC,CAAC,CAEvD,GAAI5B,CAAO,OACL,CAAAC,CAAM,EAAIC,CAAI,CACT,GAAI,CAAAL,eAAe,CAAC,CAAEG,OAAO,CAAPA,CAAO,CAAEC,MAAM,CAANA,CAAM,CAAEC,IAAI,CAAJA,CAAK,CAAC,CAAC,CAC5CD,CAAM,CACR,GAAI,CAAAJ,eAAe,CAAC,CAAEG,OAAO,CAAPA,CAAO,CAAEC,MAAM,CAANA,CAAO,CAAC,CAAC,CAExC,GAAI,CAAAJ,eAAe,CAAC,CAAEG,OAAO,CAAPA,CAAQ,CAAC,CAG5C,CACF,CAAC8B,OAAA,CAAAjC,eAAA,CAAAA,eAAA"}
|
|
@@ -9,6 +9,7 @@ export { GeolocationData } from './geolocation';
|
|
|
9
9
|
export { OperatingSystem } from './operatingSystem';
|
|
10
10
|
export { ApplicationVersion } from './applicationVersion';
|
|
11
11
|
export { VisitsData } from './visitsData';
|
|
12
|
+
export { KameleoonConversionScore } from './kameleoonConversionScore';
|
|
12
13
|
export { DEFAULT_CLEANUP_INTERVAL } from './constants';
|
|
13
14
|
export { DeviceType, CookieType, VisitsDataType, BrowserType, KameleoonData, DeviceDataType, CustomDataType, BrowserDataType, BrowserIndexMap, PageViewDataType, KameleoonDataType, UserAgentDataType, ConversionDataType, OperatingSystemType, GeolocationInfoType, KameleoonDataItemType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './types';
|
|
14
15
|
export { DataManager } from './dataManager';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function(){return _applicationVersion.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function(){return _types.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _browser.Browser}}),Object.defineProperty(exports,"BrowserDataType",{enumerable:!0,get:function(){return _types.BrowserDataType}}),Object.defineProperty(exports,"BrowserIndexMap",{enumerable:!0,get:function(){return _types.BrowserIndexMap}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function(){return _types.BrowserType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _conversion.Conversion}}),Object.defineProperty(exports,"ConversionDataType",{enumerable:!0,get:function(){return _types.ConversionDataType}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function(){return _types.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _cookie.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function(){return _types.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _customData.CustomData}}),Object.defineProperty(exports,"CustomDataType",{enumerable:!0,get:function(){return _types.CustomDataType}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function(){return _constants.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DataManager",{enumerable:!0,get:function(){return _dataManager.DataManager}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _device.Device}}),Object.defineProperty(exports,"DeviceDataType",{enumerable:!0,get:function(){return _types.DeviceDataType}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function(){return _types.DeviceType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function(){return _geolocation.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function(){return _types.GeolocationInfoType}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function(){return _types.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataItemType",{enumerable:!0,get:function(){return _types.KameleoonDataItemType}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function(){return _types.KameleoonDataType}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _operatingSystem.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function(){return _types.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function(){return _pageView.PageView}}),Object.defineProperty(exports,"PageViewDataType",{enumerable:!0,get:function(){return _types.PageViewDataType}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function(){return _types.PageViewParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return _userAgent.UserAgent}}),Object.defineProperty(exports,"UserAgentDataType",{enumerable:!0,get:function(){return _types.UserAgentDataType}}),Object.defineProperty(exports,"VisitsData",{enumerable:!0,get:function(){return _visitsData.VisitsData}}),Object.defineProperty(exports,"VisitsDataType",{enumerable:!0,get:function(){return _types.VisitsDataType}});var _device=require("./device"),_cookie=require("./cookie"),_browser=require("./browser"),_pageView=require("./pageView"),_userAgent=require("./userAgent"),_customData=require("./customData"),_conversion=require("./conversion"),_geolocation=require("./geolocation"),_operatingSystem=require("./operatingSystem"),_applicationVersion=require("./applicationVersion"),_visitsData=require("./visitsData"),_constants=require("./constants"),_types=require("./types"),_dataManager=require("./dataManager");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function(){return _applicationVersion.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function(){return _types.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _browser.Browser}}),Object.defineProperty(exports,"BrowserDataType",{enumerable:!0,get:function(){return _types.BrowserDataType}}),Object.defineProperty(exports,"BrowserIndexMap",{enumerable:!0,get:function(){return _types.BrowserIndexMap}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function(){return _types.BrowserType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _conversion.Conversion}}),Object.defineProperty(exports,"ConversionDataType",{enumerable:!0,get:function(){return _types.ConversionDataType}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function(){return _types.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _cookie.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function(){return _types.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _customData.CustomData}}),Object.defineProperty(exports,"CustomDataType",{enumerable:!0,get:function(){return _types.CustomDataType}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function(){return _constants.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DataManager",{enumerable:!0,get:function(){return _dataManager.DataManager}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _device.Device}}),Object.defineProperty(exports,"DeviceDataType",{enumerable:!0,get:function(){return _types.DeviceDataType}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function(){return _types.DeviceType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function(){return _geolocation.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function(){return _types.GeolocationInfoType}}),Object.defineProperty(exports,"KameleoonConversionScore",{enumerable:!0,get:function(){return _kameleoonConversionScore.KameleoonConversionScore}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function(){return _types.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataItemType",{enumerable:!0,get:function(){return _types.KameleoonDataItemType}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function(){return _types.KameleoonDataType}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _operatingSystem.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function(){return _types.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function(){return _pageView.PageView}}),Object.defineProperty(exports,"PageViewDataType",{enumerable:!0,get:function(){return _types.PageViewDataType}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function(){return _types.PageViewParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return _userAgent.UserAgent}}),Object.defineProperty(exports,"UserAgentDataType",{enumerable:!0,get:function(){return _types.UserAgentDataType}}),Object.defineProperty(exports,"VisitsData",{enumerable:!0,get:function(){return _visitsData.VisitsData}}),Object.defineProperty(exports,"VisitsDataType",{enumerable:!0,get:function(){return _types.VisitsDataType}});var _device=require("./device"),_cookie=require("./cookie"),_browser=require("./browser"),_pageView=require("./pageView"),_userAgent=require("./userAgent"),_customData=require("./customData"),_conversion=require("./conversion"),_geolocation=require("./geolocation"),_operatingSystem=require("./operatingSystem"),_applicationVersion=require("./applicationVersion"),_visitsData=require("./visitsData"),_kameleoonConversionScore=require("./kameleoonConversionScore"),_constants=require("./constants"),_types=require("./types"),_dataManager=require("./dataManager");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/kameleoonData/index.ts"],"sourcesContent":["export { Device } from './device';\nexport { Cookie } from './cookie';\nexport { Browser } from './browser';\nexport { PageView } from './pageView';\nexport { UserAgent } from './userAgent';\nexport { CustomData } from './customData';\nexport { Conversion } from './conversion';\nexport { GeolocationData } from './geolocation';\nexport { OperatingSystem } from './operatingSystem';\nexport { ApplicationVersion } from './applicationVersion';\nexport { VisitsData } from './visitsData';\nexport { DEFAULT_CLEANUP_INTERVAL } from './constants';\nexport {\n DeviceType,\n CookieType,\n VisitsDataType,\n BrowserType,\n KameleoonData,\n DeviceDataType,\n CustomDataType,\n BrowserDataType,\n BrowserIndexMap,\n PageViewDataType,\n KameleoonDataType,\n UserAgentDataType,\n ConversionDataType,\n OperatingSystemType,\n GeolocationInfoType,\n KameleoonDataItemType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './types';\nexport { DataManager } from './dataManager';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/kameleoonData/index.ts"],"sourcesContent":["export { Device } from './device';\nexport { Cookie } from './cookie';\nexport { Browser } from './browser';\nexport { PageView } from './pageView';\nexport { UserAgent } from './userAgent';\nexport { CustomData } from './customData';\nexport { Conversion } from './conversion';\nexport { GeolocationData } from './geolocation';\nexport { OperatingSystem } from './operatingSystem';\nexport { ApplicationVersion } from './applicationVersion';\nexport { VisitsData } from './visitsData';\nexport { KameleoonConversionScore } from './kameleoonConversionScore';\nexport { DEFAULT_CLEANUP_INTERVAL } from './constants';\nexport {\n DeviceType,\n CookieType,\n VisitsDataType,\n BrowserType,\n KameleoonData,\n DeviceDataType,\n CustomDataType,\n BrowserDataType,\n BrowserIndexMap,\n PageViewDataType,\n KameleoonDataType,\n UserAgentDataType,\n ConversionDataType,\n OperatingSystemType,\n GeolocationInfoType,\n KameleoonDataItemType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './types';\nexport { DataManager } from './dataManager';\n"],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IKameleoonData, KCSType, KCSDataType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
* KameleoonConversionScore - a class for creating an KCS Heat Range data
|
|
5
|
+
* */
|
|
6
|
+
export declare class KameleoonConversionScore implements IKameleoonData {
|
|
7
|
+
private kcs;
|
|
8
|
+
/**
|
|
9
|
+
* @param {KCSType} kcs - Kameleoon Conversion Score nested object
|
|
10
|
+
* */
|
|
11
|
+
constructor(kcs: KCSType);
|
|
12
|
+
get url(): string;
|
|
13
|
+
get data(): KCSDataType;
|
|
14
|
+
get isSent(): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonConversionScore=void 0;function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}class KameleoonConversionScore{constructor(a){_defineProperty(this,"kcs",void 0),this.kcs=a}get url(){return""}get data(){return{kcs:this.kcs,type:_types.KameleoonData.KameleoonConversionScore,sent:!0}}get isSent(){return!0}}exports.KameleoonConversionScore=KameleoonConversionScore;
|
|
2
|
+
//# sourceMappingURL=kameleoonConversionScore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kameleoonConversionScore.js","names":["_types","require","Object","defineProperty","exports","value","KameleoonConversionScore","_defineProperty","a","b","c","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","d","call","TypeError","String","Number","constructor","kcs","url","data","type","KameleoonData","sent","isSent"],"sources":["../../src/kameleoonData/kameleoonConversionScore.ts"],"sourcesContent":["import { IKameleoonData, KCSType, KCSDataType, KameleoonData } from './types';\n\n/**\n * @class\n * KameleoonConversionScore - a class for creating an KCS Heat Range data\n * */\nexport class KameleoonConversionScore implements IKameleoonData {\n private kcs: KCSType;\n\n /**\n * @param {KCSType} kcs - Kameleoon Conversion Score nested object\n * */\n constructor(kcs: KCSType) {\n this.kcs = kcs;\n }\n\n get url(): string {\n return '';\n }\n\n get data(): KCSDataType {\n return {\n kcs: this.kcs,\n type: KameleoonData.KameleoonConversionScore,\n sent: true,\n };\n }\n\n get isSent(): boolean {\n return true;\n }\n}\n"],"mappings":"aAAA,IAAAA,MAAA,C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,15 @@ export declare class OperatingSystem implements IKameleoonData {
|
|
|
11
11
|
* @param {OperatingSystemType} operatingSystem - one of the available operating system types from `OperatingSystemType` enum
|
|
12
12
|
* */
|
|
13
13
|
constructor(operatingSystem: OperatingSystemType);
|
|
14
|
-
/**
|
|
15
|
-
* @property url - url for the current data type used for events tracking
|
|
16
|
-
* */
|
|
17
14
|
get url(): string;
|
|
18
|
-
/**
|
|
19
|
-
* @property data - data of the current class instance
|
|
20
|
-
* */
|
|
21
15
|
get data(): OperatingSystemDataType;
|
|
22
|
-
/**
|
|
23
|
-
* @property isSent - signifying if the data was sent already tracked
|
|
24
|
-
* */
|
|
25
16
|
get isSent(): boolean;
|
|
26
17
|
set isSent(value: boolean);
|
|
27
18
|
/**
|
|
28
19
|
* @private
|
|
29
|
-
* @method
|
|
30
|
-
* @param {VisitType
|
|
20
|
+
* @method _fromVisit - a static method for creating an instance of OperatingSystem class from a visit
|
|
21
|
+
* @param {VisitType} visit - a visit
|
|
31
22
|
* @returns {OperatingSystem | undefined} an instance of OperatingSystem class or undefined
|
|
32
23
|
* */
|
|
33
|
-
static
|
|
24
|
+
static _fromVisit(visit: VisitType): OperatingSystem | undefined;
|
|
34
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystem=void 0;var _requester=require("../requester"),_types=require("./types");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 OperatingSystem{constructor(a){_defineProperty(this,"operatingSystem",void 0),_defineProperty(this,"sent",void 0),this.operatingSystem=a,this.sent=!1}get url(){return this.operatingSystem?_requester.UrlEventType.StaticData+_requester.UrlParameter.Os+this.operatingSystem+_requester.UrlParameter.OsIndex+_types.OperatingSystemIndexMap[this.operatingSystem]:""}get data(){return{operatingSystem:this.operatingSystem,type:_types.KameleoonData.OperatingSystem,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystem=void 0;var _requester=require("../requester"),_types=require("./types");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 OperatingSystem{constructor(a){_defineProperty(this,"operatingSystem",void 0),_defineProperty(this,"sent",void 0),this.operatingSystem=a,this.sent=!1}get url(){return this.operatingSystem?_requester.UrlEventType.StaticData+_requester.UrlParameter.Os+this.operatingSystem+_requester.UrlParameter.OsIndex+_types.OperatingSystemIndexMap[this.operatingSystem]:""}get data(){return{operatingSystem:this.operatingSystem,type:_types.KameleoonData.OperatingSystem,sent:this.sent}}get isSent(){return this.sent}set isSent(a){this.sent=a}static _fromVisit(a){if(a.staticDataEvent){const{os:b,osIndex:c}=a.staticDataEvent.data;if(b||"number"==typeof c){const a=null!==b&&void 0!==b?b:_types.OperatingSystemTypeMap[c];return new OperatingSystem(a)}}}}exports.OperatingSystem=OperatingSystem;
|
|
2
2
|
//# sourceMappingURL=operatingSystem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operatingSystem.js","names":["OperatingSystem","constructor","operatingSystem","_defineProperty","sent","url","UrlEventType","StaticData","UrlParameter","Os","OsIndex","OperatingSystemIndexMap","data","type","KameleoonData","isSent","value","
|
|
1
|
+
{"version":3,"file":"operatingSystem.js","names":["OperatingSystem","constructor","operatingSystem","_defineProperty","sent","url","UrlEventType","StaticData","UrlParameter","Os","OsIndex","OperatingSystemIndexMap","data","type","KameleoonData","isSent","value","_fromVisit","visit","staticDataEvent","os","operatingSystemType","osIndex","OperatingSystemTypeMap","exports"],"sources":["../../src/kameleoonData/operatingSystem.ts"],"sourcesContent":["import { UrlEventType, UrlParameter, VisitType } from 'src/requester';\nimport {\n IKameleoonData,\n KameleoonData,\n OperatingSystemDataType,\n OperatingSystemIndexMap,\n OperatingSystemType,\n OperatingSystemTypeMap,\n} from './types';\n\n/**\n * @class\n * OperatingSystem - a class for creating an instance for Operating System of a certain type\n * */\nexport class OperatingSystem implements IKameleoonData {\n private operatingSystem: OperatingSystemType;\n private sent: boolean;\n\n /**\n * @param {OperatingSystemType} operatingSystem - one of the available operating system types from `OperatingSystemType` enum\n * */\n constructor(operatingSystem: OperatingSystemType) {\n this.operatingSystem = operatingSystem;\n this.sent = false;\n }\n\n get url(): string {\n // --- Note ---\n // If SDK is used in vanilla JS codebase, then you're also able to create an instance\n // with no required data, we don't want send anything to tracking in that case\n if (!this.operatingSystem) {\n return '';\n }\n\n return (\n UrlEventType.StaticData +\n UrlParameter.Os +\n this.operatingSystem +\n UrlParameter.OsIndex +\n OperatingSystemIndexMap[this.operatingSystem]\n );\n }\n\n get data(): OperatingSystemDataType {\n return {\n operatingSystem: this.operatingSystem,\n type: KameleoonData.OperatingSystem,\n sent: this.sent,\n };\n }\n\n get isSent(): boolean {\n return this.sent;\n }\n\n set isSent(value: boolean) {\n this.sent = value;\n }\n\n /**\n * @private\n * @method _fromVisit - a static method for creating an instance of OperatingSystem class from a visit\n * @param {VisitType} visit - a visit\n * @returns {OperatingSystem | undefined} an instance of OperatingSystem class or undefined\n * */\n public static _fromVisit(visit: VisitType): OperatingSystem | undefined {\n if (!visit.staticDataEvent) {\n return undefined;\n }\n\n const { os: operatingSystemType, osIndex } = visit.staticDataEvent.data;\n\n if (operatingSystemType || typeof osIndex === 'number') {\n const operatingSystem =\n operatingSystemType ?? OperatingSystemTypeMap[osIndex as number];\n\n return new OperatingSystem(operatingSystem);\n }\n\n return undefined;\n }\n}\n"],"mappings":"uqBAcO,KAAM,CAAAA,eAA0C,CAOrDC,WAAWA,CAACC,CAAoC,CAAE,CAAAC,eAAA,gCAAAA,eAAA,qBAChD,IAAI,CAACD,eAAe,CAAGA,CAAe,CACtC,IAAI,CAACE,IAAI,GACX,CAEA,GAAI,CAAAC,GAAGA,CAAA,CAAW,OAIX,KAAI,CAACH,eAAe,CAKvBI,uBAAY,CAACC,UAAU,CACvBC,uBAAY,CAACC,EAAE,CACf,IAAI,CAACP,eAAe,CACpBM,uBAAY,CAACE,OAAO,CACpBC,8BAAuB,CAAC,IAAI,CAACT,eAAe,CAAC,CARtC,EAUX,CAEA,GAAI,CAAAU,IAAIA,CAAA,CAA4B,CAClC,MAAO,CACLV,eAAe,CAAE,IAAI,CAACA,eAAe,CACrCW,IAAI,CAAEC,oBAAa,CAACd,eAAe,CACnCI,IAAI,CAAE,IAAI,CAACA,IACb,CACF,CAEA,GAAI,CAAAW,MAAMA,CAAA,CAAY,CACpB,MAAO,KAAI,CAACX,IACd,CAEA,GAAI,CAAAW,MAAMA,CAACC,CAAc,CAAE,CACzB,IAAI,CAACZ,IAAI,CAAGY,CACd,CAQA,MAAc,CAAAC,UAAUA,CAACC,CAAgB,CAA+B,CACtE,GAAKA,CAAK,CAACC,eAAe,EAI1B,KAAM,CAAEC,EAAE,CAAEC,CAAmB,CAAEC,OAAO,CAAPA,CAAQ,CAAC,CAAGJ,CAAK,CAACC,eAAe,CAACP,IAAI,CAEvE,GAAIS,CAAmB,EAAuB,QAAQ,EAA3B,MAAO,CAAAC,CAAoB,CAAE,CACtD,KAAM,CAAApB,CAAe,QACnBmB,CAAmB,WAAnBA,CAAmB,CAAnBA,CAAmB,CAAIE,6BAAsB,CAACD,CAAO,CAAW,CAElE,MAAO,IAAI,CAAAtB,eAAe,CAACE,CAAe,CAC5C,CAAC,CAGH,CACF,CAACsB,OAAA,CAAAxB,eAAA,CAAAA,eAAA"}
|
|
@@ -14,17 +14,8 @@ export declare class PageView implements IKameleoonData {
|
|
|
14
14
|
* @param {PageViewParametersType} pageViewParameters - an object with page view parameters
|
|
15
15
|
* */
|
|
16
16
|
constructor({ urlAddress, title, referrers }: PageViewParametersType);
|
|
17
|
-
/**
|
|
18
|
-
* @property url - url for the current data type used for events tracking
|
|
19
|
-
* */
|
|
20
17
|
get url(): string;
|
|
21
|
-
/**
|
|
22
|
-
* @property data - data of the current class instance
|
|
23
|
-
* */
|
|
24
18
|
get data(): PageViewDataType;
|
|
25
|
-
/**
|
|
26
|
-
* @property isSent - signifying if the data was sent already tracked
|
|
27
|
-
* */
|
|
28
19
|
get isSent(): boolean;
|
|
29
20
|
set isSent(value: boolean);
|
|
30
21
|
/**
|
|
@@ -34,9 +25,9 @@ export declare class PageView implements IKameleoonData {
|
|
|
34
25
|
set timestamps(value: number[]);
|
|
35
26
|
/**
|
|
36
27
|
* @private
|
|
37
|
-
* @method
|
|
38
|
-
* @param {VisitType
|
|
39
|
-
* @
|
|
28
|
+
* @method _updateFromVisit - an internal method for updating a list of page view data from a visit
|
|
29
|
+
* @param {VisitType} visit - a visit
|
|
30
|
+
* @param {Map<string, PageView>} dataMap - a map of page view data where we collect data
|
|
40
31
|
* */
|
|
41
|
-
static
|
|
32
|
+
static _updateFromVisit(visit: VisitType, dataMap: Map<string, PageView>): void;
|
|
42
33
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("./types");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 PageView{constructor(a){let{urlAddress:b,title:c,referrers:d}=a;_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"referrers",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"timestampList",[]),this.urlAddress=b,this.title=c,this.referrers=d,this.sent=!1}get url(){var a;if(!this.urlAddress)return"";const b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c}get data(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types2.KameleoonData.PageView,sent:this.sent,timestamps:this.timestampList}}get isSent(){return this.sent}set isSent(a){this.sent=a}get timestamps(){return this.timestampList}set timestamps(a){const b=new Set(a);this.timestampList.length?b.forEach(a=>{_utilities.Utilities.insertInOrderedListMutably({list:this.timestampList,element:a,order:_types.Order.Ascending})}):this.timestampList=[...b]}static
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("./types");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 PageView{constructor(a){let{urlAddress:b,title:c,referrers:d}=a;_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"referrers",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"timestampList",[]),this.urlAddress=b,this.title=c,this.referrers=d,this.sent=!1}get url(){var a;if(!this.urlAddress)return"";const b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c}get data(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types2.KameleoonData.PageView,sent:this.sent,timestamps:this.timestampList}}get isSent(){return this.sent}set isSent(a){this.sent=a}get timestamps(){return this.timestampList}set timestamps(a){const b=new Set(a);this.timestampList.length?b.forEach(a=>{_utilities.Utilities.insertInOrderedListMutably({list:this.timestampList,element:a,order:_types.Order.Ascending})}):this.timestampList=[...b]}static _updateFromVisit(a,b){const c=a.pageEvents;if(c)for(const a of c){let c=[];const{time:d}=a,{href:e,title:f,referrersIndices:g}=a.data;"number"==typeof g[0]&&(c=g);let h;if(b.has(e)){const a=b.get(e).timestamps;h=new PageView({urlAddress:e,title:f,referrers:c}),h.timestamps=[...a,d]}else h=new PageView({urlAddress:e,title:f,referrers:c}),h.timestamps=[d];h.isSent=!0,b.set(e,h)}}}exports.PageView=PageView;
|
|
2
2
|
//# sourceMappingURL=pageView.js.map
|