diff --git a/lib/application_wrapper.dart b/lib/application_wrapper.dart index ae7d1ae..9f824d4 100644 --- a/lib/application_wrapper.dart +++ b/lib/application_wrapper.dart @@ -26,11 +26,14 @@ class ApplicationWrapper extends StatelessWidget { @override Widget build(BuildContext context) { + final remoteConfigService = env.buildType != BuildType.dev + ? const RemoteConfigService(LightmeterAnalytics(api: LightmeterAnalyticsFirebase())) + : const MockRemoteConfigService(); return FutureBuilder( future: Future.wait([ SharedPreferences.getInstance(), const LightSensorService(LocalPlatform()).hasSensor(), - if (env.buildType != BuildType.dev) const RemoteConfigService().activeAndFetchFeatures(), + remoteConfigService.activeAndFetchFeatures(), ]), builder: (_, snapshot) { if (snapshot.data != null) { @@ -47,8 +50,7 @@ class ApplicationWrapper extends StatelessWidget { userPreferencesService: userPreferencesService, volumeEventsService: const VolumeEventsService(LocalPlatform()), child: RemoteConfigProvider( - remoteConfigService: - env.buildType != BuildType.dev ? const RemoteConfigService() : const MockRemoteConfigService(), + remoteConfigService: remoteConfigService, child: EquipmentProfileProvider( storageService: iapService, child: FilmsProvider( diff --git a/lib/data/remote_config_service.dart b/lib/data/remote_config_service.dart index 5159a2b..7c80d0f 100644 --- a/lib/data/remote_config_service.dart +++ b/lib/data/remote_config_service.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'dart:developer'; import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:flutter/foundation.dart'; +import 'package:lightmeter/data/analytics/analytics.dart'; import 'package:lightmeter/data/models/feature.dart'; abstract class IRemoteConfigService { @@ -24,7 +24,9 @@ abstract class IRemoteConfigService { } class RemoteConfigService implements IRemoteConfigService { - const RemoteConfigService(); + final LightmeterAnalytics analytics; + + const RemoteConfigService(this.analytics); @override Future activeAndFetchFeatures() async { @@ -99,9 +101,7 @@ class RemoteConfigService implements IRemoteConfigService { @override bool isEnabled(Feature feature) => FirebaseRemoteConfig.instance.getBool(feature.name); - void _logError(dynamic throwable, {StackTrace? stackTrace}) { - FirebaseCrashlytics.instance.recordError(throwable, stackTrace); - } + void _logError(dynamic throwable, {StackTrace? stackTrace}) => analytics.logCrash(throwable, stackTrace); } class MockRemoteConfigService implements IRemoteConfigService {