Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-356: Add Sentry grouping #2262

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/ErrorHandling/Sentry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getCurrentHub,
init,
Replay,
setTag,
withScope,
} from "@sentry/react";
import type { Scope, SeverityLevel } from "@sentry/react";
Expand Down Expand Up @@ -46,6 +47,21 @@ const sendError = (
withScope((scope) => {
setScope(scope, { level: severity, context: metadata });

const { gqlErr, operationName } = metadata ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve the type safety on these by adding gqlErr and operationName as option fields in the metadata struct on line 46.


// Add additional sorting for GraphQL errors
if (operationName) {
// A custom fingerprint allows for more intelligent grouping
const fingerprint = [operationName];
if (gqlErr?.path && Array.isArray(gqlErr.path)) {
fingerprint.push(...gqlErr.path);
}
scope.setFingerprint(fingerprint);

// Apply tag, which is a searchable/filterable property
setTag("operationName", metadata.operationName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setTag("operationName", metadata.operationName);
setTag("operationName", operationName);

}

captureException(err);
});
};
Expand Down
Loading