v145 · Web APIs · API Reference

API Reference

Full method reference for navigator.crashReporter, key name and value constraints, privacy considerations, and best practices for crash annotation.

interface

Member Signature Description
setKey() setKey(key: string, value: string): void Registers a key-value pair as a crash annotation. If key already exists, the value is overwritten. Set value to an empty string to remove the key.

constraints

Property Limit Notes
Key length ≤ 40 characters Use short, descriptive names. Longer keys may be silently truncated.
Value length ≤ 20 KB Values exceeding the limit may be truncated in the crash report.
Key characters ASCII alphanumeric + underscore Non-conforming keys may be rejected or sanitised.
Persistence Tab lifetime only Keys are cleared when the page navigates away or the tab closes normally.
Report delivery On crash only Values are never sent proactively. No network request is made by setKey().

privacy guidelines

// DO: attach pseudonymous identifiers
navigator.crashReporter.setKey('user_id', hashUserId(userId));
navigator.crashReporter.setKey('session_id', sessionId);

// DO: attach diagnostic context
navigator.crashReporter.setKey('active_tab', currentTabName);
navigator.crashReporter.setKey('feature_flags', enabledFlags.join(','));
navigator.crashReporter.setKey('renderer_version', BUNDLE_HASH);

// DON'T: attach raw PII
// navigator.crashReporter.setKey('email', user.email);      // ✗
// navigator.crashReporter.setKey('ip_address', clientIp);   // ✗
// navigator.crashReporter.setKey('payment_method', card);   // ✗

// Users who have opted out of crash reporting in Chrome settings
// will not send crash reports — keys are never transmitted in that case.

recommended keys

Key name Example value Why useful
session_id sess_abc123 Correlate with server-side logs
app_version 3.14.0 Identify which build crashed
feature_flags dark_mode,new_api Which experiments were active
active_route /checkout/payment Which page/view was displayed
memory_mb 428 Help diagnose OOM crashes

see also