-
public class ScreenTrackingA singleton object responsible for initializing and providing access to the analytics manager. This is the primary entry point for setting up screen tracking in an Android application.
The library supports two initialization approaches:
Lifecycle-based tracking: Pass an Application instance to register lifecycle callbacks for automatic screen tracking of Activities and Fragments.
Plugin-based tracking: Pass null for application parameter when using the Gradle plugin for automatic bytecode instrumentation and screen tracking.
-
-
Field Summary
Fields Modifier and Type Field Description public final static ScreenTrackingINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitsetAnalyticsManagerForTesting(AnalyticsManager manager)final Unitinitialize(AnalyticsConfig config)Initializes the Screen Tracking library. final static AnalyticsManagergetManager()Retrieves the initialized AnalyticsManager instance. final UnitsetGlobalParameters(Map<String, Object> parameters)Sets global parameters that will be included with all subsequent analytics events. final UnittrackScreen(String screenName, Map<String, Object> parameters)Tracks a screen view event with the given name and parameters. final static MethodTrackingConfiggetMethodTrackingConfig()Gets the method tracking configuration. final static Map<String, Object>createParametersMap(Object instance, Array<String> parameterKeys)Creates a parameters map by checking if the instance implements TrackedScreenParamsProvider and filtering the provided parameters against the requested parameter keys. -
-
Method Detail
-
setAnalyticsManagerForTesting
@VisibleForTesting() final Unit setAnalyticsManagerForTesting(AnalyticsManager manager)
-
initialize
final Unit initialize(AnalyticsConfig config)
Initializes the Screen Tracking library. This method should be called once, typically in the
onCreate()method of your application's custom Application class.- Parameters:
config- The AnalyticsConfig that defines the analytics providers and other settings.
-
getManager
final static AnalyticsManager getManager()
Retrieves the initialized AnalyticsManager instance. This method should only be called after initialize has been successfully invoked. Used by both lifecycle callbacks and Gradle plugin injected code.
-
setGlobalParameters
final Unit setGlobalParameters(Map<String, Object> parameters)
Sets global parameters that will be included with all subsequent analytics events. This method can be called at any time after initialize to update global parameters.
- Parameters:
parameters- A map of key-value pairs representing the global parameters.
-
trackScreen
final Unit trackScreen(String screenName, Map<String, Object> parameters)
Tracks a screen view event with the given name and parameters. This method is used by the Gradle plugin for automatic screen tracking injection.
- Parameters:
screenName- The name of the screen being tracked.parameters- Additional parameters to include with the screen tracking event.
-
getMethodTrackingConfig
@RestrictTo(value = {RestrictTo.Scope.LIBRARY}) final static MethodTrackingConfig getMethodTrackingConfig()
Gets the method tracking configuration. This method is used by ASM-generated code to access runtime configuration.
-
createParametersMap
@RestrictTo(value = {RestrictTo.Scope.LIBRARY}) final static Map<String, Object> createParametersMap(Object instance, Array<String> parameterKeys)
Creates a parameters map by checking if the instance implements TrackedScreenParamsProvider and filtering the provided parameters against the requested parameter keys. This method is used by the Gradle plugin for bytecode injection.
- Parameters:
instance- The Activity/Fragment instance to check for TrackedScreenParamsProviderparameterKeys- Array of parameter keys to extract from the provider
-
-
-
-