From 9daaf4b9d0852f9da7cef5f98b3a362fca21a80c Mon Sep 17 00:00:00 2001 From: Tom Rees Date: Wed, 4 Nov 2020 07:58:22 +0000 Subject: [PATCH] feat: allow config to be passed to requestHandler (#243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rafał Chłodnicki --- README.md | 8 +++++++- lib/module.js | 5 +++-- types/sentry.d.ts | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9e713ac..5e276815 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/module.js b/lib/module.js index c45a85e9..785b2528 100644 --- a/lib/module.js +++ b/lib/module.js @@ -48,7 +48,8 @@ export default function SentryModule (moduleOptions) { '.nuxt/dist/client/img' ], configFile: '.sentryclirc' - } + }, + requestHandlerConfig: {} } const topLevelOptions = this.options.sentry || {} @@ -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 diff --git a/types/sentry.d.ts b/types/sentry.d.ts index 67fd99a0..29d65cd3 100644 --- a/types/sentry.d.ts +++ b/types/sentry.d.ts @@ -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 @@ -33,4 +34,5 @@ export interface ModuleConfiguration { serverIntegrations?: IntegrationsConfiguration sourceMapStyle?: WebpackOptions.Devtool webpackConfig?: SentryCliPluginOptions + requestHandlerConfig?: Handlers.RequestHandlerOptions }