feat: add local-first private AI digest workflow
Migrate app code into canonical feature slices, add phone-only AI digest scheduling and review, wire local notification/background task support, and cover the flow with tests.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:relationship_saver/core/config/app_config.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class SentryInit {
|
||||
SentryInit();
|
||||
|
||||
Future<void>? _initializeFuture;
|
||||
bool _initialized = false;
|
||||
|
||||
Future<void> initialize({FutureOr<void> Function()? appRunner}) async {
|
||||
final Future<void>? inFlight = _initializeFuture;
|
||||
if (inFlight != null) {
|
||||
await inFlight;
|
||||
if (appRunner != null && !_initialized) {
|
||||
await Future<void>.sync(appRunner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_initializeFuture = _initializeInternal(appRunner: appRunner);
|
||||
return _initializeFuture;
|
||||
}
|
||||
|
||||
Future<void> _initializeInternal({
|
||||
FutureOr<void> Function()? appRunner,
|
||||
}) async {
|
||||
if (!kReleaseMode || AppConfig.sentryDsn.isEmpty) {
|
||||
if (appRunner != null) {
|
||||
await Future<void>.sync(appRunner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
await SentryFlutter.init((options) {
|
||||
options.dsn = AppConfig.sentryDsn;
|
||||
options.environment = AppConfig.useFakeBackend
|
||||
? 'development'
|
||||
: 'production';
|
||||
options.tracesSampleRate = 0.1;
|
||||
}, appRunner: appRunner);
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
void captureException(Object error, {StackTrace? stackTrace}) {
|
||||
if (_initialized) {
|
||||
Sentry.captureException(error, stackTrace: stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
void captureMessage(String message, {SentryLevel level = SentryLevel.info}) {
|
||||
if (_initialized) {
|
||||
Sentry.captureMessage(message, level: level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final sentryInitProvider = Provider<SentryInit>((Ref ref) {
|
||||
return SentryInit();
|
||||
});
|
||||
Reference in New Issue
Block a user