kimi-code / packages /node-sdk /src /telemetry.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
4e23b01 verified
Raw
History Blame Contribute Delete
787 Bytes
export type TelemetryPropertyValue = boolean | number | string | undefined | null;
export type TelemetryProperties = Readonly<Record<string, TelemetryPropertyValue>>;
export interface TelemetryContextPatch {
readonly sessionId?: string | null;
}
export interface TelemetryClient {
track(event: string, properties?: TelemetryProperties): void;
withContext?(patch: TelemetryContextPatch): TelemetryClient;
setContext?(patch: TelemetryContextPatch): void;
}
export const noopTelemetryClient: TelemetryClient = {
track: () => {},
withContext: () => noopTelemetryClient,
setContext: () => {},
};
export function withTelemetryContext(
telemetry: TelemetryClient,
patch: TelemetryContextPatch,
): TelemetryClient {
return telemetry.withContext?.(patch) ?? telemetry;
}