Added sentry
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:linkdy/constants/global_keys.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:linkdy/providers/app_status_provider.dart';
|
||||
@@ -26,21 +29,36 @@ void main() async {
|
||||
|
||||
HttpOverrides.global = MyHttpOverrides();
|
||||
|
||||
await dotenv.load(fileName: '.env');
|
||||
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
|
||||
final appInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
runApp(
|
||||
TranslationProvider(
|
||||
child: ProviderScope(
|
||||
overrides: [
|
||||
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
|
||||
appInfoProvider.overrideWithValue(appInfo),
|
||||
],
|
||||
child: const MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
void startApp() => runApp(
|
||||
TranslationProvider(
|
||||
child: ProviderScope(
|
||||
overrides: [
|
||||
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
|
||||
appInfoProvider.overrideWithValue(appInfo),
|
||||
],
|
||||
child: const MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if ((kReleaseMode && (dotenv.env['SENTRY_DSN'] != null && dotenv.env['SENTRY_DSN'] != "")) ||
|
||||
(dotenv.env['ENABLE_SENTRY'] == "true" && (dotenv.env['SENTRY_DSN'] != null && dotenv.env['SENTRY_DSN'] != ""))) {
|
||||
SentryFlutter.init(
|
||||
(options) {
|
||||
options.dsn = dotenv.env['SENTRY_DSN'];
|
||||
options.sendDefaultPii = false;
|
||||
},
|
||||
appRunner: () => startApp(),
|
||||
);
|
||||
} else {
|
||||
startApp();
|
||||
}
|
||||
}
|
||||
|
||||
class MyApp extends ConsumerWidget {
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:linkdy/utils/open_url.dart';
|
||||
import 'package:linkdy/constants/strings.dart';
|
||||
import 'package:linkdy/constants/urls.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/providers/api_client_provider.dart';
|
||||
|
||||
class Settings extends ConsumerWidget {
|
||||
const Settings({Key? key}) : super(key: key);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:linkdy/constants/enums.dart';
|
||||
import 'package:linkdy/models/api_response.dart';
|
||||
@@ -46,6 +47,7 @@ class ApiClientService {
|
||||
content: BookmarksResponse.fromJson(response.data),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +65,7 @@ class ApiClientService {
|
||||
content: CheckBookmark.fromJson(response.data),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
@@ -78,6 +81,7 @@ class ApiClientService {
|
||||
content: Bookmark.fromJson(response.data),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
@@ -97,6 +101,7 @@ class ApiClientService {
|
||||
content: TagsResponse.fromJson(response.data),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart' as flutter_custom_tabs;
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:url_launcher/url_launcher.dart' as url_launcher;
|
||||
|
||||
void openUrl(String url) async {
|
||||
@@ -19,13 +20,13 @@ void openUrl(String url) async {
|
||||
),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
// Sentry.captureException(e, stackTrace: stackTrace);
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
url_launcher.launchUrl(Uri.parse(url));
|
||||
} catch (e, stackTrace) {
|
||||
// Sentry.captureException(e, stackTrace: stackTrace);
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user