Skip to content

Commit

Permalink
add sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisme committed Oct 31, 2021
1 parent c6d60e9 commit 29e83c6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 26 deletions.
51 changes: 27 additions & 24 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:desktop_window/desktop_window.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_icon_badge/flutter_app_icon_badge.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:notifi/notifications/db_provider.dart';
import 'package:notifi/notifications/notification.dart';
Expand All @@ -20,6 +21,7 @@ import 'package:provider/single_child_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() => mainImpl();

Expand Down Expand Up @@ -72,30 +74,31 @@ Future<void> mainImpl({bool integration: false}) async {
} catch (_) {
canBadge = false;
}

runApp(MultiProvider(
providers: <SingleChildWidget>[
ChangeNotifierProvider<TableNotifier>(
create: (BuildContext context) => TableNotifier()),
ChangeNotifierProxyProvider<TableNotifier, Notifications>(
create: (BuildContext context) => Notifications(notifications, db,
Provider.of<TableNotifier>(context, listen: false),
canBadge: canBadge),
update: (BuildContext context, TableNotifier tableNotifier,
Notifications user) =>
user..setTableNotifier(tableNotifier),
),
ChangeNotifierProxyProvider<Notifications, User>(
create: (BuildContext context) => User(
Provider.of<Notifications>(context, listen: false),
pushNotifications),
update:
(BuildContext context, Notifications notifications, User user) =>
user..setNotifications(notifications),
),
],
child: const MyApp(),
));
await SentryFlutter.init(
(SentryFlutterOptions options) => options.dsn = dotenv.env['SENTRY_DSN'],
appRunner: () => runApp(MultiProvider(
providers: <SingleChildWidget>[
ChangeNotifierProvider<TableNotifier>(
create: (BuildContext context) => TableNotifier()),
ChangeNotifierProxyProvider<TableNotifier, Notifications>(
create: (BuildContext context) => Notifications(notifications,
db, Provider.of<TableNotifier>(context, listen: false),
canBadge: canBadge),
update: (BuildContext context, TableNotifier tableNotifier,
Notifications user) =>
user..setTableNotifier(tableNotifier),
),
ChangeNotifierProxyProvider<Notifications, User>(
create: (BuildContext context) => User(
Provider.of<Notifications>(context, listen: false),
pushNotifications),
update: (BuildContext context, Notifications notifications,
User user) =>
user..setNotifications(notifications),
),
],
child: const MyApp(),
)));
}

class MyApp extends StatefulWidget {
Expand Down
11 changes: 9 additions & 2 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ Future<bool> loadDotEnv() async {
return true;
} else {
await dotenv.load();
return dotenv.isEveryDefined(
<String>['HOST', 'WS_HOST', 'KEY_STORE', 'TLS', 'SERVER_KEY', 'DEV']);
return dotenv.isEveryDefined(<String>[
'HOST',
'WS_HOST',
'KEY_STORE',
'TLS',
'SERVER_KEY',
'DEV',
'SENTRY_DSN'
]);
}
}

Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <desktop_window/desktop_window_plugin.h>
#include <flutter_app_icon_badge/flutter_app_icon_badge_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
Expand All @@ -17,6 +18,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_app_icon_badge_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAppIconBadgePlugin");
flutter_app_icon_badge_plugin_register_with_registrar(flutter_app_icon_badge_registrar);
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
desktop_window
flutter_app_icon_badge
sentry_flutter
url_launcher_linux
)

Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import launch_at_login
import package_info
import package_info_plus_macos
import path_provider_macos
import sentry_flutter
import share_plus_macos
import shared_preferences_macos
import sqflite
Expand All @@ -31,6 +32,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
path_provider: ^2.0.2
provider: ^6.0.0
pull_to_refresh: ^2.0.0
sentry_flutter: ^6.0.1
share_plus: ^3.0.2
shared_preferences: ^2.0.6
sqflite: ^2.0.0+3
Expand Down

0 comments on commit 29e83c6

Please sign in to comment.