Skip to content

Commit 9efd3d5

Browse files
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
1 parent e575ba2 commit 9efd3d5

File tree

7 files changed

+10405
-0
lines changed

7 files changed

+10405
-0
lines changed

apps/sim/app/api/v1/admin/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ export interface AdminUserBilling {
550550
totalWebhookTriggers: number
551551
totalScheduledExecutions: number
552552
totalChatExecutions: number
553+
totalMcpExecutions: number
554+
totalA2aExecutions: number
553555
totalTokensUsed: number
554556
totalCost: string
555557
currentUsageLimit: string | null

apps/sim/app/api/v1/admin/users/[id]/billing/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export const GET = withAdminAuthParams<RouteParams>(async (_, context) => {
9797
totalWebhookTriggers: stats?.totalWebhookTriggers ?? 0,
9898
totalScheduledExecutions: stats?.totalScheduledExecutions ?? 0,
9999
totalChatExecutions: stats?.totalChatExecutions ?? 0,
100+
totalMcpExecutions: stats?.totalMcpExecutions ?? 0,
101+
totalA2aExecutions: stats?.totalA2aExecutions ?? 0,
100102
totalTokensUsed: stats?.totalTokensUsed ?? 0,
101103
totalCost: stats?.totalCost ?? '0',
102104
currentUsageLimit: stats?.currentUsageLimit ?? null,

apps/sim/lib/logs/execution/logger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,12 @@ export class ExecutionLogger implements IExecutionLoggerService {
543543
case 'chat':
544544
updateFields.totalChatExecutions = sql`total_chat_executions + 1`
545545
break
546+
case 'mcp':
547+
updateFields.totalMcpExecutions = sql`total_mcp_executions + 1`
548+
break
549+
case 'a2a':
550+
updateFields.totalA2aExecutions = sql`total_a2a_executions + 1`
551+
break
546552
}
547553

548554
await db.update(userStats).set(updateFields).where(eq(userStats.userId, userId))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "user_stats" ADD COLUMN "total_mcp_executions" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
2+
ALTER TABLE "user_stats" ADD COLUMN "total_a2a_executions" integer DEFAULT 0 NOT NULL;

0 commit comments

Comments
 (0)