From 5698c9fae066d53fd36c10516a8cef7ceb67eaaf Mon Sep 17 00:00:00 2001 From: bidetofevil Date: Tue, 31 Dec 2024 14:25:36 -0800 Subject: [PATCH] Remove the reset event --- .../capture/activity/UiLoadEventListener.kt | 6 ------ .../internal/capture/activity/UiLoadExt.kt | 14 -------------- .../capture/activity/UiLoadTraceEmitter.kt | 6 +----- .../internal/capture/activity/UiLoadExtTest.kt | 18 ------------------ .../capture/activity/UiLoadTraceEmitterTest.kt | 6 ------ .../fakes/FakeUiLoadEventListener.kt | 9 --------- 6 files changed, 1 insertion(+), 58 deletions(-) diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadEventListener.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadEventListener.kt index 2be1fccf06..d1564da1c4 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadEventListener.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadEventListener.kt @@ -77,10 +77,4 @@ interface UiLoadEventListener { * or after it has loaded. Calls to this for a given instance should be idempotent. */ fun exit(instanceId: Int, activityName: String, timestampMs: Long) - - /** - * When the app is no longer in a state where it is trying to open up UI. All traces should be abandoned and - * Any events received after this should assume the app is emerging or have emerged from a background state. - */ - fun reset(lastInstanceId: Int) } diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt index c30185da24..4c205a22f8 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt @@ -81,10 +81,6 @@ private class ActivityLoadEventEmitter( override fun onActivityPrePaused(activity: Activity) { lifecycleEventEmitter.pause(activity) } - - override fun onActivityStopped(activity: Activity) { - lifecycleEventEmitter.stop(activity) - } } /** @@ -117,10 +113,6 @@ private class LegacyActivityLoadEventEmitter( override fun onActivityPaused(activity: Activity) { lifecycleEventEmitter.pause(activity) } - - override fun onActivityStopped(activity: Activity) { - lifecycleEventEmitter.stop(activity) - } } /** @@ -186,12 +178,6 @@ private class LifecycleEventEmitter( ) } - fun stop(activity: Activity) { - uiLoadEventListener.reset( - lastInstanceId = traceInstanceId(activity), - ) - } - private fun traceInstanceId(activity: Activity): Int = activity.hashCode() private fun nowMs(): Long = clock.now().nanosToMillis() diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitter.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitter.kt index 25101c7b75..10566894e2 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitter.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitter.kt @@ -162,9 +162,6 @@ class UiLoadTraceEmitter( ) } - override fun reset(lastInstanceId: Int) { - } - private fun startTrace( uiLoadType: UiLoadType, instanceId: Int, @@ -174,8 +171,7 @@ class UiLoadTraceEmitter( ) { if (!activeTraces.containsKey(instanceId)) { val newInstance = UiInstance(activityName, instanceId) - val previousInstance = currentInstance.getAndSet(newInstance) - if (previousInstance != null) { + currentInstance.getAndSet(newInstance)?.let { previousInstance -> exit(previousInstance.id, previousInstance.name, timestampMs) } diff --git a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt index bcdf848252..61d9cbdda3 100644 --- a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt +++ b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt @@ -85,9 +85,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + (POST_DURATION + STATE_DURATION + PRE_DURATION) * 3 + PRE_DURATION ), - createEvent( - stage = "reset", - ), ) ) } @@ -118,9 +115,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + (POST_DURATION + STATE_DURATION + PRE_DURATION) * 2 + PRE_DURATION ), - createEvent( - stage = "reset", - ), ) ) } @@ -136,9 +130,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + (POST_DURATION + STATE_DURATION + PRE_DURATION) * 3 + PRE_DURATION ), - createEvent( - stage = "reset", - ), ) ) } @@ -173,9 +164,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + STATE_DURATION * 4 ), - createEvent( - stage = "reset", - ), ) ) } @@ -206,9 +194,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + STATE_DURATION * 3 ), - createEvent( - stage = "reset", - ), ) ) } @@ -224,9 +209,6 @@ internal class UiLoadExtTest { stage = "abandon", timestampMs = startTimeMs + STATE_DURATION * 4 ), - createEvent( - stage = "reset", - ), ) ) } diff --git a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt index dfb63793cb..c56cb60521 100644 --- a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt +++ b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt @@ -337,12 +337,6 @@ internal class UiLoadTraceEmitterTest { instanceId = lastInstanceId, firePreAndPost = firePreAndPost, ) - traceEmitter.exit( - instanceId = lastInstanceId, - activityName = lastActivityName, - timestampMs = lastActivityExitMs - ) - traceEmitter.reset(lastInstanceId) } PreviousState.FROM_INTERRUPTED_LOAD -> { diff --git a/embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeUiLoadEventListener.kt b/embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeUiLoadEventListener.kt index be58e21add..56f3b8165d 100644 --- a/embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeUiLoadEventListener.kt +++ b/embrace-test-fakes/src/main/kotlin/io/embrace/android/embracesdk/fakes/FakeUiLoadEventListener.kt @@ -16,15 +16,6 @@ class FakeUiLoadEventListener : UiLoadEventListener { ) } - override fun reset(lastInstanceId: Int) { - events.add( - EventData( - stage = "reset", - instanceId = lastInstanceId, - ) - ) - } - override fun create(instanceId: Int, activityName: String, timestampMs: Long, manualEnd: Boolean) { events.add( EventData(