From 3ae9342a860490cd4e111d65f13b48bd7e962cb7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 29 Jul 2021 16:13:15 +1000 Subject: [PATCH] Provide release code to sentry --- lib/main.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index dd375d35..e5997452 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,7 @@ import 'package:inventree/widget/home.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:one_context/one_context.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'dsn.dart'; @@ -17,15 +18,23 @@ import 'package:sentry_flutter/sentry_flutter.dart'; Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await runZonedGuarded>(() async { + PackageInfo info = await PackageInfo.fromPlatform(); + String pkg = info.packageName; + String version = info.version; + String build = info.buildNumber; + + String release = "${pkg}@${version}:${build}"; + await Sentry.init((options) { options.dsn = SENTRY_DSN_KEY; + options.release = release; options.environment = isInDebugMode() ? "debug" : "release"; }); - WidgetsFlutterBinding.ensureInitialized(); - // Pass any flutter errors off to the Sentry reporting context! FlutterError.onError = (FlutterErrorDetails details) async {