@ezghcloud/rum-react
v1.0.0
Published
React integration for @ezghcloud/rum: error boundary, views and React Router route templates
Readme
@ezghcloud/rum-react
React integration for @ezghcloud/rum: an error boundary
that reports render errors, manual views, and route templates from React Router.
npm install @ezghcloud/rum @ezghcloud/rum-reactimport { init } from "@ezghcloud/rum"
import { EzghErrorBoundary, instrumentReactRouter } from "@ezghcloud/rum-react"
import { createBrowserRouter, RouterProvider } from "react-router"
init({ token: "ezgh_ct_…", release: "…" })
const router = createBrowserRouter(routes)
instrumentReactRouter(router) // views named by route pattern: /users/:id
root.render(
<EzghErrorBoundary fallback={<p>Something went wrong.</p>}>
<RouterProvider router={router} />
</EzghErrorBoundary>,
)Exports
EzghErrorBoundary: propsfallback(a node, or(error, reset) => node) andattributes. Errors it catches are reported with sourceboundaryand React's component stack.useEzghView(name): starts a view namedname.instrumentReactRouter(router): for data routers (createBrowserRouter); returns an unsubscribe.useEzghRouteTemplate(): for framework mode or any tree under a router; names views from the route params.
License
Apache-2.0
