Skip to content

Commit b504152

Browse files
committed
Only include Supabase query body and RPC params when sendDefaultPii is enabled
1 parent a54be32 commit b504152

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

packages/core/src/integrations/supabase.ts

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,13 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte
417417
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',
418418
};
419419

420-
if (queryItems.length) {
420+
const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
421+
422+
if (sendDefaultPii && queryItems.length) {
421423
attributes['db.query'] = queryItems;
422424
}
423425

424-
if (Object.keys(body).length) {
426+
if (sendDefaultPii && Object.keys(body).length) {
425427
attributes['db.body'] = body;
426428
}
427429

@@ -451,10 +453,10 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte
451453
}
452454

453455
const supabaseContext: Record<string, any> = {};
454-
if (queryItems.length) {
456+
if (sendDefaultPii && queryItems.length) {
455457
supabaseContext.query = queryItems;
456458
}
457-
if (Object.keys(body).length) {
459+
if (sendDefaultPii && Object.keys(body).length) {
458460
supabaseContext.body = body;
459461
}
460462

@@ -480,18 +482,20 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte
480482
message: description,
481483
};
482484

483-
const data: Record<string, unknown> = {};
485+
if (sendDefaultPii) {
486+
const data: Record<string, unknown> = {};
484487

485-
if (queryItems.length) {
486-
data.query = queryItems;
487-
}
488+
if (queryItems.length) {
489+
data.query = queryItems;
490+
}
488491

489-
if (Object.keys(body).length) {
490-
data.body = body;
491-
}
492+
if (Object.keys(body).length) {
493+
data.body = body;
494+
}
492495

493-
if (Object.keys(data).length) {
494-
breadcrumb.data = data;
496+
if (Object.keys(data).length) {
497+
breadcrumb.data = data;
498+
}
495499
}
496500

497501
addBreadcrumb(breadcrumb);
@@ -1063,10 +1067,18 @@ function instrumentGenericRpc(
10631067
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',
10641068
};
10651069

1066-
if (params && typeof params === 'object') {
1070+
const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
1071+
const includeParams = sendDefaultPii && params != null && typeof params === 'object';
1072+
1073+
if (includeParams) {
10671074
attributes['db.params'] = params;
10681075
}
10691076

1077+
const rpcContext: Record<string, unknown> = { function: functionName };
1078+
if (includeParams) {
1079+
rpcContext.params = params;
1080+
}
1081+
10701082
return startSpan(
10711083
{
10721084
name: `rpc(${functionName})`,
@@ -1094,7 +1106,7 @@ function instrumentGenericRpc(
10941106
message: `rpc(${functionName})`,
10951107
};
10961108

1097-
if (params && typeof params === 'object') {
1109+
if (includeParams) {
10981110
breadcrumb.data = { body: params as Record<string, unknown> };
10991111
}
11001112

@@ -1106,19 +1118,13 @@ function instrumentGenericRpc(
11061118
if (error.code) err.code = error.code;
11071119
if (error.details) err.details = error.details;
11081120

1109-
captureSupabaseError(err, 'auto.db.supabase.rpc', {
1110-
function: functionName,
1111-
params,
1112-
});
1121+
captureSupabaseError(err, 'auto.db.supabase.rpc', rpcContext);
11131122
}
11141123

11151124
return res;
11161125
},
11171126
(err: Error) => {
1118-
captureSupabaseError(err, 'auto.db.supabase.rpc', {
1119-
function: functionName,
1120-
params,
1121-
});
1127+
captureSupabaseError(err, 'auto.db.supabase.rpc', rpcContext);
11221128

11231129
if (span) {
11241130
setHttpStatus(span, 500);

0 commit comments

Comments
 (0)