Skip to content

Commit

Permalink
Fix missing OS context for iOS events (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Jul 25, 2022
1 parent 94daf24 commit 7011abe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

* Missing OS context for iOS events ([#958](https://github.com/getsentry/sentry-dart/pull/958))

### Features

* Dio Integration adds response data ([#934](https://github.com/getsentry/sentry-dart/pull/934))
Expand Down
11 changes: 10 additions & 1 deletion flutter/lib/src/default_integrations.dart
Expand Up @@ -185,10 +185,19 @@ class _LoadContextsIntegrationEventProcessor extends EventProcessor {
contexts.forEach(
(key, dynamic value) {
if (value != null) {
final currentValue = eventContexts[key];
if (key == SentryRuntime.listType) {
contexts.runtimes.forEach(eventContexts.addRuntime);
} else if (eventContexts[key] == null) {
} else if (currentValue == null) {
eventContexts[key] = value;
} else {
if (key == SentryOperatingSystem.type &&
currentValue is SentryOperatingSystem &&
value is SentryOperatingSystem) {
final osMap = {...value.toJson(), ...currentValue.toJson()};
final os = SentryOperatingSystem.fromJson(osMap);
eventContexts[key] = os;
}
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions flutter/test/load_contexts_integrations_test.dart
Expand Up @@ -75,12 +75,14 @@ void main() {
expect(fixture.options.eventProcessors.length, 1);

final e = SentryEvent();
e.contexts.operatingSystem = SentryOperatingSystem(theme: 'theme1');
final event = await fixture.options.eventProcessors.first.apply(e);

expect(fixture.called, true);
expect(event?.contexts.device?.name, 'Device1');
expect(event?.contexts.app?.name, 'test-app');
expect(event?.contexts.operatingSystem?.name, 'os1');
expect(event?.contexts.operatingSystem?.theme, 'theme1');
expect(event?.contexts.gpu?.name, 'gpu1');
expect(event?.contexts.browser?.name, 'browser1');
expect(
Expand Down

0 comments on commit 7011abe

Please sign in to comment.