mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-01-31 17:50:40 +00:00
fb58b6cd9f
* fixed fvm path typo * Update pubspec.yaml * version control pubspec.lock * fixed ios build * deleted `ExpandableSectionList` * removed redundant default cases * avoided async gaps * replaced deprecated color value getter * `WillPopScope` -> `PopScope` * removed theme deprecations * replaced text scale deprecation * updated goldens * updated flutter version across workflows * [android] migrated to the new gradle * upgraded dependencies * [android] fixed build * [ios] fixed build * updated config * allow release notes to fail * updated stub pubspec * [android] use java 17 * [ios] enable flutterfire * added firebase.json to secrets * typo * update color utils * use exact versions * reverted color utils * updated goldens
58 lines
1.3 KiB
Dart
58 lines
1.3 KiB
Dart
import 'dart:async';
|
|
import 'dart:developer';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:lightmeter/data/analytics/api/analytics_api_interface.dart';
|
|
|
|
class LightmeterAnalytics {
|
|
final ILightmeterAnalyticsApi _api;
|
|
|
|
const LightmeterAnalytics({required ILightmeterAnalyticsApi api}) : _api = api;
|
|
|
|
void init() {
|
|
FlutterError.onError = (details) {
|
|
if (details.silent) return;
|
|
logCrash(details.exception, details.stack);
|
|
};
|
|
PlatformDispatcher.instance.onError = (error, stack) {
|
|
logCrash(error, stack);
|
|
return true;
|
|
};
|
|
}
|
|
|
|
Future<void> logEvent(
|
|
String eventName, {
|
|
Map<String, Object>? parameters,
|
|
}) async {
|
|
if (!kReleaseMode) {
|
|
log('<LightmeterAnalytics> logEvent: $eventName / $parameters');
|
|
return;
|
|
}
|
|
|
|
return _api.logEvent(
|
|
eventName,
|
|
parameters: parameters,
|
|
);
|
|
}
|
|
|
|
Future<void> logCrash(
|
|
dynamic exception,
|
|
StackTrace? stackTrace, {
|
|
dynamic reason,
|
|
Iterable<Object> information = const [],
|
|
}) async {
|
|
log(exception.toString(), stackTrace: stackTrace);
|
|
if (!kReleaseMode) {
|
|
return;
|
|
}
|
|
|
|
return _api.logCrash(
|
|
exception,
|
|
stackTrace,
|
|
reason: reason,
|
|
information: information,
|
|
);
|
|
}
|
|
|
|
Future<void> setCustomKey(String key, String value) async => _api.setCustomKey(key, value);
|
|
}
|