1.2.0 β€’ Published 5 years ago

web-monitor-sdk v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

SDK for web monitor, a simple web data collection tool for performance, exceptions, etc.

🏠 Homepage

δΈ­ζ–‡ζ–‡ζ‘£

Install

npm install web-monitor-sdk

Usage

Use it in UMD style

There is example

import dist/web-monitor-sdk.min.js:

<script src="../../dist/web-monitor-sdk.min.js"></script>

and call init:

window.WebMonitorSDK.init({ 
    debug: true,
    sendError: false,
    outtime:3000,
    blacklistUrls:[
      // 'localhost:8080/examples'
    ],
    data:{
      webUser:{
        id:12345
      }
    }
 },(data)=>{
     fetch('http://demo/api',{
        method:'POST',
         headers: {'Content-Type': 'application/json'},
         body:JSON.stringify(data)
     })
 });

Use it in CommonJS style

There is example

// import * as webMonitor from 'web-monitor-sdk'
const webMonitor = require('web-monitor-sdk')

webMonitor.init({
    debug:true,
    sendError: false,
    outtime:2000
},data=>{
    fetch('http://demo/api',{
        method:'POST',
        headers: {'Content-Type': 'application/json'},
        body:JSON.stringify(data)  
    })
})

API

WebMonitor.init(Options,fn)

fn

Function

Callback function after data collection. We only collect data, not responsible for reporting data, so you need to assemble the logic of reporting data ourselves.

Options

debug

Enable debug funtionality such as Logger, in the SDK.

(Defaults to false)

blacklistUrls

Array<string | RegExp>

A pattern for URLs which should not be report. (By default, all urls will be sent)

outtime

number

Delay time to report, ensure the loading of asynchronous data. The unit is milliseconds. (Defaults to 1000)

sendPage

boolean

Whether to report page performance data. (Defaults to true)

sendError

boolean

Whether to report error. (Defaults to true)

sendUnhandledRejection

boolean

Whether to report unhandledrejection error in promise in Chrome 49+. (Defaults to true)

sendUnloadError

boolean

Whether to report unload error. (Defaults to true)

sendClientInfo

boolean

Whether to report client info such as user agent and resolution. (Defaults to true)

data

object

Additional data, to send to server together. (Default is undefined)

Author

πŸ‘€ Brizer <brizer@163.com>

ChangeLog

🀝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

Copyright Β© 2019 Brizer <brizer@163.com>. This project is MIT licensed.


This README was generated with ❀️ by readme-md-generator