1 Star 1 Fork 0

vivi / PH-HcTrackSdk

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Tracker SDK 使用文档

修订记录

版本 时间 修订人 状态
Beta1.0 20210804 余双江 第一版本待测
Beta1.0 20210805 余双江 添加Header,混淆,注释,部分代码优化
Beta1.0 20210927 余双江 支持远程仓库
Beta1.0 20211018 余双江 更新版本

本地库集成步骤 不建议使用

1.将tracker 拷贝到项目工程目录

2.在settings.gradle中添加 include ':tracker'

3.将tracker module以Libiary方式引入

4.在项目或者module中添加 implementation project(':tracker')

远程仓库模式集成步骤 建议使用

1. implementation 'com.gitee.vivi2:PH-HcTrackSdk:v1.5-RC3'

2. allprojects {

	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

配置

在Application中初始化

 		//组装埋点请求需要的header
        var headerMap = mapOf(
            "app-version" to AppConfig.getInstance().appVersion.orEmpty(),
            "lang" to AppConfig.getInstance().appLanguage.orEmpty(),
            "organizationId" to Constant.ORGANIZATIONID,
            "commercialId" to Constant.COMMERCIALID,
            "app-name" to Constant.APP_NAME,
            "channel" to AppConfig.getInstance().appChannel.orEmpty(),
            "token" to AppConfig.getInstance().appToken.orEmpty()
        )
        //埋点配置 初始化
        val configuration: TrackConfiguration = TrackConfiguration()
            .enableLog(true)//log开关
            .setDevice(TrackDevice(DeviceUtil.getAndroidId(this).orEmpty(), DeviceUtil.getPhoneModel().orEmpty(), DeviceUtil.getIMEI(this).orEmpty()))//请求参数需要的设备信息
            .setHeaderMap(headerMap)//配置header
            .setUploadCategory(TrackerUploadStrategy.NOW) //上传策略 实时上传
            .setServerUrl("http://192.168.122.215:9010/hc/app/noAuth/param/submitBuryingPoint") //上传接口地址
        Tracker.getInstance().init(this, configuration)

使用

1.普通事件埋点

以下示例表示新增一条登录页面的埋点(枚举类型和值都可以自定义)

        Tracker.getInstance().track(TrackParamsEntity(PageEmum.LOGIN, EventEmum.LOGIN))//带有页面code和事件code的埋点
		Tracker.getInstance().track(TrackParamsEntity(PageEmum.LOGIN, EventEmum.LOGIN),@optional String "remark")//带有页面code,事件code,和标记的埋点

2.埋点统计文本输入时长

需要使你的EditText继承TrackTimeEditText

		//输入手机号码时长的埋点
		editText.addFocusTrackListener(TrackParamsEntity(PageEmum.LOGIN, EventEmum.LOGIN_INPUT_TEL))
		//输入手机号码时长和输入内容的埋点
		editText.addFocusAndTextTrackListener(TrackParamsEntity(PageEmum.LOGIN, EventEmum.LOGIN_INPUT_TEL))

TrackConfiguration 配置说明

enableLog :Log开关

请求接口:{"androidId":"fbcc18d4fd306ee9", "deviceModel":"PCLM10", "imei":"", "buryingPointCode":"2040", "eventTime":"0", "pageCode":"2000", "remark":"6500"}

setDevice :设置设备信息

setUploadCategory :上传策略(及时上传,定时上传,下一次启动时上传)

setServerUrl:POST提交接口地址

setMinutes :定时上传埋点时间间隔(分钟)

混淆

		-keep class  com.ph.clouds.tracker.emun.**{ *;}
		-keep class  com.ph.clouds.tracker.entity.**{ *;}

Repository Comments ( 0 )

Sign in for post a comment

About

PH-HcTrackSdk expand collapse
Java
Apache-2.0
Cancel

Releases (7)

All

Contributors

All

Activities

Load More
can not load any more
1
https://gitee.com/vivi2/PH-HcTrackSdk.git
git@gitee.com:vivi2/PH-HcTrackSdk.git
vivi2
PH-HcTrackSdk
PH-HcTrackSdk
master

Search