0.0.5 • Published 5 years ago

@helpscout/stats v0.0.5

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

📊 Stats

Build Status npm version

Easy performance monitoring for JavaScript / React

Stats

Table of Contents

Installation

Add stats to your project via npm install:

npm install --save @helpscout/stats

Usage

JavaScript

To use Stats in your JavaScript project, simply import it and instantiate!

import createStats from '@helpscout/stats'

const stats = createStats()
// Stats will automatically mount to window.document

// For clean up, execute the destroy() method
stats.destroy()

React

Stats comes with a handy <StatsGraph /> component. To add it to your React project, import it and render it:

import React from 'react'
import {StatsGraph} from '@helpscout/stats'

class App extends React.Component {
  render() {
    return (
      <div>
        ...
        <StatsGraph />
        ...
      </div>
    )
  }
}

export default App

StatsGraph cleans up after itself if it unmounts.

Graphs

  • FPS Frames rendered in the last second. The higher the number the better.
  • MB MBytes of allocated memory. (Run Chrome with --enable-precise-memory-info)
  • NODES Number of DOM nodes in window.document (including iFrame nodes).

Options

Stats accepts a handful of options to adjust it's position and UI.

PropTypeDefaultDescription
topnumber/string0(CSS) top position.
rightnumber/string0(CSS) right position.
bottomnumber/string0(CSS) bottom position.
leftnumber/string0(CSS) left position.
opacitynumber0.5Opacity for the Stats UI.
positionstringfixedPosition for the Stats UI.
zIndexstring99999999z-index for the Stats UI.

The React StatsGraph uses the same options for it's defaultProps

Thanks

Thanks for mrdoob for his stats.js library, which inspired this one!