/**
 * Telemetry config. `source` is stamped as an EVENT property on every capture
 * (never a person property) so the same human stays merged across surfaces
 * while events remain filterable by surface.
 */
export type TelemetryOptions = {
    enabled?: boolean;
    source?: 'cli' | 'mcp' | 'core' | 'tryout';
    editor?: string;
};
type AgentToolSummary = {
    toolCallCounts?: Record<string, number>;
    readTargets?: string[];
    editTargets?: string[];
    writeTargets?: string[];
};
export declare class TelemetryService {
    private hashTelemetryValue;
    private posthog;
    private isEnabled;
    /** Default `source` stamped on every event (overridable per-call). */
    private readonly defaultSource;
    /** MCP editor (`--editor`) stamped on events when present. */
    private readonly editor?;
    constructor(options?: boolean | TelemetryOptions);
    /**
     * Returns the canonical analytics identity: the Supabase user id when known,
     * else the email, else a stable anonymous ID. Keying on user id means the
     * same human is one PostHog person across surfaces and survives email changes.
     */
    private get distinctId();
    /**
     * Identify the user in PostHog keyed on the canonical Supabase user id, and
     * merge their prior identities (email + anonymous ID) into it so history is
     * not split. `source` is intentionally NOT set as a person property — it is
     * an event property so the person stays merged across surfaces.
     *
     * No-op if the current user id has already been aliased+identified in a prior
     * run: posthog-node has no dedup, and this is called from the constructor on
     * every CLI/server process start. Without persistence we'd emit a
     * $create_alias event on every invocation.
     */
    identifyUser(): void;
    /**
     * Track an event with properties
     */
    track(event: string, properties?: Record<string, unknown>): void;
    /**
     * Track CLI session start
     */
    trackSessionStart(options: {
        framework?: string;
        port?: number;
        userPort?: number;
        debugMode?: boolean;
    }): void;
    /**
     * Track code modification request - NO CODE CONTENT, just metadata
     */
    trackCodeModification(data: {
        success: boolean;
        instruction?: string;
        instructionLength?: number;
        elementCount?: number;
        fileCount?: number;
        errorType?: string;
        modificationTimeMs?: number;
    }): void;
    /**
     * Track agentic code modification request
     */
    trackAgentModification(data: {
        success: boolean;
        instruction?: string;
        instructionLength?: number;
        elementCount?: number;
        fileCount?: number;
        errorType?: string;
        modificationTimeMs?: number;
        model?: string;
        sessionId?: string;
        ttfmMs?: number;
        traceId?: string;
        agentRunId?: string;
        posthogSessionId?: string;
    }): void;
    /**
     * Track the start of a desktop agent run with correlation identifiers.
     */
    trackAgentRunStarted(data: {
        traceId: string;
        agentRunId: string;
        instructionLength: number;
        elementCount: number;
        posthogSessionId?: string;
        resumeSessionId?: string;
        model?: string;
        source?: string;
    }): void;
    /**
     * Track successful completion of a desktop agent run.
     */
    trackAgentRunCompleted(data: {
        traceId: string;
        agentRunId: string;
        sessionId?: string;
        posthogSessionId?: string;
        model?: string;
        durationMs: number;
        ttfmMs?: number;
        ttfwMs?: number;
        fileCount?: number;
        toolSummary?: AgentToolSummary;
        source?: string;
    }): void;
    /**
     * Track failed desktop agent runs for incident debugging.
     */
    trackAgentRunFailed(data: {
        traceId: string;
        agentRunId: string;
        sessionId?: string;
        posthogSessionId?: string;
        model?: string;
        durationMs: number;
        errorType: string;
        errorMessage: string;
        ttfmMs?: number;
        ttfwMs?: number;
        toolSummary?: AgentToolSummary;
        source?: string;
    }): void;
    /**
     * Track agent abort events with enough context to distinguish inactivity timeouts,
     * explicit user cancels, and unexpected process exits.
     */
    trackAgentAborted(data: {
        traceId?: string;
        agentRunId?: string;
        sessionId?: string;
        posthogSessionId?: string;
        model?: string;
        abortReason: 'inactivity_timeout' | 'user_cancel' | 'process_exit';
        lastToolName?: string;
        lastToolMs?: number;
        elapsedMs: number;
        inputTokens?: number;
        source?: string;
    }): void;
    /**
     * Track component search
     */
    trackComponentSearch(data: {
        success: boolean;
        resultCount?: number;
        searchTimeMs?: number;
    }): void;
    /**
     * Track git operations
     */
    trackGitOperation(data: {
        operation: 'commit' | 'publish' | 'branch_create';
        success: boolean;
        errorType?: string;
    }): void;
    /**
     * Track errors
     */
    trackError(data: {
        errorType: string;
        context: string;
        framework?: string;
    }): void;
    /**
     * Capture an exception with full stack trace for PostHog Error Tracking
     */
    captureException(error: unknown, context: string): void;
    /**
     * Track element selection patterns
     */
    trackElementSelection(data: {
        method: 'click' | 'search';
        elementType?: string;
        framework?: string;
    }): void;
    private buildTryoutContextProperties;
    trackTryoutSessionProvisionStarted(data: {
        isAuthenticatedRequest: boolean;
        requireSignedInUsers: boolean;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutSessionProvisionCompleted(data: {
        demoSessionId: string;
        timeToReadyMs: number;
        activeSessionsAfter: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutSessionProvisionFailed(data: {
        errorType: string;
        statusCode?: number;
        timeToFailureMs?: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutSessionCapacityRejected(data: {
        activeSessions: number;
        maxActiveSessions: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutSessionMetadataRequested(data: {
        demoSessionId: string;
        found: boolean;
        deploymentEnv?: string;
    }): void;
    trackTryoutSessionExpiredCleaned(data: {
        demoSessionId: string;
        cleanupDurationMs: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutSessionCleanupFailed(data: {
        demoSessionId?: string;
        errorType: string;
        stage: 'runtime_stop' | 'worktree_remove' | 'session_close' | 'cleanup_loop';
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutRuntimeStarted(data: {
        demoSessionId: string;
        rivetPort: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutRuntimeShutdown(data: {
        demoSessionId: string;
        signal?: string;
        deploymentEnv?: string;
    }): void;
    trackTryoutRuntimeStoppedIdle(data: {
        demoSessionId: string;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutRuntimeRehydrationStarted(data: {
        demoSessionId: string;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutRuntimeRehydrationCompleted(data: {
        demoSessionId: string;
        timeToReadyMs: number;
        rivetPort: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutRuntimeRehydrationFailed(data: {
        demoSessionId: string;
        errorType: string;
        timeToFailureMs?: number;
        deploymentEnv?: string;
        templateProject?: string;
    }): void;
    trackTryoutAuthStoreCompleted(data: {
        demoSessionId?: string;
        hasRefreshToken: boolean;
        deploymentEnv?: string;
    }): void;
    trackTryoutAuthStoreFailed(data: {
        reason: string;
        statusCode?: number;
        demoSessionId?: string;
        deploymentEnv?: string;
    }): void;
    trackTryoutProxySessionMissing(data: {
        demoSessionId: string;
        deploymentEnv?: string;
    }): void;
    /**
     * Build shared MCP correlation properties for event capture.
     */
    private buildMCPCorrelationProperties;
    /**
     * Track MCP session start (includes `mcp_editor` for PostHog breakdowns: cursor / codex / claude / other).
     */
    trackMCPSessionStart(data: {
        framework: string;
        devServerStarted: boolean;
        sessionId: string;
        /** From `rivet mcp --editor`; omitted or legacy clients are recorded as `claude`. */
        mcpEditor?: string;
        browserSessionId?: string;
        browserDistinctId?: string;
    }): void;
    /**
     * Track changes queued (agent received pending changes)
     */
    trackChangesQueued(data: {
        sessionId: string;
        styleChangeCount: number;
        textChangeCount: number;
        commentCount?: number;
        chatCount?: number;
        round: number;
        traceId?: string;
        agentRunId?: string;
        browserSessionId?: string;
        browserDistinctId?: string;
    }): void;
    /**
     * Track MCP session end
     */
    trackMCPSessionEnd(data: {
        sessionId: string;
        rounds: number;
        durationMs: number;
        browserSessionId?: string;
        browserDistinctId?: string;
    }): void;
    /**
     * Track when the user clicks "Send to Claude" and changes are queued (before the agent picks them up).
     * Compare with changes_queued (agent received) to detect "sent but not picked up".
     */
    trackMCPChangesSent(data: {
        sessionId: string;
        styleChangeCount: number;
        textChangeCount: number;
        commentCount?: number;
        chatCount?: number;
        round?: number;
        traceId?: string;
        agentRunId?: string;
        browserSessionId?: string;
        browserDistinctId?: string;
    }): void;
    /**
     * Track the start of background scaffold + npm install for an agent-
     * variants fresh-project session.
     */
    trackAgentVariantsScaffoldStarted(data: {
        sessionId: string;
        variantCount: number;
        designContext?: Array<{
            slot: number;
            kind: 'slug' | 'markdown';
            slug?: string;
            markdownLabel?: string;
        }> | null;
    }): void;
    /**
     * Track successful completion of background scaffold + install.
     */
    trackAgentVariantsScaffoldCompleted(data: {
        sessionId: string;
        durationMs: number;
        installDurationMs: number;
        variantCount: number;
    }): void;
    /**
     * Track failure of background scaffold + install.
     */
    trackAgentVariantsScaffoldFailed(data: {
        sessionId: string;
        errorCode: string;
        durationMs: number;
    }): void;
    /**
     * Track the ranked design-system list chosen for a fresh-project session.
     */
    trackAgentVariantsFreshDesignSystemsRanked(data: {
        sessionId: string;
        entries: Array<{
            slot: number;
            kind: 'slug' | 'markdown';
            slug?: string;
            markdownLabel?: string;
        }>;
        count: number;
    }): void;
    /**
     * Track the per-slot design-system pin chosen for a fresh-project session.
     */
    trackAgentVariantsFreshDesignSystemsPinned(data: {
        sessionId: string;
        slot: number;
        kind: 'slug' | 'markdown';
        slug?: string;
        markdownLabel?: string;
        sourceMode: 'ranking' | 'explicit-slug' | 'explicit-markdown' | 'fallback';
    }): void;
    /**
     * Track a fresh-variant dev server reaching ready state.
     */
    trackAgentVariantsFreshDevServerStarted(data: {
        sessionId: string;
        variantId: string;
        port: number;
    }): void;
    /**
     * Track a fresh-variant dev server failing to come up.
     */
    trackAgentVariantsFreshDevServerFailed(data: {
        sessionId: string;
        variantId: string;
        errorCode: string;
    }): void;
    /**
     * Track materialize of a fresh-project pick into its user-facing
     * destination after commit_variant.
     */
    trackAgentVariantsNewProjectMaterialized(data: {
        sessionId: string;
        variantId: string;
        destinationPath: string;
        changedFilesCount: number;
        durationMs: number;
    }): void;
    trackAgentVariantsSourceContextQuality(data: {
        sessionId: string;
        sourceUrlCount: number;
        artifactCount: number;
        hasScreenshotReferences: boolean;
        preserveBrand: boolean;
    }): void;
    trackAgentVariantsBriefQuality(data: {
        sessionId: string;
        briefCount: number;
        evidenceBackedCount: number;
        shortBriefCount: number;
    }): void;
    trackAgentVariantsRefinePass(data: {
        sessionId: string;
        variantId: string;
        status: 'completed' | 'skipped' | 'failed' | 'missing';
    }): void;
    trackAgentVariantsActiveProjectTransition(data: {
        sessionId: string;
        success: boolean;
        reasonCode: string;
        destinationPath: string | null;
    }): void;
    /**
     * Track a variant-request batch received via /api/mcp/queue-changes.
     * Variant-request batches do NOT start an apply run, so the normal
     * `mcp_changes_sent` / `changes_queued` / `agent_run_started` chain is
     * suppressed; this event takes its place at intake.
     */
    trackCommentVariantRequestReceived(data: {
        sessionId: string;
        requestedCount: number;
        traceId?: string;
        agentRunId?: string;
        browserSessionId?: string;
        browserDistinctId?: string;
    }): void;
    /**
     * Flush pending events without tearing down the client.
     * Safe to call between sessions when the process stays alive.
     */
    flush(): Promise<void>;
    /**
     * Flush any pending events and tear down the client.
     * Call once before the process exits.
     */
    shutdown(): Promise<void>;
}
export {};
//# sourceMappingURL=TelemetryService.d.ts.map