systemprompt_cli/commands/analytics/
mod.rs1pub mod agents;
13pub mod content;
14pub mod conversations;
15pub mod costs;
16pub mod overview;
17pub mod requests;
18pub mod sessions;
19pub mod shared;
20pub mod tools;
21pub mod traffic;
22
23use anyhow::Result;
24use clap::Subcommand;
25
26use crate::context::CommandContext;
27use crate::shared::render_result;
28
29#[derive(Debug, Subcommand)]
30pub enum AnalyticsCommands {
31 #[command(about = "Dashboard overview of all analytics")]
32 Overview(overview::OverviewArgs),
33
34 #[command(subcommand, about = "Conversation analytics")]
35 Conversations(conversations::ConversationsCommands),
36
37 #[command(subcommand, about = "Agent performance analytics")]
38 Agents(agents::AgentsCommands),
39
40 #[command(subcommand, about = "Tool usage analytics")]
41 Tools(tools::ToolsCommands),
42
43 #[command(subcommand, about = "AI request analytics")]
44 Requests(requests::RequestsCommands),
45
46 #[command(subcommand, about = "Session analytics")]
47 Sessions(sessions::SessionsCommands),
48
49 #[command(subcommand, about = "Content performance analytics")]
50 Content(content::ContentCommands),
51
52 #[command(subcommand, about = "Traffic analytics")]
53 Traffic(traffic::TrafficCommands),
54
55 #[command(subcommand, about = "Cost analytics")]
56 Costs(costs::CostsCommands),
57}
58
59pub async fn execute(command: AnalyticsCommands, ctx: &CommandContext) -> Result<()> {
60 match command {
61 AnalyticsCommands::Overview(args) => {
62 let result =
63 overview::execute_with_pool(args, &ctx.database().await?, &ctx.cli).await?;
64 render_result(&result, &ctx.cli);
65 Ok(())
66 },
67 AnalyticsCommands::Conversations(cmd) => conversations::execute(cmd, ctx).await,
68 AnalyticsCommands::Agents(cmd) => agents::execute(cmd, ctx).await,
69 AnalyticsCommands::Tools(cmd) => tools::execute(cmd, ctx).await,
70 AnalyticsCommands::Requests(cmd) => requests::execute(cmd, ctx).await,
71 AnalyticsCommands::Sessions(cmd) => sessions::execute(cmd, ctx).await,
72 AnalyticsCommands::Content(cmd) => content::execute(cmd, ctx).await,
73 AnalyticsCommands::Traffic(cmd) => traffic::execute(cmd, ctx).await,
74 AnalyticsCommands::Costs(cmd) => costs::execute(cmd, ctx).await,
75 }
76}