-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(routes): track last route in routeNotFound (#77835)
### The problem In Sentry today, tons of “route not found” events are grouped together into one issue, even if the suspect routes/transactions are not related. This poses a problem because the relevant teams are not alerted to these issues, which means 1) we’re not able to triage & fix these issues as quickly, and 2) we do not have proper scope of the problem areas. See an issue example [here](https://sentry.sentry.io/issues/496412334/events/c7dce88ad52944a095d672d0d114d7da/?project=11276&referrer=replay-errors), and notice that not all the [events](https://sentry.sentry.io/issues/496412334/events/c720b6d1807849b9ae0859f9b165a344/events/?project=11276&referrer=next-event) have the same transaction. ### The goal Improve our grouping for “route not found” issues so that the events are split up into better issues — specifically, based on where the last known route was. That way, we can have more relevant issues grouped by (hopefully) the suspect problem route & triage more effectively. ### Next steps Next step would be setting the fingerprinting rules in the `javascript` project to include the new tag-based grouping rule. This is in project settings: <img width="1061" alt="SCR-20240919-tsyc" src="https://github.com/user-attachments/assets/d2f22c3d-e892-4303-868e-520d15c36ac9"> [notion doc](https://www.notion.so/sentry/Improve-Route-not-found-issue-grouping-1068b10e4b5d80129e5dc9b84b1b5eb5?showMoveTo=true&saveParent=true)
- Loading branch information
1 parent
347ede1
commit 07396b7
Showing
3 changed files
with
54 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {createContext, useContext} from 'react'; | ||
|
||
import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes'; | ||
import usePrevious from 'sentry/utils/usePrevious'; | ||
import {useRoutes} from 'sentry/utils/useRoutes'; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const LastKnownRouteContext = createContext<string>('<unknown>'); | ||
|
||
export function useLastKnownRoute() { | ||
return useContext(LastKnownRouteContext); | ||
} | ||
|
||
/** | ||
* This provider tracks the last known route that the user has navigated to. | ||
* This is used to better group issues when we hit "route not found" errors. | ||
*/ | ||
export default function LastKnownRouteContextProvider({children}: Props) { | ||
const route = useRoutes(); | ||
const prevRoute = usePrevious(route); | ||
const lastKnownRoute = getRouteStringFromRoutes(prevRoute); | ||
|
||
return ( | ||
<LastKnownRouteContext.Provider value={lastKnownRoute}> | ||
{children} | ||
</LastKnownRouteContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters