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

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tag and fingerprint to graphql errors
Browse files Browse the repository at this point in the history
sophstad committed Feb 15, 2024

Verified

This commit was signed with the committer’s verified signature.
sophstad Sophie Stadler
1 parent 06fe697 commit 1a7b68b
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
@@ -4,6 +4,7 @@ import {
getCurrentHub,
init,
Replay,
setTag,
withScope,
} from "@sentry/react";
import type { Scope, SeverityLevel } from "@sentry/react";
@@ -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);
});
};

0 comments on commit 1a7b68b

Please sign in to comment.