---
title: "Sentry Integration"
description: "Tag Sentry events with the Shorebird patch number, so you can tell which patch a crash came from."
---

Sentry reports crashes from Shorebird releases and patches with no extra setup. If you have multiple patches, it can be unclear which patch caused the crash. This document shows how to include the Shorebird patch number in your Sentry events so you can differentiate between patches.

If you build with `--obfuscate` or `--split-debug-info`, upload each patch’s symbols on Android. On iOS, Sentry can’t yet show names for Dart frames in code a patch changed. See [Reading crashes from patches](/code-push/crash-reporting/uploading-symbols/#reading-crashes-from-patches).

If crashes start after a patch installs, see [App crashes after a patch installs](/code-push/troubleshooting/#app-crashes-after-a-patch-installs).

## Add the `shorebird_code_push` package to your project.

[shorebird\_code\_push](https://pub.dev/packages/shorebird_code_push) is available on pub.dev and lets you programmatically determine your app’s current patch number. To add it to your project, follow the instructions on the package’s pub.dev page.

## Configure Sentry

If you haven’t already, follow the Sentry [getting started with Flutter](https://docs.sentry.io/platforms/dart/guides/flutter/) guide.

Update the Sentry init code to include the patch number as a tag. This will look something like:

```
Future<void> main() async {
  // Get the current patch number. This will be null if no patch is installed.
  final patch = await ShorebirdUpdater().readCurrentPatch();

  await SentryFlutter.init(
    (options) {
      options.dsn = 'YOUR_DSN';
    },
    appRunner: () {
      // Add the patch number as a tag. You can use whatever name you would like
      // as the key. `$patch` will be "null" if there is no patch. You may
      // wish to handle this case differently.
      Sentry.configureScope((scope) {
        scope.setTag('shorebird_patch_number', '${patch?.number}');
      });
      return runApp(const MyApp());
    },
  );
}
```
