refactor:plausible
parent
0656a92dc7
commit
8cc6b838de
|
|
@ -96,16 +96,20 @@ class MyApp extends StatelessWidget with WidgetsBindingObserver {
|
||||||
} else if (state == AppLifecycleState.resumed) {
|
} else if (state == AppLifecycleState.resumed) {
|
||||||
LoggerUtil.logNStackInfo("The application is resumed");
|
LoggerUtil.logNStackInfo("The application is resumed");
|
||||||
|
|
||||||
// check if plausible is UP
|
if (PlausibleUtil.isPlausibleInitialized()) {
|
||||||
await PlausibleUtil.hello();
|
// check if plausible is UP
|
||||||
|
await PlausibleUtil.hello();
|
||||||
|
|
||||||
PlausibleUtil.addEvent(
|
PlausibleUtil.addEvent(
|
||||||
name: 'access',
|
name: 'access',
|
||||||
page: 'access',
|
page: 'access',
|
||||||
referrer: 'referrerPage',
|
referrer: 'referrerPage',
|
||||||
props: {
|
props: {
|
||||||
'name': SharedPrefs().login,
|
'name': SharedPrefs().login,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
await PlausibleUtil.initializePlausible(window.physicalSize.width);
|
||||||
|
}
|
||||||
} else if (state == AppLifecycleState.inactive) {
|
} else if (state == AppLifecycleState.inactive) {
|
||||||
LoggerUtil.logNStackInfo("The application is inactive");
|
LoggerUtil.logNStackInfo("The application is inactive");
|
||||||
} else if (state == AppLifecycleState.detached) {
|
} else if (state == AppLifecycleState.detached) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ import 'package:mobdr/network/get_ip_address.dart';
|
||||||
class PlausibleUtil {
|
class PlausibleUtil {
|
||||||
static PlausibleTracker? plausible;
|
static PlausibleTracker? plausible;
|
||||||
|
|
||||||
|
static bool isPlausibleInitialized() {
|
||||||
|
return plausible != null;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> initializePlausible(double screenWidth) async {
|
static Future<void> initializePlausible(double screenWidth) async {
|
||||||
plausible = PlausibleTracker(
|
plausible = PlausibleTracker(
|
||||||
"https://plausible.q2ii.fr",
|
"https://plausible.q2ii.fr",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue