added logging to CameraInfoService

This commit is contained in:
Vadim 2025-05-14 10:10:46 +02:00
parent 7410d7ed60
commit 04b5e8d4ef
2 changed files with 24 additions and 7 deletions

View file

@ -33,9 +33,9 @@ class ApplicationWrapper extends StatefulWidget {
}
class _ApplicationWrapperState extends State<ApplicationWrapper> {
late final remoteConfigService = widget.env.buildType != BuildType.dev
? const RemoteConfigService(LightmeterAnalytics(api: LightmeterAnalyticsFirebase()))
: const MockRemoteConfigService();
static const analytics = LightmeterAnalytics(api: LightmeterAnalyticsFirebase());
late final remoteConfigService =
widget.env.buildType != BuildType.dev ? const RemoteConfigService(analytics) : const MockRemoteConfigService();
late final UserPreferencesService userPreferencesService;
late final bool hasLightSensor;
@ -100,7 +100,7 @@ class _ApplicationWrapperState extends State<ApplicationWrapper> {
await Future.wait([
SharedPreferences.getInstance(),
const LightSensorService(LocalPlatform()).hasSensor(),
const CameraInfoService().mainCameraEfl(),
const CameraInfoService(analytics).mainCameraEfl(),
remoteConfigService.activeAndFetchFeatures(),
equipmentProfilesStorageService.init(),
filmsStorageService.init(),

View file

@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:lightmeter/data/analytics/analytics.dart';
class CameraInfoService {
@visibleForTesting
@ -7,10 +8,26 @@ class CameraInfoService {
"com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel",
);
const CameraInfoService();
final LightmeterAnalytics analytics;
const CameraInfoService(this.analytics);
Future<int?> mainCameraEfl() async {
try {
final focalLength = await cameraInfoPlatformChannel.invokeMethod<double?>('mainCameraEfl');
return focalLength?.round();
} on PlatformException catch (e) {
analytics.logEvent(
e.code,
parameters: {
"message": "${e.message}",
"details": e.details.toString(),
},
);
return null;
} catch (e) {
analytics.logEvent(e.toString());
return null;
}
}
}