0.0.9 • Published 2 months ago

@heimdallr-sdk/wx v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@heimdallr-sdk/wx

微信小程序监控基座,内置错误捕获sdk

默认使用 get 上报,允许修改 wx.request 配置项(不可修改 data、dataType)

Options

配置名称类型描述可选值默认值
dsnObject上报接口配置信息DSN-
appObject应用信息APPInfo-
enabledBoolean是否向后台发送事件true/falsetrue
pluginsArray插件集合--
debugBoolean控制台是否显示报错true/falsefalse
reqOptionRequestOption请求配置项(最高优先级)--
userStoreKeyString用户信息存储key--

DSN

名称类型描述可选值
hostString上报接口域名地址-
initString应用初始化接口地址-
uploadString信息上报接口地址-

APPInfo

名称类型描述可选值
nameString应用名称-
leaderString负责人-
descString应用描述-

RequestOption

名称类型描述可选值
urlString接口地址-
enableCacheBoolean开启 cachefalse/true
enableHttp2Boolean开启 http2false/true
enableQuicBoolean开启 quicfalse/true
failFunction接口失败回调-
headerObject请求头(不可设置Referer)-
methodString请求方法OPTIONS/GET/HEAD/POST/PUT/DELETE/TRACE/CONNECT
responseTypeString响应的数据类型text/arraybuffer
successFunction接口成功回调-
timeoutNumber超时时间,单位为毫秒-

Usage

Init

通常在 app.js 中完成初始化,可直接挂载到 wx 对象上

import heimdallr from "@heimdallr-sdk/wx";
wx.heimdallrInstance = heimdallr({
    dsn: {
        host: 'http://localhost:8888',
        init: '/project/init',
        upload: '/log/upload'
    },
    app: {
        name: 'playgroundWx',
        leader: 'test',
        desc: 'test wx proj'
    }
});

Lifecycle

提供两种方式监听页面显示、隐藏方式

1. Overwrite Page

const { heimdallrPage } = wx.heimdallrInstance;
heimdallrPage({
  data: {
    text: "This is page data."
  },
  onLoad: function(options) {
    // Do some initialize when page load.
  },
  onShow: function() {
    // Do something when page show.
  },
  onReady: function() {
    // Do something when page ready.
  },
  onHide: function() {
    // Do something when page hide.
  },
  onUnload: function() {
    // Do something when page close.
  }
});

2. Add the track function to the lifecycle function

const { track } = wx.heimdallrInstance;
Page({
  data: {
    text: "This is page data."
  },
  onLoad: function(options) {
    // Do some initialize when page load.
  },
  onShow: function() {
    track('show', this.route);
    // Do something when page show.
  },
  onReady: function() {
    // Do something when page ready.
  },
  onHide: function() {
    track('hide', this.route);
    // Do something when page hide.
  },
  onUnload: function() {
    // Do something when page close.
  }
})
0.0.9

2 months ago

0.0.8

5 months ago

0.0.7

10 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago