Delete monitoring.ts, add `captureSentryException` to sentry.ts
This commit is contained in:
parent
0658530447
commit
a7d78d0935
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import * as BuildConfig from 'soapbox/build-config';
|
import * as BuildConfig from 'soapbox/build-config';
|
||||||
import { HStack, Text, Stack } from 'soapbox/components/ui';
|
import { HStack, Text, Stack } from 'soapbox/components/ui';
|
||||||
import { captureException } from 'soapbox/monitoring';
|
import { captureSentryException } from 'soapbox/sentry';
|
||||||
import KVStore from 'soapbox/storage/kv-store';
|
import KVStore from 'soapbox/storage/kv-store';
|
||||||
import sourceCode from 'soapbox/utils/code';
|
import sourceCode from 'soapbox/utils/code';
|
||||||
import { unregisterSW } from 'soapbox/utils/sw';
|
import { unregisterSW } from 'soapbox/utils/sw';
|
||||||
|
@ -37,7 +37,7 @@ class ErrorBoundary extends React.PureComponent<Props, State> {
|
||||||
textarea: HTMLTextAreaElement | null = null;
|
textarea: HTMLTextAreaElement | null = null;
|
||||||
|
|
||||||
componentDidCatch(error: any, info: any): void {
|
componentDidCatch(error: any, info: any): void {
|
||||||
captureException(error, {
|
captureSentryException(error, {
|
||||||
tags: {
|
tags: {
|
||||||
// Allow page crashes to be easily searched in Sentry.
|
// Allow page crashes to be easily searched in Sentry.
|
||||||
ErrorBoundary: 'yes',
|
ErrorBoundary: 'yes',
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import type { CaptureContext } from '@sentry/types';
|
|
||||||
|
|
||||||
/** Capture the exception and report it to Sentry. */
|
|
||||||
async function captureException (exception: any, captureContext?: CaptureContext | undefined): Promise<void> {
|
|
||||||
try {
|
|
||||||
const Sentry = await import('@sentry/react');
|
|
||||||
Sentry.captureException(exception, captureContext);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { captureException };
|
|
|
@ -2,6 +2,7 @@ import { NODE_ENV } from 'soapbox/build-config';
|
||||||
import sourceCode from 'soapbox/utils/code';
|
import sourceCode from 'soapbox/utils/code';
|
||||||
|
|
||||||
import type { Account } from './schemas';
|
import type { Account } from './schemas';
|
||||||
|
import type { CaptureContext } from '@sentry/types';
|
||||||
|
|
||||||
/** Start Sentry. */
|
/** Start Sentry. */
|
||||||
async function startSentry(dsn: string): Promise<void> {
|
async function startSentry(dsn: string): Promise<void> {
|
||||||
|
@ -63,4 +64,10 @@ async function unsetSentryAccount() {
|
||||||
Sentry.setUser(null);
|
Sentry.setUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { startSentry, setSentryAccount, unsetSentryAccount };
|
/** Capture the exception and report it to Sentry. */
|
||||||
|
async function captureSentryException (exception: any, captureContext?: CaptureContext | undefined): Promise<void> {
|
||||||
|
const Sentry = await import('@sentry/react');
|
||||||
|
Sentry.captureException(exception, captureContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { startSentry, setSentryAccount, unsetSentryAccount, captureSentryException };
|
Loading…
Reference in New Issue