Skip to content

Commit

Permalink
guard device name behind sendDefaultPii (#2741)
Browse files Browse the repository at this point in the history
* guard device name behind sendDefaultPii

* update CHANGELOG

* update test
  • Loading branch information
buenaflor authored Feb 20, 2025
1 parent f42d238 commit 803f3a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- ⚠️ Auto IP assignment for `SentryUser` is now guarded by `sendDefaultPii` ([#2726](https://github.com/getsentry/sentry-dart/pull/2726))
- If you rely on Sentry automatically processing the IP address of the user, set `options.sendDefaultPii = true` or manually set the IP address of the `SentryUser` to `{{auto}}`
- Adding the device name to Contexts is now guarded by `sendDefaultPii` ([#2741](https://github.com/getsentry/sentry-dart/pull/2741))
- Set `options.sendDefaultPii = true` if you want to have the device name reported

### Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
SentryDevice _getDevice(SentryDevice? device) {
final platformMemory = PlatformMemory(_options);
return (device ?? SentryDevice()).copyWith(
name: device?.name ?? Platform.localHostname,
name: device?.name ??
(_options.sendDefaultPii ? Platform.localHostname : null),
processorCount: device?.processorCount ?? Platform.numberOfProcessors,
memorySize: device?.memorySize ?? platformMemory.getTotalPhysicalMemory(),
freeMemory: device?.freeMemory ?? platformMemory.getFreePhysicalMemory(),
Expand Down
9 changes: 8 additions & 1 deletion dart/test/event_processor/enricher/io_enricher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ void main() {
}
});

test('device has name', () {
test('device has no name if sendDefaultPii = false', () {
final enricher = fixture.getSut();
final event = enricher.apply(SentryEvent(), Hint());

expect(event?.contexts.device?.name, isNull);
});

test('device has name if sendDefaultPii = true', () {
final enricher = fixture.getSut(includePii: true);
final event = enricher.apply(SentryEvent(), Hint());

expect(event?.contexts.device?.name, isNotNull);
});

Expand Down

0 comments on commit 803f3a9

Please sign in to comment.