Repository navigation
refactor: sentry #1918
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
base: develop
Are you sure you want to change the base?
refactor: sentry #1918
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import 'package:logger/logger.dart'; | ||
| import 'package:sentry_flutter/sentry_flutter.dart'; | ||
| import 'package:uni/controller/background_workers/notifications.dart'; | ||
| import 'package:workmanager/workmanager.dart'; | ||
|
|
||
|
|
@@ -17,6 +18,7 @@ const taskMap = { | |
| // when the app is completely terminated | ||
| Future<void> workerStartCallback() async { | ||
| Workmanager().executeTask((taskName, inputData) async { | ||
| final transaction = Sentry.startTransaction(taskName, 'background_worker'); | ||
| try { | ||
| Logger().d('''[$taskName]: Start executing job...'''); | ||
|
|
||
|
|
@@ -31,18 +33,24 @@ Future<void> workerStartCallback() async { | |
| await value.$1(); | ||
| } | ||
| }); | ||
| transaction.status = const SpanStatus.ok(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Await the iOS tasks before marking the transaction successful.
This remains incorrect after background Sentry initialization is fixed. Replace the asynchronous 🤖 Prompt for AI Agents |
||
| return true; | ||
| } | ||
| // try to keep the usage of this function BELOW +-30 seconds | ||
| // to not be punished by the scheduler in future runs. | ||
| await taskMap[taskName]!.$1(); | ||
| transaction.status = const SpanStatus.ok(); | ||
| } catch (err, st) { | ||
| transaction.status = const SpanStatus.internalError(); | ||
| await Sentry.captureException(err, stackTrace: st); | ||
| Logger().e( | ||
| 'Error while running $taskName job:', | ||
| error: err, | ||
| stackTrace: st, | ||
| ); | ||
| return false; | ||
| } finally { | ||
| await transaction.finish(); | ||
| } | ||
| return true; | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Initialize Sentry in the background isolate.
Workmanager runs this callback in a separate isolate. Initialization in
packages/uni_app/lib/main.dartdoes not initialize that isolate. (github.com)Sentry starts with a no-op hub and queue. This transaction and the background exception captures therefore produce no reports. (raw.githubusercontent.com)
Initialize a Dart Sentry client before
startTransaction. Share the DSN, sampling settings, and privacy filters with the main-isolate configuration.🤖 Prompt for AI Agents