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