Skip to content

Commit 6f22635

Browse files
chore: readme update with real examples (#314)
## Summary Update readme with examples from the test app. ## How did you test this change? <!-- Frontend - Leave a screencast or a screenshot to visually describe the changes. --> ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Refreshes README session replay masking examples (XML, View Binding/Data Binding, Compose) with realistic code and switches LoginActivity to ComponentActivity. > > - **Docs (sdk/@launchdarkly/observability-android/README.md)**: > - **Session Replay / Masking examples**: > - XML Views: update `LoginActivity` sample to use `ComponentActivity`; simplify imports. > - View Binding/Data Binding: replace `Fragment` example with `onCreateView` using `SettingsPageBinding` and mask `toolbar` via `ldMask()`. > - Jetpack Compose: replace generic `TextField` with `OutlinedTextField` ZIP code example, add `KeyboardOptions`, and apply `Modifier.ldMask()`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit afe4bff. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 50723a3 commit 6f22635

File tree

1 file changed

+20
-23
lines changed
  • sdk/@launchdarkly/observability-android

1 file changed

+20
-23
lines changed

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,9 @@ Use `ldMask()` to mark views that should be masked in session replay. There are
178178
Import the masking API and call `ldMask()` on any `View` (for example, after inflating the layout in an `Activity` or `Fragment`).
179179

180180
```kotlin
181-
import android.os.Bundle
182-
import android.widget.EditText
183-
import androidx.appcompat.app.AppCompatActivity
184181
import com.launchdarkly.observability.api.ldMask
185182

186-
class LoginActivity : AppCompatActivity() {
183+
class LoginActivity : ComponentActivity() {
187184
override fun onCreate(savedInstanceState: Bundle?) {
188185
super.onCreate(savedInstanceState)
189186
setContentView(R.layout.activity_login)
@@ -197,18 +194,18 @@ class LoginActivity : AppCompatActivity() {
197194
With View Binding or Data Binding:
198195

199196
```kotlin
200-
import android.os.Bundle
201-
import android.view.View
202-
import androidx.fragment.app.Fragment
203197
import com.launchdarkly.observability.api.ldMask
204198

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-
}
199+
override fun onCreateView(
200+
inflater: LayoutInflater,
201+
container: ViewGroup?,
202+
savedInstanceState: Bundle?,
203+
): View {
204+
_binding = SettingsPageBinding.inflate(inflater, container, false)
205+
binding.nestedScrollView.systemBarsPadding()
206+
viewModel.toggleBackgroundAccess(requireContext().isIgnoreBatteryEnabled())
207+
val toolbar = binding.toolbar
208+
toolbar.ldMask()
212209
}
213210
```
214211

@@ -219,21 +216,21 @@ Optional: use `ldUnmask()` to explicitly clear masking on a view you previously
219216
Add the masking `Modifier` to any composable you want masked in session replay.
220217

221218
```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
226219
import com.launchdarkly.observability.api.ldMask
227220

228221
@Composable
229222
fun CreditCardField() {
230-
var number by remember { mutableStateOf("") }
231-
TextField(
232-
value = number,
233-
onValueChange = { number = it },
223+
...
224+
var zipCode by remember { mutableStateOf("") }
225+
226+
OutlinedTextField(
227+
value = zipCode,
228+
onValueChange = { zipCode = it },
229+
label = { Text("ZIP Code") },
230+
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
234231
modifier = Modifier
235232
.fillMaxWidth()
236-
.ldMask() // mask this composable in session replay
233+
.ldMask()
237234
)
238235
}
239236
```

0 commit comments

Comments
 (0)