@@ -11,6 +11,7 @@ import { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../
11
11
import type { IntegrationFn } from '../types-hoist/integration' ;
12
12
import { debug } from '../utils/debug-logger' ;
13
13
import { isPlainObject } from '../utils/is' ;
14
+ import { addExceptionMechanism } from '../utils/misc' ;
14
15
15
16
const AUTH_OPERATIONS_TO_INSTRUMENT = [
16
17
'reauthenticate' ,
@@ -236,6 +237,7 @@ function instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): A
236
237
captureException ( res . error , {
237
238
mechanism : {
238
239
handled : false ,
240
+ type : 'auto.db.supabase.auth' ,
239
241
} ,
240
242
} ) ;
241
243
} else {
@@ -252,6 +254,7 @@ function instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): A
252
254
captureException ( err , {
253
255
mechanism : {
254
256
handled : false ,
257
+ type : 'auto.db.supabase.auth' ,
255
258
} ,
256
259
} ) ;
257
260
@@ -408,18 +411,27 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte
408
411
err . details = res . error . details ;
409
412
}
410
413
411
- const supabaseContext : Record < string , unknown > = { } ;
414
+ const supabaseContext : Record < string , any > = { } ;
412
415
if ( queryItems . length ) {
413
416
supabaseContext . query = queryItems ;
414
417
}
415
418
if ( Object . keys ( body ) . length ) {
416
419
supabaseContext . body = body ;
417
420
}
418
421
419
- captureException ( err , {
420
- contexts : {
421
- supabase : supabaseContext ,
422
- } ,
422
+ captureException ( err , scope => {
423
+ scope . addEventProcessor ( e => {
424
+ addExceptionMechanism ( e , {
425
+ handled : false ,
426
+ type : 'auto.db.supabase.postgres' ,
427
+ } ) ;
428
+
429
+ return e ;
430
+ } ) ;
431
+
432
+ scope . setContext ( 'supabase' , supabaseContext ) ;
433
+
434
+ return scope ;
423
435
} ) ;
424
436
}
425
437
@@ -448,6 +460,7 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte
448
460
return res ;
449
461
} ,
450
462
( err : Error ) => {
463
+ // TODO: shouldn't we capture this error?
451
464
if ( span ) {
452
465
setHttpStatus ( span , 500 ) ;
453
466
span . end ( ) ;
0 commit comments