Skip to content

Commit 6abf164

Browse files
committed
additional review comments
1 parent 803f35e commit 6abf164

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/CaptureSource.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import android.view.ViewGroup
1919
import androidx.compose.ui.platform.ComposeView
2020
import androidx.compose.ui.semantics.SemanticsNode
2121
import androidx.compose.ui.semantics.SemanticsOwner
22+
import com.launchdarkly.observability.coroutines.DispatcherProviderHolder
2223
import io.opentelemetry.android.session.SessionManager
2324
import kotlinx.coroutines.CoroutineScope
24-
import kotlinx.coroutines.Dispatchers
2525
import kotlinx.coroutines.flow.MutableSharedFlow
2626
import kotlinx.coroutines.flow.SharedFlow
2727
import kotlinx.coroutines.flow.asSharedFlow
@@ -109,7 +109,7 @@ class CaptureSource(
109109
/**
110110
* Internal capture routine.
111111
*/
112-
private suspend fun doCapture(): CaptureEvent? = withContext(Dispatchers.Main) {
112+
private suspend fun doCapture(): CaptureEvent? = withContext(DispatcherProviderHolder.current.main) {
113113
try {
114114
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
115115
val activity = _mostRecentActivity ?: return@withContext null // return if no activity
@@ -149,7 +149,7 @@ class CaptureSource(
149149
val session = sessionManager.getSessionId()
150150

151151
if (result == PixelCopy.SUCCESS) {
152-
CoroutineScope(Dispatchers.Default).launch {
152+
CoroutineScope(DispatcherProviderHolder.current.default).launch {
153153
try {
154154
val postMask = if (maskMatchers.isNotEmpty()) {
155155
maskSensitiveRects(bitmap, sensitiveComposeRects)

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/InteractionSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InteractionSource(
2424
// Using tryEmit() instead of emit() to avoid blocking the UI thread
2525
private val _captureEventFlow = MutableSharedFlow<InteractionEvent>(
2626
extraBufferCapacity = 64, // Buffer up to 64 events before dropping
27-
onBufferOverflow = BufferOverflow.DROP_LATEST
27+
onBufferOverflow = BufferOverflow.DROP_OLDEST
2828
)
2929

3030
// Interactions from the most recent window will be reported periodically on this flow.
@@ -63,7 +63,7 @@ class InteractionSource(
6363
val pointerIndex = motionEvent.findPointerIndex(_watchedPointerId)
6464
val eventTimeReference = System.currentTimeMillis() - SystemClock.uptimeMillis()
6565

66-
when (motionEvent.action) {
66+
when (motionEvent.actionMasked) {
6767
MotionEvent.ACTION_DOWN -> {
6868
val interaction = InteractionEvent(
6969
action = motionEvent.action,

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/ReplayInstrumentation.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.launchdarkly.observability.replay
22

3+
import com.launchdarkly.observability.coroutines.DispatcherProviderHolder
34
import com.launchdarkly.observability.interfaces.LDExtendedInstrumentation
45
import io.opentelemetry.android.instrumentation.InstallationContext
56
import io.opentelemetry.api.logs.Logger
67
import io.opentelemetry.sdk.logs.LogRecordProcessor
78
import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor
8-
import kotlinx.coroutines.Dispatchers
99
import kotlinx.coroutines.GlobalScope
1010
import kotlinx.coroutines.Job
1111
import kotlinx.coroutines.delay
@@ -82,7 +82,7 @@ class ReplayInstrumentation(
8282

8383
// TODO: O11Y-621 - don't use global scope
8484
// TODO: O11Y-621 - shutdown procedure and cleanup of dispatched jobs
85-
GlobalScope.launch(Dispatchers.Default) {
85+
GlobalScope.launch(DispatcherProviderHolder.current.default) {
8686
_captureSource.captureFlow.collect { capture ->
8787
_otelLogger.logRecordBuilder()
8888
.setAttribute("event.domain", "media")
@@ -95,7 +95,7 @@ class ReplayInstrumentation(
9595
}
9696
}
9797

98-
GlobalScope.launch(Dispatchers.Default) {
98+
GlobalScope.launch(DispatcherProviderHolder.current.default) {
9999
_interactionSource.captureFlow.collect{ interaction->
100100
// Serialize positions list to JSON using StringBuilder for performance
101101
val positionsJson = StringBuilder().apply {
@@ -163,7 +163,7 @@ class ReplayInstrumentation(
163163

164164
private fun internalStartCapture() {
165165
// TODO: O11Y-621 - don't use global scope
166-
_captureJob = GlobalScope.launch(Dispatchers.Default) {
166+
_captureJob = GlobalScope.launch(DispatcherProviderHolder.current.default) {
167167
try {
168168
while (true) {
169169
// Perform capture

0 commit comments

Comments
 (0)