Skip to content

Commit

Permalink
feat: allow config to be passed to requestHandler (#243)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafał Chłodnicki <[email protected]>
  • Loading branch information
Zephod and rchl authored Nov 4, 2020
1 parent 281656a commit 9daaf4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@ Normally, setting required DSN information would be enough.
- Type: `Object`
- Default: Refer to `module.js` since defaults include various options that also change dynamically based on other options.
- Options passed to `@sentry/webpack-plugin`. See documentation at https://github.com/getsentry/sentry-webpack-plugin/blob/master/README.md


### requestHandlerConfig
- Type: `Object`
- Default: `{
}`
- Options passed to `requestHandler` in `@sentry/node`. See: https://docs.sentry.io/platforms/node/guides/express/

## Submitting releases to Sentry
Support for the [sentry-webpack-plugin](https://github.com/getsentry/sentry-webpack-plugin) was introduced [#a6cd8d3](https://github.com/nuxt-community/sentry-module/commit/a6cd8d3b983b4c6659e985736b19dc771fe7c9ea). This can be used to send releases to Sentry. Use the publishRelease option to enable this feature.

Expand Down
5 changes: 3 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function SentryModule (moduleOptions) {
'.nuxt/dist/client/img'
],
configFile: '.sentryclirc'
}
},
requestHandlerConfig: {}
}

const topLevelOptions = this.options.sentry || {}
Expand All @@ -58,7 +59,7 @@ export default function SentryModule (moduleOptions) {

if (serverSentryEnabled(options)) {
// @ts-ignore
this.nuxt.hook('render:setupMiddleware', app => app.use(SentryHandlers.requestHandler()))
this.nuxt.hook('render:setupMiddleware', app => app.use(SentryHandlers.requestHandler(options.requestHandlerConfig)))
// @ts-ignore
this.nuxt.hook('render:errorMiddleware', app => app.use(SentryHandlers.errorHandler()))
// @ts-ignore
Expand Down
2 changes: 2 additions & 0 deletions types/sentry.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Options as WebpackOptions } from 'webpack'
import { Options as SentryOptions } from '@sentry/types'
import { SentryCliPluginOptions } from '@sentry/webpack-plugin'
import { Handlers } from '@sentry/node'

export type IntegrationsConfiguration = Record<string, unknown>

Expand Down Expand Up @@ -33,4 +34,5 @@ export interface ModuleConfiguration {
serverIntegrations?: IntegrationsConfiguration
sourceMapStyle?: WebpackOptions.Devtool
webpackConfig?: SentryCliPluginOptions
requestHandlerConfig?: Handlers.RequestHandlerOptions
}

0 comments on commit 9daaf4b

Please sign in to comment.