jollychic-h5-logs

1.2.1 • Public • Published

jollychic-h5-logs

jollychic-h5-logs

安装

npm install jollychic-h5-logs

简介

前后端分离,收集前端错误日志使用,只支持navigator.sendBeacon 的浏览器使用,支持嵌入vue

主要程序

import h5Logs from "jollychic-h5-logs";
h5Logs.init({
    event: 'reportEventTest'
});
支持的函数 errorHandlerCollectFunction(err,info),参看案例
支持的init(options)自定义设置,参看案例

使用例子

import Vue from 'vue';
import h5Logs from "jollychic-h5-logs";
h5Logs.init({
    event: 'reportEventTest',
    baseUrl: 'http://www.test.com', //收集日志的主域名,默认 ''
    baseApiUrl: '/api/logs', //api地址, 默认'/api/chatCollector',最好自己配置为post的接口地址
    sendCount: 50 //设置达到多少阀值自动上报日志, 默认16, 程序默认是浏览器关闭也会上报日志
});
Vue.config.errorHandler = function (err, vm, info) {
    h5Logs.errorHandlerCollectFunction(err, 'EventVueTest:' + info);
};
Vue.prototype['$throw'] = function (err, info) {
    h5Logs.errorHandlerCollectFunction(err, info);
};

//window.h5logsThrow = function (err, info) {
//	h5Logs.errorHandlerCollectFunction(err, info);
//};

//参数window.h5logsThrow(info,event);
//window.h5logsThrow({aa:1,bb:2},'test1');
//window.h5logsThrow('hahahaha','test2');
//this.$throw({aa:1,bb:2},'test1');
//this.$throw('hahahaha','test2');

日志更新记录

版本1.1.8

1.更新 增加默认使用参数,若果不填, info='systemInfo',event='systemEvent'
2.默认开始上报日志下调到16个.

Readme

Keywords

Package Sidebar

Install

npm i jollychic-h5-logs

Weekly Downloads

7

Version

1.2.1

License

ISC

Unpacked Size

3.64 kB

Total Files

3

Last publish

Collaborators

  • xiaobai8