安卓埋点SDK
Go to file
tiananlin ca12b2a522 更新 Dockerfile 2025-12-18 17:21:17 +08:00
app feat: 自动化发布到Maven 2025-12-11 17:25:51 +08:00
gradle feat: 更新AGP 2025-12-12 15:29:10 +08:00
library fix: 处理部分设备启动上传任务异常 2025-12-16 14:39:41 +08:00
.gitignore feat: 埋点数据收集SDK 2025-12-09 15:09:16 +08:00
Dockerfile 更新 Dockerfile 2025-12-18 17:21:17 +08:00
Readme.md fix: 处理部分设备启动上传任务异常 2025-12-16 14:39:41 +08:00
build.gradle.kts feat: 埋点数据收集SDK 2025-12-09 15:09:16 +08:00
gradle.properties feat: 自动化发布到Maven 2025-12-12 11:55:34 +08:00
gradlew feat: 埋点数据收集SDK 2025-12-09 15:09:16 +08:00
gradlew.bat feat: 埋点数据收集SDK 2025-12-09 15:09:16 +08:00
settings.gradle.kts feat: 切换阿里源 2025-12-15 15:29:58 +08:00
test.jks feat: 埋点数据收集SDK 2025-12-09 15:09:16 +08:00

Readme.md

Room 数据持久化Worker管理上传任务初次上传+重试共5次重试间隔10s线性增加多上传任务顺序处理 网络请求 Retrofit

debug release 区别

BuildType 域名 是否打印日志 HttpLoggingInterceptor依赖
debug http://192.168.2.7:18828
release https://track.23544.com

使用

1.0.14

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")
/**
 * 初始化
 */
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 = ""
    )
)

常见问题

// 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")
}