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