import type { INSM } from './insm'; import type { AddedProperties, ExperienceProperties } from './types'; import { PeriodTracking } from './insm-period'; import { LongAnimationFrameMeasurer } from './session-measurers/LongAnimationFrameMeasurer'; /** * Only intended for internal use. * * Exported for consumers who may require the type. * * Note: Events are not reliably fired from mobile browsers (ie. when a browser is closed when not in use) */ export declare class INSMSession { private experienceKey; private experienceProperties; private startedAt; private pageLoadTime; insm: INSM; private running; private addedProperties; private staticProperties; runningFeatures: Set; periodTracking: PeriodTracking; longAnimationFrameMeasurer: LongAnimationFrameMeasurer; constructor(experienceKey: string, experienceProperties: ExperienceProperties, insm: INSM); /** * Completes the page load timing. This is called automatically when ending a heavy task * with the key 'PageLoad'. */ completePageLoad(): void; updateExperienceKey(experienceKey: string): void; /** * Adds a feature to the currently running session */ startFeature(featureName: string): void; /** * Ends a features usage in the currently running session */ endFeature(featureName: string): void; /** * Returns details on the current session. */ get details(): { experienceKey: string; experienceProperties: ExperienceProperties; paused: boolean; periodState: 'inactive' | 'active'; /** * The only scenario where this value should return false is when * the experience has been stopped early. */ running: boolean; }; /** * This api is an alternative to addProperties for scenarios * such as where you have a hot path that will repeatedly fire * throughout a session. * The last value for a given key will be used, and if there is a * matching key from addProperties, the addProperties value will be used. * * ```ts * insm.session.addProperties('custom:lcm', true) * ``` */ setProperty(key: string, value: number | string | boolean): void; /** * This api takes either a static single-level key-value object, or callbacks which return the same and * will be evaluated on session end. * * When ending a session, all properties received via this api are merged, in order, into the resulting * insm event’s properties; last write wins. * * Callback values are evaluated at session end. * * For example, for the following * * ```ts * insm.experience.addProperties({ one: 1, two: 2 }); * insm.experience.addProperties(() => ({ one: 'one' })); * insm.experience.addProperties({ three: 3 }); * ``` * * The resulting added properties will be * * ```ts * { one: 'one', two: 2, three: 3 } * ``` */ addProperties(propertiesToAdd: AddedProperties): void; /** * In some scenarios (ie. when a page error boundary is hit), you will want to exit early. * This is api supports these scenarios * * ```ts * insm.stopEarly(reasonKey: string, description: string); * ``` * * Sessions closed early are identifiable by their end details * `"endDetails": { stoppedBy: "early-stop", reasonKey, description }`. * * **Note**: The session is ended as soon as this is called, and any `addProperties` handlers will * called immediately. */ earlyStop(reason: string, description?: string): void; end(endDetails: { contentId?: string | null; experienceKey: string; stoppedBy: 'new-experience'; } | { stoppedBy: 'beforeunload'; } | { description?: string; reason: string; stoppedBy: 'early-stop'; }): void; }