public interface ISensorsDataAPI extends IUserIdentityAPI, SAAdvertAPIProtocol, AutoTrackProtocol, SAExposureAPIProtocol
BIND_ID, UNBIND_ID
限定符和类型 | 方法和说明 |
---|---|
void |
addHeatMapActivities(java.util.List<java.lang.Class<?>> activitiesList)
开启多个 activity 的点击图
|
void |
addHeatMapActivity(java.lang.Class<?> activity)
开启某个 activity 的点击图
|
void |
addVisualizedAutoTrackActivities(java.util.List<java.lang.Class<?>> activitiesList)
开启多个 activity 的可视化全埋点
|
void |
addVisualizedAutoTrackActivity(java.lang.Class<?> activity)
开启某个 activity 的可视化全埋点
|
void |
clearGPSLocation()
清除 GPS 位置信息
|
void |
clearSuperProperties()
删除所有事件公共属性
|
void |
clearTrackTimer()
清除所有事件计时器
|
void |
deleteAll()
删除本地缓存的全部事件
|
void |
enableDeepLinkInstallSource(boolean enable)
DeepLink 是否采集设备信息
|
void |
enableLog(boolean enable)
设置是否开启 log
|
void |
enableNetworkRequest(boolean isRequest)
设置是否允许请求网络,默认是 true
|
void |
enableRemoteConfig(boolean enable)
是否开启远程配置
|
void |
enableTrackScreenOrientation(boolean enable)
开启/关闭采集屏幕方向
|
void |
flush()
将所有本地缓存的日志发送到 Sensors Analytics.
|
void |
flushScheduled()
以轮询形式将所有本地缓存的日志发送到 Sensors Analytics.
|
void |
flushSync()
将所有本地缓存的日志发送到 Sensors Analytics.
|
java.lang.String |
getAnonymousId()
获取当前用户的匿名 ID
若调用前未调用
identify(String) 设置用户的匿名 ID,SDK 会优先调用 SensorsDataUtils#getAndroidID 获取 Android ID,
如获取的 Android ID 非法,则调用 UUID 随机生成 UUID,作为用户的匿名 ID |
java.lang.String |
getCookie(boolean decode)
获取已设置的 Cookie
URLDecoder.decode(Cookie, "UTF-8")
|
java.lang.String |
getDistinctId()
获取当前用户的 distinctId
|
int |
getFlushBulkSize()
返回本地缓存日志的最大条目数
默认值为 100 条
在每次调用 track、signUp 以及 profileSet 等接口的时候,都会检查如下条件,以判断是否向服务器上传数据:
1.
|
int |
getFlushInterval()
两次数据发送的最小时间间隔,单位毫秒
默认值为 15 * 1000 毫秒
在每次调用 track、signUp 以及 profileSet 等接口的时候,都会检查如下条件,以判断是否向服务器上传数据:
1.
|
java.lang.String |
getLoginId()
获取当前用户的 loginId
若调用前未调用
login(String) 设置用户的 loginId,会返回 null |
long |
getMaxCacheSize()
获取本地缓存上限制
|
org.json.JSONObject |
getPresetProperties()
返回预置属性
|
java.lang.String |
getScreenOrientation()
获取当前屏幕方向
|
java.lang.String |
getServerUrl()
获取当前 serverUrl
|
int |
getSessionIntervalTime()
设置 App 切换到后台与下次事件的事件间隔
默认值为 30*1000 毫秒
若 App 在后台超过设定事件,则认为当前 Session 结束,发送 $AppEnd 事件
|
org.json.JSONObject |
getSuperProperties()
获取事件公共属性
|
void |
identify(java.lang.String distinctId)
设置当前用户的 distinctId。
|
boolean |
isDebugMode()
是否是开启 debug 模式
|
boolean |
isHeatMapActivity(java.lang.Class<?> activity)
activity 是否开启了点击图
|
boolean |
isHeatMapEnabled()
是否开启点击图
|
boolean |
isNetworkRequestEnable()
是否请求网络,默认是 true
|
boolean |
isVisualizedAutoTrackActivity(java.lang.Class<?> activity)
activity 是否开启了可视化全埋点
|
boolean |
isVisualizedAutoTrackEnabled()
是否开启可视化全埋点
|
void |
itemDelete(java.lang.String itemType,
java.lang.String itemId)
删除 item
|
void |
itemSet(java.lang.String itemType,
java.lang.String itemId,
org.json.JSONObject properties)
设置 item
|
void |
login(java.lang.String loginId)
登录,设置当前用户的 loginId
|
void |
login(java.lang.String loginId,
org.json.JSONObject properties)
登录,设置当前用户的 loginId
|
void |
logout()
注销,清空当前用户的 loginId
|
void |
profileAppend(java.lang.String property,
java.util.Set<java.lang.String> values)
给一个列表类型的 Profile 增加一个或多个元素
|
void |
profileAppend(java.lang.String property,
java.lang.String value)
给一个列表类型的 Profile 增加一个元素
|
void |
profileDelete()
删除用户所有 Profile
|
void |
profileIncrement(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
给一个或多个数值类型的 Profile 增加一个数值。
|
void |
profileIncrement(java.lang.String property,
java.lang.Number value)
给一个数值类型的 Profile 增加一个数值。
|
void |
profilePushId(java.lang.String pushTypeKey,
java.lang.String pushId)
保存用户推送 ID 到用户表
|
void |
profileSet(org.json.JSONObject properties)
设置用户的一个或多个 Profile。
|
void |
profileSet(java.lang.String property,
java.lang.Object value)
设置用户的一个 Profile,如果之前存在,则覆盖,否则,新创建
|
void |
profileSetOnce(org.json.JSONObject properties)
首次设置用户的一个或多个 Profile。
|
void |
profileSetOnce(java.lang.String property,
java.lang.Object value)
首次设置用户的一个 Profile
与profileSet接口不同的是,如果之前存在,则忽略,否则,新创建
|
void |
profileUnset(java.lang.String property)
删除用户的一个 Profile
|
void |
profileUnsetPushId(java.lang.String pushTypeKey)
删除用户设置的 pushId
|
void |
registerDynamicSuperProperties(SensorsDataDynamicSuperProperties dynamicSuperProperties)
注册事件动态公共属性
|
void |
registerLimitKeys(java.util.Map<java.lang.String,java.lang.String> limitKeys)
注册限制性属性 key
|
void |
registerPropertyPlugin(SAPropertyPlugin plugin)
注册自定义插件
|
void |
registerSuperProperties(org.json.JSONObject superProperties)
注册所有事件都有的公共属性
|
void |
removeTimer(java.lang.String eventName)
删除事件的计时器
|
void |
resetAnonymousId()
已过时。
|
void |
resumeTrackScreenOrientation()
恢复采集屏幕方向
|
void |
setCookie(java.lang.String cookie,
boolean encode)
设置 Cookie,flush 的时候会设置 HTTP 的 cookie
内部会 URLEncoder.encode(cookie, "UTF-8")
|
void |
setFlushBulkSize(int flushBulkSize)
设置本地缓存日志的最大条目数,最小 50 条
|
void |
setFlushInterval(int flushInterval)
设置两次数据发送的最小时间间隔
|
void |
setFlushNetworkPolicy(int networkType)
设置 flush 时网络发送策略,默认 3G、4G、5G、WI-FI 环境下都会尝试 flush
|
void |
setGPSLocation(double latitude,
double longitude)
更新 GPS 位置信息
|
void |
setGPSLocation(double latitude,
double longitude,
java.lang.String coordinate)
更新 GPS 位置信息及对应坐标系
|
void |
setMaxCacheSize(long maxCacheSize)
设置本地缓存上限值,单位 byte,默认为 32MB:32 * 1024 * 1024,最小 16MB:16 * 1024 * 1024,若小于 16MB,则按 16MB 处理。
|
void |
setServerUrl(java.lang.String serverUrl)
设置当前 serverUrl
|
void |
setServerUrl(java.lang.String serverUrl,
boolean isRequestRemoteConfig)
设置当前 serverUrl
|
void |
setSessionIntervalTime(int sessionIntervalTime)
设置 App 切换到后台与下次事件的事件间隔
默认值为 30*1000 毫秒
若 App 在后台超过设定事件,则认为当前 Session 结束,发送 $AppEnd 事件
|
void |
setTrackEventCallBack(SensorsDataTrackEventCallBack trackEventCallBack)
设置 track 事件回调
|
void |
showUpWebView(android.webkit.WebView webView,
boolean isSupportJellyBean)
向 WebView 注入本地方法,默认不开启认证校验。
|
void |
showUpWebView(android.webkit.WebView webView,
boolean isSupportJellyBean,
boolean enableVerify)
向 WebView 注入本地方法
|
void |
showUpWebView(android.webkit.WebView webView,
boolean isSupportJellyBean,
org.json.JSONObject properties)
已过时。
|
void |
showUpWebView(android.webkit.WebView webView,
org.json.JSONObject properties,
boolean isSupportJellyBean,
boolean enableVerify)
已过时。
|
void |
showUpX5WebView(java.lang.Object x5WebView)
向腾讯 x5WebView 注入本地方法, 默认不开启认证校验。
|
void |
showUpX5WebView(java.lang.Object x5WebView,
boolean enableVerify)
向腾讯 x5WebView 注入本地方法
|
void |
showUpX5WebView(java.lang.Object x5WebView,
org.json.JSONObject properties,
boolean isSupportJellyBean,
boolean enableVerify)
已过时。
|
void |
startTrackThread()
开启事件采集
|
void |
stopTrackScreenOrientation()
暂停采集屏幕方向
|
void |
stopTrackThread()
停止事件采集,注意不要随便调用,调用后会造成数据丢失。
|
void |
track(java.lang.String eventName)
与
track(String, JSONObject) 类似,无事件属性 |
void |
track(java.lang.String eventName,
org.json.JSONObject properties) |
void |
trackDeepLinkLaunch(java.lang.String deepLinkUrl)
记录 $AppDeepLinkLaunch
trackDeepLinkLaunch(String, String) }事件 |
void |
trackDeepLinkLaunch(java.lang.String deepLinkUrl,
java.lang.String oaid)
记录 $AppDeepLinkLaunch 事件
|
void |
trackTimer(java.lang.String eventName,
java.util.concurrent.TimeUnit timeUnit)
已过时。
|
void |
trackTimerEnd(java.lang.String eventName)
停止事件计时器
|
void |
trackTimerEnd(java.lang.String eventName,
org.json.JSONObject properties)
停止事件计时器
|
void |
trackTimerPause(java.lang.String eventName)
暂停事件计时器,计时单位为秒。
|
void |
trackTimerResume(java.lang.String eventName)
恢复事件计时器,计时单位为秒。
|
java.lang.String |
trackTimerStart(java.lang.String eventName)
初始化事件的计时器,计时单位为秒。
|
void |
unregisterPropertyPlugin(SAPropertyPlugin plugin)
注销自定义插件
|
void |
unregisterSuperProperty(java.lang.String superPropertyName)
删除事件公共属性
|
bind, getIdentities, loginWithKey, loginWithKey, resetAnonymousIdentity, unbind
requestDeferredDeepLink, setDeepLinkCallback, setDeepLinkCompletion, trackAppInstall, trackAppInstall, trackAppInstall, trackChannelEvent, trackChannelEvent, trackInstallation, trackInstallation, trackInstallation
clearLastScreenUrl, clearReferrerWhenAppEnd, disableAutoTrack, disableAutoTrack, enableAutoTrack, getIgnoredViewTypeList, getLastScreenTrackProperties, getLastScreenUrl, ignoreAutoTrackActivities, ignoreAutoTrackActivity, ignoreView, ignoreView, ignoreViewType, isActivityAutoTrackAppClickIgnored, isActivityAutoTrackAppViewScreenIgnored, isAutoTrackEnabled, isAutoTrackEventTypeIgnored, isAutoTrackEventTypeIgnored, resumeAutoTrackActivities, resumeAutoTrackActivity, setViewActivity, setViewFragmentName, setViewID, setViewID, setViewID, setViewProperties, trackViewAppClick, trackViewAppClick, trackViewScreen, trackViewScreen, trackViewScreen
enableAutoTrackFragment, enableAutoTrackFragments, ignoreAutoTrackFragment, ignoreAutoTrackFragments, isFragmentAutoTrackAppViewScreen, isTrackFragmentAppViewScreenEnabled, resumeIgnoredAutoTrackFragment, resumeIgnoredAutoTrackFragments, trackFragmentAppViewScreen
addExposureView, removeExposureView, removeExposureView, setExposureIdentifier, updateExposureProperties
org.json.JSONObject getPresetProperties()
java.lang.String getServerUrl()
void setServerUrl(java.lang.String serverUrl)
serverUrl
- 当前 serverUrlvoid setServerUrl(java.lang.String serverUrl, boolean isRequestRemoteConfig)
serverUrl
- 当前 serverUrlisRequestRemoteConfig
- 是否立即请求当前 serverUrl 的远程配置void enableLog(boolean enable)
enable
- booleanlong getMaxCacheSize()
void setMaxCacheSize(long maxCacheSize)
maxCacheSize
- 单位 byteboolean isDebugMode()
boolean isNetworkRequestEnable()
void enableNetworkRequest(boolean isRequest)
isRequest
- booleanvoid setFlushNetworkPolicy(int networkType)
networkType
- int 网络类型int getFlushInterval()
void setFlushInterval(int flushInterval)
flushInterval
- 时间间隔,单位毫秒int getFlushBulkSize()
void setFlushBulkSize(int flushBulkSize)
flushBulkSize
- 缓存数目int getSessionIntervalTime()
void setSessionIntervalTime(int sessionIntervalTime)
sessionIntervalTime
- intvoid showUpWebView(android.webkit.WebView webView, boolean isSupportJellyBean)
webView
- 当前 WebViewisSupportJellyBean
- 是否支持 API level 16 及以下的版本。
因为 API level 16 及以下的版本, addJavascriptInterface 有安全漏洞,请谨慎使用void showUpWebView(android.webkit.WebView webView, boolean isSupportJellyBean, boolean enableVerify)
webView
- 当前 WebViewisSupportJellyBean
- 是否支持 API level 16 及以下的版本。enableVerify
- 是否开启认证
因为 API level 16 及以下的版本, addJavascriptInterface 有安全漏洞,请谨慎使用@Deprecated void showUpWebView(android.webkit.WebView webView, org.json.JSONObject properties, boolean isSupportJellyBean, boolean enableVerify)
webView
- 当前 WebViewproperties
- 属性isSupportJellyBean
- 是否支持 API level 16 及以下的版本。enableVerify
- 是否开启认证
因为 API level 16 及以下的版本, addJavascriptInterface 有安全漏洞,请谨慎使用。
此方法谨慎修改,插件配置 disableJsInterface 会修改此方法。@Deprecated void showUpWebView(android.webkit.WebView webView, boolean isSupportJellyBean, org.json.JSONObject properties)
webView
- 当前 WebViewisSupportJellyBean
- 是否支持 API level 16 及以下的版本。
因为 API level 16 及以下的版本, addJavascriptInterface 有安全漏洞,请谨慎使用properties
- 用户自定义属性@Deprecated void showUpX5WebView(java.lang.Object x5WebView, org.json.JSONObject properties, boolean isSupportJellyBean, boolean enableVerify)
x5WebView
- 腾讯 x5WebViewproperties
- 属性isSupportJellyBean
- 是否支持 API level 16 及以下的版本。enableVerify
- 是否开启认证
此方法谨慎修改,插件配置 disableJsInterface 会修改此方法。void showUpX5WebView(java.lang.Object x5WebView, boolean enableVerify)
x5WebView
- 腾讯 x5WebViewenableVerify
- 是否开启认证
此方法谨慎修改,插件配置 disableJsInterface 会修改此方法。void showUpX5WebView(java.lang.Object x5WebView)
x5WebView
- 腾讯 x5WebViewboolean isVisualizedAutoTrackActivity(java.lang.Class<?> activity)
activity
- activity 类的对象void addVisualizedAutoTrackActivity(java.lang.Class<?> activity)
activity
- activity 类的对象void addVisualizedAutoTrackActivities(java.util.List<java.lang.Class<?>> activitiesList)
activitiesList
- activity 类的对象集合boolean isVisualizedAutoTrackEnabled()
boolean isHeatMapActivity(java.lang.Class<?> activity)
activity
- activity 类的对象void addHeatMapActivity(java.lang.Class<?> activity)
activity
- activity 类的对象void addHeatMapActivities(java.util.List<java.lang.Class<?>> activitiesList)
activitiesList
- activity 类的对象集合boolean isHeatMapEnabled()
java.lang.String getDistinctId()
getDistinctId
在接口中 IUserIdentityAPI
java.lang.String getAnonymousId()
identify(String)
设置用户的匿名 ID,SDK 会优先调用 SensorsDataUtils#getAndroidID 获取 Android ID,
如获取的 Android ID 非法,则调用 UUID
随机生成 UUID,作为用户的匿名 IDgetAnonymousId
在接口中 IUserIdentityAPI
@Deprecated void resetAnonymousId()
resetAnonymousId
在接口中 IUserIdentityAPI
java.lang.String getLoginId()
login(String)
设置用户的 loginId,会返回 nullgetLoginId
在接口中 IUserIdentityAPI
void identify(java.lang.String distinctId)
identify
在接口中 IUserIdentityAPI
distinctId
- 当前用户的 distinctId,仅接受数字、下划线和大小写字母void login(java.lang.String loginId)
login
在接口中 IUserIdentityAPI
loginId
- 当前用户的 loginId,不能为空,且长度不能大于 255void login(java.lang.String loginId, org.json.JSONObject properties)
login
在接口中 IUserIdentityAPI
loginId
- 当前用户的 loginId,不能为空,且长度不能大于 255properties
- 用户登录属性void logout()
logout
在接口中 IUserIdentityAPI
void track(java.lang.String eventName, org.json.JSONObject properties)
void track(java.lang.String eventName)
track(String, JSONObject)
类似,无事件属性eventName
- 事件的名称@Deprecated void trackTimer(java.lang.String eventName, java.util.concurrent.TimeUnit timeUnit)
eventName
- 事件的名称timeUnit
- 计时结果的时间单位void removeTimer(java.lang.String eventName)
eventName
- 事件名称void trackTimerEnd(java.lang.String eventName, org.json.JSONObject properties)
eventName
- 事件的名称,或者交叉计算场景时 trackTimerStart 的返回值properties
- 事件的属性void trackTimerEnd(java.lang.String eventName)
eventName
- 事件的名称,或者交叉计算场景时 trackTimerStart 的返回值void clearTrackTimer()
void flush()
void flushSync()
void flushScheduled()
void registerDynamicSuperProperties(SensorsDataDynamicSuperProperties dynamicSuperProperties)
dynamicSuperProperties
- 事件动态公共属性回调接口void setTrackEventCallBack(SensorsDataTrackEventCallBack trackEventCallBack)
trackEventCallBack
- track 事件回调接口org.json.JSONObject getSuperProperties()
void registerSuperProperties(org.json.JSONObject superProperties)
superProperties
- 事件公共属性void unregisterSuperProperty(java.lang.String superPropertyName)
superPropertyName
- 事件属性名称void registerPropertyPlugin(SAPropertyPlugin plugin)
plugin
- 自定义插件void unregisterPropertyPlugin(SAPropertyPlugin plugin)
plugin
- 自定义插件void clearSuperProperties()
void profileSet(org.json.JSONObject properties)
properties
- 属性列表void profileSet(java.lang.String property, java.lang.Object value)
property
- 属性名称value
- 属性的值,值的类型只允许为
String
, Number
, Date
, Boolean
, JSONArray
void profileSetOnce(org.json.JSONObject properties)
properties
- 属性列表void profileSetOnce(java.lang.String property, java.lang.Object value)
property
- 属性名称value
- 属性的值,值的类型只允许为
String
, Number
, Date
, Boolean
, JSONArray
void profileIncrement(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
properties
- 一个或多个属性集合void profileIncrement(java.lang.String property, java.lang.Number value)
property
- 属性名称value
- 属性的值,值的类型只允许为 Number
void profileAppend(java.lang.String property, java.lang.String value)
property
- 属性名称value
- 新增的元素void profileAppend(java.lang.String property, java.util.Set<java.lang.String> values)
property
- 属性名称values
- 新增的元素集合void profileUnset(java.lang.String property)
property
- 属性名称void profileDelete()
void setGPSLocation(double latitude, double longitude)
latitude
- 纬度longitude
- 经度void setGPSLocation(double latitude, double longitude, java.lang.String coordinate)
latitude
- 纬度longitude
- 经度coordinate
- 坐标系,坐标系类型请参照 SensorsDataGPSLocation.CoordinateType
void clearGPSLocation()
void enableTrackScreenOrientation(boolean enable)
enable
- true:开启 false:关闭void resumeTrackScreenOrientation()
void stopTrackScreenOrientation()
java.lang.String getScreenOrientation()
java.lang.String trackTimerStart(java.lang.String eventName)
eventName
- 事件的名称void trackTimerPause(java.lang.String eventName)
eventName
- 事件的名称void trackTimerResume(java.lang.String eventName)
eventName
- 事件的名称void setCookie(java.lang.String cookie, boolean encode)
cookie
- String cookieencode
- boolean 是否 encodejava.lang.String getCookie(boolean decode)
decode
- Stringvoid deleteAll()
void profilePushId(java.lang.String pushTypeKey, java.lang.String pushId)
pushTypeKey
- 属性名称(例如 jgId)pushId
- 推送 ID
使用 profilePushId("jgId",JPushInterface.getRegistrationID(this))void profileUnsetPushId(java.lang.String pushTypeKey)
pushTypeKey
- 属性名称(例如 jgId)void itemSet(java.lang.String itemType, java.lang.String itemId, org.json.JSONObject properties)
itemType
- item 类型itemId
- item IDproperties
- item 相关属性void itemDelete(java.lang.String itemType, java.lang.String itemId)
itemType
- item 类型itemId
- item IDvoid stopTrackThread()
void startTrackThread()
void enableDeepLinkInstallSource(boolean enable)
enableDeepLinkInstallSource
在接口中 SAAdvertAPIProtocol
enable
- 是否开启采集设备信息void trackDeepLinkLaunch(java.lang.String deepLinkUrl)
trackDeepLinkLaunch(String, String)
}事件trackDeepLinkLaunch
在接口中 SAAdvertAPIProtocol
deepLinkUrl
- 唤起应用的 DeepLink 链接void trackDeepLinkLaunch(java.lang.String deepLinkUrl, java.lang.String oaid)
trackDeepLinkLaunch
在接口中 SAAdvertAPIProtocol
deepLinkUrl
- 唤起应用的 DeepLink 链接oaid
- oaidvoid registerLimitKeys(java.util.Map<java.lang.String,java.lang.String> limitKeys)
limitKeys
- 限制性属性 keyvoid enableRemoteConfig(boolean enable)
enable
- true 开启,false 不开启