-
-
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
Changes from 15 commits
28792c6
a5e3fb8
4b5e8ea
ee35bad
51d18de
f0ab2b9
cc4e835
c43d5bd
c2f89fa
27a8d31
070bfa5
eaa39e0
352a270
9c5110c
904b7b9
d0728c7
3f6f198
f5dc698
c2e6b4d
fa1a8b1
1f5828d
b0de53b
91beccc
1e36ab9
d30a89b
7b618c7
edc6f35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,6 @@ ios/ | |
| build/ | ||
| .cxx/ | ||
|
|
||
|
|
||
| .test_coverage.dart | ||
| dart/coverage/* | ||
| 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/ |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||
| # Sentry Dart : web example | ||||||||
|
|
||||||||
| ```dart | ||||||||
| pub get | ||||||||
| webdev serve --release | ||||||||
|
||||||||
| webdev serve --release | |
| # Serve the static files with your preferred dev static site server | |
| webdev serve --release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the Dart cli to run and build Dart web projects.
To be served from a static site server, the project needs to be build (webdev build ...) .
webdev serve is simplest/fastest way to run this example, so I just added a link to the webdev page.
marandaneto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| 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. | ||
marandaneto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # version: 1.0.0 | ||
| #homepage: https://www.example.com | ||
|
|
||
| environment: | ||
| sdk: '>=2.0.0 <3.0.0' | ||
rxlabz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| dependencies: | ||
| sentry: | ||
| path: ../.. | ||
|
|
||
| dev_dependencies: | ||
| build_runner: ^1.10.0 | ||
| build_web_compilers: ^2.13.0 | ||
| pedantic: ^1.9.0 | ||
| 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> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import 'dart:async'; | ||
| import 'dart:html'; | ||
|
|
||
| import 'package:sentry/sentry.dart'; | ||
|
|
||
| const dsn = | ||
| 'https://[email protected]/5428562'; | ||
|
|
||
| void main() { | ||
| querySelector('#output').text = 'Your Dart app is running.'; | ||
|
|
||
| querySelector('#btEvent') | ||
| .onClick | ||
| .listen((event) => captureCompleteExampleEvent()); | ||
| querySelector('#btMessage').onClick.listen((event) => captureMessage()); | ||
| querySelector('#btException').onClick.listen((event) => captureException()); | ||
|
|
||
| Sentry.init((options) => options.dsn = dsn); | ||
| } | ||
|
|
||
| void captureMessage() async { | ||
| print('Capturing Message : '); | ||
| final sentryId = await Sentry.captureMessage( | ||
| 'Message 2', | ||
| template: 'Message %s', | ||
| params: ['2'], | ||
| ); | ||
| print('capture message result : $sentryId'); | ||
| if (sentryId != SentryId.empty()) { | ||
| querySelector('#messageResult').style.display = 'block'; | ||
| } | ||
| await Sentry.close(); | ||
| } | ||
|
|
||
| void captureException() async { | ||
| try { | ||
| await foo(); | ||
| } catch (error, stackTrace) { | ||
| print('\nReporting the following stack trace: '); | ||
| print(stackTrace); | ||
| final sentryId = await Sentry.captureException( | ||
| error, | ||
| stackTrace: stackTrace, | ||
| ); | ||
|
|
||
| print('Capture exception : SentryId: ${sentryId}'); | ||
|
|
||
| if (sentryId != SentryId.empty()) { | ||
| querySelector('#exceptionResult').style.display = 'block'; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Future<void> captureCompleteExampleEvent() async { | ||
| final event = SentryEvent( | ||
| logger: 'main', | ||
| serverName: 'server.dart', | ||
| 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'}, | ||
| 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', | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| final sentryId = await Sentry.captureEvent(event); | ||
|
|
||
| print('\nReporting a complete event example: ${sdkName}'); | ||
| print('Response SentryId: ${sentryId}'); | ||
|
|
||
| if (sentryId != SentryId.empty()) { | ||
| querySelector('#eventResult').style.display = 'block'; | ||
| } | ||
| } | ||
|
|
||
| Future<void> foo() async { | ||
| await bar(); | ||
| } | ||
|
|
||
| Future<void> bar() async { | ||
| await baz(); | ||
| } | ||
|
|
||
| Future<void> baz() async { | ||
| throw StateError('This is a test error'); | ||
| } | ||
marandaneto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| @import url(https://fonts.googleapis.com/css?family=Roboto); | ||
|
|
||
| html, body { | ||
| width: 100%; | ||
| height: 100%; | ||
| margin: 0; | ||
| padding: 0; | ||
| font-family: 'Roboto', sans-serif; | ||
| } | ||
|
|
||
| #output { | ||
| padding: 20px; | ||
| text-align: center; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.