Skip to content

用户错误报告服务端实现

Kaid Wong edited this page Feb 17, 2014 · 16 revisions

HTTP API

关于获取手机信息参考 http://www.cnblogs.com/mainroadlee/archive/2011/01/09/Get_Phone_Number_Model_SDKVersion_Information_in_Android_SDK.html

  API名称: 程序异常的提交
  使用范围: 被移动客户端调用

  请求:
    url: /api/sbmit_exception
    请求类型: POST
    参数:
      version: x.x.x # 当前客户端软件版本号
      datetime: 1392621238074 # 时间戳信息
      # 时间戳信息相当于ruby里的 Time.now.to_i 
      # java 里面获取时间戳的方式可以参考 http://yunnick.iteye.com/blog/1074495
      user_id:  xx  # 服务端 users 表的 id
      device_name: xx  # 对应API Build.MODEL
      sdk_version: xx  # 对应API Build.VERSION.SDK
      os_release_version: xx # 对应API Build.VERSION.RELEASE
      other_device_info: json_str # 对应API Build 类的其他常量
      exception_type: xx # 抛出异常的类的完整包名和类名
      exception_stack: xx # 抛出异常的完整堆栈信息

  后台处理:
    记录传递过来的数据到 mongodb 的数据表

  响应:
    HTTP status:200
    空字符串
  API名称: 用户反馈的提交
  使用范围: 被移动客户端调用

  请求:
    url: /api/sbmit_feedback
    请求类型: POST
    参数:
      version: x.x.x # 当前客户端软件版本号
      datetime: 1392621050 # Time.now.to_i
      user_id:  xx  
      device_name: xx  # 对应API Build.MODEL
      sdk_version: xx  # 对应API Build.VERSION.SDK
      os_release_version: xx # 对应API Build.VERSION.RELEASE
      other_device_info: json_str # 对应API Build 类的其他常量
      feedback: 用户反馈内容

  后台处理:
    记录传递过来的数据到 mongodb 的数据表

  响应:
    HTTP status:200
    空字符串

服务端模型设计

移动端异常信息模型

class MobileFeedback
  include Mongoid::Document
  include Mongoid::Timestamps

  field :version,            :type => String
  field :datetime,           :type => DateTime
  field :user_id,            :type => Integer
  field :device_name,        :type => String
  field :sdk_version,        :type => String
  field :os_release_version, :type => String
  field :other_device_info,  :type => Hash

  # 用来记录反馈类型, 若为feedback, 只记录下列feedback字段
  # 为exception, 则记录exception_type和exception_stack字段
  field :kind,               :type => String

  field :exception_type,     :type => String
  field :exception_stack,    :type => String
  field :feedback,           :type => String
end
Clone this wiki locally