Sentry

How to integrate Sentry with Asayer and see backend errors alongside session replays.

1. Generate Sentry Auth Token

Go to Sentry > Account > API > Auth Tokens and generate the token with event:read, org:read and project:read permissions. This latter will be used in the next step when enabling your Sentry integration in Asayer dashboard.

Create Token in Sentry

2. Enable Integration in Asayer

Copy your organization_slug and project_slug from the Projects page in your Sentry dashboard.

Projects Page in Sentry

Sentry Integration Form in Asayer

Then paste them in Asayer dashboard under Preferences > Integrations alongside the Token you previously generated in step 1.

3. Propagate asayer_session_id

In order for Asayer to associate a Sentry event with the recorded user session, a unique id has to be propagated from your frontend to your backend on each request you want to track. If you're relying on Sentry on your frontend, you can follow the below example.

if (window.asayer && window.asayer.id()) { Raven.setTagsContext({asayer_session_id: window.asayer.id()}); }

Otherwise, this can be done using a custom HTTP header. In the below example, we use the fetch function to send that header.

const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
};
if (window.asayer && window.asayer.id()) {
headers['X-Session-Id'] = window.asayer.id(); // Inject asayer_session_id
}
fetch('www.your-backend.com', {
'GET',
headers,
});

Then you can extract the asayer_session_id from the header and add it to your Sentry scope (ideally using a middleware or decorator).

with configure_scope() as scope:
scope.set_tag('asayer_session_id', app.current_request.headers.get('X-Session-Id'))

The name of the tag should be exactly asayer_session_id.