Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(routes): track last route in routeNotFound #77835

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

michellewzhang
Copy link
Member

@michellewzhang michellewzhang commented Sep 19, 2024

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, and notice that not all the events 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:
SCR-20240919-tsyc

notion doc

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 19, 2024

function useLastKnownRoute() {
const route = useRoutes();
const lastRoute = usePrevious(route);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should consider excluding the route not found route, since it isn't really "known". Not that it would be a problem I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by "exclude"?

Copy link
Member

@JonasBa JonasBa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple small comments. Great improvement btw, that umbrella issue is probably hiding all sorts of bad links around the dashboard

static/app/views/lastKnownRouteContextProvider.tsx Outdated Show resolved Hide resolved
static/app/views/routeNotFound.tsx Outdated Show resolved Hide resolved
static/app/views/routeNotFound.tsx Outdated Show resolved Hide resolved
export default function LastKnownRouteContextProvider({children}: Props) {
const route = useRoutes();
const prevRoute = usePrevious(route);
const lastKnownRoute = getRouteStringFromRoutes(prevRoute);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could just use the location state, but we call navigate in so many areas that it would be really annoying to update

export const LastKnownRouteContext = createContext<string>('');

export function useLastKnownRoute() {
return useContext(LastKnownRouteContext);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care if this hook ever gets called outside of the provider?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, i guess it could possibly be useful elsewhere in the future, so it's not awful if it does get called outside of here. the only place we currently need it is inside routeNotFound.tsx

@@ -27,13 +29,14 @@ function RouteNotFound({router, location}: Props) {
scope.setFingerprint(['RouteNotFound']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could alternatively set the fingerprint here, though it'd be less flexible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i might prefer to do it in settings!

children: React.ReactNode;
}

export const LastKnownRouteContext = createContext<string>('unknown');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol sorry, I was reviewing on my phone and it lost the <. I actually meant the string <unknown> so it's very easy to disambiguate it from a route named unknown or whatever

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated again 😆

@michellewzhang michellewzhang merged commit 07396b7 into master Sep 23, 2024
43 checks passed
@michellewzhang michellewzhang deleted the mz/track-last-route branch September 23, 2024 15:56
Copy link

sentry-io bot commented Sep 23, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: Profile summary requires a transaction query params, got undefined /profiling/summary/:projectId/ View Issue
  • ‼️ SyntaxError: Bad escaped character in JSON at position 14 (line 1 column 15) /issues/5871599227/ View Issue

Did you find this useful? React with a 👍 or 👎

michellewzhang added a commit that referenced this pull request Sep 24, 2024
follow up to #77835

sometimes our last known route can be `/*`, which is the not found
route. this isn't helpful for grouping, so we want to track routes
distinct from that.
0Calories pushed a commit that referenced this pull request Sep 25, 2024
follow up to #77835

sometimes our last known route can be `/*`, which is the not found
route. this isn't helpful for grouping, so we want to track routes
distinct from that.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants