import 'package:mobdr/core/routes/plausible_tracker.dart'; import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/network/get_ip_address.dart'; class PlausibleUtil { static PlausibleTracker? plausible; static bool isPlausibleInitialized() { return plausible != null; } static Future initializePlausible(double screenWidth) async { plausible = PlausibleTracker( "https://plausible.q2ii.fr", "mobdr.ikksgroup.com", ); await plausible!.hello(); plausible!.userAgent = SharedPrefs().mobileUserAgent; plausible!.xForwardedFor = await getPublicIPAddress(); plausible!.screenWidth = screenWidth.toString(); plausible!.enabled = await plausible!.hello(); } static Future hello() async { plausible!.enabled = await plausible!.hello(); } static void addEvent({ required String name, required String page, String? referrer, Map? props, }) { PlausibleUtil.plausible?.event( name: name, page: page, referrer: referrer ?? '', props: props ?? {}, ); } }