feat: analytics
Node.js CI / Lint and Test (push) Successful in 52s

This commit is contained in:
2025-10-07 18:26:02 -07:00
parent 7eaa4416d5
commit b9214d6ff1
4 changed files with 66 additions and 7 deletions
+5
View File
@@ -15,6 +15,7 @@ import {
type Message,
} from "discord.js";
import { checkGuildEntitlement } from "../utils/checkEntitlement.js";
import { logger } from "../utils/logger.js";
import type { Liora } from "../interfaces/liora.js";
/**
@@ -41,6 +42,10 @@ const messageCreate = async(
return;
}
await logger.metric("highlight_triggered", highlights.length, {
guildId: message.guild.id,
});
await Promise.all(
// eslint-disable-next-line max-lines-per-function -- It's mostly components.
highlights.map(async(record) => {
+5 -1
View File
@@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
import { PrismaClient } from "@prisma/client";
import {
Client,
@@ -25,17 +26,20 @@ const liora: Liora = {
GatewayIntentBits.MessageContent,
],
}),
};
const analytics = new DiscordAnalytics(liora.discord, logger);
liora.discord.once(Events.ClientReady, () => {
void logger.log(
"debug",
`Logged in as ${liora.discord.user?.username ?? "unknown"}`,
);
analytics.startCron();
});
liora.discord.on(Events.InteractionCreate, (interaction) => {
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
if (interaction.isChatInputCommand()) {
if (!interaction.inCachedGuild()) {
void interaction.reply({