You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There doesn't appear to be any way to use unstable_HistoryRouter with Sentry.reactRouterV6BrowserTracingIntegration. I've tried all the recommendations from the Sentry.io docs for the integration. It was mentioned in #4118, but none of the workarounds work.
The code comments for Sentry.reactRouterV6BrowserTracingIntegration appear to be out-of-date and mentions "history", but the function itself doesn't accept it:
import"core-js";import{createRoot}from"react-dom/client";import{unstable_HistoryRouterasHistoryRouter}from"react-router-dom";importqueryStringfrom"query-string";import{createBrowserHistory}from"history";/* * Preserves query string parameters using a custom createBrowserHistory implementation * https://stackoverflow.com/questions/43613140 */functionpreserveQueryParameters(history,preserve,location){constcurrentQuery=queryString.parse(history.location.search);if(currentQuery){constpreservedQuery={};for(letpofpreserve){constv=currentQuery[p];if(v){preservedQuery[p]=v;}}if(location.search){Object.assign(preservedQuery,queryString.parse(location.search));}location.search=queryString.stringify(preservedQuery);}returnlocation;}functioncreateLocationDescriptorObject(location,state){returntypeoflocation==="string" ?
{pathname: location, state} : location;}functioncreatePreserveQueryHistory(createHistory,queryParameters){return(options)=>{consthistory=createHistory(options);constoldPush=history.push,oldReplace=history.replace;history.push=(path,state)=>oldPush.apply(history,[preserveQueryParameters(history,queryParameters,createLocationDescriptorObject(path,state))]);history.replace=(path,state)=>oldReplace.apply(history,[preserveQueryParameters(history,queryParameters,createLocationDescriptorObject(path,state))]);returnhistory;};}exportconstrouteHistory=createPreserveQueryHistory(createBrowserHistory,["myQueryParam"])();// Routes and Route are contained in a component inside AppcreateRoot(document.getElementById("root")).render(<HistoryRouterhistory={routeHistory}><App/></HistoryRouter>);
I've tried just using SentryRoutes variable as mentioned in the docs.
I've also tried this in my Sentry.init config without luck:
Maybe I was wrong in my assumption it wasn't working. I was expecting to see something on Sentry.io that indicated that React Router was being integrated specially.
If I see in Discover that it has event with the title /pages/manifest/p/*/start does that mean React Router integration is working right? The docs seem to suggest (at least for some versions) there is supposed to be parameterized results somewhere.
If I see in Discover that it has event with the title "/pages/manifest/p/*/start` does that mean React Router integration is working right? The docs seem to suggest (at least for some versions) there is supposed to be parameterized results somewhere.
Thanks for your quick response! Does it display those parameterized values anywhere on the website? Like in my example after /p/ is the name or id of the item.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
7.113.0
Framework Version
React 18
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
There doesn't appear to be any way to use
unstable_HistoryRouter
withSentry.reactRouterV6BrowserTracingIntegration
. I've tried all the recommendations from the Sentry.io docs for the integration. It was mentioned in #4118, but none of the workarounds work.The code comments for
Sentry.reactRouterV6BrowserTracingIntegration
appear to be out-of-date and mentions "history", but the function itself doesn't accept it:sentry-javascript/packages/react/src/reactrouterv6.tsx
Lines 61 to 67 in d5a3ded
index.jsx:
SentryRoutes
variable as mentioned in the docs.Sentry.init
config without luck:Sentry.browserTracingIntegration()
.Expected Result
I expect there to be some way to hook
react-router-dom
with Sentry.io when usingunstable_HistoryRouter
Actual Result
Doesn't report browser tracing events to Sentry.io.
The text was updated successfully, but these errors were encountered: