Custom Events

Discover how to track custom events with Tebex Analytics.

Starting from v2.0, Tebex Analytics has the ability to track custom events that happen within your Minecraft server. This provides additional visibility into what's happening on your server, such as; which crates are most used, the top commands ran or even which ranks players are most interested in. There are endless possibilities with the new event feature and it's easy to start using it, this can either be done via command or using our developer SDK.

Tracking via Command

If you wish to track a custom event via a command, you can run the /analyse trackcommand which takes the following syntax:

/analyse track <player> <event> <value>
  • <player> - The player this event relates to, e.g. Siri.

  • <event> - The events identifier, e.g. crate_open.

  • <value> - Any relevant metadata for the event (JSON format).

For example, let's say that you wanted to trigger an event once a player unlocks a rare cosmetic on your server - you may run a command similar to this:

/analyse track Siri cosmetics:unlock {"name": "Wings of Destiny", "rarity": "epic"}

Of course you'd swap out the player name using a placeholder, which may typically be something along the lines of %player_name%. Another example would be tracking which quests are completed most often, in which case you may decide to run a command such as:

/analyse track Steve quest:complete {"quest": "Level 1: Upgrade your Tool", "duration": 300}

That's the gist of it! But, if you're more of a developer, you can also utilise the Analytics SDK to smoothly track custom events.

Tracking via SDK

If you're a developer, you can also send custom events to Analyse using the track method from the AnalysePlayerinterface. This method takes an instance of PlayerEvent - or even multiple instances if you wish to. Here's an example:

PlayerEvent playerEvent = new PlayerEvent("mine_diamond", "MyAwesomePlugin")
    .withMetadata("block_location", "Underground Fortress")
    .withMetadata("tool_used", "Diamond Pickaxe")
    .withMetadata("mining_speed", 3);

The PlayerEvent class takes 2 parameters, the id of the event and an origin of which plugin triggered this. The id helps to identify the specific event for querying later on, while the origin makes it easier to find which events have come from which plugin. For example, you might have an unlock event which is used in both your Crate and Quest plugins.

In addition, you may use the withMetadata method to pass in any additional information which takes a key and value parameter. The key parameter must be a lowercase string, while the value can be anything; a number, string or even a date!

Want to learn more about events? Check out our event documentation for more information.

Last updated