Skip to content

Collection Overview

How the SDK detects, categorizes, and delivers analytics data from your Discord bot to the Dicolytics backend.

Three Data Categories

The SDK organizes all collected data into three categories based on the direction of the action and how it is detected:

CategoryWhat It CapturesDetection MethodDelivery ModeDashboard Metric
InteractionsUser-initiated actions sent to your botinteractionCreate gateway eventPer-event (immediate)interactions
ActionsBot-initiated REST API calls to DiscordREST method patching (post, patch, put, delete)Per-event (immediate)actions
EventsServer activity flowing through the gatewayGateway event listeners (guildMemberAdd, messageCreate, etc.)Aggregated (60-second counter flush)discord_events

How detection works

  • Interactions are detected via a single interactionCreate listener. The SDK classifies each interaction by type and measures response latency by patching reply(), deferReply(), editReply(), and followUp() on each interaction instance.
  • Actions are detected by patching client.rest.post, .patch, .put, and .delete methods. Each outbound REST call is matched against a route table to identify the action type. No request payload is ever inspected -- only the route and HTTP method matter.
  • Events are detected by registering listeners on discord.js client events. Each listener increments a counter, which is flushed every 60 seconds as an aggregated data.count value.

Delivery Flow

Your Bot Process                    Dicolytics Backend
                                    
  SDK captures event                
    |                               
    v                               
  Serialize & enqueue               
  (UUIDv7 id assigned)              
    |                               
    v                               
  Queue (max 5,000 events)          
    |                               
    |-- 50 events pending? -------> Flush
    |-- 5 second timer fires? ----> Flush
    |                               
    v                               
  HTTP POST /v1/events              
  (batch: max 500 events / 1 MiB)  
    |                               
    v                               
  Dicolytics validates & stores     
    |                               
    v                               
  Database

Queue Behavior

ParameterValueConfigurable
Flush trigger (event count)50 eventsNo
Flush trigger (timer)5 secondsYes (flushIntervalMs)
Max queued events5,000No
Max events per batch500No
Max batch body size1 MiBNo

Note

When the queue exceeds 5,000 events, the oldest events are dropped first. This protects memory but means data loss under extreme load. If drops occur, the SDK logs a warning and a console.warn is emitted once.

Retry Policy

Failed requests are retried with full-jitter exponential backoff:

ScenarioBehavior
2xxAccepted. Batch complete.
400Dropped. Bad request, no retry.
401Transport permanently disabled. API key rejected.
403Retryable. May be transient (CDN/WAF).
429Quiet period from Retry-After header (default 300s). Only heartbeat and guild_snapshot keep flowing.
5xx / network errorJittered exponential backoff, max 5 attempts.

See Transport & Retries for the full specification.

Python SDK

The Python SDK (dicolytics) sends "name": "dicolytics-discord.py" in the sdk envelope field, with version 0.1.0. The envelope format is otherwise identical to the discord.js SDK.

Additional Data Types

Beyond the three main categories, the SDK also emits:

TypeDescriptionDeliveryStored In
heartbeatPer-shard health snapshot (guild count, ping, memory, CPU, etc.)Every 60sbot_snapshots
guild_snapshotPer-guild state (member count, online count, name, locale)Every 60sguild_snapshots
command_errorError during interaction reply lifecyclePer-eventevents
errorExplicit error report via captureError() or unhandledRejectionPer-eventevents
customDeveloper-defined events via track()Per-eventevents
api_routes_snapshotTop 10 REST API routes by call countEvery 5 minevents

Snapshots and quota

heartbeat and guild_snapshot events are stored in dedicated tables (bot_snapshots and guild_snapshots) and do not count against event quota. They also bypass the 429 quiet period to ensure uptime tracking remains accurate.

Intent Auto-detection

The SDK checks your bot's configured intents at attach time. Gateway event listeners are only registered for events whose required intent is present. For example:

  • event_member_join requires GuildMembers intent
  • event_message_create requires GuildMessages intent
  • event_presence_update requires GuildPresences intent (privileged)

If an intent is missing, the corresponding listeners are simply not registered -- no error is thrown. Enable debug: true to see which listeners were registered and the detected intent bitfield.

Learn More

Dicolytics — Discord bot analytics