import { HoistService, InitContext, PageState, PlainObject } from '@xh/hoist/core'; import { WebSocketTelemetry } from '@xh/hoist/svc/WebSocketService'; /** * Service for gathering data about the current state and health of the client app, for submission * to the server or review on the console during interactive troubleshooting. * * Hoist sends this data once on application load and can be configured to send at regular intervals * throughout a user's session via the `xhActivityTracking.clientHealthReport` app config. Reports * are submitted via activity tracking for review within the Admin Console. */ export declare class ClientHealthService extends HoistService { static instance: ClientHealthService; private sources; initAsync(ctx: InitContext): Promise; get enabled(): boolean; /** @returns a customizable report with metrics capturing client app/session state. */ getReport(): ClientHealthReport; /** @returns a report, formatted for easier viewing in console. */ getFormattedReport(): PlainObject; /** * Register a new source for app-specific data to be sent with each report. * @param key - key under which to report the data - can be used to remove this source later. * @param callback - function returning serializable to include with each report. */ addSource(key: string, callback: () => any): void; /** Unregister a previously-enabled source for client health report data. */ removeSource(key: string): void; /** * Generate and submit a report to the server, via TrackService. * * For ad-hoc troubleshooting. Apps may also configure this service to * submit on regular intervals. */ sendReportAsync(): Promise; getGeneral(): GeneralData; getConnection(): ConnectionData; getMemory(): MemoryData; getCustom(): PlainObject; private sendReportInternal; } export interface GeneralData { startTime: number; durationMins: number; idleMins: number; pageState: PageState; } export interface ConnectionData { downlink: number; effectiveType: string; rtt: number; } export interface MemoryData { modelCount: number; usedPctLimit?: number; jsHeapSizeLimit?: number; totalJSHeapSize?: number; usedJSHeapSize?: number; } export interface ClientHealthReport { general: GeneralData; connection: ConnectionData; memory: MemoryData; webSockets: WebSocketTelemetry; }