@kameleoon/javascript-sdk-core
Version:
Kameleoon JS SDK Core
92 lines (91 loc) • 3.27 kB
TypeScript
import { VisitType } from '../requester';
import { CustomDataType, IKameleoonData } from './types';
import { TrackingStatus } from '../types';
/**
* @class
* CustomData - a class for creating an instance for user's custom data
* */
export declare class CustomData implements IKameleoonData {
static readonly UNDEFINED_INDEX = -1;
private _status;
private _index;
private value;
private isIdentifier;
private overwrite;
private _name?;
/**
* @param {number|string} indexOrName - either:
* - `number` — an index of custom data (configured in *Advanced Tools* section of Kameleoon Application)
* - `string` — a custom name for the data
* @param {boolean} [overwrite=true] - optional flag, whether to overwrite existing data
* @param {...string} value - one or more values to store. Values must be strings (or stringified).
*
* @example
* ```ts
* // - Using index with single value
* const cd1 = new CustomData(0, 'value_1');
*
* // - Using index with multiple values
* const cd2 = new CustomData(0, 'value_1', 'value_2');
*
* // - Using index with overwrite flag
* const cd3 = new CustomData(0, false, 'value_1', 'value_2');
*
* // - Using name with single value
* const cd4 = new CustomData('name', 'value_1');
*
* // - Using name with multiple values
* const cd5 = new CustomData('name', 'value_1', 'value_2');
*
* // - Using name with overwrite flag
* const cd6 = new CustomData('name', false, 'value_1', 'value_2');
* ```
*/
constructor(index: number, ...value: string[]);
constructor(index: number, overwrite: boolean, ...value: string[]);
constructor(name: string, ...value: string[]);
constructor(name: string, overwrite: boolean, ...value: string[]);
get url(): string;
get data(): CustomDataType;
get status(): TrackingStatus;
/**
* @private
* @method _fromRaw - an internal method for creating a CustomData instance from raw data
* @param {CustomDataType} data - a raw data
* @return {CustomData} a CustomData instance
* */
static _fromRaw(data: CustomDataType): CustomData;
/**
* @property isMappingIdentifier - signifying if the data is a mapping identifier
* @private
* */
set _isMappingIdentifier(value: boolean);
set status(status: TrackingStatus);
/**
* @private
* @method _updateFromVisit - an internal method for updating a list of custom data from a visit
* @param {VisitType} visit - a visit
* */
static _updateFromVisit(visit: VisitType, dataMap: Map<number, CustomData>): void;
/**
* @private
* @method index - an internal setter for setting index of custom data
* @param {number} value - an index value
* */
set index(value: number);
/**
* @private
* @method index - an internal getter for index of custom data
* */
get index(): number;
/**
* @private
* @method name - an internal getter for a name of custom data
* */
get name(): string | undefined;
/**
* @private
* @method name - an internal getter for a name of custom data
* */
get values(): string[];
}