import ConstantProperties from './constantProperties.js'; import type { StorageLike } from './constantProperties.js'; import Events from './events.js'; import People from './people.js'; interface Options { ingestPoint: string; projectKey: string; /** Storage class for persistent data */ localStorage?: StorageLike; /** Storage class for data on a per-session basis */ sessionStorage?: StorageLike; /** Used to request a custom session token when in not-standalone mode */ getToken?: () => string; /** Used to get current timestamp when not in standalone mode */ getTimestamp?: () => number; /** Callback for people.identify */ setUserId?: (user_id: string) => void; /** automatically set when used inside openreplay tracker */ notStandalone?: boolean; } export default class Analytics { readonly events: Events; readonly constantProperties: ConstantProperties; readonly people: People; private token; private readonly batcher; private readonly backendUrl; private readonly projectKey; private readonly localStorage; private readonly sessionStorage; private readonly getToken; private readonly getTimestamp; private readonly setUserId; private readonly standalone; /** * @param localStorage Class or Object that implements Storage-like interface that stores * values persistently like window.localStorage or any other file-based storage * * @param sessionStorage Class or Object that implements Storage-like interface that stores values * on per-session basis like window.sessionStorage or any other in-memory storage * * @param getToken Function that returns token to bind events to a session * * @param getTimestamp returns current timestamp * * @param setUserId callback for people.identify * * @param standalone if true, analytics will manage its own token (instead of using with openreplay tracker session) * */ constructor(options: Options); _getToken: () => string | null; _getTimestamp: () => number; init: () => Promise; /** * Used by tracker when running in blundled mode */ onStart: () => void; onStop: () => void; reset: () => void; /** * COMPATIBILITY LAYER * */ /** * Identify a user with an id (e.g. email, username, etc.) * will bind all events and properties (including device_id) to this user * * you will need to manually call people.reset() to clear the id on logout event * */ identify: (user_id: string) => void; /** * Add event to batch with option to send it immediately, * properties are optional and will not be saved as super prop * */ track: (eventName: string, properties?: Record, options?: { send_immediately: boolean; }) => void; } export {};