@kameleoon/javascript-sdk-core 5.14.4 → 5.15.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.
@@ -10,21 +10,40 @@ export declare class CustomData implements IKameleoonData {
10
10
  private index;
11
11
  private value;
12
12
  private isIdentifier;
13
+ private overwrite;
14
+ private name?;
13
15
  /**
14
- * @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application
15
- * @param {string[]} value - custom value to store under the specified id, value can be anything but has to be stringified to match the `string` type. *Note* value is variadic parameter and can be used as follows
16
+ * @param {number|string} indexOrName - either:
17
+ * - `number` an index of custom data (configured in *Advanced Tools* section of Kameleoon Application)
18
+ * - `string` — a custom name for the data
19
+ * @param {boolean} [overwrite=true] - optional flag, whether to overwrite existing data
20
+ * @param {...string} value - one or more values to store. Values must be strings (or stringified).
21
+ *
16
22
  * @example
17
23
  * ```ts
18
- * // - Single value
19
- * const customData = new CustomData(0, 'value_1');
20
- * // - Variadic number of values
21
- * const customData = new CustomData(0, 'value_1', 'value_2', 'value_3');
22
- * // - Array of values
23
- * const values = ['value_1', 'value_2', 'value_3'];
24
- * const customData = new CustomData(0, ...values);
24
+ * // - Using index with single value
25
+ * const cd1 = new CustomData(0, 'value_1');
26
+ *
27
+ * // - Using index with multiple values
28
+ * const cd2 = new CustomData(0, 'value_1', 'value_2');
29
+ *
30
+ * // - Using index with overwrite flag
31
+ * const cd3 = new CustomData(0, false, 'value_1', 'value_2');
32
+ *
33
+ * // - Using name with single value
34
+ * const cd4 = new CustomData('name', 'value_1');
35
+ *
36
+ * // - Using name with multiple values
37
+ * const cd5 = new CustomData('name', 'value_1', 'value_2');
38
+ *
39
+ * // - Using name with overwrite flag
40
+ * const cd6 = new CustomData('name', false, 'value_1', 'value_2');
25
41
  * ```
26
- * */
42
+ */
27
43
  constructor(index: number, ...value: string[]);
44
+ constructor(index: number, overwrite: boolean, ...value: string[]);
45
+ constructor(name: string, ...value: string[]);
46
+ constructor(name: string, overwrite: boolean, ...value: string[]);
28
47
  get url(): string;
29
48
  get data(): CustomDataType;
30
49
  get status(): TrackingStatus;
@@ -47,4 +66,10 @@ export declare class CustomData implements IKameleoonData {
47
66
  * @param {VisitType} visit - a visit
48
67
  * */
49
68
  static _updateFromVisit(visit: VisitType, dataMap: Map<number, CustomData>): void;
69
+ /**
70
+ * @private
71
+ * @method _index - an internal setter for setting index of custom data
72
+ * @param {number} value - an index value
73
+ * */
74
+ set _index(value: number);
50
75
  }
@@ -27,6 +27,7 @@ export interface IDataManager {
27
27
  readonly storedCustomDataIndexes: Set<number>;
28
28
  readonly trees: Map<string, Tree>;
29
29
  readonly unsentDataVisitors: string[];
30
+ getCustomDataIndexByName(name: string): number | undefined;
30
31
  }
31
32
  export declare class DataManager implements IDataManager {
32
33
  protected dataStorage: IStorage<TargetingDataType>;
@@ -36,6 +37,7 @@ export declare class DataManager implements IDataManager {
36
37
  protected mappingIdentifierCustomDataIndex: number | null;
37
38
  protected persistentCustomDataIndexes: Set<number>;
38
39
  protected localCustomDataIndexes: Set<number>;
40
+ protected customDataIndexByName: Map<string, number>;
39
41
  protected cleanupIntervalId: NodeJS.Timeout | null;
40
42
  protected packageInfo: ExternalPackageInfoType;
41
43
  constructor({ dataStorage, infoStorage, cleanupInterval, packageInfo, }: DataManagerParametersType);
@@ -63,4 +65,5 @@ export declare class DataManager implements IDataManager {
63
65
  get trees(): Map<string, Tree>;
64
66
  get storedCustomDataIndexes(): Set<number>;
65
67
  set customDataIndexes(customData: CustomDataConfigurationType[]);
68
+ getCustomDataIndexByName(name: string): number | undefined;
66
69
  }
@@ -206,8 +206,10 @@ export type ConversionDataType = {
206
206
  } & SharedDataPropertiesType;
207
207
  export type CustomDataType = {
208
208
  index: number;
209
+ name?: string;
209
210
  value: string[];
210
211
  isIdentifier: boolean;
212
+ overwrite?: boolean;
211
213
  } & SharedDataPropertiesType;
212
214
  export type DeviceDataType = {
213
215
  device: DeviceType;
@@ -9,7 +9,8 @@ export declare class Tracker implements ITracker {
9
9
  private bodyProvider;
10
10
  private intervalId;
11
11
  private trackingStorage;
12
- constructor({ dataManager, trackingStorage, variationConfiguration, trackingInterval, requester, prng, }: TrackerParametersType);
12
+ private clientConfiguration;
13
+ constructor({ dataManager, trackingStorage, variationConfiguration, trackingInterval, requester, prng, clientConfiguration, }: TrackerParametersType);
13
14
  scheduleVisitor(visitorCode: string, isConsentProvided: boolean): void;
14
15
  private checkIsIdentifier;
15
16
  private getUserAgent;
@@ -5,6 +5,7 @@ import { IExternalPRNG } from '../utilities';
5
5
  import { VariationConfiguration } from '../variationConfiguration';
6
6
  import { BaseVariationDataType } from '../variationConfiguration/types';
7
7
  import { StaticData } from '../kameleoonData/staticData';
8
+ import { ClientConfiguration } from '../clientConfiguration';
8
9
  export type PendingDataType = {
9
10
  [visitorCode: string]: {
10
11
  visitorData: (KameleoonDataType | StaticData)[];
@@ -24,6 +25,7 @@ export type TrackerParametersType = {
24
25
  variationConfiguration: VariationConfiguration;
25
26
  requester: Requester;
26
27
  prng: IExternalPRNG;
28
+ clientConfiguration: ClientConfiguration;
27
29
  };
28
30
  export type AddDataParametersType = {
29
31
  visitorCode: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/javascript-sdk-core",
3
- "version": "5.14.4",
3
+ "version": "5.15.0",
4
4
  "description": "Kameleoon JS SDK Core",
5
5
  "main": "dist/javascript-sdk-core.cjs.js",
6
6
  "module": "dist/javascript-sdk-core.es.js",