2024-05-06-【工程化】小程序监控

腾讯云监控

RUM 腾讯云前端性能监控
RUM 快速入门
小程序接入指引

接入指引

一、腾讯云产品 RUM 开通并使用

  1. 开通 RUM 产品
    https://console.cloud.tencent.com/monitor/rum?region=ap-guangzhou

  2. 添加应用
    https://console.cloud.tencent.com/monitor/rum/manage?region=ap-guangzhou

  • 2.1 创建业务系统

填写系统名称、计费模式、标签等信息

  • 2.2 应用接入
  • 当前页,切换至 ”应用设置“ tab
  • 点击”创建应用“,填写应用名称,应用类型选”小程序“,所属系统选择上一步填写的 业务系统
  • 确定后,即可在 数据总览页中查看数据上报情况

二、小程序控制台配置

  • 打开小程序控制台,将https://rumt-zh.com 添加到安全域名中。

三、小程序项目引入监控插件

  1. npm 依赖安装
1
$ npm install --save aegis-mp-sdk
  1. 初始化
    注:为了不遗漏数据,须尽早初始化。
  • app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import Aegis from 'aegis-mp-sdk';
...

App({
onLaunch: function () {
const aegis = new Aegis({
id: "pGUVFTCZyewxxxxx", // RUM 上申请的上报 key
uin: 'xxx', // 用户唯一 ID(可选)
reportApiSpeed: true, // 接口测速
reportAssetSpeed: true, // 静态资源测速
hostUrl: 'https://rumt-zh.com', // 上报域名,中国大陆 rumt-zh.com
spa: true, // 页面切换的时候上报 pv
});

},
...
});

2024-05-06-【工程化】小程序监控
https://zhangyingxuan.github.io/2024-05-06-【工程化】小程序监控/
作者
blowsysun
许可协议