mirror of
https://github.com/tiennm99/claude-status-webhook.git
synced 2026-04-17 15:20:37 +00:00
feat: add metrics tracking and remove unsupported HMAC verification
- Add metrics.js tracking webhooks, messages, cron, commands - Add GET /metrics/:secret endpoint (text + JSON format) - Remove HMAC verification (Statuspage doesn't support it) - Extract validateSecret helper in index.js - Integrate trackMetrics across webhook, queue, cron, bot handlers
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
} from "./kv-store.js";
|
||||
import { fetchComponentByName, escapeHtml } from "./status-fetcher.js";
|
||||
import { registerInfoCommands } from "./bot-info-commands.js";
|
||||
import { trackMetrics } from "./metrics.js";
|
||||
|
||||
/**
|
||||
* Extract chatId and threadId from grammY context
|
||||
@@ -26,6 +27,12 @@ export async function handleTelegramWebhook(c) {
|
||||
const bot = new Bot(c.env.BOT_TOKEN);
|
||||
const kv = c.env.claude_status;
|
||||
|
||||
// Track command usage
|
||||
bot.use(async (ctx, next) => {
|
||||
await trackMetrics(kv, { commandsProcessed: 1 });
|
||||
await next();
|
||||
});
|
||||
|
||||
bot.command("start", async (ctx) => {
|
||||
const { chatId, threadId } = getChatTarget(ctx);
|
||||
await addSubscriber(kv, chatId, threadId);
|
||||
|
||||
Reference in New Issue
Block a user