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

This commit is contained in:
2025-10-08 15:28:49 -07:00
parent b848009011
commit 1db44891bb
5 changed files with 65 additions and 6 deletions
+5
View File
@@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
import {
ActionRowBuilder,
Client,
@@ -24,10 +25,13 @@ const callista = new Client({
intents: [],
});
const analytics = new DiscordAnalytics(callista, logger);
// eslint-disable-next-line max-statements, complexity, max-lines-per-function -- Reason: It's fine like this
const handleInteraction = async(
interaction: BaseInteraction,
): Promise<void> => {
await analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
if (interaction.isButton()) {
if (!interaction.channel) {
await callista.channels.fetch(interaction.channelId);
@@ -83,6 +87,7 @@ const handleInteraction = async(
callista.once("ready", () => {
void logger.log("debug", "Callista is online!");
analytics.startCron();
});
callista.on(Events.InteractionCreate, (interaction) => {
+2
View File
@@ -12,6 +12,7 @@ import {
import { addNote } from "../buttons/addNote.js";
import { discord } from "../buttons/discord.js";
import { donate } from "../buttons/donate.js";
import { logger } from "../utils/logger.js";
/**
* Bookmarks the target message by sending the user a DM with the message link.
@@ -50,4 +51,5 @@ export const bookmark = async(
await interaction.editReply({
content: "✅ I've sent you a DM with the message link!",
});
await logger.metric("bookmarks", 1, { user: user.id });
};
+2
View File
@@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import { logger } from "../utils/logger.js";
import type { MessageContextMenuCommandInteraction } from "discord.js";
/**
@@ -20,4 +21,5 @@ export const deleteCmd = async(
await interaction.editReply({
content: "✅ I've deleted the target message!",
});
await logger.metric("bookmark", -1, { user: interaction.user.id });
};