monitor-track-weapp
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

微信小程序监控及埋点 SDK 工具

使用

npm install monitor-track-weapp -S
import Track from 'monitor-track-weapp';

export const track = new Track();

track.init({
  appid: 'wx25040ed54a350d66',
  reportUrl: 'https://some-path/some-path',
  projectID: 'xxxx',
  framework: 'Taro',
  enable: process.env.NODE_ENV === 'production',
});

// 有些信息可能是需要异步获取的,需要获取后再设置,比如设置customPayload
wx.request({
  url: 'https://some-path/some-path',
  data: {},
  header: {
    'content-type': 'application/json',
  },
  method: 'POST',
  success: (res) => {
    track.setGlobalReport('customPayload', JSON.stringify(res));
  },
});

配置项

配置项 类型 必填 默认值 注释
reportUrl string '' 上报地址,后台地址
projectID string '' 项目 ID
appid string '' 小程序 appid
framework 'Taro' - 框架
enablePerformance boolean false 启用性能上报
ignore object false 忽略上报的信息
customPayload string false 自定义 payload
enable boolean false 是否开启日志收集,默认关闭

ignore

参数 类型 必填 默认值 注释
urls string[] [] 忽略的 url
errors string[] [] 忽略的异常信息
apis string[] [] 忽略的接口

Package Sidebar

Install

npm i monitor-track-weapp

Weekly Downloads

1

Version

1.3.2

License

none

Unpacked Size

80.1 kB

Total Files

37

Last publish

Collaborators

  • shoujian