v145 · Web APIs · Crash Report Demo
Crash Report Demo
Demonstrates navigator.crashReporter.setKey() — setting crash annotations, detecting API support, and understanding the write-only, ephemeral contract.
Crash keys are stored in the renderer process and included in crash reports if the tab crashes. They are never sent proactively. This demo calls the real API when it is available; unsupported browsers report that no annotation was written.
API status
navigator.crashReporterChecking…
setKey()—
set a crash key
Click “Set key” to attach a crash annotation.
code
// Feature detection
if ('crashReporter' in navigator && typeof navigator.crashReporter.setKey === 'function') {
// Set annotations immediately on page load
navigator.crashReporter.setKey('session_id', generateSessionId());
navigator.crashReporter.setKey('user_id', getCurrentUserId());
navigator.crashReporter.setKey('build', BUILD_HASH);
// Update as state changes
document.addEventListener('featureflagschanged', () => {
navigator.crashReporter.setKey('flags', getActiveFlags().join(','));
});
// Clear user data on sign-out
signOutButton.addEventListener('click', () => {
navigator.crashReporter.setKey('user_id', '');
});
}