mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2026-03-03 15:10:53 +01:00
Add metrics
This commit is contained in:
@@ -12,6 +12,7 @@ import * as Messages from "./messages";
|
||||
import * as CallbackData from "./callback_data";
|
||||
|
||||
import * as BookLibrary from "./services/book_library";
|
||||
import UsersCounter from '@/analytics/users_counter';
|
||||
import { createOrUpdateUserSettings, getUserSettings } from './services/user_settings';
|
||||
import { formatBook, formatAuthor, formatSequence, formatTranslator } from './format';
|
||||
import { getCallbackArgs, getPaginatedMessage, getPrefixWithQueryCreator, getSearchArgs, registerLanguageSettingsCallback, registerPaginationCommand, registerRandomItemCallback } from './utils';
|
||||
@@ -45,8 +46,9 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
||||
last_name: user.last_name || '',
|
||||
first_name: user.first_name,
|
||||
username: user.username || '',
|
||||
source: ctx.botInfo.username,
|
||||
source: me.username,
|
||||
});
|
||||
UsersCounter.take(user.id, me.username);
|
||||
}
|
||||
await next();
|
||||
});
|
||||
|
||||
@@ -11,6 +11,8 @@ import { Telegraf } from 'telegraf';
|
||||
|
||||
import env from '@/config';
|
||||
import getBot, { BotStatuses } from './factory/index';
|
||||
import UsersCounter from '@/analytics/users_counter';
|
||||
|
||||
|
||||
Sentry.init({
|
||||
dsn: env.SENTRY_DSN,
|
||||
@@ -126,6 +128,10 @@ export default class BotsManager {
|
||||
res.send("Ok!");
|
||||
});
|
||||
|
||||
application.get("/metrics", (req, res) => {
|
||||
res.send(UsersCounter.getMetrics());
|
||||
});
|
||||
|
||||
application.use((req: Request, res: Response, next: NextFunction) => this.handleUpdate(req, res, next));
|
||||
|
||||
this.server = application.listen(env.WEBHOOK_PORT);
|
||||
|
||||
Reference in New Issue
Block a user