Code Monkey home page Code Monkey logo

raven-weapp's Introduction

Raven-weapp

为方便小程序接入sentry,由raven改写而来的小程序版本。

引入文件

由于目前小程序不支持从node_modules中引入文件,因此以npm方式安装的话只能手动将raven-weapp/dist目录下需要的文件拷贝到其他文件中,在app.js中引入,例如:

var Raven = require('./utils/raven-weapp/build/raven')

或以Bower安装raven-weapp并引入:

var Raven = require('./bower_components/raven-weapp/build/raven')

初始化Raven

Raven.config('https://[email protected]/x', options).install()

在app的onLaunch中初始化(?),options为可选配置对象,目前支持:

options = {
    release: '当前小程序版本',
    environment: '指定为production才会上报',
    allowDuplicates: true, // 允许相同错误重复上报
    sampleRate: 0.5 // 采样率
}

收集信息

收集的信息将在上报时被一起带上

基本信息

初始化后raven会默认收集以下信息:

{
    SDKversion: '小程序基础库版本',
    WXversion: '微信版本',
    device: '设备型号',
    network: '网络类型',
    system: '系统信息',
}

可以通过Raven.setUserContext(context)或者Raven.setExtraContext(context)添加更多信息(kdtId和userId等)

用户行为
console

console的行为默认将被自动收集

ajax

wx.request不可扩展,因此只能手动收集请求的行为:例如在经过封装的请求函数的成功回调内添加:

Raven.captureBreadcrumb({
  category: 'ajax',
  data: {
    method: 'get',
    url: 'weapp.showcase.page/1.0.0/get',
    status_code: 200
  }
dom

ui操作的记录暂不支持

location

页面变化的记录暂不支持

信息上报

分为message和exception的上报

message

使用Raven.captureMessage(msg, option)上报需要上报的信息比如ajax的报错等

exception

所有uncaught exception都会被小程序捕获封装成msg传递到app的onError中,在onError中上报这些信息:

onError(msg) {
    Raven.captureException(msg, {
      level: 'error'
    })
  }

raven-weapp's People

Contributors

everywill avatar ninofocus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raven-weapp's Issues

小程序 request 合法域名

目前小程序不支持 sentry.io 设置合法域名,那是不是表示无法在小程序里使用 sentry 了呢😢
image

resolve:
我们内部做了一个接口转发

require('./utils/raven-weapp/build/raven')提示This relative module was not found

require('./utils/raven-weapp/build/raven')提示This relative module was not found
我的目录是对的,所引入的文件夹也不在es-lint-loader 范围中。

This relative module was not found:

  • ../utils/raven-weapp/build/raven.min.js in ./node_modules/mpvue-entry/dist/cardDetail.js, ./node_modules/mpvue-entry/dist/pagesIndex.js and 32 others

我用的美团的开源框架mpvue来搭建的小程序。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.