Skip to content

Commit

Permalink
feat(ErrorBoundary): include Bugsnag activate process
Browse files Browse the repository at this point in the history
  • Loading branch information
kubosho committed Dec 11, 2020
1 parent 7c3c3af commit 3460f21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React from 'react';
import Bugsnag from '@bugsnag/js';
import BugsnagPluginReact from '@bugsnag/plugin-react';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function activateErrorBoundaryComponent(): any {
export function activateErrorBoundaryComponent(apiKey: string): any {
Bugsnag.start({
apiKey,
plugins: [new BugsnagPluginReact(React)],
});

return Bugsnag.getPlugin('react');
}
4 changes: 1 addition & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { insertGtmScript } from '../tracking/gtm';
import { PRODUCTION_GTM_ID, DEVELOPMENT_GTM_ID } from '../tracking/gtm_id';
import { isProduction, isDevelopment } from '../constants/environment';
import { createGAOptout } from '../tracking/ga_optout';
import { activateBugsnag } from '../activate_bugsnag';
import { activateErrorBoundaryComponent } from '../components/ErrorBoundary';
import { SiteHeader } from '../components/SiteHeader';
import { SiteFooter } from '../components/SiteFooter';
Expand Down Expand Up @@ -57,8 +56,7 @@ export default class MyApp extends App {
return e;
}

activateBugsnag(bugsnagApiKey);
const ErrorBoundary = activateErrorBoundaryComponent();
const ErrorBoundary = activateErrorBoundaryComponent(bugsnagApiKey);

return <ErrorBoundary>{e}</ErrorBoundary>;
}
Expand Down

0 comments on commit 3460f21

Please sign in to comment.