-
- All Implemented Interfaces:
-
cn.thinkingdata.analytics.IThinkingAnalyticsAPI
public class ThinkingAnalyticsSDK implements IThinkingAnalyticsAPISDK Instance Class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumThinkingAnalyticsSDK.ThinkingdataNetworkTypepublic interfaceThinkingAnalyticsSDK.DynamicSuperPropertiesTrackerpublic interfaceThinkingAnalyticsSDK.AutoTrackDynamicPropertiespublic interfaceThinkingAnalyticsSDK.ThinkingSDKErrorCallbackpublic interfaceThinkingAnalyticsSDK.AutoTrackEventListenerpublic enumThinkingAnalyticsSDK.AutoTrackEventTypeauto-tracking event types.
public interfaceThinkingAnalyticsSDK.InstanceProcessorpublic enumThinkingAnalyticsSDK.TATrackStatusTATrackStatus
-
Field Summary
Fields Modifier and Type Field Description public TDConfigmConfigpublic JSONObjectmAutoTrackEventPropertiespublic CalibratedTimeManagermCalibratedTimeManagerpublic UserOperationHandlermUserOperationHandlerpublic booleanmEnableTrackOldDatapublic DataHandlemMessagespublic SystemInformationmSystemInformationpublic StringmCurrentAccountIdpublic final ObjectlockAccountObjpublic StringmCurrentDistinctIdpublic final ObjectlockDistinctIdpublic ThinkingAnalyticsSDK.TATrackStatusmCurrentTrackStatuspublic final ObjectlockTrackStatuspublic Map<String, EventTimer>mTrackTimerpublic booleanmTrackFragmentAppViewScreenpublic ThinkingAnalyticsSDK.DynamicSuperPropertiesTrackermDynamicSuperPropertiesTrackerpublic ThinkingAnalyticsSDK.AutoTrackDynamicPropertiesmAutoTrackDynamicPropertiespublic booleanmTrackCrashpublic booleanmIgnoreAppViewInExtPackage
-
Constructor Summary
Constructors Constructor Description ThinkingAnalyticsSDK()ThinkingAnalyticsSDK(TDConfig config)
-
Method Summary
Modifier and Type Method Description static ThinkingAnalyticsSDKsharedInstance(Context context, String appId)static ThinkingAnalyticsSDKsharedInstance(Context context, String appId, String url)static ThinkingAnalyticsSDKsharedInstance(Context context, String appId, String url, boolean trackOldData)static ThinkingAnalyticsSDKsharedInstance(TDConfig config)static voidcalibrateTime(long timestamp)static voidcalibrateTimeWithNtp(Array<String> ntpServer)voidlogin(String loginId)Set the account ID. voidlogout()Clearing the account ID will not upload user logout events. StringgetLoginId()voididentify(String identity)Set the distinct ID to replace the default UUID distinct ID. StringgetDistinctId()Get a visitor ID: The #distinct_id value in the reported data. StringgetRandomID()StringgetDeviceId()Obtain the device ID. booleanisTrackDisabled()booleanisStatusTrackSaveOnly()voidsetNetworkType(ThinkingAnalyticsSDK.ThinkingdataNetworkType type)Set the network conditions for uploading. voidautoTrack(String eventName, JSONObject properties)voidautoTrack(String eventName, JSONObject properties, ITime time)voidtrack(String eventName, JSONObject properties)Upload events and their associated attributes. voidtrack(String eventName, JSONObject properties, Date time)Upload event, you can set the event trigger time. voidtrack(String eventName, JSONObject properties, Date time, TimeZone timeZone)Upload the event and set the event trigger time. voidtrack(String eventName)Upload a single event, containing only preset properties and set public properties. voidtrack(ThinkingAnalyticsEvent event)Upload a special type of event. voidtrackWithDebugOnly(String eventName, JSONObject properties)voidtrackInternal(DataDescription dataDescription)voiduser_add(JSONObject properties)Adds the numeric type user attributes. voiduser_add(String propertyName, Number propertyValue)Only one attribute is set when the user attributes of a numeric type are added. voiduser_add(JSONObject properties, Date date)voiduser_append(JSONObject properties)Append a user attribute of the List type. voiduser_append(JSONObject properties, Date date)voiduser_uniqAppend(JSONObject property)The element appended to the library needs to be done to remove the processing, remove the support, and then import. voiduser_uniqAppend(JSONObject properties, Date date)voiduser_setOnce(JSONObject properties)Sets a single user attribute, ignoring the new attribute value if the attribute already exists. voiduser_setOnce(JSONObject properties, Date date)voiduser_set(JSONObject properties)Sets the user property, replacing the original value with the new value if the property already exists. voiduser_set(JSONObject properties, Date date)voiduser_operations(TDConstants.DataType type, JSONObject properties, Date date)voiduser_delete()Delete the user attributes, but retain the uploaded event data. voiduser_delete(Date date)voiduser_unset(Array<String> properties)Reset user properties. voiduser_unset(JSONObject properties, Date date)voidflush()Empty the cache queue. JSONObjectgetSuperProperties()Gets the public event properties that have been set. TDPresetPropertiesgetPresetProperties()Gets prefabricated properties for all events. voidsetSuperProperties(JSONObject superProperties)Set the public event attribute, which will be included in every event uploaded after that. voidunsetSuperProperty(String superPropertyName)Clears a public event attribute. voidclearSuperProperties()Clear all public event attributes. voidsetJsBridge(WebView webView)Support H5 to connect with native APP SDK.This function is called when the WebView is initialized. voidsetJsBridgeForX5WebView(Object x5WebView)Tencent X5 WebView gets through with native APP SDK. voidregisterErrorCallback(ThinkingAnalyticsSDK.ThinkingSDKErrorCallback callback)ThinkingAnalyticsSDK.ThinkingSDKErrorCallbackgetSDKErrorCallback()voidsetDynamicSuperPropertiesTracker(ThinkingAnalyticsSDK.DynamicSuperPropertiesTracker dynamicSuperPropertiesTracker)Set dynamic public properties. voidsetAutoTrackDynamicProperties(ThinkingAnalyticsSDK.AutoTrackDynamicProperties autoTrackDynamicProperties)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. booleanisActivityAutoTrackAppViewScreenIgnored(Class<out Object> activity)voidignoreAutoTrackActivity(Class<out Object> activity)Ignores automatic collection events for the specified page, including page browsing and control clicking events. voidignoreAutoTrackActivities(List<Class<out Object>> activitiesList)Ignore automatic collection events for multiple pages, including page browsing and control clicks. booleanisAutoTrackEventTypeIgnored(ThinkingAnalyticsSDK.AutoTrackEventType eventType)booleanisAutoTrackEnabled()voidtrackViewScreenInternal(String url, JSONObject properties)voidignoreAppViewEventInExtPackage()Ignore automatic collection events in the extension pack booleanisIgnoreAppViewInExtPackage()voidtrackViewScreen(Activity activity)Manually trigger the page browsing event upload. voidtrackViewScreen(Fragment fragment)Manually trigger the page browsing event upload. voidtrackViewScreen(Object fragment)Manually trigger the page browsing event upload. voidappEnterBackground()voidappBecomeActive()voidtrackAppInstall()Enable the collection of installation events. voidenableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, JSONObject properties)voidenableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, ThinkingAnalyticsSDK.AutoTrackEventListener autoTrackEventListener)voidenableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList)Enable the auto tracking function. voidsetAutoTrackProperties(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, JSONObject autoTrackEventProperties)Set the custom properties of the automatic collection event. voidtrackAppCrashAndEndEvent(JSONObject properties)voidignoreViewType(Class viewType)Ignores control click events of the specified type. voidtrackFragmentAppViewScreen()Enable the automatic collection Fragment browsing event. voidsetViewID(View view, String viewID)Custom control ID. voidsetViewID(Dialog view, String viewID)Custom Dialog control ID. voidsetViewProperties(View view, JSONObject properties)Customize the properties of the control click event. voidignoreView(View view)Ignores the click event for the specified element. static voidallInstances(ThinkingAnalyticsSDK.InstanceProcessor processor)static ThinkingAnalyticsSDKgetInstanceByAppId(String name)voidsetTrackStatus(ThinkingAnalyticsSDK.TATrackStatus status)The switch reporting status is suspended and restored. voidenableTracking(boolean enabled)Enable or disable the instance function. voidoptOutTrackingAndDeleteUser()Stop reporting the user data. voidoptOutTracking()Example Stop reporting the user data. voidoptInTracking()Enable the reporting of the instance. ThinkingAnalyticsSDKcreateLightInstance()Create lightweight SDK instances. StringgetToken()StringgetTimeString(Date date)StringgetCurrentTime()DoublegetCurrentZoneOffset()voidenableThirdPartySharing(int types)Enable three-party data synchronization. voidenableThirdPartySharing(int type, Object obj)-
Methods inherited from class cn.thinkingdata.analytics.IThinkingAnalyticsAPI
createLightInstance, enableAutoTrack, enableTracking, identify, login, setAutoTrackProperties, setDynamicSuperPropertiesTracker, setNetworkType, setSuperProperties, setTrackStatus, setViewID, timeEvent, track, trackViewScreen, trackViewScreen, unsetSuperProperty, user_add, user_append, user_set, user_setOnce -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ThinkingAnalyticsSDK
ThinkingAnalyticsSDK()
-
ThinkingAnalyticsSDK
ThinkingAnalyticsSDK(TDConfig config)
-
-
Method Detail
-
sharedInstance
static ThinkingAnalyticsSDK sharedInstance(Context context, String appId)
-
sharedInstance
static ThinkingAnalyticsSDK sharedInstance(Context context, String appId, String url)
-
sharedInstance
static ThinkingAnalyticsSDK sharedInstance(Context context, String appId, String url, boolean trackOldData)
-
sharedInstance
static ThinkingAnalyticsSDK sharedInstance(TDConfig config)
-
calibrateTime
static void calibrateTime(long timestamp)
-
calibrateTimeWithNtp
static void calibrateTimeWithNtp(Array<String> ntpServer)
-
login
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
void logout()
Clearing the account ID will not upload user logout events.
-
getLoginId
String getLoginId()
-
identify
void identify(String identity)
Set the distinct ID to replace the default UUID distinct ID.
-
getDistinctId
String getDistinctId()
Get a visitor ID: The #distinct_id value in the reported data.
-
getRandomID
String getRandomID()
-
getDeviceId
String getDeviceId()
Obtain the device ID.
-
isTrackDisabled
boolean isTrackDisabled()
-
isStatusTrackSaveOnly
boolean isStatusTrackSaveOnly()
-
setNetworkType
void setNetworkType(ThinkingAnalyticsSDK.ThinkingdataNetworkType type)
Set the network conditions for uploading. By default, the SDK will upload data on 3G, 4G and Wifi.
- Parameters:
type- Type of the network on which data is uploaded
-
autoTrack
void autoTrack(String eventName, JSONObject properties)
-
autoTrack
void autoTrack(String eventName, JSONObject properties, ITime time)
-
track
void track(String eventName, JSONObject properties)
Upload events and their associated attributes.
- Parameters:
eventName- event nameproperties- event properties
-
track
void track(String eventName, JSONObject properties, Date time)
Upload event, you can set the event trigger time. SDK support began with version 1.1.5. This method is deprecated in v2.2.0+time will be reported as a string serialized to the specified format according to the device's default time zone, but #zone_offset will not be set.
- Parameters:
eventName- event nameproperties- event propertiestime- event time
-
track
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
void track(String eventName)
Upload a single event, containing only preset properties and set public properties.
- Parameters:
eventName- event name
-
track
void track(ThinkingAnalyticsEvent event)
Upload a special type of event.
- Parameters:
event- Event Object TDUniqueEvent / TDUpdatableEvent / TDOverWritableEvent
-
trackWithDebugOnly
void trackWithDebugOnly(String eventName, JSONObject properties)
-
trackInternal
void trackInternal(DataDescription dataDescription)
-
user_add
void user_add(JSONObject properties)
Adds the numeric type user attributes.
-
user_add
void user_add(String propertyName, Number propertyValue)
Only one attribute is set when the user attributes of a numeric type are added.
-
user_add
void user_add(JSONObject properties, Date date)
-
user_append
void user_append(JSONObject properties)
Append a user attribute of the List type.
-
user_append
void user_append(JSONObject properties, Date date)
-
user_uniqAppend
void user_uniqAppend(JSONObject property)
The element appended to the library needs to be done to remove the processing, remove the support, and then import.
- Parameters:
property- JSONObject
-
user_uniqAppend
void user_uniqAppend(JSONObject properties, Date date)
-
user_setOnce
void user_setOnce(JSONObject properties)
Sets a single user attribute, ignoring the new attribute value if the attribute already exists.
-
user_setOnce
void user_setOnce(JSONObject properties, Date date)
-
user_set
void user_set(JSONObject properties)
Sets the user property, replacing the original value with the new value if the property already exists.
-
user_set
void user_set(JSONObject properties, Date date)
-
user_operations
void user_operations(TDConstants.DataType type, JSONObject properties, Date date)
-
user_delete
void user_delete()
Delete the user attributes, but retain the uploaded event data. This operation is not reversible and should be performed with caution.
-
user_delete
void user_delete(Date date)
-
user_unset
void user_unset(Array<String> properties)
Reset user properties.
-
user_unset
void user_unset(JSONObject properties, Date date)
-
flush
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.
-
getSuperProperties
JSONObject getSuperProperties()
Gets the public event properties that have been set.
-
getPresetProperties
TDPresetProperties getPresetProperties()
Gets prefabricated properties for all events.
-
setSuperProperties
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.
-
unsetSuperProperty
void unsetSuperProperty(String superPropertyName)
Clears a public event attribute.
- Parameters:
superPropertyName- Public event attribute key to clear
-
clearSuperProperties
void clearSuperProperties()
Clear all public event attributes.
-
setJsBridge
void setJsBridge(WebView webView)
Support H5 to connect with native APP SDK.This function is called when the WebView is initialized.
-
setJsBridgeForX5WebView
void setJsBridgeForX5WebView(Object x5WebView)
Tencent X5 WebView gets through with native APP SDK.
- Parameters:
x5WebView- WebView instance
-
registerErrorCallback
void registerErrorCallback(ThinkingAnalyticsSDK.ThinkingSDKErrorCallback callback)
-
getSDKErrorCallback
ThinkingAnalyticsSDK.ThinkingSDKErrorCallback getSDKErrorCallback()
-
setDynamicSuperPropertiesTracker
void setDynamicSuperPropertiesTracker(ThinkingAnalyticsSDK.DynamicSuperPropertiesTracker dynamicSuperPropertiesTracker)
Set dynamic public properties. Each event uploaded after that will contain a public event attribute.
- Parameters:
dynamicSuperPropertiesTracker- Dynamic public attribute interface
-
setAutoTrackDynamicProperties
void setAutoTrackDynamicProperties(ThinkingAnalyticsSDK.AutoTrackDynamicProperties autoTrackDynamicProperties)
-
timeEvent
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
-
isActivityAutoTrackAppViewScreenIgnored
boolean isActivityAutoTrackAppViewScreenIgnored(Class<out Object> activity)
-
ignoreAutoTrackActivity
void ignoreAutoTrackActivity(Class<out Object> activity)
Ignores automatic collection events for the specified page, including page browsing and control clicking events.
-
ignoreAutoTrackActivities
void ignoreAutoTrackActivities(List<Class<out Object>> activitiesList)
Ignore automatic collection events for multiple pages, including page browsing and control clicks.
-
isAutoTrackEventTypeIgnored
boolean isAutoTrackEventTypeIgnored(ThinkingAnalyticsSDK.AutoTrackEventType eventType)
-
isAutoTrackEnabled
boolean isAutoTrackEnabled()
-
trackViewScreenInternal
void trackViewScreenInternal(String url, JSONObject properties)
-
ignoreAppViewEventInExtPackage
void ignoreAppViewEventInExtPackage()
Ignore automatic collection events in the extension pack
-
isIgnoreAppViewInExtPackage
boolean isIgnoreAppViewInExtPackage()
-
trackViewScreen
void trackViewScreen(Activity activity)
Manually trigger the page browsing event upload.
- Parameters:
activity- Activity
-
trackViewScreen
void trackViewScreen(Fragment fragment)
Manually trigger the page browsing event upload.
- Parameters:
fragment- Indicates the Fragment instance to be collected
-
trackViewScreen
void trackViewScreen(Object fragment)
Manually trigger the page browsing event upload.
- Parameters:
fragment- Indicates the Fragment instance to be collected.
-
appEnterBackground
void appEnterBackground()
-
appBecomeActive
void appBecomeActive()
-
trackAppInstall
void trackAppInstall()
Enable the collection of installation events. added for unity3D.
-
enableAutoTrack
void enableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, JSONObject properties)
-
enableAutoTrack
void enableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, ThinkingAnalyticsSDK.AutoTrackEventListener autoTrackEventListener)
-
enableAutoTrack
void enableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList)
Enable the auto tracking function.
- Parameters:
eventTypeList- Indicates the type of the automatic collection event to be enabled
-
setAutoTrackProperties
void setAutoTrackProperties(List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList, JSONObject autoTrackEventProperties)
Set the custom properties of the automatic collection event.The uploaded automatic collection event will contain the event properties that have been set for the event
-
trackAppCrashAndEndEvent
void trackAppCrashAndEndEvent(JSONObject properties)
-
ignoreViewType
void ignoreViewType(Class viewType)
Ignores control click events of the specified type.
-
trackFragmentAppViewScreen
void trackFragmentAppViewScreen()
Enable the automatic collection Fragment browsing event.
-
setViewID
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
void setViewID(Dialog view, String viewID)
Custom Dialog control ID. If not set, android:id is used by default.
- Parameters:
view- widgetviewID- widget ID
-
setViewProperties
void setViewProperties(View view, JSONObject properties)
Customize the properties of the control click event.
- Parameters:
view- Control that you want to set custom properties
-
ignoreView
void ignoreView(View view)
Ignores the click event for the specified element.
-
allInstances
static void allInstances(ThinkingAnalyticsSDK.InstanceProcessor processor)
-
getInstanceByAppId
static ThinkingAnalyticsSDK getInstanceByAppId(String name)
-
setTrackStatus
void setTrackStatus(ThinkingAnalyticsSDK.TATrackStatus status)
The switch reporting status is suspended and restored.
- Parameters:
status- TATrackStatus
-
enableTracking
@Deprecated() void enableTracking(boolean enabled)
Enable or disable the instance function. When the SDK function is disabled, the cached data is retained and continued to be reported. But it doesn't track subsequent data and changes.
- Parameters:
enabled- true Opening the Report; false Disable reporting
-
optOutTrackingAndDeleteUser
@Deprecated() void optOutTrackingAndDeleteUser()
Stop reporting the user data. After this interface is invoked, the local cache data and previous Settings are deleted.Subsequent reports and Settings are invalid. And send user_del (no retry)
-
optOutTracking
@Deprecated() void optOutTracking()
Example Stop reporting the user data. After calling this interface,the local cache data and previous Settings are deleted; Subsequent reports and Settings are invalid.
-
optInTracking
@Deprecated() void optInTracking()
Enable the reporting of the instance.
-
createLightInstance
ThinkingAnalyticsSDK createLightInstance()
Create lightweight SDK instances. Lightweight SDK instances do not supportcaching of local account ids, guest ids, public properties, etc.
-
getTimeString
String getTimeString(Date date)
-
getCurrentTime
String getCurrentTime()
-
getCurrentZoneOffset
Double getCurrentZoneOffset()
-
enableThirdPartySharing
void enableThirdPartySharing(int types)
Enable three-party data synchronization.
-
enableThirdPartySharing
void enableThirdPartySharing(int type, Object obj)
-
-
-
-