-
-
Notifications
You must be signed in to change notification settings - Fork 277
Fix/unified api fixes and web example #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
28792c6
ioClient : set a default Client
rxlabz a5e3fb8
options.compressPayload default value + minor
rxlabz 4b5e8ea
captureMessage as a static method
rxlabz ee35bad
io example : send a formatted message
rxlabz 51d18de
add a Dart web example
rxlabz f0ab2b9
changelog
rxlabz cc4e835
update web example
rxlabz c43d5bd
Merge remote-tracking branch 'origin/feature/unified-api' into fix/un…
rxlabz c2f89fa
Merge remote-tracking branch 'origin/feature/unified-api' into fix/un…
rxlabz 27a8d31
add tests ( applyScope, captureMessage )
rxlabz 070bfa5
minor
rxlabz eaa39e0
more applyScope tests
rxlabz 352a270
refacto sentry client tests
rxlabz 9c5110c
add a client.captureException test
rxlabz 904b7b9
clean
rxlabz d0728c7
Update dart/examples/web_example/pubspec.yaml
rxlabz 3f6f198
update the web example readme
rxlabz f5dc698
rename example methods
rxlabz c2e6b4d
clear the SentryOptions ctor
rxlabz fa1a8b1
refactor clients and update tests
rxlabz 1f5828d
fix a test
rxlabz b0de53b
typo
rxlabz 91beccc
clear tests
rxlabz 1e36ab9
update examples
rxlabz d30a89b
move back example to /example ( pub.dev visibility)
rxlabz 7b618c7
update example events
rxlabz edc6f35
update example events
rxlabz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refacto sentry client tests
- Loading branch information
commit 352a270076f4c55ad1f75081400a272c26a16874
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,156 @@ | ||
| /* | ||
| group('SentryClient : apply scope to the captured event', () { | ||
| SentryOptions options; | ||
| String eventLevel; | ||
| String eventTransaction; | ||
| String eventBreadcrumbMessage; | ||
| List<dynamic> eventFingerprint; | ||
| String userId; | ||
| Scope scope; | ||
| String capturedScopeTagValue; | ||
| String capturedScopeExtraValue; | ||
| String capturedEventTagValue; | ||
| String capturedEventExtraValue; | ||
|
|
||
| final level = SentryLevel.error; | ||
| final transaction = '/test/scope'; | ||
| final fingerprint = ['foo', 'bar', 'baz']; | ||
| final user = User(id: '123', username: 'test'); | ||
| final crumb = Breadcrumb(message: 'bread'); | ||
| final scopeTagKey = 'scope-tag'; | ||
| final scopeTagValue = 'scope-tag-value'; | ||
| final eventTagKey = 'event-tag'; | ||
| final eventTagValue = 'event-tag-value'; | ||
| final scopeExtraKey = 'scope-extra'; | ||
| final scopeExtraValue = 'scope-extra-value'; | ||
| final eventExtraKey = 'event-extra'; | ||
| final eventExtraValue = 'event-extra-value'; | ||
|
|
||
| final event = SentryEvent( | ||
| tags: {eventTagKey: eventTagValue}, | ||
| extra: {eventExtraKey: eventExtraValue}, | ||
| level: SentryLevel.warning, | ||
| ); | ||
|
|
||
| final mockClient = MockClient((request) async { | ||
| if (request.method == 'POST') { | ||
| final body = const JsonDecoder().convert( | ||
| Utf8Codec().decode(request.bodyBytes), | ||
| ); | ||
|
|
||
| eventLevel = body['level']; | ||
| eventTransaction = body['transaction']; | ||
| eventFingerprint = body['fingerprint']; | ||
| userId = body['user']['id']; | ||
| eventBreadcrumbMessage = body['breadcrumbs']['values'].first['message']; | ||
| capturedScopeTagValue = body['tags'][scopeTagKey]; | ||
| capturedEventTagValue = body['tags'][eventTagKey]; | ||
| capturedScopeExtraValue = body['extra'][scopeExtraKey]; | ||
| capturedEventExtraValue = body['extra'][eventExtraKey]; | ||
|
|
||
| return Response('{"id": "test-event-id"}', 200); | ||
| } | ||
| fail( | ||
| 'Unexpected request on ${request.method} ${request.url} in HttpMock', | ||
| ); | ||
| }); | ||
|
|
||
| setUp(() { | ||
| options = SentryOptions(dsn: fakeDsn); | ||
| options.compressPayload = false; | ||
| options.httpClient = mockClient; | ||
| scope = Scope(options) | ||
| ..user = user | ||
| ..level = level | ||
| ..transaction = transaction | ||
| ..fingerprint = fingerprint | ||
| ..addBreadcrumb(crumb) | ||
| ..setTag(scopeTagKey, scopeTagValue) | ||
| ..setExtra(scopeExtraKey, scopeExtraValue); | ||
| }); | ||
|
|
||
| test('should apply the scope', () async { | ||
| final client = SentryClient(options); | ||
| await client.captureEvent(event, scope: scope); | ||
|
|
||
| expect(userId, user.id); | ||
| expect(eventLevel, SentryLevel.error.name); | ||
| expect(eventTransaction, transaction); | ||
| expect(eventFingerprint, fingerprint); | ||
| expect(eventBreadcrumbMessage, crumb.message); | ||
| expect(capturedScopeTagValue, scopeTagValue); | ||
| expect(capturedEventTagValue, eventTagValue); | ||
| expect(capturedScopeExtraValue, scopeExtraValue); | ||
| expect(capturedEventExtraValue, eventExtraValue); | ||
| }); | ||
| }); | ||
|
|
||
| group('SentryClient : apply partial scope to the captured event', () { | ||
| SentryOptions options; | ||
| String capturedLevel; | ||
| String capturedTransaction; | ||
| String capturedBreadcrumbMessage; | ||
| List<dynamic> capturedFingerprint; | ||
| String capturedUserId; | ||
| Scope scope; | ||
|
|
||
| final transaction = '/test/scope'; | ||
| final eventTransaction = '/event/transaction'; | ||
| final fingerprint = ['foo', 'bar', 'baz']; | ||
| final eventFingerprint = ['123', '456', '798']; | ||
| final user = User(id: '123'); | ||
| final eventUser = User(id: '987'); | ||
| final crumb = Breadcrumb(message: 'bread'); | ||
| final eventCrumbs = [Breadcrumb(message: 'bread')]; | ||
|
|
||
| final event = SentryEvent( | ||
| level: SentryLevel.warning, | ||
| transaction: eventTransaction, | ||
| userContext: eventUser, | ||
| fingerprint: eventFingerprint, | ||
| breadcrumbs: eventCrumbs, | ||
| ); | ||
|
|
||
| final mockClient = MockClient((request) async { | ||
| if (request.method == 'POST') { | ||
| final body = const JsonDecoder().convert( | ||
| Utf8Codec().decode(request.bodyBytes), | ||
| ); | ||
|
|
||
| capturedLevel = body['level']; | ||
| capturedTransaction = body['transaction']; | ||
| capturedFingerprint = body['fingerprint']; | ||
| capturedUserId = body['user']['id']; | ||
| capturedBreadcrumbMessage = | ||
| body['breadcrumbs']['values'].first['message']; | ||
|
|
||
| return Response('{"id": "test-event-id"}', 200); | ||
| } | ||
| fail( | ||
| 'Unexpected request on ${request.method} ${request.url} in HttpMock', | ||
| ); | ||
| }); | ||
|
|
||
| setUp(() { | ||
| options = SentryOptions(dsn: fakeDsn); | ||
| options.compressPayload = false; | ||
| options.httpClient = mockClient; | ||
| scope = Scope(options) | ||
| ..user = user | ||
| ..transaction = transaction | ||
| ..fingerprint = fingerprint | ||
| ..addBreadcrumb(crumb); | ||
| }); | ||
|
|
||
| test('should not apply the scope to non null event fields ', () async { | ||
| final client = SentryClient(options); | ||
| await client.captureEvent(event, scope: scope); | ||
|
|
||
| expect(capturedUserId, eventUser.id); | ||
| expect(capturedLevel, SentryLevel.warning.name); | ||
| expect(capturedTransaction, eventTransaction); | ||
| expect(capturedFingerprint, eventFingerprint); | ||
| expect(capturedBreadcrumbMessage, eventCrumbs.first.message); | ||
| }); | ||
| }); | ||
| */ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.