Skip to content

Commit 28eecb9

Browse files
committed
feat: update slash commands
1 parent 8ac5a57 commit 28eecb9

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,14 @@ public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
385385
SlashCommand interactor = requireUserInteractor(
386386
UserInteractionType.SLASH_COMMAND.getPrefixedName(name), SlashCommand.class);
387387

388-
String eventName = "slash-" + name;
388+
Map<String, Object> dimensions = new HashMap<>();
389+
dimensions.put("name", name);
390+
389391
if (event.getSubcommandName() != null) {
390-
eventName += "_" + event.getSubcommandName();
392+
dimensions.put("subCommandName", event.getSubcommandName());
391393
}
392-
metrics.count(eventName);
394+
395+
metrics.count("slash", dimensions);
393396

394397
interactor.onSlashCommand(event);
395398
});

application/src/main/resources/db/V17__Add_Metric_Dimensions.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,19 @@ WHERE event LIKE 'tag-%';
2323
UPDATE metric_events
2424
SET event = 'top_helper',
2525
dimensions = json_object('userId', CAST(SUBSTR(event, LENGTH('top_helper-') + 1) AS INTEGER))
26-
WHERE event LIKE 'top_helper-%';
26+
WHERE event LIKE 'top_helper-%';
27+
28+
UPDATE metric_events
29+
SET event = 'slash',
30+
dimensions = json_object(
31+
'name', SUBSTR(event, LENGTH('slash-') + 1, INSTR(SUBSTR(event, LENGTH('slash-') + 1), '_') - 1),
32+
'subCommandName', SUBSTR(event, LENGTH('slash-') + 1 + INSTR(SUBSTR(event, LENGTH('slash-') + 1), '_'))
33+
)
34+
WHERE event LIKE 'slash-%'
35+
AND INSTR(SUBSTR(event, LENGTH('slash-') + 1), '_') > 0;
36+
37+
UPDATE metric_events
38+
SET event = 'slash',
39+
dimensions = json_object('name', SUBSTR(event, LENGTH('slash-') + 1))
40+
WHERE event LIKE 'slash-%'
41+
AND INSTR(SUBSTR(event, LENGTH('slash-') + 1), '_') = 0;

0 commit comments

Comments
 (0)