Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/core/src/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {

const client = getClient();
const clientOptions = client?.getOptions();
const dataCollection = client?.getDataCollectionOptions();
Comment thread
chargome marked this conversation as resolved.

const trpcContext: Record<string, unknown> = {
procedure_path: path,
Expand All @@ -59,7 +60,11 @@ export function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {
(clientOptions?.normalizeDepth ?? 5), // 5 is a sane depth
);

if (options.attachRpcInput !== undefined ? options.attachRpcInput : clientOptions?.sendDefaultPii) {
if (
options.attachRpcInput !== undefined
? options.attachRpcInput
: dataCollection?.httpBodies.includes('incomingRequest')
) {
if (rawInput !== undefined) {
trpcContext.input = normalize(rawInput);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/test/lib/trpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { type Client, setCurrentClient, type Span, trpcMiddleware } from '../../
import * as currentScopes from '../../src/currentScopes';
import * as exports from '../../src/exports';
import * as tracing from '../../src/tracing';
import { resolveDataCollectionOptions } from '../../src/utils/data-collection/resolveDataCollectionOptions';
import { getDefaultTestClientOptions, TestClient } from '../mocks/client';

describe('trpcMiddleware', () => {
Expand All @@ -13,6 +14,7 @@ describe('trpcMiddleware', () => {
normalizeDepth: 3,
sendDefaultPii: false,
}),
getDataCollectionOptions: vi.fn().mockReturnValue(resolveDataCollectionOptions({ sendDefaultPii: false })),
captureException: vi.fn(),
} as unknown as Client;

Expand Down
Loading