API Reference
Complete reference for all public classes and methods in the Analyse SDK.
Analyse
Main entry point for the SDK. All methods are static.
import net.analyse.api.Analyse;
Availability
| Method | Returns | Description |
|---|
isAvailable() | boolean | Check if Analyse is initialized and ready |
get() | AnalysePlatform | Get the platform instance (throws if unavailable) |
if (Analyse.isAvailable()) {
}
Event Tracking
| Method | Returns | Description |
|---|
trackEvent(String name) | EventBuilder | Create a new event |
trackEvent(String name, UUID uuid, String username) | EventBuilder | Create event with player |
trackEvent(String name, Map<String, Object> data) | EventBuilder | Create event with data |
Analyse.trackEvent("event_name")
.withPlayer(uuid, username)
.withData("key", "value")
.withValue(100.0)
.send();
A/B Testing
| Method | Returns | Description |
|---|
getVariant(UUID uuid, String testKey) | String | Get assigned variant (null if inactive) |
isTestActive(String testKey) | boolean | Check if test is active |
getActiveTests() | List<ABTest> | Get all active tests |
getTest(String testKey) | ABTest | Get test by key (null if not found) |
trackConversion(UUID, String, String, String) | void | Track a conversion event |
String variant = Analyse.getVariant(uuid, "test-key");
Analyse.trackConversion(uuid, username, "test-key", "event_name");
Manager Shortcuts
| Method | Returns | Description |
|---|
sessions() | SessionManager | Get the session manager |
abTests() | ABTestManager | Get the A/B test manager |
EventBuilder
Fluent builder for custom events. Create via Analyse.trackEvent().
import net.analyse.api.object.builder.EventBuilder;
Builder Methods
| Method | Parameters | Returns | Description |
|---|
withPlayer | UUID uuid, String username | EventBuilder | Associate with player |
withPlayer | UUID uuid | EventBuilder | Associate with player (UUID only) |
withData | String key, Object value | EventBuilder | Add single data field |
withData | Map<String, Object> data | EventBuilder | Add multiple data fields |
withValue | double value | EventBuilder | Set numeric value |
send | | void | Send event (fire and forget) |
send | Consumer<Boolean> callback | void | Send with callback |
Getters
| Method | Returns |
|---|
getName() | String |
getPlayerUuid() | UUID |
getPlayerUsername() | String |
getData() | Map<String, Object> |
getValue() | Double |
Example
Analyse.trackEvent("quest_completed")
.withPlayer(player.getUniqueId(), player.getName())
.withData("quest_id", "dragon_slayer")
.withData("difficulty", "hard")
.withData("time_minutes", 45)
.withValue(500.0)
.send(success -> {
if (success) {
log.info("Event tracked successfully");
}
});
SessionManager
Manages player analytics sessions.
import net.analyse.api.manager.SessionManager;
SessionManager sessions = Analyse.sessions();
Methods
| Method | Parameters | Returns | Description |
|---|
getSession | UUID uuid | Optional<PlayerSession> | Get player's session |
hasSession | UUID uuid | boolean | Check if player has session |
getAllSessions | | Collection<PlayerSession> | Get all active sessions |
getSessionCount | | int | Get count of active sessions |
Example
Analyse.sessions().getSession(uuid).ifPresent(session -> {
String hostname = session.getHostname();
Instant joinTime = session.getJoinTime();
});
PlayerSession
Represents a player's analytics session. Obtained from SessionManager.
import net.analyse.api.session.PlayerSession;
Methods
| Method | Returns | Description |
|---|
getPlayerUuid() | UUID | Player's unique ID |
getSessionId() | String | Analytics session ID (null if pending) |
getHostname() | String | Hostname player connected with |
getIp() | String | Player's IP address |
getJoinTime() | Instant | When player joined |
hasActiveSession() | boolean | If registered with API |
ABTestManager
Manages A/B tests and variant assignments.
import net.analyse.api.manager.ABTestManager;
ABTestManager abTests = Analyse.abTests();
Methods
| Method | Parameters | Returns | Description |
|---|
getActiveTests | | List<ABTest> | Get all active tests |
getTest | String testKey | ABTest | Get test by key |
getVariant | UUID uuid, String testKey | String | Get assigned variant |
isTestActive | String testKey | boolean | Check if test is active |
trackConversion | UUID, String, String, String | void | Track conversion |
ABTest
Represents an A/B test configuration.
import net.analyse.api.object.abtest.ABTest;
Methods
| Method | Returns | Description |
|---|
getId() | String | Test ID |
getKey() | String | Test key (used in code) |
getName() | String | Display name |
getTrigger() | Trigger | When test activates |
getTriggerCommand() | String | Command trigger (if applicable) |
getTriggerEvent() | String | Event trigger (if applicable) |
isCancelCommand() | boolean | Cancel command on trigger |
getStatus() | Status | Test status |
getVariants() | List<Variant> | All variants |
getPrimaryMetric() | String | Primary conversion metric |
isActive() | boolean | If test is active |
assignVariant(UUID) | Variant | Assign variant to player |
getVariant(String) | Variant | Get variant by key |
Enums
ABTest.Trigger {
FIRST_JOIN,
EVERY_JOIN,
ON_COMMAND,
ON_EVENT
}
ABTest.Status {
DRAFT,
ACTIVE,
PAUSED,
COMPLETED
}
Matching Methods
| Method | Parameters | Returns | Description |
|---|
matchesTrigger | Trigger trigger | boolean | Check trigger type |
matchesCommand | String command | boolean | Check if command triggers |
matchesEvent | String eventName | boolean | Check if event triggers |
Variant
Represents a variant in an A/B test.
import net.analyse.api.object.abtest.Variant;
Methods
| Method | Returns | Description |
|---|
getKey() | String | Variant key |
getName() | String | Display name |
getWeight() | int | Traffic weight (0-100) |
hasActions() | boolean | Has configured actions |
Exceptions
IllegalStateException
Thrown when SDK is used before initialization:
try {
Analyse.trackEvent("test").send();
} catch (IllegalStateException e) {
}
Prevent with availability check:
if (Analyse.isAvailable()) {
Analyse.trackEvent("test").send();
}
IllegalArgumentException
Thrown for invalid parameters:
Analyse.trackEvent(null);
Analyse.trackEvent("");