justbetter / magento2-sentry

Magento 2 module to log to Sentry
MIT License
165 stars 70 forks source link

LogRocket sessionUrl not set #72

Closed jahvi closed 3 years ago

jahvi commented 3 years ago

Do you want to request a feature or report a bug? Bug

Bug: What is the current behavior? The LogRocket sessionUrl does not show in Sentry's issue report when LogRocket is configured.

Screenshot 2021-01-17 at 12 58 06

Bug: What is the expected behavior? The LogRocket sessionUrl should show in Sentry's issue report when LogRocket is configured.

Bug: What is the proposed solution? I'm not sure to be honest, here's a few things I tried but didn't help:

I can confirm LogRocket works as expected and the URL does get generated (I added a console.log(sessionUrl) and visiting the logged URL does show the session replay fine). I'm not sure if this is an issue with the module or LogRocket/Sentry.

What is the version of Magento and of Sentry extension you are using? Always use the latest version of the extension one before opening a bug issue.

Magento 2.4.1 Module 2.5.0

indykoning commented 3 years ago

A possibility is to follow along with https://docs.logrocket.com/docs/sentry and replacing the setExtra with setContext https://docs.sentry.io/platforms/javascript/enriching-events/context/#structured-context

This way you'd get a new fieldset with a Logrocket heading and under this heading you can push any logrocket information. It would be a nice addition

jahvi commented 3 years ago

After some investigation this is not a problem with this module but the Sentry JS SDK itself. To summarise you can't use setContext or setExtra asynchronously with transactions.

This means it doesn't work for JS errors that trigger on page load but it works with errors that trigger afterwards (like AJAX requests, etc).

What we did was going the other way around, save the Sentry traceId in LogRocket so when an error is reported in Sentry we can find the session in LogRocket by filtering this value.