import type { SessionReplayOptions, SessionReplayStartResult } from "./session-replay.js"; export { scrubUrl } from "./url-scrub.js"; export { addErrorBreadcrumb, captureException, captureMessage, isErrorCaptureInstalled, type CaptureExceptionContext, type CapturedExceptionEvent, type ExceptionBreadcrumb, type ExceptionLevel, } from "./error-capture.js"; export type { SessionReplayConsoleOptions, SessionReplayNetworkOptions, SessionReplayOptions, SessionReplayStartResult, SessionReplayContext, SessionReplayLinkOptions, SessionReplayUrlMatcher, } from "./session-replay.js"; export { getSessionReplayContext, getSessionReplayUrl, } from "./session-replay.js"; declare global { interface Window { gtag?: (...args: any[]) => void; __AGENT_NATIVE_CONFIG__?: { sentryDsn?: string; sentryEnvironment?: string; /** * Hosted Realtime Gateway config. Impersonal (same for every visitor), * so it is safe inside the CDN-cached SSR shell — unlike the per-user * subscribe token, which is minted client-side after load. Absent when * the app uses the in-process (local) transport. */ realtime?: { transport?: string; gatewayBaseUrl?: string; }; }; } } type GetDefaultProps = (name: string, properties: Record) => Record; /** * First-party, Sentry-style error capture configuration. Pass `true`/`false` * to force on/off, or an options object to tune it. When omitted, error * capture auto-enables whenever a first-party analytics public key is * configured (mirroring pageview + session-replay auto-enable). */ export type ErrorCaptureConfigOptions = { /** Build/release identifier attached to every captured exception. */ release?: string; /** Deployment environment (e.g. "production"). Defaults to Vite MODE. */ environment?: string; /** Auto-capture `window.onerror`. Defaults to true. */ captureGlobalErrors?: boolean; /** Auto-capture `unhandledrejection`. Defaults to true. */ captureUnhandledRejections?: boolean; /** Breadcrumb ring-buffer size. Defaults to 20. */ maxBreadcrumbs?: number; }; export type ConfigureTrackingOptions = { /** * Agent Native first-party analytics public key. This mirrors hosted * analytics SDKs where consumers pass the key at setup time instead of * relying on build-time environment variables. */ key?: string; /** Alias for `key`, matching the replay ingest payload name. */ publicKey?: string; /** First-party analytics track endpoint. */ endpoint?: string; getDefaultProps?: GetDefaultProps; /** * Disable content-capturing analytics such as interaction autocapture and * session replay while retaining pageviews, explicit events, and Sentry. */ contentCapture?: boolean; /** Resolve content capture synchronously for each browser pathname. */ contentCaptureForPath?: (pathname: string) => boolean; /** * Whether tracking may read the authenticated agent-engine status endpoint. * Disable this on anonymous/public routes to avoid an expected 401 request. */ llmConnectionStatus?: boolean; /** Disable framework auth refresh when the host owns identity/session state. */ authSessionRefresh?: boolean; /** Disable automatic history/pageview events when the host emits its own. */ pageviewTracking?: boolean; sessionReplay?: boolean | SessionReplayOptions; /** * First-party, Sentry-style error capture. Auto-captures uncaught errors * and unhandled rejections and exposes `captureException`/`captureMessage`. * Auto-enables when a public key is present; pass `false` to disable. */ errorCapture?: boolean | ErrorCaptureConfigOptions; }; export type TrackingIdentityUser = { id?: string; email?: string; username?: string; }; /** * Dedicated first-party analytics event name for captured exceptions. The * analytics server ingest forks events with this name into the error-capture * tables (error_issues / error_events) while still recording them in * analytics_events for alerting. Keep in sync with the template server ingest. */ export declare const AGENT_NATIVE_EXCEPTION_EVENT_NAME = "$exception"; export interface FirstTouchAttribution { ref?: string; via?: string; utm_source?: string; utm_medium?: string; utm_campaign?: string; utm_content?: string; utm_term?: string; landing_path?: string; landing_referrer?: string; landed_at?: string; } export declare function getAnalyticsAnonymousId(): string | undefined; export declare function getAnalyticsSessionId(): string | undefined; /** * Return the parsed first-touch referral attribution captured for this * visitor, or `null` when none is stored. Reads from `localStorage` * (`an_attribution`). SSR-safe and defensive. */ export declare function getFirstTouchAttribution(): FirstTouchAttribution | null; /** * Attach the current user to Sentry events from the browser. Pass `null` to * clear (e.g. on logout). If Sentry isn't initialized yet, the value is * buffered and applied once `ensureSentry()` runs. * * Pass `orgId` to also tag events with the active organization ID — useful * for filtering Sentry by tenant. */ export declare function setSentryUser(user: TrackingIdentityUser | null, orgId?: string | null): void; /** Neutral alias for hosts that own identity outside Sentry. */ export declare function setTrackingIdentity(user: TrackingIdentityUser | null, orgId?: string | null): void; export interface ClientCaptureContext { /** Searchable Sentry tags (low-cardinality strings only). */ tags?: Record; /** * High-cardinality / structured payload — not searchable but visible in * the Sentry event detail (file sizes, request URLs, response body * tails, etc.). */ extra?: Record; /** * Grouped contexts shown as separate cards in the Sentry event UI. */ contexts?: Record>; } /** * Capture an exception to Sentry from browser code without forcing the * caller to depend on `@sentry/browser` directly. * * Templates can route a thrown Error through here on a known failure path * (chunk-upload 500, thumbnail upload, etc.) to attach searchable tags and * structured extra context. No-ops gracefully when Sentry isn't * initialized — never throws back into the caller, so a Sentry hiccup * can't mask the original error. */ export declare function captureClientException(error: unknown, context?: ClientCaptureContext): string | undefined; /** * Public browser-side error capture utility, mirroring `trackEvent()`: * templates can call `captureError(err, { tags, extra, contexts })` without * depending on Sentry directly. Sentry receives the event when a browser DSN * is configured; otherwise this is a quiet no-op. */ export declare function captureError(error: unknown, context?: ClientCaptureContext): string | undefined; export type AgentChatLifecycleEvent = { phase: "surface-mounted" | "run-observed" | "run-stopped"; surface?: string; threadId?: string; runId?: string; tabId?: string; }; /** * Record a content-free, browser-session-linked chat lifecycle marker and add * the same marker to session replay when replay is configured. The bounded * global de-dupe survives React Strict Mode remounts without retaining keys * forever. */ export declare function trackAgentChatLifecycle(input: AgentChatLifecycleEvent): void; export declare function configureTracking(options: ConfigureTrackingOptions): void; export declare function setTrackingContentCaptureEnabled(enabled: boolean): void; export declare function startSessionReplay(options?: SessionReplayOptions): Promise; export declare function maybeStartSessionReplay(options?: SessionReplayOptions): Promise; export declare function stopSessionReplay(reason?: string): Promise; export declare function trackEvent(name: string, params?: Record): void; export declare function trackSessionStatus(signedIn: boolean): void; //# sourceMappingURL=analytics.d.ts.map