Skip to content

Commit 50723a3

Browse files
doc: Add using ldMask in readme. (#311)
## Summary Documentation on using ldMask() ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds README guidance for Android session replay masking using `ldMask`/`ldUnmask` for XML Views and Jetpack Compose, with brief examples and notes. > > - **Documentation** (`sdk/@launchdarkly/observability-android/README.md`): > - **Session Replay**: Adds guidance on masking sensitive UI content. > - XML Views: Use `ldMask()` (and optional `ldUnmask()`) on `View`s; includes activity/fragment examples. > - Jetpack Compose: Add `Modifier.ldMask()` (and optional `Modifier.ldUnmask()`); includes `TextField` example. > - Notes on masking behavior and applicability to sensitive elements. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 587aba4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent a83f828 commit 50723a3

File tree

1 file changed

+75
-0
lines changed
  • sdk/@launchdarkly/observability-android

1 file changed

+75
-0
lines changed

sdk/@launchdarkly/observability-android/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,82 @@ span.makeCurrent().use {
167167
span.end()
168168
```
169169

170+
### Session Replay
170171

172+
#### Masking sensitive UI
173+
174+
Use `ldMask()` to mark views that should be masked in session replay. There are helpers for both XML-based Views and Jetpack Compose.
175+
176+
##### XML Views
177+
178+
Import the masking API and call `ldMask()` on any `View` (for example, after inflating the layout in an `Activity` or `Fragment`).
179+
180+
```kotlin
181+
import android.os.Bundle
182+
import android.widget.EditText
183+
import androidx.appcompat.app.AppCompatActivity
184+
import com.launchdarkly.observability.api.ldMask
185+
186+
class LoginActivity : AppCompatActivity() {
187+
override fun onCreate(savedInstanceState: Bundle?) {
188+
super.onCreate(savedInstanceState)
189+
setContentView(R.layout.activity_login)
190+
191+
val password = findViewById<EditText>(R.id.password)
192+
password.ldMask() // mask this field in session replay
193+
}
194+
}
195+
```
196+
197+
With View Binding or Data Binding:
198+
199+
```kotlin
200+
import android.os.Bundle
201+
import android.view.View
202+
import androidx.fragment.app.Fragment
203+
import com.launchdarkly.observability.api.ldMask
204+
205+
class CheckoutFragment : Fragment(R.layout.fragment_checkout) {
206+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
207+
super.onViewCreated(view, savedInstanceState)
208+
val binding = FragmentCheckoutBinding.bind(view)
209+
binding.creditCardNumber.ldMask()
210+
binding.cvv.ldMask()
211+
}
212+
}
213+
```
214+
215+
Optional: use `ldUnmask()` to explicitly clear masking on a view you previously masked.
216+
217+
##### Jetpack Compose
218+
219+
Add the masking `Modifier` to any composable you want masked in session replay.
220+
221+
```kotlin
222+
import androidx.compose.foundation.layout.fillMaxWidth
223+
import androidx.compose.material3.TextField
224+
import androidx.compose.runtime.*
225+
import androidx.compose.ui.Modifier
226+
import com.launchdarkly.observability.api.ldMask
227+
228+
@Composable
229+
fun CreditCardField() {
230+
var number by remember { mutableStateOf("") }
231+
TextField(
232+
value = number,
233+
onValueChange = { number = it },
234+
modifier = Modifier
235+
.fillMaxWidth()
236+
.ldMask() // mask this composable in session replay
237+
)
238+
}
239+
```
240+
241+
Optional: use `Modifier.ldUnmask()` to explicitly clear masking on a composable you previously masked.
242+
243+
Notes:
244+
- Masking marks elements so their contents are obscured in recorded sessions.
245+
- You can apply masking to any `View` or composable where sensitive data may appear.
171246

172247
## Contributing
173248

0 commit comments

Comments
 (0)