Skip to content

Commit

Permalink
Merge pull request #2129 from DataDog/jmoskovich/rum-5524/modify-imag…
Browse files Browse the repository at this point in the history
…e-privacy

RUM-5524: Make ImagePrivacy clearer
  • Loading branch information
jonathanmos authored Jul 23, 2024
2 parents 99068f2 + 91ccfc3 commit b36d867
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion features/dd-sdk-android-session-replay/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface com.datadog.android.sessionreplay.ExtensionSupport
fun getOptionSelectorDetectors(): List<com.datadog.android.sessionreplay.recorder.OptionSelectorDetector>
enum com.datadog.android.sessionreplay.ImagePrivacy
- MASK_NONE
- MASK_CONTENT
- MASK_LARGE_ONLY
- MASK_ALL
data class com.datadog.android.sessionreplay.MapperTypeWrapper<T: android.view.View>
constructor(Class<T>, com.datadog.android.sessionreplay.recorder.mapper.WireframeMapper<T>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public abstract interface class com/datadog/android/sessionreplay/ExtensionSuppo

public final class com/datadog/android/sessionreplay/ImagePrivacy : java/lang/Enum {
public static final field MASK_ALL Lcom/datadog/android/sessionreplay/ImagePrivacy;
public static final field MASK_CONTENT Lcom/datadog/android/sessionreplay/ImagePrivacy;
public static final field MASK_LARGE_ONLY Lcom/datadog/android/sessionreplay/ImagePrivacy;
public static final field MASK_NONE Lcom/datadog/android/sessionreplay/ImagePrivacy;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/sessionreplay/ImagePrivacy;
public static fun values ()[Lcom/datadog/android/sessionreplay/ImagePrivacy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package com.datadog.android.sessionreplay
/**
* Defines the Session Replay privacy policy when recording images.
* @see ImagePrivacy.MASK_NONE
* @see ImagePrivacy.MASK_CONTENT
* @see ImagePrivacy.MASK_LARGE_ONLY
* @see ImagePrivacy.MASK_ALL
*/
enum class ImagePrivacy {
Expand All @@ -19,10 +19,10 @@ enum class ImagePrivacy {
MASK_NONE,

/**
* Mask images that we consider to be content images.
* In the replay images will be replaced with placeholders with the label: Content Image.
* Mask images that we consider to be content images based on them being larger than 100x100 dp.
* In the replay such images will be replaced with placeholders with the label: Content Image.
*/
MASK_CONTENT,
MASK_LARGE_ONLY,

/**
* No images will be recorded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data class SessionReplayConfiguration internal constructor(
class Builder(@FloatRange(from = 0.0, to = 100.0) private val sampleRate: Float) {
private var customEndpointUrl: String? = null
private var privacy = SessionReplayPrivacy.MASK
private var imagePrivacy = ImagePrivacy.MASK_CONTENT
private var imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY
private var extensionSupport: ExtensionSupport = NoOpExtensionSupport()

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ data class SessionReplayConfiguration internal constructor(
* Sets the image recording level for the Session Replay feature.
* If not specified then all images that are considered to be content images will be masked by default.
* @see ImagePrivacy.MASK_NONE
* @see ImagePrivacy.MASK_CONTENT
* @see ImagePrivacy.MASK_LARGE_ONLY
* @see ImagePrivacy.MASK_ALL
*/
fun setImagePrivacy(level: ImagePrivacy): Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ internal class DefaultImageWireframeHelper(
drawable: Drawable,
density: Float
): Boolean =
imagePrivacy == ImagePrivacy.MASK_CONTENT &&
imagePrivacy == ImagePrivacy.MASK_LARGE_ONLY &&
usePIIPlaceholder &&
imageTypeResolver.isDrawablePII(drawable, density)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class SessionReplayConfigurationBuilderTest {
// Then
assertThat(sessionReplayConfiguration.customEndpointUrl).isNull()
assertThat(sessionReplayConfiguration.privacy).isEqualTo(SessionReplayPrivacy.MASK)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_CONTENT)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_LARGE_ONLY)
assertThat(sessionReplayConfiguration.customMappers).isEmpty()
assertThat(sessionReplayConfiguration.customOptionSelectorDetectors).isEmpty()
assertThat(sessionReplayConfiguration.sampleRate).isEqualTo(fakeSampleRate)
Expand All @@ -78,7 +78,7 @@ internal class SessionReplayConfigurationBuilderTest {
assertThat(sessionReplayConfiguration.customEndpointUrl)
.isEqualTo(sessionReplayUrl)
assertThat(sessionReplayConfiguration.privacy).isEqualTo(SessionReplayPrivacy.MASK)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_CONTENT)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_LARGE_ONLY)
assertThat(sessionReplayConfiguration.customMappers).isEmpty()
assertThat(sessionReplayConfiguration.customOptionSelectorDetectors).isEmpty()
assertThat(sessionReplayConfiguration.sampleRate).isEqualTo(fakeSampleRate)
Expand All @@ -96,7 +96,7 @@ internal class SessionReplayConfigurationBuilderTest {
// Then
assertThat(sessionReplayConfiguration.customEndpointUrl).isNull()
assertThat(sessionReplayConfiguration.privacy).isEqualTo(fakePrivacy)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_CONTENT)
assertThat(sessionReplayConfiguration.imagePrivacy).isEqualTo(ImagePrivacy.MASK_LARGE_ONLY)
assertThat(sessionReplayConfiguration.customMappers).isEmpty()
assertThat(sessionReplayConfiguration.customOptionSelectorDetectors).isEmpty()
assertThat(sessionReplayConfiguration.sampleRate).isEqualTo(fakeSampleRate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
fun `M create ImageWireFrame W map() { checked, above M }`() {
// Given
val allowedMappingContext =
fakeMappingContext.copy(privacy = SessionReplayPrivacy.ALLOW, imagePrivacy = ImagePrivacy.MASK_CONTENT)
fakeMappingContext.copy(privacy = SessionReplayPrivacy.ALLOW, imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY)
whenever(mockButtonDrawable.intrinsicHeight).thenReturn(fakeIntrinsicDrawableHeight)
whenever(mockCheckableTextView.isChecked).thenReturn(true)

Expand All @@ -215,7 +215,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
// Then
verify(fakeMappingContext.imageWireframeHelper).createImageWireframe(
view = eq(mockCheckableTextView),
imagePrivacy = eq(ImagePrivacy.MASK_CONTENT),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
currentWireframeIndex = anyInt(),
x = eq(expectedX),
y = eq(expectedY),
Expand All @@ -237,7 +237,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
// Given
val allowedMappingContext = fakeMappingContext.copy(
privacy = SessionReplayPrivacy.ALLOW,
imagePrivacy = ImagePrivacy.MASK_CONTENT
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY
)
whenever(mockButtonDrawable.intrinsicHeight).thenReturn(fakeIntrinsicDrawableHeight)
whenever(mockCheckableTextView.isChecked).thenReturn(false)
Expand All @@ -258,7 +258,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
// Then
verify(fakeMappingContext.imageWireframeHelper).createImageWireframe(
view = eq(mockCheckableTextView),
imagePrivacy = eq(ImagePrivacy.MASK_CONTENT),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
currentWireframeIndex = anyInt(),
x = eq(expectedX),
y = eq(expectedY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class SwitchCompatMapperTest : BaseSwitchCompatMapperTest() {
// When
val resolvedWireframes = testedSwitchCompatMapper.map(
mockSwitch,
fakeMappingContext.copy(imagePrivacy = ImagePrivacy.MASK_CONTENT),
fakeMappingContext.copy(imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY),
mockAsyncJobStatusCallback,
mockInternalLogger
)
Expand All @@ -89,7 +89,7 @@ internal class SwitchCompatMapperTest : BaseSwitchCompatMapperTest() {

verify(fakeMappingContext.imageWireframeHelper, times(2)).createImageWireframe(
view = eq(mockSwitch),
imagePrivacy = eq(ImagePrivacy.MASK_CONTENT),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
currentWireframeIndex = ArgumentMatchers.anyInt(),
x = xCaptor.capture(),
y = yCaptor.capture(),
Expand Down Expand Up @@ -147,7 +147,7 @@ internal class SwitchCompatMapperTest : BaseSwitchCompatMapperTest() {
// When
val resolvedWireframes = testedSwitchCompatMapper.map(
mockSwitch,
fakeMappingContext.copy(privacy = SessionReplayPrivacy.MASK, imagePrivacy = ImagePrivacy.MASK_CONTENT),
fakeMappingContext.copy(privacy = SessionReplayPrivacy.MASK, imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY),
mockAsyncJobStatusCallback,
mockInternalLogger
)
Expand All @@ -172,7 +172,7 @@ internal class SwitchCompatMapperTest : BaseSwitchCompatMapperTest() {
// When
val resolvedWireframes = testedSwitchCompatMapper.map(
mockSwitch,
fakeMappingContext.copy(privacy = SessionReplayPrivacy.MASK, imagePrivacy = ImagePrivacy.MASK_CONTENT),
fakeMappingContext.copy(privacy = SessionReplayPrivacy.MASK, imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY),
mockAsyncJobStatusCallback,
mockInternalLogger
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal class DefaultImageWireframeHelperTest {
val randomXLocation = forge.aLong(min = 1, max = (fakeScreenWidth - fakeDrawableWidth).toLong())
val randomYLocation = forge.aLong(min = 1, max = (fakeScreenHeight - fakeDrawableHeight).toLong())
fakeDrawableXY = Pair(randomXLocation, randomYLocation)
whenever(mockMappingContext.imagePrivacy).thenReturn(ImagePrivacy.MASK_CONTENT)
whenever(mockMappingContext.imagePrivacy).thenReturn(ImagePrivacy.MASK_LARGE_ONLY)
whenever(mockMappingContext.systemInformation).thenReturn(mockSystemInformation)
whenever(mockSystemInformation.screenDensity).thenReturn(0f)
whenever(mockViewIdentifierResolver.resolveChildUniqueIdentifier(mockView, "drawable"))
Expand Down Expand Up @@ -229,7 +229,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val wireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand All @@ -254,7 +254,7 @@ internal class DefaultImageWireframeHelperTest {
// When
testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -283,7 +283,7 @@ internal class DefaultImageWireframeHelperTest {
// When
testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -313,7 +313,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val wireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand All @@ -336,7 +336,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val wireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand All @@ -358,7 +358,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val wireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -415,7 +415,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val wireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = fakeDrawableXY.first,
y = fakeDrawableXY.second,
Expand Down Expand Up @@ -593,7 +593,7 @@ internal class DefaultImageWireframeHelperTest {
// When
testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -625,7 +625,7 @@ internal class DefaultImageWireframeHelperTest {
// When
testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -676,7 +676,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val result = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = forge.aPositiveInt(),
x = fakeGlobalX,
y = fakeGlobalY,
Expand All @@ -703,7 +703,7 @@ internal class DefaultImageWireframeHelperTest {
// When
testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down Expand Up @@ -736,7 +736,7 @@ internal class DefaultImageWireframeHelperTest {
// When
val actualWireframe = testedHelper.createImageWireframe(
view = mockView,
imagePrivacy = ImagePrivacy.MASK_CONTENT,
imagePrivacy = ImagePrivacy.MASK_LARGE_ONLY,
currentWireframeIndex = 0,
x = 0,
y = 0,
Expand Down

0 comments on commit b36d867

Please sign in to comment.