New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clappr-stats

Package Overview
Dependencies
Maintainers
5
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.1.1 to 0.1.2

4

package.json
{
"name": "clappr-stats",
"version": "0.1.1",
"version": "0.1.2",
"description": "clappr playback stats report plugin",
"main": "src/clappr-stats.js",
"main": "dist/clappr-stats.js",
"repository": {

@@ -7,0 +7,0 @@ "type": "git",

@@ -61,3 +61,3 @@ [![npm version](https://badge.fury.io/js/clappr-stats.svg)](https://badge.fury.io/js/clappr-stats)

fullscreen: 0, // number of times that user went to fullscreen
dvrUsage: 0 // number of time taht user used dvr seek (at live stream)
dvrUsage: 0 // number of time that user used dvr seek (at live stream)
},

@@ -79,10 +79,10 @@ timers: {

bitratesHistory: [], // the bitrates changes history
bitrateWeightedMean: 0, // bitrate weighted mean (kbps)
bitrateMostUsed: 0, // most used (based on time) bitrate (kbps)
bitrateWeightedMean: 0, // bitrate weighted mean (bps)
bitrateMostUsed: 0, // most used (based on time) bitrate (bps)
watchHistory: [], // an array of an array of watched range time ex: [0, 2200]
watchedPercentage: 0, // % of watched time
bufferingPercentage: 0, // % of buffering time
bandwidth: 0, // bandwidth in kbps
bandwidth: 0, // user bandwidth (bps)
}
}
```

@@ -31,3 +31,3 @@ import {ContainerPlugin, Events, Log} from 'clappr'

watch: get(container, 'options.clapprStats.onCompletion', []),
lastCalled: 0
calls: []
}

@@ -95,2 +95,3 @@

playAfterPause() {
this.listenTo(this.container, Events.CONTAINER_TIMEUPDATE, this.onContainerUpdateWhilePlaying)
this._stop('pause')

@@ -109,2 +110,3 @@ this._start('watch')

this.listenToOnce(this.container, Events.CONTAINER_PLAY, this.playAfterPause)
this.stopListening(this.container, Events.CONTAINER_TIMEUPDATE, this.onContainerUpdateWhilePlaying)
}

@@ -184,7 +186,7 @@

let allPercentages = this._completion.watch
let isCalled = currentPercentage <= this._completion.lastCalled
let isCalled = this._completion.calls.indexOf(currentPercentage) != -1
if (allPercentages.indexOf(currentPercentage) != -1 && !isCalled) {
Log.info(this.name + ' PERCENTAGE_EVENT: ' + currentPercentage)
this._completion.lastCalled = currentPercentage
this._completion.calls.push(currentPercentage)
this.trigger(ClapprStats.PERCENTAGE_EVENT, currentPercentage)

@@ -223,7 +225,10 @@ }

_calculateBitrates() {
var totalTime = this._metrics.extra.bitratesHistory.map((x) => x.time).reduce((a,b) => a + b, 0)
this._metrics.extra.bitrateWeightedMean = this._metrics.extra.bitratesHistory.map((x) => {
return x.bitrate * x.time
}).reduce((a,b) => a + b, 0) / this._metrics.timers.watch
}).reduce((a,b) => a + b, 0) / totalTime
this._metrics.extra.bitrateMostUsed = this._metrics.extra.bitratesHistory.slice().sort((a,b) => a.time < b.time)[0]
if (this._metrics.extra.bitratesHistory.length > 0) {
this._metrics.extra.bitrateMostUsed = this._metrics.extra.bitratesHistory.slice().sort((a,b) => a.time < b.time)[0].bitrate
}
}

@@ -303,4 +308,3 @@

var bandwidthBps = (e.loaded * 8) / timeSpent
var bandwidthKbps = bandwidthBps / 1000
this._metrics.extra.bandwidth = bandwidthKbps
this._metrics.extra.bandwidth = bandwidthBps
this._urisToMeasureBandwidth.forEach((x) => {

@@ -307,0 +311,0 @@ x.start = 0

@@ -75,2 +75,12 @@ import { expect, assert } from 'chai'

it('call PERCENTAGE_EVENT if video start in middle time and make seek for past', () => {
this.plugin.on(ClapprStats.PERCENTAGE_EVENT, this.callback)
this.simulator.play(10)
assert.isOk(this.callback.calledOnce)
this.simulator.play(4)
assert.isOk(this.callback.calledTwice)
})
it('call PERCENTAGE_EVENT once with the same state', () => {

@@ -86,2 +96,25 @@ this.plugin.on(ClapprStats.PERCENTAGE_EVENT, this.callback)

it('does not update time watch in this events sequence [BUG]', () => {
let counter = 0
let originalMethod = window.performance.now
window.performance.now = () => { return counter++ }
let container = this.simulator.container
this.simulator.plugin.on(ClapprStats.REPORT_EVENT, this.callback)
container.play()
container.playing()
container.timeUpdated({current: 50})
container.paused()
container.timeUpdated({current: 80})
container.pause()
this.clock.tick(this.timeInterval)
let watch = this.callback.getCall(0).args[0].timers.watch
expect(watch).to.be.equal(3)
window.performance.now = originalMethod
})
it('should update counters', () => {

@@ -88,0 +121,0 @@ this.plugin.on(ClapprStats.REPORT_EVENT, this.callback)

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