Developer API
Other plugins emit telemetry by calling the AnalyticsService interface — the same interface used internally for join, command, and LuckPerms events. There is no AstralAnalytics-specific dependency to add; the interface lives in AstralCore.
Maven coordinates
The interface is part of core-commons:
AstralAnalytics registers the implementation at runtime with AstralCore's service repository, so your plugin only depends on the interface.
Looking up the service
On Velocity the lookup is AstralVelocityAPI.getService(AnalyticsService.class). On MageHic it is MageHicAPI.services().get(AnalyticsService.class).
The service is Optional<>-typed: when AstralAnalytics isn't installed your plugin keeps working — it just doesn't emit telemetry.
AnalyticsService
Three overloads, all fire-and-forget:
Parameter | Description |
|---|---|
| The subject of the event. Pass |
| Discriminator stored in the |
| Anything that round-trips through Gson. The result is stored as a |
The implementation never throws into the caller — RabbitMQ failures are logged at WARN.
Add an ip field to your payload to trigger GeoIP enrichment: the master appends a country ISO code before persisting. See Architecture.
The track-event action
For YAML-driven instrumentation (menus, dialogs, filters), AstralAnalytics registers a single AstralCore action:
Argument format: <type> <json> — the first token is the event type, the rest is the JSON payload. Both parts go through AstralCore placeholder substitution, so you can mix in %player_*%, %parameters_*%, and any other placeholder.
The action calls AnalyticsService.log(player.uniqueId, type, payload) with the player who clicked, so the event is automatically attributed to them.
Conventions
When you add a new event type from your plugin:
Convention | Why |
|---|---|
| Matches the built-in types and reads better in dashboards. |
Stable field names. | Renaming breaks every dashboard / query that already filters on the field. |
Include | The |
Don't include | The master appends |
Numbers as numbers, durations in milliseconds. | Matches the built-in |
When to skip the API
The master exposes a MHAnalyticsService that bypasses RabbitMQ for MageHic-side plugins running in the master JVM. Same AnalyticsService interface — same overloads — so your code doesn't change. The only difference is the resulting rows carry server_name = server_group = "magehic" instead of the local server tags. See Architecture for the rationale.