@amplitude/experiment-js-client
Version:
Amplitude Experiment Javascript Client SDK
37 lines (36 loc) • 1.56 kB
TypeScript
import { AnalyticsConnector } from '@amplitude/analytics-connector';
import { ExperimentConfig } from '../config';
import { Client } from '../types/client';
import { ExperimentEvent, ExperimentPluginType, IntegrationPlugin } from '../types/plugin';
import { ExperimentUser } from '../types/user';
/**
* Integration plugin for Amplitude Analytics. Uses the analytics connector to
* track events and get user identity.
*
* On initialization, this plugin attempts to read the user identity from all
* the storage locations and formats supported by the analytics SDK, then
* commits the identity to the connector. The order of locations checks are:
* - Cookie
* - Cookie (Legacy)
* - Local Storage
* - Session Storage
*
* Events are tracked only if the connector has an event receiver set, otherwise
* track returns false, and events are persisted and managed by the
* IntegrationManager.
*/
export declare class AmplitudeIntegrationPlugin implements IntegrationPlugin {
readonly type: ExperimentPluginType;
private readonly apiKey;
private readonly identityStore;
private readonly eventBridge;
private readonly contextProvider;
private readonly timeoutMillis;
constructor(apiKey: string | undefined, connector: AnalyticsConnector, timeoutMillis: number);
setup?(config?: ExperimentConfig, client?: Client): Promise<void>;
getUser(): ExperimentUser;
track(event: ExperimentEvent): boolean;
private loadPersistedState;
private commitIdentityToConnector;
private waitForConnectorIdentity;
}