import { Emitter } from 'mitt'; import { SuprSendOptions, Dictionary, EmitterEvents, AuthenticateOptions } from './interface'; import { default as ApiClient } from './api'; import { default as User } from './user'; import { default as WebPush } from './webpush'; import { default as FeedsFactory } from './feed'; export default class SuprSend { host: string; publicApiKey: string; distinctId: unknown; userToken?: string; vapidKey: string; swFileName: string; private apiClient; private userTokenExpirationTimer; authenticateOptions?: AuthenticateOptions; readonly user: User; readonly webpush: WebPush; readonly feeds: FeedsFactory; readonly emitter: Emitter; constructor(publicApiKey: string, options?: SuprSendOptions); private handleRefreshUserToken; client(): ApiClient; eventApi(payload: Dictionary): Promise; /** * Used to authenticate user. Usually called just after successful login and on reload of loggedin route to re-authenticate loggedin user. * In production env's userToken is mandatory for security purposes. */ identify(distinctId: unknown, userToken?: string, options?: AuthenticateOptions): Promise; /** * Check's if SuprSend instance is authenticated. To check if userToken is also present pass true. */ isIdentified(checkUserToken?: boolean): boolean; /** * Used to trigger events to suprsend. */ track(event: string, properties?: Dictionary): Promise; /** * Clears user related data attached to SuprSend instance. Usually called during logout. */ reset(options?: { unsubscribePush?: boolean; }): Promise; }