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
2 changes: 1 addition & 1 deletion docs/sdk/android/network.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Notes on the filter shape:
- Event types are `NetworkEvent` / `LogEvent` in `com.bugsee.library.contracts`.
- Mutators (`setUrl`, `setMethod`, `setBody`, headers, etc.) and `getBodyAbsenceReason()` are available.
- The filter applies uniformly to events coming from every network extension — OkHttp, Ktor 2, Ktor 3, and Cronet all feed the same pipeline.
- Installing a filter turns off the built-in redaction of credentials (`Authorization`, cookies, `password` and `token` fields); your filter must redact them, or call `NetworkDataSanitizer.sanitize(event)` to keep the built-in redaction. See [Privacy → Network traffic](/sdk/android/privacy/network#a-filter-replaces-the-built-in-redaction).
- Installing a filter turns off the built-in redaction of credentials (`Authorization`, cookies, `password` and `token` fields); your filter must redact them, or call `Bugsee.getDefaultNetworkSanitizer().sanitize(event)` to keep the built-in redaction (on SDK 7.0.3 through 7.2.0, the static `NetworkDataSanitizer.sanitize(event)`). See [Privacy → Network traffic](/sdk/android/privacy/network#a-filter-replaces-the-built-in-redaction).

See also the [Logs page](/sdk/android/logs) for the matching `setLogEventFilter(...)` API.

Expand Down
29 changes: 24 additions & 5 deletions docs/sdk/android/privacy/network.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,15 @@ only adds or renames a field records `Authorization` headers, cookies and
unless you disabled `CaptureNetworkUseDefaultSanitizer`.
:::

To keep the built-in redaction and add your own, call
`NetworkDataSanitizer.sanitize(event)` (package
`com.bugsee.library.shared.security.privacy`) at the start of your filter:
To keep the built-in redaction and add your own, call the SDK's default
sanitizer, `Bugsee.getDefaultNetworkSanitizer()`, at the start of your filter:

<Tabs groupId="lang-android">
<TabItem value="java" label="Java">

```java
Bugsee.setNetworkEventFilter((event, callback) -> {
NetworkDataSanitizer.sanitize(event); // built-in redaction
Bugsee.getDefaultNetworkSanitizer().sanitize(event); // built-in redaction
// ...your own redaction...
callback.run(event);
});
Expand All @@ -137,7 +136,7 @@ Bugsee.setNetworkEventFilter((event, callback) -> {

```kotlin
Bugsee.setNetworkEventFilter { event, callback ->
NetworkDataSanitizer.sanitize(event) // built-in redaction
Bugsee.getDefaultNetworkSanitizer().sanitize(event) // built-in redaction
// ...your own redaction...
callback.run(event)
}
Expand All @@ -146,6 +145,26 @@ Bugsee.setNetworkEventFilter { event, callback ->
</TabItem>
</Tabs>

`getDefaultNetworkSanitizer()` works before `Bugsee.launch()`, so you can use
it in a [manifest-declared filter](#declaring-the-filter-in-the-manifest), and
you can call it for every event. Besides `sanitize(event)`, which redacts the
URL, headers, body and error messages, it has `sanitizeUrl(event)` and
`sanitizeErrorMessage(event)`, which redact only the URL or only the error
messages.

:::note
`Bugsee.getDefaultNetworkSanitizer()` is new in SDK 7.3.0. On SDK 7.0.3
through 7.2.0, call the static `NetworkDataSanitizer.sanitize(event)` (package
`com.bugsee.library.shared.security.privacy`) instead; that class is deprecated
from 7.3.0 but still works. Earlier versions have no public sanitizer.

If your code wildcard-imports both `com.bugsee.library.contracts.exchange.*` and
`com.bugsee.library.shared.security.privacy.*`, the compiler reports
`NetworkDataSanitizer` as ambiguous after the upgrade. Import the one you mean by
its full name, or use `Bugsee.getDefaultNetworkSanitizer()`, which needs no
import.
:::

Capture from OkHttp 3/4, Ktor 2/3, and Cronet is wired automatically by the
Bugsee Gradle plugin through the matching
[extension modules](/sdk/android/extensibility/bugsee-extensions) — no manual interceptor
Expand Down
Loading