mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-20 04:17:57 -05:00
improvement(stats): should track mcp and a2a executions like other trigger types (#2895)
* improvement(stats): should track mcp and a2a executions like other trigger types * update types
This commit is contained in:
committed by
GitHub
parent
e575ba2965
commit
9efd3d5b4c
@@ -550,6 +550,8 @@ export interface AdminUserBilling {
|
||||
totalWebhookTriggers: number
|
||||
totalScheduledExecutions: number
|
||||
totalChatExecutions: number
|
||||
totalMcpExecutions: number
|
||||
totalA2aExecutions: number
|
||||
totalTokensUsed: number
|
||||
totalCost: string
|
||||
currentUsageLimit: string | null
|
||||
|
||||
@@ -97,6 +97,8 @@ export const GET = withAdminAuthParams<RouteParams>(async (_, context) => {
|
||||
totalWebhookTriggers: stats?.totalWebhookTriggers ?? 0,
|
||||
totalScheduledExecutions: stats?.totalScheduledExecutions ?? 0,
|
||||
totalChatExecutions: stats?.totalChatExecutions ?? 0,
|
||||
totalMcpExecutions: stats?.totalMcpExecutions ?? 0,
|
||||
totalA2aExecutions: stats?.totalA2aExecutions ?? 0,
|
||||
totalTokensUsed: stats?.totalTokensUsed ?? 0,
|
||||
totalCost: stats?.totalCost ?? '0',
|
||||
currentUsageLimit: stats?.currentUsageLimit ?? null,
|
||||
|
||||
@@ -543,6 +543,12 @@ export class ExecutionLogger implements IExecutionLoggerService {
|
||||
case 'chat':
|
||||
updateFields.totalChatExecutions = sql`total_chat_executions + 1`
|
||||
break
|
||||
case 'mcp':
|
||||
updateFields.totalMcpExecutions = sql`total_mcp_executions + 1`
|
||||
break
|
||||
case 'a2a':
|
||||
updateFields.totalA2aExecutions = sql`total_a2a_executions + 1`
|
||||
break
|
||||
}
|
||||
|
||||
await db.update(userStats).set(updateFields).where(eq(userStats.userId, userId))
|
||||
|
||||
2
packages/db/migrations/0146_cultured_ikaris.sql
Normal file
2
packages/db/migrations/0146_cultured_ikaris.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "user_stats" ADD COLUMN "total_mcp_executions" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "user_stats" ADD COLUMN "total_a2a_executions" integer DEFAULT 0 NOT NULL;
|
||||
10384
packages/db/migrations/meta/0146_snapshot.json
Normal file
10384
packages/db/migrations/meta/0146_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1016,6 +1016,13 @@
|
||||
"when": 1768602646955,
|
||||
"tag": "0145_messy_archangel",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 146,
|
||||
"version": "7",
|
||||
"when": 1768867605608,
|
||||
"tag": "0146_cultured_ikaris",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -698,6 +698,8 @@ export const userStats = pgTable('user_stats', {
|
||||
totalWebhookTriggers: integer('total_webhook_triggers').notNull().default(0),
|
||||
totalScheduledExecutions: integer('total_scheduled_executions').notNull().default(0),
|
||||
totalChatExecutions: integer('total_chat_executions').notNull().default(0),
|
||||
totalMcpExecutions: integer('total_mcp_executions').notNull().default(0),
|
||||
totalA2aExecutions: integer('total_a2a_executions').notNull().default(0),
|
||||
totalTokensUsed: integer('total_tokens_used').notNull().default(0),
|
||||
totalCost: decimal('total_cost').notNull().default('0'),
|
||||
currentUsageLimit: decimal('current_usage_limit').default(DEFAULT_FREE_CREDITS.toString()), // Default $20 for free plan, null for team/enterprise
|
||||
|
||||
Reference in New Issue
Block a user