Class MyTracker

java.lang.Object
com.my.tracker.MyTracker

public final class MyTracker extends Object
Main facade to access MyTracker API
  • Field Details

    • VERSION

      public static final String VERSION
      Library version
  • Method Details

    • isDebugMode

      public static boolean isDebugMode()
      Return the attribute whether the tracker prints debug information.
    • setDebugMode

      public static void setDebugMode(boolean debugMode)
      Enable or disable printing debug information.
      Parameters:
      debugMode - If true, the tracker prints debug information to LogCat.
    • setAttributionListener

      public static void setAttributionListener(MyTracker.AttributionListener attributionListener)
      Set the attribution listener.
      Parameters:
      attributionListener - The instance of MyTracker.AttributionListener or null.
    • setAttributionListener

      public static void setAttributionListener(MyTracker.AttributionListener attributionListener, android.os.Handler handler)
      Set the attribution listener.
      Parameters:
      attributionListener - The instance of MyTracker.AttributionListener or null.
      handler - The instance of Handler which will be used for invocation listener.
    • getTrackerParams

      public static MyTrackerParams getTrackerParams()
      Return the instance of MyTrackerParams.
    • getTrackerConfig

      public static MyTrackerConfig getTrackerConfig()
      Return the instance of MyTrackerConfig.
    • initTracker

      public static void initTracker(String id, android.app.Application application)
      Perform initialization of tracker.

      NOTE: this method should be called right after setup tracker configuration.

      NOTE: it's supposed that this method should be called in Application.onCreate().

      Parameters:
      id - The identifier of your application.
      application - The instance of application.
    • flush

      public static void flush()
      Force sending all saved events to the server.
    • trackEvent

      public static void trackEvent(String name, Map<String,String> eventParams)
      Track user defined event with custom name and optional key-value parameters.
      Parameters:
      name - User defined event name. Max length is 255 symbols.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackEvent

      public static void trackEvent(String name)
      Track user defined event with custom name.
      Parameters:
      name - User defined event name. Max length is 255 symbols.
    • trackLoginEvent

      public static void trackLoginEvent(String userId, String vkConnectId, Map<String,String> eventParams)
      Track user login event.

      NOTE: Call the method right after user successfully authorized in the app and got an unique identifier.

      Parameters:
      userId - Unique user identifier.
      vkConnectId - VK Connect user identifier.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackLoginEvent

      public static void trackLoginEvent(String userId, String vkConnectId)
      Track user login event.

      NOTE: Call the method right after user successfully authorized in the app and got an unique identifier.

      Parameters:
      userId - Unique user identifier.
      vkConnectId - VK Connect user identifier.
    • trackRegistrationEvent

      public static void trackRegistrationEvent(String userId, String vkConnectId, Map<String,String> eventParams)
      Track user registration event.

      NOTE: Call the method right after user successfully registered in the app and got an unique identifier.

      Parameters:
      userId - Unique user identifier.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackRegistrationEvent

      public static void trackRegistrationEvent(String userId, String vkConnectId)
      Track user registration event.

      NOTE: Call the method right after user successfully registered in the app and got an unique identifier.

      Parameters:
      userId - Unique user identifier.
    • trackInviteEvent

      public static void trackInviteEvent(Map<String,String> eventParams)
      Track user invitation event. Call this method if the current user was invited by other user.
      Parameters:
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackInviteEvent

      public static void trackInviteEvent()
      Track user invitation event. Call this method if the current user was invited by other user.
    • trackLevelEvent

      public static void trackLevelEvent(Map<String,String> eventParams)
      Track achieving new level. Call this method when user has achieved new level.
      Parameters:
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackLevelEvent

      public static void trackLevelEvent()
      Track achieving new level. Call this method when user has achieved new level.
    • trackLevelEvent

      public static void trackLevelEvent(int level, Map<String,String> eventParams)
      Track achieving new level. Call this method when user has achieved new level.
      Parameters:
      level - The level that has been achieved.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackAdEvent

      public static void trackAdEvent(AdEvent adEvent)
      Track advertising event. Call this method when an advertising event has occurred.
      Parameters:
      adEvent - Instance of AdEvent
    • trackMiniAppEvent

      public static void trackMiniAppEvent(MiniAppEvent miniAppEvent)
      Track mini-app event. Call this method when an event in mini-app has occurred.
      Parameters:
      miniAppEvent - Instance of MiniAppEvent
    • trackPurchaseEvent

      public static void trackPurchaseEvent(org.json.JSONObject skuDetails, org.json.JSONObject purchaseData, String dataSignature, Map<String,String> eventParams)
      Track purchase event. The method could be used if application contains the logic for processing in-app purchases.
      Parameters:
      skuDetails - The result of getSkuDetails.
      purchaseData - The field INAPP_PURCHASE_DATA of getBuyIntent.
      dataSignature - The field INAPP_DATA_SIGNATURE of getBuyIntent.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackAppGalleryPurchaseEvent

      public static void trackAppGalleryPurchaseEvent(Object productInfo, String inAppPurchaseData, String inAppDataSignature, String signatureAlgorithm, Map<String,String> eventParams)
      Track AppGalleryPurchase event. The method could be used if application contains the logic for processing in-app purchases.
      Parameters:
      productInfo - The result of getProductInfo.
      inAppPurchaseData - The result of getInAppPurchaseData.
      inAppDataSignature - The field INAPP_PURCHASE_DATA of getInAppDataSignature.
      signatureAlgorithm - The field INAPP_DATA_SIGNATURE of getSignatureAlgorithm.
      eventParams - Additional event key-value parameters. Max length for key or value is 255 symbols.
    • trackPurchaseEvent

      public static void trackPurchaseEvent(org.json.JSONObject skuDetails, org.json.JSONObject purchaseData, String dataSignature)
      Track purchase event. The method could be used if application contains the logic for processing in-app purchases.
      Parameters:
      skuDetails - The result of getSkuDetails.
      purchaseData - The field INAPP_PURCHASE_DATA of getBuyIntent.
      dataSignature - The field INAPP_DATA_SIGNATURE of getBuyIntent.
    • trackLaunchManually

      public static void trackLaunchManually(android.app.Activity activity)
      This method could be used in rare cases when tracker isn't able to correctly identify application start.
      Parameters:
      activity - The start activity.
    • onActivityResult

      public static void onActivityResult(int resultCode, android.content.Intent data)
      The method is used for tracking purchases when autotracking purchases is enabled with MyTrackerConfig.setAutotrackingPurchaseEnabled(boolean). This method should be called in Activity.onActivityResult(int, int, Intent).
      Parameters:
      resultCode - The resultCode from Activity.onActivityResult(int, int, Intent).
      data - The data from Activity.onActivityResult(int, int, Intent).
    • onPurchasesUpdated

      public static void onPurchasesUpdated(int responseCode, List<Object> purchases)
      The method is used for tracking purchases when autotracking purchases is enabled with MyTrackerConfig.setAutotrackingPurchaseEnabled(boolean). This method should be called in PurchasesUpdatedListener.onPurchasesUpdated(BillingResult, List).
      Parameters:
      responseCode - The value of BillingResult.getResponseCode().
      purchases - List of purchases received on PurchasesUpdatedListener.onPurchasesUpdated(BillingResult, List).
    • handleDeeplink

      public static String handleDeeplink(android.content.Intent intent)
      The method for processing deeplink to application. You could call the method in Activity.onNewIntent(Intent) or in Activity.startActivity(Intent).
      Parameters:
      intent - The intent with deeplink.
      Returns:
      The deeplink string or null if it hasn't been found.
    • applyPlugin

      public static void applyPlugin(com.my.tracker.plugins.MyTrackerPluginConfig pluginConfig)
      This method could be used to apply additional plugin.

      NOTE: it's mandatory to call this method before initTracker(String, Application) call.

      Parameters:
      pluginConfig - The instance of plugin configuration.
    • getInstanceId

      public static String getInstanceId(android.content.Context context)
      Return current instance id of tracker.
      Parameters:
      context - Instance of class Context.
      Returns:
      Tracker's instance id.
    • startForegroundTimeSpent

      public static void startForegroundTimeSpent(int id)
      Start tracking foreground-only custom TimeSpent
      Parameters:
      id - Id of custom TimeSpent
    • startAnytimeTimeSpent

      public static void startAnytimeTimeSpent(int id)
      Start tracking anytime custom TimeSpent (tracking background and foreground time)
      Parameters:
      id - Id of custom TimeSpent
    • stopForegroundTimeSpent

      public static void stopForegroundTimeSpent(int id)
      Stop tracking foreground-only custom TimeSpent (pair method for startForegroundTimeSpent(int))
      Parameters:
      id - Id of started foreground-only custom TimeSpent
    • stopAnytimeTimeSpent

      public static void stopAnytimeTimeSpent(int id)
      Stop tracking anytime custom TimeSpent (pair method for startAnytimeTimeSpent(int))
      Parameters:
      id - Id of started anytime custom TimeSpent
    • incrementEventTimeSpent

      public static void incrementEventTimeSpent(int id)
      Increment count-based TimeSpent (i.e TimeSpent based on count of events (for example count of likes, reposts etc))
      Parameters:
      id - Id of custom count-based TimeSpent