Sign In

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

MethodReturnsDescription
isAvailable()booleanCheck if Analyse is initialized and ready
get()AnalysePlatformGet the platform instance (throws if unavailable)
if (Analyse.isAvailable()) {
// Safe to use SDK
}

Event Tracking

MethodReturnsDescription
trackEvent(String name)EventBuilderCreate a new event
trackEvent(String name, UUID uuid, String username)EventBuilderCreate event with player
trackEvent(String name, Map<String, Object> data)EventBuilderCreate event with data
Analyse.trackEvent("event_name")
.withPlayer(uuid, username)
.withData("key", "value")
.withValue(100.0)
.send();

A/B Testing

MethodReturnsDescription
getVariant(UUID uuid, String testKey)StringGet assigned variant (null if inactive)
isTestActive(String testKey)booleanCheck if test is active
getActiveTests()List<ABTest>Get all active tests
getTest(String testKey)ABTestGet test by key (null if not found)
trackConversion(UUID, String, String, String)voidTrack a conversion event
String variant = Analyse.getVariant(uuid, "test-key");
Analyse.trackConversion(uuid, username, "test-key", "event_name");

Manager Shortcuts

MethodReturnsDescription
sessions()SessionManagerGet the session manager
abTests()ABTestManagerGet the A/B test manager

EventBuilder

Fluent builder for custom events. Create via Analyse.trackEvent().

import net.analyse.api.object.builder.EventBuilder;

Builder Methods

MethodParametersReturnsDescription
withPlayerUUID uuid, String usernameEventBuilderAssociate with player
withPlayerUUID uuidEventBuilderAssociate with player (UUID only)
withDataString key, Object valueEventBuilderAdd single data field
withDataMap<String, Object> dataEventBuilderAdd multiple data fields
withValuedouble valueEventBuilderSet numeric value
sendvoidSend event (fire and forget)
sendConsumer<Boolean> callbackvoidSend with callback

Getters

MethodReturns
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

MethodParametersReturnsDescription
getSessionUUID uuidOptional<PlayerSession>Get player's session
hasSessionUUID uuidbooleanCheck if player has session
getAllSessionsCollection<PlayerSession>Get all active sessions
getSessionCountintGet 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

MethodReturnsDescription
getPlayerUuid()UUIDPlayer's unique ID
getSessionId()StringAnalytics session ID (null if pending)
getHostname()StringHostname player connected with
getIp()StringPlayer's IP address
getJoinTime()InstantWhen player joined
hasActiveSession()booleanIf registered with API

ABTestManager

Manages A/B tests and variant assignments.

import net.analyse.api.manager.ABTestManager;
ABTestManager abTests = Analyse.abTests();

Methods

MethodParametersReturnsDescription
getActiveTestsList<ABTest>Get all active tests
getTestString testKeyABTestGet test by key
getVariantUUID uuid, String testKeyStringGet assigned variant
isTestActiveString testKeybooleanCheck if test is active
trackConversionUUID, String, String, StringvoidTrack conversion

ABTest

Represents an A/B test configuration.

import net.analyse.api.object.abtest.ABTest;

Methods

MethodReturnsDescription
getId()StringTest ID
getKey()StringTest key (used in code)
getName()StringDisplay name
getTrigger()TriggerWhen test activates
getTriggerCommand()StringCommand trigger (if applicable)
getTriggerEvent()StringEvent trigger (if applicable)
isCancelCommand()booleanCancel command on trigger
getStatus()StatusTest status
getVariants()List<Variant>All variants
getPrimaryMetric()StringPrimary conversion metric
isActive()booleanIf test is active
assignVariant(UUID)VariantAssign variant to player
getVariant(String)VariantGet variant by key

Enums

ABTest.Trigger {
FIRST_JOIN,
EVERY_JOIN,
ON_COMMAND,
ON_EVENT
}
ABTest.Status {
DRAFT,
ACTIVE,
PAUSED,
COMPLETED
}

Matching Methods

MethodParametersReturnsDescription
matchesTriggerTrigger triggerbooleanCheck trigger type
matchesCommandString commandbooleanCheck if command triggers
matchesEventString eventNamebooleanCheck if event triggers

Variant

Represents a variant in an A/B test.

import net.analyse.api.object.abtest.Variant;

Methods

MethodReturnsDescription
getKey()StringVariant key
getName()StringDisplay name
getWeight()intTraffic weight (0-100)
hasActions()booleanHas configured actions

Exceptions

IllegalStateException

Thrown when SDK is used before initialization:

try {
Analyse.trackEvent("test").send();
} catch (IllegalStateException e) {
// Analyse plugin not loaded
}

Prevent with availability check:

if (Analyse.isAvailable()) {
Analyse.trackEvent("test").send();
}

IllegalArgumentException

Thrown for invalid parameters:

Analyse.trackEvent(null); // Throws - name cannot be null
Analyse.trackEvent(""); // Throws - name cannot be blank