-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flutter): isar integration (#9181)
* Add isar page * Update docs/platforms/flutter/integrations/isar-instrumentation.mdx Co-authored-by: vivianyentran <[email protected]> * Update isar-instrumentation.mdx * update text --------- Co-authored-by: Giancarlo Buenaflor <[email protected]> Co-authored-by: vivianyentran <[email protected]>
- Loading branch information
1 parent
41d91f3
commit 1c6be04
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
docs/platforms/flutter/integrations/isar-instrumentation.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: Isar Database Instrumentation | ||
description: "Learn more about the Sentry Isar Database Instrumentation for the Flutter SDK." | ||
caseStyle: camelCase | ||
supportLevel: production | ||
sdk: sentry.dart.flutter | ||
categories: | ||
- mobile | ||
--- | ||
|
||
<Include name="feature-stage-beta.mdx" /> | ||
|
||
_(New in version 7.16.0)_ | ||
|
||
Isar is a fast cross-platform database for Flutter. | ||
The [sentry_isar](https://pub.dev/packages/sentry_isar) package provides `Isar` support for database instrumentation and allows you to track the performance of your queries. | ||
|
||
## Instrumentation Behaviour | ||
|
||
The created spans will be attached to the transaction on the scope. If no transaction is on the scope the Isar span will not be sent to Sentry. | ||
|
||
## Prerequisites | ||
|
||
Before starting, ensure: | ||
|
||
1. The Sentry Flutter SDK is initialized. Learn more [here](/platforms/flutter/#configure). | ||
2. Performance Monitoring is set up. Learn more [here](/platforms/flutter/performance/). | ||
|
||
## Install | ||
|
||
Add the `sentry_isar` dependency to install the Isar database instrumentation. | ||
|
||
```yml {filename:pubspec.yaml} | ||
dependencies: | ||
sentry_flutter: ^{{@inject packages.version('sentry.dart.flutter', '7.16.0') }} | ||
sentry_isar: ^{{@inject packages.version('sentry.dart.isar', '7.16.0') }} | ||
path_provider: ^2.0.0 | ||
``` | ||
## Configure | ||
Use `SentryIsar` to initialize the instance: | ||
|
||
```dart | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_isar/sentry_isar.dart'; | ||
import 'user.dart'; // Import your Isar model instead | ||
final dir = await getApplicationDocumentsDirectory(); | ||
final isar = await SentryIsar.open( | ||
[UserSchema], | ||
directory: dir.path, | ||
); | ||
``` | ||
|
||
## Verify | ||
|
||
### 1. Execute the Code | ||
|
||
```dart | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_isar/sentry_isar.dart'; | ||
import 'user.dart'; // Import your Isar model instead | ||
Future<void> runApp() async { | ||
final tr = Sentry.startTransaction('isarTest', 'db', bindToScope: true); | ||
final dir = await getApplicationDocumentsDirectory(); | ||
final isar = await SentryIsar.open( | ||
[UserSchema], | ||
directory: dir.path, | ||
); | ||
final newUser = User() | ||
..name = 'Joe Dirt' | ||
..age = 36; | ||
await isar.writeTxn(() async { | ||
await isar.users.put(newUser); // insert & update | ||
}); | ||
final existingUser = await isar.users.get(newUser.id); // get | ||
await isar.writeTxn(() async { | ||
await isar.users.delete(existingUser!.id); // delete | ||
}); | ||
await tr.finish(status: const SpanStatus.ok()); | ||
} | ||
``` | ||
|
||
### 2. View the Transaction on Sentry.io | ||
|
||
To view the recorded transaction, log into [sentry.io](https://sentry.io). Use the left sidebar to navigate to the **Performance** page. Select your project and scroll down to the transactions table to see the just recorded transaction with the name `isarTest`. You can also use the search bar to find the transaction. Click on the transaction to open its **Transaction Summary** page for more performance details. |