@@ -233,44 +233,37 @@ function instrumentRpcReturnedFromSchemaCall(SupabaseClient: unknown): void {
233233 if ( isInstrumented ( ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ) ) {
234234 return ;
235235 }
236-
237236 ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema = new Proxy (
238237 ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ,
239238 {
240239 apply ( target , thisArg , argumentsList ) {
241240 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 ) ;
266242 return supabaseInstance ;
267243 } ,
268244 } ,
269245 ) ;
270-
271246 markAsInstrumented ( ( SupabaseClient as unknown as SupabaseClientConstructorType ) . prototype . schema ) ;
272247}
273248
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+
274267function extractTraceAndBaggageFromMessage ( message : { _sentry ?: { sentry_trace ?: string ; baggage ?: string } } ) : {
275268 sentryTrace ?: string ;
276269 baggage ?: string ;
0 commit comments