Browser Crash Logging Configuration
This feature is currently only compatible with Chrome 72+
In order to use the Crash Logging feature, your server must send a Report-To
header in the initial page response that looks like this:
{"max_age":10886400,"endpoints":[{"url":"https://app.logrocket.com/reports/{orgName}/{appName}"}]}
This will inform your users' browsers to send crash reports to LogRocket so we can correlate them with your LogRocket sessions.
This header can either be configured server-side or CDN-side like with a Cloudflare worker.
Here is an example of a CloudFlare worker that attaches the Report-To
header to every response:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Add Report-To header
* @param {Request} request
*/
async function handleRequest(request) {
const response = await fetch(request);
const reportTo = response.headers.get('Report-To');
if (!reportTo) {
const newHeaders = new Headers(response.headers);
const reportToHeader = {
max_age: 10886400,
endpoints: [{
url: 'https://app.logrocket.com/reports/orgName/appName'
}]
}
newHeaders.set('Report-To', JSON.stringify(reportToHeader));
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});
}
return response;
}
Updated over 1 year ago