mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
added analytics to RemoteConfigService
This commit is contained in:
parent
683b506650
commit
147fedc36f
2 changed files with 10 additions and 8 deletions
|
@ -26,11 +26,14 @@ class ApplicationWrapper extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final remoteConfigService = env.buildType != BuildType.dev
|
||||||
|
? const RemoteConfigService(LightmeterAnalytics(api: LightmeterAnalyticsFirebase()))
|
||||||
|
: const MockRemoteConfigService();
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: Future.wait<dynamic>([
|
future: Future.wait<dynamic>([
|
||||||
SharedPreferences.getInstance(),
|
SharedPreferences.getInstance(),
|
||||||
const LightSensorService(LocalPlatform()).hasSensor(),
|
const LightSensorService(LocalPlatform()).hasSensor(),
|
||||||
if (env.buildType != BuildType.dev) const RemoteConfigService().activeAndFetchFeatures(),
|
remoteConfigService.activeAndFetchFeatures(),
|
||||||
]),
|
]),
|
||||||
builder: (_, snapshot) {
|
builder: (_, snapshot) {
|
||||||
if (snapshot.data != null) {
|
if (snapshot.data != null) {
|
||||||
|
@ -47,8 +50,7 @@ class ApplicationWrapper extends StatelessWidget {
|
||||||
userPreferencesService: userPreferencesService,
|
userPreferencesService: userPreferencesService,
|
||||||
volumeEventsService: const VolumeEventsService(LocalPlatform()),
|
volumeEventsService: const VolumeEventsService(LocalPlatform()),
|
||||||
child: RemoteConfigProvider(
|
child: RemoteConfigProvider(
|
||||||
remoteConfigService:
|
remoteConfigService: remoteConfigService,
|
||||||
env.buildType != BuildType.dev ? const RemoteConfigService() : const MockRemoteConfigService(),
|
|
||||||
child: EquipmentProfileProvider(
|
child: EquipmentProfileProvider(
|
||||||
storageService: iapService,
|
storageService: iapService,
|
||||||
child: FilmsProvider(
|
child: FilmsProvider(
|
||||||
|
|
|
@ -2,9 +2,9 @@ import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
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:firebase_remote_config/firebase_remote_config.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:lightmeter/data/analytics/analytics.dart';
|
||||||
import 'package:lightmeter/data/models/feature.dart';
|
import 'package:lightmeter/data/models/feature.dart';
|
||||||
|
|
||||||
abstract class IRemoteConfigService {
|
abstract class IRemoteConfigService {
|
||||||
|
@ -24,7 +24,9 @@ abstract class IRemoteConfigService {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RemoteConfigService implements IRemoteConfigService {
|
class RemoteConfigService implements IRemoteConfigService {
|
||||||
const RemoteConfigService();
|
final LightmeterAnalytics analytics;
|
||||||
|
|
||||||
|
const RemoteConfigService(this.analytics);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> activeAndFetchFeatures() async {
|
Future<void> activeAndFetchFeatures() async {
|
||||||
|
@ -99,9 +101,7 @@ class RemoteConfigService implements IRemoteConfigService {
|
||||||
@override
|
@override
|
||||||
bool isEnabled(Feature feature) => FirebaseRemoteConfig.instance.getBool(feature.name);
|
bool isEnabled(Feature feature) => FirebaseRemoteConfig.instance.getBool(feature.name);
|
||||||
|
|
||||||
void _logError(dynamic throwable, {StackTrace? stackTrace}) {
|
void _logError(dynamic throwable, {StackTrace? stackTrace}) => analytics.logCrash(throwable, stackTrace);
|
||||||
FirebaseCrashlytics.instance.recordError(throwable, stackTrace);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockRemoteConfigService implements IRemoteConfigService {
|
class MockRemoteConfigService implements IRemoteConfigService {
|
||||||
|
|
Loading…
Reference in a new issue