Skip to content

Commit 6c15592

Browse files
committed
feat(metrics): add metrics tracking for plugin installation events
1 parent 8c7a4b8 commit 6c15592

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

astrbot/core/star/star_manager.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
get_astrbot_plugin_path,
2323
)
2424
from astrbot.core.utils.io import remove_dir
25+
from astrbot.core.utils.metrics import Metric
2526

2627
from . import StarMetadata
2728
from .command_management import sync_command_configs
@@ -656,6 +657,14 @@ async def install_plugin(self, repo_url: str, proxy=""):
656657
如果找不到插件元数据则返回 None。
657658
658659
"""
660+
# this metric is for displaying plugins installation count in webui
661+
asyncio.create_task(
662+
Metric.upload(
663+
et="install_star",
664+
repo=repo_url,
665+
),
666+
)
667+
659668
async with self._pm_lock:
660669
plugin_path = await self.updator.install(repo_url, proxy)
661670
# reload the plugin
@@ -1025,4 +1034,12 @@ async def install_plugin_from_file(self, zip_file_path: str):
10251034
"name": plugin.name,
10261035
}
10271036

1037+
if plugin.repo:
1038+
asyncio.create_task(
1039+
Metric.upload(
1040+
et="install_star_f", # install star
1041+
repo=plugin.repo,
1042+
),
1043+
)
1044+
10281045
return plugin_info

0 commit comments

Comments
 (0)