added analytics to RemoteConfigService

This commit is contained in:
Vadim 2024-01-27 20:59:10 +01:00
parent 683b506650
commit 147fedc36f
2 changed files with 10 additions and 8 deletions

View file

@ -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<dynamic>([
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(

View file

@ -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<void> 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 {