# MiniReportManager.report(Object param)

基础库 3.8.12 开始支持,低版本需做兼容处理

Promise 风格 调用:不支持

微信 Windows 版:支持

微信 Mac 版:支持

# 功能描述

上报关卡日志。report 方法支持在上报时传入关卡事件 ID、关卡 ID、关卡名称、关卡行为、关卡结果、关卡耗时、关卡道具、关卡广告、关卡分享。可设置上报后的回调函数。

# 参数

# Object param

日志上报的参数对象。

属性 类型 默认值 必填 说明
eventID string 关卡事件 ID,在 小游戏管理后台->统计-> 收入诊断调优->分析调优->事件上报中配置
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

# 示例代码

eventID是必填字段,支持自定义参数,key可以为任意字符串如 levelID,value为(string,number,boolean),注意:value不能为NaN。透传上报的数据。 下面只展示关卡事件上报的示例代码。我们还为开发者们提供了道具获取、道具使用、广告观看等多种协议。关于其他协议的使用说明和示例代码,可以在收入诊断调优指引查看。

let logger = null;
if (wx.getMiniReportManager) {
  logger = wx.getMiniReportManager({
    debug: true,
    eventList: ['10000003'],
  });
}

// 关卡事件上报
logger.report({
  eventID: '10000003',          // 事件ID
  levelID: 1,                   // 关卡ID
  levelName: '第三关',           // 关卡名称
  levelAction: 1,               // 关卡类型
  levelResult: 2,               // 关卡动作
  levelTime: 40,                // 关卡用时
  levelProgress: 75,            // 关卡进度
  externInfo: JSON.stringify({
    "fail_reason": 1,           // 失败原因类型
    "resources_remaining": {    // 剩余资源
      "health": 30,             // 生命值
      "ammo": 12,               // 弹药
    }
  }),                           // 自定义属性
  gameVersion: 3,               // 版本号
  loginCount: 1,                // 关卡进入次数
  success(res) {
    console.log('success', res)
  },
  fail(res) {
    console.log('fail', res)
  },
  complete(res) {
    console.log('complete', res)
  }
});
点击咨询小助手