yx_tracking_point_android/Readme.md

94 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Room 数据持久化Worker管理上传任务初次上传+重试共5次重试间隔10s线性增加多上传任务顺序处理
网络请求 Retrofit
### debug release 区别
| BuildType | 域名 | 是否打印日志 | HttpLoggingInterceptor依赖 |
|-----------|--------------------------|--------|--------------------------|
| debug | http://192.168.2.7:18828 | 是 | 有 |
| release | https://track.23544.com | 否 | 无 |
### 使用
#### 1.0.14
```kotlin
repositories {
google()
mavenCentral()
maven {
url = uri("https://nexus.23544.com/repository/maven-releases/")
isAllowInsecureProtocol = true
credentials {
username = "admin"
password = "j7EgYb2ejMCt5aYw"
}
}
maven {
url = uri("https://nexus.23544.com/repository/maven-snapshots/")
isAllowInsecureProtocol = true
credentials {
username = "admin"
password = "j7EgYb2ejMCt5aYw"
}
}
}
//测试环境
debugImplementation("com.yuanxuan:tracking_point:x.x.x-SNAPSHOT")
//生产环境
releaseImplementation("com.yuanxuan:tracking_point:x.x.x")
```
```kotlin
/**
* 初始化
*/
TrackingManager.init(
context = this.application,
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 = "R.id.xxxxx", //最好传控件的 R.id.xxx 方便找到此控件
page = "Main",
url = ""
)
)
```
### 常见问题
```kotlin
// aar中 使用 `retrofit:3.0.0` `okhttp:5.3.2` 如果你的项目使用的 `okhttp:4.x` 或更久的版本
implementation("com.squareup.okhttp3:okhttp:4.12.0")
debugImplementation("com.yuanxuan:tracking_point:1.0.13-SNAPSHOT") {
// 排除掉aar中的 okhttp 相关依赖
exclude(group = "com.squareup.okhttp3")
}
// 因为这是测试版的aar 还需要添加拦截器
debugImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
// release版 就只需要排除掉okhttp
implementation("com.yuanxuan:tracking_point:1.0.13") {
exclude(group = "com.squareup.okhttp3", module = "okhttp")
}
```