@@ -5,18 +5,23 @@ import android.os.Build
55import android.os.Looper
66import androidx.test.core.app.ApplicationProvider
77import androidx.test.ext.junit.runners.AndroidJUnit4
8+ import io.sentry.DateUtils
89import io.sentry.DiagnosticLogger
910import io.sentry.Hint
1011import io.sentry.IScopes
1112import io.sentry.SentryEvent
1213import io.sentry.SentryLevel
14+ import io.sentry.SentryLogEvent
15+ import io.sentry.SentryLogLevel
16+ import io.sentry.SentryMetricsEvent
1317import io.sentry.SentryTracer
1418import io.sentry.TransactionContext
1519import io.sentry.TypeCheckHint.SENTRY_DART_SDK_NAME
1620import io.sentry.android.core.internal.util.CpuInfoUtils
1721import io.sentry.protocol.OperatingSystem
1822import io.sentry.protocol.SdkVersion
1923import io.sentry.protocol.SentryException
24+ import io.sentry.protocol.SentryId
2025import io.sentry.protocol.SentryStackFrame
2126import io.sentry.protocol.SentryStackTrace
2227import io.sentry.protocol.SentryThread
@@ -619,4 +624,45 @@ class DefaultAndroidEventProcessorTest {
619624 assertEquals(" IllegalArgumentException" , it.exceptions!! [1 ].type)
620625 }
621626 }
627+
628+ @Test
629+ fun `device and os are set on metric` () {
630+ val sut = fixture.getSut(context)
631+ val processedEvent: SentryMetricsEvent ? =
632+ sut.process(
633+ SentryMetricsEvent (
634+ SentryId (" 5c1f73d39486827b9e60ceb1fc23277a" ),
635+ DateUtils .dateToSeconds(DateUtils .getDateTime(" 2004-04-10T18:24:03.000Z" )),
636+ " 42e6bd2a-c45e-414d-8066-ed5196fbc686" ,
637+ " counter" ,
638+ 123.0 ,
639+ )
640+ )
641+
642+ assertNotNull(processedEvent?.attributes?.get(" device.brand" ))
643+ assertNotNull(processedEvent?.attributes?.get(" device.model" ))
644+ assertNotNull(processedEvent?.attributes?.get(" device.family" ))
645+ assertNotNull(processedEvent?.attributes?.get(" os.name" ))
646+ assertNotNull(processedEvent?.attributes?.get(" os.version" ))
647+ }
648+
649+ @Test
650+ fun `device and os are set on log` () {
651+ val sut = fixture.getSut(context)
652+ val processedEvent: SentryLogEvent ? =
653+ sut.process(
654+ SentryLogEvent (
655+ SentryId (" 5c1f73d39486827b9e60ceb1fc23277a" ),
656+ DateUtils .dateToSeconds(DateUtils .getDateTime(" 2004-04-10T18:24:03.000Z" )),
657+ " message" ,
658+ SentryLogLevel .WARN ,
659+ )
660+ )
661+
662+ assertNotNull(processedEvent?.attributes?.get(" device.brand" ))
663+ assertNotNull(processedEvent?.attributes?.get(" device.model" ))
664+ assertNotNull(processedEvent?.attributes?.get(" device.family" ))
665+ assertNotNull(processedEvent?.attributes?.get(" os.name" ))
666+ assertNotNull(processedEvent?.attributes?.get(" os.version" ))
667+ }
622668}
0 commit comments