question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RUM not automatically working with HashRouter

See original GitHub issue

Hi!

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:

image

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

image


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

image

But with this approach the datadogRum don’t update the locationPath also.


It’s possible that this is a bug? Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
vzakharov-rxntcommented, Nov 2, 2021

I think hash routing should work out of the box. Should be no need to implement the following approach:

event.view.url = event.view.url.replace('#', '')
3reactions
strowkcommented, Aug 16, 2021

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 / or Load Page / followed by Load Page /hash , even though I am sure client was always loading /#hash, I checked that Load 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is HashRouter not working when BrowserRouter works?
I want to deploy my react code to github pages, but apparently, it doesn't support BrowserRouter. I ...
Read more >
Using Amazon CloudWatch RUM with a React web ...
In this post we will explain how you can use Amazon CloudWatch RUM to monitor a single-page web application built using React.
Read more >
React-Router - HashRouter Does Not Work with 2+ Routes
Now we import HashRouter from 'react-router-dom' and use <... ... I'm not sure. ... This worked for me: Add / before the path...
Read more >
RUM Browser Data Collected - Datadog Docs
The device name as reported by the device (User-Agent HTTP header). Operating system. The following OS-related attributes are attached automatically to all ...
Read more >
HashRouter v6.6.1 - React Router
<HashRouter> is for use in web browsers when the URL should not (or cannot) be sent to the server for some reason. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found