随笔 - 2649  文章 - 2452  评论 - 0  阅读 - 86517

获取性能数据

获取性能数据

调试工具

接口应在服务器端调用,详细说明参见服务端API

接口说明

接口英文名

getPerformance

功能描述

该接口用于获取性能数据

调用方式

HTTPS 调用

POST https://api.weixin.qq.com/wxaapi/log/get_performance?access_token=ACCESS_TOKEN 

第三方调用

  • 调用方式以及出入参和HTTPS相同,仅是调用的token不同
  • 该接口所属的权限集id为:18
  • 服务商获得其中之一权限集授权后,可通过使用authorizer_access_token代商家进行调用

请求参数

属性 类型 必填 说明
access_token string 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token或者authorizer_access_token
cost_time_type number 可选值 1(启动总耗时), 2(下载耗时),3(初次渲染耗时)
default_start_time number 查询开始时间
default_end_time number 查询结束时间
device string 系统平台,可选值 "@_all:"(全部),1(IOS), 2(android)
is_download_code string 是否下载代码包,当 type 为 1 的时候才生效,可选值 "@_all:"(全部),1(是), 2(否)
scene string 访问来源,当 type 为 1 或者 2 的时候才生效,通过 getSceneList 接口获取
networktype string 网络环境, 当 type 为 2 的时候才生效,可选值 "@_all:",wifi, 4g, 3g, 2g

返回参数

属性 类型 说明
errcode number 错误码
errmsg string 错误信息
default_time_data string 错误查询数据(json字符串,结构如下所述的 strbody)
compare_time_data string 比较数据

其他说明

strbody 的结构

属性 类型 说明
ref_date string 日期
cost_time_type number 意思同参数里面的 cost_time_type
cost_time number 耗时(毫秒)

调用示例

示例说明: HTTPQ请求示例

请求数据示例

{
  "cost_time_type": 2,
  "default_start_time": 1572339403,
  "default_end_time": 1574931403,
  "device": "@_all",
  "networktype": "@_all",
  "scene": "@_all",
  "is_download_code": "@_all"
} 

返回数据示例

{
  "default_time_data": "{\"list\":[{\"ref_date\":\"20191029\",\"cost_time_type\":2,\"cost_time\":1533},{\"ref_date\":\"20191030\",\"cost_time_type\":2,\"cost_time\":1682}]}",
  "compare_time_data": "",
  "errcode": 0
} 

示例说明: 云函数调用示例

请求数据示例

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.operation.getPerformance({
        "device": '@_all',
        "networktype": '@_all',
        "scene": '@_all',
        "costTimeType": 2,
        "defaultStartTime": 1572339403,
        "defaultEndTime": 1574931403,
        "isDownloadCode": '@_all'
      })
    return result
  } catch (err) {
    return err
  }
} 

返回数据示例

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.operation.getPerformance({
        "errcode": 0,
        "defaultTimeData": '{\'list\":[{\"ref_date\":\"20191029\",\"cost_time_type\":2,\"cost_time\":1533},{\"ref_date\":\"20191030\",\"cost_time_type\":2,\"cost_time\":1682}]}",
        "compareTimeData": ''
      })
    return result
  } catch (err) {
    return err
  }
} 

错误码

错误码 错误码取值 解决方案
-1 system error 系统繁忙,此时请开发者稍候再试
40001 invalid credential access_token isinvalid or not latest 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口
posted on   AtlasLapetos  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示