-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/capture-touch-breadcrumbs
- Loading branch information
Showing
23 changed files
with
548 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
@internal | ||
bool isMatchingRegexPattern(String value, List<String> regexPattern, | ||
{bool caseSensitive = false}) { | ||
final combinedRegexPattern = regexPattern.join('|'); | ||
final regExp = RegExp(combinedRegexPattern, caseSensitive: caseSensitive); | ||
return regExp.hasMatch(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:sentry/src/utils/regex_utils.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('regex_utils', () { | ||
final testString = "this is a test"; | ||
|
||
test('testString contains string pattern', () { | ||
expect(isMatchingRegexPattern(testString, ["is"]), isTrue); | ||
}); | ||
|
||
test('testString does not contain string pattern', () { | ||
expect(isMatchingRegexPattern(testString, ["not"]), isFalse); | ||
}); | ||
|
||
test('testString contains regex pattern', () { | ||
expect(isMatchingRegexPattern(testString, ["^this.*\$"]), isTrue); | ||
}); | ||
|
||
test('testString does not contain regex pattern', () { | ||
expect(isMatchingRegexPattern(testString, ["^is.*\$"]), isFalse); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'dart:html' as html show window, Window; | ||
Check warning on line 1 in flutter/lib/src/event_processor/url_filter/html_url_filter_event_processor.dart GitHub Actions / analyze / analyzeUnused import: 'dart:html'.
|
||
|
||
import '../../../sentry_flutter.dart'; | ||
import 'url_filter_event_processor.dart'; | ||
// ignore: implementation_imports | ||
import 'package:sentry/src/utils/regex_utils.dart'; | ||
|
||
// ignore_for_file: invalid_use_of_internal_member | ||
|
||
UrlFilterEventProcessor urlFilterEventProcessor(SentryFlutterOptions options) => | ||
WebUrlFilterEventProcessor(options); | ||
|
||
class WebUrlFilterEventProcessor implements UrlFilterEventProcessor { | ||
WebUrlFilterEventProcessor( | ||
this._options, | ||
); | ||
|
||
final SentryFlutterOptions _options; | ||
|
||
@override | ||
SentryEvent? apply(SentryEvent event, Hint hint) { | ||
final frames = _getStacktraceFrames(event); | ||
final lastPath = frames?.first?.absPath; | ||
|
||
if (lastPath == null) { | ||
return event; | ||
} | ||
|
||
if (_options.allowUrls.isNotEmpty && | ||
!isMatchingRegexPattern(lastPath, _options.allowUrls)) { | ||
return null; | ||
} | ||
|
||
if (_options.denyUrls.isNotEmpty && | ||
isMatchingRegexPattern(lastPath, _options.denyUrls)) { | ||
return null; | ||
} | ||
|
||
return event; | ||
} | ||
|
||
Iterable<SentryStackFrame?>? _getStacktraceFrames(SentryEvent event) { | ||
if (event.exceptions?.isNotEmpty == true) { | ||
return event.exceptions?.first.stackTrace?.frames; | ||
} | ||
if (event.threads?.isNotEmpty == true) { | ||
final stacktraces = event.threads?.map((e) => e.stacktrace); | ||
return stacktraces | ||
?.where((element) => element != null) | ||
.expand((element) => element!.frames); | ||
} | ||
return null; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
flutter/lib/src/event_processor/url_filter/io_url_filter_event_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import '../../../sentry_flutter.dart'; | ||
import 'url_filter_event_processor.dart'; | ||
|
||
UrlFilterEventProcessor urlFilterEventProcessor(SentryFlutterOptions _) => | ||
IoUrlFilterEventProcessor(); | ||
|
||
class IoUrlFilterEventProcessor implements UrlFilterEventProcessor { | ||
@override | ||
SentryEvent apply(SentryEvent event, Hint hint) => event; | ||
} |
9 changes: 9 additions & 0 deletions
9
flutter/lib/src/event_processor/url_filter/url_filter_event_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import '../../../sentry_flutter.dart'; | ||
import 'io_url_filter_event_processor.dart' | ||
if (dart.library.html) 'html_url_filter_event_processor.dart' | ||
if (dart.library.js_interop) 'web_url_filter_event_processor.dart'; | ||
|
||
abstract class UrlFilterEventProcessor implements EventProcessor { | ||
factory UrlFilterEventProcessor(SentryFlutterOptions options) => | ||
urlFilterEventProcessor(options); | ||
} |
56 changes: 56 additions & 0 deletions
56
flutter/lib/src/event_processor/url_filter/web_url_filter_event_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// We would lose compatibility with old dart versions by adding web to pubspec. | ||
// ignore: depend_on_referenced_packages | ||
import 'package:web/web.dart' as web show window, Window; | ||
Check warning on line 3 in flutter/lib/src/event_processor/url_filter/web_url_filter_event_processor.dart GitHub Actions / analyze / analyzeUnused import: 'package:web/web.dart'.
|
||
|
||
import '../../../sentry_flutter.dart'; | ||
import 'url_filter_event_processor.dart'; | ||
// ignore: implementation_imports | ||
import 'package:sentry/src/utils/regex_utils.dart'; | ||
|
||
// ignore_for_file: invalid_use_of_internal_member | ||
|
||
UrlFilterEventProcessor urlFilterEventProcessor(SentryFlutterOptions options) => | ||
WebUrlFilterEventProcessor(options); | ||
|
||
class WebUrlFilterEventProcessor implements UrlFilterEventProcessor { | ||
WebUrlFilterEventProcessor( | ||
this._options, | ||
); | ||
|
||
final SentryFlutterOptions _options; | ||
|
||
@override | ||
SentryEvent? apply(SentryEvent event, Hint hint) { | ||
final frames = _getStacktraceFrames(event); | ||
final lastPath = frames?.first?.absPath; | ||
|
||
if (lastPath == null) { | ||
return event; | ||
} | ||
|
||
if (_options.allowUrls.isNotEmpty && | ||
!isMatchingRegexPattern(lastPath, _options.allowUrls)) { | ||
return null; | ||
} | ||
|
||
if (_options.denyUrls.isNotEmpty && | ||
isMatchingRegexPattern(lastPath, _options.denyUrls)) { | ||
return null; | ||
} | ||
|
||
return event; | ||
} | ||
|
||
Iterable<SentryStackFrame?>? _getStacktraceFrames(SentryEvent event) { | ||
if (event.exceptions?.isNotEmpty == true) { | ||
return event.exceptions?.first.stackTrace?.frames; | ||
} | ||
if (event.threads?.isNotEmpty == true) { | ||
final stacktraces = event.threads?.map((e) => e.stacktrace); | ||
return stacktraces | ||
?.where((element) => element != null) | ||
.expand((element) => element!.frames); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.