2024-03-11 20:43:16 +08:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-11-05 15:56:48 +08:00
|
|
|
import 'package:flutter/foundation.dart';
|
2024-01-29 20:44:00 +08:00
|
|
|
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
|
2024-02-07 19:32:36 +08:00
|
|
|
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
2024-03-01 20:59:43 +08:00
|
|
|
import 'package:starcitizen_doctor/common/utils/log.dart';
|
2023-10-30 20:39:31 +08:00
|
|
|
|
|
|
|
class AnalyticsApi {
|
|
|
|
static touch(String key) async {
|
2024-05-07 21:08:16 +08:00
|
|
|
if (kDebugMode || kProfileMode) {
|
|
|
|
dPrint("AnalyticsApi.touch === $key skip");
|
|
|
|
return;
|
|
|
|
}
|
2023-10-30 20:39:31 +08:00
|
|
|
dPrint("AnalyticsApi.touch === $key start");
|
|
|
|
try {
|
2024-02-17 11:30:01 +08:00
|
|
|
final r = await RSHttp.postData(
|
|
|
|
"${URLConf.analyticsApiHome}/analytics/$key",
|
2024-02-16 22:47:06 +08:00
|
|
|
data: null);
|
|
|
|
dPrint("AnalyticsApi.touch === $key over statusCode == ${r.statusCode}");
|
2023-10-30 20:39:31 +08:00
|
|
|
} catch (e) {
|
|
|
|
dPrint("AnalyticsApi.touch === $key Error:$e");
|
|
|
|
}
|
|
|
|
}
|
2024-03-11 20:43:16 +08:00
|
|
|
|
2024-03-17 17:19:37 +08:00
|
|
|
static Future<Map<String, dynamic>> getAnalyticsData() async {
|
2024-03-11 20:43:16 +08:00
|
|
|
final r = await RSHttp.get("${URLConf.analyticsApiHome}/analytics");
|
|
|
|
if (r.data == null) return {};
|
|
|
|
final jsonData = json.decode(utf8.decode(r.data!));
|
|
|
|
dPrint("AnalyticsApi.getAnalyticsData");
|
|
|
|
return jsonData;
|
|
|
|
}
|
2023-10-30 20:39:31 +08:00
|
|
|
}
|