mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
1.6 KiB
1.6 KiB
icon, order
| icon | order |
|---|---|
| dot | 300 |
Java SDK
This guide will help you set up FancyAnalytics in your general Java application.
Include the Java SDK
Gradle
repositories {
maven("https://repo.fancyinnovations.com/releases")
}
dependencies {
implementation("de.oliver.fancyanalytics:java-sdk:VERSION")
}
Maven
<repository>
<id>fancyplugins-releases</id>
<name>FancyPlugins Repository</name>
<url>https://repo.fancyinnovations.com/releases</url>
</repository>
<dependency>
<groupId>de.oliver.FancyAnalytics</groupId>
<artifactId>java-sdk</artifactId>
<version>VERSION</version>
</dependency>
!!! warning Make sure to shade the API into your app! You can use the Shade plugin for this. !!!
Use the API
Initialize the ApiClient
First you need to create an instance of the ApiClient class.
ApiClient fancyAnalytics = new ApiClient("https://api.fancyanalytics.net", "", "YOUR API TOKEN");
Send metric data
You can send metric data to the server using the record service.
Record record = new Record("unique sender id", "project id", timestamp, new HashMap<>());
record.withEntry("metric name", "metric value");
fancyAnalytics.getRecordService().createRecord("project id", record);
Send events
You can also send events to the server using the event service.
Event event = new Event("event name", new HashMap<>());
event.withProperty("prop key", "prop value");
fancyAnalytics.getEventService().createEvent("project id", event);