@@ -5,21 +5,10 @@ import type {
5
5
ExecutionContext ,
6
6
HttpServer ,
7
7
NestInterceptor ,
8
- OnModuleInit ,
9
8
} from '@nestjs/common' ;
10
9
import { Catch , Global , HttpException , Injectable , Logger , Module } from '@nestjs/common' ;
11
10
import { APP_INTERCEPTOR , BaseExceptionFilter } from '@nestjs/core' ;
12
- import type { Span } from '@sentry/core' ;
13
- import {
14
- SEMANTIC_ATTRIBUTE_SENTRY_OP ,
15
- SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
16
- captureException ,
17
- getClient ,
18
- getDefaultIsolationScope ,
19
- getIsolationScope ,
20
- logger ,
21
- spanToJSON ,
22
- } from '@sentry/core' ;
11
+ import { captureException , getDefaultIsolationScope , getIsolationScope , logger } from '@sentry/core' ;
23
12
import type { Observable } from 'rxjs' ;
24
13
import { isExpectedError } from './helpers' ;
25
14
@@ -46,10 +35,6 @@ interface ExpressRequest {
46
35
47
36
/**
48
37
* Interceptor to add Sentry tracing capabilities to Nest.js applications.
49
- *
50
- * @deprecated `SentryTracingInterceptor` is deprecated.
51
- * If you are using `@sentry/nestjs` you can safely remove any references to the `SentryTracingInterceptor`.
52
- * If you are using another package migrate to `@sentry/nestjs` and remove the `SentryTracingInterceptor` afterwards.
53
38
*/
54
39
class SentryTracingInterceptor implements NestInterceptor {
55
40
// used to exclude this class from being auto-instrumented
@@ -84,10 +69,7 @@ class SentryTracingInterceptor implements NestInterceptor {
84
69
return next . handle ( ) ;
85
70
}
86
71
}
87
- // eslint-disable-next-line deprecation/deprecation
88
72
Injectable ( ) ( SentryTracingInterceptor ) ;
89
- // eslint-disable-next-line deprecation/deprecation
90
- export { SentryTracingInterceptor } ;
91
73
92
74
/**
93
75
* Global filter to handle exceptions and report them to Sentry.
@@ -133,84 +115,6 @@ class SentryGlobalFilter extends BaseExceptionFilter {
133
115
Catch ( ) ( SentryGlobalFilter ) ;
134
116
export { SentryGlobalFilter } ;
135
117
136
- /**
137
- * Global filter to handle exceptions in NestJS + GraphQL applications and report them to Sentry.
138
- *
139
- * @deprecated `SentryGlobalGraphQLFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
140
- */
141
- class SentryGlobalGraphQLFilter {
142
- private static readonly _logger = new Logger ( 'ExceptionsHandler' ) ;
143
- public readonly __SENTRY_INTERNAL__ : boolean ;
144
-
145
- public constructor ( ) {
146
- this . __SENTRY_INTERNAL__ = true ;
147
- }
148
-
149
- /**
150
- * Catches exceptions and reports them to Sentry unless they are HttpExceptions.
151
- */
152
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
- public catch ( exception : unknown , host : ArgumentsHost ) : void {
154
- // neither report nor log HttpExceptions
155
- if ( exception instanceof HttpException ) {
156
- throw exception ;
157
- }
158
- if ( exception instanceof Error ) {
159
- // eslint-disable-next-line deprecation/deprecation
160
- SentryGlobalGraphQLFilter . _logger . error ( exception . message , exception . stack ) ;
161
- }
162
- captureException ( exception ) ;
163
- throw exception ;
164
- }
165
- }
166
- // eslint-disable-next-line deprecation/deprecation
167
- Catch ( ) ( SentryGlobalGraphQLFilter ) ;
168
- // eslint-disable-next-line deprecation/deprecation
169
- export { SentryGlobalGraphQLFilter } ;
170
-
171
- /**
172
- * Global filter to handle exceptions and report them to Sentry.
173
- *
174
- * This filter is a generic filter that can handle both HTTP and GraphQL exceptions.
175
- *
176
- * @deprecated `SentryGlobalGenericFilter` is deprecated. Use the `SentryGlobalFilter` instead. The `SentryGlobalFilter` is a drop-in replacement.
177
- */
178
- export const SentryGlobalGenericFilter = SentryGlobalFilter ;
179
-
180
- /**
181
- * Service to set up Sentry performance tracing for Nest.js applications.
182
- *
183
- * @deprecated `SentryService` is deprecated.
184
- * If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
185
- * If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
186
- */
187
- class SentryService implements OnModuleInit {
188
- public readonly __SENTRY_INTERNAL__ : boolean ;
189
-
190
- public constructor ( ) {
191
- this . __SENTRY_INTERNAL__ = true ;
192
- }
193
-
194
- /**
195
- * Initializes the Sentry service and registers span attributes.
196
- */
197
- public onModuleInit ( ) : void {
198
- // Sadly, NestInstrumentation has no requestHook, so we need to add the attributes here
199
- // We register this hook in this method, because if we register it in the integration `setup`,
200
- // it would always run even for users that are not even using Nest.js
201
- const client = getClient ( ) ;
202
- if ( client ) {
203
- client . on ( 'spanStart' , span => {
204
- addNestSpanAttributes ( span ) ;
205
- } ) ;
206
- }
207
- }
208
- }
209
- // eslint-disable-next-line deprecation/deprecation
210
- Injectable ( ) ( SentryService ) ;
211
- // eslint-disable-next-line deprecation/deprecation
212
- export { SentryService } ;
213
-
214
118
/**
215
119
* Set up a root module that can be injected in nest applications.
216
120
*/
@@ -222,48 +126,21 @@ class SentryModule {
222
126
return {
223
127
module : SentryModule ,
224
128
providers : [
225
- // eslint-disable-next-line deprecation/deprecation
226
- SentryService ,
227
129
{
228
130
provide : APP_INTERCEPTOR ,
229
- // eslint-disable-next-line deprecation/deprecation
230
131
useClass : SentryTracingInterceptor ,
231
132
} ,
232
133
] ,
233
- // eslint-disable-next-line deprecation/deprecation
234
- exports : [ SentryService ] ,
235
134
} ;
236
135
}
237
136
}
238
137
Global ( ) ( SentryModule ) ;
239
138
Module ( {
240
139
providers : [
241
- // eslint-disable-next-line deprecation/deprecation
242
- SentryService ,
243
140
{
244
141
provide : APP_INTERCEPTOR ,
245
- // eslint-disable-next-line deprecation/deprecation
246
142
useClass : SentryTracingInterceptor ,
247
143
} ,
248
144
] ,
249
- // eslint-disable-next-line deprecation/deprecation
250
- exports : [ SentryService ] ,
251
145
} ) ( SentryModule ) ;
252
146
export { SentryModule } ;
253
-
254
- function addNestSpanAttributes ( span : Span ) : void {
255
- const attributes = spanToJSON ( span ) . data ;
256
-
257
- // this is one of: app_creation, request_context, handler
258
- const type = attributes [ 'nestjs.type' ] ;
259
-
260
- // If this is already set, or we have no nest.js span, no need to process again...
261
- if ( attributes [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] || ! type ) {
262
- return ;
263
- }
264
-
265
- span . setAttributes ( {
266
- [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.otel.nestjs' ,
267
- [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : `${ type } .nestjs` ,
268
- } ) ;
269
- }
0 commit comments