chore: misc update
This commit is contained in:
@@ -40,7 +40,7 @@ export default config;
|
|||||||
|
|
||||||
### Data Source Name (DSN) and where to find it
|
### Data Source Name (DSN) and where to find it
|
||||||
|
|
||||||
- `dsn` : string[] | required
|
- `dsn` : string | required
|
||||||
|
|
||||||
Sentry automatically assigns a DSN when you create a project, the unique DSN informs Sentry where to send events so they are associated with the correct project.
|
Sentry automatically assigns a DSN when you create a project, the unique DSN informs Sentry where to send events so they are associated with the correct project.
|
||||||
|
|
||||||
|
|||||||
@@ -9,54 +9,53 @@ import type { PluginOptions } from './types'
|
|||||||
export const startSentry = (pluginOptions: PluginOptions): void => {
|
export const startSentry = (pluginOptions: PluginOptions): void => {
|
||||||
const { dsn, options } = pluginOptions
|
const { dsn, options } = pluginOptions
|
||||||
|
|
||||||
if (dsn)
|
if (!dsn) return
|
||||||
try {
|
|
||||||
const app = express()
|
|
||||||
|
|
||||||
Sentry.init({
|
try {
|
||||||
...options?.init,
|
const app = express()
|
||||||
dsn: dsn,
|
|
||||||
integrations: [
|
|
||||||
...(options?.init?.integrations || []),
|
|
||||||
new Sentry.Integrations.Http({ tracing: true }),
|
|
||||||
new Sentry.Integrations.Express({ app }),
|
|
||||||
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
|
|
||||||
],
|
|
||||||
})
|
|
||||||
|
|
||||||
app.use(
|
Sentry.init({
|
||||||
Sentry.Handlers.requestHandler(options?.requestHandler || {}) as express.RequestHandler,
|
...options?.init,
|
||||||
)
|
dsn: dsn,
|
||||||
app.use(Sentry.Handlers.tracingHandler())
|
integrations: [
|
||||||
|
...(options?.init?.integrations || []),
|
||||||
|
new Sentry.Integrations.Http({ tracing: true }),
|
||||||
|
new Sentry.Integrations.Express({ app }),
|
||||||
|
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
app.use(
|
app.use(Sentry.Handlers.requestHandler(options?.requestHandler || {}) as express.RequestHandler)
|
||||||
Sentry.Handlers.errorHandler({
|
app.use(Sentry.Handlers.tracingHandler())
|
||||||
shouldHandleError(error) {
|
|
||||||
if (error.status === 500) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
options?.captureErrors &&
|
|
||||||
typeof error.status === 'number' &&
|
|
||||||
options.captureErrors.includes(error.status)
|
|
||||||
) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
}) as express.ErrorRequestHandler,
|
|
||||||
)
|
|
||||||
|
|
||||||
app.use(function onError(
|
app.use(
|
||||||
_err: unknown,
|
Sentry.Handlers.errorHandler({
|
||||||
_req: Request,
|
shouldHandleError(error) {
|
||||||
res: Response & { sentry?: string },
|
if (error.status === 500) {
|
||||||
_next: NextFunction,
|
return true
|
||||||
) {
|
}
|
||||||
res.statusCode = 500
|
if (
|
||||||
res.end(res.sentry + '\n')
|
options?.captureErrors &&
|
||||||
})
|
typeof error.status === 'number' &&
|
||||||
} catch (err: unknown) {
|
options.captureErrors.includes(error.status)
|
||||||
console.log('There was an error initializing Sentry, please ensure you entered a valid DSN')
|
) {
|
||||||
}
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
}) as express.ErrorRequestHandler,
|
||||||
|
)
|
||||||
|
|
||||||
|
app.use(function onError(
|
||||||
|
_err: unknown,
|
||||||
|
_req: Request,
|
||||||
|
res: Response & { sentry?: string },
|
||||||
|
_next: NextFunction,
|
||||||
|
) {
|
||||||
|
res.statusCode = 500
|
||||||
|
res.end(res.sentry + '\n')
|
||||||
|
})
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.log('There was an error initializing Sentry, please ensure you entered a valid DSN')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user