Add LLM digest setup and share timestamp context

This commit is contained in:
Rijad Zuzo
2026-05-19 19:17:35 +02:00
parent 9d2da0c600
commit 5d80af375e
42 changed files with 2878 additions and 39 deletions
+73 -8
View File
@@ -28,7 +28,7 @@ class SentryInit {
Future<void> _initializeInternal({
FutureOr<void> Function()? appRunner,
}) async {
if (!kReleaseMode || AppConfig.sentryDsn.isEmpty) {
if (AppConfig.sentryDsn.isEmpty) {
if (appRunner != null) {
await Future<void>.sync(appRunner);
}
@@ -37,25 +37,90 @@ class SentryInit {
await SentryFlutter.init((options) {
options.dsn = AppConfig.sentryDsn;
options.environment = AppConfig.useFakeBackend
? 'development'
: 'production';
options.environment = AppConfig.sentryEnvironment;
options.release = AppConfig.sentryRelease;
options.sendDefaultPii = false;
options.tracesSampleRate = 0.1;
}, appRunner: appRunner);
await Sentry.configureScope((scope) async {
await scope.setTag('service', 'relationship_saver');
await scope.setTag('build_mode', kReleaseMode ? 'release' : 'debug');
});
_installGlobalHandlers();
_initialized = true;
}
void captureException(Object error, {StackTrace? stackTrace}) {
void captureException(
Object error, {
StackTrace? stackTrace,
String? area,
Map<String, dynamic>? context,
}) {
if (_initialized) {
Sentry.captureException(error, stackTrace: stackTrace);
unawaited(
Sentry.captureException(
error,
stackTrace: stackTrace,
withScope: (scope) async {
if (area != null) {
await scope.setTag('area', area);
}
if (context != null) {
await scope.setContexts('diagnostics', context);
}
},
),
);
}
}
void captureMessage(String message, {SentryLevel level = SentryLevel.info}) {
void captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String? area,
Map<String, dynamic>? context,
}) {
if (_initialized) {
Sentry.captureMessage(message, level: level);
unawaited(
Sentry.captureMessage(
message,
level: level,
withScope: (scope) async {
if (area != null) {
await scope.setTag('area', area);
}
if (context != null) {
await scope.setContexts('diagnostics', context);
}
},
),
);
}
}
void _installGlobalHandlers() {
final FlutterExceptionHandler? previousFlutterHandler =
FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
previousFlutterHandler?.call(details);
captureException(
details.exception,
stackTrace: details.stack,
area: 'flutter_framework',
context: <String, dynamic>{
'library': details.library,
'context': details.context?.toDescription(),
},
);
};
final ErrorCallback? previousPlatformHandler =
PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = (Object error, StackTrace stack) {
captureException(error, stackTrace: stack, area: 'platform_dispatcher');
return previousPlatformHandler?.call(error, stack) ?? false;
};
}
}
final sentryInitProvider = Provider<SentryInit>((Ref ref) {