You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(java): Document Data Collection controls (#19401)
Document the Java and Android Data Collection controls planned for SDK
8.57.0.
This explains the new defaults, migration behavior from
`sendDefaultPii`, built-in filtering, and configuration through code,
properties, environment variables, Spring Boot, and Android manifest
metadata. It also documents support across HTTP, GraphQL, Apollo,
OkHttp, Ktor, OpenFeign, and File I/O integrations.
Update onboarding examples to opt into Data Collection with
`userInfo=false`, matching the privacy-conscious JavaScript setup
without adding unnecessary body configuration. Update Logback setup to
load SDK options from `sentry.properties` and document the scoped
`includeUnencodedMessage` control.
The documentation was checked against the cumulative sentry-java
implementation rather than the original plan. `databaseQueryData`
remains undocumented until a production integration consumes it.
Related implementation:
getsentry/sentry-java#5759
Refs getsentry/sentry-java#5666
---------
Co-authored-by: Claude <noreply@anthropic.com>
If this flag is enabled, certain personally identifiable information (PII) is added by active integrations.
102
102
103
+
This is a legacy flag. Use [`dataCollection`](#dataCollection) for granular control over automatically collected data.
104
+
105
+
For backwards compatibility, `sendDefaultPii` keeps its existing behavior when no Data Collection field is configured. As soon as you configure any `dataCollection` field, Data Collection becomes the source of truth for its categories and `sendDefaultPii` no longer controls them.
106
+
103
107
<Alert>
104
108
105
109
If you are using Sentry in your mobile app, read our [frequently asked questions about mobile data privacy](/security-legal-pii/security/mobile-privacy/) to assist with Apple App Store and Google Play app privacy details.
@@ -110,6 +114,110 @@ If you enable this option, be sure to manually remove what you don't want to sen
Controls which categories of data SDK integrations collect automatically. Data Collection applies only where an integration supports the category. It doesn't remove data you add explicitly through scopes, event processors, or callbacks such as `beforeSend`.
120
+
121
+
<Alert>
122
+
123
+
Call `options.getDataCollection().forceDataCollection()` or explicitly configure any field to enable Data Collection. All fields you don't configure use the defaults below, and the `sendDefaultPii` option is ignored.
|`userInfo`|`boolean`|`true`| Allows integrations to populate user identity and IP address information. |
130
+
|`cookies`\*|`KeyValueCollectionBehavior`|`DENY_LIST`| Collects cookies and filters sensitive values. |
131
+
|`httpHeaders.request`\*|`KeyValueCollectionBehavior`|`DENY_LIST`| Collects request headers and filters sensitive values. |
132
+
|`httpHeaders.response`\*|`KeyValueCollectionBehavior`|`DENY_LIST`| Collects response headers and filters sensitive values. |
133
+
|`httpBodies`|`Set<HttpBodyType>`| all body types | Collects supported incoming and outgoing request and response bodies. An empty set disables body collection. |
134
+
|`urlQueryParams`\*|`KeyValueCollectionBehavior`|`DENY_LIST`| Collects URL query parameters and filters sensitive values. |
|`filePaths`|`boolean`|`true`| Allows File I/O instrumentation to collect file names and absolute paths. File extensions and byte counts remain available when disabled. |
138
+
139
+
\* Fields marked with an asterisk take a single `KeyValueCollectionBehavior` value in code. Properties, environment variables, Spring Boot, and Android manifest metadata expose that value as separate `mode` and `terms` settings. `terms` contains additional matching terms for deny-list or allow-list behavior.
140
+
141
+
The marked fields support three modes:
142
+
143
+
-`OFF` (`KeyValueCollectionBehavior.off()`): Don't collect the category.
144
+
-`DENY_LIST` (`KeyValueCollectionBehavior.denyList(...)`): Collect values except those matching the built-in sensitive list or additional configured terms. The no-argument constructor uses this mode without custom terms.
145
+
-`ALLOW_LIST` (`KeyValueCollectionBehavior.allowList(...)`): Include plaintext values only for keys that match configured terms and don't match the built-in sensitive list. Sensitive values are always replaced with `"[Filtered]"`.
146
+
147
+
Matching is partial and case-insensitive. The built-in terms are `auth`, `token`, `secret`, `password`, `passwd`, `pwd`, `key`, `jwt`, `bearer`, `sso`, `saml`, `csrf`, `xsrf`, `credentials`, `session`, `sid`, and `identity`. Filtered values are replaced with `"[Filtered]"`. Custom deny-list terms extend the built-in list rather than replacing it.
148
+
149
+
When migrating from `sendDefaultPii=false`, configuring Data Collection causes supported integrations to send HTTP request and response headers by default. Review these headers for sensitive data and adjust `httpHeaders.request` and `httpHeaders.response` as needed.
150
+
151
+
The legacy header filtering also omitted sensitive headers such as `X-Forwarded-For`, `X-Real-IP`, and `Remote-Addr` in supported integrations. After you configure any Data Collection field, `sendDefaultPii` no longer controls these headers. Data Collection's default deny list filters credential and secret values but doesn't automatically match those identifying headers. To continue filtering them, add `forwarded`, `-ip`, `remote-`, `via`, and `-user` to a deny list. These terms also match keys such as `CF-Connecting-IP` and `X-User-Id`. Add them to `cookies`, `httpHeaders.request`, `httpHeaders.response`, or `urlQueryParams` as needed.
152
+
153
+
Configure Data Collection in `AndroidManifest.xml`:
| No Data Collection fields | Existing `sendDefaultPii` behavior is preserved. |
212
+
|`forceDataCollection()`| All Data Collection categories use the defaults above. |
213
+
| Any Data Collection field | That field uses its configured value, omitted fields use the defaults above, and `sendDefaultPii` is ignored for Data Collection categories. |
214
+
215
+
If you previously used `sendDefaultPii=false`, either leave Data Collection unset to preserve that behavior or explicitly disable every category you don't want collected. If you used `sendDefaultPii=true`, call `options.getDataCollection().forceDataCollection()` to opt into the new filtered defaults.
216
+
217
+
Data Collection doesn't control Session Replay. Configure Replay's URL, header, and body collection separately in the <PlatformLinkto="/session-replay/configuration/">Session Replay options</PlatformLink>.
When set to `true`, the SDK will send session events to Sentry. This is supported in all browser SDKs, emitting one session per pageload and page navigation to Sentry. In mobile SDKs, when the app goes to the background for longer than 30 seconds, sessions are ended.
Copy file name to clipboardExpand all lines: docs/platforms/android/data-management/data-collected.mdx
+28-20Lines changed: 28 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,45 +6,47 @@ sidebar_order: 1
6
6
7
7
Sentry takes data privacy very seriously and has default settings in place that prioritize data safety, especially when it comes to personally identifiable information (PII) data. When you add the Sentry SDK to your application, you allow it to collect data and send it to Sentry during the runtime of your application.
8
8
9
-
The category types and amount of data collected vary, depending on the integrations you've enabled in the Sentry SDK. This page lists data categories that the Sentry Android SDK collects.
9
+
The category types and amount of data collected vary, depending on the integrations you've enabled in the Sentry SDK. This page lists data categories that the Sentry Android SDK collects. Use <PlatformLinkto="/configuration/options/#dataCollection"><PlatformIdentifiername="data-collection" /></PlatformLink> to control automatic collection for supported categories.
10
10
11
-
Many of the categories listed here require you to enable the <PlatformLinkto="/configuration/options/#sendDefaultPii">sendDefaultPii option</PlatformLink>.
11
+
After you configure any Data Collection field or call `options.getDataCollection().forceDataCollection()`, unconfigured fields use their documented defaults.
12
+
13
+
Data Collection controls only data added automatically by SDK integrations. Data you add through scopes, event processors, `beforeSend`, or other APIs is still sent.
12
14
13
15
## HTTP Headers
14
16
15
-
By default, the Sentry SDK doesn't send any headers for outgoing HTTP requests. Even when sending HTTP headers is enabled, we have a [denylist](https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/util/HttpUtils.java#L21-L34) in place, which filters out any headers that contain sensitive data.
17
+
Request and response headers use `DENY_LIST` by default. Supported integrations collect header names and non-sensitive values while replacing sensitive values with `"[Filtered]"`.
16
18
17
-
To start sending HTTP headers, set <PlatformLinkto="/configuration/options/#sendDefaultPii">`sendDefaultPii=true`</PlatformLink>. Outside of the `sendDefaultPii` flag, you can opt to have specific headers captured in recorded user sessions. See the [Session Replay network detail options](/platforms/android/session-replay/configuration/) for more details.
19
+
Configure <PlatformLinkto="/configuration/options/#dataCollection">`dataCollection.httpHeaders.request`</PlatformLink> and <PlatformLinkto="/configuration/options/#dataCollection">`dataCollection.httpHeaders.response`</PlatformLink> to control header collection. `Cookie` and `Set-Cookie` values in the general HTTP header map are always replaced with `"[Filtered]"`; use `dataCollection.cookies` to control separately collected cookie data. OkHttp, Ktor Client, and Apollo 3 and 4 can attach available request and response headers to captured HTTP client errors.
18
20
19
-
## Cookies
21
+
Session Replay network details use [separate options](/platforms/android/session-replay/configuration/).
20
22
21
-
By default, the Sentry SDK doesn't send cookies. Sentry tries to remove any cookies that contain sensitive information, such as the Session ID and CSRF Token cookies.
23
+
## Cookies
22
24
23
-
If you want to send cookies, set <PlatformLinkto="/configuration/options/#send-default-pii">`sendDefaultPii=true`</PlatformLink>.
25
+
Cookies use `DENY_LIST` by default. Supported integrations collect cookies while replacing sensitive values with `"[Filtered]"`. Use `dataCollection.cookies` to control cookie collection.
24
26
25
27
## Information About Logged-in User
26
28
27
-
By default, the Sentry SDK doesn't send any information about the logged-in user, such as email address, user ID, or username. Even if enabled, the type of logged-in user information you'll be able to send depends on the integrations you enable in Sentry's SDK. Most integrations won't send any user information. Some will only set the user ID, but there are a few that will set the user ID, username, and email address.
29
+
The SDK assigns a random installation ID when an event has no user ID. This ID is generated once per app installation and isn't controlled by Data Collection.
28
30
29
-
To start sending logged-in user information, set <PlatformLinkto="/configuration/options/#send-default-pii">`sendDefaultPii=true`</PlatformLink>.
31
+
`dataCollection.userInfo` allows integrations to populate other user identity information automatically. It defaults to `true`. Set it to `false` to disable automatic user enrichment. User information you set explicitly with `Sentry.setUser()` or on a scope isn't removed.
30
32
31
33
## Users' IP Addresses
32
34
33
-
By default, the Sentry SDK doesn't send the user's IP address. Once enabled, the Sentry backend services will infer the user ip address based on the incoming request, unless certain integrations you can enable override this behavior.
34
-
35
-
To enable sending the user's IP address, set <PlatformLinkto="/configuration/options/#send-default-pii">`sendDefaultPii=true`</PlatformLink>.
35
+
When `dataCollection.userInfo` is `true`, the SDK adds `"{{auto}}"` as the user's IP address so Sentry can infer it from the connection. Set `dataCollection.userInfo=false` to disable automatic IP enrichment.
36
36
37
37
## Request URL
38
38
39
-
The full request URL of outgoing and incoming HTTP requests is **always sent to Sentry**. Depending on your application, this could contain PII data.
39
+
The request URL (without the query string) of outgoing and incoming HTTP requests is **always sent to Sentry**. Depending on your application, this could contain PII data.
40
40
41
41
## Request Query String
42
42
43
-
The full request query string of outgoing and incoming HTTP requests is **always sent to Sentry**. Depending on your application, this could contain PII data.
43
+
Query parameters use `DENY_LIST` by default. Use `dataCollection.urlQueryParams`to filter or disable query string collection for instrumented request URLs.
44
44
45
45
## Request and Response Bodies
46
46
47
-
By default, no request or response bodies are sent to Sentry from the Android SDK. If you want to collect request or response bodies in recorded user sessions, see the Session Replay [network detail configuration docs](/platforms/android/session-replay/configuration/).
47
+
All request and response body directions are enabled by default, but integrations collect bodies only where supported. Some integrations collect body content, while others collect only body sizes.
48
+
49
+
Use `dataCollection.httpBodies` to choose which directions to collect or an empty set to disable body collection. Session Replay network body collection uses [separate options](/platforms/android/session-replay/configuration/).
48
50
49
51
## Source Context
50
52
@@ -54,20 +56,26 @@ To opt into sending this source context to Sentry, you have to enable the featur
54
56
55
57
## File I/O
56
58
57
-
By default the Sentry SDK does not send the name or path of files when instrumenting File I/O.
59
+
File I/O instrumentation collects file names and absolute paths by default. Set `dataCollection.filePaths=false` to omit them. File extensions and byte counts remain available when paths are disabled.
60
+
61
+
## Device Context
58
62
59
-
If you want to send file names and paths, set <PlatformLinkto="/configuration/options/#send-default-pii">`sendDefaultPii=true`</PlatformLink>.
63
+
The SDK automatically collects device and operating-system context, including the manufacturer, model, architecture, orientation, display details, boot time, timezone, memory size, and emulator status.
60
64
61
-
## Device Information
65
+
Set <PlatformLinkto="/configuration/options/#collectAdditionalContext">`collectAdditionalContext=false`</PlatformLink> to reduce additional dynamic context such as battery level, available memory, storage state, and connectivity.
62
66
63
-
By default the Sentry SDK does not send the name of the device (Android phone).
67
+
## GraphQL Data
64
68
65
-
If you want to send the device name, set <PlatformLinkto="/configuration/options/#send-default-pii">`sendDefaultPii=true`</PlatformLink>.
69
+
GraphQL document and variable collection default to `true`. Use `dataCollection.graphql.document` and `dataCollection.graphql.variables` to disable either category. Operation metadata used for tracing and grouping can still be collected when document or variable content is disabled.
66
70
67
71
## SQL Queries
68
72
69
73
While SQL queries are sent to Sentry, neither the full SQL query (`UPDATE app_user SET password='supersecret' WHERE id=1;`), nor the values of its parameters will ever be sent. A parameterized version of the query (`UPDATE app_user SET password=? WHERE id=?;`) is sent instead.
70
74
75
+
## Logs
76
+
77
+
Log messages, parameters, and breadcrumb content may contain application data. Data Collection doesn't filter this content. Use `beforeBreadcrumb` for breadcrumbs, `beforeSend` for events, or `options.getLogs().setBeforeSend(...)` for Sentry Logs when you need application-specific filtering.
78
+
71
79
## Session Replay
72
80
73
81
By default, our Session Replay SDK masks all text content, images, webviews, and user input. This helps ensure that no sensitive data is exposed. You can find <PlatformLinkto="/session-replay/privacy/">more details in the Session Replay documentation</PlatformLink>.
0 commit comments