-
public class TDAnalyticsThe packaging class of ThinkingAnalyticsSDK provides static methods, which is more convenient for customers to use
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceTDAnalytics.TDAutoTrackEventTypeAutomatic collection of event types
public interfaceTDAnalytics.TDAutoTrackEventHandlerAutomatic collection event callback
public enumTDAnalytics.TDTrackStatusData sending status
public enumTDAnalytics.TDNetworkTypeIndicates the network type that can be reported
public interfaceTDAnalytics.TDDynamicSuperPropertiesHandlerThis parameter is reported on all network types
public interfaceTDAnalytics.TDSendDataErrorCallback
-
Field Summary
Fields Modifier and Type Field Description public static Map<String, ThinkingAnalyticsSDK>sInstances
-
Method Summary
Modifier and Type Method Description static StringgetLocalRegion()Get the local area/country code static voidcalibrateTime(long timestamp)time calibration with timestamp static voidcalibrateTimeWithNtp(Array<String> ntpServer)time calibration with ntp static voidenableLog(boolean enableLog)enable debug logging static voidsetCustomerLibInfo(String libName, String libVersion)Set libName and libVersion of SDK static voidencryptLocalStorage()static voidinit(Context context, String appId, String serverUrl)Initialize the SDK. static synchronized voidinit(TDConfig config)Initialize the SDK with config. static StringlightInstance()Create lightweight SDK instances. static voidsetNetworkType(TDAnalytics.TDNetworkType networkType)Set the network conditions for uploading. static voidregisterErrorCallback(TDAnalytics.TDSendDataErrorCallback callback)static voidtrack(String eventName)Upload a single event, containing only preset properties and set public properties. static voidtrack(String eventName, JSONObject properties)Upload events and their associated attributes. static voidtrack(String eventName, JSONObject properties, Date time, TimeZone timeZone)Upload the event and set the event trigger time. static voidtrack(TDEventModel eventModel)Upload a special type of event. static voidenableAutoTrack(int autoTrackEventType)Enable the auto tracking function. static voidenableAutoTrack(int autoTrackEventType, JSONObject properties)Enable the auto tracking function with properties static voidenableAutoTrack(int autoTrackEventType, TDAnalytics.TDAutoTrackEventHandler eventHandler)Enable the auto tracking function with properties static voidtimeEvent(String eventName)Record the event duration, call this method to start the timing, stop the timing when the target event is uploaded, and add the attribute #duration to the event properties, in seconds. static voiduserSet(JSONObject properties)Sets the user property, replacing the original value with the new value if the property already exists. static voiduserSetOnce(JSONObject properties)Sets a single user attribute, ignoring the new attribute value if the attribute already exists. static voiduserUnset(Array<String> properties)Reset user properties. static voiduserAdd(JSONObject properties)Only one attribute is set when the user attributes of a numeric type are added. static voiduserAppend(JSONObject properties)Append a user attribute of the List type. static voiduserUniqAppend(JSONObject properties)The element appended to the library needs to be done to remove the processing, remove the support, and then import. static voiduserDelete()Delete the user attributes, but retain the uploaded event data. static voidsetSuperProperties(JSONObject superProperties)Set the public event attribute, which will be included in every event uploaded after that. static voidsetDynamicSuperProperties(TDAnalytics.TDDynamicSuperPropertiesHandler dynamicSuperPropertiesTracker)Set dynamic public properties. static voidunsetSuperProperty(String superPropertyName)Clears a public event attribute. static voidclearSuperProperties()Clear all public event attributes. static JSONObjectgetSuperProperties()Gets the public event properties that have been set. static TDPresetPropertiesgetPresetProperties()Gets prefabricated properties for all events. static voidlogin(String loginId)Set the account ID. static voidlogout()Clearing the account ID will not upload user logout events. static voidsetDistinctId(String identity)Set the distinct ID to replace the default UUID distinct ID. static StringgetDistinctId()Get a visitor ID: The #distinct_id value in the reported data. static StringgetAccountId()static StringgetDeviceId()Obtain the device ID. static voidflush()Empty the cache queue. static voidsetTrackStatus(TDAnalytics.TDTrackStatus status)The switch reporting status is suspended and restored. static voidenableThirdPartySharing(int types)Enable three-party data synchronization. static voidenableThirdPartySharing(int type, Object obj)Enable three-party data synchronization. static voidignoreAppViewEventInExtPackage()Ignore automatic collection events in the extension pack static voidtrackViewScreen(Activity activity)Manually trigger the page browsing event upload. static voidtrackViewScreen(Fragment fragment)Manually trigger the page browsing event upload. static voidtrackViewScreen(Object fragment)Manually trigger the page browsing event upload. static voidignoreViewType(Class<out Object> viewType)Ignores control click events of the specified type. static voidtrackFragmentAppViewScreen()Enable the automatic collection Fragment browsing event. static voidignoreAutoTrackActivity(Class<out Object> activity)Ignore automatic collection events for multiple pages, including page browsing and control clicks. static voidignoreAutoTrackActivities(List<Class<out Object>> activitiesList)Ignore automatic collection events for multiple pages, including page browsing and control clicks. static voidsetViewID(View view, String viewID)Custom control ID. static voidsetViewID(Dialog view, String viewID)Custom control ID. static voidsetViewProperties(View view, JSONObject properties)Customize the properties of the control click event. static voidignoreView(View view)Ignores control click events of the specified view. static voidsetJsBridge(WebView webView)Support H5 to connect with native APP SDK.This function is called when the WebView is initialized. static voidsetJsBridgeForX5WebView(Object x5WebView)Tencent X5 WebView gets through with native APP SDK. -
-
Method Detail
-
getLocalRegion
static String getLocalRegion()
Get the local area/country code
-
calibrateTime
static void calibrateTime(long timestamp)
time calibration with timestamp
- Parameters:
timestamp- timestamp
-
calibrateTimeWithNtp
static void calibrateTimeWithNtp(Array<String> ntpServer)
time calibration with ntp
- Parameters:
ntpServer- ntp server url
-
enableLog
static void enableLog(boolean enableLog)
enable debug logging
- Parameters:
enableLog- log switch
-
setCustomerLibInfo
static void setCustomerLibInfo(String libName, String libVersion)
Set libName and libVersion of SDK
- Parameters:
libName- sdk namelibVersion- sdk version
-
encryptLocalStorage
static void encryptLocalStorage()
-
init
static void init(Context context, String appId, String serverUrl)
Initialize the SDK. The track function is not available until this interface is invoked.
- Parameters:
context- contextappId- app idserverUrl- server url
-
init
static synchronized void init(TDConfig config)
Initialize the SDK with config. The track function is not available until this interface is invoked.
- Parameters:
config- init config
-
lightInstance
static String lightInstance()
Create lightweight SDK instances. Lightweight SDK instances do not supportcaching of local account ids, guest ids, public properties, etc.
-
setNetworkType
static void setNetworkType(TDAnalytics.TDNetworkType networkType)
Set the network conditions for uploading. By default, the SDK will upload data on 3G, 4G and Wifi.
- Parameters:
networkType- Type of the network on which data is uploaded
-
registerErrorCallback
static void registerErrorCallback(TDAnalytics.TDSendDataErrorCallback callback)
-
track
static void track(String eventName)
Upload a single event, containing only preset properties and set public properties.
- Parameters:
eventName- event name
-
track
static void track(String eventName, JSONObject properties)
Upload events and their associated attributes.
- Parameters:
eventName- event nameproperties- event properties
-
track
static void track(String eventName, JSONObject properties, Date time, TimeZone timeZone)
Upload the event and set the event trigger time. SDK v2.2.0 support is available.
- Parameters:
eventName- event nameproperties- event propertiestime- event timetimeZone- event timeZone
-
track
static void track(TDEventModel eventModel)
Upload a special type of event.
- Parameters:
eventModel- Event Object TDFirstEventModel / TDOverWritableEventModel / TDUpdatableEventModel
-
enableAutoTrack
static void enableAutoTrack(int autoTrackEventType)
Enable the auto tracking function.
- Parameters:
autoTrackEventType- Indicates the type of the automatic collection event to be enabled
-
enableAutoTrack
static void enableAutoTrack(int autoTrackEventType, JSONObject properties)
Enable the auto tracking function with properties
- Parameters:
autoTrackEventType- Indicates the type of the automatic collection event to be enabledproperties- properties
-
enableAutoTrack
static void enableAutoTrack(int autoTrackEventType, TDAnalytics.TDAutoTrackEventHandler eventHandler)
Enable the auto tracking function with properties
- Parameters:
autoTrackEventType- Indicates the type of the automatic collection event to be enabledeventHandler- callback
-
timeEvent
static void timeEvent(String eventName)
Record the event duration, call this method to start the timing, stop the timing when the target event is uploaded, and add the attribute #duration to the event properties, in seconds.
- Parameters:
eventName- target event name
-
userSet
static void userSet(JSONObject properties)
Sets the user property, replacing the original value with the new value if the property already exists.
- Parameters:
properties- user property
-
userSetOnce
static void userSetOnce(JSONObject properties)
Sets a single user attribute, ignoring the new attribute value if the attribute already exists.
- Parameters:
properties- user property
-
userUnset
static void userUnset(Array<String> properties)
Reset user properties.
- Parameters:
properties- user property
-
userAdd
static void userAdd(JSONObject properties)
Only one attribute is set when the user attributes of a numeric type are added.
- Parameters:
properties- user property
-
userAppend
static void userAppend(JSONObject properties)
Append a user attribute of the List type.
- Parameters:
properties- user property
-
userUniqAppend
static void userUniqAppend(JSONObject properties)
The element appended to the library needs to be done to remove the processing, remove the support, and then import.
- Parameters:
properties- user property
-
userDelete
static void userDelete()
Delete the user attributes, but retain the uploaded event data. This operation is not reversible and should be performed with caution.
-
setSuperProperties
static void setSuperProperties(JSONObject superProperties)
Set the public event attribute, which will be included in every event uploaded after that. The public event properties are saved without setting them each time.
- Parameters:
superProperties- super properties
-
setDynamicSuperProperties
static void setDynamicSuperProperties(TDAnalytics.TDDynamicSuperPropertiesHandler dynamicSuperPropertiesTracker)
Set dynamic public properties. Each event uploaded after that will contain a public event attribute.
- Parameters:
dynamicSuperPropertiesTracker- Dynamic public attribute interface
-
unsetSuperProperty
static void unsetSuperProperty(String superPropertyName)
Clears a public event attribute.
- Parameters:
superPropertyName- Public event attribute key to clear
-
clearSuperProperties
static void clearSuperProperties()
Clear all public event attributes.
-
getSuperProperties
static JSONObject getSuperProperties()
Gets the public event properties that have been set.
-
getPresetProperties
static TDPresetProperties getPresetProperties()
Gets prefabricated properties for all events.
-
login
static void login(String loginId)
Set the account ID. Each setting overrides the previous value. Login events will not be uploaded.
- Parameters:
loginId- account id
-
logout
static void logout()
Clearing the account ID will not upload user logout events.
-
setDistinctId
static void setDistinctId(String identity)
Set the distinct ID to replace the default UUID distinct ID.
- Parameters:
identity- distinct id
-
getDistinctId
static String getDistinctId()
Get a visitor ID: The #distinct_id value in the reported data.
-
getAccountId
static String getAccountId()
-
getDeviceId
static String getDeviceId()
Obtain the device ID.
-
flush
static void flush()
Empty the cache queue. When this function is called, the data in the current cache queue will attempt to be reported.If the report succeeds, local cache data will be deleted.
-
setTrackStatus
static void setTrackStatus(TDAnalytics.TDTrackStatus status)
The switch reporting status is suspended and restored.
- Parameters:
status- TDTrackStatus
-
enableThirdPartySharing
static void enableThirdPartySharing(int types)
Enable three-party data synchronization.
- Parameters:
types- third types
-
enableThirdPartySharing
static void enableThirdPartySharing(int type, Object obj)
Enable three-party data synchronization.
- Parameters:
type- third typesobj- extras
-
ignoreAppViewEventInExtPackage
static void ignoreAppViewEventInExtPackage()
Ignore automatic collection events in the extension pack
-
trackViewScreen
static void trackViewScreen(Activity activity)
Manually trigger the page browsing event upload.
- Parameters:
activity- activity
-
trackViewScreen
static void trackViewScreen(Fragment fragment)
Manually trigger the page browsing event upload.
- Parameters:
fragment- Indicates the Fragment instance to be collected
-
trackViewScreen
static void trackViewScreen(Object fragment)
Manually trigger the page browsing event upload.
- Parameters:
fragment- Indicates the Fragment instance to be collected.
-
ignoreViewType
static void ignoreViewType(Class<out Object> viewType)
Ignores control click events of the specified type.
- Parameters:
viewType- view type
-
trackFragmentAppViewScreen
static void trackFragmentAppViewScreen()
Enable the automatic collection Fragment browsing event.
-
ignoreAutoTrackActivity
static void ignoreAutoTrackActivity(Class<out Object> activity)
Ignore automatic collection events for multiple pages, including page browsing and control clicks.
- Parameters:
activity- single activity
-
ignoreAutoTrackActivities
static void ignoreAutoTrackActivities(List<Class<out Object>> activitiesList)
Ignore automatic collection events for multiple pages, including page browsing and control clicks.
- Parameters:
activitiesList- list of activity
-
setViewID
static void setViewID(View view, String viewID)
Custom control ID. If this parameter is not specified, android:id is used by default.
- Parameters:
view- widgetviewID- widget ID
-
setViewID
static void setViewID(Dialog view, String viewID)
Custom control ID. If this parameter is not specified, android:id is used by default.
- Parameters:
view- dialog viewviewID- widget ID
-
setViewProperties
static void setViewProperties(View view, JSONObject properties)
Customize the properties of the control click event.
- Parameters:
view- Control that you want to set custom propertiesproperties- properties
-
ignoreView
static void ignoreView(View view)
Ignores control click events of the specified view.
- Parameters:
view- widget
-
setJsBridge
static void setJsBridge(WebView webView)
Support H5 to connect with native APP SDK.This function is called when the WebView is initialized.
- Parameters:
webView- WebView instance
-
setJsBridgeForX5WebView
static void setJsBridgeForX5WebView(Object x5WebView)
Tencent X5 WebView gets through with native APP SDK.
- Parameters:
x5WebView- WebView instance
-
-
-
-