@kameleoon/javascript-sdk-core
Version:
Kameleoon JS SDK Core
71 lines (70 loc) • 3.95 kB
TypeScript
/// <reference types="node" />
import { Result } from 'ts-res';
import { KameleoonError } from '../kameleoonError';
import { SegmentType, TargetingDataType, Tree } from '../targeting';
import { DataProcessor } from './dataProcessor';
import { CustomData } from './customData';
import { DataManagerParametersType, KameleoonData, KameleoonDataType, KameleoonVisitorDataType, VisitorsDataType } from './types';
import { IStorage } from '../storage';
import { CustomDataConfigurationType } from '../clientConfiguration';
import { DataInfoType, MappingIdentifierType } from '../storage/types';
import { ExternalPackageInfoType } from '../sdkInfoTypes';
import { StaticData } from '../kameleoonData/staticData';
export interface IDataManager {
storeData(data: VisitorsDataType, extendTtl: boolean): Result<void, KameleoonError>;
storeTrackedData(data: VisitorsDataType): void;
getTree(segment: SegmentType): Tree;
clearTrees(): void;
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
isUniqueIdentifier(visitorCode: string): boolean;
getLinkedVisitor(visitorCode: string, index: number | null): string | null;
getVisitorData(visitorCode: string): KameleoonVisitorDataType | undefined;
getVisitorIdentifier(visitorCode: string): string;
getPendingData(visitorCode: string): KameleoonDataType[];
getUnsentData(visitorCode: string): (KameleoonDataType | StaticData)[];
getVisitorStoredDataTypes(visitorCode: string): Set<KameleoonData>;
readonly identifierCustomDataIndex: number | null;
readonly storedCustomDataIndexes: Set<number>;
readonly trees: Map<string, Tree>;
readonly unsentDataVisitors: string[];
getCustomDataIndexByName(name: string): number | undefined;
}
export declare class DataManager implements IDataManager {
protected dataStorage: IStorage<TargetingDataType>;
protected infoStorage: IStorage<DataInfoType>;
protected dataProcessor: DataProcessor;
protected targetingTrees: Map<string, Tree>;
protected mappingIdentifierCustomDataIndex: number | null;
protected persistentCustomDataIndexes: Set<number>;
protected localCustomDataIndexes: Set<number>;
protected customDataIndexByName: Map<string, number>;
protected cleanupIntervalId: NodeJS.Timeout | null;
protected packageInfo: ExternalPackageInfoType;
constructor({ dataStorage, infoStorage, cleanupInterval, packageInfo, }: DataManagerParametersType);
getUnsentData(visitorCode: string): (KameleoonDataType | StaticData)[];
getPendingData(visitorCode: string): KameleoonDataType[];
private getDataFromRaw;
storeTrackedData(data: VisitorsDataType): void;
storeData(data: VisitorsDataType, extendTtl: boolean): Result<void, KameleoonError>;
storeData(visitorCode: string, ...data: KameleoonDataType[]): Result<void, KameleoonError>;
getTree(segment: SegmentType): Tree;
clearTrees(): void;
isPersistentCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
isUniqueIdentifier(visitorCode: string): boolean;
getVisitorIdentifier(visitorCode: string): string;
getMappingIdentifier(visitorCode: string): MappingIdentifierType | undefined;
setMappingIdentifier(visitorCode: string, mappingIdentifier: MappingIdentifierType): void;
getVisitorData(visitorCode: string): KameleoonVisitorDataType | undefined;
getVisitorStoredDataTypes(visitorCode: string): Set<KameleoonData>;
getLinkedVisitor(visitorCode: string): string | null;
private mutUpdateTargetingData;
private cleanupData;
private processCustomData;
private trySetCustomDataIndexByName;
get unsentDataVisitors(): string[];
get identifierCustomDataIndex(): number | null;
get trees(): Map<string, Tree>;
get storedCustomDataIndexes(): Set<number>;
set customDataIndexes(customData: CustomDataConfigurationType[]);
getCustomDataIndexByName(name: string): number | undefined;
}