Skip to content

Commit

Permalink
[stats] recording app features
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Sep 26, 2024
1 parent a7e7169 commit f499c84
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class _MimirAppState extends ConsumerState<MimirApp> {

void onRouteChanged() {
final info = router.routeInformationProvider.value;
Stats.onRoute(info.uri);
Stats.route(info.uri);
}

@override
Expand Down
3 changes: 3 additions & 0 deletions lib/backend/bulletin/x.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:mimir/backend/bulletin/entity/bulletin.dart';
import 'package:mimir/backend/init.dart';
import 'package:mimir/backend/stats/utils/stats.dart';
import 'package:mimir/feature/feature.dart';

class XBulletin {
static Future<MimirBulletin?> getLatest() async {
Expand All @@ -13,6 +15,7 @@ class XBulletin {

static Future<List<MimirBulletin>> getList() async {
final list = await BackendInit.bulletin.getList();
Stats.feature(AppFeature.mimirBulletin, "/list");
BackendInit.bulletinStorage.list = list;
return list;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/backend/stats/utils/stats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../init.dart';
class Stats {
static String? lastRoute;

static void onRoute(Uri uri) {
static void route(Uri uri) {
final route = uri.toString();
if (route == lastRoute) {
return;
Expand All @@ -22,7 +22,7 @@ class Stats {
debugPrint('[${time.toString()}] On route #$id: "$route"');
}

static void onFeature(String feature, [String? result]) {
static void feature(String feature, [String? result]) {
final time = DateTime.now();
final row = StatsFeatureUsage(
feature: feature,
Expand Down
3 changes: 3 additions & 0 deletions lib/life/electricity/widget/search.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:mimir/backend/stats/utils/stats.dart';
import 'package:mimir/design/adaptive/multiplatform.dart';
import 'package:mimir/design/adaptive/swipe.dart';
import 'package:mimir/design/widget/common.dart';
import 'package:mimir/feature/feature.dart';
import 'package:mimir/life/electricity/entity/room.dart';
import 'package:mimir/widget/search.dart';
import 'package:rettulf/rettulf.dart';
Expand All @@ -15,6 +17,7 @@ Future<String?> searchRoom({
required ValueNotifier<List<String>> $searchHistory,
required List<String> roomList,
}) async {
Stats.feature(AppFeature.electricityBalance, "/search");
final result = await showSearch(
useRootNavigator: true,
context: ctx,
Expand Down
9 changes: 7 additions & 2 deletions lib/life/expense_records/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:mimir/backend/stats/utils/stats.dart';
import 'package:mimir/credentials/init.dart';
import 'package:mimir/design/widget/app.dart';
import 'package:mimir/design/adaptive/dialog.dart';
import 'package:mimir/feature/feature.dart';
import 'package:mimir/l10n/extension.dart';
import 'package:mimir/life/event.dart';
import 'package:mimir/settings/settings.dart';
Expand Down Expand Up @@ -112,8 +114,11 @@ class _ExpenseRecordsAppCardState extends ConsumerState<ExpenseRecordsAppCard> w
OutlinedButton(
onPressed: () async {
final success = await guardLaunchUrlString(context, _alipaySchoolCardTopUpMiniapp);
if (!context.mounted) return;
if (!success) {
if (success) {
Stats.feature(AppFeature.expenseRecords, "/top-up?launched");
} else {
Stats.feature(AppFeature.expenseRecords, "/top-up?failed");
if (!context.mounted) return;
context.showTip(
title: i18n.launchFailed,
desc: i18n.launchFailedDesc,
Expand Down
4 changes: 4 additions & 0 deletions lib/life/lab_door/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mimir/backend/stats/utils/stats.dart';
import 'package:mimir/design/adaptive/dialog.dart';
import 'package:mimir/design/adaptive/multiplatform.dart';
import 'package:mimir/design/widget/app.dart';
import 'package:mimir/design/widget/task_builder.dart';
import 'package:mimir/feature/feature.dart';
import 'package:mimir/init.dart';
import 'package:rettulf/rettulf.dart';
import 'package:mimir/utils/error.dart';
Expand Down Expand Up @@ -45,7 +47,9 @@ class _OpenLabDoorAppCardState extends ConsumerState<OpenLabDoorAppCard> {
await Future.delayed(const Duration(milliseconds: 2000));
if (!mounted) return;
context.showSnackBar(content: "开门成功".text());
Stats.feature(AppFeature.sitRobotOpenLabDoor, "/open?success");
} else {
Stats.feature(AppFeature.sitRobotOpenLabDoor, "/open?failed");
if (!mounted) return;
context.showSnackBar(content: "开门失败".text());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/timetable/p13n/widget/wallpaper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _WallpaperImplState extends State<_WallpaperImpl> with SingleTickerProvide
},
onShow: () {
final now = DateTime.now();
if (widget.fade && now.difference(lastHiddenTime ?? now).inSeconds > 15) {
if (widget.fade && now.difference(lastHiddenTime ?? now).inSeconds > 60) {
final hasCache = PaintingBinding.instance.imageCache.containsKey(FileImage(File(widget.background.path)));
if (!hasCache) {
$opacity.value = 0;
Expand Down

0 comments on commit f499c84

Please sign in to comment.