Package 

Class AnalyticsManagerImpl

  • All Implemented Interfaces:
    com.shalan.analytics.core.AnalyticsManager

    
    public final class AnalyticsManagerImpl
     implements AnalyticsManager
                        

    Default implementation of AnalyticsManager that dispatches analytics events to a list of registered AnalyticsProviders. This implementation ensures that if one provider fails to log an event, it does not prevent other providers from logging, and it prevents application crashes.

    Events are logged asynchronously on a background thread to avoid blocking the main thread.

    • Constructor Detail

    • Method Detail

      • logScreenView

         Unit logScreenView(String screenName, String screenClass, Map<String, Object> parameters)

        Logs a screen view event by iterating through all registered AnalyticsProviders and calling their AnalyticsProvider.logEvent method. Each call to a provider is wrapped in a try-catch block to prevent crashes.

        Parameters:
        screenName - The name of the screen being viewed.
        screenClass - The class name associated with the screen.
        parameters - An optional map of additional key-value pairs for the event.
      • logEvent

         Unit logEvent(String eventName, Map<String, Object> parameters, Boolean includeGlobalParameters)

        Logs a custom event by iterating through all registered AnalyticsProviders and calling their AnalyticsProvider.logEvent method. Each call to a provider is wrapped in a try-catch block to prevent crashes.

        Parameters:
        eventName - The name of the event.
        parameters - A map of key-value pairs representing the event parameters.
      • setGlobalParameters

         Unit setGlobalParameters(Map<String, Object> parameters)

        Sets global parameters that will be included with all subsequent analytics events. Existing global parameters will be replaced by the new ones.

        Parameters:
        parameters - A map of key-value pairs representing the global parameters.
      • release

         Unit release()

        Releases any resources held by the analytics manager, canceling any ongoing coroutine tasks.