Skip to content

📹 A SDK for wechat miniprogramme error and performance. 微信小程序错误及性能监控SDK

License

Notifications You must be signed in to change notification settings

alex1504/femonitor-wx

Repository files navigation

Description

A SDK for wx miniprogramme error and performance monitor, using event subscription.

Screenshot

screenshot

Example

Click this here to open WeChat Mini Program Developer Tool for test

Feature

  • Error observe, includes js error, unhandle rejection error and http error
  • Error filters and error sampling
  • Slow http request observe
  • Observe user behaviors into a behavior queue
  • Performance observe for every page

Install

NPM

npm i femonitor-wx -S

Directly download

Click here to dowload femonitor-wx sdk

Usage

const { Monitor } = require("femonitor-wx");

/* Options could be undefined because SDK has default options  */
const monitor = Monitor.init(options);

/* Listen all event */
monitor.on("event", (eventName, emitData) => {
  /* Use wx.request to report data here  */  
  console.log(eventName, emitData);
});

DefaultOptions

Options param will be deepmerge into defaultOptions

export const defaultOptions = {
  env: Env.Dev,   
  isSystemInfo: true,  // If get system info
  isNetwork: true,     // If get network info
  httpTimeout: 0,      // Define slow httptimeout(ms)
  error: {
    filters: [],       // Filter error using regexp array
    random: 1          // Extract error samples, 1 is 100%
  },
  behavior: {
    isFilterConsole: false,  // If record console behavior
    queueLimit: 20,          // Limit behavior queue to 20
    // Observe function name includes methodWhilteList, priority is higher than methodBlackList
    methodWhiteList: [],
    // Observe function name excludes methodBlackList
    methodBlackList: []
  },
  performance: {
    watch: true,       // If watch page performance
    queueLimit: 20     // Limit performane queue to 20
  }
};

Support events

EventName Description
jsError app.onError
unhandleRejection app.onunhandledrejection
reqError Network request error
performanceInfoReady Page performance data is ready
slowHttpRequest Emit when http request cost time larger than timeout httpTimeout
event Includes all events above

Development

npm run watch

Build

npm run build

About

📹 A SDK for wechat miniprogramme error and performance. 微信小程序错误及性能监控SDK

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published