@flagship.io/js-sdk
Version:
89 lines (88 loc) • 3.32 kB
TypeScript
import { IBucketingConfig } from '../config/IBucketingConfig';
import { IDecisionApiConfig } from '../config/IDecisionApiConfig';
import { IEdgeConfig } from '../config/IEdgeConfig';
import { Visitor } from '../visitor/Visitor';
import { FSSdkStatus } from '../enum/FSSdkStatus';
import { type IFlagshipConfig } from '../config/index';
import { NewVisitor } from '../types';
/**
* The `Flagship` class represents the SDK. It facilitates the initialization process and creation of new visitors.
*/
export declare class Flagship {
private static _instance;
private _configManager;
private _config;
private _status;
private _visitorInstance?;
private instanceId;
private lastInitializationTimestamp;
private _sdkManager;
private static visitorProfile;
private static onSaveVisitorProfile;
private _sdkApi?;
private _visitorVariationState;
private set configManager(value);
private get configManager();
private constructor();
protected static getInstance(): Flagship;
protected setStatus(status: FSSdkStatus): void;
/**
* Return current status of Flagship SDK.
*/
static getStatus(): FSSdkStatus;
/**
* Return current status of Flagship SDK.
*/
getStatus(): FSSdkStatus;
/**
* Return the current config set by the customer and used by the SDK.
*/
static getConfig(): IFlagshipConfig;
/**
* Return the current config set by the customer and used by the SDK.
*/
getConfig(): IFlagshipConfig;
/**
* Return the last visitor created if isNewInstance key is false. Return undefined otherwise.
*/
getVisitor(): Visitor | undefined;
/**
* Return the last visitor created if isNewInstance key is false. Return undefined otherwise.
*/
static getVisitor(): Visitor | undefined;
private buildConfig;
private createManagers;
private buildSdkApi;
private sendInitializedPostMessage;
private initializeSdk;
/**
* Start the flagship SDK, with a custom configuration implementation
* @param {string} envId : Environment id provided by Flagship.
* @param {string} apiKey : Secure api key provided by Flagship.
* @param {IFlagshipConfig} config : (optional) SDK configuration.
*/
static start(envId: string, apiKey: string, config?: IDecisionApiConfig | IBucketingConfig | IEdgeConfig): Promise<Flagship>;
/**
* When called, it will batch and send all hits that are in the pool before the application is closed
*/
close(): Promise<void>;
/**
* When called, it will batch and send all hits that are in the pool before the application is closed
*/
static close(): Promise<void>;
/**
* Creates a new Visitor instance.
*
* @param params - The parameters for creating the new Visitor.
* @returns A new Visitor instance.
*/
newVisitor(params: NewVisitor): Visitor;
private initializeConfigManager;
/**
* Creates a new Visitor instance.
*
* @param params - The parameters for creating the new Visitor.
* @returns A new Visitor instance.
*/
static newVisitor({ visitorId, context, isAuthenticated, hasConsented, initialCampaigns, initialFlagsData, shouldSaveInstance, onFlagsStatusChanged }: NewVisitor): Visitor;
}