Created
March 22, 2018 07:59
-
-
Save longbai/471af8cc52d64993966570bf9371caae to your computer and use it in GitHub Desktop.
Android Pandora SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
使用Android SDK 进行数据上报 | |
现在移动端越来越普及,大家都有自己的APP,想要把数据从终端上传上来进行分析。Pandora 有现成的SDK 提供使用。比如播放器的播放行为上报,App使用情况上报,等等。 | |
Panddora 上报SDK已经集成到存储SDK中,可以直接使用。 | |
代码地址在:https://github.com/qiniu/android-sdk/tree/master/library/src/main/java/com/qiniu/android/bigdata | |
接入步骤: | |
* 如果在Adroid Studio中使用,添加dependencies compile 'com.qiniu:qiniu-android-sdk:7.2.+' 或在项目中添加maven依赖 | |
* 在portal.qiniu.com 按照需要的字段创建好对应的工作流,记住repo名字,后面用到,具体操作详见 https://qiniu.github.io/pandora-docs/#/workflow | |
* 根据账号AK,SK 生成上报数据用的Token,也可以用 https://qiniu.github.io/pandora-docs/#/akutil 这里的工具生成 | |
* 参考样例代码 https://github.com/qiniu/android-sdk/blob/master/library/src/androidTest/java/com/qiniu/android/PipelineTest.java | |
``` | |
Map<String, Object> map = new HashMap<>(); | |
map.put("platform", "android"); | |
map.put("tl", 1L); | |
map.put("tf", 1.0); | |
map.put("tb", true); | |
map.put("td", new Date()); | |
Pipeline pipe = new Pipeline(null); | |
pipe.pump("testsdk", map, "token...", new Pipeline.PumpCompleteHandler() { | |
@Override | |
public void complete(ResponseInfo inf) { | |
} | |
}); | |
``` | |
可以直接上传对象,map。具体数值字段支持long,double,date,Bool, String, 嵌套json string. 可以一次上传单条或者多条数据。 | |
上传之后的数据查询可以直接在 https://qiniu.github.io/pandora-docs/#/logdb 直接进行查询, 也可以使用 https://qiniu.github.io/pandora-docs/#/keywordalert?id=grafana-%E7%9B%91%E6%8E%A7%E5%92%8C%E5%91%8A%E8%AD%A6 进行展示,监控和告警 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment