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

Commit

Permalink
Add tag and fingerprint to graphql errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad committed Feb 15, 2024
1 parent 06fe697 commit e5f39d6
Showing 1 changed file with 16 additions and 0 deletions.
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 ?? {};

// 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);
}

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

0 comments on commit e5f39d6

Please sign in to comment.