@kameleoon/javascript-sdk-core 5.17.3 → 5.18.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 +9 -0
- package/dist/browser.d.ts +1 -1
- package/dist/cacheManager/cacheManager.d.ts +2 -2
- package/dist/clientConfiguration/clientConfiguration.d.ts +9 -9
- package/dist/clientSettings/clientSettings.d.ts +11 -8
- package/dist/index.d.ts +1 -1
- package/dist/javascript-sdk-core.browser.cjs.js +214 -180
- package/dist/javascript-sdk-core.browser.cjs.js.map +1 -1
- package/dist/javascript-sdk-core.browser.es.js +214 -180
- package/dist/javascript-sdk-core.browser.es.js.map +1 -1
- package/dist/javascript-sdk-core.cjs.js +214 -180
- package/dist/javascript-sdk-core.cjs.js.map +1 -1
- package/dist/javascript-sdk-core.es.js +214 -180
- package/dist/javascript-sdk-core.es.js.map +1 -1
- package/dist/kameleoonClient.d.ts +12 -10
- package/dist/kameleoonClientInterface.d.ts +18 -10
- package/dist/kameleoonData/browser.d.ts +2 -2
- package/dist/kameleoonData/conversion.d.ts +3 -3
- package/dist/kameleoonData/customData.d.ts +3 -3
- package/dist/kameleoonData/dataManager.d.ts +11 -4
- package/dist/kameleoonData/device.d.ts +1 -1
- package/dist/kameleoonData/geolocation.d.ts +5 -5
- package/dist/kameleoonData/index.d.ts +1 -1
- package/dist/kameleoonData/pageView.d.ts +3 -3
- package/dist/kameleoonData/targetedSegment.d.ts +1 -1
- package/dist/kameleoonData/types.d.ts +12 -0
- package/dist/kameleoonData/uniqueIdentifier.d.ts +1 -1
- package/dist/kameleoonData/userAgent.d.ts +1 -1
- package/dist/tracking/tracker.d.ts +7 -7
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5,24 +5,25 @@ import { IKameleoonClient } from './kameleoonClientInterface';
|
|
|
5
5
|
import { EventCallbackType, EventType } from './eventManager';
|
|
6
6
|
import { Tracker } from './tracking';
|
|
7
7
|
import { LogLevel } from './logging';
|
|
8
|
+
import { AddDataParamsType } from './kameleoonData/types';
|
|
8
9
|
/**
|
|
9
10
|
* @class
|
|
10
11
|
* KameleoonClient - a class for creating kameleoon client instance
|
|
11
12
|
* for communicating with Kameleoon JavaScript SDK Core, when new instance is created
|
|
12
13
|
*/
|
|
13
14
|
export declare class KameleoonClient implements IKameleoonClient {
|
|
14
|
-
private variationConfiguration;
|
|
15
|
-
private clientConfiguration;
|
|
16
|
-
private dataManager;
|
|
17
|
-
private consentDataStorage;
|
|
18
|
-
private trackingCache;
|
|
19
|
-
private requester;
|
|
20
|
-
private externalPackageInfo;
|
|
15
|
+
private readonly variationConfiguration;
|
|
16
|
+
private readonly clientConfiguration;
|
|
17
|
+
private readonly dataManager;
|
|
18
|
+
private readonly consentDataStorage;
|
|
19
|
+
private readonly trackingCache;
|
|
20
|
+
private readonly requester;
|
|
21
|
+
private readonly externalPackageInfo;
|
|
21
22
|
protected initialized: boolean;
|
|
22
|
-
private visitorCodeManager;
|
|
23
|
-
private eventManager;
|
|
23
|
+
private readonly visitorCodeManager;
|
|
24
|
+
private readonly eventManager;
|
|
24
25
|
protected readonly tracker: Tracker;
|
|
25
|
-
private environment;
|
|
26
|
+
private readonly environment;
|
|
26
27
|
protected readonly stubMode?: boolean;
|
|
27
28
|
/**
|
|
28
29
|
* @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
|
|
@@ -30,6 +31,7 @@ export declare class KameleoonClient implements IKameleoonClient {
|
|
|
30
31
|
constructor({ siteCode, dependencies, configuration, internalConfiguration, stubMode, }: SDKCoreParameters);
|
|
31
32
|
initialize(): Promise<boolean>;
|
|
32
33
|
addData(visitorCode: string, ...data: KameleoonDataType[]): void;
|
|
34
|
+
addData({ visitorCode, data, track }: AddDataParamsType): void;
|
|
33
35
|
getRemoteVisitorData({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
|
|
34
36
|
trackConversion({ visitorCode, goalId, negative, revenue, metadata, }: TrackConversionParamsType): void;
|
|
35
37
|
flush(params?: string | FlushParamsType): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONType } from './clientConfiguration';
|
|
2
2
|
import { EventCallbackType, EventType } from './eventManager';
|
|
3
3
|
import { CustomData, KameleoonDataType } from './kameleoonData';
|
|
4
|
-
import { DataFile, FeatureFlagType, FeatureFlagVariableType, GetFeatureFlagVariableParamsType, GetVariationParamsType, GetVariationsParamsType, GetVisitorWarehouseAudienceParamsType, IsFeatureFlagActiveParamsType, KameleoonVariationType, RemoteVisitorDataParamsType, SetForcedVariationParametersType, TrackConversionParamsType, Variable, Variation } from './types';
|
|
4
|
+
import { AddDataParamsType, DataFile, FeatureFlagType, FeatureFlagVariableType, GetFeatureFlagVariableParamsType, GetVariationParamsType, GetVariationsParamsType, GetVisitorWarehouseAudienceParamsType, IsFeatureFlagActiveParamsType, KameleoonVariationType, RemoteVisitorDataParamsType, SetForcedVariationParametersType, TrackConversionParamsType, Variable, Variation } from './types';
|
|
5
5
|
import { LogLevel } from './logging';
|
|
6
6
|
/**
|
|
7
7
|
* @interface an interface of KameleoonClient instance
|
|
@@ -21,18 +21,26 @@ export interface IKameleoonClient {
|
|
|
21
21
|
*/
|
|
22
22
|
initialize(): Promise<boolean>;
|
|
23
23
|
/**
|
|
24
|
-
* @method addData -
|
|
25
|
-
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
26
|
-
* @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments
|
|
27
|
-
* @returns {void}
|
|
28
|
-
* @throws `KameleoonError` with one of the following `type` s:
|
|
24
|
+
* @method addData - Stores targeting data for a visitor so other methods can evaluate targeting rules.
|
|
29
25
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* This method supports two calling forms:
|
|
27
|
+
* 1) `addData(visitorCode, ...data)`
|
|
28
|
+
* 2) `addData({ visitorCode, data, track })`
|
|
29
|
+
*
|
|
30
|
+
* Note: `UserAgent` data is not persisted in storage like other data; it is sent with every tracking request for bot filtration.
|
|
31
|
+
*
|
|
32
|
+
* @param visitorCode - Unique visitor identifier, must not exceed 255 characters.
|
|
33
|
+
* @param track - Optional flag (only via `AddDataParamsType`) controlling whether the added data should be tracked/marked as unsent.
|
|
34
|
+
* @param data - One or more instances of `KameleoonData` (either as rest args or via `AddDataParamsType.data`).
|
|
35
|
+
*
|
|
36
|
+
* @returns void
|
|
37
|
+
* @throws KameleoonError with one of:
|
|
38
|
+
* - `KameleoonException.VisitorCodeMaxLength` Visitor code length was exceeded
|
|
39
|
+
* - `KameleoonException.VisitorCodeEmpty` Visitor code is empty
|
|
32
40
|
* - `KameleoonException.StorageWrite` Couldn't update storage data
|
|
33
|
-
* - `KameleoonException.Initialization`
|
|
41
|
+
* - `KameleoonException.Initialization` Called before `kameleoonClient.initialize` completed
|
|
34
42
|
*/
|
|
35
|
-
addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;
|
|
43
|
+
addData: ((visitorCode: string, ...data: KameleoonDataType[]) => void) & (({ visitorCode, track, data }: AddDataParamsType) => void);
|
|
36
44
|
/**
|
|
37
45
|
* @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
|
|
38
46
|
* @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
|
|
@@ -7,8 +7,8 @@ import { TrackingStatus } from '../types';
|
|
|
7
7
|
* */
|
|
8
8
|
export declare class Browser implements IKameleoonData {
|
|
9
9
|
status: TrackingStatus;
|
|
10
|
-
private browser;
|
|
11
|
-
private version?;
|
|
10
|
+
private readonly browser;
|
|
11
|
+
private readonly version?;
|
|
12
12
|
/**
|
|
13
13
|
* @param {BrowserType} browser - one of the browser types available for data, if browser can not be found in a list, it can be marked as `BrowserType.Other`
|
|
14
14
|
* @param {number | undefined} version - version of the browser, floating point number represents major and minor version of the browser
|
|
@@ -8,9 +8,9 @@ import { CustomData } from '../kameleoonData/customData';
|
|
|
8
8
|
* */
|
|
9
9
|
export declare class Conversion implements IKameleoonData {
|
|
10
10
|
status: TrackingStatus;
|
|
11
|
-
private goalId;
|
|
12
|
-
private revenue;
|
|
13
|
-
private negative;
|
|
11
|
+
private readonly goalId;
|
|
12
|
+
private readonly revenue;
|
|
13
|
+
private readonly negative;
|
|
14
14
|
private id;
|
|
15
15
|
private nonce;
|
|
16
16
|
private metadata;
|
|
@@ -9,10 +9,10 @@ export declare class CustomData implements IKameleoonData {
|
|
|
9
9
|
static readonly UNDEFINED_INDEX = -1;
|
|
10
10
|
private _status;
|
|
11
11
|
private _index;
|
|
12
|
-
private value;
|
|
12
|
+
private readonly value;
|
|
13
13
|
private isIdentifier;
|
|
14
|
-
private overwrite;
|
|
15
|
-
private _name?;
|
|
14
|
+
private readonly overwrite;
|
|
15
|
+
private readonly _name?;
|
|
16
16
|
/**
|
|
17
17
|
* @param {number|string} indexOrName - either:
|
|
18
18
|
* - `number` — an index of custom data (configured in *Advanced Tools* section of Kameleoon Application)
|
|
@@ -8,16 +8,16 @@ import { DataManagerParametersType, KameleoonData, KameleoonDataType, KameleoonV
|
|
|
8
8
|
import { IStorage } from '../storage';
|
|
9
9
|
import { CustomDataConfigurationType } from '../clientConfiguration';
|
|
10
10
|
import { DataInfoType, MappingIdentifierType } from '../storage/types';
|
|
11
|
+
import { AddDataParamsType } from '../types';
|
|
11
12
|
import { ExternalPackageInfoType } from '../sdkInfoTypes';
|
|
12
13
|
import { StaticData } from '../kameleoonData/staticData';
|
|
13
14
|
export interface IDataManager {
|
|
14
|
-
storeData(data: VisitorsDataType, extendTtl: boolean): Result<void, KameleoonError>;
|
|
15
15
|
storeTrackedData(data: VisitorsDataType): void;
|
|
16
16
|
getTree(segment: SegmentType): Tree;
|
|
17
17
|
clearTrees(): void;
|
|
18
18
|
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
19
19
|
isUniqueIdentifier(visitorCode: string): boolean;
|
|
20
|
-
getLinkedVisitor(visitorCode: string
|
|
20
|
+
getLinkedVisitor(visitorCode: string): string | null;
|
|
21
21
|
getVisitorData(visitorCode: string): KameleoonVisitorDataType | undefined;
|
|
22
22
|
getVisitorIdentifier(visitorCode: string): string;
|
|
23
23
|
getPendingData(visitorCode: string): KameleoonDataType[];
|
|
@@ -45,8 +45,15 @@ export declare class DataManager implements IDataManager {
|
|
|
45
45
|
getPendingData(visitorCode: string): KameleoonDataType[];
|
|
46
46
|
private getDataFromRaw;
|
|
47
47
|
storeTrackedData(data: VisitorsDataType): void;
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Store data for a single visitor
|
|
50
|
+
*/
|
|
51
|
+
storeData({ visitorCode, data, track, }: AddDataParamsType): Result<void, KameleoonError>;
|
|
52
|
+
/**
|
|
53
|
+
* Store data for multiple visitors
|
|
54
|
+
*/
|
|
55
|
+
storeDataForVisitors(data: VisitorsDataType, extendTtl: boolean): Result<void, KameleoonError>;
|
|
56
|
+
private storeDataInternal;
|
|
50
57
|
getTree(segment: SegmentType): Tree;
|
|
51
58
|
clearTrees(): void;
|
|
52
59
|
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
@@ -7,7 +7,7 @@ import { TrackingStatus } from '../types';
|
|
|
7
7
|
* */
|
|
8
8
|
export declare class Device implements IKameleoonData {
|
|
9
9
|
status: TrackingStatus;
|
|
10
|
-
private device;
|
|
10
|
+
private readonly device;
|
|
11
11
|
/**
|
|
12
12
|
* @param {DeviceType} device - one of the available device types from `DeviceType` enum
|
|
13
13
|
* */
|
|
@@ -7,11 +7,11 @@ import { TrackingStatus } from '../types';
|
|
|
7
7
|
* */
|
|
8
8
|
export declare class GeolocationData implements IKameleoonData {
|
|
9
9
|
status: TrackingStatus;
|
|
10
|
-
private country;
|
|
11
|
-
private region?;
|
|
12
|
-
private city?;
|
|
13
|
-
private postalCode?;
|
|
14
|
-
private coordinates?;
|
|
10
|
+
private readonly country;
|
|
11
|
+
private readonly region?;
|
|
12
|
+
private readonly city?;
|
|
13
|
+
private readonly postalCode?;
|
|
14
|
+
private readonly coordinates?;
|
|
15
15
|
/**
|
|
16
16
|
* @param {GeolocationInfoType} geolocationInfo - an object containing information about geolocation of a visitor
|
|
17
17
|
* @example
|
|
@@ -13,5 +13,5 @@ export { VisitsData } from './visitsData';
|
|
|
13
13
|
export { KameleoonConversionScore } from './kameleoonConversionScore';
|
|
14
14
|
export { DataProcessor } from './dataProcessor';
|
|
15
15
|
export { StaticData } from './staticData';
|
|
16
|
-
export { DeviceType, CookieType, VisitsDataType, BrowserType, KameleoonData, DeviceDataType, CustomDataType, BrowserDataType, BrowserIndexMap, PageViewDataType, KameleoonDataType, UserAgentDataType, IdentifierDataType, ConversionDataType, OperatingSystemType, GeolocationInfoType, KameleoonDataItemType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './types';
|
|
16
|
+
export { DeviceType, CookieType, VisitsDataType, BrowserType, KameleoonData, DeviceDataType, CustomDataType, BrowserDataType, BrowserIndexMap, PageViewDataType, KameleoonDataType, UserAgentDataType, IdentifierDataType, ConversionDataType, OperatingSystemType, GeolocationInfoType, KameleoonDataItemType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, AddDataParamsType, } from './types';
|
|
17
17
|
export { DataManager, IDataManager } from './dataManager';
|
|
@@ -7,10 +7,10 @@ import { TrackingStatus } from '../types';
|
|
|
7
7
|
* */
|
|
8
8
|
export declare class PageView implements IKameleoonData {
|
|
9
9
|
timestamps: TimestampType[];
|
|
10
|
-
private urlAddress;
|
|
11
|
-
private title;
|
|
10
|
+
private readonly urlAddress;
|
|
11
|
+
private readonly title;
|
|
12
12
|
private nonce?;
|
|
13
|
-
private referrers?;
|
|
13
|
+
private readonly referrers?;
|
|
14
14
|
/**
|
|
15
15
|
* @param {PageViewParametersType} pageViewParameters - an object with page view parameters
|
|
16
16
|
* */
|
|
@@ -2,7 +2,7 @@ import { IKameleoonData, TargetedSegmentDataType } from './types';
|
|
|
2
2
|
import { TrackingStatus } from '../types';
|
|
3
3
|
export declare class TargetedSegment implements IKameleoonData {
|
|
4
4
|
status: TrackingStatus;
|
|
5
|
-
private id;
|
|
5
|
+
private readonly id;
|
|
6
6
|
constructor(id: number);
|
|
7
7
|
get url(): string;
|
|
8
8
|
get data(): TargetedSegmentDataType;
|
|
@@ -177,6 +177,7 @@ export type MutUpdateTargetingDataParametersType = {
|
|
|
177
177
|
kameleoonData: KameleoonDataType[];
|
|
178
178
|
targetingData: TargetingDataType;
|
|
179
179
|
extendTtl: boolean;
|
|
180
|
+
track?: boolean;
|
|
180
181
|
};
|
|
181
182
|
export type ReferenceParametersType = {
|
|
182
183
|
mutData: TargetingDataType;
|
|
@@ -401,4 +402,15 @@ export type StaticDataType = {
|
|
|
401
402
|
deviceType?: DeviceType;
|
|
402
403
|
os?: OperatingSystemType;
|
|
403
404
|
};
|
|
405
|
+
/**
|
|
406
|
+
* @type `AddDataParamsType` Parameters for the object-style `KameleoonClient.addData` call.
|
|
407
|
+
* @param {string} visitorCode - Unique visitor identifier.
|
|
408
|
+
* @param {boolean} [track=true] - When `false`, stored items are treated as already tracked (no tracking will be sent for them).
|
|
409
|
+
* @param {KameleoonDataType[]} data - One or more `KameleoonData` instances to store for this visitor.
|
|
410
|
+
*/
|
|
411
|
+
export type AddDataParamsType = {
|
|
412
|
+
visitorCode: string;
|
|
413
|
+
track?: boolean;
|
|
414
|
+
data: KameleoonDataType[];
|
|
415
|
+
};
|
|
404
416
|
export {};
|
|
@@ -2,7 +2,7 @@ import { TrackingStatus } from '../types';
|
|
|
2
2
|
import { IKameleoonData, IdentifierDataType } from './types';
|
|
3
3
|
export declare class UniqueIdentifier implements IKameleoonData {
|
|
4
4
|
status: TrackingStatus;
|
|
5
|
-
private _value;
|
|
5
|
+
private readonly _value;
|
|
6
6
|
/**
|
|
7
7
|
* @param {boolean} value - a boolean value that indicates if the visitor has a unique identifier
|
|
8
8
|
* */
|
|
@@ -6,7 +6,7 @@ import { TrackingStatus } from '../types';
|
|
|
6
6
|
* */
|
|
7
7
|
export declare class UserAgent implements IKameleoonData {
|
|
8
8
|
status: TrackingStatus;
|
|
9
|
-
private value;
|
|
9
|
+
private readonly value;
|
|
10
10
|
constructor(value: string);
|
|
11
11
|
get url(): string;
|
|
12
12
|
get data(): UserAgentDataType;
|
|
@@ -3,13 +3,13 @@ export interface ITracker {
|
|
|
3
3
|
scheduleVisitor: (visitorCode: string, isConsentProvided: boolean) => void;
|
|
4
4
|
}
|
|
5
5
|
export declare class Tracker implements ITracker {
|
|
6
|
-
private dataManager;
|
|
7
|
-
private variationConfiguration;
|
|
8
|
-
private requester;
|
|
9
|
-
private bodyProvider;
|
|
10
|
-
private intervalId;
|
|
11
|
-
private trackingStorage;
|
|
12
|
-
private clientConfiguration;
|
|
6
|
+
private readonly dataManager;
|
|
7
|
+
private readonly variationConfiguration;
|
|
8
|
+
private readonly requester;
|
|
9
|
+
private readonly bodyProvider;
|
|
10
|
+
private readonly intervalId;
|
|
11
|
+
private readonly trackingStorage;
|
|
12
|
+
private readonly clientConfiguration;
|
|
13
13
|
constructor({ dataManager, trackingStorage, variationConfiguration, trackingInterval, requester, prng, clientConfiguration, }: TrackerParametersType);
|
|
14
14
|
scheduleVisitor(visitorCode: string, isConsentProvided: boolean): void;
|
|
15
15
|
private checkIsIdentifier;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { IExternalLogger } from './logging';
|
|
|
8
8
|
import { FeatureFlagType as ConfigFeatureFlagType } from './clientConfiguration/types';
|
|
9
9
|
import { Environment, ExternalPackageInfoType } from './sdkInfoTypes';
|
|
10
10
|
import { CustomData, DataManager } from './kameleoonData';
|
|
11
|
+
export { AddDataParamsType } from './kameleoonData/types';
|
|
11
12
|
/**
|
|
12
13
|
* @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute
|
|
13
14
|
* @defaultvalue 60
|
|
@@ -26,7 +27,7 @@ import { CustomData, DataManager } from './kameleoonData';
|
|
|
26
27
|
* @param {string | undefined} networkDomain - custom domain to be used in place of all requests URL, domain format is `example.com`, if the format is incorrect, default Kameleoon domain will be used
|
|
27
28
|
* @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests
|
|
28
29
|
* @defaultvalue `10_000` (10 seconds)
|
|
29
|
-
* @param {number | undefined} trackingInterval - interval in _milliseconds_ for performing background tracking requests, must be a value between `
|
|
30
|
+
* @param {number | undefined} trackingInterval - interval in _milliseconds_ for performing background tracking requests, must be a value between `1_000` to `5_000` milliseconds
|
|
30
31
|
* @defaultvalue `1_000` (1 second)
|
|
31
32
|
* @param {string | undefined} defaultDataFile - json string containing default configuration data, used to initialize the SDK when no data is available in the storage or when the data is not up-to-date
|
|
32
33
|
* @defaultvalue `undefined` (no default data file)
|