@@ -233,44 +233,37 @@ function instrumentRpcReturnedFromSchemaCall(SupabaseClient: unknown): void {
233
233
if ( isInstrumented ( ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ) ) {
234
234
return ;
235
235
}
236
-
237
236
( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema = new Proxy (
238
237
( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ,
239
238
{
240
239
apply ( target , thisArg , argumentsList ) {
241
240
const supabaseInstance = Reflect . apply ( target , thisArg , argumentsList ) ;
242
-
243
- ( supabaseInstance as unknown as SupabaseClientConstructorType ) . rpc = new Proxy (
244
- ( supabaseInstance as unknown as SupabaseClientInstance ) . rpc ,
245
- {
246
- apply ( target , thisArg , argumentsList ) {
247
- const isProducerSpan = argumentsList [ 0 ] === 'send' || argumentsList [ 0 ] === 'send_batch' ;
248
- const isConsumerSpan = argumentsList [ 0 ] === 'pop' ;
249
-
250
- if ( ! isProducerSpan && ! isConsumerSpan ) {
251
- return Reflect . apply ( target , thisArg , argumentsList ) ;
252
- }
253
-
254
- if ( isProducerSpan ) {
255
- return instrumentRpcProducer ( target , thisArg , argumentsList ) ;
256
- } else if ( isConsumerSpan ) {
257
- return instrumentRpcConsumer ( target , thisArg , argumentsList ) ;
258
- }
259
-
260
- // If the operation is not a queue operation, return the original function
261
- return Reflect . apply ( target , thisArg , argumentsList ) ;
262
- } ,
263
- } ,
264
- ) ;
265
-
241
+ instrumentRpcMethod ( supabaseInstance as unknown as SupabaseClientConstructorType ) ;
266
242
return supabaseInstance ;
267
243
} ,
268
244
} ,
269
245
) ;
270
-
271
246
markAsInstrumented ( ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ) ;
272
247
}
273
248
249
+ function instrumentRpcMethod ( supabaseInstance : SupabaseClientConstructorType ) : void {
250
+ supabaseInstance . rpc = new Proxy ( ( supabaseInstance as unknown as SupabaseClientInstance ) . rpc , {
251
+ apply ( target , thisArg , argumentsList ) {
252
+ const isProducerSpan = argumentsList [ 0 ] === 'send' || argumentsList [ 0 ] === 'send_batch' ;
253
+ const isConsumerSpan = argumentsList [ 0 ] === 'pop' ;
254
+ if ( ! isProducerSpan && ! isConsumerSpan ) {
255
+ return Reflect . apply ( target , thisArg , argumentsList ) ;
256
+ }
257
+ if ( isProducerSpan ) {
258
+ return instrumentRpcProducer ( target , thisArg , argumentsList ) ;
259
+ } else if ( isConsumerSpan ) {
260
+ return instrumentRpcConsumer ( target , thisArg , argumentsList ) ;
261
+ }
262
+ return Reflect . apply ( target , thisArg , argumentsList ) ;
263
+ } ,
264
+ } ) ;
265
+ }
266
+
274
267
function extractTraceAndBaggageFromMessage ( message : { _sentry ?: { sentry_trace ?: string ; baggage ?: string } } ) : {
275
268
sentryTrace ?: string ;
276
269
baggage ?: string ;
0 commit comments