diff --git a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt index 43a3e4a64..23808de28 100644 --- a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt +++ b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt @@ -9,7 +9,6 @@ package io.bitdrift.capture import android.content.Context import android.util.Log -import io.bitdrift.capture.common.IBackgroundThreadHandler import io.bitdrift.capture.common.MainThreadHandler import io.bitdrift.capture.events.span.Span import io.bitdrift.capture.events.span.SpanResult @@ -22,7 +21,6 @@ import io.bitdrift.capture.providers.SystemDateProvider import io.bitdrift.capture.providers.session.SessionStrategy import io.bitdrift.capture.reports.FatalIssueMechanism import io.bitdrift.capture.reports.FatalIssueReporter -import io.bitdrift.capture.threading.CaptureDispatchers import okhttp3.HttpUrl import java.util.UUID import java.util.concurrent.atomic.AtomicReference @@ -36,17 +34,14 @@ internal sealed class LoggerState { /** * The logger is in the process of being started. Subsequent attempts to start the logger will be ignored. - * Any calls to Logger.log() meanwhile Logger.start() is in process will be cached in memory */ - class Starting( - val preInitInMemoryLogger: PreInitInMemoryLogger, - ) : LoggerState() + data object Starting : LoggerState() /** * The logger has been successfully started and is ready for use. Subsequent attempts to start the logger will be ignored. */ class Started( - val loggerImpl: LoggerImpl, + val logger: LoggerImpl, ) : LoggerState() /** @@ -62,7 +57,6 @@ object Capture { internal const val LOG_TAG = "BitdriftCapture" private val default: AtomicReference = AtomicReference(LoggerState.NotStarted) private val fatalIssueReporter = FatalIssueReporter() - private val preInitInMemoryLogger by lazy { PreInitInMemoryLogger() } /** * Returns a handle to the underlying logger instance, if Capture has been started. @@ -72,8 +66,8 @@ object Capture { fun logger(): ILogger? = when (val state = default.get()) { is LoggerState.NotStarted -> null - is LoggerState.Starting -> state.preInitInMemoryLogger - is LoggerState.Started -> state.loggerImpl + is LoggerState.Starting -> null + is LoggerState.Started -> state.logger is LoggerState.StartFailure -> null } @@ -163,7 +157,6 @@ object Capture { fieldProviders: List = listOf(), dateProvider: DateProvider? = null, apiUrl: HttpUrl = defaultCaptureApiUrl, - context: Context? = null, ) { start( apiKey, @@ -173,7 +166,6 @@ object Capture { dateProvider, apiUrl, CaptureJniLibrary, - context, ) } @@ -188,14 +180,12 @@ object Capture { dateProvider: DateProvider? = null, apiUrl: HttpUrl = defaultCaptureApiUrl, bridge: IBridge, - context: Context? = null, - backgroundThreadHandler: IBackgroundThreadHandler = CaptureDispatchers.CommonBackground, ) { // Note that we need to use @Synchronized to prevent multiple loggers from being initialized, // while subsequent logger access relies on volatile reads. // There's nothing we can do if we don't have yet access to the application context. - if (context == null && !ContextHolder.isInitialized) { + if (!ContextHolder.isInitialized) { Log.w( LOG_TAG, "Attempted to initialize Capture with a null context", @@ -204,32 +194,26 @@ object Capture { } // Ideally we would use `getAndUpdate` in here but it's available for API 24 and up only. - if (default.compareAndSet(LoggerState.NotStarted, LoggerState.Starting(preInitInMemoryLogger))) { - backgroundThreadHandler.runAsync { - try { - val unwrappedContext = context?.applicationContext ?: ContextHolder.APP_CONTEXT - if (configuration.enableFatalIssueReporting) { - fatalIssueReporter.initBuiltInMode(unwrappedContext) - } - val loggerImpl = - LoggerImpl( - apiKey = apiKey, - apiUrl = apiUrl, - context = unwrappedContext, - fieldProviders = fieldProviders, - dateProvider = dateProvider ?: SystemDateProvider(), - configuration = configuration, - sessionStrategy = sessionStrategy, - bridge = bridge, - fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitInMemoryLogger, - ) - default.set(LoggerState.Started(loggerImpl)) - } catch (e: Throwable) { - Log.w(LOG_TAG, "Failed to start Capture", e) - preInitInMemoryLogger.clear() - default.set(LoggerState.StartFailure) + if (default.compareAndSet(LoggerState.NotStarted, LoggerState.Starting)) { + try { + if (configuration.enableFatalIssueReporting) { + fatalIssueReporter.initBuiltInMode(ContextHolder.APP_CONTEXT) } + val loggerImpl = + LoggerImpl( + apiKey = apiKey, + apiUrl = apiUrl, + fieldProviders = fieldProviders, + dateProvider = dateProvider ?: SystemDateProvider(), + configuration = configuration, + sessionStrategy = sessionStrategy, + bridge = bridge, + fatalIssueReporter = fatalIssueReporter, + ) + default.set(LoggerState.Started(loggerImpl)) + } catch (e: Throwable) { + Log.w(LOG_TAG, "Failed to start Capture", e) + default.set(LoggerState.StartFailure) } } else { Log.w(LOG_TAG, "Multiple attempts to start Capture") diff --git a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/IPreInitLogFlusher.kt b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/IPreInitLogFlusher.kt deleted file mode 100644 index ed9cc8e1d..000000000 --- a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/IPreInitLogFlusher.kt +++ /dev/null @@ -1,15 +0,0 @@ -// capture-sdk - bitdrift's client SDK -// Copyright Bitdrift, Inc. All rights reserved. -// -// Use of this source code is governed by a source available license that can be found in the -// LICENSE file or at: -// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt -package io.bitdrift.capture - -/** - * Flushes the internal memory logging into the loggerImpl - */ -fun interface IPreInitLogFlusher { - /** Flush all in memory Logger calls into the Native `LoggerImpl` **/ - fun flushToNative(loggerImpl: ILogger) -} diff --git a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/LoggerImpl.kt b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/LoggerImpl.kt index d9742b983..a5eb05ec6 100644 --- a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/LoggerImpl.kt +++ b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/LoggerImpl.kt @@ -70,7 +70,7 @@ internal class LoggerImpl( dateProvider: DateProvider, private val errorHandler: ErrorHandler = ErrorHandler(), sessionStrategy: SessionStrategy, - context: Context, + context: Context = ContextHolder.APP_CONTEXT, clientAttributes: ClientAttributes = ClientAttributes( context, @@ -84,7 +84,6 @@ internal class LoggerImpl( private val eventListenerDispatcher: CaptureDispatchers.CommonBackground = CaptureDispatchers.CommonBackground, windowManager: IWindowManager = WindowManager(errorHandler), private val fatalIssueReporter: IFatalIssueReporter, - private val preInitLogFlusher: IPreInitLogFlusher, ) : ILogger { private val metadataProvider: MetadataProvider private val batteryMonitor = BatteryMonitor(context) @@ -262,8 +261,6 @@ internal class LoggerImpl( appExitLogger.installAppExitLogger() CaptureJniLibrary.startLogger(this.loggerId) - - preInitLogFlusher.flushToNative(this) } writeSdkStartLog(context, clientAttributes, initDuration = duration) diff --git a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/PreInitInMemoryLogger.kt b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/PreInitInMemoryLogger.kt deleted file mode 100644 index a0e14b31f..000000000 --- a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/PreInitInMemoryLogger.kt +++ /dev/null @@ -1,124 +0,0 @@ -// capture-sdk - bitdrift's client SDK -// Copyright Bitdrift, Inc. All rights reserved. -// -// Use of this source code is governed by a source available license that can be found in the -// LICENSE file or at: -// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt -package io.bitdrift.capture - -import androidx.annotation.OpenForTesting -import io.bitdrift.capture.events.span.Span -import io.bitdrift.capture.network.HttpRequestInfo -import io.bitdrift.capture.network.HttpResponseInfo -import java.util.UUID -import java.util.concurrent.ConcurrentLinkedQueue -import kotlin.time.Duration - -/** - * - * Given that Logger.start() runs on dedicated thread, will be caching any calls to Logger.log while - * start is in process of being initialized. - * - * When Logger.start() is completed will flush the in memory calls to the native layer - */ -internal class PreInitInMemoryLogger : - ILogger, - IPreInitLogFlusher { - private val _bufferedLoggerCalls = ConcurrentLinkedQueue<(ILogger) -> Unit>() - - @get:OpenForTesting - val bufferedLoggerCalls: List<(ILogger) -> Unit> - get() = _bufferedLoggerCalls.toList() - - override val sessionId: String = DEFAULT_NOT_SETUP_MESSAGE - - override val sessionUrl: String = DEFAULT_NOT_SETUP_MESSAGE - - override val deviceId: String = DEFAULT_NOT_SETUP_MESSAGE - - /** Flush all in memory Logger calls into the Native `LoggerImpl` **/ - override fun flushToNative(loggerImpl: ILogger) { - _bufferedLoggerCalls.forEach { it(loggerImpl) } - _bufferedLoggerCalls.clear() - } - - override fun startNewSession() { - addLoggerCall { it.startNewSession() } - } - - override fun createTemporaryDeviceCode(completion: (CaptureResult) -> Unit) { - addLoggerCall { it.createTemporaryDeviceCode(completion) } - } - - override fun addField( - key: String, - value: String, - ) { - addLoggerCall { it.addField(key, value) } - } - - override fun removeField(key: String) { - addLoggerCall { it.removeField(key) } - } - - override fun log( - level: LogLevel, - fields: Map?, - throwable: Throwable?, - message: () -> String, - ) { - addLoggerCall { it.log(level, fields, throwable, message) } - } - - override fun logAppLaunchTTI(duration: Duration) { - addLoggerCall { it.logAppLaunchTTI(duration) } - } - - override fun logScreenView(screenName: String) { - addLoggerCall { it.logScreenView(screenName) } - } - - override fun startSpan( - name: String, - level: LogLevel, - fields: Map?, - startTimeMs: Long?, - parentSpanId: UUID?, - ): Span { - val span = Span(null, name, level, fields, startTimeMs, parentSpanId) - addLoggerCall { - span.setLoggerImpl(it as LoggerImpl) - it.startSpan(name, level, fields, startTimeMs, parentSpanId) - } - return span - } - - override fun setSleepMode(sleepMode: SleepMode) { - addLoggerCall { it.setSleepMode(sleepMode) } - } - - override fun log(httpRequestInfo: HttpRequestInfo) { - addLoggerCall { it.log(httpRequestInfo) } - } - - override fun log(httpResponseInfo: HttpResponseInfo) { - addLoggerCall { it.log(httpResponseInfo) } - } - - /** Clear stored Logger calls **/ - fun clear() { - _bufferedLoggerCalls.clear() - } - - private fun addLoggerCall(logCall: (ILogger) -> Unit) { - if (_bufferedLoggerCalls.size >= MAX_LOG_CALL_SIZE) { - _bufferedLoggerCalls.poll() - } - _bufferedLoggerCalls.add(logCall) - } - - private companion object { - private const val DEFAULT_NOT_SETUP_MESSAGE = "SDK starting" - private const val MAX_LOG_CALL_SIZE = 512 // Matching the pre-config buffer definition - } -} diff --git a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/events/span/Span.kt b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/events/span/Span.kt index cea30ac21..f6f9d4b7e 100644 --- a/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/events/span/Span.kt +++ b/platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/events/span/Span.kt @@ -130,11 +130,4 @@ class Span internal constructor( } logger = null } - - /** - * This is only needed during [io.bitdrift.capture.PreInitInMemoryLogger] - */ - internal fun setLoggerImpl(loggerImpl: LoggerImpl) { - this.logger = loggerImpl - } } diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerSessionOverrideTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerSessionOverrideTest.kt index 85db63449..442e0515b 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerSessionOverrideTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerSessionOverrideTest.kt @@ -17,7 +17,6 @@ import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.anyOrNull import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.whenever -import io.bitdrift.capture.fakes.FakePreInitLogFlusher import io.bitdrift.capture.providers.DateProvider import io.bitdrift.capture.providers.session.SessionStrategy import io.bitdrift.capture.reports.FatalIssueReporter @@ -52,7 +51,6 @@ class CaptureLoggerSessionOverrideTest { private lateinit var logger: LoggerImpl private var testServerPort: Int? = null private val fatalIssueReporter = FatalIssueReporter() - private val preInitLogFlusher = FakePreInitLogFlusher() @Before fun setUp() { @@ -91,7 +89,6 @@ class CaptureLoggerSessionOverrideTest { context = ContextHolder.APP_CONTEXT, preferences = preferences, fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) CaptureTestJniLibrary.stopTestApiServer() @@ -126,7 +123,6 @@ class CaptureLoggerSessionOverrideTest { preferences = preferences, activityManager = activityManager, fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) val newStreamId = CaptureTestJniLibrary.awaitNextApiStream() assertThat(newStreamId).isNotEqualTo(-1) diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerTest.kt index 2c581e807..ca436b20a 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerTest.kt @@ -21,7 +21,6 @@ import io.bitdrift.capture.attributes.DeviceAttributes import io.bitdrift.capture.attributes.NetworkAttributes import io.bitdrift.capture.common.RuntimeFeature import io.bitdrift.capture.fakes.FakeFatalIssueReporter -import io.bitdrift.capture.fakes.FakePreInitLogFlusher import io.bitdrift.capture.network.HttpRequestInfo import io.bitdrift.capture.network.HttpResponse import io.bitdrift.capture.network.HttpResponseInfo @@ -64,7 +63,6 @@ class CaptureLoggerTest { private lateinit var logger: LoggerImpl private var testServerPort: Int? = null private val fatalIssueReporter: IFatalIssueReporter = FakeFatalIssueReporter() - private val preInitLogFlusher = FakePreInitLogFlusher() @Before fun setUp() { @@ -76,7 +74,6 @@ class CaptureLoggerTest { testServerPort = CaptureTestJniLibrary.startTestApiServer(-1) - preInitLogFlusher.reset() logger = buildLogger(dateProvider = systemDateProvider) } @@ -444,7 +441,6 @@ class CaptureLoggerTest { ) assertThat(JniRuntime(logger.loggerId).isEnabled(RuntimeFeature.SESSION_REPLAY_COMPOSE)).isFalse - assertThat(preInitLogFlusher.wasFlushed).isTrue() } private fun testServerUrl(): HttpUrl = @@ -474,7 +470,6 @@ class CaptureLoggerTest { dateProvider = dateProvider, configuration = Configuration(), fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) } diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ConfigurationTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ConfigurationTest.kt index cccfc9ac7..0b7e2b1ca 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ConfigurationTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ConfigurationTest.kt @@ -4,7 +4,6 @@ // Use of this source code is governed by a source available license that can be found in the // LICENSE file or at: // https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt - package io.bitdrift.capture import androidx.test.core.app.ApplicationProvider @@ -13,7 +12,6 @@ import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever -import io.bitdrift.capture.fakes.FakeBackgroundThreadHandler import io.bitdrift.capture.providers.session.SessionStrategy import org.assertj.core.api.Assertions import org.junit.After @@ -25,8 +23,6 @@ import org.robolectric.annotation.Config @RunWith(RobolectricTestRunner::class) @Config(sdk = [21]) class ConfigurationTest { - private val fakeBackgroundThreadHandler = FakeBackgroundThreadHandler() - @Test fun configurationFailure() { val initializer = ContextHolder() @@ -60,7 +56,6 @@ class ConfigurationTest { sessionStrategy = SessionStrategy.Fixed(), dateProvider = null, bridge = bridge, - backgroundThreadHandler = fakeBackgroundThreadHandler, ) // The configuration failed so the logger is still `null`. @@ -91,7 +86,6 @@ class ConfigurationTest { sessionStrategy = SessionStrategy.Fixed(), dateProvider = null, bridge = bridge, - backgroundThreadHandler = fakeBackgroundThreadHandler, ) Assertions.assertThat(Capture.logger()).isNull() diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ErrorReporterTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ErrorReporterTest.kt index a10a1d2df..06ae0269c 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ErrorReporterTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ErrorReporterTest.kt @@ -13,7 +13,6 @@ import com.google.gson.reflect.TypeToken import io.bitdrift.capture.error.ErrorReportRequest import io.bitdrift.capture.error.ErrorReporterService import io.bitdrift.capture.fakes.FakeFatalIssueReporter -import io.bitdrift.capture.fakes.FakePreInitLogFlusher import io.bitdrift.capture.network.okhttp.OkHttpApiClient import io.bitdrift.capture.providers.FieldProvider import io.bitdrift.capture.providers.SystemDateProvider @@ -37,7 +36,6 @@ class ErrorReporterTest { private lateinit var server: MockWebServer private lateinit var reporter: ErrorReporterService private val fatalIssueReporter: IFatalIssueReporter = FakeFatalIssueReporter() - private val preInitLogFlusher = FakePreInitLogFlusher() init { CaptureJniLibrary.load() @@ -113,7 +111,6 @@ class ErrorReporterTest { configuration = Configuration(), errorReporter = reporter, fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) val errorHandler = ErrorHandler() diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/PreInitInMemoryLoggerTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/PreInitInMemoryLoggerTest.kt deleted file mode 100644 index 375efff63..000000000 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/PreInitInMemoryLoggerTest.kt +++ /dev/null @@ -1,110 +0,0 @@ -// capture-sdk - bitdrift's client SDK -// Copyright Bitdrift, Inc. All rights reserved. -// -// Use of this source code is governed by a source available license that can be found in the -// LICENSE file or at: -// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt - -package io.bitdrift.capture - -import io.bitdrift.capture.events.span.Span -import io.bitdrift.capture.network.HttpRequestInfo -import io.bitdrift.capture.network.HttpResponseInfo -import org.assertj.core.api.Assertions.assertThat -import org.junit.Before -import org.junit.Test -import java.util.UUID -import kotlin.time.Duration - -class PreInitInMemoryLoggerTest { - private val preInitInMemoryLogger = PreInitInMemoryLogger() - private val testLogger = TestLogger() - - @Before - fun setup() { - preInitInMemoryLogger.clear() - testLogger.clear() - } - - @Test - fun log_withoutOverwriteOldest_shouldMatchExpectedCalls() { - val totalCalls = 100 - - triggerScreenViewCalls(totalCalls = totalCalls) - - assertThat(testLogger.screenNameViewed.size).isEqualTo(totalCalls) - assertThat(testLogger.screenNameViewed).last().isEqualTo("Screen Viewed 100") - } - - @Test - fun log_withMaxSizeReached_shouldRemoveFirstEntryAndKeepLast() { - val totalCalls = 2048 - - triggerScreenViewCalls(totalCalls = totalCalls) - - assertThat(testLogger.screenNameViewed.size).isEqualTo(512) - assertThat(testLogger.screenNameViewed).first().isEqualTo("Screen Viewed 1537") - assertThat(testLogger.screenNameViewed).last().isEqualTo("Screen Viewed 2048") - } - - private fun triggerScreenViewCalls(totalCalls: Int) { - for (i in 1..totalCalls) { - preInitInMemoryLogger.logScreenView("Screen Viewed $i") - } - - preInitInMemoryLogger.bufferedLoggerCalls.forEach { it(testLogger) } - } - - @Suppress("EmptyFunctionBlock") - private class TestLogger : ILogger { - val screenNameViewed = mutableListOf() - - override val sessionId: String = "test-session" - - override val sessionUrl: String = "test-url" - - override val deviceId: String = "test-device" - - override fun startNewSession() {} - - override fun createTemporaryDeviceCode(completion: (CaptureResult) -> Unit) {} - - override fun addField( - key: String, - value: String, - ) {} - - override fun removeField(key: String) {} - - override fun logScreenView(screenName: String) { - screenNameViewed.add(screenName) - } - - override fun log( - level: LogLevel, - fields: Map?, - throwable: Throwable?, - message: () -> String, - ) {} - - override fun logAppLaunchTTI(duration: Duration) {} - - override fun startSpan( - name: String, - level: LogLevel, - fields: Map?, - startTimeMs: Long?, - parentSpanId: UUID?, - ): Span = Span(null, name, level, fields, startTimeMs, parentSpanId) - - override fun setSleepMode(sleepMode: SleepMode) {} - - override fun log(httpRequestInfo: HttpRequestInfo) {} - - override fun log(httpResponseInfo: HttpResponseInfo) {} - - fun clear() { - screenNameViewed.clear() - } - } -} diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionStrategyTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionStrategyTest.kt index 87593376c..c9bca9642 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionStrategyTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionStrategyTest.kt @@ -10,7 +10,6 @@ package io.bitdrift.capture import androidx.test.core.app.ApplicationProvider import com.nhaarman.mockitokotlin2.mock import io.bitdrift.capture.fakes.FakeFatalIssueReporter -import io.bitdrift.capture.fakes.FakePreInitLogFlusher import io.bitdrift.capture.providers.session.SessionStrategy import io.bitdrift.capture.reports.IFatalIssueReporter import okhttp3.HttpUrl @@ -27,7 +26,6 @@ import java.util.concurrent.CountDownLatch @Config(sdk = [21]) class SessionStrategyTest { private val fatalIssueReporter: IFatalIssueReporter = FakeFatalIssueReporter() - private val preInitLogFlusher = FakePreInitLogFlusher() @Before fun setUp() { @@ -54,7 +52,6 @@ class SessionStrategyTest { }, configuration = Configuration(), fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) val sessionId = logger.sessionId @@ -90,7 +87,6 @@ class SessionStrategyTest { configuration = Configuration(), preferences = mock(), fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) val sessionId = logger.sessionId diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionUrlTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionUrlTest.kt index ae9aa9a08..efbfc096e 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionUrlTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/SessionUrlTest.kt @@ -9,7 +9,6 @@ package io.bitdrift.capture import androidx.test.core.app.ApplicationProvider import io.bitdrift.capture.fakes.FakeFatalIssueReporter -import io.bitdrift.capture.fakes.FakePreInitLogFlusher import io.bitdrift.capture.providers.SystemDateProvider import io.bitdrift.capture.providers.session.SessionStrategy import io.bitdrift.capture.reports.IFatalIssueReporter @@ -25,7 +24,6 @@ import org.robolectric.annotation.Config @Config(sdk = [21]) class SessionUrlTest { private val fatalIssueReporter: IFatalIssueReporter = FakeFatalIssueReporter() - private val preInitLogFlusher = FakePreInitLogFlusher() @Before fun setUp() { @@ -79,6 +77,5 @@ class SessionUrlTest { dateProvider = SystemDateProvider(), sessionStrategy = SessionStrategy.Fixed { "SESSION_ID" }, fatalIssueReporter = fatalIssueReporter, - preInitLogFlusher = preInitLogFlusher, ) } diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/fakes/FakePreInitLogFlusher.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/fakes/FakePreInitLogFlusher.kt deleted file mode 100644 index 01bc4440c..000000000 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/fakes/FakePreInitLogFlusher.kt +++ /dev/null @@ -1,27 +0,0 @@ -// capture-sdk - bitdrift's client SDK -// Copyright Bitdrift, Inc. All rights reserved. -// -// Use of this source code is governed by a source available license that can be found in the -// LICENSE file or at: -// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt -package io.bitdrift.capture.fakes - -import io.bitdrift.capture.ILogger -import io.bitdrift.capture.IPreInitLogFlusher - -/** - * Fake [IPreInitLogFlusher] to ease testing - */ -class FakePreInitLogFlusher : IPreInitLogFlusher { - private var _wasFlushed = false - val wasFlushed: Boolean - get() = _wasFlushed - - override fun flushToNative(loggerImpl: ILogger) { - _wasFlushed = true - } - - fun reset() { - _wasFlushed = false - } -}