Package com.brightcove.player.analytics
Class AnalyticsClient
- java.lang.Object
-
- com.brightcove.player.analytics.AnalyticsClient
-
public class AnalyticsClient extends java.lang.ObjectAnalytics 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.
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_BACKLOG_LIMITThe default limit for analytics events backlog, expressed as total number of bytes.static intDEFAULT_BATCH_SIZEThe maximum number of events that will be processed in a batch when transmitting backlog.static intDEFAULT_RETRY_LIMITThe maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMALevents.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnalyticsClientaddHandler(IAnalyticsHandler handler)Adds the specified handler to the set of handlers that will be notified when an analytics event is received.static voiddisableNetwork(int type)Disables the specified network type for transmission of analytics events.static voidenableNetwork(int type)Enables the specified network type for transmission of analytics events.static longgetBacklogLimit()Gets the maximum size of the analytics events backlog, expressed as total number of bytes.static intgetBatchSize()Gets the maximum number of events that will be processed in a batch when transmitting backlog.static AnalyticsClientgetInstance(android.content.Context context)Provides reference to the single instance ofAnalyticsClient.static android.util.SparseArray<java.lang.Boolean>getNetworkEntitlements()Gets the network entitlements for transmission of analytics events.static intgetRetryLimit()Gets the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMALevents.static booleanisNetworkEnabled(int type)Checks if the specified network type is currently enabled for transmission of analytics events.AnalyticsClientpublish(com.brightcove.player.analytics.AnalyticsEvent event, IAnalyticsErrorListener errorHandler)Publishes the specified event to the current set of registered analytics handlers.AnalyticsClientremoveAllHandlers()Removes all handlers that are currently registered with client.AnalyticsClientremoveHandler(IAnalyticsHandler handler)Removed the specified handler to the set of handlers that will be notified when an analytics event is received.static voidsetBacklogLimit(long backlogLimit)Sets the maximum size of the analytics events backlog, expressed as total number of bytes.static voidsetBatchSize(int batchSize)Sets the maximum number of events that will be processed in a batch when transmitting backlog.static booleansetNetworkEnabled(int type, boolean enabled)Sets whether the specified network type is enabled for transmission of analytics events.static voidsetRetryLimit(int retryLimit)Sets the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMALevents.
-
-
-
Field Detail
-
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 sendAbstractAnalyticsEvent.NORMALevents.
-
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 Detail
-
getInstance
public static AnalyticsClient getInstance(@NonNull android.content.Context context)
Provides reference to the single instance ofAnalyticsClient.- Parameters:
context- context of the host activity or application.- Returns:
- reference to the single instance of
AnalyticsClient. - Throws:
java.lang.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<java.lang.Boolean> getNetworkEntitlements()
Gets the network entitlements for transmission of analytics events.- Returns:
- a
SparseArrayofConnectivityMonitor.NetworkTypeandBooleanvalues 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 sendAbstractAnalyticsEvent.NORMALevents.- Returns:
- the maximum number of attempts that will be made to send
AbstractAnalyticsEvent.NORMALevents.
-
setRetryLimit
public static void setRetryLimit(int retryLimit)
Sets the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMALevents.- Parameters:
retryLimit- the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMALevents.
-
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.
-
-