Umami Analytics
Umami is a simple, fast, privacy-focused alternative to Google Analytics. CommandKit provides seamless integration with Umami for tracking anonymous bot metrics.
Setup
- First, install the analytics package:
npm install @commandkit/analytics
- Configure Umami in your CommandKit config:
import { umami } from '@commandkit/analytics/umami';
export default defineConfig({
plugins: [
umami({
umamiOptions: {
hostUrl: 'YOUR_UMAMI_HOST_URL',
websiteId: 'YOUR_UMAMI_WEBSITE_ID',
// Optional: Additional configuration
sessionId: 'YOUR_UMAMI_SESSION_ID',
userAgent: 'YOUR_UMAMI_USER_AGENT',
},
}),
],
});
Usage
Once configured, you can track anonymous events using the track
function:
import { track } from 'commandkit/analytics';
await track({
name: 'guild_event',
data: {
eventType: 'member_count_change',
// Track anonymous metrics
memberCount: guild.memberCount,
// Track timing patterns
timeOfDay: new Date().getHours(),
// Track performance
processingTime: 100, // ms
},
});
Automatic Events
CommandKit automatically tracks the following anonymous events in Umami:
command_execution
: Command execution eventscache_hit
: Cache hit eventscache_miss
: Cache miss eventscache_revalidated
: Cache revalidation eventsfeature_flag_metrics
: Feature flag metricsfeature_flag_decision
: Feature flag decision events- Anonymous interaction patterns
Best Practices
- Keep event names simple and descriptive
- Only track anonymous, aggregated data
- Avoid storing personal information
- Use hashed identifiers when necessary
- Be transparent about what data you collect
- Respect user privacy and Discord's Terms of Service
Next Steps
- Learn about PostHog analytics
- Learn how to create custom providers