Add light telemetry (command counting)

This commit is contained in:
Ean Milligan (Bastion) 2023-04-07 00:30:47 -04:00
parent 5ccf65d89b
commit 0a4c622dfe
4 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,11 @@ const actions = [
'cmd-info', 'cmd-info',
'cmd-report', 'cmd-report',
'cmd-setup', 'cmd-setup',
'cmd-gameSel',
'btn-gameSel',
'btn-customAct',
'btn-createEvt',
'btn-createWLEvt',
]; ];
for (const action of actions) { for (const action of actions) {
await dbClient.execute('INSERT INTO command_cnt(command) values(?)', [action]).catch((e) => { await dbClient.execute('INSERT INTO command_cnt(command) values(?)', [action]).catch((e) => {

View File

@ -20,6 +20,7 @@ import utils from '../../utils.ts';
import { customId as createCustomActivityBtnId } from './step1a-openCustomModal.ts'; import { customId as createCustomActivityBtnId } from './step1a-openCustomModal.ts';
import { customId as finalizeEventBtnId } from './step2-finalize.ts'; import { customId as finalizeEventBtnId } from './step2-finalize.ts';
import { monthsShort } from './dateTimeUtils.ts'; import { monthsShort } from './dateTimeUtils.ts';
import { dbClient, queries } from '../../db.ts';
export const customId = 'gameSel'; export const customId = 'gameSel';
export const eventTimeId = 'eventTime'; export const eventTimeId = 'eventTime';
@ -45,6 +46,14 @@ const customEventRow: ActionRow = {
const execute = async (bot: Bot, interaction: Interaction) => { const execute = async (bot: Bot, interaction: Interaction) => {
if (interaction.data && (interaction.data.name === slashCommandName || interaction.data.customId) && interaction.member && interaction.guildId && interaction.channelId) { if (interaction.data && (interaction.data.name === slashCommandName || interaction.data.customId) && interaction.member && interaction.guildId && interaction.channelId) {
// Light Telemetry
if (interaction.data.name === slashCommandName) {
dbClient.execute(queries.callIncCnt('cmd-gameSel')).catch((e) => utils.commonLoggers.dbError('step1-gameSelection.ts@cmd', 'call sproc INC_CNT on', e));
}
if (interaction.data.customId === customId) {
dbClient.execute(queries.callIncCnt('btn-gameSel')).catch((e) => utils.commonLoggers.dbError('step1-gameSelection.ts@btn', 'call sproc INC_CNT on', e));
}
// Check if we are done // Check if we are done
const customIdIdxPath = (interaction.data.customId || '').substring((interaction.data.customId || '').indexOf(idSeparator) + 1) || ''; const customIdIdxPath = (interaction.data.customId || '').substring((interaction.data.customId || '').indexOf(idSeparator) + 1) || '';
const valuesIdxPath = interaction.data?.values?.[0] || ''; const valuesIdxPath = interaction.data?.values?.[0] || '';

View File

@ -2,6 +2,7 @@ import { Bot, Interaction, InteractionResponseTypes, MessageComponentTypes, Text
import { deleteTokenEarly, idSeparator, pathIdxSeparator } from './utils.ts'; import { deleteTokenEarly, idSeparator, pathIdxSeparator } from './utils.ts';
import { customId as verifyCustomActivityId } from './step1b-verifyCustomActivity.ts'; import { customId as verifyCustomActivityId } from './step1b-verifyCustomActivity.ts';
import utils from '../../utils.ts'; import utils from '../../utils.ts';
import { dbClient, queries } from '../../db.ts';
export const customId = 'customAct'; export const customId = 'customAct';
@ -11,6 +12,9 @@ export const activityMaxPlayersId = 'activityMaxPlayers';
const execute = async (bot: Bot, interaction: Interaction) => { const execute = async (bot: Bot, interaction: Interaction) => {
if (interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId) { if (interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId) {
// Light Telemetry
dbClient.execute(queries.callIncCnt('btn-customAct')).catch((e) => utils.commonLoggers.dbError('step1a-openCustomModal.ts', 'call sproc INC_CNT on', e));
const [actTitle, actSubtitle, activityMaxPlayers] = (interaction.data.customId.split(idSeparator)[1] || '').split(pathIdxSeparator); const [actTitle, actSubtitle, activityMaxPlayers] = (interaction.data.customId.split(idSeparator)[1] || '').split(pathIdxSeparator);
await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id); await deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);

View File

@ -10,6 +10,11 @@ const execute = async (bot: Bot, interaction: Interaction) => {
if ( if (
interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].fields interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId && interaction.message && interaction.message.embeds[0] && interaction.message.embeds[0].fields
) { ) {
// Light Telemetry
dbClient.execute(queries.callIncCnt(interaction.data.customId.includes(idSeparator) ? 'btn-createWLEvt' : 'btn-createEvt')).catch((e) =>
utils.commonLoggers.dbError('step3-createEvent.ts', 'call sproc INC_CNT on', e)
);
deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id); deleteTokenEarly(bot, interaction, interaction.guildId, interaction.channelId, interaction.member.id);
// Get OwnerId and EventTime from embed for DB // Get OwnerId and EventTime from embed for DB