datadog-ux-utils Documentation - v1.0.0
    Preparing search index...

    Function captureResourceErrors

    • Capture failures of static assets (img/script/link for CSS/fonts, etc.) and CSP violations. Reports are sampled, deduped, and rate limited. Returns an uninstall function.

      Implementation notes:

      • Uses a window-level "error" listener in the capture phase so it catches resource errors that do not bubble (e.g., , failures).
      • Serializes only safe, compact details about the target element and URL.
      • Adds a separate listener for "securitypolicyviolation" when enabled.

      Parameters

      Returns () => void

      import { captureResourceErrors } from "@milliman/datadog-ux-utils/errors/resourceErrors";

      const uninstall = captureResourceErrors({
      sampleRate: 25,
      dedupeWindowMs: 45_000,
      maxPerMinute: 30,
      captureCspViolations: true,
      });

      // Later, when tearing down the app or test harness:
      uninstall();