Skip to content

Commit

Permalink
fix: Setup Sentry fingerprint for errors only (#2357)
Browse files Browse the repository at this point in the history
To help Sentry group similar errors together, we set the message
fingerprint ourselves with the error's name and message and the
originating logger name.

However, if we trying to send a message to Sentry without an error
(i.e. we logged a message with the `sentry: true` option), trying to
get its name or message will throw an error for trying to get
attributes of `undefined`.

Therefore, we'll set the fingerprint manually only when sending a
message related to an error.
  • Loading branch information
taratatach authored Oct 31, 2024
1 parent e137a7a commit 3c81e18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/utils/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class SentryTransport extends winston.Transport {
Sentry.withScope(scope => {
scope.setLevel(sentryLevel)
scope.setContext('msgDetails', extra)
scope.setFingerprint([component, err.name, err.message])

if (err) {
scope.setFingerprint([component, err.name, err.message])
Sentry.captureException(formatError(err))
} else {
Sentry.captureMessage(msg)
Expand Down

0 comments on commit 3c81e18

Please sign in to comment.