import { type EventType, type ErrorDetails } from './schema'; import type { ITelemetrySink } from './sink/sink-interface'; import type { Context } from '../../api/context'; import type { CliIoHost } from '../io-host/cli-io-host'; export interface TelemetrySessionProps { readonly ioHost: CliIoHost; readonly client: ITelemetrySink; readonly arguments: any; readonly context: Context; } export interface TelemetryEvent { readonly eventType: EventType; readonly duration: number; readonly error?: ErrorDetails; readonly counters?: Record; } /** * Timer of a single event */ export interface Timing { /** * Total time spent in this operation */ totalMs: number; /** * Count of operations that together took `totalMs`. */ count: number; } export declare class TelemetrySession { private readonly props; private ioHost; private client; private _sessionInfo?; private span?; private _nextEventCounters?; private count; constructor(props: TelemetrySessionProps); begin(): Promise; attachRegion(region: string): Promise; /** * Attach a language guess */ attachLanguage(language: string | undefined): void; /** * Attach our best guess at running under an agent or not */ attachAgent(isAgent: boolean | undefined): void; /** * Temporarily attach counters for the next event operation. * * They may be committed to the sent telemetry later. */ attachCountersToNextEvent(counters: Record): void; /** * Attach the CDK library version * * By default the telemetry will guess at the CDK library version if it so * happens that the CDK project is an NPM project and the CDK CLI is executed * in the root of NPM project with `aws-cdk-lib` available in `node_modules`. * This may succeed or may fail. * * Once we have produced and loaded the cloud assembly more accurate * information becomes available that we can add in. */ attachCdkLibVersion(libVersion: string): void; /** * When the command is complete, so is the CliIoHost. Ends the span of the entire CliIoHost * and notifies with an optional error message in the data. */ end(error?: ErrorDetails): Promise; emit(event: TelemetryEvent): Promise; private get sessionInfo(); }