TF-4136 Fix duplicate Executor instance creation.
This commit is contained in:
@@ -30,6 +30,7 @@ class ApplicationManager {
|
||||
_versionCache = null;
|
||||
_cachedWebUserAgent = null;
|
||||
_cachedMobileUserAgent = null;
|
||||
_isMobileUserAgentInitialized = false;
|
||||
}
|
||||
|
||||
Future<PackageInfo> getPackageInfo() async {
|
||||
|
||||
@@ -29,6 +29,7 @@ class EnvLoader {
|
||||
);
|
||||
} catch (e) {
|
||||
logWarning('EnvLoader::loadFcmConfigFileToEnv: Exception = $e');
|
||||
// FCM config is optional; reload base config to restore dotenv.env state
|
||||
await onCallBack?.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class SentryConfig {
|
||||
});
|
||||
|
||||
/// Load configuration from an env file.
|
||||
static Future<SentryConfig> load() async {
|
||||
static Future<SentryConfig?> load() async {
|
||||
await EnvLoader.loadConfigFromEnv();
|
||||
|
||||
final sentryAvailable = dotenv.get('SENTRY_ENABLED', fallback: 'false');
|
||||
@@ -54,12 +54,10 @@ class SentryConfig {
|
||||
final sentryDSN = dotenv.get('SENTRY_DSN', fallback: '');
|
||||
final sentryEnvironment = dotenv.get('SENTRY_ENVIRONMENT', fallback: '');
|
||||
|
||||
if (!isAvailable) {
|
||||
throw Exception('Sentry is not available');
|
||||
}
|
||||
|
||||
if (sentryDSN.trim().isEmpty || sentryEnvironment.trim().isEmpty) {
|
||||
throw Exception('Sentry configuration is missing');
|
||||
if (!isAvailable ||
|
||||
sentryDSN.trim().isEmpty ||
|
||||
sentryEnvironment.trim().isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final appVersion = await ApplicationManager().getAppVersion();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:core/utils/sentry/sentry_manager.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:sentry_dio/sentry_dio.dart';
|
||||
|
||||
class SentryDioHelper {
|
||||
static void addIfAvailable(Dio dio) {
|
||||
if (!SentryManager.instance.isSentryAvailable) return;
|
||||
|
||||
final alreadyHasSentry = dio.interceptors.any(
|
||||
(i) => i.runtimeType.toString().contains('FailedRequestInterceptor'));
|
||||
if (!alreadyHasSentry) {
|
||||
dio.addSentry();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,19 @@ class SentryInitializer {
|
||||
'x-auth',
|
||||
'x-token',
|
||||
'api-key',
|
||||
'x-api-key',
|
||||
'apikey',
|
||||
'secret',
|
||||
'bearer',
|
||||
'session',
|
||||
'password',
|
||||
];
|
||||
|
||||
static Future<bool> init(FutureOr<void> Function() appRunner) async {
|
||||
final config = await SentryConfig.load();
|
||||
|
||||
if (config == null) return false;
|
||||
|
||||
await SentryFlutter.init(
|
||||
(options) {
|
||||
options.dsn = config.dsn;
|
||||
|
||||
@@ -22,6 +22,7 @@ class SentryManager {
|
||||
try {
|
||||
if (_isSentryAvailable) {
|
||||
log('[SentryManager] Already initialized, skipping');
|
||||
await appRunner();
|
||||
return;
|
||||
}
|
||||
_isSentryAvailable = await SentryInitializer.init(appRunner);
|
||||
|
||||
Reference in New Issue
Block a user