
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
monitor-track-weapp
Advanced tools
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 | 是否开启日志收集,默认关闭 |
| 参数 | 类型 | 必填 | 默认值 | 注释 |
|---|---|---|---|---|
| urls | string[] | 否 | [] | 忽略的 url |
| errors | string[] | 否 | [] | 忽略的异常信息 |
| apis | string[] | 否 | [] | 忽略的接口 |
见uniapp.ts
initTrackpvTrackerrorTrackrequestTrackmanualReportinitTrack
小程序加载的时候触发,在引入monitor-track.ts时会自动调用。
注意:程序默认取uni.getStorageSync('username')作为uuid,所以如果要将用户名作为用户标识,请将username存到storage中
如果uni.getStorageSync('username')取不到值,则不会上报埋点,小程序必须登录埋点才有意义
pvTrack
页面切换的时候触发,一般写在uniapp-router的beforeEach钩子里,示例代码如图:

errorTrack
全局错误信息收集,在App.vue的onPageNotFound、onError和onUnhandledRejection钩子中收集错误信息,示例代码如图:

requestTrack
请求拦截,分为请求错误和请求时间过长2个拦截器,请求时间过长的阈值可自行设置,示例代码如图:

manualReport
手动上报,用于程序手动触发埋点,如点击按钮,点击事件等。
需要注意manualReport的参数必须是一个对象,否则不能上报成功
FAQs
微信小程序埋点SDK
The npm package monitor-track-weapp receives a total of 10 weekly downloads. As such, monitor-track-weapp popularity was classified as not popular.
We found that monitor-track-weapp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.