import 'package:aitrainer_app/main.dart'; import 'package:aitrainer_app/model/cache.dart'; import 'package:aitrainer_app/service/logging.dart'; import 'package:aitrainer_app/service/tracking_service.dart'; import 'package:aitrainer_app/util/enums.dart'; import 'package:aitrainer_app/model/tracking.dart' as model; import 'package:flurry/flurry.dart'; import 'package:flutter_uxcam/flutter_uxcam.dart'; class Track with Logging { static final Track _singleton = Track._internal(); factory Track() { return _singleton; } Track._internal(); void track(TrackingEvent event, {String eventValue = ""}) { if (!isInDebugMode) { Flurry.logEvent(event.toString()); // Smartlook.setGlobalEventProperty(event.toString(), eventValue, false); FlutterUxcam.logEventWithProperties(event.enumToString(), {"value": eventValue}); model.Tracking tracking = model.Tracking(); tracking.customerId = Cache().userLoggedIn == null ? 0 : Cache().userLoggedIn!.customerId!; tracking.event = event.enumToString(); if (eventValue.isNotEmpty) { tracking.eventValue = eventValue; } tracking.dateAdd = DateTime.now(); TrackingApi().saveTracking(tracking); } } }