Class AnalyticsEvent

java.lang.Object
com.tccc.kos.core.service.analytics.AnalyticsEvent

public class AnalyticsEvent extends Object
Analytics event that can either be used as a base class for event data or as a wrapper for existing objects when they are to be recorded as events.

Each analytics event records the following information:

  • timestamp: By default the timestamp is the creation time of the event object but it can be overidden to use a different timestamp when recording event data after the fact. The timestamp is a standard UTC millisecond value for convenience, but will be converted to a timezone based value when processed. This ensures that time data can be various ways by upstream systems.
  • type: The type of the event. This is generally a dotted notation hierarchical name for the event. Policy can be applied on the type or type prefix.
  • priority: The priority of the information in the event. Higher priority events will cause more frequent flushing / uploading of data. This should not be used as the severity of an event, just an indication of how quickly the data should be processed. The default priority is LOW.
  • view: The json view to apply to the data to serialize the data object to event json. By default this will be AnalyticsEvent.View but can be overridden as needed. Setting to null will use no json view.
  • data: The data for the event. This will be converted to json using the associated view. This is commonly a complex live object where a view is used to control what parts of the object should actually be included in the serialized event object.
Since:
1.0
Version:
2024-03-12
  • Constructor Details

    • AnalyticsEvent

      public AnalyticsEvent()
  • Method Details

    • setTimestamp

      public AnalyticsEvent setTimestamp(long timestamp)
      Override the timestamp of the event if the event occurred at a different time from creation of this analytics object.
      Parameters:
      timestamp - the new timestamp in utc
    • setType

      public AnalyticsEvent setType(String type)
      Set the type of the event. This is typically a dotted notation, hierarchical string.
      Parameters:
      type - the event type
    • setPriority

      public AnalyticsEvent setPriority(AnalyticsPriority priority)
      Set the priority of how the event should be processed. This is not event severity, it only impacts how quickly the event is processed and forwarded to other systems.
      Parameters:
      priority - the new priority
    • setData

      public AnalyticsEvent setData(Object data)
      Set the data for the event. This will be serialized to json using the associated view.
    • setView

      public AnalyticsEvent setView(Class<?> view)
      Set the json view to use when serializing the data to json.
    • getTimestamp

      public long getTimestamp()
    • getType

      public String getType()
    • getPriority

      public AnalyticsPriority getPriority()
    • getView

      public Class<?> getView()
    • getData

      public Object getData()