refactor:plausible

release/mobdr-v0.0.1
Frédérik Benoist 2023-06-01 23:20:02 +02:00
parent 0656a92dc7
commit 8cc6b838de
2 changed files with 17 additions and 9 deletions

View File

@ -96,16 +96,20 @@ class MyApp extends StatelessWidget with WidgetsBindingObserver {
} else if (state == AppLifecycleState.resumed) {
LoggerUtil.logNStackInfo("The application is resumed");
// check if plausible is UP
await PlausibleUtil.hello();
if (PlausibleUtil.isPlausibleInitialized()) {
// check if plausible is UP
await PlausibleUtil.hello();
PlausibleUtil.addEvent(
name: 'access',
page: 'access',
referrer: 'referrerPage',
props: {
'name': SharedPrefs().login,
});
PlausibleUtil.addEvent(
name: 'access',
page: 'access',
referrer: 'referrerPage',
props: {
'name': SharedPrefs().login,
});
} else {
await PlausibleUtil.initializePlausible(window.physicalSize.width);
}
} else if (state == AppLifecycleState.inactive) {
LoggerUtil.logNStackInfo("The application is inactive");
} else if (state == AppLifecycleState.detached) {

View File

@ -5,6 +5,10 @@ import 'package:mobdr/network/get_ip_address.dart';
class PlausibleUtil {
static PlausibleTracker? plausible;
static bool isPlausibleInitialized() {
return plausible != null;
}
static Future<void> initializePlausible(double screenWidth) async {
plausible = PlausibleTracker(
"https://plausible.q2ii.fr",