FancyAnalytics 1.0 Help

Java API

This page explains how to use the FancyAnalytics API in your Java project. Currently the API offers many Minecraft specific features, but it can be used in any Java project.

Include the FancyAnalytics API

Gradle

repositories { maven("https://repo.fancyplugins.de/releases") }
dependencies { implementation("de.oliver.fancyanalytics:api:VERSION") }

Maven

<repository> <id>fancyanalytics-repo</id> <url>https://repo.fancyplugins.de/releases</url> </repository>
<dependency> <groupId>de.oliver.fancyanalytics</groupId> <artifactId>api</artifactId> <version>VERSION</version> </dependency>

Initialize the API

FancyAnalyticsAPI fancyAnalytics = new FancyAnalyticsAPI("project-id", "api-token"); fancyAnalytics.registerMinecraftPluginMetrics(); fancyAnalytics.initialize();

You can find your project ID and api token in the project settings page.

Custom metrics

You can also send custom metrics to the server:

# Register a number metric to track the amount of npcs fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_npcs", () -> npcManager.getNpcs().size())); # Register a string metric to track the used language fancyAnalytics.registerStringMetric(new MetricSupplier<>("language", () -> languageManager.getLanguage()));

You can also send multiple values at once with the registerStringArrayMetric and registerNumberArrayMetric methods. This is useful for tracking the player client's version for example.

Make sure to add the metrics on website at the project settings page (must be same name as in the code)!

Events

Some things are better tracked as events. For example, purchases in a shop. You can send events like this:

fancyAnalytics.sendEvent( new Event("PurchasedItem") .withProperty("player","Steve") .withProperty("item","Diamond") .withProperty("amount","1") .withProperty("price","5") );

You can also add custom properties to the event. Each property has a key (string) and a value (string but can be converted to a number if needed).

Once the first event is sent, there will be a new event-type created on the website. This event-type will have the name and the keys of all properties of the event. You can then see the events on the website.

You do not need to add the events on the website, they will be created automatically and all properties will be updated automatically as well.

Read more about events here: Events

Error reporting

FancyAnalytics can also track errors in your project. All you need to do is register all relevant loggers:

Logger myLogger = ...; fancyAnalytics.getExceptionHandler().registerLogger(myLogger);

All exceptions that are thrown in the logger and are related to the plugin will be tracked. You can see all thrown exceptions on the website.

Done!

This is all you need to do to get started with FancyAnalytics. It will automatically send the data to the server.

Last modified: 22 April 2025