diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapper.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapper.kt index 1bfea50265..f533a032a4 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapper.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapper.kt @@ -2,8 +2,8 @@ package io.embrace.android.embracesdk.comms.api import io.embrace.android.embracesdk.BuildConfig import io.embrace.android.embracesdk.EventType -import io.embrace.android.embracesdk.internal.logs.LogPayload import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.network.http.HttpMethod import io.embrace.android.embracesdk.payload.BlobMessage diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiService.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiService.kt index 72d43ccd92..97b4947d4e 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiService.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/ApiService.kt @@ -1,8 +1,8 @@ package io.embrace.android.embracesdk.comms.api import io.embrace.android.embracesdk.config.remote.RemoteConfig -import io.embrace.android.embracesdk.internal.logs.LogPayload import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.internal.utils.SerializationAction import io.embrace.android.embracesdk.payload.BlobMessage diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt index 9a1072c7e0..30db45ffb0 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt @@ -10,8 +10,8 @@ import io.embrace.android.embracesdk.comms.delivery.PendingApiCallsSender import io.embrace.android.embracesdk.config.remote.RemoteConfig import io.embrace.android.embracesdk.internal.Systrace import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream -import io.embrace.android.embracesdk.internal.logs.LogPayload import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer import io.embrace.android.embracesdk.internal.utils.SerializationAction diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/DeliveryService.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/DeliveryService.kt index c1e2d0f686..4977daab5a 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/DeliveryService.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/DeliveryService.kt @@ -1,6 +1,6 @@ package io.embrace.android.embracesdk.comms.delivery -import io.embrace.android.embracesdk.internal.logs.LogPayload +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.ndk.NdkService import io.embrace.android.embracesdk.payload.BlobMessage diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt index 239d743c78..4a87a15403 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/delivery/EmbraceDeliveryService.kt @@ -3,8 +3,8 @@ package io.embrace.android.embracesdk.comms.delivery import io.embrace.android.embracesdk.comms.api.ApiService import io.embrace.android.embracesdk.gating.GatingService import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream -import io.embrace.android.embracesdk.internal.logs.LogPayload import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer import io.embrace.android.embracesdk.logging.InternalEmbraceLogger diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogOrchestrator.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogOrchestrator.kt index 9eece67062..1a40e20645 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogOrchestrator.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogOrchestrator.kt @@ -2,6 +2,8 @@ package io.embrace.android.embracesdk.internal.logs import io.embrace.android.embracesdk.comms.delivery.DeliveryService import io.embrace.android.embracesdk.internal.clock.Clock +import io.embrace.android.embracesdk.internal.payload.LogPayload +import io.embrace.android.embracesdk.internal.payload.toNewPayload import io.embrace.android.embracesdk.worker.ScheduledWorker import java.lang.Long.min import java.util.concurrent.ScheduledFuture @@ -59,7 +61,7 @@ internal class LogOrchestrator( val storedLogs = sink.flushLogs(MAX_LOGS_PER_BATCH) if (storedLogs.isNotEmpty()) { - deliveryService.sendLogs(LogPayload(logs = storedLogs)) + deliveryService.sendLogs(LogPayload(logs = storedLogs.map(EmbraceLogRecordData::toNewPayload))) } return true diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogPayload.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogPayload.kt deleted file mode 100644 index 63f1bcca6b..0000000000 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/logs/LogPayload.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.embrace.android.embracesdk.internal.logs - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -internal data class LogPayload( - - @Json(name = "logs") - val logs: List = emptyList() -) diff --git a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/payload/Envelope.kt b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/payload/Envelope.kt index 36243fcaf0..77118a108a 100644 --- a/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/payload/Envelope.kt +++ b/embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/payload/Envelope.kt @@ -2,11 +2,10 @@ package io.embrace.android.embracesdk.internal.payload import com.squareup.moshi.Json import com.squareup.moshi.JsonClass -import io.embrace.android.embracesdk.internal.logs.LogPayload /** * Envelope used for Embrace API requests for different types of data: - * - [LogPayload] + * - LogPayload * - SessionPayload * - BlobPayload * - CrashPayload diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/FakeDeliveryService.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/FakeDeliveryService.kt index 8cdc4f3b35..18a85a3ff5 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/FakeDeliveryService.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/FakeDeliveryService.kt @@ -1,7 +1,7 @@ package io.embrace.android.embracesdk import io.embrace.android.embracesdk.comms.delivery.DeliveryService -import io.embrace.android.embracesdk.internal.logs.LogPayload +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.ndk.NdkService import io.embrace.android.embracesdk.payload.BlobMessage diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapperTest.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapperTest.kt index a7fadb962c..f8f91fe590 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapperTest.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/ApiRequestMapperTest.kt @@ -1,10 +1,11 @@ package io.embrace.android.embracesdk.comms.api import io.embrace.android.embracesdk.EventType -import io.embrace.android.embracesdk.internal.logs.EmbraceLogBody -import io.embrace.android.embracesdk.internal.logs.EmbraceLogRecordData -import io.embrace.android.embracesdk.internal.logs.LogPayload +import io.embrace.android.embracesdk.internal.payload.Attribute import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.Log +import io.embrace.android.embracesdk.internal.payload.LogBody +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.network.http.HttpMethod import io.embrace.android.embracesdk.payload.AppInfo import io.embrace.android.embracesdk.payload.BlobMessage @@ -68,14 +69,14 @@ internal class ApiRequestMapperTest { Envelope( data = LogPayload( logs = listOf( - EmbraceLogRecordData( + Log( traceId = "traceId", spanId = "spanId", - timeUnixNanos = 1234567890, + timeUnixNano = 1234567890, severityText = "severityText", severityNumber = 1, - body = EmbraceLogBody("a message"), - attributes = mapOf("key" to "value") + body = LogBody("a message"), + attributes = listOf(Attribute("key", "value")), ) ) ) diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/EmbraceApiServiceTest.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/EmbraceApiServiceTest.kt index 74b19cc392..566ea0b30a 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/EmbraceApiServiceTest.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/comms/api/EmbraceApiServiceTest.kt @@ -13,10 +13,11 @@ import io.embrace.android.embracesdk.fakes.FakeDeliveryCacheManager import io.embrace.android.embracesdk.fakes.FakeNetworkConnectivityService import io.embrace.android.embracesdk.fakes.FakePendingApiCallsSender import io.embrace.android.embracesdk.internal.compression.ConditionalGzipOutputStream -import io.embrace.android.embracesdk.internal.logs.EmbraceLogBody -import io.embrace.android.embracesdk.internal.logs.EmbraceLogRecordData -import io.embrace.android.embracesdk.internal.logs.LogPayload +import io.embrace.android.embracesdk.internal.payload.Attribute import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.Log +import io.embrace.android.embracesdk.internal.payload.LogBody +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer import io.embrace.android.embracesdk.logging.InternalEmbraceLogger @@ -261,14 +262,14 @@ internal class EmbraceApiServiceTest { val logsEnvelope = Envelope( data = LogPayload( logs = listOf( - EmbraceLogRecordData( + Log( traceId = "traceId", spanId = "spanId", - timeUnixNanos = 1234567890, + timeUnixNano = 1234567890, severityText = "severityText", severityNumber = 1, - body = EmbraceLogBody("a message"), - attributes = mapOf("key" to "value") + body = LogBody("a message"), + attributes = listOf(Attribute("key", "value")) ) ) ) diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/FakeApiService.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/FakeApiService.kt index 77b3d32dd3..394620da3b 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/FakeApiService.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/FakeApiService.kt @@ -3,8 +3,8 @@ package io.embrace.android.embracesdk.fakes import io.embrace.android.embracesdk.comms.api.ApiService import io.embrace.android.embracesdk.comms.api.CachedConfig import io.embrace.android.embracesdk.config.remote.RemoteConfig -import io.embrace.android.embracesdk.internal.logs.LogPayload import io.embrace.android.embracesdk.internal.payload.Envelope +import io.embrace.android.embracesdk.internal.payload.LogPayload import io.embrace.android.embracesdk.internal.payload.SessionPayload import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer import io.embrace.android.embracesdk.internal.utils.SerializationAction diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/internal/logs/LogOrchestratorTest.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/internal/logs/LogOrchestratorTest.kt index 80c103203a..bb00859ae8 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/internal/logs/LogOrchestratorTest.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/internal/logs/LogOrchestratorTest.kt @@ -118,13 +118,13 @@ internal class LogOrchestratorTest { latch.await(1000L, TimeUnit.MILLISECONDS) assertEquals("Too many payloads sent", 1, deliveryService.lastSentLogPayloads.size) - assertEquals("Too many logs in payload", 50, deliveryService.lastSentLogPayloads[0].logs.size) + assertEquals("Too many logs in payload", 50, deliveryService.lastSentLogPayloads[0].logs?.size) } private fun verifyPayload(numberOfLogs: Int) { assertNotNull(deliveryService.lastSentLogPayloads) assertEquals(1, deliveryService.lastSentLogPayloads.size) - assertEquals(numberOfLogs, deliveryService.lastSentLogPayloads[0].logs.size) + assertEquals(numberOfLogs, deliveryService.lastSentLogPayloads[0].logs?.size) } private fun verifyPayloadNotSent() {