1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2025-12-06 14:52:50 +08:00

feat: 新增开关控制是否开始谷歌统计 see #473

This commit is contained in:
涵曦
2025-06-12 01:07:13 +08:00
parent fff35783c2
commit 6ef7d4c6c2
3 changed files with 15 additions and 2 deletions

View File

@@ -57,8 +57,11 @@ class Analytics:
await self._send(event)
async def _send(self, event):
asyncio.create_task(self.post_to_umami(event))
await self.run_with_cancel(self._google_send, [event])
if self.config.enable_analytics:
asyncio.create_task(self.post_to_umami(event))
await self.run_with_cancel(self._google_send, [event])
else:
self.log.info("analytics is disabled, skip sending event")
def _google_send(self, events):
try:

View File

@@ -191,6 +191,9 @@ class Config:
enable_save_tag: bool = (
os.getenv("XIAOMUSIC_ENABLE_SAVE_TAG", "false").lower() == "true"
)
enable_analytics: bool = (
os.getenv("XIAOMUSIC_ENABLE_ANALYTICS", "true").lower() == "true"
)
get_ask_by_mina: bool = (
os.getenv("XIAOMUSIC_GET_ASK_BY_MINA", "false").lower() == "true"
)

View File

@@ -260,6 +260,13 @@ var vConsole = new window.VConsole();
<option value="false" selected>false</option>
</select>
<label for="enable_analytics">开启谷歌数据统计(无敏感数据):</label>
<select id="enable_analytics">
<option value="true" selected>true</option>
<option value="false">false</option>
</select>
<label for="music_list_url" class="setting-label">歌单地址:
<button class="option-inline mini-button" id="get_music_list">
<span class="material-icons">sync_alt</span>