Skip to content

Commit

Permalink
feat: track settings usage
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Mar 22, 2024
1 parent c318651 commit 0b20a3d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="unplugin-analytics/client" />

declare module '~build/time' {
const time: Date;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"typescript": "^5.3.3",
"unbuild": "^2.0.0",
"unocss": "^0.58.5",
"unplugin-analytics": "^0.0.8",
"unplugin-analytics": "^0.0.10",
"unplugin-info": "^1.1.0",
"vitest": "^1.3.1",
"vue": "^3.4.20",
Expand Down
26 changes: 18 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions stores/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { skipHydrate } from 'pinia';
import { useStorage } from '@vueuse/core';

import { umami } from '~analytics/umami';

export type ListSortMode = 'byCity' | 'byProfit';
export type ProfitComputeRule = 'maxPriceChange' | 'noChange';
export type DataDisplayItems = 'profit' | 'perTicketProfit';
Expand All @@ -16,11 +18,15 @@ export const useSettingStore = defineStore('setting', () => {
// 切换列表排序模式
const switchListSortModeTo = (targetMode: ListSortMode) => {
listSortMode.value = targetMode;

umami?.track(`switch list mode to ${targetMode}`).catch(() => {});
};

// 切换利润计算规则
const switchProfitComputeRuleTo = (targetRule: ProfitComputeRule) => {
profitComputeRule.value = targetRule;

umami?.track(`switch profit compute rule to ${targetRule}`).catch(() => {});
};

// 切换数据显示项
Expand Down

0 comments on commit 0b20a3d

Please sign in to comment.