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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@

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

- **ref(core): Deprecate `sendDefaultPii` in favor of `dataCollection` [#21277](https://github.com/getsentry/sentry-javascript/pull/21277)**

`sendDefaultPii` is deprecated and will be removed in v11. The new `dataCollection` option lets you control each category of collected data.
`sendDefaultPii: true` still works and maps to enabling all `dataCollection` categories.
`dataCollection.userInfo` defaults to `false` and only gates auto-populated `user.*` fields (e.g. IP address from a request).
Data you set explicitly via `Sentry.setUser()` is always sent regardless.

Note that an empty `dataCollection: {}` falls back to more permissive defaults than `sendDefaultPii: false`, so replicate the old behavior by opting out explicitly:

```js
Sentry.init({
dataCollection: {
genAI: { inputs: false, outputs: false },
httpHeaders: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
cookies: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
queryParams: { deny: ['forwarded', '-ip', 'remote-', 'via', '-user'] },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super-l: Should we use different deny examples for each entry?

For cookies we could use csrf or token, and for queryParams there would be state for OAuth requests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csrf and token are sensitive and will be filtered always: https://github.com/getsentry/sentry-javascript/blob/develop/packages/core/src/utils/data-collection/filtering-snippets.ts|

We can also include state in there.

},
});
```

## 10.55.0

### Important Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import * as Sentry from '@sentry/aws-serverless';

Sentry.init({
dsn: '__DSN__',
// Adds request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
sendDefaultPii: true,
// Adds HTTP request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#dataCollection
dataCollection: { userInfo: true, httpHeaders: { request: true } },
// Add Tracing by setting tracesSampleRate and adding integration
// Set tracesSampleRate to 1.0 to capture 100% of transactions
// We recommend adjusting this value in production
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/integrations/httpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ function _getDataCollectionSettings() {
// collect headers/cookies with deny-list filtering even without sendDefaultPii).
const options = client.getOptions();
if (options.dataCollection == null) {
// eslint-disable-next-line deprecation/deprecation
const enabled = Boolean(options.sendDefaultPii);
return { cookies: enabled, requestHeaders: enabled, responseHeaders: enabled };
}
Expand Down
1 change: 1 addition & 0 deletions packages/cloudflare/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function getDefaultIntegrations(options: CloudflareOptions): Integration[
// TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved
// `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not
// attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.
// eslint-disable-next-line deprecation/deprecation
const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;
return [
// The Dedupe integration should not be used in workflows because we want to
Expand Down
14 changes: 9 additions & 5 deletions packages/core/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,21 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
*
* @default false
*
* NOTE: This option currently controls only a few data points in a selected
* set of SDKs. The goal for this option is to eventually control all sensitive
* data the SDK sets by default. However, this would be a breaking change so
* until the next major update this option only controls data points which were
* added in versions above `7.9.0`.
* @deprecated Use the {@link ClientOptions.dataCollection} option instead, which lets you control
* each category of collected data individually. `sendDefaultPii` will be removed in the next major
* version (v11). For backwards compatibility, setting `sendDefaultPii: true` currently behaves like
* enabling all `dataCollection` categories. If both `sendDefaultPii` and `dataCollection` are set,
* `sendDefaultPii` will be ignored.
*/
sendDefaultPii?: boolean;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ const _anthropicAIIntegration = ((options: AnthropicAiOptions = {}) => {
*
* ## Options
*
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
*
* ### Default Behavior
*
* By default, the integration will:
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
*
* @example
Expand Down
15 changes: 8 additions & 7 deletions packages/node/src/integrations/tracing/google-genai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ const _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {
*
* ## Options
*
* - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)
* - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`)
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`)
*
* ### Default Behavior
*
* By default, the integration will:
* - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
* - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
*
* @example
* ```javascript
* // Record inputs and outputs when sendDefaultPii is false
* // Always record inputs and outputs regardless of global dataCollection config
* Sentry.init({
* integrations: [
* Sentry.googleGenAiIntegration({
Expand All @@ -57,9 +58,9 @@ const _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {
* ],
* });
*
* // Never record inputs/outputs regardless of sendDefaultPii
* // Never record inputs/outputs regardless of global dataCollection config
* Sentry.init({
* sendDefaultPii: true,
* dataCollection: { genAI: { inputs: true, outputs: true } },
* integrations: [
* Sentry.googleGenAiIntegration({
* recordInputs: false,
Expand Down
17 changes: 9 additions & 8 deletions packages/node/src/integrations/tracing/langchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
*
* Sentry.init({
* integrations: [Sentry.langChainIntegration()],
* sendDefaultPii: true, // Enable to record inputs/outputs
* dataCollection: { genAI: { inputs: true, outputs: true } }, // Enable to record inputs/outputs
* });
*
* // LangChain calls are automatically instrumented
Expand Down Expand Up @@ -67,18 +67,19 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
*
* ## Options
*
* - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)
* - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
* - `recordInputs`: Whether to record input messages/prompts (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
*
* ### Default Behavior
*
* By default, the integration will:
* - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
* - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
*
* @example
* ```javascript
* // Record inputs and outputs when sendDefaultPii is false
* // Always record inputs and outputs regardless of global dataCollection config
* Sentry.init({
* integrations: [
* Sentry.langChainIntegration({
Expand All @@ -88,9 +89,9 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
* ],
* });
*
* // Never record inputs/outputs regardless of sendDefaultPii
* // Never record inputs/outputs regardless of global dataCollection config
* Sentry.init({
* sendDefaultPii: true,
* dataCollection: { genAI: { inputs: true, outputs: true } },
* integrations: [
* Sentry.langChainIntegration({
* recordInputs: false,
Expand Down
7 changes: 4 additions & 3 deletions packages/node/src/integrations/tracing/langgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ const _langGraphIntegration = ((options: LangGraphOptions = {}) => {
*
* ## Options
*
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
* - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
*
* ### Default Behavior
*
* By default, the integration will:
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
*
* @example
Expand Down
7 changes: 4 additions & 3 deletions packages/node/src/integrations/tracing/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ const _openAiIntegration = ((options: OpenAiOptions = {}) => {
*
* ## Options
*
* - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)
* - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)
* - `recordInputs`: Whether to record input messages/prompts (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)
* - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)
*
* ### Default Behavior
*
* By default, the integration will:
* - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options
* - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options
* (or the deprecated `sendDefaultPii` option, for backwards compatibility)
* - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config
*
* @example
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/tracing/vercelai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export declare type AttributeValue =

export interface VercelAiOptions {
/**
* Enable or disable input recording. Enabled if `sendDefaultPii` or `dataCollection.genAI.inputs` is `true`
* Enable or disable input recording. Enabled if `dataCollection.genAI.inputs` (or the deprecated `sendDefaultPii` option) is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
* Integration-level options take precedence over global `dataCollection` config.
*/
recordInputs?: boolean;
/**
* Enable or disable output recording. Enabled if `sendDefaultPii` or `dataCollection.genAI.outputs` is `true`
* Enable or disable output recording. Enabled if `dataCollection.genAI.outputs` (or the deprecated `sendDefaultPii` option) is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
* Integration-level options take precedence over global `dataCollection` config.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/vercel-edge/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ declare const process: {
const nodeStackParser = createStackParser(nodeStackLineParser());

/** Get the default integrations for the browser SDK. */
export function getDefaultIntegrations(options: Options): Integration[] {
export function getDefaultIntegrations(_options: Options): Integration[] {
// todo(v11): remove options parameter
return [
dedupeIntegration(),
// TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`
Expand All @@ -56,8 +57,7 @@ export function getDefaultIntegrations(options: Options): Integration[] {
linkedErrorsIntegration(),
winterCGFetchIntegration(),
consoleIntegration(),
// TODO(v11): integration can be included - but integration should not add IP address etc
...(options.sendDefaultPii ? [requestDataIntegration()] : []),
requestDataIntegration(),
];
Comment on lines 59 to 61
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The requestDataIntegration() is now always included, causing unintended collection of request headers, cookies, and query parameters for users who haven't opted into PII collection.
Severity: HIGH

Suggested Fix

Reinstate a guard around the requestDataIntegration() inclusion. The integration should only be added if the user has explicitly opted into data collection, for example by checking sendDefaultPii or a more modern data collection option. This will prevent the default collection of sensitive request data for users who have not consented.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/vercel-edge/src/sdk.ts#L59-L61

Potential issue: The removal of the `sendDefaultPii` guard around
`requestDataIntegration()` in the `vercel-edge` SDK causes it to be unconditionally
included. By default, this integration collects and sends request headers, cookies, and
query parameters, even when `sendDefaultPii` is not explicitly enabled. This is a change
in behavior for existing users who previously did not have this data collected, leading
to an unintended privacy regression where potentially sensitive information is sent to
Sentry without explicit opt-in.

Did we get this right? 👍 / 👎 to inform future reviews.

}

Expand Down
1 change: 0 additions & 1 deletion packages/vue/src/errorhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const attachErrorHandler = (app: Vue, options?: Partial<VueOptions>): voi
trace,
};

// TODO(v11): guard via sendDefaultPii?
if (options?.attachProps !== false && vm) {
// Vue2 - $options.propsData
// Vue3 - $props
Expand Down
Loading