rollbar / rollbar-react

React features to enhance using Rollbar.js in React Applications
https://docs.rollbar.com/docs/react
MIT License
42 stars 10 forks source link

<RollbarContext /> implementation doesn't match docs #88

Open daniellzl opened 1 year ago

daniellzl commented 1 year ago

Docs: https://docs.rollbar.com/docs/react#rollbarcontext-component

1 - RollbarContext requires the onRender prop

Calling

<RollbarContext context="home">…</RollbarContext>

doesn't actually set Rollbar's context to 'home'. On further examination of the RollbarContext component, I saw I needed to add a onRender prop for it to work:

<RollbarContext context="home" onRender>…</RollbarContext>

This doesn't align with the docs linked above.

2 - RollbarContext type is incorrect

Given the requirement of the onRender prop, RollbarContext's type is incomplete.

gazpachu commented 1 year ago

I also have errors using <RollbarContext context="something"> with "react-router-dom": "6.11.2":

import { useRoutes } from 'react-router-dom';

return useRoutes([
{
  path: `${Route.Foo}/:bar`,
  element: (
    <RollbarContext context="/foo-bar">
      <FooBar />
    </RollbarContext>
  )
}
]);
Screenshot 2023-06-19 at 11 45 15
gazpachu commented 1 year ago

cc @rollbar-bborsits (Juanjo Marrón suggested to ping you) to have a look at this 🙏

gazpachu commented 1 year ago

cc @waltjones

ghost commented 1 year ago

Hey @gazpachu @daniellzl, We'll need to analyze the proposed solution further. We'll get back to you.