Android SDK ⁠-⁠ Sanitize sensitive data

Sanitized views will be blurred out in the resulting replay. You can add any UI component and it will be automatically removed (to preserve memory) as soon as its not on screen.

import com.openreplay.tracker.OpenReplay


Two keys are exported to automatically trim the request/response data: ignoredKeys for body and ignoredHeaders for headers. Both, request and response will be sanitized, but body will only be affected if its a valid JSON.

Simply assign a list of strings that you would like to sanitize:

val networkListener = NetworkListener()
networkListener.ignoredHeaders = ["mySecretToken"]
networkListener.ignoredKeys = ["password"]

It is also possible to change the response data before passing it to the listener:

// ... request

var sanitizedData: Any? = null
data?.let {
    try {
        val json = JSONTokener(it).nextValue()
        sanitizedData = customSanitizeFunction(it)
    } catch (error: JSONException) {
        println("Error deserializing JSON: $error")

networkListener.finish(response, sanitizedData)

If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.