Skip to content
Merged
Show file tree
Hide file tree
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 Oct 26, 2020
a5e3fb8
options.compressPayload default value + minor
rxlabz Oct 26, 2020
4b5e8ea
captureMessage as a static method
rxlabz Oct 26, 2020
ee35bad
io example : send a formatted message
rxlabz Oct 26, 2020
51d18de
add a Dart web example
rxlabz Oct 26, 2020
f0ab2b9
changelog
rxlabz Oct 26, 2020
cc4e835
update web example
rxlabz Oct 26, 2020
c43d5bd
Merge remote-tracking branch 'origin/feature/unified-api' into fix/un…
rxlabz Oct 26, 2020
c2f89fa
Merge remote-tracking branch 'origin/feature/unified-api' into fix/un…
rxlabz Oct 26, 2020
27a8d31
add tests ( applyScope, captureMessage )
rxlabz Oct 26, 2020
070bfa5
minor
rxlabz Oct 26, 2020
eaa39e0
more applyScope tests
rxlabz Oct 26, 2020
352a270
refacto sentry client tests
rxlabz Oct 26, 2020
9c5110c
add a client.captureException test
rxlabz Oct 26, 2020
904b7b9
clean
rxlabz Oct 26, 2020
d0728c7
Update dart/examples/web_example/pubspec.yaml
rxlabz Oct 27, 2020
3f6f198
update the web example readme
rxlabz Oct 27, 2020
f5dc698
rename example methods
rxlabz Oct 27, 2020
c2e6b4d
clear the SentryOptions ctor
rxlabz Oct 27, 2020
fa1a8b1
refactor clients and update tests
rxlabz Oct 27, 2020
1f5828d
fix a test
rxlabz Oct 27, 2020
b0de53b
typo
rxlabz Oct 27, 2020
91beccc
clear tests
rxlabz Oct 27, 2020
1e36ab9
update examples
rxlabz Oct 27, 2020
d30a89b
move back example to /example ( pub.dev visibility)
rxlabz Oct 27, 2020
7b618c7
update example events
rxlabz Oct 27, 2020
edc6f35
update example events
rxlabz Oct 27, 2020
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
Prev Previous commit
Next Next commit
update web example
  • Loading branch information
rxlabz committed Oct 26, 2020
commit cc4e8354e452d328fcdc3d6090acdb41fe79d858
5 changes: 5 additions & 0 deletions dart/examples/web_example/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Sentry Dart : web example

```dart
pub get
webdev serve --release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's webdev? should we propose installing that?

In the Flutter Web example I used python3 which should be installed on macOS and Linux OOTB: https://github.com/getsentry/sentry-dart/blob/main/flutter/example/run.sh#L54

Not true for Windows though. So maybe a comment:

Suggested change
webdev serve --release
# Serve the static files with your preferred dev static site server
webdev serve --release

Copy link
Contributor Author

@rxlabz rxlabz Oct 27, 2020

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.

```

## more Resources

* [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/platforms/flutter/)
Expand Down
2 changes: 1 addition & 1 deletion dart/examples/web_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:

dependencies:
sentry:
path: /Users/rxlabz/projects/sentry/sentry-dart/dart
path: ../..

dev_dependencies:
build_runner: ^1.10.0
Expand Down
29 changes: 28 additions & 1 deletion dart/examples/web_example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,41 @@
<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>

<button id="bt">Capture</button>
<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>
41 changes: 26 additions & 15 deletions dart/examples/web_example/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,46 @@ const dsn =
void main() {
querySelector('#output').text = 'Your Dart app is running.';

querySelector('#bt').onClick.listen((event) => capture());
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 capture() async {
print('capture... ');
//final client = SentryClient(SentryOptions(dsn: dsn));
await captureCompleteExampleEvent();

final msgResultId = await Sentry.captureMessage(
void captureMessage() async {
print('Capturing Message : ');
final sentryId = await Sentry.captureMessage(
'Message 2',
template: 'Message %s',
params: ['2'],
);
print('capture message result : $msgResultId');
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 response = await Sentry.captureException(
final sentryId = await Sentry.captureException(
error,
stackTrace: stackTrace,
);

print('Capture exception : SentryId: ${response}');
}
print('Capture exception : SentryId: ${sentryId}');

await Sentry.close();
if (sentryId != SentryId.empty()) {
querySelector('#exceptionResult').style.display = 'block';
}
}
}

Future<void> captureCompleteExampleEvent() async {
Expand Down Expand Up @@ -120,10 +129,12 @@ Future<void> captureCompleteExampleEvent() async {

final sentryId = await Sentry.captureEvent(event);

print(
'\nReporting a complete event example: ${sdkName}',
);
print('\nReporting a complete event example: ${sdkName}');
print('Response SentryId: ${sentryId}');

if (sentryId != SentryId.empty()) {
querySelector('#eventResult').style.display = 'block';
}
}

Future<void> foo() async {
Expand Down