Skip to content

Commit 8bbd106

Browse files
committed
Clean up
1 parent da14266 commit 8bbd106

File tree

1 file changed

+36
-48
lines changed

1 file changed

+36
-48
lines changed

packages/core/src/integrations/supabase.ts

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* eslint-disable max-lines */
2727
import { logger, isPlainObject } from '../utils-hoist';
2828

29-
import type { Span, IntegrationFn } from '../types-hoist';
29+
import type { IntegrationFn } from '../types-hoist';
3030
import { setHttpStatus, startInactiveSpan } from '../tracing';
3131
import { addBreadcrumb } from '../breadcrumbs';
3232
import { defineIntegration } from '../integration';
@@ -271,35 +271,28 @@ function instrumentPostgrestFilterBuilder(PostgrestFilterBuilder: PostgrestFilte
271271
}
272272
}
273273

274-
// TODO / Should?
275-
const shouldCreateSpan = true;
276-
277-
let span: Span | undefined;
278-
279-
if (shouldCreateSpan) {
280-
const attributes: Record<string, any> = {
281-
'db.table': table,
282-
'db.schema': typedThis.schema,
283-
'db.url': typedThis.url.origin,
284-
'db.sdk': typedThis.headers['X-Client-Info'],
285-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',
286-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `db.${operation}`,
287-
};
288-
289-
if (query.length) {
290-
attributes['db.query'] = query;
291-
}
292-
293-
if (Object.keys(body).length) {
294-
attributes['db.body'] = body;
295-
}
274+
const attributes: Record<string, any> = {
275+
'db.table': table,
276+
'db.schema': typedThis.schema,
277+
'db.url': typedThis.url.origin,
278+
'db.sdk': typedThis.headers['X-Client-Info'],
279+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',
280+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `db.${operation}`,
281+
};
282+
283+
if (query.length) {
284+
attributes['db.query'] = query;
285+
}
296286

297-
span = startInactiveSpan({
298-
name: description,
299-
attributes,
300-
});
287+
if (Object.keys(body).length) {
288+
attributes['db.body'] = body;
301289
}
302290

291+
const span = startInactiveSpan({
292+
name: description,
293+
attributes,
294+
});
295+
303296
return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)
304297
.then(
305298
(res: SupabaseResponse) => {
@@ -334,33 +327,28 @@ function instrumentPostgrestFilterBuilder(PostgrestFilterBuilder: PostgrestFilte
334327
});
335328
}
336329

337-
// Todo / Should?
338-
const shouldCreateBreadcrumb = true;
339-
340-
if (shouldCreateBreadcrumb) {
341-
const breadcrumb: SupabaseBreadcrumb = {
342-
type: 'supabase',
343-
category: `db.${operation}`,
344-
message: description,
345-
};
330+
const breadcrumb: SupabaseBreadcrumb = {
331+
type: 'supabase',
332+
category: `db.${operation}`,
333+
message: description,
334+
};
346335

347-
const data: Record<string, unknown> = {};
336+
const data: Record<string, unknown> = {};
348337

349-
if (query.length) {
350-
data.query = query;
351-
}
352-
353-
if (Object.keys(body).length) {
354-
data.body = body;
355-
}
338+
if (query.length) {
339+
data.query = query;
340+
}
356341

357-
if (Object.keys(data).length) {
358-
breadcrumb.data = data;
359-
}
342+
if (Object.keys(body).length) {
343+
data.body = body;
344+
}
360345

361-
addBreadcrumb(breadcrumb);
346+
if (Object.keys(data).length) {
347+
breadcrumb.data = data;
362348
}
363349

350+
addBreadcrumb(breadcrumb);
351+
364352
return res;
365353
},
366354
(err: Error) => {

0 commit comments

Comments
 (0)