style: dart format analytics_service(CI 门禁要求)
CI / flutter-gates (push) Failing after 22s

This commit is contained in:
2026-09-04 18:31:04 +08:00
parent b0207c9972
commit 45f94d2558
+9 -4
View File
@@ -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<void> trackEvent(String eventName, [Map<String, dynamic>? props]) async {
Future<void> trackEvent(
String eventName, [
Map<String, dynamic>? 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,8 +95,8 @@ class AnalyticsService {
if (token != null) 'Authorization': 'Bearer $token',
};
final request = await HttpClient()
.postUrl(Uri.parse('$_apiBaseUrl/api/v1/events'))
final request =
await HttpClient().postUrl(Uri.parse('$_apiBaseUrl/api/v1/events'))
..headers.contentType = ContentType.json;
if (token != null) {
request.headers.add('Authorization', 'Bearer $token');