-
-
Notifications
You must be signed in to change notification settings - Fork 277
feature: Unified API #117
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
feature: Unified API #117
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
163cce7
Merge branch 'main' into feature/unified-api
marandaneto b91c954
Merge branch 'main' into feature/unified-api
marandaneto 5018978
feat : static SDK main entry withSentry.init(options),... (#108)
rxlabz d577e35
Feat : add a Hub class (#113)
rxlabz fabf56f
feat: sentry options (#116)
marandaneto 2b36bec
ref: Hub passes the Scope (#114)
marandaneto af3ecc0
Refacto : initialize SentryClient with SentryOptions (#118)
rxlabz 19f5592
ref: SentryId generates UUID (#119)
marandaneto b51b0da
ref: Event now is SentryEvent and added GPU (#121)
marandaneto 3fa0b79
feat: before breadcrumb and scope ref (#122)
marandaneto 2cc1d78
Ref: Hint is passed across Sentry static class, Hub and Client (#124)
marandaneto 11b821b
Ref: Remove stackFrameFilter in favor of beforeSendCallback (#125)
marandaneto ee737a2
Ref: Sentry init with null and empty DSN and close method (#126)
marandaneto eab4ccf
Refacto : add a Transport class (#123)
rxlabz c301ec6
Ref: execute before send callback (#128)
marandaneto 1794f04
feat: addBreadcrumb to the Sentry static API (#133)
marandaneto e7db5d1
Feat: add lastEventId to the Sentry static API (#134)
marandaneto dc962ae
Fix: Breadcrumb data should accept serializable types and not only St…
marandaneto b9cd68b
Fix: NoOp encode for Web (#138)
marandaneto 7b81890
Fix: execute Integrations on Hub creation (#136)
marandaneto b1761f4
unified api fixes and add web example (#137)
rxlabz d249c97
Ref/prepare event & scope.applyToEvent (#140)
rxlabz dc258d9
Ref : rename files accordely to their content (#141)
rxlabz c6669c3
rename the `throwable` argument to `exception` (#142)
rxlabz a0bb939
lint : prefer relative imports and show error when a @required argume…
rxlabz a7ca364
fix: Unified API code review (#144)
marandaneto 56ac62a
Ref : remove dsn from Transport public API (#145)
rxlabz 209f18a
Fix the pubspecs SDK constraints (#146)
rxlabz 108ac6c
fix : throws on invalid dsn (#148)
rxlabz a81da3e
add comment to change the DSN
marandaneto c1812b7
update the workflow to run both on vm and on browser (#150)
rxlabz f597604
Bump sentry sdk to 4.0.0-alpha.1 (#151)
marandaneto 6d9caff
remove TODOs
marandaneto 32debd7
fix the web example pubspec (#153)
rxlabz c80365f
Ref: remove platform specific clients to use SentryClient (#152)
rxlabz 2ed0f92
fix conflict
marandaneto c3ab59f
rewrite changelog
marandaneto 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
unified api fixes and add web example (#137)
- Loading branch information
commit b1761f4615658b4cb17708f3acbe2e6ee55fd9e9
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,6 @@ ios/ | |
| build/ | ||
| .cxx/ | ||
|
|
||
|
|
||
| .test_coverage.dart | ||
| dart/coverage/* | ||
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 |
|---|---|---|
|
|
@@ -6,43 +6,45 @@ final event = SentryEvent( | |
| release: '1.4.0-preview.1', | ||
| environment: 'Test', | ||
| message: Message('This is an example Dart event.'), | ||
| transaction: '/example/app', | ||
| level: SentryLevel.warning, | ||
| tags: const <String, String>{'project-id': '7371'}, | ||
| extra: const <String, String>{'company-name': 'Dart Inc'}, | ||
| extra: const <String, String>{'section': '1'}, | ||
| fingerprint: const <String>['example-dart'], | ||
| userContext: const User( | ||
| id: '800', | ||
| username: 'first-user', | ||
| email: '[email protected]', | ||
| ipAddress: '127.0.0.1', | ||
| extras: <String, String>{'first-sign-in': '2020-01-01'}), | ||
| id: '800', | ||
| username: 'first-user', | ||
| email: '[email protected]', | ||
| ipAddress: '127.0.0.1', | ||
| extras: <String, String>{'first-sign-in': '2020-01-01'}, | ||
| ), | ||
| breadcrumbs: [ | ||
| Breadcrumb( | ||
| message: 'UI Lifecycle', | ||
| timestamp: DateTime.now().toUtc(), | ||
| category: 'ui.lifecycle', | ||
| type: 'navigation', | ||
| data: {'screen': 'MainActivity', 'state': 'created'}, | ||
| level: SentryLevel.info) | ||
| message: 'UI Lifecycle', | ||
| timestamp: DateTime.now().toUtc(), | ||
| category: 'ui.lifecycle', | ||
| type: 'navigation', | ||
| data: {'screen': 'MainActivity', 'state': 'created'}, | ||
| level: SentryLevel.info, | ||
| ) | ||
| ], | ||
| contexts: Contexts( | ||
| operatingSystem: const OperatingSystem( | ||
| name: 'Android', | ||
| version: '5.0.2', | ||
| build: 'LRX22G.P900XXS0BPL2', | ||
| kernelVersion: | ||
| 'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016', | ||
| rooted: false), | ||
| name: 'Android', | ||
| version: '5.0.2', | ||
| build: 'LRX22G.P900XXS0BPL2', | ||
| kernelVersion: | ||
| 'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016', | ||
| rooted: false, | ||
| ), | ||
| runtimes: [const Runtime(name: 'ART', version: '5')], | ||
| app: App( | ||
| name: 'Example Dart App', | ||
| version: '1.42.0', | ||
| identifier: 'HGT-App-13', | ||
| build: '93785', | ||
| buildType: 'release', | ||
| deviceAppHash: '5afd3a6', | ||
| startTime: DateTime.now().toUtc()), | ||
| name: 'Example Dart App', | ||
| version: '1.42.0', | ||
| identifier: 'HGT-App-13', | ||
| build: '93785', | ||
| buildType: 'release', | ||
| deviceAppHash: '5afd3a6', | ||
| startTime: DateTime.now().toUtc(), | ||
| ), | ||
| browser: const Browser(name: 'Firefox', version: '42.0.1'), | ||
| device: Device( | ||
| name: 'SM-P900', | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -3,32 +3,72 @@ | |
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:sentry/sentry.dart'; | ||
|
|
||
| import 'event_example.dart'; | ||
|
|
||
| /// Sends a test exception report to Sentry.io using this Dart client. | ||
| Future<void> main(List<String> rawArgs) async { | ||
| if (rawArgs.length != 1) { | ||
| stderr.writeln( | ||
| 'Expected exactly one argument, which is the DSN issued by Sentry.io to your project.'); | ||
| exit(1); | ||
| } | ||
| Future<void> main() async { | ||
| const dsn = | ||
| 'https://[email protected]/5428562'; | ||
|
|
||
| SentryEvent processTagEvent(SentryEvent event, Object hint) => | ||
| event..tags.addAll({'page-locale': 'en-us'}); | ||
|
|
||
| Sentry.init((options) => options | ||
| ..dsn = dsn | ||
| ..addEventProcessor(processTagEvent)); | ||
|
|
||
| Sentry.addBreadcrumb( | ||
| Breadcrumb( | ||
| message: 'Authenticated user', | ||
| category: 'auth', | ||
| type: 'debug', | ||
| data: { | ||
| 'admin': true, | ||
| 'permissions': [1, 2, 3] | ||
| }, | ||
| ), | ||
| ); | ||
|
|
||
| final dsn = rawArgs.single; | ||
| Sentry.init((options) => options.dsn = dsn); | ||
| Sentry.configureScope((scope) { | ||
| scope | ||
| ..user = User( | ||
| id: '800', | ||
| username: 'first-user', | ||
| email: '[email protected]', | ||
| ipAddress: '127.0.0.1', | ||
| extras: <String, String>{'first-sign-in': '2020-01-01'}, | ||
| ) | ||
| ..fingerprint = ['example-dart'] | ||
| ..transaction = '/example/app' | ||
| ..level = SentryLevel.warning | ||
| ..setTag('build', '579') | ||
| ..setExtra('company-name', 'Dart Inc'); | ||
| }); | ||
|
|
||
| print('\nReporting a complete event example: '); | ||
|
|
||
| // Sends a full Sentry event payload to show the different parts of the UI. | ||
| final sentryId = await Sentry.captureEvent(event); | ||
|
|
||
| print('SentryId : ${sentryId}'); | ||
| print('Capture event result : SentryId : ${sentryId}'); | ||
|
|
||
| print('\nCapture message: '); | ||
|
|
||
| // Sends a full Sentry event payload to show the different parts of the UI. | ||
| final messageSentryId = await Sentry.captureMessage( | ||
| 'Message 1', | ||
| level: SentryLevel.warning, | ||
| template: 'Message %s', | ||
| params: ['1'], | ||
| ); | ||
|
|
||
| print('Capture message result : SentryId : ${messageSentryId}'); | ||
|
|
||
| try { | ||
| await foo(); | ||
| await loadConfig(); | ||
| } catch (error, stackTrace) { | ||
| print('\nReporting the following stack trace: '); | ||
| print(stackTrace); | ||
|
|
@@ -37,22 +77,22 @@ Future<void> main(List<String> rawArgs) async { | |
| stackTrace: stackTrace, | ||
| ); | ||
|
|
||
| print('SentryId : ${sentryId}'); | ||
| print('Capture exception result : SentryId : ${sentryId}'); | ||
| } finally { | ||
| await Sentry.close(); | ||
| } | ||
|
|
||
| /* TODO(rxlabz) Sentry CaptureMessage(message, level) */ | ||
| } | ||
|
|
||
| Future<void> foo() async { | ||
| await bar(); | ||
| Future<void> loadConfig() async { | ||
| await parseConfig(); | ||
| } | ||
|
|
||
| Future<void> bar() async { | ||
| await baz(); | ||
| Future<void> parseConfig() async { | ||
| await decode(); | ||
| } | ||
|
|
||
| Future<void> baz() async { | ||
| Future<void> decode() async { | ||
| throw StateError('This is a test error'); | ||
| } | ||
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,9 @@ | ||
| # Files and directories created by pub | ||
| .dart_tool/ | ||
| .packages | ||
|
|
||
| # Conventional directory for build outputs | ||
| build/ | ||
|
|
||
| # Directory created by dartdoc | ||
| doc/api/ |
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,9 @@ | ||
| # Sentry Dart : web example | ||
|
|
||
| ```dart | ||
| pub get | ||
|
|
||
| # run the project ( see https://dart.dev/tools/webdev#serve ) | ||
| webdev serve --release | ||
|
|
||
| ``` |
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,16 @@ | ||
| name: sentry_dart_web_example | ||
| description: An absolute bare-bones web app. | ||
| # version: 1.0.0 | ||
| #homepage: https://www.example.com | ||
|
|
||
| environment: | ||
| sdk: ^2.0.0 | ||
|
|
||
| dependencies: | ||
| sentry: | ||
| path: ../.. | ||
|
|
||
| dev_dependencies: | ||
| build_runner: ^1.10.0 | ||
| build_web_compilers: ^2.13.0 | ||
| pedantic: ^1.9.0 | ||
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,77 @@ | ||
| import 'package:sentry/src/protocol.dart'; | ||
|
|
||
| final event = SentryEvent( | ||
| logger: 'main', | ||
| serverName: 'server.dart', | ||
| release: '1.4.0-preview.1', | ||
| environment: 'Test', | ||
| message: Message('This is an example Dart event.'), | ||
| tags: const <String, String>{'project-id': '7371'}, | ||
| extra: const <String, String>{'section': '1'}, | ||
| fingerprint: const <String>['example-dart'], | ||
| userContext: const User( | ||
| id: '800', | ||
| username: 'first-user', | ||
| email: '[email protected]', | ||
| ipAddress: '127.0.0.1', | ||
| extras: <String, String>{'first-sign-in': '2020-01-01'}, | ||
| ), | ||
| breadcrumbs: [ | ||
| Breadcrumb( | ||
| message: 'UI Lifecycle', | ||
| timestamp: DateTime.now().toUtc(), | ||
| category: 'ui.lifecycle', | ||
| type: 'navigation', | ||
| data: {'screen': 'MainActivity', 'state': 'created'}, | ||
| level: SentryLevel.info, | ||
| ) | ||
| ], | ||
| contexts: Contexts( | ||
| operatingSystem: const OperatingSystem( | ||
| name: 'Android', | ||
| version: '5.0.2', | ||
| build: 'LRX22G.P900XXS0BPL2', | ||
| kernelVersion: | ||
| 'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016', | ||
| rooted: false, | ||
| ), | ||
| runtimes: [const Runtime(name: 'ART', version: '5')], | ||
| app: App( | ||
| name: 'Example Dart App', | ||
| version: '1.42.0', | ||
| identifier: 'HGT-App-13', | ||
| build: '93785', | ||
| buildType: 'release', | ||
| deviceAppHash: '5afd3a6', | ||
| startTime: DateTime.now().toUtc(), | ||
| ), | ||
| browser: const Browser(name: 'Firefox', version: '42.0.1'), | ||
| device: Device( | ||
| name: 'SM-P900', | ||
| family: 'SM-P900', | ||
| model: 'SM-P900 (LRX22G)', | ||
| modelId: 'LRX22G', | ||
| arch: 'armeabi-v7a', | ||
| batteryLevel: 99, | ||
| orientation: Orientation.landscape, | ||
| manufacturer: 'samsung', | ||
| brand: 'samsung', | ||
| screenResolution: '2560x1600', | ||
| screenDensity: 2.1, | ||
| screenDpi: 320, | ||
| online: true, | ||
| charging: true, | ||
| lowMemory: true, | ||
| simulator: false, | ||
| memorySize: 1500, | ||
| freeMemory: 200, | ||
| usableMemory: 4294967296, | ||
| storageSize: 4294967296, | ||
| freeStorage: 2147483648, | ||
| externalStorageSize: 8589934592, | ||
| externalFreeStorage: 2863311530, | ||
| bootTime: DateTime.now().toUtc(), | ||
| timezone: 'America/Toronto', | ||
| ), | ||
| ), | ||
| ); |
Binary file not shown.
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,49 @@ | ||
| <!DOCTYPE html> | ||
|
|
||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta name="scaffolded-by" content="https://github.com/dart-lang/stagehand"> | ||
| <title>dart_web</title> | ||
| <link rel="stylesheet" href="styles.css"> | ||
| <link rel="icon" href="favicon.ico"> | ||
|
|
||
| <style> | ||
| .bloc { | ||
| display: flex; | ||
| margin: 1rem; | ||
| } | ||
|
|
||
| .result { | ||
| padding-left: 1rem; | ||
| color: green; | ||
| display: none; | ||
| } | ||
| </style> | ||
|
|
||
| <script defer src="main.dart.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| <div id="output"></div> | ||
|
|
||
| <div class="bloc"> | ||
| <button id="btEvent">Capture Event</button> | ||
| <div id="eventResult" class="result">Captured</div> | ||
| </div> | ||
|
|
||
| <div class="bloc"> | ||
| <button id="btMessage">Capture Message</button> | ||
| <div id="messageResult" class="result">Captured</div> | ||
| </div> | ||
|
|
||
| <div class="bloc"> | ||
| <button id="btException">Capture Exception</button> | ||
| <div id="exceptionResult" class="result">Captured</div> | ||
| </div> | ||
|
|
||
| </body> | ||
| </html> |
Oops, something went wrong.
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.