Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- Recursion in `openDatabase` when using `SentrySqfliteDatabaseFactory` ([#3231](https://github.com/getsentry/sentry-dart/pull/3231))

### Enhancements

- Replay: continue processing if encountering `InheritedWidget` ([#3200](https://github.com/getsentry/sentry-dart/pull/3200))
- Prevents false debug warnings when using [provider](https://pub.dev/packages/provider) for example which extensively uses `InheritedWidget`

## 9.7.0-beta.2

### Features
Expand Down
3 changes: 3 additions & 0 deletions packages/flutter/lib/src/sentry_privacy_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class SentryPrivacyOptions {

rules.add(SentryMaskingCustomRule<Widget>(
callback: (Element element, Widget widget) {
if (widget is InheritedWidget) {
return SentryMaskingDecision.continueProcessing;
}
final type = widget.runtimeType.toString();
if (regexp.hasMatch(type)) {
logger(
Expand Down
27 changes: 27 additions & 0 deletions packages/flutter/test/screenshot/masking_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,26 @@ void main() async {
});
});
});

testWidgets('ignores InheritedWidget and does not log', (tester) async {
final logger = MockLogger();
final options = SentryPrivacyOptions();
final config =
options.buildMaskingConfig(logger.call, MockRuntimeChecker());

final rootElement = await pumpTestElement(tester, children: const [
_PasswordInherited(child: Text('child')),
]);

final element = rootElement.findFirstOfType<_PasswordInherited>();
expect(config.shouldMask(element, element.widget),
SentryMaskingDecision.continueProcessing);

// The debug rule contains a RegExp that matches 'password'. Our widget
// name contains it but because it's an InheritedWidget it should be
// ignored and thus no warning is logged.
expect(logger.items.where((i) => i.level == SentryLevel.warning), isEmpty);
});
}

extension on Element {
Expand Down Expand Up @@ -327,3 +347,10 @@ extension on Element {
return result;
}
}

class _PasswordInherited extends InheritedWidget {
const _PasswordInherited({required super.child});

@override
bool updateShouldNotify(covariant _PasswordInherited oldWidget) => false;
}
Loading