UNPKG

datadog-ux-utils

Version:

Datadog RUM focused UX & performance toolkit: API guards (retry, breaker, rate), React telemetry (error boundary, profiler, Suspense), web vitals & resource observers, offline queues.

58 lines (57 loc) 2.83 kB
import { RumInitConfiguration, Context, ContextValue } from '@datadog/browser-rum'; import { LogsInitConfiguration } from '@datadog/browser-logs'; type User = { id?: string; name?: string; email?: string; [k: string]: unknown; }; export type DdBaseInit = { applicationId: string; clientToken: string; site?: "datadoghq.com" | "datadoghq.eu" | "us3.datadoghq.com" | "us5.datadoghq.com" | "ap1.datadoghq.com"; service?: string; env?: string; version?: string; sessionSampleRate?: number; sessionReplaySampleRate?: number; actionSampleRate?: number; errorSampleRate?: number; enableSessionReplay?: boolean; enableLogs?: boolean; rumOverrides?: Partial<RumInitConfiguration>; logsOverrides?: Partial<LogsInitConfiguration>; }; /** Toggle global telemetry on or off at runtime. */ export declare function setTelemetryEnabled(enabled: boolean): void; /** True if initDatadog has completed on this page. */ export declare function isDatadogInitialized(): boolean; /** Guarded, SSR-safe initialization. No-ops if already initialized. */ export declare function initDatadog(base: DdBaseInit): void; export declare function addAction(name: string, attrs?: Record<string, unknown>, sampleRate?: number): void; /** Add or replace global context for the session. Keep it small and flat. */ export declare function setGlobalContext(ctx: Context): void; /** Add a single key to the global context. */ export declare function addGlobalContext(key: string, value: ContextValue): void; /** Associate the current RUM session with a user. */ export declare function setUser(user: User): void; /** Optional breadcrumb for SPA navigations. Call from your router listener. */ export declare function trackRouteChange(from: string | null, to: string): void; /** Escape hatch for advanced consumers. Prefer the helpers above in library code. */ export declare function getRum(): { init: (config: RumInitConfiguration) => void; addAction: (name: string, context?: import('@datadog/browser-rum').RumActionContext) => void; addError: (e: any, context?: any) => void; addTiming: (name: string, time?: number) => void; startSessionReplayRecording: () => void; setUser?: (user: Record<string, any>) => void; addFeatureFlagEvaluation?: (key: string, value: any) => void; addGlobalContext: (key: string, value: any) => void; setGlobalContext?: (ctx: Record<string, any>) => void; getGlobalContext?: () => Record<string, any>; removeGlobalContext?: (key: string) => void; }; export declare function safeAddAction(name: string, attrs?: Record<string, unknown>, sampleRate?: number): void; export declare function addError(err: unknown, context?: Record<string, unknown>, sampleRate?: number): void; export {}; //# sourceMappingURL=datadog.d.ts.map