refactor:plausible
parent
37cd9272e7
commit
0656a92dc7
|
|
@ -1,5 +1,3 @@
|
|||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
|
@ -8,12 +6,10 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||
|
||||
import 'objectbox.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import 'package:event_bus_plus/event_bus_plus.dart';
|
||||
|
||||
import 'package:mobdr/service/logger_util.dart';
|
||||
import 'package:mobdr/config/constant.dart';
|
||||
import 'package:mobdr/core/routes/plausible_tracker.dart';
|
||||
import 'package:mobdr/cubit/language/language_cubit.dart';
|
||||
import 'package:mobdr/cubit/language/app_localizations.dart';
|
||||
import 'package:mobdr/cubit/language/initial_language.dart';
|
||||
|
|
@ -26,7 +22,6 @@ import 'package:mobdr/db/db_log.dart';
|
|||
|
||||
/// Provides access to the ObjectBox Store throughout the app.
|
||||
late ObjectBox objectbox;
|
||||
late PlausibleTracker plausible;
|
||||
|
||||
final EventBus eventBus = EventBus();
|
||||
|
||||
|
|
@ -96,19 +91,29 @@ class MyCustomScrollBehavior extends MaterialScrollBehavior {
|
|||
class MyApp extends StatelessWidget with WidgetsBindingObserver {
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
LoggerUtil.logNStackInfo("The application is in foreground");
|
||||
if (state == AppLifecycleState.paused) {
|
||||
LoggerUtil.logNStackInfo("The application is paused");
|
||||
} else if (state == AppLifecycleState.resumed) {
|
||||
LoggerUtil.logNStackInfo("The application is resumed");
|
||||
|
||||
// check if plausible is UP
|
||||
plausible.enabled = await plausible.hello();
|
||||
await PlausibleUtil.hello();
|
||||
|
||||
plausible.event(
|
||||
PlausibleUtil.addEvent(
|
||||
name: 'access',
|
||||
page: 'access',
|
||||
referrer: 'referrerPage',
|
||||
props: {
|
||||
'name': SharedPrefs().login,
|
||||
});
|
||||
} else if (state == AppLifecycleState.inactive) {
|
||||
LoggerUtil.logNStackInfo("The application is inactive");
|
||||
} else if (state == AppLifecycleState.detached) {
|
||||
LoggerUtil.logNStackInfo("The application is detached");
|
||||
eventBus.dispose();
|
||||
}
|
||||
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
} else if (state == AppLifecycleState.inactive) {
|
||||
LoggerUtil.logNStackInfo("The application runs in the background");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ class PlausibleUtil {
|
|||
plausible!.enabled = await plausible!.hello();
|
||||
}
|
||||
|
||||
static Future<void> hello() async {
|
||||
plausible!.enabled = await plausible!.hello();
|
||||
}
|
||||
|
||||
static void addEvent({
|
||||
required String name,
|
||||
required String page,
|
||||
|
|
|
|||
Loading…
Reference in New Issue