<commit_before>[![npm version](https://badge.fury.io/js/clappr-stats.svg)](https://badge.fury.io/js/clappr-stats)
[![license](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)

# Usage

You can use if from JSDelivr `https://cdn.jsdelivr.net/clappr.stats/latest/clappr-stats.min.js` or npm package.

```html
<script>
    var player = new Clappr.Player({
      parentId: '#player',
      plugins: [ClapprStats],
      source: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
      height: 360,
      width: 640,
      clapprStats: {
        runEach: 5000, //optional: time in miliseconds for each report default:  5000
        onReport: (metrics) => {console.log(metrics)}, //optional: callback function default: console.log
        uriToMeasureLatency: 'http://www.example.com/images/tv/pixel-1x1-red.gif', //optional: provide an img uri hosted at
        // the same place as your farm or near of it prefferable 1x1px, without caching. default: none
      }
    })
</script>
```

# Metrics

```javascript
{
  counters: {
    play: 0, // number of plays
    pause: 0, // number of pauses
    error: 0, // number of errors
    buffering: 0, // number of bufferings
    decodedFrames: 0, // number of decoded frames (when available)
    droppedFrames: 0, // number of dropped frames (when available)
    fps: 0, // frames per second (when available)
    changeLevel: 0, // number of adaptative bitrate changes
    seek: 0, // number of seeks
    fullscreen: 0, // number of times that user went to fullscreen
    dvrUsage: 0 // number of time taht user used dvr seek (at live stream)
  },
  timers: {
    startup: 0, // time (ms) since user click/touch play (intent to play) to the play
    watch: 0, // time (ms) of watched content (does not include pause and buffering)
    pause: 0, // time (ms) of paused content
    buffering: 0, // time (ms) of buffering
    session: 0, // time (ms) of session (sum of watch+pause+buffering)
    latency: 0, // time (ms) of latency between user and the provided uri
  },
  extra: {
    playbackName: '', // playback name (hls, html5_video, flashls)
    playbackType: '', // vod or live
    buffersize: 0, // buffersize in ms
    bitratesHistory: [], // the bitrates changes history
    bitrateMean: 0, // bitrate mean (kbps)  (we're considering height as "bitrate")
    bitrateVariance: 0, // bitrate variance (kbps)  (we're considering height as "bitrate")
    bitrateStandardDeviation: 0, // bitrate standard deviation (kbps)  (we're considering height as "bitrate")
    bitrateMostUsed: 0, // most used (based on time) bitrate  (kbps)  (we're considering height as "bitrate")
  }
}
```
<commit_msg>fixes grammar<commit_after>[![npm version](https://badge.fury.io/js/clappr-stats.svg)](https://badge.fury.io/js/clappr-stats)
[![license](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)

# Usage

You can use it from JSDelivr `https://cdn.jsdelivr.net/clappr.stats/latest/clappr-stats.min.js` or as a npm package.

```html
<script>
    var player = new Clappr.Player({
      parentId: '#player',
      plugins: [ClapprStats],
      source: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
      height: 360,
      width: 640,
      clapprStats: {
        runEach: 5000, //optional: time in miliseconds for each report default:  5000
        onReport: (metrics) => {console.log(metrics)}, //optional: callback function default: console.log
        uriToMeasureLatency: 'http://www.example.com/images/tv/pixel-1x1-red.gif', //optional: provide an img uri hosted at
        // the same place as your farm or near of it prefferable 1x1px, without caching. default: none
      }
    })
</script>
```

# Metrics

```javascript
{
  counters: {
    play: 0, // number of plays
    pause: 0, // number of pauses
    error: 0, // number of errors
    buffering: 0, // number of bufferings
    decodedFrames: 0, // number of decoded frames (when available)
    droppedFrames: 0, // number of dropped frames (when available)
    fps: 0, // frames per second (when available)
    changeLevel: 0, // number of adaptative bitrate changes
    seek: 0, // number of seeks
    fullscreen: 0, // number of times that user went to fullscreen
    dvrUsage: 0 // number of time taht user used dvr seek (at live stream)
  },
  timers: {
    startup: 0, // time (ms) since user click/touch play (intent to play) to the play
    watch: 0, // time (ms) of watched content (does not include pause and buffering)
    pause: 0, // time (ms) of paused content
    buffering: 0, // time (ms) of buffering
    session: 0, // time (ms) of session (sum of watch+pause+buffering)
    latency: 0, // time (ms) of latency between user and the provided uri
  },
  extra: {
    playbackName: '', // playback name (hls, html5_video, flashls)
    playbackType: '', // vod or live
    buffersize: 0, // buffersize in ms
    bitratesHistory: [], // the bitrates changes history
    bitrateMean: 0, // bitrate mean (kbps)  (we're considering height as "bitrate")
    bitrateVariance: 0, // bitrate variance (kbps)  (we're considering height as "bitrate")
    bitrateStandardDeviation: 0, // bitrate standard deviation (kbps)  (we're considering height as "bitrate")
    bitrateMostUsed: 0, // most used (based on time) bitrate  (kbps)  (we're considering height as "bitrate")
  }
}
```

{'fraction_non_alphanumeric': 0.13237727523441808, 'fraction_numerical': 0.016179444750873323, 'mean_word_length': 3.0476190476190474, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '995515', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1744, 'n_words': 573}