02.友盟项目--原始日志数据生成

Posted star521

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了02.友盟项目--原始日志数据生成相关的知识,希望对你有一定的参考价值。

 友盟架构图1

技术分享图片

 友盟架构图2

技术分享图片

 

 

日志生成类

技术分享图片

 

技术分享图片
package com.star.umeng.phone.domain;

/**
 * App日志的公共属性
 */
public class AppBaseLog {
    private Long createdAtMs;           //日志创建时间
    private String appId;               //应用唯一标识
    private String tenantId;            //租户唯一标识,企业用户
    private String deviceId;            //设备唯一标识
    private String appVersion;          //版本
    private String appChannel;          //渠道,安装时就在清单中制定了,appStore等。
    private String appPlatform;         //平台
    private String osType;              //操作系统
    private String deviceStyle;         //机型

    public Long getCreatedAtMs() {
        return createdAtMs;
    }

    public void setCreatedAtMs(Long createdAtMs) {
        this.createdAtMs = createdAtMs;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public void setAppVersion(String appVersion) {
        this.appVersion = appVersion;
    }

    public String getAppChannel() {
        return appChannel;
    }

    public void setAppChannel(String appChannel) {
        this.appChannel = appChannel;
    }

    public String getAppPlatform() {
        return appPlatform;
    }

    public void setAppPlatform(String appPlatform) {
        this.appPlatform = appPlatform;
    }

    public String getOsType() {
        return osType;
    }

    public void setOsType(String osType) {
        this.osType = osType;
    }

    public String getDeviceStyle() {
        return deviceStyle;
    }

    public void setDeviceStyle(String deviceStyle) {
        this.deviceStyle = deviceStyle;
    }
}
AppBaseLog-App日志的公共属性
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 错误日志
 */
public class AppErrorLog extends AppBaseLog {
    private String errorBrief;        //错误摘要
    private String errorDetail;       //错误详情

    public String getErrorBrief() {
        return errorBrief;
    }

    public void setErrorBrief(String errorBrief) {
        this.errorBrief = errorBrief;
    }

    public String getErrorDetail() {
        return errorDetail;
    }

    public void setErrorDetail(String errorDetail) {
        this.errorDetail = errorDetail;
    }
}
AppErrorLog-错误日志
技术分享图片
package com.star.umeng.phone.domain;

import java.util.Map;

/**
 * 事件日志
 */
public class AppEventLog extends AppBaseLog {
    private String eventId;                                //事件唯一标识
    private Long eventDurationSecs;                        //事件持续时长
    private Map<String, String> paramKeyValueMap;        //参数名/值对

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public Long getEventDurationSecs() {
        return eventDurationSecs;
    }

    public void setEventDurationSecs(Long eventDurationSecs) {
        this.eventDurationSecs = eventDurationSecs;
    }

    public Map<String, String> getParamKeyValueMap() {
        return paramKeyValueMap;
    }

    public void setParamKeyValueMap(Map<String, String> paramKeyValueMap) {
        this.paramKeyValueMap = paramKeyValueMap;
    }
    //getter/setter
}
AppEventLog-事件日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 页面日志
 */
public class AppPageLog extends AppBaseLog {
    private int pageViewCntInSession = 0;
    private String pageId;                        //页面id
    private int visitIndex = 0;                    //访问顺序号,0为第一个页面
    private String nextPage;                    //下一个访问页面,空表示为退出应用的页面
    private Long stayDurationSecs = (long) 0;     //当前页面停留时长

    public int getPageViewCntInSession() {
        return pageViewCntInSession;
    }

    public void setPageViewCntInSession(int pageViewCntInSession) {
        this.pageViewCntInSession = pageViewCntInSession;
    }

    public String getPageId() {
        return pageId;
    }

    public void setPageId(String pageId) {
        this.pageId = pageId;
    }

    public int getVisitIndex() {
        return visitIndex;
    }

    public void setVisitIndex(int visitIndex) {
        this.visitIndex = visitIndex;
    }

    public String getNextPage() {
        return nextPage;
    }

    public void setNextPage(String nextPage) {
        this.nextPage = nextPage;
    }

    public Long getStayDurationSecs() {
        return stayDurationSecs;
    }

    public void setStayDurationSecs(Long stayDurationSecs) {
        this.stayDurationSecs = stayDurationSecs;
    }
}
AppPageLog --页面日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 启动日志
 */
public class AppStartupLog extends AppBaseLog {
    private String country;           //国家,终端不用上报,服务器自动填充该属性
    private String province;          //省份,终端不用上报,服务器自动填充该属性
    private String ipAddress;         //ip地址

    private String network;           //网络
    private String carrier;           //运营商

    private String brand;             //品牌
    private String screenSize;        //分辨率

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getNetwork() {
        return network;
    }

    public void setNetwork(String network) {
        this.network = network;
    }

    public String getCarrier() {
        return carrier;
    }

    public void setCarrier(String carrier) {
        this.carrier = carrier;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getScreenSize() {
        return screenSize;
    }

    public void setScreenSize(String screenSize) {
        this.screenSize = screenSize;
    }
}
AppStartupLog --启动日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 使用日志
 */
public class AppUsageLog extends AppBaseLog {
    private Long singleUseDurationSecs;      //单次使用时长
    private Long singleUploadTraffic;        //单次使用过程中的上传流量
    private Long singleDownloadTraffic;      //单次使用过程中的下载流量

    public Long getSingleUseDurationSecs() {
        return singleUseDurationSecs;
    }

    public void setSingleUseDurationSecs(Long singleUseDurationSecs) {
        this.singleUseDurationSecs = singleUseDurationSecs;
    }

    public Long getSingleUploadTraffic() {
        return singleUploadTraffic;
    }

    public void setSingleUploadTraffic(Long singleUploadTraffic) {
        this.singleUploadTraffic = singleUploadTraffic;
    }

    public Long getSingleDownloadTraffic() {
        return singleDownloadTraffic;
    }

    public void setSingleDownloadTraffic(Long singleDownloadTraffic) {
        this.singleDownloadTraffic = singleDownloadTraffic;
    }
}
AppUsageLog --使用日志
技术分享图片
package com.star.umeng.phone.domain;


import java.util.ArrayList;
import java.util.List;

/**
 * 日志聚合体
 */
public class AppLogAggEntity {
    private String appId;               //应用唯一标识
    private String tenantId;            //租户唯一标识,企业用户
    private String deviceId;            //设备唯一标识
    private String appVersion;          //版本
    private String appChannel;          //渠道,安装时就在清单中制定了,appStore等。
    private String appPlatform;         //平台
    private String osType;              //操作系统
    private String deviceStyle;         //机型

    //5中类型的日志集合
    private List<AppStartupLog> startupLogs = new ArrayList<AppStartupLog>();
    private List<AppErrorLog> errorLogs = new ArrayList<AppErrorLog>();
    private List<AppEventLog> eventLogs = new ArrayList<AppEventLog>();
    private List<AppUsageLog> usageLogs = new ArrayList<AppUsageLog>();
    private List<AppPageLog> pageLogs = new ArrayList<AppPageLog>();

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public void setAppVersion(String appVersion) {
        this.appVersion = appVersion;
    }

    public String getAppChannel() {
        return appChannel;
    }

    public void setAppChannel(String appChannel) {
        this.appChannel = appChannel;
    }

    public String getAppPlatform() {
        return appPlatform;
    }

    public void setAppPlatform(String appPlatform) {
        this.appPlatform = appPlatform;
    }

    public String getOsType() {
        return osType;
    }

    public void setOsType(String osType) {
        this.osType = osType;
    }

    public String getDeviceStyle() {
        return deviceStyle;
    }

    public void setDeviceStyle(String deviceStyle) {
        this.deviceStyle = deviceStyle;
    }

    public List<AppStartupLog> getStartupLogs() {
        return startupLogs;
    }

    public void setStartupLogs(List<AppStartupLog> startupLogs) {
        this.startupLogs = startupLogs;
    }

    public List<AppErrorLog> getErrorLogs() {
        return errorLogs;
    }

    public void setErrorLogs(List<AppErrorLog> errorLogs) {
        this.errorLogs = errorLogs;
    }

    public List<AppEventLog> getEventLogs() {
        return eventLogs;
    }

    public void setEventLogs(List<AppEventLog> eventLogs) {
        this.eventLogs = eventLogs;
    }

    public List<AppUsageLog> getUsageLogs() {
        return usageLogs;
    }

    public void setUsageLogs(List<AppUsageLog> usageLogs) {
        this.usageLogs = usageLogs;
    }

    public List<AppPageLog> getPageLogs() {
        return pageLogs;
    }

    public void setPageLogs(List<AppPageLog> pageLogs) {
        this.pageLogs = pageLogs;
    }
}
AppLogAggEntity-- 日志聚合体

 

 

测试生成

技术分享图片
package com.star.umeng.phone;

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * 入口点程序
 */
public class Main {
    public static void main(String[] args) throws Exception {
        String strURL = "http://localhost/1.html" ;
        URL url = new URL(strURL) ;
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        //设置请求方式
        conn.setRequestMethod("POST");
        //设置发送的内容类型
        conn.setRequestProperty("Content-Type" , "application/json");
        //允许输出到服务器
        conn.setDoOutput(true);
        OutputStream out = conn.getOutputStream() ;

        String json = "{
" + "  "appChannel": "anroid bus",
" + "  "appId": "sohuvideo",
" + "  "appPlatform": "ios",
" + "  "appVersion": "1.1.0",
" + "  "deviceStyle": "oppo 1",
" + "  "errorLogs": [
" + "    {
" + "      "appChannel": "umeng",
" + "      "appId": "gaodemap",
" + "      "appPlatform": "blackberry",
" + "      "appVersion": "1.1.0",
" + "      "deviceStyle": "vivo 3",
" + "      "errorBrief": "at cn.lift.dfdf.web.AbstractBaseController.validInbound(AbstractBaseController.java:72)",
" + "      "errorDetail": "at cn.lift.dfdfdf.control.CommandUtil.getInfo(CommandUtil.java:67) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606)",
" + "      "osType": "android 4.0",
" + "      "tenantId": "tnt023"
" + "    }
" + "  ],
" + "  "eventLogs": [
" + "    {
" + "      "appChannel": "anroid bus",
" + "      "appId": "tianya",
" + "      "appPlatform": "android",
" + "      "appVersion": "2.0.0",
" + "      "deviceStyle": "红米",
" + "      "eventId": "popmenu",
" + "      "osType": "ios11",
" + "      "tenantId": "tnt009"
" + "    },
" + "    {
" + "      "appChannel": "appstore",
" + "      "appId": "gaodemap",
" + "      "appPlatform": "android",
" + "      "appVersion": "1.1.0",
" + "      "deviceStyle": "iphone 7 plus",
" + "      "eventId": "popmenu",
" + "      "osType": "android 4.0",
" + "      "tenantId": "tnt009"
" + "    },
" + "    {
" + "      "appChannel": "appstore",
" + "      "appId": "faobengplay",
" + "      "appPlatform": "blackberry",
" + "      "appVersion": "1.0.0",
" + "      "deviceStyle": "vivo 3",
" + "      "eventId": "autoImport",
" + "      "osType": "ios11",
" + "      "tenantId": "tnt009"
" + "    },
" + "    {
" + "      "appChannel": "anroid bus",
" + "      "appId": "tianya",
" + "      "appPlatform": "blackberry",
" + "      "appVersion": "1.1.0",
" + "      "deviceStyle": "iphone 7 plus",
" + "      "eventId": "popmenu",
" + "      "osType": "mi 5.5",
" + "      "tenantId": "tnt009"
" + "    },
" + "    {
" + "      "appChannel": "anroid bus",
" + "      "appId": "tianya",
" + "      "appPlatform": "android",
" + "      "appVersion": "1.2.0",
" + "      "deviceStyle": "iphone 7",
" + "      "eventId": "bookstore",
" + "      "osType": "ios11",
" + "      "tenantId": "tnt501"
" + "    }
" + "  ],
" + "  "osType": "ios11",
" + "  "pageLogs": [
" + "    null,
" + "    null,
" + "    null,
" + "    null,
" + "    null
" + "  ],
" + "  "startupLogs": [
" + "    {
" + "      "appChannel": "anroid bus",
" + "      "appId": "faobengplay",
" + "      "appPlatform": "ios",
" + "      "appVersion": "1.2.0",
" + "      "brand": "魅族",
" + "      "carrier": "中国铁通",
" + "      "country": "america",
" + "      "deviceStyle": "vivo 3",
" + "      "network": "wifi",
" + "      "osType": "android 4.0",
" + "      "province": "guangdong",
" + "      "screenSize": "480 * 320",
" + "      "tenantId": "tnt501"
" + "    },
" + "    {
" + "      "appChannel": "appstore",
" + "      "appId": "sohuvideo",
" + "      "appPlatform": "blackberry",
" + "      "appVersion": "2.0.0",
" + "      "brand": "Apple",
" + "      "carrier": "中国铁通",
" + "      "country": "china",
" + "      "deviceStyle": "iphone 7",
" + "      "network": "3g",
" + "      "osType": "ios11",
" + "      "province": "guangxi",
" + "      "screenSize": "1136 * 640",
" + "      "tenantId": "tnt501"
" + "    }
" + "  ],
" + "  "tenantId": "tnt009",
" + "  "usageLogs": [
" + "    {
" + "      "appChannel": "umeng",
" + "      "appId": "gaodemap",
" + "      "appPlatform": "winphone",
" + "      "appVersion": "1.1.0",
" + "      "deviceStyle": "iphone 7",
" + "      "osType": "ios11",
" + "      "tenantId": "tnt009"
" + "    },
" + "    {
" + "      "appChannel": "anroid bus",
" + "      "appId": "tianya",
" + "      "appPlatform": "android",
" + "      "appVersion": "1.2.0",
" + "      "deviceStyle": "iphone 6",
" + "      "osType": "android 4.0",
" + "      "tenantId": "tnt501"
" + "    },
" + "    {
" + "      "appChannel": "umeng",
" + "      "appId": "tianya",
" + "      "appPlatform": "winphone",
" + "      "appVersion": "1.0.0",
" + "      "deviceStyle": "vivo 3",
" + "      "osType": "mi 5.5",
" + "      "tenantId": "tnt023"
" + "    },
" + "    {
" + "      "appChannel": "umeng",
" + "      "appId": "sohuvideo",
" + "      "appPlatform": "android",
" + "      "appVersion": "1.0.0",
" + "      "deviceStyle": "iphone 6 plus",
" + "      "osType": "mi 5.5",
" + "      "tenantId": "tnt023"
" + "    }
" + "  ]
" + "}" ;
        out.write(json.getBytes());
        out.flush();
        out.close();
        int code = conn.getResponseCode() ;
        if(code == 200){
            System.out.println("发送ok!!");
        }
    }
}
测试代码-生成数据

s102--s104查看生成的数据

技术分享图片

 

以上是关于02.友盟项目--原始日志数据生成的主要内容,如果未能解决你的问题,请参考以下文章

友盟SDK升级记录

itools工具+友盟测试推送消息到APP

android bug笔记

在通知单击时将项目添加到片段内的 recyclerview

友盟埋点安卓技术点

EntityFramework 映射片段问题