Add Sentry to client for error handling (#43920)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
// TODO: integrate with Sentry?
|
||||
import * as Sentry from '@sentry/gatsby';
|
||||
import envData from '../../../config/env.json';
|
||||
|
||||
const { sentryClientDSN } = envData;
|
||||
|
||||
export function reportClientSideError(
|
||||
e: Error,
|
||||
message = 'Unhandled error'
|
||||
): void {
|
||||
return console.error(`Client: ${message}`, e);
|
||||
message = sentryClientDSN === null
|
||||
? 'Unhandled error'
|
||||
: 'Error sent to Sentry'
|
||||
): string | void {
|
||||
return sentryClientDSN === null
|
||||
? console.error(`Client: ${message}`, e)
|
||||
: Sentry.captureException(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user