diff --git a/lib/analytics/analytics_service.dart b/lib/analytics/analytics_service.dart index ba9fdd2..aa240b9 100644 --- a/lib/analytics/analytics_service.dart +++ b/lib/analytics/analytics_service.dart @@ -14,9 +14,9 @@ class AnalyticsService { required this.getAccessToken, String? anonymousId, String? userId, - }) : _apiBaseUrl = apiBaseUrl, - _anonymousId = anonymousId ?? const Uuid().v4(), - _userId = userId; + }) : _apiBaseUrl = apiBaseUrl, + _anonymousId = anonymousId ?? const Uuid().v4(), + _userId = userId; static const _queueKey = 'patbond_analytics_queue'; static const _queueMaxSize = 500; @@ -40,7 +40,10 @@ class AnalyticsService { /// Tracks event (never throws, never awaits network). Props are validated /// for privacy red-line patterns locally before queuing. - Future trackEvent(String eventName, [Map? props]) async { + Future trackEvent( + String eventName, [ + Map? props, + ]) async { try { if (props != null && _containsForbiddenField(props)) { debugPrint('Analytics: event $eventName rejected (forbidden field)'); @@ -57,7 +60,9 @@ class AnalyticsService { 'clientTs': DateTime.now().toUtc().toIso8601String(), 'appVersion': '1.0.0+1', // TODO: read from package_info_plus 'platform': Platform.isAndroid ? 'android' : 'ios', - 'osVersion': Platform.isAndroid ? 'android-14' : 'ios-17', // TODO: device_info_plus + 'osVersion': Platform.isAndroid + ? 'android-14' + : 'ios-17', // TODO: device_info_plus if (props != null && props.isNotEmpty) 'props': props, }; @@ -90,9 +95,9 @@ class AnalyticsService { if (token != null) 'Authorization': 'Bearer $token', }; - final request = await HttpClient() - .postUrl(Uri.parse('$_apiBaseUrl/api/v1/events')) - ..headers.contentType = ContentType.json; + final request = + await HttpClient().postUrl(Uri.parse('$_apiBaseUrl/api/v1/events')) + ..headers.contentType = ContentType.json; if (token != null) { request.headers.add('Authorization', 'Bearer $token'); }