Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import Bugsnag from '@bugsnag/js'
import bugsnagReact from '@bugsnag/plugin-react'
Bugsnag.init('YOUR_API_KEY')
Bugsnag.use(bugsnagReact, React)
const ErrorBoundary = Bugsnag.getPlugin('react')
const ErrorScreen = () =>
<div>
<h1><span aria-label="warning icon" role="img">⚠️</span> Error <span aria-label="warning icon" role="img">⚠️</span></h1>
<p><strong>Uh oh, there was an error in the component tree!</strong></p>
<p>This <code>FallbackComponent</code> prop can be used to show something useful to your users when such errors occur.</p>
</div>
const onError = event => {
// You can also provide an onError callback to run just on errors caught by
// the error boundary. Maybe you want to attach some of the current state from
// whatever model/store you're using (e.g redux)
console.log('about to send this event', { event })
}
export default function (options) {
const logger = consola.withScope('Bugsnag')
logger.info('Configuring')
const bugsnagOptions = { ...this.options.bugsnag, ...options.bugsnag }
logger.info('Adding browser plugin')
this.addPlugin({
src: join(__dirname, 'client.js'),
options: { apiKey: bugsnagOptions.browserApiKey },
ssr: false
})
Bugsnag.init({ apiKey: bugsnagOptions.serverApiKey, logger })
Bugsnag.use(bugsnagExpress)
logger.info('Adding server handlers')
this.nuxt.hook('render:setupMiddleware', app => app.use(Bugsnag.getPlugin('express').requestHandler))
this.nuxt.hook('render:errorMiddleware', app => app.use(Bugsnag.getPlugin('express').errorHandler))
this.nuxt.hook('generate:routeFailed', ({ route, errors }) => {
errors.forEach(({ error }) => Bugsnag.notify(error, event => event.addMetadata('route', route)))
})
}
const Bugsnag = require('@bugsnag/js')
const Koa = require('koa')
const router = require('koa-router')
const serve = require('koa-static')
const mount = require('koa-mount')
const { readFileSync } = require('fs')
Bugsnag.init(process.env.BUGSNAG_API_KEY)
Bugsnag.use(require('@bugsnag/plugin-koa'))
const app = new Koa()
const { requestHandler, errorHandler } = Bugsnag.getPlugin('koa')
app.use(requestHandler)
app.use(mount('/static', serve(`${__dirname}/static`)))
const index = readFileSync('./views/index.html', 'utf8')
app.use(
router()
.get('/', (ctx, next) => {
ctx.body = index
})
.post('/crash', (ctx, next) => {
import React from 'react'
import Bugsnag from '@bugsnag/js'
import bugsnagReact from '@bugsnag/plugin-react'
import getConfig from 'next/config'
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
Bugsnag.init({
apiKey: serverRuntimeConfig.BUGSNAG_API_KEY || publicRuntimeConfig.BUGSNAG_API_KEY
})
Bugsnag.use(bugsnagReact, React)
export default Bugsnag
import Vue from 'vue'
import Bugsnag from '@bugsnag/js'
import bugsnagVue from '@bugsnag/plugin-vue'
Bugsnag.init('<%= options.apiKey %>')
Bugsnag.use(bugsnagVue, Vue)
export default function ({ app }, inject) {
inject('Bugsnag', Bugsnag)
}
import Vue from 'vue'
import App from './App.vue'
import Bugsnag from '@bugsnag/js'
import bugsnagVue from '@bugsnag/plugin-vue'
Bugsnag.init('YOUR_API_KEY')
Bugsnag.use(bugsnagVue, Vue)
Vue.config.productionTip = false
new Vue({
render: h => h(App)
}).$mount('#app')