Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clappr-stats

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clappr-stats - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.eslintrc.js

60

index.js

@@ -1,2 +0,2 @@

import {ContainerPlugin, Log, Events} from 'clappr'
import {ContainerPlugin, Events} from 'clappr'
import get from 'lodash.get'

@@ -12,3 +12,3 @@

_now() {
const hasPerformanceSupport = performance && typeof(performance.now) === "function"
const hasPerformanceSupport = performance && typeof(performance.now) === 'function'
return (hasPerformanceSupport)?performance.now():new Date()

@@ -20,3 +20,3 @@ }

_stop(timer) {this._metrics.timers[timer] += this._now() - this[`_start${timer}`]}
_defaultReport(metrics) {console.log(metrics)}
_defaultReport(metrics) {console.log(metrics)} //eslint-disable-line no-console

@@ -31,12 +31,13 @@ constructor(container) {

counters: {
play: 0, pause: 0, error: 0, buffering: 0, decodedFrames: 0, droppedFrames: 0,
fps: 0, changeLevel: 0, seek: 0, fullscreen: 0, dvrUsage: 0
play: 0, pause: 0, error: 0, buffering: 0, decodedFrames: 0, droppedFrames: 0,
fps: 0, changeLevel: 0, seek: 0, fullscreen: 0, dvrUsage: 0
},
timers: {
startup: 0, watch: 0, pause: 0, buffering: 0, session: 0, latency: 0
startup: 0, watch: 0, pause: 0, buffering: 0, session: 0, latency: 0
},
extra: {
playbackName: '', playbackType: '', bitratesHistory: [], bitrateMean: 0,
bitrateVariance: 0, bitrateStandardDeviation: 0, bitrateMostUsed: 0
} //buffersize, all playbacks???
bitrateVariance: 0, bitrateStandardDeviation: 0, bitrateMostUsed: 0,
buffersize: 0
}
}

@@ -52,6 +53,5 @@

this.listenToOnce(this.container.playback, Events.PLAYBACK_PLAY_INTENT, this.startTimers)
this.listenToOnce(this.container, Events.CONTAINER_PLAY, () => this._start('watch'))
this.listenToOnce(this.container, Events.CONTAINER_PLAY, this.onFirstPlaying)
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay)
this.listenTo(this.container, Events.CONTAINER_PAUSE, this.onPause)
this.listenToOnce(this.container, Events.CONTAINER_TIMEUPDATE, (e) => e.current > 0 && this._stop('startup')) //should be at PLAY
this.listenTo(this.container, Events.CONTAINER_TIMEUPDATE, (e) => e.current > 0 && this.onContainerUpdateWhilePlaying())

@@ -93,2 +93,7 @@ this.listenToOnce(this.container, Events.CONTAINER_STATE_BUFFERING, this.onBuffering)

onFirstPlaying() {
this._start('watch')
this._stop('startup')
}
playAfterPause() {

@@ -148,5 +153,5 @@ this._stop('pause')

const fetchFPS = {
'html5_video': this._html5FetchFPS,
'hls': this._html5FetchFPS,
'dash_shaka_playback': this._html5FetchFPS
'html5_video': this._html5FetchFPS,
'hls': this._html5FetchFPS,
'dash_shaka_playback': this._html5FetchFPS
}

@@ -187,22 +192,21 @@

if (this._uriToMeasureLatency) {
var t=[], n=2, tcp, rtt;
var t=[], n=2, rtt
var ld = () => {
t.push(this._now());
if(t.length > n)
done();
else {
var img = new Image;
img.onload = ld;
img.src=this._uriToMeasureLatency + '?' + Math.random()
+ '=' + this._now();
}
};
t.push(this._now())
if(t.length > n)
done()
else {
var img = new Image
img.onload = ld
img.src=this._uriToMeasureLatency + '?' + Math.random()
+ '=' + this._now()
}
}
var done = () => {
rtt=t[2]-t[1]
tcp=t[1]-t[0]-rtt
rtt=t[2]-t[1]
this._metrics.timers.latency = rtt
};
ld();
}
ld()
}
}
}
{
"name": "clappr-stats",
"version": "0.0.2",
"version": "0.0.3",
"description": "clappr playback stats report plugin",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,3 +1,8 @@

[![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

@@ -14,3 +19,4 @@ <script>

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
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
}

@@ -44,3 +50,3 @@ })

session: 0, // time (ms) of session (sum of watch+pause+buffering)
latency: 0, // time (ms) of latency between user and the uri provided
latency: 0, // time (ms) of latency between user and the provided uri
},

@@ -52,8 +58,8 @@ extra: {

bitratesHistory: [], // the bitrates changes history
bitrateMean: 0, // bitrate mean
bitrateVariance: 0, // bitrate variance
bitrateStandardDeviation: 0, // bitrate standard deviation
bitrateMostUsed: 0, // most used (based on time) bitrate
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")
}
}
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc