feat: Add routing instrumentation for react router v4/v5 #2780
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So in React Router v4 and v5, there is no longer a static set of routes we can depend upon to change transaction name.
Take a look at their philosophy for more: https://reactrouter.com/core/guides/philosophy
This means it is hard for us to get all the transaction names without additional user configuration. I have set this up in two ways.
a) They can use a custom Route component to achieve this functionality. This is as every time a Route renders, we get access to the match params (what path they matched with). We can then grab update the name there.
Usage:
b) They can pass us a route config. We accept a config object that is supported by https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config, so something that looks like:
Then usage:
The Route Component matching trumps the config.