navicat数据库管理工具对游戏激活用户和付费用户的统计管理
来源:互联网 发布:淘宝好的精品店 编辑:程序博客网 时间:2024/06/15 02:18
为什么要写这篇文章呢?这是因为有时候游戏发布之后,运营那边如果数据出现异常的话来问咱们技术的话,咱就拿数据说话哈......不然,运营只会把责任推给咱们技术了 唉!
好了,进入正题:
Java端代码:
public class StatisticsLog{ //private static final String path = "http://192.168.254.76:8080/gm/log"; private static final String SERVER_PATH = "http://42.96.170.133:10017/fishLog/log";//数据库服务器地址 private static final StatisticsLog instance = new StatisticsLog(); public static StatisticsLog getInstance(){ return instance; } public long firstBeginTime = 0; public long beginTime; public List<NameValuePair> staticInfo = new ArrayList<NameValuePair>(); public static final String RUNTIME_RECORD_NAME = "runInfo.data";//当游戏在用户手机运行(激活时),会产生的文件 public static final String FIRST_BEGIN_TIME_KEY = "firstTime";//定义开始游戏时间 public void buildLogInfo(Context activity, String curOperator){ beginTime = System.currentTimeMillis(); InputStream is = CommonFunc.readFileFromNativePlace(activity, RUNTIME_RECORD_NAME);//读取开始游戏的KEY Properties properties = new Properties(); //如果开始游戏不为空或者时间不为0,直接取 if(null != is){ try{ properties.load(is); Object firstTime = properties.get(FIRST_BEGIN_TIME_KEY); if(null != firstTime){ firstBeginTime = Long.parseLong((String) firstTime); } }catch(IOException e){ e.printStackTrace(); } } if(0 == firstBeginTime){ firstBeginTime = beginTime; properties.put(FIRST_BEGIN_TIME_KEY, Long.toString(firstBeginTime)); OutputStream os = CommonFunc.getNativeFileOutputStream(activity, RUNTIME_RECORD_NAME); if(null != os){ properties.save(os, ""); } } staticInfo.add(new BasicNameValuePair("fbt", Long.toString(firstBeginTime)));//添加字段key:首次启动客户端时间 staticInfo.add(new BasicNameValuePair("bt", Long.toString(beginTime)));//客户端启动时间 staticInfo.add(new BasicNameValuePair("ver", PhoneUtils.getAppVersionName(activity)));//版本号 staticInfo.add(new BasicNameValuePair("ch", Channel.getSonChannelID(activity)));//渠道号 staticInfo.add(new BasicNameValuePair("pt", android.os.Build.MODEL));//机型 staticInfo.add(new BasicNameValuePair("aVer", android.os.Build.VERSION.RELEASE)); String key = PhoneUtils.getIMEI(activity); if(null == key || key.length() <= 0){ WifiManager wifiMgr = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE); WifiInfo info = (null == wifiMgr ? null : wifiMgr.getConnectionInfo()); if(null != info){ key = info.getMacAddress(); }else{ key = "unkown"; } } staticInfo.add(new BasicNameValuePair("key", key));//imei/mac staticInfo.add(new BasicNameValuePair("imsi", PhoneUtils.getIMSI(activity)));//IMSI staticInfo.add(new BasicNameValuePair("operatorName", null == curOperator? "" : curOperator)); } //发送打印日志 public void sendSelfLog(String tag){ try { HttpPost httpRequest = new HttpPost(SERVER_PATH); // Post运作传送变数必须用NameValuePair[]阵列储存 // 传参数 服务端获取的方法为request.getParameter("name") List<NameValuePair> params = new ArrayList<NameValuePair>(staticInfo); params.add(new BasicNameValuePair("ct", Long.toString(System.currentTimeMillis()))); params.add(new BasicNameValuePair("tag", tag)); // 发出HTTP request httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); // 取得HTTP response HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest); // 若状态码为200 ok if(httpResponse.getStatusLine().getStatusCode() == 200){ // 取出回应字串 // String // strResult=EntityUtils.toString(httpResponse.getEntity()); }else{ // textView1.setText("Error Response"+httpResponse.getStatusLine().toString()); } } catch (Exception e) { e.printStackTrace(); } }}
代码中有2处一处是从文件读取字段:
public static InputStream readFileFromNativePlace(Context activity, String name){ try{ File file = activity.getFileStreamPath(name); if(file.exists()){ return activity.openFileInput(name); } return null; }catch(FileNotFoundException e){ e.printStackTrace(); return null; } }
还有一处是从文件得到字段:
public static OutputStream getNativeFileOutputStream(Context activity, String name){ try{ return activity.openFileOutput(name, Context.MODE_PRIVATE); }catch(FileNotFoundException e){ e.printStackTrace(); return null; } }定义一个静态的方法,以便供C++调用:
public static void sendLog(String tag){ StatisticsLog.getInstance().sendSelfLog(tag); }
Java这边如何使用呢,看代码:
StatisticsLog.getInstance().buildLogInfo(this, Channel.curOperator);StatisticsLog.getInstance().sendSelfLog("begin");sendLog("created");
C++端代码:
void MyGame::sendTestLog(const char* tag){#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "skt/board/fish/Fish", "sendLog", "(Ljava/lang/String;)V")) { CCLog("jni:have sendLog"); jstring stringArg1 = t.env->NewStringUTF(tag); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(t.classID); }else{ CCLog("jni:not have sendLog"); }#endif}
里面的参数就别不多说了,不懂的看我以前的文章,Cocos2d-x利用jni调用java层代码
使用方法和java一样,在需要记录的地方调用方法就行,比如需要在启动游戏记录,找到位置,直接调用方法
MyGame::getInstance()->sendTestLog("begin");
![](file:///C:\Users\admin\AppData\Roaming\Tencent\Users\1420877091\QQ\WinTemp\RichOle\JWC[W%K(6YUN5Z2V0DMV4$O.jpg)
![](file:///C:\Users\admin\AppData\Roaming\Tencent\Users\1420877091\QQ\WinTemp\RichOle\JWC[W%K(6YUN5Z2V0DMV4$O.jpg)
打开自己的目录界面显示如下:
看到了吗 自己的定义的字段以及手机类型,这样就容易找出运营异常的情况了,比如付费转换率和用户激活率的问题
0 0
- navicat数据库管理工具对游戏激活用户和付费用户的统计管理
- Navicat for MySQL 连接数据库、管理用户、创建数据库和表
- oracle对用户和权限的管理
- oracle命令 建立用户和对用户的管理
- 为什么付费用户才是“最好”的用户
- 数据库管理工具Navicat的安装
- oracle对用户的管理
- 电子书只让用户付费 只对用户负责
- 对数据库管理员和数据库用户的认识
- 用户管理的复制数据库
- Oracle数据库的用户管理
- 用户的邮件激活
- qmail邮件系统(五)vpopmail和qmailadmin对用户的管理
- Linux管理用户帐户和控制对文件的访问
- Linux用户最喜欢的9款数据库管理工具!
- 使用Navicat Premium对mssql2008r2授权用户
- 刺激用户付费的6种手段
- 支持多种数据库的管理工具:navicat premium
- linux下更改系统默认语言
- App Validation on Xcode 6 GM release
- mysql子查询
- 英语学习
- ListView的几种优化方式
- navicat数据库管理工具对游戏激活用户和付费用户的统计管理
- Ajax发送GET请求
- 消息队列技术终结者(一)—通俗深刻地认识JMS(即Java Message Service)
- 从学生到社会人士的转变
- ZooKeeper应用场景-分布式锁设计
- 一些功能函数使用(收集中)
- Linux内核与SMP(对称多处理)
- 向 AppStore iOS 苹果appstore 提交新版本app出现问题
- SQL语句操作ALTER