Skip to content

Commit c0a2e6d

Browse files
committed
docs: add missing event types
1 parent fefd559 commit c0a2e6d

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

apps/website/docs/guide/10-analytics/01-analytics-in-commandkit.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ CommandKit automatically tracks various anonymous metrics:
2525
- Cache hits (`cache_hit`)
2626
- Cache misses (`cache_miss`)
2727
- Cache revalidations (`cache_revalidated`)
28+
- Feature flag metrics:
29+
- Feature flag metrics (`feature_flag_metrics`)
30+
- Feature flag decisions (`feature_flag_decision`)
2831
- Anonymous interaction patterns
2932

3033
## Installation

apps/website/docs/guide/10-analytics/02-posthog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ CommandKit automatically tracks the following anonymous events in PostHog:
8080
- `cache_hit`: Cache hit events
8181
- `cache_miss`: Cache miss events
8282
- `cache_revalidated`: Cache revalidation events
83+
- `feature_flag_metrics`: Feature flag metrics
84+
- `feature_flag_decision`: Feature flag decision events
8385

8486
## Best Practices
8587

apps/website/docs/guide/10-analytics/03-umami.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ CommandKit automatically tracks the following anonymous events in Umami:
6464
- `cache_hit`: Cache hit events
6565
- `cache_miss`: Cache miss events
6666
- `cache_revalidated`: Cache revalidation events
67+
- `feature_flag_metrics`: Feature flag metrics
68+
- `feature_flag_decision`: Feature flag decision events
6769
- Anonymous interaction patterns
6870

6971
## Best Practices

packages/commandkit/src/analytics/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { randomUUID } from 'node:crypto';
33
export const DO_NOT_TRACK_KEY = `COMMANDKIT_ANALYTICS__DO_NOT_TRACK::${randomUUID()}`;
44

55
export const AnalyticsEvents = {
6+
// commands
67
COMMAND_EXECUTION: 'command_execution',
8+
// feature flags
9+
FEATURE_FLAG_METRICS: 'feature_flag_metrics',
10+
FEATURE_FLAG_DECISION: 'feature_flag_decision',
711
// @commandkit/cache
812
CACHE_HIT: 'cache_hit',
913
CACHE_MISS: 'cache_miss',

packages/commandkit/src/flags/feature-flags.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from 'discord.js';
1515
import { LoadedCommand } from '../app';
1616
import { defer, JsonSerialize } from '../utils/utilities';
17+
import { AnalyticsEvents } from '../analytics/constants';
1718

1819
export type MaybePromise<T> = T | Promise<T>;
1920

@@ -160,7 +161,7 @@ export class FeatureFlag<R, T> {
160161

161162
defer(async () => {
162163
await this.commandkit.analytics.track({
163-
name: 'feature_flag_metrics',
164+
name: AnalyticsEvents.FEATURE_FLAG_METRICS,
164165
data: {
165166
flag: this.options.key,
166167
identificationTime: identificationTime.toFixed(2),
@@ -171,7 +172,7 @@ export class FeatureFlag<R, T> {
171172

172173
defer(async () => {
173174
await this.commandkit.analytics.track({
174-
name: 'feature_flag_decision',
175+
name: AnalyticsEvents.FEATURE_FLAG_DECISION,
175176
id:
176177
entities &&
177178
typeof entities === 'object' &&

0 commit comments

Comments
 (0)