Skip to main content
Version: SDK 5.0.x

Class AppEvent

This class is a builder for app events you can publish to the backend. Call JustTrackSdk.publishEvent(AppEvent) to publish it:


AppEvent event = new AppEvent("namespace_module_action");
sdk.publishEvent(event);

You can also include additional information about the event, either by passing additional parameters to the constructor or by calling the setters afterwards:


AppEvent event = new AppEvent(
"namespace_module_action",
5,
Unit.COUNT
);
sdk.publishEvent(event);
event = new AppEvent("namespace_module_action")
.addDimension("key1", "some value")
.addDimension("some other key", "some other value")
.setValue(5, Unit.COUNT);
sdk.publishEvent(event);

public class AppEvent
extends Object
Inheritance

java.lang.Object ← io.justtrack.AppEvent ← Direct Known Subclasses: ← : JtAdEvent, JtLoginEvent, JtProgressionEvent, JtPurchaseEvent, JtResourceEvent

Constructors

AppEvent

public AppEvent(@NonNull String name, @NonNull Money money)

Create a new event with a value and currency but without any dimensions set.

Parameters

NameDescription
nameThe name of the event.
moneyThe value of the event with a currency. Needs to be a finite value.

AppEvent

public AppEvent(@NonNull String name, double value, @NonNull Unit unit)

Create a new event with a value and unit but without any dimensions set.

Parameters

NameDescription
nameThe name of the event.
valueThe value of the event. Needs to be a finite value.
unitThe unit of value.

AppEvent

public AppEvent(@NonNull String name)

Create a new event with only the name specified.

Parameters

NameDescription
nameThe name of the event.

Methods

addDimension

@NonNull
public AppEvent addDimension(@NonNull Dimension name, @Nullable String value)

addDimension

@NonNull
public AppEvent addDimension(@NonNull String name, @Nullable String value)

Add a dimension with the given name and value.

See validate() to learn more about permissible dimension values.

Parameters

NameDescription
nameA unique name to be added to dimension's map
valueA value that associate to the given name.

Returns

The modified app event for chaining.

equals

public boolean equals(@Nullable Object obj)

Overrides

equals in class Object

hashCode

public int hashCode()

Overrides

hashCode in class Object

removeDimension

@NonNull
public AppEvent removeDimension(@NonNull Dimension name)

removeDimension

@NonNull
public AppEvent removeDimension(@NonNull String name)

Remove a dimension with the given name form an event again.

See validate() to learn more about permissible dimension values.

Parameters

NameDescription
nameThe name of the dimension to be removed again.

Returns

The modified app event for chaining.

setCount

@NonNull
public AppEvent setCount(double count)

Convenience method for setValue(double, Unit) with unit set to Unit.COUNT.

Parameters

NameDescription
countThe new count for the event. Needs to be a finite value.

Returns

The modified app event for chaining.

setMilliseconds

@NonNull
public AppEvent setMilliseconds(double milliseconds)

Convenience method for setValue(double, Unit) with unit set to Unit.MILLISECONDS.

Parameters

NameDescription
millisecondsThe new milliseconds for the event. Needs to be a finite value.

Returns

The modified app event for chaining.

setSeconds

@NonNull
public AppEvent setSeconds(double seconds)

Convenience method for setValue(double, Unit) with unit set to Unit.SECONDS.

Parameters

NameDescription
secondsThe new seconds for the event. Needs to be a finite value.

Returns

The modified app event for chaining.

setValue

@NonNull
public AppEvent setValue(@NonNull Money money)

Set the value and currency of the event to the given values.

Parameters

NameDescription
moneyThe new value of the event with a currency. Needs to be a finite value.

Returns

The modified app event for chaining.

setValue

@NonNull
public AppEvent setValue(double value, @NonNull Unit unit)

Set the value and unit of the event to the given values.

Parameters

NameDescription
valueThe new value of the event. Needs to be a finite value.
unitThe Unit of value.

Returns

The modified app event for chaining.

toString

@NonNull
public String toString()

Overrides

toString in class Object

validate

public void validate() throws InvalidFieldException

Validate the name and fields of the app event, throwing an error if any field is invalid.

The name of the event is must not exceed 256 characters and consist of only printable ISO 8859-1 characters (U+0020 to U+007E as well as U+00A0 to U+00FF). Any dimension value must be shorter than 4096 characters and consist of only printable ISO 8859-1 characters (U+0020 to U+007E as well as U+00A0 to U+00FF). The value of the event must be a finite value (thus, neither NaN or ±Infinity).

You don't need to call this method normally, it will automatically be called once you submit a AppEvent to JustTrackSdk.publishEvent(AppEvent).

Throws

NameDescription
InvalidFieldExceptionIf any field has an invalid value.