fix:调整firebase必须在Android和生产环境才生效
This commit is contained in:
parent
5e1d1bd0c1
commit
26e0f4d3bb
@ -71,21 +71,45 @@ class FirebaseHelper {
|
||||
}
|
||||
|
||||
Future<void> initSdk() async {
|
||||
FirebaseAnalytics.instance.setAnalyticsCollectionEnabled(true);
|
||||
const bool isProductVmMode = bool.fromEnvironment('dart.vm.product');
|
||||
if (F.isProductionEnv &&
|
||||
isProductVmMode &&
|
||||
defaultTargetPlatform == TargetPlatform.android) {
|
||||
FirebaseAnalytics.instance.setAnalyticsCollectionEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> login(String userId) async {
|
||||
FirebaseAnalytics.instance.setUserId(id: userId);
|
||||
const bool isProductVmMode = bool.fromEnvironment('dart.vm.product');
|
||||
if (F.isProductionEnv &&
|
||||
isProductVmMode &&
|
||||
defaultTargetPlatform == TargetPlatform.android) {
|
||||
FirebaseAnalytics.instance.setUserId(id: userId);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> trackEvent(
|
||||
String eventName, Map<String, Object>? parameters) async {
|
||||
FirebaseAnalytics.instance
|
||||
.logEvent(name: eventName, parameters: parameters);
|
||||
String eventName,
|
||||
Map<String, Object>? parameters,
|
||||
) async {
|
||||
const bool isProductVmMode = bool.fromEnvironment('dart.vm.product');
|
||||
if (F.isProductionEnv &&
|
||||
isProductVmMode &&
|
||||
defaultTargetPlatform == TargetPlatform.android) {
|
||||
FirebaseAnalytics.instance.logEvent(
|
||||
name: eventName,
|
||||
parameters: parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
FirebaseAnalytics.instance.setUserId(id: '');
|
||||
const bool isProductVmMode = bool.fromEnvironment('dart.vm.product');
|
||||
if (F.isProductionEnv &&
|
||||
isProductVmMode &&
|
||||
defaultTargetPlatform == TargetPlatform.android) {
|
||||
FirebaseAnalytics.instance.setUserId(id: '');
|
||||
}
|
||||
}
|
||||
}
|
||||
//</com>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user