chore(plugin-sentry): migrate esm, remove webpack
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
/* eslint-disable no-console */
|
||||
import type { Config } from 'payload/config'
|
||||
|
||||
import type { PluginOptions } from './types'
|
||||
import type { PluginOptions } from './types.js'
|
||||
|
||||
import { captureException } from './captureException'
|
||||
import { startSentry } from './startSentry'
|
||||
import { extendWebpackConfig } from './webpack'
|
||||
import { captureException } from './captureException.js'
|
||||
import { startSentry } from './startSentry.js'
|
||||
|
||||
export const sentry =
|
||||
(pluginOptions: PluginOptions) =>
|
||||
(incomingConfig: Config): Config => {
|
||||
const config = { ...incomingConfig }
|
||||
const webpack = extendWebpackConfig(incomingConfig)
|
||||
|
||||
config.admin = {
|
||||
...(config.admin || {}),
|
||||
webpack,
|
||||
}
|
||||
|
||||
if (pluginOptions.enabled === false || !pluginOptions.dsn) {
|
||||
return config
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import type { Config } from 'payload/config'
|
||||
import type { Configuration as WebpackConfig } from 'webpack'
|
||||
|
||||
import path from 'path'
|
||||
|
||||
export const extendWebpackConfig =
|
||||
(config: Config): ((webpackConfig: WebpackConfig) => WebpackConfig) =>
|
||||
(webpackConfig) => {
|
||||
const existingWebpackConfig =
|
||||
typeof config.admin?.webpack === 'function'
|
||||
? config.admin.webpack(webpackConfig)
|
||||
: webpackConfig
|
||||
|
||||
const mockModulePath = path.resolve(__dirname, './mocks/mockFile.js')
|
||||
|
||||
const newWebpack = {
|
||||
...existingWebpackConfig,
|
||||
resolve: {
|
||||
...(existingWebpackConfig.resolve || {}),
|
||||
alias: {
|
||||
...(existingWebpackConfig.resolve?.alias ? existingWebpackConfig.resolve.alias : {}),
|
||||
[path.resolve(__dirname, './captureException')]: mockModulePath,
|
||||
[path.resolve(__dirname, './startSentry')]: mockModulePath,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return newWebpack
|
||||
}
|
||||
@@ -6,27 +6,13 @@ import { Users } from './collections/Users.js'
|
||||
import { testErrors } from './components.js'
|
||||
|
||||
export default buildConfigWithDefaults({
|
||||
collections: [Posts, Users],
|
||||
admin: {
|
||||
user: Users.slug,
|
||||
components: {
|
||||
beforeDashboard: [testErrors],
|
||||
},
|
||||
user: Users.slug,
|
||||
},
|
||||
plugins: [
|
||||
sentry({
|
||||
dsn: 'https://61edebe5ee6d4d38a9d6459c7323d777@o4505289711681536.ingest.sentry.io/4505357688242176',
|
||||
options: {
|
||||
init: {
|
||||
debug: true,
|
||||
},
|
||||
requestHandler: {
|
||||
serverName: false,
|
||||
},
|
||||
captureErrors: [400, 403, 404],
|
||||
},
|
||||
}),
|
||||
],
|
||||
collections: [Posts, Users],
|
||||
onInit: async (payload) => {
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
@@ -36,4 +22,18 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
})
|
||||
},
|
||||
plugins: [
|
||||
sentry({
|
||||
dsn: 'https://61edebe5ee6d4d38a9d6459c7323d777@o4505289711681536.ingest.sentry.io/4505357688242176',
|
||||
options: {
|
||||
captureErrors: [400, 403, 404],
|
||||
init: {
|
||||
debug: true,
|
||||
},
|
||||
requestHandler: {
|
||||
serverName: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user