Skip to content

Commit

Permalink
Remove unused method from DeliveryService.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslabari committed Nov 17, 2023
1 parent 7b2e011 commit 37ea394
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ internal interface DeliveryService {
fun sendSession(sessionMessage: SessionMessage, state: SessionMessageState)
fun sendCachedSessions(isNdkEnabled: Boolean, ndkService: NdkService, currentSession: String?)
fun saveCrash(crash: EventMessage)
fun sendEventAsync(eventMessage: EventMessage)
fun saveBackgroundActivity(backgroundActivityMessage: BackgroundActivityMessage)
fun sendBackgroundActivity(backgroundActivityMessage: BackgroundActivityMessage)
fun sendBackgroundActivities()
fun sendLogs(eventMessage: EventMessage)
fun sendLog(eventMessage: EventMessage)
fun sendNetworkCall(networkEvent: NetworkEvent)
fun sendCrash(crash: EventMessage)
fun sendAEIBlob(blobMessage: BlobMessage)
fun sendEvent(eventMessage: EventMessage)
fun sendEventAsync(eventMessage: EventMessage)
fun sendEventAndWait(eventMessage: EventMessage)
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ internal class EmbraceDeliveryService(
}
}

override fun sendLogs(eventMessage: EventMessage) {
override fun sendLog(eventMessage: EventMessage) {
apiService.sendLog(eventMessage)
}

Expand All @@ -188,14 +188,6 @@ internal class EmbraceDeliveryService(
apiService.sendAEIBlob(blobMessage)
}

override fun sendEvent(eventMessage: EventMessage) {
apiService.sendEvent(eventMessage)
}

override fun sendEventAndWait(eventMessage: EventMessage) {
apiService.sendEventAndWait(eventMessage)
}

override fun sendCachedSessions(
isNdkEnabled: Boolean,
ndkService: NdkService,
Expand Down Expand Up @@ -293,4 +285,8 @@ internal class EmbraceDeliveryService(
apiService.sendEvent(eventMessage)
}
}

override fun sendEventAndWait(eventMessage: EventMessage) {
apiService.sendEventAndWait(eventMessage)

Check warning on line 290 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt#L290

Added line #L290 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ internal class EmbraceRemoteLogger constructor(
// Sanitize log event
val logEvent = gatingService.gateEventMessage(eventMessage)
logDeveloper("EmbraceRemoteLogger", "Attempt to Send log Event")
deliveryService.sendLogs(logEvent)
deliveryService.sendLog(logEvent)
logDeveloper("EmbraceRemoteLogger", "LogEvent api call running in background job")
}
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,14 @@ internal class FakeDeliveryService : DeliveryService {
sendBackgroundActivitiesInvokedCount++
}

override fun sendLogs(eventMessage: EventMessage) {
override fun sendLog(eventMessage: EventMessage) {
lastSentLogs.add(eventMessage)
}

override fun sendNetworkCall(networkEvent: NetworkEvent) {
lastSentNetworkCall = networkEvent
}

override fun sendEvent(eventMessage: EventMessage) {
lastSentEvent = eventMessage
}

override fun sendEventAndWait(eventMessage: EventMessage) {
lastSentEvent = eventMessage
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,23 @@ internal class EmbraceRemoteLoggerTest {
remoteLogger.log("Hello errors", EmbraceEvent.Type.ERROR_LOG, null)

verify {
deliveryService.sendLogs(
withArg {
Assert.assertEquals("Hello world", it.event.name)
Assert.assertNotNull(it.event.timestamp)
Assert.assertEquals(EmbraceEvent.Type.INFO_LOG, it.event.type)
Assert.assertEquals(props, it.event.customPropertiesMap)
Assert.assertNotNull(it.event.messageId)
Assert.assertNotNull(it.event.eventId)
Assert.assertNotNull(it.event.sessionId)
it.event.screenshotTaken?.let { Assert.assertFalse(it) }
Assert.assertEquals(LogExceptionType.NONE.value, it.event.logExceptionType)
deliveryService.sendLog(
withArg { eventMessage ->
Assert.assertEquals("Hello world", eventMessage.event.name)
Assert.assertNotNull(eventMessage.event.timestamp)
Assert.assertEquals(EmbraceEvent.Type.INFO_LOG, eventMessage.event.type)
Assert.assertEquals(props, eventMessage.event.customPropertiesMap)
Assert.assertNotNull(eventMessage.event.messageId)
Assert.assertNotNull(eventMessage.event.eventId)
Assert.assertNotNull(eventMessage.event.sessionId)
eventMessage.event.screenshotTaken?.let { Assert.assertFalse(it) }
Assert.assertEquals(LogExceptionType.NONE.value, eventMessage.event.logExceptionType)
}
)
}

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertEquals("Warning world", it.event.name)
Assert.assertEquals(EmbraceEvent.Type.WARNING_LOG, it.event.type)
Expand All @@ -167,16 +167,16 @@ internal class EmbraceRemoteLoggerTest {
}

verify {
deliveryService.sendLogs(
withArg {
Assert.assertEquals("Hello errors", it.event.name)
Assert.assertEquals(EmbraceEvent.Type.ERROR_LOG, it.event.type)
Assert.assertNull(it.event.customPropertiesMap)
Assert.assertNotNull(it.event.messageId)
Assert.assertNotNull(it.event.eventId)
Assert.assertNotNull(it.event.sessionId)
it.event.screenshotTaken?.let { Assert.assertFalse(it) }
Assert.assertEquals(LogExceptionType.NONE.value, it.event.logExceptionType)
deliveryService.sendLog(
withArg { eventMessage ->
Assert.assertEquals("Hello errors", eventMessage.event.name)
Assert.assertEquals(EmbraceEvent.Type.ERROR_LOG, eventMessage.event.type)
Assert.assertNull(eventMessage.event.customPropertiesMap)
Assert.assertNotNull(eventMessage.event.messageId)
Assert.assertNotNull(eventMessage.event.eventId)
Assert.assertNotNull(eventMessage.event.sessionId)
eventMessage.event.screenshotTaken?.let { Assert.assertFalse(it) }
Assert.assertEquals(LogExceptionType.NONE.value, eventMessage.event.logExceptionType)
}
)
}
Expand Down Expand Up @@ -208,7 +208,7 @@ internal class EmbraceRemoteLoggerTest {
)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertEquals("Hello world", it.event.name)
Assert.assertEquals(EmbraceEvent.Type.ERROR_LOG, it.event.type)
Expand Down Expand Up @@ -265,7 +265,7 @@ internal class EmbraceRemoteLoggerTest {
remoteLogger.log("Hi".repeat(65), EmbraceEvent.Type.INFO_LOG, null)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Hi".repeat(62) + "H...")
}
Expand All @@ -282,7 +282,7 @@ internal class EmbraceRemoteLoggerTest {
remoteLogger.log("Hi".repeat(50), EmbraceEvent.Type.INFO_LOG, null)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Hi".repeat(23) + "H...")
}
Expand All @@ -291,23 +291,23 @@ internal class EmbraceRemoteLoggerTest {
}

@Test
fun testLogMessageEabled() {
fun testLogMessageEnabled() {
every { configService.dataCaptureEventBehavior.isLogMessageEnabled("Hello World") } returns false
remoteLogger = getRemoteLogger()

remoteLogger.log("Hello World", EmbraceEvent.Type.INFO_LOG, null)
remoteLogger.log("Another", EmbraceEvent.Type.INFO_LOG, null)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Another")
}
)
}

verify(exactly = 0) {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Hello World")
}
Expand All @@ -322,7 +322,7 @@ internal class EmbraceRemoteLoggerTest {

remoteLogger.log("Hello World", EmbraceEvent.Type.INFO_LOG, null)

verify(exactly = 0) { deliveryService.sendLogs(any()) }
verify(exactly = 0) { deliveryService.sendLog(any()) }
}

@Test
Expand Down Expand Up @@ -362,7 +362,7 @@ internal class EmbraceRemoteLoggerTest {
)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Unity".repeat(1000)) // log limit higher on unity
Assert.assertTrue(it.stacktraces?.unityStacktrace == "my stacktrace")
Expand Down Expand Up @@ -393,7 +393,7 @@ internal class EmbraceRemoteLoggerTest {
)

verify {
deliveryService.sendLogs(
deliveryService.sendLog(
withArg {
Assert.assertTrue(it.event.name == "Unity".repeat(1000)) // log limit higher on unity
Assert.assertTrue(it.stacktraces?.unityStacktrace == "my stacktrace")
Expand Down Expand Up @@ -425,7 +425,7 @@ internal class EmbraceRemoteLoggerTest {
executor.awaitTermination(1, TimeUnit.SECONDS)

val action = slot<EventMessage>()
verify(exactly = 1) { deliveryService.sendLogs(capture(action)) }
verify(exactly = 1) { deliveryService.sendLog(capture(action)) }
val msg = action.captured
Assert.assertEquals("Dart error name", msg.event.exceptionName)
Assert.assertEquals("Dart error message", msg.event.exceptionMessage)
Expand All @@ -438,10 +438,7 @@ internal class EmbraceRemoteLoggerTest {
@Test
fun testIfShouldGateInfoLog() {
remoteLogger = getRemoteLogger()
cfg = buildCustomRemoteConfig(
setOf(),
null
)
cfg = buildCustomRemoteConfig(setOf())
Assert.assertTrue(remoteLogger.checkIfShouldGateLog(EmbraceEvent.Type.INFO_LOG))
Assert.assertTrue(remoteLogger.checkIfShouldGateLog(EmbraceEvent.Type.WARNING_LOG))
}
Expand All @@ -450,20 +447,19 @@ internal class EmbraceRemoteLoggerTest {
fun testIfShouldNotGateInfoLog() {
remoteLogger = getRemoteLogger()
cfg = buildCustomRemoteConfig(
setOf(SessionGatingKeys.LOGS_INFO, SessionGatingKeys.LOGS_WARN),
null
setOf(SessionGatingKeys.LOGS_INFO, SessionGatingKeys.LOGS_WARN)
)
Assert.assertFalse(remoteLogger.checkIfShouldGateLog(EmbraceEvent.Type.INFO_LOG))
Assert.assertFalse(remoteLogger.checkIfShouldGateLog(EmbraceEvent.Type.WARNING_LOG))
}

private fun buildCustomRemoteConfig(components: Set<String>?, fullSessionEvents: Set<String>?) =
private fun buildCustomRemoteConfig(components: Set<String>?, fullSessionEvents: Set<String>? = null) =
RemoteConfig(
sessionConfig = SessionRemoteConfig(
true,
false,
components,
fullSessionEvents
isEnabled = true,
endAsync = false,
sessionComponents = components,
fullSessionEvents = fullSessionEvents
)
)
}

0 comments on commit 37ea394

Please sign in to comment.