The Grafana Faro Web SDK, part of the Grafana Faro project, is a highly configurable web SDK for real user monitoring (RUM) that instruments browser frontend applications to capture observability signals. Frontend telemetry can then be correlated with backend and infrastructure data for full-stack observability.
This PR adds support for the React Router V6 which is using the new RouterProvider which supporting the new Data Routers.
Setting up Routes with RouterProvider works differently then before.
On result of this is that we can't wrap the React Routes with FaroRoutes anymore.
Also wrapping the RouterProvider with FaroRoutes also doesn't work because FaroRoutes are using useLocation internally which is not available outside of the Data Routers.
To instrument the new routers we created the withFaroRouterInstrumentation(router) which subscribe to route changes of the passed router and sends the respective Faro route change events.
withFaroRouterInstrumentation(router) work with all current data routers which are:
Note
To test the new router you can use below branch of the Faro demo which uses the data router.
To test the data routers mentioned above just open the App.tsx file and replace createBrowserRouter with createHashRouter or createMemoryRouter.
👉🏼 Don't forget to rebuild the demo after you made changes to App.tsx
Why
This PR adds support for the React Router V6 which is using the new RouterProvider which supporting the new Data Routers.
Setting up Routes with
RouterProvider
works differently then before. On result of this is that we can't wrap the React Routes withFaroRoutes
anymore. Also wrapping theRouterProvider
withFaroRoutes
also doesn't work becauseFaroRoutes
are usinguseLocation
internally which is not available outside of the Data Routers.To instrument the new routers we created the
withFaroRouterInstrumentation(router)
which subscribe to route changes of the passed router and sends the respective Faro route change events.withFaroRouterInstrumentation(router)
work with all current data routers which are:Because setting up data routers is differently then other V6 routers, the Faro React setup is different as well:
Note To test the new router you can use below branch of the Faro demo which uses the data router. To test the data routers mentioned above just open the
App.tsx
file and replacecreateBrowserRouter
withcreateHashRouter
orcreateMemoryRouter
. 👉🏼 Don't forget to rebuild the demo after you made changes to App.tsxWhat
withFaroRouterInstrumentation(router)
function to instrument the data routersLinks
Related issue: https://github.com/grafana/faro-web-sdk/issues/235
Checklist