Add anonymous analytics

This commit is contained in:
Christopher Cookman 2025-01-02 13:05:44 -07:00
parent 74f4d916c5
commit efe4ba607f
2 changed files with 58 additions and 1 deletions

View file

@ -13,4 +13,59 @@ module.exports = (req, res, next) => {
} }
} }
); );
if (path.includes('/v1/ban/roblox/')) {
pool.query(
'INSERT INTO globalAnalytics (tag, value) VALUES ("ROBLOX_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;',
(error) => {
if (error) {
console.error('Error logging global analytics:', error);
}
}
);
}
if (path.includes('/v1/ban/discord/')) {
pool.query(
'INSERT INTO globalAnalytics (tag, value) VALUES ("DISCORD_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;',
(error) => {
if (error) {
console.error('Error logging global analytics:', error);
}
}
);
}
if (path.includes('/v1/ban/')) {
pool.query(
'INSERT INTO globalAnalytics (tag, value) VALUES ("TOTAL_CHECKS", 1) ON DUPLICATE KEY UPDATE value = value + 1;',
(error) => {
if (error) {
console.error('Error logging global analytics:', error);
}
}
);
}
if (req.headers['roblox-id']) { // Roblox game ID. Insert if not exists into gameAnalytics table, if /v1/ban/roblox/:id is called incirment globalAnalytics key=TOTAL_CHECKS
pool.query(
'INSERT INTO gameAnalytics (gameID) VALUES (?) ON DUPLICATE KEY UPDATE gameID = gameID;',
[req.headers['roblox-id']],
(error) => {
if (error) {
console.error('Error logging game analytics:', error);
}
}
);
if (path.includes('/v1/ban/roblox/')) {
pool.query(
'INSERT INTO globalAnalytics (tag, value) VALUES ("ROBLOX_CHECKS_FROM_SERVERS", 1) ON DUPLICATE KEY UPDATE value = value + 1;',
(error) => {
if (error) {
console.error('Error logging global analytics:', error);
}
}
);
}
}
} }

View file

@ -134,7 +134,7 @@ console.log(process.env.REASON_FLAGS)
// Discord stuff // Discord stuff
const Discord = require("discord.js"); const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["Guilds", "GuildBans", "GuildMembers"] }) const client = new Discord.Client({ intents: ["Guilds", "GuildBans", "GuildMembers"] })
global.discord_client = client
client.on("ready", async () => { client.on("ready", async () => {
log.info(`Logged into Discord as ${client.user.displayName}`); log.info(`Logged into Discord as ${client.user.displayName}`);
const commands = require("./commands") const commands = require("./commands")
@ -179,6 +179,8 @@ client.on("interactionCreate", async (interaction) => {
} }
}); });
client.on('guildMemberAdd', require("./discordJoins.js"))
// Startup // Startup
log.info("Starting up...") log.info("Starting up...")
const bcrypt = require("bcrypt") const bcrypt = require("bcrypt")