Files
freeCodeCamp/client/src/utils/report-error.ts
Tristan Toye dfe5a7fd05 Add Sentry to client for error handling (#43920)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2022-04-15 09:54:02 -05:00

16 lines
404 B
TypeScript

import * as Sentry from '@sentry/gatsby';
import envData from '../../../config/env.json';
const { sentryClientDSN } = envData;
export function reportClientSideError(
e: Error,
message = sentryClientDSN === null
? 'Unhandled error'
: 'Error sent to Sentry'
): string | void {
return sentryClientDSN === null
? console.error(`Client: ${message}`, e)
: Sentry.captureException(e);
}