Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WIP Crashlytics guide #261

Merged
merged 2 commits into from
Jul 1, 2024
Merged
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
47 changes: 47 additions & 0 deletions src/content/docs/guides/crash-reporting/crashlytics.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Crashlytics Integration
description: Integrate Shorebird into your Crashlytics crash reporting
sidebar:
label: Crashlytics
order: 2
---

If you're using Crashlytics 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
Crashlytics 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 Crashlytics

If you haven't already, follow the Crashlytics [getting started with
Flutter](https://firebase.google.com/docs/crashlytics/get-started?platform=flutter) guide.

Update the Firebase init code to include the patch number as a custom key. This will look
something like:

```dart
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

final patchNumber = await ShorebirdCodePush().currentPatchNumber();

// 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.
FirebaseCrashlytics.instance.setCustomKey(
'shorebird_patch_number',
'$patchNumber',
);
runApp(const MyApp());
}
```