|
7 | 7 | import io.sentry.EventProcessor; |
8 | 8 | import io.sentry.Hint; |
9 | 9 | import io.sentry.IpAddressUtils; |
| 10 | +import io.sentry.SentryAttributeType; |
10 | 11 | import io.sentry.SentryBaseEvent; |
11 | 12 | import io.sentry.SentryEvent; |
12 | 13 | import io.sentry.SentryLevel; |
| 14 | +import io.sentry.SentryLogEvent; |
| 15 | +import io.sentry.SentryLogEventAttributeValue; |
13 | 16 | import io.sentry.SentryReplayEvent; |
14 | 17 | import io.sentry.android.core.internal.util.AndroidThreadChecker; |
15 | 18 | import io.sentry.android.core.performance.AppStartMetrics; |
16 | 19 | import io.sentry.android.core.performance.TimeSpan; |
17 | 20 | import io.sentry.protocol.App; |
| 21 | +import io.sentry.protocol.Device; |
18 | 22 | import io.sentry.protocol.OperatingSystem; |
19 | 23 | import io.sentry.protocol.SentryException; |
20 | 24 | import io.sentry.protocol.SentryStackFrame; |
@@ -81,6 +85,13 @@ public DefaultAndroidEventProcessor( |
81 | 85 | return event; |
82 | 86 | } |
83 | 87 |
|
| 88 | + @Override |
| 89 | + public @Nullable SentryLogEvent process(@NotNull SentryLogEvent event) { |
| 90 | + setDevice(event); |
| 91 | + setOs(event); |
| 92 | + return event; |
| 93 | + } |
| 94 | + |
84 | 95 | /** |
85 | 96 | * The last exception is usually used for picking the issue title, but the convention is to send |
86 | 97 | * inner exceptions first, e.g. [inner, outer] This doesn't work very well on Android, as some |
@@ -199,6 +210,37 @@ private void mergeOS(final @NotNull SentryBaseEvent event) { |
199 | 210 | } |
200 | 211 | } |
201 | 212 |
|
| 213 | + private void setDevice(final @NotNull SentryLogEvent event) { |
| 214 | + try { |
| 215 | + final @NotNull Device device = deviceInfoUtil.get().collectDeviceInformation(false, false); |
| 216 | + event.setAttribute( |
| 217 | + "device.brand", |
| 218 | + new SentryLogEventAttributeValue(SentryAttributeType.STRING, device.getBrand())); |
| 219 | + event.setAttribute( |
| 220 | + "device.model", |
| 221 | + new SentryLogEventAttributeValue(SentryAttributeType.STRING, device.getModel())); |
| 222 | + event.setAttribute( |
| 223 | + "device.family", |
| 224 | + new SentryLogEventAttributeValue(SentryAttributeType.STRING, device.getFamily())); |
| 225 | + } catch (Throwable e) { |
| 226 | + options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve device info", e); |
| 227 | + } |
| 228 | + } |
| 229 | + |
| 230 | + private void setOs(final @NotNull SentryLogEvent event) { |
| 231 | + try { |
| 232 | + final OperatingSystem androidOS = deviceInfoUtil.get().getOperatingSystem(); |
| 233 | + event.setAttribute( |
| 234 | + "os.name", |
| 235 | + new SentryLogEventAttributeValue(SentryAttributeType.STRING, androidOS.getName())); |
| 236 | + event.setAttribute( |
| 237 | + "os.version", |
| 238 | + new SentryLogEventAttributeValue(SentryAttributeType.STRING, androidOS.getVersion())); |
| 239 | + } catch (Throwable e) { |
| 240 | + options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve os system", e); |
| 241 | + } |
| 242 | + } |
| 243 | + |
202 | 244 | // Data to be applied to events that was created in the running process |
203 | 245 | private void processNonCachedEvent( |
204 | 246 | final @NotNull SentryBaseEvent event, final @NotNull Hint hint) { |
|
0 commit comments