Skip to content

Commit ff50e60

Browse files
authored
ref(core): Deprecate sendDefaultPii in favor or dataCollection (#21277)
Deprecates `sendDefaultPii`. Some `sendDefaultPii` occurences are still there as we still test against the deprecated behavior. This will be removed in v11. Closes #20937
1 parent 154fbba commit ff50e60

13 files changed

Lines changed: 68 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
- **ref(core): Deprecate `sendDefaultPii` in favor of `dataCollection` [#21277](https://github.com/getsentry/sentry-javascript/pull/21277)**
8+
9+
`sendDefaultPii` is deprecated and will be removed in v11. The new `dataCollection` option lets you control each category of collected data.
10+
`sendDefaultPii: true` still works and maps to enabling all `dataCollection` categories.
11+
`dataCollection.userInfo` defaults to `false` and only gates auto-populated `user.*` fields (e.g. IP address from a request).
12+
Data you set explicitly via `Sentry.setUser()` is always sent regardless.
13+
14+
Note that an empty `dataCollection: {}` falls back to more permissive defaults than `sendDefaultPii: false`, so replicate the old behavior by opting out explicitly:
15+
16+
```js
17+
Sentry.init({
18+
dataCollection: {
19+
genAI: { inputs: false, outputs: false },
20+
httpHeaders: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
21+
cookies: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
22+
queryParams: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
23+
},
24+
});
25+
```
26+
727
## 10.55.0
828

929
### Important Changes

packages/aws-serverless/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ import * as Sentry from '@sentry/aws-serverless';
4141

4242
Sentry.init({
4343
dsn: '__DSN__',
44-
// Adds request headers and IP for users, for more info visit:
45-
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
46-
sendDefaultPii: true,
44+
// Adds HTTP request headers and IP for users, for more info visit:
45+
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#dataCollection
46+
dataCollection: { userInfo: true, httpHeaders: { request: true } },
4747
// Add Tracing by setting tracesSampleRate and adding integration
4848
// Set tracesSampleRate to 1.0 to capture 100% of transactions
4949
// We recommend adjusting this value in production

packages/browser/src/integrations/httpclient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ function _getDataCollectionSettings() {
433433
// collect headers/cookies with deny-list filtering even without sendDefaultPii).
434434
const options = client.getOptions();
435435
if (options.dataCollection == null) {
436+
// eslint-disable-next-line deprecation/deprecation
436437
const enabled = Boolean(options.sendDefaultPii);
437438
return { cookies: enabled, requestHeaders: enabled, responseHeaders: enabled };
438439
}

packages/cloudflare/src/sdk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function getDefaultIntegrations(options: CloudflareOptions): Integration[
2727
// TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved
2828
// `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not
2929
// attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.
30+
// eslint-disable-next-line deprecation/deprecation
3031
const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;
3132
return [
3233
// The Dedupe integration should not be used in workflows because we want to

packages/core/src/types/options.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,21 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
386386
*
387387
* @default false
388388
*
389-
* NOTE: This option currently controls only a few data points in a selected
390-
* set of SDKs. The goal for this option is to eventually control all sensitive
391-
* data the SDK sets by default. However, this would be a breaking change so
392-
* until the next major update this option only controls data points which were
393-
* added in versions above `7.9.0`.
389+
* @deprecated Use the {@link ClientOptions.dataCollection} option instead, which lets you control
390+
* each category of collected data individually. `sendDefaultPii` will be removed in the next major
391+
* version (v11). For backwards compatibility, setting `sendDefaultPii: true` currently behaves like
392+
* enabling all `dataCollection` categories. If both `sendDefaultPii` and `dataCollection` are set,
393+
* `sendDefaultPii` will be ignored.
394394
*/
395395
sendDefaultPii?: boolean;
396396

397397
/**
398398
* Controls what data the SDK collects and sends to Sentry.
399399
* All fields are optional — omitted fields use the documented defaults.
400+
*
401+
* This replaces the deprecated {@link ClientOptions.sendDefaultPii} option and lets you control
402+
* each category of collected data (user info, cookies, headers, query params, request/response
403+
* bodies, gen AI inputs/outputs, etc.) individually.
400404
*/
401405
dataCollection?: DataCollection;
402406

packages/node/src/integrations/tracing/anthropic-ai/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ const _anthropicAIIntegration = ((options: AnthropicAiOptions = {}) => {
3737
*
3838
* ## Options
3939
*
40-
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
41-
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
40+
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
41+
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
4242
*
4343
* ### Default Behavior
4444
*
4545
* By default, the integration will:
46-
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
46+
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
47+
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
4748
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
4849
*
4950
* @example

packages/node/src/integrations/tracing/google-genai/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ const _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {
3636
*
3737
* ## Options
3838
*
39-
* - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)
40-
* - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
39+
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`)
40+
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`)
4141
*
4242
* ### Default Behavior
4343
*
4444
* By default, the integration will:
45-
* - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
46-
* - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
45+
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
46+
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
47+
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
4748
*
4849
* @example
4950
* ```javascript
50-
* // Record inputs and outputs when sendDefaultPii is false
51+
* // Always record inputs and outputs regardless of global dataCollection config
5152
* Sentry.init({
5253
* integrations: [
5354
* Sentry.googleGenAiIntegration({
@@ -57,9 +58,9 @@ const _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {
5758
* ],
5859
* });
5960
*
60-
* // Never record inputs/outputs regardless of sendDefaultPii
61+
* // Never record inputs/outputs regardless of global dataCollection config
6162
* Sentry.init({
62-
* sendDefaultPii: true,
63+
* dataCollection: { genAI: { inputs: true, outputs: true } },
6364
* integrations: [
6465
* Sentry.googleGenAiIntegration({
6566
* recordInputs: false,

packages/node/src/integrations/tracing/langchain/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
3636
*
3737
* Sentry.init({
3838
* integrations: [Sentry.langChainIntegration()],
39-
* sendDefaultPii: true, // Enable to record inputs/outputs
39+
* dataCollection: { genAI: { inputs: true, outputs: true } }, // Enable to record inputs/outputs
4040
* });
4141
*
4242
* // LangChain calls are automatically instrumented
@@ -67,18 +67,19 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
6767
*
6868
* ## Options
6969
*
70-
* - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)
71-
* - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
70+
* - `recordInputs`: Whether to record input messages/prompts (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
71+
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
7272
*
7373
* ### Default Behavior
7474
*
7575
* By default, the integration will:
76-
* - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
77-
* - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
76+
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
77+
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
78+
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
7879
*
7980
* @example
8081
* ```javascript
81-
* // Record inputs and outputs when sendDefaultPii is false
82+
* // Always record inputs and outputs regardless of global dataCollection config
8283
* Sentry.init({
8384
* integrations: [
8485
* Sentry.langChainIntegration({
@@ -88,9 +89,9 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
8889
* ],
8990
* });
9091
*
91-
* // Never record inputs/outputs regardless of sendDefaultPii
92+
* // Never record inputs/outputs regardless of global dataCollection config
9293
* Sentry.init({
93-
* sendDefaultPii: true,
94+
* dataCollection: { genAI: { inputs: true, outputs: true } },
9495
* integrations: [
9596
* Sentry.langChainIntegration({
9697
* recordInputs: false,

packages/node/src/integrations/tracing/langgraph/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ const _langGraphIntegration = ((options: LangGraphOptions = {}) => {
3636
*
3737
* ## Options
3838
*
39-
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
40-
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
39+
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
40+
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
4141
*
4242
* ### Default Behavior
4343
*
4444
* By default, the integration will:
45-
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
45+
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
46+
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
4647
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
4748
*
4849
* @example

packages/node/src/integrations/tracing/openai/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ const _openAiIntegration = ((options: OpenAiOptions = {}) => {
3636
*
3737
* ## Options
3838
*
39-
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
40-
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
39+
* - `recordInputs`: Whether to record input messages/prompts (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
40+
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
4141
*
4242
* ### Default Behavior
4343
*
4444
* By default, the integration will:
45-
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
45+
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
46+
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
4647
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
4748
*
4849
* @example

0 commit comments

Comments
 (0)