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
Maven
Initialize the API
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:
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:
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:
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.