Now enforcing curly brackets on all if statements. Includes auto-fixer. ```ts // ❌ Bad if (foo) foo++; // ✅ Good if (foo) { foo++; } ``` Note: this did not lint the `drizzle` package or any `db-*` packages. This will be done in the future.
34 lines
840 B
TypeScript
34 lines
840 B
TypeScript
import type { Config } from 'payload'
|
|
|
|
import type { PluginOptions } from './types.js'
|
|
|
|
import { captureException } from './captureException.js'
|
|
import { startSentry } from './startSentry.js'
|
|
|
|
export const sentryPlugin =
|
|
(pluginOptions: PluginOptions) =>
|
|
(incomingConfig: Config): Config => {
|
|
const config = { ...incomingConfig }
|
|
|
|
if (pluginOptions.enabled === false || !pluginOptions.dsn) {
|
|
return config
|
|
}
|
|
|
|
config.hooks = {
|
|
...(incomingConfig.hooks || {}),
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
afterError: (err: any) => {
|
|
captureException(err)
|
|
},
|
|
}
|
|
|
|
config.onInit = async (payload) => {
|
|
if (incomingConfig.onInit) {
|
|
await incomingConfig.onInit(payload)
|
|
}
|
|
startSentry(pluginOptions, payload)
|
|
}
|
|
|
|
return config
|
|
}
|