Skip to content

Commit 81d9a5c

Browse files
docs: Add getting started guides for FancyAnalytics
1 parent 98c5208 commit 81d9a5c

5 files changed

Lines changed: 263 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
icon: info
3+
---
4+
5+
There are multiple ways to send data to FancyAnalytics.
6+
7+
!!! danger
8+
The FancyAnalytics platform is still in development. Expect breaking changes in the future.
9+
!!!
10+
11+
### For Minecraft servers
12+
13+
If you run a Minecraft server, you might want to track metrics about your players and server performance.
14+
We provide a Minecraft plugin which can be installed on your server to send data to FancyAnalytics.
15+
See the [Minecraft Servers](minecraft-servers.md) page for more information.
16+
17+
### For Minecraft plugins
18+
19+
If you are a Minecraft plugin developer, you might want to track metrics about your plugin usage.
20+
So you know how many people are using your plugin and how they are using it.
21+
We provide a Java SDK which is specifically designed for Minecraft plugins.
22+
See the [Minecraft Plugins](minecraft-plugins.md) page for more information.
23+
24+
### For Java developers
25+
26+
If you are a Java developer, who wants to track metrics about your Java application, without being in the Minecraft ecosystem, you can use our Java SDK.
27+
The Java SDK is a general purpose SDK which can be used to track metrics about any Java application.
28+
See the [Java SDK](java-sdk.md) page for more information.
29+
30+
### For everyone else
31+
32+
If you are not a Java developer, or you are using a different programming language, you can use our REST API to send data to FancyAnalytics.
33+
See the [REST API](rest-api.md) page for more information.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
icon: dot
3+
order: 300
4+
---
5+
6+
# Java SDK
7+
8+
This guide will help you set up FancyAnalytics in your general Java application.
9+
10+
## Include the Java SDK
11+
12+
### Gradle
13+
14+
```kotlin
15+
repositories {
16+
maven("https://repo.fancyinnovations.com/releases")
17+
}
18+
```
19+
20+
```kotlin
21+
dependencies {
22+
implementation("de.oliver.fancyanalytics:java-sdk:VERSION")
23+
}
24+
```
25+
26+
### Maven
27+
28+
```xml
29+
<repository>
30+
<id>fancyplugins-releases</id>
31+
<name>FancyPlugins Repository</name>
32+
<url>https://repo.fancyinnovations.com/releases</url>
33+
</repository>
34+
```
35+
36+
```xml
37+
<dependency>
38+
<groupId>de.oliver.FancyAnalytics</groupId>
39+
<artifactId>java-sdk</artifactId>
40+
<version>VERSION</version>
41+
</dependency>
42+
```
43+
44+
!!! warning
45+
Make sure to shade the API into your app! You can use the [Shade plugin](https://imperceptiblethoughts.com/shadow/) for this.
46+
!!!
47+
48+
## Use the API
49+
50+
### Initialize the ApiClient
51+
52+
First you need to create an instance of the `ApiClient` class.
53+
54+
```java
55+
ApiClient fancyAnalytics = new ApiClient("https://api.fancyanalytics.net", "", "YOUR API TOKEN");
56+
```
57+
58+
### Send metric data
59+
60+
You can send metric data to the server using the record service.
61+
62+
```java
63+
Record record = new Record("unique sender id", "project id", timestamp, new HashMap<>());
64+
record.withEntry("metric name", "metric value");
65+
66+
fancyAnalytics.getRecordService().createRecord("project id", record);
67+
```
68+
69+
### Send events
70+
71+
You can also send events to the server using the event service.
72+
73+
```java
74+
Event event = new Event("event name", new HashMap<>());
75+
event.withProperty("prop key", "prop value");
76+
77+
fancyAnalytics.getEventService().createEvent("project id", event);
78+
```
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
icon: dot
3+
order: 400
4+
---
5+
6+
# Minecraft Plugins
7+
8+
This guide will help you set up FancyAnalytics in your Minecraft plugin. The API is very easy to use and has many default metrics. You can also define your own metrics and events.
9+
10+
## Include the FancyAnalytics API
11+
12+
### Gradle
13+
14+
```kotlin
15+
repositories {
16+
maven("https://repo.fancyinnovations.com/releases")
17+
}
18+
```
19+
20+
```kotlin
21+
dependencies {
22+
implementation("de.oliver.fancyanalytics:mc-api:VERSION")
23+
}
24+
```
25+
26+
### Maven
27+
28+
```xml
29+
<repository>
30+
<id>fancyplugins-releases</id>
31+
<name>FancyPlugins Repository</name>
32+
<url>https://repo.fancyinnovations.com/releases</url>
33+
</repository>
34+
```
35+
36+
```xml
37+
<dependency>
38+
<groupId>de.oliver.FancyAnalytics</groupId>
39+
<artifactId>mc-api</artifactId>
40+
<version>VERSION</version>
41+
</dependency>
42+
```
43+
44+
!!! warning
45+
Make sure to shade the API into your plugin! You can use the [Shade plugin](https://imperceptiblethoughts.com/shadow/) for this.
46+
!!!
47+
48+
## Initialize the API
49+
50+
```java
51+
FancyAnalyticsAPI fancyAnalytics = new FancyAnalyticsAPI("project-id", "api-token");
52+
fancyAnalytics.registerMinecraftPluginMetrics();
53+
fancyAnalytics.initialize();
54+
```
55+
56+
You can find your project ID and api token in the project settings page.
57+
58+
### Custom metrics
59+
60+
You can also send custom metrics to the server:
61+
62+
```java
63+
// Register a number metric to track the amount of npcs
64+
fancyAnalytics.registerNumberMetric(new MetricSupplier<>("amount_npcs", () -> npcManager.getNpcs().size()));
65+
66+
// Register a string metric to track the used language
67+
fancyAnalytics.registerStringMetric(new MetricSupplier<>("language", () -> languageManager.getLanguage()));
68+
```
69+
70+
You can also send multiple values at once with the `registerStringArrayMetric` and `registerNumberArrayMetric` methods.
71+
This is useful for tracking the player client's version for example.
72+
73+
Make sure to add the metrics on website at the project settings page (must be same name as in the code)!
74+
75+
### Events
76+
77+
Some things are better tracked as events. For example, purchases in a shop. You can send events like this:
78+
79+
```java
80+
fancyAnalytics.sendEvent(
81+
new Event("PurchasedItem")
82+
.withProperty("player","Steve")
83+
.withProperty("item","Diamond")
84+
.withProperty("amount","1")
85+
.withProperty("price","5")
86+
);
87+
```
88+
89+
You can also add custom properties to the event. Each property has a key (string) and a value (string but can be
90+
converted to a number if needed).
91+
92+
Once the first event is sent, there will be a new event-type created on the website. This event-type will have the name
93+
and the keys of all properties of the event. You can then see the events on the website.
94+
95+
You do not need to add the events on the website, they will be created automatically and all properties will be updated
96+
automatically as well.
97+
98+
### Error reporting
99+
100+
FancyAnalytics can also track errors in your project. All you need to do is register all relevant loggers:
101+
102+
```java
103+
Logger myLogger = ...;
104+
fancyAnalytics.getExceptionHandler().registerLogger(myLogger);
105+
```
106+
107+
All exceptions that are thrown in the logger and are related to the plugin will be tracked. You can see all thrown
108+
exceptions on the website.
109+
110+
### Done!
111+
112+
This is all you need to do to get started with FancyAnalytics. It will automatically send the data to the server.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
icon: dot
3+
order: 500
4+
---
5+
6+
# Minecraft Servers
7+
8+
This guide will help you set up FancyAnalytics on your Minecraft server. The plugin already has many default metrics.
9+
10+
## Installation
11+
12+
To install FancyAnalytics on your server, you need to follow these steps:
13+
14+
1. Download the latest release from the [download page](https://fancyanalytics.net/downloads)
15+
2. Put the downloaded jar file in the ``plugins`` folder of your server
16+
3. Restart your server
17+
4. Run the command `/fancyanalytics version` to confirm that the plugin is installed
18+
19+
## Configuration
20+
21+
To use FancyAnalytics, you need to create an account on the [FancyAnalytics website](https://fancyanalytics.net/register) and create a new project.
22+
After creating the project, you need to put the project ID and the API key in the `config.yml` file of the plugin.
23+
24+
```yaml
25+
project_id: "your project id"
26+
api_key: "your api key",
27+
enable_default_events: false
28+
```
29+
30+
## Usage
31+
32+
All you need to do is wait for the data to be collected, and then you can see it on the website. This can take up to 2 minutes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
icon: dot
3+
order: 200
4+
---
5+
6+
# REST API
7+
8+
TODO

0 commit comments

Comments
 (0)