---
updatedAt: 2025-01-30T23:24:15.000Z
agentTools:
  projectIndex: https://docs.logrocket.com/llms.txt
---

# Sentry

Integrating LogRocket with [Sentry](https://sentry.io)

Add a LogRocket session recording URL to every Sentry exception report.

```javascript
Sentry.configureScope(scope => {
  scope.setExtra("sessionURL", LogRocket.sessionURL);
});
```

`LogRocket.sessionURL` returns `null` in cases where the LogRocket SDK hasn't fully initialized and begun sending session data back to LogRocket servers. To guarantee the presence of a session URL, pass a callback to [`LogRocket.getSessionURL()`](https://docs.logrocket.com/reference#get-session-url).

```javascript
LogRocket.getSessionURL(sessionURL => {
  Sentry.configureScope(scope => {
    scope.setExtra("sessionURL", sessionURL);
  });
});
```

To pass the session URL with a timestamp to the moment that an error is caught by Sentry, the LogRocket URL can be included in Sentry's `beforeSend()` action

```javascript Configuring Sentry beforeSend() with LogRocket
Sentry.init({
  beforeSend(event) {
    const logRocketSession = LogRocket.sessionURL;
    if (logRocketSession !== null) {
      event.extra["LogRocket"] = logRocketSession;
      return event;
    } else {
      return event;
    }
  },
});
```

If you're using the legacy Raven SDK:

```javascript
Raven.setDataCallback(data => {
  data.extra.sessionURL = LogRocket.sessionURL;
  return data;
});
```