SDK
Overview
What the SDK does, when to use it, and how it fits next to the plugin you already installed.
The Analyse Java API (analyse-api) lets your own plugins talk to Analyse. It's what you use to track custom events, read A/B test variants, and look up the current session of a player.
You don't need the API for Analyse to work. The plugin does all the default tracking on its own. You only need the API when you want to teach Analyse about your server: your quests, your shops, your gamemodes, your custom features.
When you need it
Reach for the SDK when you want to:
- Send a custom event from your plugin (Custom events)
- Show one of two variants in an A/B test (A/B tests)
- Read the Campaign a player came from inside your own code
- Send events from a backend game server through your proxy
If none of that applies, you don't need the SDK.
The shape of the API
Everything lives under one static entry point: net.analyse.api.Analyse.
import net.analyse.api.Analyse;// Send a custom eventAnalyse.trackEvent("quest_completed").withPlayer(player.getUniqueId(), player.getName()).withData("quest_id", "dragon_slayer").withValue(500.0).send();// Read an A/B test variant for a playerString variant = Analyse.getVariant(player.getUniqueId(), "welcome-rewards");// Track a conversion for that testAnalyse.trackConversion(player.getUniqueId(), player.getName(),"welcome-rewards", "first_purchase");// Grab the live sessionAnalyse.sessions().getSession(player.getUniqueId());
That's about 90% of what most plugins use.
It's a normal plugin dependency
You don't ship the Analyse API as a shaded library. You add it as a compileOnly dependency and the Analyse plugin provides it at runtime. See SDK installation.
Requires the Analyse plugin
The API only works when the Analyse plugin is installed on the same server. Always wrap calls in Analyse.isAvailable() if you want your plugin to gracefully degrade when Analyse isn't there.
What lives where
| Class | Purpose |
|---|---|
Analyse | Static entry point. Most of what you'll use. |
Analyse.trackEvent(name) | Returns an EventBuilder to send custom events. |
Analyse.sessions() | The live SessionManager for the current server. |
Analyse.abTests() | The ABTestManager for programmatic A/B test control. |
AnalyseMessaging | Helpers for sending events from a backend through the proxy. |