0.1.14 • Published 5 years ago

fe-supervisor v0.1.14

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

fe-supervisor (The frontend monitor project)

NPM downloads npm version Build Status codecov install size license

Quick Start

Several options to get up and running:

  • Clone the repo: git clone git@github.com:BobbyLH/fe-supervisor.git
  • Install with npm: npm install fe-supervisor -S
  • Install with Yarn: yarn add fe-supervisor
<script src=`${pathTo}/dist/fe-supervisor.sdk.${version}.js` ></script>
<script>
    console.log($sv.getTiming())
</script>
import sv from 'fe-supervisor'

console.log(sv.getMemory())

API

Global NameSpace

$sv

Methods

getPerformanceData(config)

Get the all performance data.

import sv from 'fe-supervisor'

sv.getPerformanceData().then(data => console.log(data))
interface IconfigSources {
  [propName: string]: string[];
}

interface config {
  apiRatio?: number;
  sourceRatio?: number;
  apis?: string[] | string;
  sources?: IconfigSources | string[] | string;
  timeout?: number; // timeout threshold(millisecond) - default 2000
  whitelist?: Iwhitelist;
  paintTiming?: boolean;
}

getMemory()

Get memory consumption.

getTiming()

Get performance timing.

getSource(config)

Get source timing.

import sv from 'fe-supervisor'

sv.getSource().then(data => console.log(data))
interface IconfigSources {
  [propName: string]: string[];
}

interface config {
  apiRatio?: number;
  sourceRatio?: number;
  apis?: string[] | string;
  sources?: IconfigSources | string[] | string;
  timeout?: number; // timeout threshold(millisecond) - default 2000
  whitelist?: Iwhitelist;
  paintTiming?: boolean;
}

mark(tag)

Marking a tag in the code.

getExecTiming()

Get tagged code execution timing.

import sv from 'fe-supervisor'

sv.getExecTiming().then(data => console.log(data))

clearPerformance()

Clear performance data.

observeSource(target, callback, option?: IobserveSourceOption)

get source timing information by refer dom.

import sv from 'fe-supervisor'

const sec = document.querySelect('section')
sv.observeSource(sec, function (source) {
  console.log('source', source)
}, {
  sourceType: ['script', 'img', 'link']
})
interface IobserveSourceOption {
  sourceType?: string | string[];
  timeout?: number;
  whitelist?: Iwhitelist;
}

getEnvInfo()

Get browser environment information.

getError(errType)

Get errors information.

type errType = 'js' | 'api' | 'source'

setError(error)

Set error.

interface error {
  type: ExceptionType;
  sourceType?: string;
  url: string;
  [propName: string]: any;
}

makeTrackInfo(type, info)

Making a track infomation.

observeError(target, callback?, observeDom?)

obersevation appoint target's children error.

import sv from 'fe-supervisor'
import React from 'react'



export default class Detail extends React.PureComponent{
  constructor (props) {
    super(props)
    this.pool = React.createRef()
  }
  addImg () {
    // observer DOM
    $sv.observeError(pool, function (errObj) {
      console.log('errObj', errObj)
    })
    // api request
    this.setState({
      Imgs: data
    })
  }

  getError () {
    const errObj = sv.getError('source')
    console.log(errObj)
  }

  render () {
    const { Imgs = null } = this.state
    return (
      <div ref={this.pool}>
        <button onClick={this.addImg.bind(this)}>Load Image</button>
        { Imgs }
        <button onClick={this.getError.bind(this)}>Get Error Message</button>
      </div>
    )
  }
}
type target = HTMLElement
type observeDom = string | string[]

License

Copyright (c) 2019-2019 Bobby.li

Released under the MIT License

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.43

5 years ago

0.0.42

5 years ago

0.0.41

5 years ago

0.0.40

5 years ago

0.0.38

5 years ago

0.0.37

5 years ago

0.0.36

5 years ago

0.0.34

5 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.30

5 years ago

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago