TF-4136 Move Sentry duplication guard, but keep interceptor ordering last (not first)
This commit is contained in:
@@ -56,7 +56,7 @@ class ApplicationManager {
|
||||
log('ApplicationManager:getAppVersion -> cached: $version');
|
||||
return version;
|
||||
} catch (e) {
|
||||
logWarning('ApplicationManager:getAppVersion failedd, Exception = $e');
|
||||
logWarning('ApplicationManager:getAppVersion failed, Exception = $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ class SentryInitializer {
|
||||
'set-cookie',
|
||||
'x-auth',
|
||||
'x-token',
|
||||
'api-key',
|
||||
'apikey',
|
||||
'secret',
|
||||
'bearer',
|
||||
];
|
||||
|
||||
static Future<bool> init(FutureOr<void> Function() appRunner) async {
|
||||
@@ -63,6 +67,8 @@ class SentryInitializer {
|
||||
data: null,
|
||||
);
|
||||
|
||||
// Note: The copyWith method is deprecated,
|
||||
// so values must be assigned directly to the instance.
|
||||
return SentryEvent(
|
||||
eventId: event.eventId,
|
||||
contexts: event.contexts,
|
||||
|
||||
@@ -20,6 +20,10 @@ class SentryManager {
|
||||
required FutureOr<void> Function() fallBackRunner,
|
||||
}) async {
|
||||
try {
|
||||
if (_isSentryAvailable) {
|
||||
log('[SentryManager] Already initialized, skipping');
|
||||
return;
|
||||
}
|
||||
_isSentryAvailable = await SentryInitializer.init(appRunner);
|
||||
log('[SentryManager] Sentry initialized: $_isSentryAvailable');
|
||||
} catch (e, st) {
|
||||
|
||||
@@ -38,8 +38,8 @@ mixin AiScribeMixin {
|
||||
if (aiCapability?.isScribeEndpointAvailable == true) {
|
||||
AIScribeBindings(aiCapability!.scribeEndpoint!).dependencies();
|
||||
}
|
||||
} catch (e) {
|
||||
logWarning('AiScribeMixin::injectAIScribeBindings(): $e');
|
||||
} catch (e, st) {
|
||||
logWarning('AiScribeMixin::injectAIScribeBindings(): $e\n$st');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ extension SessionExtensions on Session {
|
||||
);
|
||||
log('SessionExtensions::getAICapability:aiCapability = $aiCapability');
|
||||
return aiCapability;
|
||||
} catch (e) {
|
||||
logWarning('SessionExtensions::getAICapability():[Exception] $e');
|
||||
} catch (e, st) {
|
||||
logWarning('SessionExtensions::getAICapability():[Exception] ${e.runtimeType}\n$st');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,12 @@ class NetworkBindings extends Bindings {
|
||||
dio.interceptors.add(LogInterceptor(requestBody: true));
|
||||
}
|
||||
if (SentryManager.instance.isSentryAvailable) {
|
||||
dio.addSentry();
|
||||
// Guard against duplicate Sentry interceptor registration
|
||||
final alreadyHasSentry = dio.interceptors
|
||||
.any((i) => i.runtimeType.toString().contains('Sentry'));
|
||||
if (!alreadyHasSentry) {
|
||||
dio.addSentry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,12 @@ class NetworkIsolateBindings extends Bindings {
|
||||
dio.interceptors.add(LogInterceptor(requestBody: true));
|
||||
}
|
||||
if (SentryManager.instance.isSentryAvailable) {
|
||||
dio.addSentry();
|
||||
// Guard against duplicate Sentry interceptor registration
|
||||
final alreadyHasSentry = dio.interceptors
|
||||
.any((i) => i.runtimeType.toString().contains('Sentry'));
|
||||
if (!alreadyHasSentry) {
|
||||
dio.addSentry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user