-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #739 from DataDog/marcosaia/RUM-7181/sr-fgm-config
[RUM-7181] SR: Fine Grained Masking privacy configuration
- Loading branch information
Showing
12 changed files
with
537 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...oid/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.reactnative.sessionreplay | ||
|
||
import android.util.Log | ||
import com.datadog.android.sessionreplay.ImagePrivacy | ||
import com.datadog.android.sessionreplay.TextAndInputPrivacy | ||
import com.datadog.android.sessionreplay.TouchPrivacy | ||
|
||
/** | ||
* A utility class to store Session Replay privacy settings, and convert them from string to | ||
* enum values. | ||
* | ||
* @param imagePrivacyLevel Defines the way images should be masked. | ||
* @param touchPrivacyLevel Defines the way user touches should be masked. | ||
* @param textAndInputPrivacyLevel Defines the way text and input should be masked. | ||
*/ | ||
class SessionReplayPrivacySettings( | ||
imagePrivacyLevel: String, | ||
touchPrivacyLevel: String, | ||
textAndInputPrivacyLevel: String | ||
){ | ||
/** | ||
* Defines the way images should be masked. | ||
*/ | ||
val imagePrivacyLevel = getImagePrivacy(imagePrivacyLevel) | ||
|
||
/** | ||
* Defines the way user touches should be masked. | ||
*/ | ||
val touchPrivacyLevel = getTouchPrivacy(touchPrivacyLevel) | ||
|
||
/** | ||
* Defines the way text and input should be masked. | ||
*/ | ||
val textAndInputPrivacyLevel = getTextAndInputPrivacy(textAndInputPrivacyLevel) | ||
|
||
companion object { | ||
internal fun getImagePrivacy(imagePrivacyLevel: String): ImagePrivacy { | ||
return when (imagePrivacyLevel) { | ||
"MASK_NON_BUNDLED_ONLY" -> ImagePrivacy.MASK_LARGE_ONLY | ||
"MASK_ALL" -> ImagePrivacy.MASK_ALL | ||
"MASK_NONE" -> ImagePrivacy.MASK_NONE | ||
else -> { | ||
Log.w( | ||
SessionReplayPrivacySettings::class.java.canonicalName, | ||
"Unknown Session Replay Image Privacy Level given: $imagePrivacyLevel, " + | ||
"using ${ImagePrivacy.MASK_ALL} as default" | ||
) | ||
ImagePrivacy.MASK_ALL | ||
} | ||
} | ||
} | ||
|
||
internal fun getTouchPrivacy(touchPrivacyLevel: String): TouchPrivacy { | ||
return when (touchPrivacyLevel) { | ||
"SHOW" -> TouchPrivacy.SHOW | ||
"HIDE" -> TouchPrivacy.HIDE | ||
else -> { | ||
Log.w( | ||
SessionReplayPrivacySettings::class.java.canonicalName, | ||
"Unknown Session Replay Touch Privacy Level given: $touchPrivacyLevel, " + | ||
"using ${TouchPrivacy.HIDE} as default" | ||
) | ||
TouchPrivacy.HIDE | ||
} | ||
} | ||
} | ||
|
||
internal fun getTextAndInputPrivacy(textAndInputPrivacyLevel: String): TextAndInputPrivacy { | ||
return when (textAndInputPrivacyLevel) { | ||
"MASK_SENSITIVE_INPUTS" -> TextAndInputPrivacy.MASK_SENSITIVE_INPUTS | ||
"MASK_ALL_INPUTS" -> TextAndInputPrivacy.MASK_ALL_INPUTS | ||
"MASK_ALL" -> TextAndInputPrivacy.MASK_ALL | ||
else -> { | ||
Log.w( | ||
SessionReplayPrivacySettings::class.java.canonicalName, | ||
"Unknown Session Replay Text And Input Privacy Level given: $textAndInputPrivacyLevel, " + | ||
"using ${TextAndInputPrivacy.MASK_ALL} as default" | ||
) | ||
TextAndInputPrivacy.MASK_ALL | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.