Package com.my.tracker
Class MyTracker
java.lang.Object
com.my.tracker.MyTracker
Main facade to access MyTracker API
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAttribution listener interface. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyPlugin(com.my.tracker.plugins.MyTrackerPluginConfig pluginConfig) This method could be used to apply additional plugin.static voidflush()Force sending all saved events to the server.static StringgetInstanceId(android.content.Context context) Return current instance id of tracker.static MyTrackerConfigReturn the instance ofMyTrackerConfig.static MyTrackerParamsReturn the instance ofMyTrackerParams.static StringhandleDeeplink(android.content.Intent intent) The method for processing deeplink to application.static voidincrementEventTimeSpent(int id) Increment count-based TimeSpent (i.e TimeSpent based on count of events (for example count of likes, reposts etc))static voidinitTracker(String id, android.app.Application application) Perform initialization of tracker.static booleanReturn the attribute whether the tracker prints debug information.static voidonActivityResult(int resultCode, android.content.Intent data) The method is used for tracking purchases when autotracking purchases is enabled withMyTrackerConfig.setAutotrackingPurchaseEnabled(boolean).static voidonPurchasesUpdated(int responseCode, List<Object> purchases) The method is used for tracking purchases when autotracking purchases is enabled withMyTrackerConfig.setAutotrackingPurchaseEnabled(boolean).static voidsetAttributionListener(MyTracker.AttributionListener attributionListener) Set the attribution listener.static voidsetAttributionListener(MyTracker.AttributionListener attributionListener, android.os.Handler handler) Set the attribution listener.static voidsetDebugMode(boolean debugMode) Enable or disable printing debug information.static voidstartAnytimeTimeSpent(int id) Start tracking anytime custom TimeSpent (tracking background and foreground time)static voidstartForegroundTimeSpent(int id) Start tracking foreground-only custom TimeSpentstatic voidstopAnytimeTimeSpent(int id) Stop tracking anytime custom TimeSpent (pair method forstartAnytimeTimeSpent(int))static voidstopForegroundTimeSpent(int id) Stop tracking foreground-only custom TimeSpent (pair method forstartForegroundTimeSpent(int))static voidtrackAdEvent(AdEvent adEvent) Track advertising event.static voidtrackAppGalleryPurchaseEvent(Object productInfo, String inAppPurchaseData, String inAppDataSignature, String signatureAlgorithm, Map<String, String> eventParams) Track AppGalleryPurchase event.static voidtrackEvent(String name) Track user defined event with custom name.static voidtrackEvent(String name, Map<String, String> eventParams) Track user defined event with custom name and optional key-value parameters.static voidTrack user invitation event.static voidtrackInviteEvent(Map<String, String> eventParams) Track user invitation event.static voidtrackLaunchManually(android.app.Activity activity) This method could be used in rare cases when tracker isn't able to correctly identify application start.static voidTrack achieving new level.static voidtrackLevelEvent(int level, Map<String, String> eventParams) Track achieving new level.static voidtrackLevelEvent(Map<String, String> eventParams) Track achieving new level.static voidtrackLoginEvent(String userId, String vkConnectId) Track user login event.static voidTrack user login event.static voidtrackMiniAppEvent(MiniAppEvent miniAppEvent) Track mini-app event.static voidtrackPurchaseEvent(org.json.JSONObject skuDetails, org.json.JSONObject purchaseData, String dataSignature) Track purchase event.static voidtrackPurchaseEvent(org.json.JSONObject skuDetails, org.json.JSONObject purchaseData, String dataSignature, Map<String, String> eventParams) Track purchase event.static voidtrackRegistrationEvent(String userId, String vkConnectId) Track user registration event.static voidTrack user registration event.
-
Field Details
-
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
Set the attribution listener.- Parameters:
attributionListener- The instance ofMyTracker.AttributionListeneror null.
-
setAttributionListener
public static void setAttributionListener(MyTracker.AttributionListener attributionListener, android.os.Handler handler) Set the attribution listener.- Parameters:
attributionListener- The instance ofMyTracker.AttributionListeneror null.handler- The instance ofHandlerwhich will be used for invocation listener.
-
getTrackerParams
Return the instance ofMyTrackerParams. -
getTrackerConfig
Return the instance ofMyTrackerConfig. -
initTracker
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
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
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
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
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
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
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
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
Track advertising event. Call this method when an advertising event has occurred.- Parameters:
adEvent- Instance ofAdEvent
-
trackMiniAppEvent
Track mini-app event. Call this method when an event in mini-app has occurred.- Parameters:
miniAppEvent- Instance ofMiniAppEvent
-
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 withMyTrackerConfig.setAutotrackingPurchaseEnabled(boolean). This method should be called inActivity.onActivityResult(int, int, Intent).- Parameters:
resultCode- The resultCode fromActivity.onActivityResult(int, int, Intent).data- The data fromActivity.onActivityResult(int, int, Intent).
-
onPurchasesUpdated
The method is used for tracking purchases when autotracking purchases is enabled withMyTrackerConfig.setAutotrackingPurchaseEnabled(boolean). This method should be called inPurchasesUpdatedListener.onPurchasesUpdated(BillingResult, List).- Parameters:
responseCode- The value ofBillingResult.getResponseCode().purchases- List of purchases received onPurchasesUpdatedListener.onPurchasesUpdated(BillingResult, List).
-
handleDeeplink
The method for processing deeplink to application. You could call the method inActivity.onNewIntent(Intent)or inActivity.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
Return current instance id of tracker.- Parameters:
context- Instance of classContext.- 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 forstartForegroundTimeSpent(int))- Parameters:
id- Id of started foreground-only custom TimeSpent
-
stopAnytimeTimeSpent
public static void stopAnytimeTimeSpent(int id) Stop tracking anytime custom TimeSpent (pair method forstartAnytimeTimeSpent(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
-