Merge branch 'sentry-async' into 'develop'
Webpack: chunk Sentry to reduce entrypoint size See merge request soapbox-pub/soapbox-fe!750
This commit is contained in:
commit
7eca5db9a9
2 changed files with 26 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import * as Sentry from '@sentry/browser';
|
import { captureException } from 'soapbox/monitoring';
|
||||||
|
|
||||||
export default class ErrorBoundary extends React.PureComponent {
|
export default class ErrorBoundary extends React.PureComponent {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export default class ErrorBoundary extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error, info) {
|
componentDidCatch(error, info) {
|
||||||
Sentry.captureException(error);
|
captureException(error);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
hasError: true,
|
hasError: true,
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
import * as Sentry from '@sentry/react';
|
|
||||||
import { Integrations } from '@sentry/tracing';
|
|
||||||
import { NODE_ENV, SENTRY_DSN } from 'soapbox/build_config';
|
import { NODE_ENV, SENTRY_DSN } from 'soapbox/build_config';
|
||||||
|
|
||||||
export function start() {
|
export const start = () => {
|
||||||
Sentry.init({
|
Promise.all([
|
||||||
dsn: SENTRY_DSN,
|
import(/* webpackChunkName: "error" */'@sentry/react'),
|
||||||
environment: NODE_ENV,
|
import(/* webpackChunkName: "error" */'@sentry/tracing'),
|
||||||
debug: false,
|
]).then(([Sentry, { Integrations: Integrations }]) => {
|
||||||
integrations: [new Integrations.BrowserTracing()],
|
Sentry.init({
|
||||||
|
dsn: SENTRY_DSN,
|
||||||
|
environment: NODE_ENV,
|
||||||
|
debug: false,
|
||||||
|
integrations: [new Integrations.BrowserTracing()],
|
||||||
|
|
||||||
// We recommend adjusting this value in production, or using tracesSampler
|
// We recommend adjusting this value in production, or using tracesSampler
|
||||||
// for finer control
|
// for finer control
|
||||||
tracesSampleRate: 1.0,
|
tracesSampleRate: 1.0,
|
||||||
});
|
});
|
||||||
}
|
}).catch(console.error);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const captureException = error => {
|
||||||
|
import(/* webpackChunkName: "error" */'@sentry/react')
|
||||||
|
.then(Sentry => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue