/** * `TType` lets a platform name its own event kinds without editing core, and every core class * flows it through. Defaults to `string`, because the set of NAMES is open — a platform that * wants a closed union passes its own. Shared shapes stay shared; only the vocabulary is open. */ type BaseEvent = { type: TType; timestamp?: number; end_timestamp?: number; start_timestamp?: number; span_name?: string; id: string; spanId: string; parentSpanId: string | undefined; traceId: string | undefined; attributes?: Record; }; type UserIdentifiers = { id: string; email: string; role: string; name: string; organization: string; properties: Record; }; type NetworkEventAttributes = { type: "HTTP"; resource_name: string; status: string; subType: string; level?: string; timestamp?: number; operation: { name: string; startTime?: number; endTime?: number; }; url: { full: string; }; http: { route: string; path: string; status: string; method: string; request: { headers: Record; method: string; }; response: { headers: Record; status_code: string; }; duration_ms?: number; }; gc: { request: { body: string; }; response: { body: string; }; }; error?: { type: string; }; }; type Stacktrace = { filename: string; function: string; lineno: number; colno: number; }; type ErrorEventAttributes = { error_type: string; error_message: string; error_stacktrace?: Array; error_fingerprint: string; error_handled: boolean; error_metadata?: Record; /** * How many occurrences this event stands for, itself included, when repeats * in the same batch were merged into it (errors.deduplication). Absent means * one; the true count of an error is the sum of this (or 1) over its events. * Set on a copy when the batch is sent, so `beforeSend` and `enrichEvent` * never see it: they see every occurrence instead. */ error_repeat_count?: number; }; declare const LOG_LEVELS: readonly ["log", "info", "warn", "error", "debug", "trace"]; type LogLevel = (typeof LOG_LEVELS)[number]; type LogEventAttributes = { message: string; level: string; /** * On an error-level log: how many occurrences it stands for, like an * exception's `error_repeat_count` (errors.deduplication). Absent means one. */ log_repeat_count?: number; } & Record; type UserDefinedEventAttributes = { custom_event_name: string; custom_event_attributes?: Record; }; type PerformanceEventAttributes = { performance_metric_name: string; performance_metric_value: number; performance_metric_id: string; performance_metric_navigation_type: string; }; type PrivacyLevel = "mask-sensitive" | "mask-all" | "allow"; /** The event surface a redactor field belongs to. */ type RedactKind = "request-body" | "response-body" | "query" | "header" | "log" | "error"; interface RedactField { /** Immediate key of the value; `""` for whole-string fields (log/error message). */ key: string; /** The leaf value — always a primitive, never an object/array. */ value: string | number | boolean | null; /** Full key path to this leaf; `[]` for whole-string fields. */ path: string[]; /** Which event surface this field came from (header name is in `key`). */ kind: RedactKind; /** Whether the built-in patterns + `sensitiveKeys` would redact this field. */ sensitive: boolean; } /** * Per-field redaction hook. Invoked on each LEAF value during the redaction * walk (never on objects/arrays — the SDK recurses those itself and never * passes them here). Return a primitive replacement, or `undefined` to defer * to the SDK default (`sensitive ? '[REDACTED]' : value`) — so a hook that * only cares about one field can't accidentally disable masking elsewhere. */ type Redactor = (field: RedactField) => string | number | boolean | null | undefined; interface PrivacyOptions$1 { /** * Master switch for data masking. `'mask-sensitive'` (default) masks only * SENSITIVE data (sensitive-key matches, platform-flagged UI elements) and * redacts network/log/error payloads while capturing the rest; * `'mask-all'` also masks all captured input/text; `'allow'` opts out. * Platform packages define what "sensitive UI element" means on their host. */ level?: PrivacyLevel; /** Redact network request/response bodies. Default on unless `level` is `'allow'`. */ maskNetworkBodies?: boolean; /** Redact network URL query params. Default on unless `level` is `'allow'`. */ maskNetworkQueryParams?: boolean; /** Redact console log messages and attributes. Default on unless `level` is `'allow'`. */ maskLogs?: boolean; /** Redact error messages and metadata (not stack frames). Default on unless `level` is `'allow'`. */ maskErrors?: boolean; /** Extra case-insensitive key substrings treated as sensitive, merged with the built-in patterns. */ sensitiveKeys?: string[]; /** * Per-field custom redaction hook for captured events. Called on each leaf * value during the redaction walk with the original typed value; see * {@link Redactor}. For arbitrary whole-event changes use `enrichEvent`. */ redact?: Redactor; } /** Distributed-tracing header propagation for outgoing network requests. */ interface TracingOptions { /** * Request URLs that receive injected tracing headers: whole-URL matches where * only `*` is a wildcard. Which strings a pattern is matched against is the * platform's (the browser adds a same-origin request's path). */ propagationUrls?: string[]; /** Inbound header names to read/propagate onto traced requests. */ propagationHeaders?: string[]; /** Header name carrying the trace id. */ traceIdHeaderName?: string; /** Header name carrying the span id. */ spanIdHeaderName?: string; /** Origin tag stamped on injected trace headers. */ origin?: { name: string; value: string; }; } /** Batching and delivery of outgoing event batches. */ interface TransportOptions { /** * Max events buffered before a batch is flushed (default 10). A merged error * (see {@link ErrorDeduplicationOptions}) is one event, however often it repeated. */ batchSize?: number; /** Max ms a batch waits before flushing regardless of size (default 10000). */ batchTimeout?: number; /** Gzip-compress outgoing batches; offloaded to the platform's async encoder when it has one (default true). */ compression?: boolean; } /** * Merging repeats of the same error, so an error loop doesn't send an event per * occurrence. Within each batch, a repeat of an exception or error-level log * already waiting to be sent is counted on that event (`error_repeat_count` / * `log_repeat_count`, the occurrences it stands for) instead of sent again, so a * batch carries one event per distinct error, with the first occurrence's * context. A merged event counts as one toward `transport.batchSize`, so a * loop alone doesn't fill a batch: it goes out with the batch, on * `transport.batchTimeout`, when other events fill it, or on a lifecycle flush. * "The same" means the same page or screen, and for an exception the same type, * message (first 400 characters, after redaction), handled flag and stack; for a * log, the same message. */ interface ErrorDeduplicationOptions { /** Merge repeated errors within a batch (default true). `false` sends every occurrence. */ enabled?: boolean; } /** How errors are reported. */ interface ErrorReportingOptions { /** * Merging repeated identical errors; see {@link ErrorDeduplicationOptions}. * `false` / `true` is shorthand for `{ enabled: false }` / `{ enabled: true }`. */ deduplication?: ErrorDeduplicationOptions | boolean; } interface SDKOptions$1 = BaseEvent> { /** * Which signal listeners to enable, by name. Empty array = all. The NAMES * are platform-defined (each platform ships its own listener set) — the * platform package narrows this to its literal union. */ enabledEvents: string[]; sessionSampleRate: number; debug: boolean; excludedUrls?: Array; beforeSend?(event: TEvent): boolean; enrichEvent?(event: TEvent): TEvent; /** * Unified privacy / data-masking config for every captured surface. * ON by default (`level: 'mask-sensitive'`); see {@link PrivacyOptions}. */ privacy?: PrivacyOptions$1; /** Distributed-tracing header propagation; see {@link TracingOptions}. */ tracing?: TracingOptions; /** Batching & delivery of outgoing events; see {@link TransportOptions}. */ transport?: TransportOptions; /** How errors are reported: merging of repeated exceptions and error-level logs; see {@link ErrorReportingOptions}. */ errors?: ErrorReportingOptions; /** * Target maximum wall-clock duration of a session, in ms. Enforced LAZILY on activity, so NOT * a hard bound — an idle session keeps its id past the cap, which deliberately avoids minting * phantom sessions. Also bounded by a 30-minute inactivity gap, counting raw input as * presence so passive reading does not end a session. * * Defaults to 4 hours; must be 1 minute to 8 hours, else falls back with a warning. */ sessionMaxDuration?: number; } interface SDKConfigInput$1 = BaseEvent> { apiKey: string; cluster: string; environment: string; dsn: string; appId: string; namespace?: string; releaseId?: string; user?: Partial; options?: Partial>; sessionId?: string; } type DomEventAttributes = { dom_event_type: string; dom_event_coordinates: { clientX: number; clientY: number; }; dom_event_target: { tagName: string; id: string; className: string; text: string; role: string; accessibleName: string; ariaLabel: string; title: string; alt: string; placeholder: string; name: string; inputType: string; href: string; }; dom_event_selector: string; dom_event_key_code: string; }; type PageLoadEventAttributes = { page_url: string; page_resources: { count: number; totalSize: number; totalDuration: number; byType: { [key: string]: { count: number; size: number; duration: number; }; }; }; page_referrer: string; page_load_time: number; }; type NavigationEventAttributes = { page_url: string; from_url?: string; metadata?: Record; duration_ms: number; start_timestamp: number; end_timestamp: number; }; type ReplayEventAttributes = { /** * Groundcover session replay payload. * * NOTE: This key is intentionally prefixed to avoid collisions with customer attributes. */ _gc_replay_data: { events: string[]; }; /** * Indicates this batch starts with a full DOM snapshot. * Full snapshots are taken at regular intervals to allow seeking directly to any point. * Queryable for filtering/indexing purposes. */ replay_is_full_snapshot?: boolean; /** * Timestamp when the full snapshot was taken (if replay_is_full_snapshot is true). */ replay_full_snapshot_timestamp?: number; }; /** * The view an event was captured on. Browser-owned: core has no notion of a * "current view" — it merges whatever the platform's `enrichAttributes` * contributor returns. `makeWebViewProvider` derives these (hash-route * detection, query-param redaction) and the SessionManager contributes them * under the `location` key. */ type LocationAttributes = { path: string; url: string; title: string; }; /** * The browser's event shape. Identical to core's `Event` plus the `location` * this platform stamps during enrichment — which is why `beforeSend` / * `enrichEvent` below are re-declared over THIS map rather than core's. */ type Event = Omit, "attributes"> & { type: T; attributes: A & { location?: LocationAttributes; }; }; type EventTypes = { "dom.event": Event<"dom.event", DomEventAttributes>; exception: Event<"exception", ErrorEventAttributes>; network: Event<"network", NetworkEventAttributes>; log: Event<"log", LogEventAttributes>; pageload: Event<"pageload", PageLoadEventAttributes>; navigation: Event<"navigation", NavigationEventAttributes>; custom: Event<"custom", UserDefinedEventAttributes>; performance: Event<"performance", PerformanceEventAttributes>; replay: Event<"replay", ReplayEventAttributes>; }; /** The browser SDK's listener names for `enabledEvents`. */ type BrowserEventName = "dom" | "network" | "exceptions" | "logs" | "pageload" | "navigation" | "performance" | "replay"; /** * Opt-in canvas capture for session replay. Charts and other ``-drawn * content (2D or WebGL) are NOT recorded by default; rrweb only serializes the * DOM/SVG around them, so canvas-rendered data series replay as empty frames. * Enabling this makes rrweb snapshot canvas pixels. * * ⚠️ HIGH COST — off by default for good reason: * - Bandwidth: canvas frames serialize as images, inflating replay payloads. * - CPU: snapshotting canvases is costly on the recorded (customer) page. * - Privacy: canvas pixels bypass text/input masking entirely — whatever is * drawn is captured verbatim, regardless of the `privacy` config. */ interface ReplayCanvasOptions { /** * Enable canvas capture. Defaults to `false` (canvas is not recorded). Maps * to rrweb's `recordCanvas`. */ enabled?: boolean; /** * Snapshot frame rate, in frames per second. Defaults to 1 and is clamped to * [1, 15]; out-of-range values are clamped with a `console.warn`. Maps to * rrweb's `sampling.canvas`. Every canvas is re-encoded on every tick, so a * higher rate costs CPU even when nothing changes; frames identical to the * previous one are dropped, so it adds bytes only for canvases that change * faster than the rate. The rate is also the time resolution: a canvas state * shorter than `1/fps` seconds (a brief transition or hover highlight) may not * appear in the replay. Raise it for animated canvases. */ fps?: number; /** * Image format for canvas snapshots. Defaults to `'image/webp'` (much smaller * than rrweb's default lossless `image/png`). Maps to rrweb * `dataURLOptions.type`. */ imageType?: "image/webp" | "image/jpeg" | "image/png"; /** * Lossy compression quality in [0, 1] for `image/webp` / `image/jpeg`. * Defaults to 0.6 (ignored for `image/png`). Maps to rrweb * `dataURLOptions.quality`. */ imageQuality?: number; } /** * Session-replay (rrweb) recording controls. This is NOT a privacy surface — * to mask sensitive content use `privacy`. */ interface ReplayOptions { /** * CSS selectors whose matching elements (and their subtrees) are excluded * from session recording. Matching elements appear in the replay as empty * placeholders of their original size. Useful for skipping noisy DOM injected * by browser extensions (e.g. Grammarly). * * NOTE: this is a noise-reduction control, NOT a privacy control. To mask * sensitive content use `privacy` instead. */ blockedSelectors?: string[]; /** * Opt-in canvas capture (chart data series, WebGL-backed widgets). Off by * default. Capturing canvas is bandwidth-, CPU-, and privacy-sensitive — see * {@link ReplayCanvasOptions}. */ canvas?: ReplayCanvasOptions; } /** Session-recording (rrweb replay) masking — the only place replay can be masked. */ interface ReplayMaskingOptions { /** rrweb `maskTextFn` pass-through. */ maskTextFn?: (text: string, el: HTMLElement | null) => string; /** rrweb `maskInputFn` pass-through. */ maskInputFn?: (text: string, el: HTMLElement) => string; } interface PrivacyOptions extends PrivacyOptions$1 { /** CSS selectors whose text/inputs are always masked (replay + DOM), regardless of `level` except `'allow'`. */ maskSelectors?: string[]; /** Session-recording (rrweb replay) masking — the only place replay can be masked. */ replay?: ReplayMaskingOptions; } interface SDKOptions extends Omit { /** * Inspect each event before it is queued; return false to drop it. Typed * over the BROWSER event map, so `attributes.location` is visible here. */ beforeSend?: (event: EventTypes[keyof EventTypes]) => boolean; /** Modify each event before it is queued. Typed over the browser event map. */ enrichEvent?: (event: EventTypes[keyof EventTypes]) => EventTypes[keyof EventTypes]; /** Which browser listeners to enable. Empty array = all. */ enabledEvents: BrowserEventName[]; /** * Unified privacy / data-masking config driving replay + non-replay masking. * ON by default (`level: 'mask-sensitive'`); see {@link PrivacyOptions}. */ privacy?: PrivacyOptions; /** * Session-replay recording controls (noise reduction, opt-in canvas capture). * For replay MASKING use `privacy` instead. See {@link ReplayOptions}. */ replay?: ReplayOptions; } interface SDKConfigInput extends Omit { options?: Partial; } type SDKConfigUpdate = Partial> & { user?: SDKConfigInput["user"] | null; }; declare class SessionManager { private logger; private readonly storage; private idGenerator; private core; private hideWired; private hideHandler; constructor(config: SDKConfigInput); private wireHideHandler; private unwireHideHandler; identifyUser(userIdentifier: Partial): void; updateConfig(params: SDKConfigUpdate): void; sendCustomEvent(event: { event: string; attributes: Record; }): void; startNavigation(metadata: Record): void; endNavigation(metadata: Record): void; captureException(error: unknown, metadata?: Record): void; emitLog(message: string, level: LogLevel, attributes?: Record): void; getSessionId(): string; setSessionId(newSessionId?: string): Promise; startReplayRecording(): void; stopReplayRecording(): void; destroy(): void; } declare class Logger { manager?: SessionManager | undefined; constructor(manager?: SessionManager | undefined); private emit; log(message: string, attributes?: Record): void; info(message: string, attributes?: Record): void; warn(message: string, attributes?: Record): void; error(message: string, attributes?: Record): void; debug(message: string, attributes?: Record): void; trace(message: string, attributes?: Record): void; } declare global { interface Window { groundcover?: typeof groundcover; } } declare function init(params: { cluster?: string; environment?: string; namespace?: string; appId: string; releaseId?: string; user?: Partial; dsn?: string; options?: Partial; apiKey?: string; sessionId?: string; }): void; declare function identifyUser(userIdentifier: Partial): void; declare function sendCustomEvent(params: { event: string; attributes: Record; }): void; declare function captureException(error: unknown, metadata?: Record): void; declare function updateConfig(params: SDKConfigUpdate): void; declare function startNavigation(metadata: Record): void; declare function endNavigation(metadata: Record): void; declare function getSessionId(): string; declare function setSessionId(newSessionId?: string): Promise; declare function startReplayRecording(): void; declare function stopReplayRecording(): void; declare const groundcover: { init: typeof init; identifyUser: typeof identifyUser; sendCustomEvent: typeof sendCustomEvent; captureException: typeof captureException; logger: Logger; updateConfig: typeof updateConfig; startNavigation: typeof startNavigation; endNavigation: typeof endNavigation; getSessionId: typeof getSessionId; setSessionId: typeof setSessionId; startReplayRecording: typeof startReplayRecording; stopReplayRecording: typeof stopReplayRecording; }; export { type ErrorDeduplicationOptions, type ErrorReportingOptions, type EventTypes, type PrivacyLevel, type PrivacyOptions, type RedactField, type RedactKind, type Redactor, type SDKOptions, groundcover as default };