Stackdriver
How to integrate Stackdriver with OpenReplay and see backend errors alongside session recordings.
1. Create Google Cloud Service Account
- In the GCP Console, go to the Create Service Account Key page.
- From the Service account list, select New Service Account.
- In the Service account name field, enter "openreplay-stackdriver".
- From the Role list, add Logging > Logs Viewer and Stackdriver > Stackdriver Accounts Viewer.
- Click Create to download the JSON file that contains your key.
2. Enable Stackdriver in OpenReplay
Paste your Log Name
and openreplay-stackdriver
credentials in OpenReplay dashboard under 'Preferences > Integration'.
3. Propagate openReplaySessionToken
To link a Stackdriver event with the recorded user session, a unique token has to be propagated from your frontend to your backend on each request you want to track. 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 (tracker.getSessionToken()) { // or window.OpenReplay instead of tracker if you're using the snippetheaders['X-OpenReplay-SessionToken'] = tracker.getSessionToken(); // Inject openReplaySessionToken}fetch('www.your-backend.com', {'GET',headers,});
In order for OpenReplay to associate a Stackdriver log entry with the recorded user session, a unique token has to be propagated as a label
to each backend error you wish to track.
Below is an example in Stackdriver's Python API.
google_logger.log_text("A LOG ENTRY", severity='ERROR', labels={"openReplaySessionToken": OPENREPLAY_SESSION_TOKEN})#orgoogle_logger.log_struct({"message": "A LOG ENTRY"}, severity='ERROR', labels={"openReplaySessionToken": OPENREPLAY_SESSION_TOKEN})
The name of the tag openReplaySessionToken
is case sensitive.
Troubleshooting
If you encounter any issues, connect to our Slack and get help from our community.