/** * Anonymous usage analytics via PostHog. * * ALL sharing logic lives in this single file for auditability. * Events contain no PII — only aggregate counts, enumerated types, and anonymous IDs. * * Network calls happen at exactly one point: * On server startup, reporting previous sessions' telemetry from SQLite. * * One event per session: a single `session` event with flattened properties. * No in-memory buffering. No shutdown flushes. All data is persisted locally * in SQLite first, then reported on the next startup (fire-and-forget). * * See docs/telemetry.md for full details. */ import { type UnreportedSession } from './storage/NoteRepository.js'; export type LibraryEnvironment = 'dev' | 'test' | 'production'; export type PackageSource = 'source' | 'packaged'; /** * Classify the analytics environment for payloads. * * Runtime form reads the explicit OPEN_ZK_KB_TELEMETRY_ENV variable and the * package source. The variable may explicitly select only `test` (synthetic * validation); `dev` and `production` always derive from source location and * cannot be overridden at runtime. * * Pure form accepts the package source plus an optional explicit environment * so tests can prove source=>dev, packaged=>production, and explicit test * winning even for a packaged install. */ export declare function classifyLibraryEnvironment(packageSource: PackageSource, explicitEnvironment?: string): LibraryEnvironment; export declare function classifyLibraryEnvironment(): LibraryEnvironment; export { normalizeTelemetryClient } from './storage/NoteRepository.js'; export interface SessionProperties { client: string; client_version: string | null; version: string; os_platform: string; vault_size: number; duration_ms: number | null; total_invocations: number; tool_store: number; tool_ingest: number; tool_search: number; tool_context: number; tool_open: number; tool_get: number; tool_health: number; tool_maintain: number; tool_mine: number; tool_template: number; session_id: string; models: string[]; } export interface AnalyticsEvent { event: 'session'; properties: SessionProperties; } export declare function isSharingEnabled(): boolean; export declare function getOrCreateAnalyticsId(): string; /** * Report previous sessions' telemetry to PostHog. * Called on server startup (fire-and-forget). Queries unreported sessions * from SQLite, sends a single batch POST, marks them reported on success. * * One `session` event per unreported session with flattened tool counts. * * @param repo - Object providing session query/mark methods */ export declare function reportPreviousSessions(repo: { getUnreportedSessions: (limit?: number) => UnreportedSession[]; markSessionsReported: (ids: string[]) => void; releaseClaimedSessions: (ids: string[]) => void; recoverAbandonedClaims: () => void; }): Promise; //# sourceMappingURL=analytics.d.ts.map