Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 2.43 KB

index.mdx

File metadata and controls

93 lines (66 loc) · 2.43 KB
title caseStyle supportLevel sdk categories
Dart
camelCase
production
sentry.dart
mobile
browser
server

On this page, we get you up and running with Sentry's Dart SDK.

If you don't already have an account and Sentry project established, head over to sentry.io, then return to this page.

Features

In addition to capturing errors, you can monitor interactions between multiple services or applications by enabling tracing.

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

Sentry provides a dedicated Flutter SDK as well.

Install

<OnboardingOptionButtons options={[ 'error-monitoring', 'performance' ]} />

Sentry captures data by using an SDK within your application's runtime.

dependencies:
  sentry: ^{{@inject packages.version('sentry.dart') }}

Configure

To capture all errors, initialize the Sentry Dart SDK as soon as possible.

import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init((options) {
    options.dsn = '___PUBLIC_DSN___';
    // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
    // We recommend adjusting this value in production.
    options.tracesSampleRate = 1.0;
    // Adds request headers and IP for users,
    // visit: https://docs.sentry.io/platforms/dart/data-management/data-collected/ for more info
    options.sendDefaultPii = true;
  });

  // you can also configure SENTRY_DSN, SENTRY_RELEASE, SENTRY_DIST, and
  // SENTRY_ENVIRONMENT via Dart environment variable (--dart-define)
}

Verify

Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

import 'package:sentry/sentry.dart';

try {
  throw Exception('Sentry Test Error');
} catch (exception, stackTrace) {
  await Sentry.captureException(
    exception,
    stackTrace: stackTrace,
  );
}

Next Steps

  • Learn about the features of Sentry's Dart SDK
  • Add performance instrumentation to your app