Package com.brightcove.player.analytics
Class AnalyticsClient
java.lang.Object
com.brightcove.player.analytics.AnalyticsClient
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.
-
Field Summary
Modifier and TypeFieldDescriptionstatic long
The default limit for analytics events backlog, expressed as total number of bytes.static int
The maximum number of events that will be processed in a batch when transmitting backlog.static int
The maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMAL
events. -
Method Summary
Modifier and TypeMethodDescriptionaddHandler
(IAnalyticsHandler handler) Adds the specified handler to the set of handlers that will be notified when an analytics event is received.static void
disableNetwork
(int type) Disables the specified network type for transmission of analytics events.static void
enableNetwork
(int type) Enables the specified network type for transmission of analytics events.static long
Gets the maximum size of the analytics events backlog, expressed as total number of bytes.static int
Gets the maximum number of events that will be processed in a batch when transmitting backlog.static AnalyticsClient
getInstance
(android.content.Context context) Provides reference to the single instance ofAnalyticsClient
.static android.util.SparseArray<Boolean>
Gets the network entitlements for transmission of analytics events.static int
Gets the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMAL
events.static boolean
isNetworkEnabled
(int type) Checks if the specified network type is currently enabled for transmission of analytics events.publish
(com.brightcove.player.analytics.AnalyticsEvent event, IAnalyticsErrorListener errorHandler) Publishes the specified event to the current set of registered analytics handlers.Removes all handlers that are currently registered with client.removeHandler
(IAnalyticsHandler handler) Removed the specified handler to the set of handlers that will be notified when an analytics event is received.static void
setBacklogLimit
(long backlogLimit) Sets the maximum size of the analytics events backlog, expressed as total number of bytes.static void
setBatchSize
(int batchSize) Sets the maximum number of events that will be processed in a batch when transmitting backlog.static boolean
setNetworkEnabled
(int type, boolean enabled) Sets whether the specified network type is enabled for transmission of analytics events.static void
setRetryLimit
(int retryLimit) Sets the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMAL
events.
-
Field Details
-
DEFAULT_BACKLOG_LIMIT
public static long DEFAULT_BACKLOG_LIMITThe default limit for analytics events backlog, expressed as total number of bytes. -
DEFAULT_RETRY_LIMIT
public static int DEFAULT_RETRY_LIMITThe maximum number of attempts that will be made to sendAbstractAnalyticsEvent.NORMAL
events. -
DEFAULT_BATCH_SIZE
public static int DEFAULT_BATCH_SIZEThe maximum number of events that will be processed in a batch when transmitting backlog.
-
-
Method Details
-
getInstance
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:
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
Gets the network entitlements for transmission of analytics events.- Returns:
- a
SparseArray
ofConnectivityMonitor.NetworkType
andBoolean
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 sendAbstractAnalyticsEvent.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 sendAbstractAnalyticsEvent.NORMAL
events.- Parameters:
retryLimit
- the maximum number of attempts that will be made to sendAbstractAnalyticsEvent.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
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
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
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.
-