feat: analytics
Code Analysis / SonarQube (push) Failing after 18s
Node.js CI / Lint and Test (push) Successful in 47s

This commit is contained in:
2025-10-08 14:59:54 -07:00
parent 930d705504
commit 84319a12fe
4 changed files with 66 additions and 6 deletions
+5
View File
@@ -3,6 +3,7 @@
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
import { Client, Events } from "discord.js";
import { about } from "./modules/about.js";
import { translate } from "./modules/translate.js";
@@ -29,7 +30,10 @@ const client = new Client({
intents: [],
});
const analytics = new DiscordAnalytics(client, logger);
client.on(Events.InteractionCreate, (interaction) => {
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
if (interaction.isMessageContextMenuCommand()) {
void translate(interaction);
}
@@ -48,6 +52,7 @@ client.on(Events.EntitlementDelete, (entitlement) => {
client.on(Events.ClientReady, () => {
void logger.log("debug", "Bot is ready.");
analytics.startCron();
});
instantiateServer();
+5
View File
@@ -111,6 +111,11 @@ export const translate = async(
translation: translation.translatedText,
}),
});
await logger.metric("translation", 1, {
locale: targetLocale,
sourceLocale: sourceLocale?.language ?? "default to en",
user: interaction.user.id,
});
} catch (error) {
const targetLocale = getLocale(interaction);
await replyToError(interaction, targetLocale);