Class AnalyticsClient

java.lang.Object
com.brightcove.player.analytics.AnalyticsClient

public class AnalyticsClient extends Object
Analytics client can be used to publish analytics event to the list of registered analytics handlers. By default the analytics client will attempt to send the analytics event to the Brightcove analytics collector. This default behavior can be change add custom handlers.
See Also:
  • Field Details

    • DEFAULT_BACKLOG_LIMIT

      public static long DEFAULT_BACKLOG_LIMIT
      The default limit for analytics events backlog, expressed as total number of bytes.
    • DEFAULT_RETRY_LIMIT

      public static int DEFAULT_RETRY_LIMIT
      The maximum number of attempts that will be made to send AbstractAnalyticsEvent.NORMAL events.
    • DEFAULT_BATCH_SIZE

      public static int DEFAULT_BATCH_SIZE
      The maximum number of events that will be processed in a batch when transmitting backlog.
  • Method Details

    • getInstance

      public static AnalyticsClient getInstance(@NonNull android.content.Context context)
      Provides reference to the single instance of AnalyticsClient.
      Parameters:
      context - context of the host activity or application.
      Returns:
      reference to the single instance of AnalyticsClient.
      Throws:
      NullPointerException - if the context is null.
    • setNetworkEnabled

      public static boolean setNetworkEnabled(int type, boolean enabled)
      Sets whether the specified network type is enabled for transmission of analytics events.
      Parameters:
      type - the type of the network.
      enabled - true, if the network should be enabled for analytics transmission, otherwise false.
      Returns:
      false if the network type cannot be disabled because it is currently the only network type that is enabled for analytics event transmission, otherwise true.
    • enableNetwork

      public static void enableNetwork(int type)
      Enables the specified network type for transmission of analytics events.
      Parameters:
      type - the type of the network.
    • disableNetwork

      public static void disableNetwork(int type)
      Disables the specified network type for transmission of analytics events.
      Parameters:
      type - the type of the network.
    • isNetworkEnabled

      public static boolean isNetworkEnabled(int type)
      Checks if the specified network type is currently enabled for transmission of analytics events.
      Parameters:
      type - the type of the network.
      Returns:
      true, if the network is entitled for analytics transmission, otherwise false.
    • getNetworkEntitlements

      public static android.util.SparseArray<Boolean> getNetworkEntitlements()
      Gets the network entitlements for transmission of analytics events.
      Returns:
      a SparseArray of ConnectivityMonitor.NetworkType and Boolean values that indicate whether a specific network type can be used for transmission of analytics events.
    • getBacklogLimit

      public static long getBacklogLimit()
      Gets the maximum size of the analytics events backlog, expressed as total number of bytes.
      Returns:
      the maximum size of the analytics events backlog, expressed as total number of bytes.
    • setBacklogLimit

      public static void setBacklogLimit(long backlogLimit)
      Sets the maximum size of the analytics events backlog, expressed as total number of bytes.
      Parameters:
      backlogLimit - the maximum size of the analytics events backlog, expressed as total number of bytes.
    • getRetryLimit

      public static int getRetryLimit()
      Gets the maximum number of attempts that will be made to send AbstractAnalyticsEvent.NORMAL events.
      Returns:
      the maximum number of attempts that will be made to send AbstractAnalyticsEvent.NORMAL events.
    • setRetryLimit

      public static void setRetryLimit(int retryLimit)
      Sets the maximum number of attempts that will be made to send AbstractAnalyticsEvent.NORMAL events.
      Parameters:
      retryLimit - the maximum number of attempts that will be made to send AbstractAnalyticsEvent.NORMAL events.
    • getBatchSize

      public static int getBatchSize()
      Gets the maximum number of events that will be processed in a batch when transmitting backlog.
      Returns:
      the maximum number of events that will be processed in a batch when transmitting backlog.
    • setBatchSize

      public static void setBatchSize(int batchSize)
      Sets the maximum number of events that will be processed in a batch when transmitting backlog.
      Parameters:
      batchSize - the maximum number of events that will be processed in a batch when transmitting backlog.
    • addHandler

      public AnalyticsClient addHandler(@NonNull IAnalyticsHandler handler)
      Adds the specified handler to the set of handlers that will be notified when an analytics event is received.
      Parameters:
      handler - the handler to be added.
      Returns:
      the single instance of the Analytics client.
    • removeHandler

      public AnalyticsClient removeHandler(@NonNull IAnalyticsHandler handler)
      Removed the specified handler to the set of handlers that will be notified when an analytics event is received.
      Parameters:
      handler - the handler to be removed.
      Returns:
      the single instance of the Analytics client.
    • removeAllHandlers

      public AnalyticsClient removeAllHandlers()
      Removes all handlers that are currently registered with client.
      Returns:
      the single instance of the Analytics client.
    • publish

      public AnalyticsClient publish(@NonNull com.brightcove.player.analytics.AnalyticsEvent event, @NonNull IAnalyticsErrorListener errorHandler)
      Publishes the specified event to the current set of registered analytics handlers.
      Parameters:
      event - the event to be published.
      errorHandler - optional reference to an object that can handle errors in processing the published analytics event.
      Returns:
      the single instance of the Analytics client.