import type { TelemetryAttributes, TelemetryOptions } from './types.js'; /** * Telemetry client for sending events to Application Insights. * * @example * ```typescript * const telemetry = new Telemetry({ * project: 'my-app', * appInsightsKey: 'InstrumentationKey=...', * version: '1.0.0', * dataDir: '/path/to/data', * }); * * await telemetry.start(); * telemetry.sendEvent('USER_ACTION', { action: 'click' }); * telemetry.stop(); * ``` */ export declare class Telemetry { private attributes; private cliId; private project; private client; private sessionId; private started; private version; private appInsightsKey; private traceLog; private flushIntervalMs; private flushTimer; private isCI; /** * Check if telemetry is disabled via environment variables. * Supports both SF_DISABLE_TELEMETRY (sf CLI standard) and SFCC_DISABLE_TELEMETRY. */ static isDisabled(): boolean; /** * Get the connection string for telemetry, respecting disable flags and env overrides. * @param projectDefault - Default connection string from project config (e.g., package.json) * @returns Connection string to use, or undefined if telemetry should be disabled */ static getConnectionString(projectDefault?: string): string | undefined; constructor(options: TelemetryOptions); /** * Add additional attributes to include with all future events. */ addAttributes(attributes: TelemetryAttributes): void; /** * Send a telemetry event. Events are buffered until you call {@link flush} or * {@link stop}. Use this for batching; use {@link sendEventAndFlush} when you * need one event sent before continuing. * * @param eventName - Name of the event (e.g., 'SERVER_STATUS', 'TOOL_CALLED') * @param attributes - Event-specific attributes (only string/number/boolean are sent) */ sendEvent(eventName: string, attributes?: TelemetryAttributes): void; /** * Send a telemetry event and flush immediately. Use this when you need the event * delivered before continuing (e.g. after a tool call or server lifecycle event), * so you don't have to remember to call {@link flush}. For batching multiple * events and flushing once, use {@link sendEvent} and then {@link flush}. * * @param eventName - Name of the event (e.g., 'SERVER_STATUS', 'TOOL_CALLED') * @param attributes - Event-specific attributes (only string/number/boolean are sent) */ sendEventAndFlush(eventName: string, attributes?: TelemetryAttributes): Promise; /** * Send an exception to telemetry. * * @param error - The error to report * @param attributes - Additional attributes to include with the exception */ sendException(error: Error, attributes?: TelemetryAttributes): void; /** * Start the telemetry reporter. * Must be called before sending events. */ start(): Promise; /** * Flush pending telemetry events without stopping the client. * Use this for long-running processes that need to ensure events are sent periodically. */ flush(): Promise; /** * Stop the telemetry client and flush any pending events. * Includes a delay to allow async HTTP requests to complete. */ stop(): Promise; private buildEventProperties; private createClient; }