11/* eslint-disable max-lines */
2- import { isPlainObject } from '../utils-hoist' ;
2+ import { logger , isPlainObject } from '../utils-hoist' ;
33
44import type { Span , IntegrationFn } from '../types-hoist' ;
55import { setHttpStatus , startInactiveSpan } from '../tracing' ;
@@ -57,10 +57,20 @@ export interface SupabaseBreadcrumb {
5757export const AVAILABLE_OPERATIONS = [ 'select' , 'insert' , 'upsert' , 'update' , 'delete' ] ;
5858
5959export const FILTER_MAPPINGS = {
60+ eq : 'eq' ,
61+ neq : 'neq' ,
62+ gt : 'gt' ,
63+ gte : 'gte' ,
64+ lt : 'lt' ,
65+ lte : 'lte' ,
66+ like : 'like' ,
6067 'like(all)' : 'likeAllOf' ,
6168 'like(any)' : 'likeAnyOf' ,
69+ ilike : 'ilike' ,
6270 'ilike(all)' : 'ilikeAllOf' ,
6371 'ilike(any)' : 'ilikeAnyOf' ,
72+ is : 'is' ,
73+ in : 'in' ,
6474 cs : 'contains' ,
6575 cd : 'containedBy' ,
6676 sr : 'rangeGt' ,
@@ -69,6 +79,11 @@ export const FILTER_MAPPINGS = {
6979 nxr : 'rangeLte' ,
7080 adj : 'rangeAdjacent' ,
7181 ov : 'overlaps' ,
82+ fts : '' ,
83+ plfts : 'plain' ,
84+ phfts : 'phrase' ,
85+ wfts : 'websearch' ,
86+ not : 'not' ,
7287} ;
7388
7489const instrumented = new Map ( ) ;
@@ -135,7 +150,7 @@ export function translateFiltersIntoMethods(key: string, query: string): string
135150 } else if ( filter ?. startsWith ( 'wfts' ) ) {
136151 method = 'textSearch[websearch]' ;
137152 } else {
138- method = ( filter && FILTER_MAPPINGS [ filter as keyof typeof FILTER_MAPPINGS ] ) || filter || 'filter' ;
153+ method = ( filter && FILTER_MAPPINGS [ filter as keyof typeof FILTER_MAPPINGS ] ) || 'filter' ;
139154 }
140155
141156 return `${ method } (${ key } , ${ value . join ( '.' ) } )` ;
@@ -359,6 +374,8 @@ function instrumentPostgrestQueryBuilder(PostgrestQueryBuilder: new () => Postgr
359374 const rv = Reflect . apply ( target , thisArg , argumentsList ) ;
360375 const PostgrestFilterBuilder = ( rv as PostgrestFilterBuilder ) . constructor ;
361376
377+ logger . log ( `Instrumenting ${ operation } operation's PostgrestFilterBuilder` ) ;
378+
362379 instrumentPostgrestFilterBuilder ( PostgrestFilterBuilder ) ;
363380
364381 return rv ;
0 commit comments