Hoglin SDK Reference
The Hoglin SDK lets you track any event from your Minecraft server plugin with just a few lines of code. This page documents all available classes, methods, and configuration options.
Installation
Section titled “Installation”See Getting Started for installation instructions.
Hoglin.Builder
Section titled “Hoglin.Builder”The main entrypoint for creating a Hoglin instance.
val analytics = Hoglin.Builder("<your server key>") .autoFlushInterval(5_000L) .maxBatchSize(50) .build()
Hoglin analytics = new Hoglin.Builder("<your server key>") .autoFlushInterval(5_000L) .maxBatchSize(50) .build();
Builder Options
Section titled “Builder Options”Method | Type | Default | Description |
---|---|---|---|
autoFlushInterval(ms) | Long | 5000 | How often (ms) to send queued events |
maxBatchSize(n) | Int | 50 | Max events sent per batch |
enableAutoFlush(b) | Boolean | true | Whether to auto-flush events |
baseUrl(url) | String | https://api.hoglin.gg | API endpoint (should never be used, outside of certain circumstances) |
Hoglin
Methods
Section titled “Hoglin Methods”track(eventType: String, properties: Map<String, Any>)
Section titled “track(eventType: String, properties: Map<String, Any>)”Tracks a custom event.
analytics.track("player_join", mapOf( "player_uuid" to event.player.uniqueId))
Map<String, String> properties = new HashMap<>();properties.put("player_uuid", event.getPlayer().getUniqueId(),toString());analytics.track("player_join", properties);
- eventType: Name of the event (e.g.
"player_join"
) - properties: Key-value pairs of event data (any serializable value)
flush()
Section titled “flush()”Immediately sends all queued events to the server.
analytics.flush();
shutdownBlocking()
Section titled “shutdownBlocking()”Stops the auto-flushing task and flushes all current events (call this in onDisable
or equivalent).
analytics.shutdownBlocking()
Event Schema
Section titled “Event Schema”Each event you send with the SDK has:
Field | Type | Description |
---|---|---|
event_type | String | Name of the event |
timestamp | Long (ms) | When the event was tracked |
properties | Map<String,Any> | Your custom event data |
Error Handling
Section titled “Error Handling”- The SDK queues events locally and retries if the API is unavailable.
- No events are lost unless the server is stopped before flushing.
- Use
flush()
orshutdownBlocking()
to ensure all events are sent.
Example Usage
Section titled “Example Usage”val analytics = Hoglin.Builder("<your server key>") .autoFlushInterval(5_000L) .maxBatchSize(50) .build()
analytics.track("player_death", mapOf( "player_uuid" to player.uniqueId, "cause" to event.deathMessage))
Hoglin analytics = new Hoglin.Builder("<your server key>") .autoFlushInterval(5_000L) .maxBatchSize(50) .build();
Map<String, Object> properties = new HashMap<>();properties.put("player_uuid", player.getUniqueId());properties.put("cause", event.getDeathMessage());analytics.track("player_death", properties);
-
What happens if my server loses connection?
Events are queued and retried automatically.
-
Is there a limit to property keys/values?
No hard limit, but keep payloads reasonable for performance.