Skip to content

Commit 08748db

Browse files
committed
docs: update the docs on count so people understand what dimensions are
1 parent 1db5745 commit 08748db

File tree

1 file changed

+9
-5
lines changed
  • application/src/main/java/org/togetherjava/tjbot/features/analytics

1 file changed

+9
-5
lines changed

application/src/main/java/org/togetherjava/tjbot/features/analytics/Metrics.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ public void count(String event) {
4545
}
4646

4747
/**
48-
* Track an event execution with custom dimensions.
48+
* Track an event execution with additional contextual data.
4949
*
50-
* @param event the event to save
51-
* @param dimensions key-value pairs providing additional context for the event
50+
* @param event the name of the event to record (e.g. "user_signup", "purchase")
51+
* @param dimensions optional key-value pairs providing extra context about the event. These are
52+
* often referred to as "metadata" and can include things like: userId: "12345", name:
53+
* "John Smith", channel_name: "chit-chat" etc. This data helps with filtering, grouping,
54+
* and analyzing events later. Note: A value for a metric should be a Java primitive
55+
* (String, int, double, long float).
5256
*/
53-
public void count(String event, Map<String, String> dimensions) {
57+
public void count(String event, Map<String, Object> dimensions) {
5458
logger.debug("Counting new record for event: {}", event);
5559

5660
Instant happenedAt = Instant.now();
@@ -60,7 +64,7 @@ public void count(String event, Map<String, String> dimensions) {
6064
dimensions.isEmpty() ? null : serializedDimensions));
6165
}
6266

63-
private static String serializeDimensions(Map<String, String> dimensions) {
67+
private static String serializeDimensions(Map<String, Object> dimensions) {
6468
try {
6569
return OBJECT_MAPPER.writeValueAsString(dimensions);
6670
} catch (JsonProcessingException e) {

0 commit comments

Comments
 (0)