PostHog
The Rollbar PostHog integration requires either PostHog Cloud, or a self-hosted PostHog instance.
What does this integration offer?
Our PostHog integration connects errors in Rollbar to a PostHog session recording allowing a much easier way to connect the end users experience back to the error data located in Rollbar. This way, debugging issues becomes a lot easier, and you can also correlate error data with your product usage metrics in PostHog.
JavaScript Integration
Make sure you're using both PostHog and Rollbar as JS modules within your application.
Rollbar Configuration
The key value that we need to use is the "posthog.sessionRecording.sessionId" and add this into the payload for the Rollbar item when it is created. To do this we use the "transform" function as shown in the JavaScript code example below.
This can be done in any SDK that PostHog and Rollbar supports. Review the supported SDK's for both solutions online.
var _rollbarConfig = {
accessToken: "<ROLLBARPROJECTACCESSTOKEN>",
captureUncaught: true,
captureUnhandledRejections: true,
autoInstrument: true,
captureUsername: true,
captureEmail: true,
payload: {
environment: "production",
server: {
host: "myapp.com",
root: "https://myapp.com/",
branch: "master",
}
},
transform: function (payload) {
//PostHog - Recording Session Id
payload.posthogsessionrecordingId = posthog.sessionRecording.sessionId;
return payload;
}
};
Enabling a quick link back to PostHog from your Rollbar Item View
When the data is sent to Rollbar as part of the item occurrence data we are able to utilize this data in various ways. This includes creating a service link on the item page in Rollbar or querying Rollbar using RQL for any issues that have this sessionid from PostHog.
Configure Rollbar Service Link
Service links allows a quick and easy way to connect external system to a Rollbar issue. The example below shows the error in Rollbar with a Service Link to PostHog.
How to add the service link
Navigate to the project you want to add the service link to. Add the new service link using the following example.
Note: This will change if you are using a self-hosted PostHog instance.
https://app.posthog.com/recordings?source=rollbar#sessionRecordingId={{posthogsessionrecordingId}}
This service link in Rollbar will now open the PostHog recording for you in a new browser tab allowing you to quickly view the users session and associated data from PostHog.
Updated about 1 year ago