File size: 586 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import type { TelemetryClient, TelemetryProperties } from '#/index';
export interface TelemetryRecord {
readonly event: string;
readonly sessionId: string | null;
readonly properties?: TelemetryProperties;
}
export function recordingTelemetry(records: TelemetryRecord[]): TelemetryClient {
return {
track: (event, properties) => {
records.push({ event, sessionId: null, properties });
},
withContext: (patch) => ({
track: (event, properties) => {
records.push({ event, sessionId: patch.sessionId ?? null, properties });
},
}),
};
}
|