RUM not automatically working with HashRouter
See original GitHub issueHi!
I’m integrating the @datadog/browser-rum with at our react (16.12.0) application that uses react-router-dom (5.1.2) to manage the routers.
We are currently using HashRouter and due to already existing analysis data, we can’t migrate from HashRouter to BrowserRouter without having the /# prefixed.
Basically, the issue we have is that the @datadog/browser-rum seems not to be integrating with HashRouter very well. I uploaded some code I was using to debug here https://github.com/eduardogspereira/datadog-debug, but basically I’m setting the datadogRum and router like this:

Even that the hashchange event is being triggered, the paths are not being correct updated at datadog:

Also, we trying to migrate from HashRouter to BrowserRouter keeping the /# prefixed. Like this:

But with this approach the datadogRum don’t update the locationPath also.
It’s possible that this is a bug? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:12 (2 by maintainers)

Top Related StackOverflow Question
I think hash routing should work out of the box. Should be no need to implement the following approach:
I tried replacing hash with slash - this worked, sort of, but does not seem to be very stable. Sometimes I still get something like
SPA Route Change /orLoad Page /followed byLoad Page /hash, even though I am sure client was always loading/#hash, I checked thatLoad Page /view and I can see that url was with/#hash, so sdk somehow firstly reported view without applying that function and then reported another view after applying function… I think such partial solution would be more confusing. Even though it gives somewhat more insight, I do not want to introduce this hack into codebase, which potentially can be broken and has to be maintained.I will wait for this issue to get proper resolution and full support of hash router (or rejection if you choose to do so), before proceeding. In the meantime I guess we just have to ignore “view” in RUM webconsole