feat: add Bugsnag error reporting service#1695
feat: add Bugsnag error reporting service#1695
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9688389 to
c3cfc88
Compare
There was a problem hiding this comment.
we typically don't do barrel files and we just directly import from the files where we need. I'd recommend using @.cursorrules to catch these sort of "style" errors.
| }; | ||
|
|
||
| // Initialize Bugsnag on module load | ||
| initializeBugsnag(); |
There was a problem hiding this comment.
Lets export this function and Initialize where we are using it (maybe src/index.tsx)
| return; | ||
| } | ||
|
|
||
| Bugsnag.start({ |
There was a problem hiding this comment.
lets wrap this in a try catch:
try {
Bugsnag.start({ ... });
} catch (error) {
console.error("Failed to initialize Bugsnag:", error);
}
| onError: (event) => { | ||
| // Only normalize and enhance generic "Error" instances | ||
| // Custom error classes (NetworkError, ValidationError, etc.) are preserved as-is | ||
| if (event.errors[0].errorClass === "Error") { |
There was a problem hiding this comment.
lets abstract this into constants:
const GENERIC_ERROR_CLASS = "Error";
if (event.errors[0].errorClass === GENERIC_ERROR_CLASS) {
| onError: (event) => { | ||
| // Only normalize and enhance generic "Error" instances | ||
| // Custom error classes (NetworkError, ValidationError, etc.) are preserved as-is | ||
| if (event.errors[0].errorClass === "Error") { | ||
| const errorMessage = event.errors[0].errorMessage; | ||
| const { normalizedMessage, extractedValues } = | ||
| normalizeErrorMessage(errorMessage); | ||
|
|
||
| // Set custom grouping hash for better error grouping | ||
| event.groupingHash = normalizedMessage; | ||
|
|
||
| // Update errorClass to show the normalized message in Observe UI | ||
| event.errors[0].errorClass = normalizedMessage; | ||
|
|
||
| // Add custom grouping key to metadata if configured | ||
| if (config.customGroupingKey) { | ||
| event.addMetadata("custom", { | ||
| [config.customGroupingKey]: normalizedMessage, | ||
| }); | ||
| } | ||
|
|
||
| // Add extracted values as metadata for debugging | ||
| if (Object.keys(extractedValues).length > 0) { | ||
| event.addMetadata("extracted_values", extractedValues); | ||
| } | ||
| } | ||
|
|
||
| // Add pathname for context (for all errors) | ||
| event.addMetadata("context", { pathname: window.location.pathname }); | ||
| }, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
This is fairly complex. Can we abstract it into a function?
const handleGenericError = (event: Bugsnag.Event, config: BugsnagConfig) => { ... };There was a problem hiding this comment.
For sure. Added some unit tests too.
c3cfc88 to
6cf38f9
Compare
956fbba to
3e8c8af
Compare
6cf38f9 to
ad2ef91
Compare
3e8c8af to
1119b6f
Compare
ad2ef91 to
62bc345
Compare
1119b6f to
7ab4019
Compare
58af5dc to
0217c23
Compare
Initialize Bugsnag SDK with custom error normalization and grouping. Reads configuration from environment variables and applies normalization to all reported errors.
0217c23 to
e60eb29
Compare
7ab4019 to
d7fc62b
Compare

Description
Added Bugsnag error management service with custom error normalization and grouping capabilities. The implementation includes:
Type of Change
Checklist
Test Instructions
.envfile:Additional Comments
The error normalization helps group similar errors together even when they contain different dynamic values, improving our error tracking and debugging capabilities.