Skip to content

Commit

Permalink
feat: 允许用户关闭数据上报
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Jan 12, 2024
1 parent 41b3023 commit 6c03fe6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@
upgrade_dependencies = False

# 是否上报统计信息
# 用于统计机器人的使用情况,不会收集任何用户信息
# 仅上报时间、字数使用量、绘图使用量,其他信息不会上报
# 用于统计机器人的使用情况,数据不公开,不会收集任何敏感信息。
# 仅实例识别UUID、上报时间、字数使用量、绘图使用量、插件使用情况、用户信息,其他信息不会上报
report_usage = True

# 日志级别
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/center/groups/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from .. import apigroup
from ... import context


class V2MainDataAPI(apigroup.APIGroup):
Expand All @@ -9,6 +10,12 @@ class V2MainDataAPI(apigroup.APIGroup):
def __init__(self, prefix: str):
super().__init__(prefix+"/main")

def do(self, *args, **kwargs):
config = context.get_config_manager().data
if not config['report_usage']:
return None
return super().do(*args, **kwargs)

def post_update_record(
self,
spent_seconds: int,
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/center/groups/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from .. import apigroup
from ... import context


class V2PluginDataAPI(apigroup.APIGroup):
Expand All @@ -9,6 +10,12 @@ class V2PluginDataAPI(apigroup.APIGroup):
def __init__(self, prefix: str):
super().__init__(prefix+"/plugin")

def do(self, *args, **kwargs):
config = context.get_config_manager().data
if not config['report_usage']:
return None
return super().do(*args, **kwargs)

def post_install_record(
self,
plugin: dict
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/center/groups/usage.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
from __future__ import annotations

from .. import apigroup
from ... import context


class V2UsageDataAPI(apigroup.APIGroup):
"""使用量数据相关 API"""

def __init__(self, prefix: str):
super().__init__(prefix+"/usage")

def do(self, *args, **kwargs):
config = context.get_config_manager().data
if not config['report_usage']:
return None
return super().do(*args, **kwargs)

def post_query_record(
self,
Expand Down

0 comments on commit 6c03fe6

Please sign in to comment.