/** * SaaS Telemetry Methods — Mixin * * Installs telemetry reporting methods onto SaaSClient.prototype. * Uses the same mixin pattern as gateway-api.ts. */ export function installTelemetryMethods(ClientClass: { prototype: any }): void { const proto = ClientClass.prototype; /** Report anonymous usage telemetry (token counts only, no content) */ proto.reportTelemetry = async function (this: { request(method: string, path: string, body?: unknown): Promise }, data: { device_id: string; app_version: string; entries: Array<{ model_id: string; input_tokens: number; output_tokens: number; latency_ms?: number; success: boolean; error_type?: string; timestamp: string; connection_mode: string; }>; }): Promise<{ accepted: number; rejected: number }> { return this.request<{ accepted: number; rejected: number }>( 'POST', '/api/v1/telemetry/report', data, ); }; /** Report audit log summary (action types and counts only, no content) */ proto.reportAuditSummary = async function (this: { request(method: string, path: string, body?: unknown): Promise }, data: { device_id: string; entries: Array<{ action: string; target: string; result: string; timestamp: string; }>; }): Promise<{ accepted: number; total: number }> { return this.request<{ accepted: number; total: number }>( 'POST', '/api/v1/telemetry/audit', data, ); }; }