60 lines
1.9 KiB
Markdown
60 lines
1.9 KiB
Markdown
Room 数据持久化;Worker管理上传任务,初次上传+重试共5次,重试间隔10s线性增加;多上传任务顺序处理;
|
||
网络请求 Retrofit
|
||
### aar位置
|
||
根目录 /aar/xxx/trackingPoint-xxx-x.x.x.aar
|
||
### debug release 区别
|
||
| BuildType | 域名 | 是否打印日志 |
|
||
|----------|------|--------------|
|
||
| debug | http://192.168.2.7:18828 | 是 |
|
||
| release | https://track.23544.com | 否 |
|
||
### 使用
|
||
```groovy
|
||
/**
|
||
* 因为是本地引入AAR 所以需要手动导入下列必备依赖 版本可根据项目调整
|
||
*/
|
||
implementation("com.squareup.retrofit2:retrofit:3.0.0")
|
||
implementation("com.squareup.retrofit2:converter-moshi:3.0.0")
|
||
implementation("com.squareup.okhttp3:logging-interceptor:5.3.2")
|
||
implementation("com.squareup.moshi:moshi:1.15.2")
|
||
implementation("androidx.work:work-runtime-ktx:2.11.0")
|
||
implementation("androidx.room:room-runtime:2.8.4")
|
||
implementation("androidx.room:room-ktx:2.8.4")
|
||
```
|
||
```kotlin
|
||
/**
|
||
* 初始化
|
||
*/
|
||
TrackingManager.init(
|
||
context = this.applicationContext,
|
||
uploadIntervalMillis = 10.seconds.inWholeMilliseconds, //收集埋点时长
|
||
iTrackingPointUserInfo = TrackingPointUserInfoImp(),
|
||
systemCode = "999999999", //通过管理平台获取
|
||
)
|
||
|
||
/**
|
||
* 实现 ITrackingPointUserInfo 获取 UserInfo 的方法
|
||
*/
|
||
class TrackingPointUserInfoImp: ITrackingPointUserInfo {
|
||
override fun uploadUserInfo(): UserInfo? {
|
||
return UserInfo(
|
||
userId = 123456,
|
||
userName = "username",
|
||
account = "account"
|
||
) or null
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 接口文档 http://192.168.2.7:18828/swagger/index.html?urls.primaryName=%E6%95%B0%E6%8D%AE%E5%9F%8B%E7%82%B9%E5%92%8Capi%E6%97%A5%E5%BF%97
|
||
* api : api/ExternalEventlogs/AddEventListLog
|
||
*/
|
||
TrackingManager.push(
|
||
eventType = "dianji", //通过管理平台获取
|
||
eventParams = EventParams(
|
||
buttonId = "${view.id}",
|
||
page = "Main",
|
||
url = ""
|
||
)
|
||
)
|
||
```
|