Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sentry integration guide
Browse files Browse the repository at this point in the history
bryanoltman committed Jun 28, 2024
1 parent 8942867 commit 799d33f
Showing 2 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -109,6 +109,12 @@ export default defineConfig({
directory: 'ci',
},
},
{
label: 'Crash Reporting',
autogenerate: {
directory: 'guides/crash-reporting',
},
},
{
label: 'Flutter Version',
link: '/flutter-version',
49 changes: 49 additions & 0 deletions src/content/docs/guides/crash-reporting/sentry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Sentry Integration
description: Integrate Shorebird into your Sentry crash reporting
sidebar:
label: Sentry
order: 1
---

If you're using Sentry for crash reporting, it will work out-of-the-box with
Shorebird releases and patches. However, if you have multiple patches, it can be
unclear which patch caused the crash. This document shows how you can use Sentry
tags to differentiate between patches.

## 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/flutter/) guide.

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

```dart
Future<void> main() async {
// Get the current patch number. This will be null if no patch is installed.
final patchNumber = await ShorebirdCodePush().currentPatchNumber();
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. `$patchNumber` will be "null" if there is no patch. You may
// wish to handle this case differently.
Sentry.configureScope((scope) {
scope.setTag('shorebird_patch_number', '$patchNumber');
});
return runApp(const MyApp());
,
);
}
```

0 comments on commit 799d33f

Please sign in to comment.