Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions src/includes/capture-error/dart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ try {
);
}
```

## Tips for Catching Errors

- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, e.g. using `Isolate.current.addErrorListener`, are captured automatically (Only for non-Web Apps).
- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException`
8 changes: 1 addition & 7 deletions src/includes/capture-error/flutter.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<PlatformContent includePath="capture-error/dart.mdx" />

## Tips for Catching Errors

- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- The SDK already runs your init `callback` on an error handler, such as using `runZonedGuarded`, are captured automatically
- Flutter-specific errors, such as using `FlutterError.onError`, are captured automatically
- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, such as using `Isolate.current.addErrorListener`, are captured automatically (only for non-Web Apps).
- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException`
- The SDK already runs your init `callback` on an error handler, such as using `runZonedGuarded`, are captured automatically
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
To track automatic [Breadcrumbs for HTTP requests](https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/#breadcrumb-types), you can add a Sentry wrapper that does it automatically for you.

This is only possible if you are using the [http.Client](https://pub.dev/documentation/http/latest/http/Client-class.html) class from the [http](https://pub.dev/packages/http) library.

The `SentryHttpClient` can be used as a standalone client like this:

```dart
import 'package:http/http.dart' as http;
import 'package:sentry/sentry.dart';

final client = SentryHttpClient();
try {
final url = 'https://example.com/whatsit/create';
final response = await client.post(url, body: {
'name': 'doodle',
'color': 'blue',
});
print('Response body: ${response.body}');
} finally {
client.close();
}
```

The `SentryHttpClient` can also be used as a wrapper for your own `HTTP Client`:

```dart
import 'package:http/http.dart' as http;
import 'package:sentry/sentry.dart';

final myClient = http.Client();
final client = SentryHttpClient(client: myClient);
try {
final url = 'https://example.com/whatsit/create';
final response = await client.post(url, body: {
'name': 'doodle',
'color': 'blue',
});
print('Response body: ${response.body}');
} finally {
client.close();
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ MaterialApp(
)
```

To track automatic Breadcrumbs for `HTTP` requests, check out the [SentryHttpClient](/platforms/dart/usage/advanced-usage/#automatic-breadcrumbs) Wrapper for the [http](https://pub.dev/packages/http) library.
To track automatic Breadcrumbs for `HTTP` requests, check out the [SentryHttpClient](/platforms/dart/enriching-events/breadcrumbs/#automatic-breadcrumbs) Wrapper for the [http](https://pub.dev/packages/http) library.
12 changes: 11 additions & 1 deletion src/includes/getting-started-primer/dart.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<Note>

Pure Dart SDK used by any Dart application like AngularDart, CLI and Server, it enables reporting messages and errors.
Sentry's Dart SDK enables automatic reporting of errors, messages, and exceptions. The SDK is available on GitHub [`sentry-dart`](https://github.com/getsentry/sentry-dart/). For Flutter apps, refer to [our Flutter documentation](/platforms/flutter) instead.

</Note>

**Features:**

- Breadcrumbs automatically captured:
- by the [Dart SDK](/platforms/dart/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- as well as `http` with the [Dart SDK](/platforms/dart/)
- [Attachments](/platforms/dart/enriching-events/attachments/) enrich your event by storing additional files, such as config or log files.
- [User Feedback](/platforms/dart/enriching-events/user-feedback/) provides the ability to collect user information when an event occurs.
- [Performance Monitoring](/product/performance/) creates transactions for:
- [HTTP requests](/platforms/dart/configuration/integrations/http-integration/#performance-monitoring-for-http-requests)
2 changes: 1 addition & 1 deletion src/platforms/common/enriching-events/tags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We’ll automatically index all tags for an event, as well as the frequency and

_Tag keys_ have a maximum length of 32 characters, while _tag values_ have a maximum length of 200 characters.

<PlatformSection notSupported={["native.minidumps", "native.ue4", "native.wasm", "php", "php.laravel", "php.symfony", "flutter"]}>
<PlatformSection notSupported={["native.minidumps", "native.ue4", "native.wasm", "php", "php.laravel", "php.symfony"]}>

Defining tags is easy, and will bind them to the [current scope](../scopes/) ensuring all future events within scope contain the same tags.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ The span finishes once the request has been executed. The span `status` depends

When the HTTP request throws an `Exception`, Sentry's SDK associates this exception to the running span. If you haven't set the SDK to swallow the exception and capture it, the span and SentryEvent will be linked when viewing it on the **Issue Details** page in sentry.io.

For more information see our [SentryHttpClient integration](/platforms/dart/usage/advanced-usage/#performance-monitoring-for-http-requests).
For more information see our [SentryHttpClient integration](/platforms/dart/configuration/integrations/http-integration/#performance-monitoring-for-http-requests).
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
---
title: Advanced Usage
title: HTTP Integration
sidebar_order: 2
redirect_from:
- /platforms/dart/usage/advanced-usage/
description: "Learn more about the Sentry HTTP integration for the Dart SDK."
---

## Requirements
<Note>

- For the usage of the Dart SDK, the minimal required Dart SDK version is `2.12.0`.
The minimum required Dart SDK version is `2.12.0`.

## Automatic Breadcrumbs

To track automatic [Breadcrumbs for HTTP requests](https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/#breadcrumb-types), you can add a Sentry wrapper that does it automatically for you.

This is only possible if you are using the [http.Client](https://pub.dev/documentation/http/latest/http/Client-class.html) class from the [http](https://pub.dev/packages/http) library.

The `SentryHttpClient` can be used as a standalone client like this:

```dart
import 'package:http/http.dart' as http;
import 'package:sentry/sentry.dart';

final client = SentryHttpClient();
try {
final url = 'https://example.com/whatsit/create';
final response = await client.post(url, body: {
'name': 'doodle',
'color': 'blue',
});
print('Response body: ${response.body}');
} finally {
client.close();
}
```

The `SentryHttpClient` can also be used as a wrapper for your own `HTTP Client`:

```dart
import 'package:http/http.dart' as http;
import 'package:sentry/sentry.dart';

final myClient = http.Client();
final client = SentryHttpClient(client: myClient);
try {
final url = 'https://example.com/whatsit/create';
final response = await client.post(url, body: {
'name': 'doodle',
'color': 'blue',
});
print('Response body: ${response.body}');
} finally {
client.close();
}
```
</Note>

## Reporting Bad HTTP Requests as Errors

Expand Down Expand Up @@ -118,10 +78,3 @@ var uriResponse = await client.post('https://example.com/whatsit/create',

await transaction.finish(status: SpanStatus.ok());
```

## Tips for Catching Errors

- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, e.g. using `Isolate.current.addErrorListener`, are captured automatically (Only for non-Web Apps).
- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException`
7 changes: 7 additions & 0 deletions src/platforms/dart/configuration/integrations/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Integrations
sidebar_order: 10
description: "Learn more about how integrations extend the functionality of our SDK to cover common libraries and environments automatically."
---

<PageGrid />
29 changes: 0 additions & 29 deletions src/platforms/dart/index.mdx

This file was deleted.

47 changes: 24 additions & 23 deletions src/platforms/dart/migration.mdx
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
---
title: Migration Guide
sidebar_order: 1000
description: "Migrate between versions of Sentry's SDK for Dart."
---

## Migrating From `sentry` `5.1.x` to `sentry` `6.0.0`

* `Sentry.currentHub` was removed. Please use the static methods on `Sentry`
* `SentryOptions.cacheDirSize` was renamed to `SentryOptions.maxCacheItems`
* `EventProcessor` was changed from a callback to an interface
* The data type from the following options was changed from `int` to `Duration`. The old options are still present but deprecated and will be removed in a future version.
* `SentryOptions.autoSessionTrackingIntervalMillis` to `SentryOptions.autoSessionTrackingInterval`
* `SentryOptions.anrTimeoutIntervalMillis` to `SentryOptions.anrTimeoutInterval`
* The `beforeSend` callback now accepts async code. The method signature changed from `SentryEvent? Function(SentryEvent event, {dynamic hint});` to `FutureOr<SentryEvent?> Function(SentryEvent event, {dynamic hint});`. While this is technically a breaking change, your code probably is still valid.
* Sentry accepts multiple exceptions and multiple threads. If you haven't set exceptions, there's no need to do anything.
- `Sentry.currentHub` was removed. Please use the static methods on `Sentry`
- `SentryOptions.cacheDirSize` was renamed to `SentryOptions.maxCacheItems`
- `EventProcessor` was changed from a callback to an interface
- The data type from the following options was changed from `int` to `Duration`. The old options are still present but deprecated and will be removed in a future version.
- `SentryOptions.autoSessionTrackingIntervalMillis` to `SentryOptions.autoSessionTrackingInterval`
- `SentryOptions.anrTimeoutIntervalMillis` to `SentryOptions.anrTimeoutInterval`
- The `beforeSend` callback now accepts async code. The method signature changed from `SentryEvent? Function(SentryEvent event, {dynamic hint});` to `FutureOr<SentryEvent?> Function(SentryEvent event, {dynamic hint});`. While this is technically a breaking change, your code probably is still valid.
- Sentry accepts multiple exceptions and multiple threads. If you haven't set exceptions, there's no need to do anything.

### Sentry Self-hosted Compatibility

* Starting with version `6.0.0` of the `sentry`, [Sentry's version >= v20.6.0](https://github.com/getsentry/self-hosted/releases) is required. This only applies to self-hosted Sentry. If you are using [sentry.io](https://sentry.io), no action is needed.
- Starting with version `6.0.0` of the `sentry`, [Sentry's version >= v20.6.0](https://github.com/getsentry/self-hosted/releases) is required. This only applies to self-hosted Sentry. If you are using [sentry.io](https://sentry.io), no action is needed.

## Migrating From `sentry` `4.0.x` to `sentry` `5.0.0`

* Sentry's Dart SDK version 5.0.0 and above requires Dart 1.12.0
* Fix: Prefix classes with Sentry
* A couple of classes were often conflicting with user's code.
- Sentry's Dart SDK version 5.0.0 and above requires Dart 1.12.0
- Fix: Prefix classes with Sentry
- A couple of classes were often conflicting with user's code.
As a result, this change renames the following classes:
* `App` -> `SentryApp`
* `Browser` -> `SentryBrowser`
* `Device` -> `SentryDevice`
* `Gpu` -> `SentryGpu`
* `Integration` -> `SentryIntegration`
* `Message` -> `SentryMessage`
* `OperatingSystem` -> `SentryOperatingSystem`
* `Orientation` -> `SentryOrientation`
* `Request` -> `SentryRequest`
* `User` -> `SentryUser`
* Return type of `Sentry.close()` changed from `void` to `Future<void>` and `Integration.close()` changed from `void` to `FutureOr<void>`
- `App` -> `SentryApp`
- `Browser` -> `SentryBrowser`
- `Device` -> `SentryDevice`
- `Gpu` -> `SentryGpu`
- `Integration` -> `SentryIntegration`
- `Message` -> `SentryMessage`
- `OperatingSystem` -> `SentryOperatingSystem`
- `Orientation` -> `SentryOrientation`
- `Request` -> `SentryRequest`
- `User` -> `SentryUser`
- Return type of `Sentry.close()` changed from `void` to `Future<void>` and `Integration.close()` changed from `void` to `FutureOr<void>`
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The span finishes once the request has been executed. The span `status` depends

When the HTTP request throws an `Exception`, Sentry's SDK associates this exception to the running span. If you haven't set the SDK to swallow the exception and capture it, the span and SentryEvent will be linked when viewing it on the **Issue Details** page in sentry.io.

For more information see our [SentryHttpClient integration](/platforms/dart/usage/advanced-usage/#performance-monitoring-for-http-requests).
For more information see our [SentryHttpClient integration](/platforms/dart/configuration/integrations/http-integration/#performance-monitoring-for-http-requests).

### Routing Instumentation

Expand Down
4 changes: 2 additions & 2 deletions src/wizard/dart/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ support_level: production
type: framework
---

Get the SDK from [pub.dev](https://pub.dev/packages/sentry) by adding the following to your `pubspec.yaml`:
Sentry captures data by using an SDK within your application’s runtime. Add the following to your `pubspec.yaml`:

```yml {filename:pubspec.yaml}
dependencies:
Expand All @@ -27,7 +27,7 @@ Future<void> main() async {
}
```

Capture a test exception:
Then create an intentional error, so you can test that everything is working:

```dart
import 'package:sentry/sentry.dart';
Expand Down