/** * Categorical phase the WebView was in when the failure was raised. * * Use this for high-level grouping; the duration fields on * {@link WebViewFailedToLoadErrorMeta} give the granular timing data. */ export type WebViewFailedToLoadErrorPhase = 'html_load' | 'html_finish' | 'sdk_bootstrap' | 'after_clear_state' | 'native_error' | 'embedded_native_error' | 'unknown'; /** * A single failed load attempt recorded by the embedded webview's bounded * retry engine. The terminal {@link WebViewFailedToLoadError} carries one * record per attempt (including the final one) so the error log shows the * full failure history, not just the last symptom. */ export type WebViewLoadAttemptFailure = { /** 1-based attempt number this failure belongs to. */ attempt: number; /** The phase the attempt was in when it failed. */ phase: WebViewFailedToLoadErrorPhase; /** Milliseconds from the start of the attempt to its failure. */ elapsedMs: number; /** Native error code, when the failure came from a native `onLoadError`. */ nativeErrorCode?: number; /** Native error domain, when the failure came from a native `onLoadError`. */ nativeErrorDomain?: string; }; /** * Which concrete sub-step a `sdk_bootstrap` failure died in, derived from * which signals the host saw before the ready window expired: * - `bundle_fetch`: no manifest request ever arrived — the webview's JS * bundle never ran (download or eval failed, or the bridge never came up). * - `sdk_init`: the manifest arrived (bundle alive, bridge works) but the * webview-side SDK never signalled ready. Covers init hanging AND the * ready message not making it back; the `loadId` query param joins this * log with the webview-side boot beacons to tell those two apart. */ export type WebViewBootstrapStage = 'bundle_fetch' | 'sdk_init'; /** * Structured context attached to {@link WebViewFailedToLoadError} so the * resulting error log carries enough information to tell *which* step the * WebView was stuck in when the failure was raised, and how long each step * took. * * The setter on `InitializationModule.error` forwards this object directly * to `logger.error`, so every field below ends up as a structured field on * the same Datadog log as the error message. */ export type WebViewFailedToLoadErrorMeta = { phase: WebViewFailedToLoadErrorPhase; /** * Sub-step of `sdk_bootstrap` the failure died in; only set when `phase` * is `sdk_bootstrap`. */ bootstrapStage?: WebViewBootstrapStage; /** * Correlation id stamped on the webview URL (`loadId` query param). The * webview-side boot beacons echo it as their instanceId, so a failure log * can be joined against `service:waas-browser-iframe` boot stages. */ loadId?: string; /** * Milliseconds between RN's `onLoadStart` and `onLoad` callbacks (the * HTML + asset fetch). `null` if `onLoad` never fired. */ htmlLoadMs: number | null; /** * Milliseconds between RN's `onLoad` and `onLoadEnd` callbacks. Usually * small; mostly there to flag pathological cases. `null` if `onLoadEnd` * never fired. */ onLoadToOnLoadEndMs: number | null; /** * Milliseconds between `onLoadEnd` and the first `manifest` request * received from the webview-side SDK. Proxy for "the JS bundle is alive * and the message bridge works". `null` if the manifest request never * arrived. */ manifestReceivedMs: number | null; /** * Milliseconds between `onLoadEnd` and the webview-side SDK signalling * it has finished initialising (via the `sdkHasLoadedEventName` store * change). `null` if the SDK never signalled it was ready. */ sdkReadyMs: number | null; /** * Number of `retry` increments in the WebView URL at the time of failure * (covers OS-kill reloads, load_error reloads, and recovery reloads). */ retryCount: number; /** * Whether the `clear-state` query parameter was present in the URL when * the failure was raised. `true` indicates we already retried with a * clean state and still couldn't finish loading. */ hadClearState: boolean; /** * Number of times RN's `onError` fired across the lifetime of the * WebView component instance. */ nativeErrorCount: number; /** * Number of times the OS killed the WebView process (via * `onContentProcessDidTerminate` on iOS or `onRenderProcessGone` on * Android) across the lifetime of the WebView component instance. */ osKillCount: number; /** The configured value for `loadingTimeout` (ms). */ loadingTimeoutMs: number; /** The configured value for `recoveryTimeout` (ms). */ recoveryTimeoutMs: number; /** The URL the WebView was attempting to load when the failure occurred. */ webviewUrl?: string; /** * Native error info, only populated when the failure originated from the * embedded native WebView path (iOS WKWebView / Android WebView), where * we get a single `onLoadError` event with these fields. */ nativeErrorCode?: number; nativeErrorDescription?: string; nativeErrorDomain?: string; nativeErrorIsProvisional?: boolean; nativeErrorFailedUrl?: string; /** * Per-attempt failure history recorded by the embedded webview's bounded * retry engine — one entry per failed attempt, including the terminal * one. Absent on the non-embedded (`react-native-webview`) path. */ attemptFailures?: WebViewLoadAttemptFailure[]; }; export declare class WebViewFailedToLoadError extends Error { readonly meta?: WebViewFailedToLoadErrorMeta; constructor(meta?: WebViewFailedToLoadErrorMeta); }