Skip to content

Commit 8c26652

Browse files
committed
feat: integrate Sentry for error tracking
1 parent 77c29e4 commit 8c26652

10 files changed

Lines changed: 154 additions & 6 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ app.*.map.json
5050
/android/app/release
5151

5252
# Inno
53-
/inno/Output
53+
/inno/Output
54+
sentry.properties
55+
sentry-wizard

lib/main.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:windows_single_instance/windows_single_instance.dart';
1111

1212
import 'app.dart';
1313
import 'bloc.dart';
14+
import 'package:sentry_flutter/sentry_flutter.dart';
1415

1516
final bloc = AppBloc();
1617

@@ -21,8 +22,27 @@ void main() async {
2122
await initWinToast();
2223
await initLaunchAtStartup();
2324
await initSharedPreferences();
25+
await initSentry();
2426
bloc.initialize();
25-
runApp(const App());
27+
}
28+
29+
Future<void> initSentry() async {
30+
await SentryFlutter.init((options) {
31+
options.dsn = 'https://7bba19233fbc2fa1f5a7a6c7770aa571@o4510396075409408.ingest.de.sentry.io/4510396076654672';
32+
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
33+
// We recommend adjusting this value in production.
34+
options.tracesSampleRate = 1.0;
35+
// Enable logs to be sent to Sentry
36+
options.enableLogs = true;
37+
// Record session replays for 100% of errors and 10% of sessions
38+
options.replay.onErrorSampleRate = 1.0;
39+
options.replay.sessionSampleRate = 0.1;
40+
// The sampling rate for profiling is relative to tracesSampleRate
41+
// Setting to 1.0 will profile 100% of sampled transactions:
42+
options.profilesSampleRate = 1.0;
43+
},
44+
appRunner: () => runApp(SentryWidget(child: const App())),
45+
);
2646
}
2747

2848
class MacWindowListener extends WindowListener {

linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "generated_plugin_registrant.h"
88

99
#include <screen_retriever/screen_retriever_plugin.h>
10+
#include <sentry_flutter/sentry_flutter_plugin.h>
1011
#include <system_tray/system_tray_plugin.h>
1112
#include <url_launcher_linux/url_launcher_plugin.h>
1213
#include <window_manager/window_manager_plugin.h>
@@ -15,6 +16,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
1516
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
1617
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
1718
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
19+
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
20+
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
21+
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);
1822
g_autoptr(FlPluginRegistrar) system_tray_registrar =
1923
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin");
2024
system_tray_plugin_register_with_registrar(system_tray_registrar);

linux/flutter/generated_plugins.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
list(APPEND FLUTTER_PLUGIN_LIST
66
screen_retriever
7+
sentry_flutter
78
system_tray
89
url_launcher_linux
910
window_manager
1011
)
1112

1213
list(APPEND FLUTTER_FFI_PLUGIN_LIST
14+
jni
1315
)
1416

1517
set(PLUGIN_BUNDLED_LIBRARIES)

macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import launch_at_startup
1010
import package_info_plus
1111
import path_provider_foundation
1212
import screen_retriever
13+
import sentry_flutter
1314
import shared_preferences_foundation
1415
import sqflite
1516
import system_tray
@@ -22,6 +23,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
2223
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
2324
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
2425
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
26+
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
2527
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
2628
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
2729
SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin"))

macos/Podfile.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PODS:
1010
- FMDB/Core
1111
- launch_at_startup (0.0.1):
1212
- FlutterMacOS
13+
- objective_c (0.0.1):
14+
- FlutterMacOS
1315
- package_info_plus (0.0.1):
1416
- FlutterMacOS
1517
- path_provider_foundation (0.0.1):
@@ -18,6 +20,11 @@ PODS:
1820
- ReachabilitySwift (5.2.4)
1921
- screen_retriever (0.0.1):
2022
- FlutterMacOS
23+
- Sentry/HybridSDK (8.56.2)
24+
- sentry_flutter (9.8.0):
25+
- Flutter
26+
- FlutterMacOS
27+
- Sentry/HybridSDK (= 8.56.2)
2128
- shared_preferences_foundation (0.0.1):
2229
- Flutter
2330
- FlutterMacOS
@@ -35,9 +42,11 @@ DEPENDENCIES:
3542
- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`)
3643
- FlutterMacOS (from `Flutter/ephemeral`)
3744
- launch_at_startup (from `Flutter/ephemeral/.symlinks/plugins/launch_at_startup/macos`)
45+
- objective_c (from `Flutter/ephemeral/.symlinks/plugins/objective_c/macos`)
3846
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
3947
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
4048
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
49+
- sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`)
4150
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
4251
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`)
4352
- system_tray (from `Flutter/ephemeral/.symlinks/plugins/system_tray/macos`)
@@ -48,6 +57,7 @@ SPEC REPOS:
4857
trunk:
4958
- FMDB
5059
- ReachabilitySwift
60+
- Sentry
5161

5262
EXTERNAL SOURCES:
5363
connectivity_plus:
@@ -56,12 +66,16 @@ EXTERNAL SOURCES:
5666
:path: Flutter/ephemeral
5767
launch_at_startup:
5868
:path: Flutter/ephemeral/.symlinks/plugins/launch_at_startup/macos
69+
objective_c:
70+
:path: Flutter/ephemeral/.symlinks/plugins/objective_c/macos
5971
package_info_plus:
6072
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
6173
path_provider_foundation:
6274
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
6375
screen_retriever:
6476
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
77+
sentry_flutter:
78+
:path: Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos
6579
shared_preferences_foundation:
6680
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
6781
sqflite:
@@ -78,10 +92,13 @@ SPEC CHECKSUMS:
7892
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
7993
FMDB: 728731dd336af3936ce00f91d9d8495f5718a0e6
8094
launch_at_startup: 76d0788c31957ca371613b61de00dc445b582e62
95+
objective_c: ec13431e45ba099cb734eb2829a5c1cd37986cba
8196
package_info_plus: 122abb51244f66eead59ce7c9c200d6b53111779
8297
path_provider_foundation: 2a68637f8a62df7f6e790a428d1bdf72cb4e2d59
8398
ReachabilitySwift: 32793e867593cfc1177f5d16491e3a197d2fccda
8499
screen_retriever: 4f97c103641aab8ce183fa5af3b87029df167936
100+
Sentry: b53951377b78e21a734f5dc8318e333dbfc682d7
101+
sentry_flutter: 4c33648b7e83310aa1fdb1b10c5491027d9643f0
85102
shared_preferences_foundation: 4e65c567e7877037d328829a522222c938bf308c
86103
sqflite: c73556b2499b92f0b6e6946abe4a4084510cdf90
87104
system_tray: 53f0cdb020c3fbee711d3fe45ae7ce730e033d2b

pubspec.lock

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4+
ansicolor:
5+
dependency: transitive
6+
description:
7+
name: ansicolor
8+
sha256: "50e982d500bc863e1d703448afdbf9e5a72eb48840a4f766fa361ffd6877055f"
9+
url: "https://pub.dev"
10+
source: hosted
11+
version: "2.0.3"
412
archive:
513
dependency: transitive
614
description:
@@ -13,10 +21,10 @@ packages:
1321
dependency: transitive
1422
description:
1523
name: args
16-
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
24+
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
1725
url: "https://pub.dev"
1826
source: hosted
19-
version: "2.4.2"
27+
version: "2.7.0"
2028
async:
2129
dependency: transitive
2230
description:
@@ -216,6 +224,14 @@ packages:
216224
url: "https://pub.dev"
217225
source: hosted
218226
version: "7.6.4"
227+
globbing:
228+
dependency: transitive
229+
description:
230+
name: globbing
231+
sha256: "4f89cfaf6fa74c9c1740a96259da06bd45411ede56744e28017cc534a12b6e2d"
232+
url: "https://pub.dev"
233+
source: hosted
234+
version: "1.0.0"
219235
http:
220236
dependency: "direct main"
221237
description:
@@ -240,6 +256,22 @@ packages:
240256
url: "https://pub.dev"
241257
source: hosted
242258
version: "4.1.3"
259+
injector:
260+
dependency: transitive
261+
description:
262+
name: injector
263+
sha256: ed389bed5b48a699d5b9561c985023d0d5cc88dd5ff2237aadcce5a5ab433e4e
264+
url: "https://pub.dev"
265+
source: hosted
266+
version: "3.0.0"
267+
jni:
268+
dependency: transitive
269+
description:
270+
name: jni
271+
sha256: d2c361082d554d4593c3012e26f6b188f902acd291330f13d6427641a92b3da1
272+
url: "https://pub.dev"
273+
source: hosted
274+
version: "0.14.2"
243275
js:
244276
dependency: transitive
245277
description:
@@ -352,6 +384,14 @@ packages:
352384
url: "https://pub.dev"
353385
source: hosted
354386
version: "0.5.0"
387+
objective_c:
388+
dependency: transitive
389+
description:
390+
name: objective_c
391+
sha256: "64e35e1e2e79da4e83f2ace3bf4e5437cef523f46c7db2eba9a1419c49573790"
392+
url: "https://pub.dev"
393+
source: hosted
394+
version: "8.0.0"
355395
octo_image:
356396
dependency: transitive
357397
description:
@@ -460,10 +500,10 @@ packages:
460500
dependency: transitive
461501
description:
462502
name: plugin_platform_interface
463-
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
503+
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
464504
url: "https://pub.dev"
465505
source: hosted
466-
version: "2.1.6"
506+
version: "2.1.8"
467507
pointycastle:
468508
dependency: transitive
469509
description:
@@ -472,6 +512,22 @@ packages:
472512
url: "https://pub.dev"
473513
source: hosted
474514
version: "3.7.3"
515+
process:
516+
dependency: transitive
517+
description:
518+
name: process
519+
sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
520+
url: "https://pub.dev"
521+
source: hosted
522+
version: "5.0.5"
523+
properties:
524+
dependency: transitive
525+
description:
526+
name: properties
527+
sha256: "333f427dd4ed07bdbe8c75b9ff864a1e70b5d7a8426a2e8bdd457b65ae5ac598"
528+
url: "https://pub.dev"
529+
source: hosted
530+
version: "2.1.1"
475531
pub_semver:
476532
dependency: transitive
477533
description:
@@ -496,6 +552,30 @@ packages:
496552
url: "https://pub.dev"
497553
source: hosted
498554
version: "0.1.9"
555+
sentry:
556+
dependency: transitive
557+
description:
558+
name: sentry
559+
sha256: "10a0bc25f5f21468e3beeae44e561825aaa02cdc6829438e73b9b64658ff88d9"
560+
url: "https://pub.dev"
561+
source: hosted
562+
version: "9.8.0"
563+
sentry_dart_plugin:
564+
dependency: "direct dev"
565+
description:
566+
name: sentry_dart_plugin
567+
sha256: "4b25aa60b5cbb46bb23859ac9212c4de5b22e2b3bc3fecbcd611756ada8973b5"
568+
url: "https://pub.dev"
569+
source: hosted
570+
version: "3.2.0"
571+
sentry_flutter:
572+
dependency: "direct main"
573+
description:
574+
name: sentry_flutter
575+
sha256: aafbf41c63c98a30b17bdbf3313424d5102db62b08735c44bff810f277e786a5
576+
url: "https://pub.dev"
577+
source: hosted
578+
version: "9.8.0"
499579
shared_preferences:
500580
dependency: "direct main"
501581
description:
@@ -613,6 +693,14 @@ packages:
613693
url: "https://pub.dev"
614694
source: hosted
615695
version: "3.1.0"
696+
system_info2:
697+
dependency: transitive
698+
description:
699+
name: system_info2
700+
sha256: b937736ecfa63c45b10dde1ceb6bb30e5c0c340e14c441df024150679d65ac43
701+
url: "https://pub.dev"
702+
source: hosted
703+
version: "4.1.0"
616704
system_tray:
617705
dependency: "direct main"
618706
description:

pubspec.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ environment:
77
flutter: "3.29.0"
88

99
dependencies:
10+
sentry_flutter: ^9.8.0
1011
flutter:
1112
sdk: flutter
1213
system_tray: ^2.0.3
@@ -29,6 +30,7 @@ dependencies:
2930
flutter_speedtest: ^0.2.0
3031

3132
dev_dependencies:
33+
sentry_dart_plugin: ^3.2.0
3234
flutter_test:
3335
sdk: flutter
3436
flutter_lints: ^2.0.0
@@ -54,3 +56,9 @@ flutter:
5456
uses-material-design: true
5557
assets:
5658
- assets/
59+
60+
sentry:
61+
upload_debug_symbols: true
62+
upload_source_maps: true
63+
project: flutter
64+
org: buildtoapp

windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
1010
#include <launch_at_startup/launch_at_startup_plugin.h>
1111
#include <screen_retriever/screen_retriever_plugin.h>
12+
#include <sentry_flutter/sentry_flutter_plugin.h>
1213
#include <system_tray/system_tray_plugin.h>
1314
#include <url_launcher_windows/url_launcher_windows.h>
1415
#include <win_toast/win_toast_plugin.h>
@@ -22,6 +23,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
2223
registry->GetRegistrarForPlugin("LaunchAtStartupPlugin"));
2324
ScreenRetrieverPluginRegisterWithRegistrar(
2425
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
26+
SentryFlutterPluginRegisterWithRegistrar(
27+
registry->GetRegistrarForPlugin("SentryFlutterPlugin"));
2528
SystemTrayPluginRegisterWithRegistrar(
2629
registry->GetRegistrarForPlugin("SystemTrayPlugin"));
2730
UrlLauncherWindowsRegisterWithRegistrar(

windows/flutter/generated_plugins.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
66
connectivity_plus
77
launch_at_startup
88
screen_retriever
9+
sentry_flutter
910
system_tray
1011
url_launcher_windows
1112
win_toast
@@ -14,6 +15,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
1415
)
1516

1617
list(APPEND FLUTTER_FFI_PLUGIN_LIST
18+
jni
1719
)
1820

1921
set(PLUGIN_BUNDLED_LIBRARIES)

0 commit comments

Comments
 (0)