From 1c554ab55ae5929e89292506d69b503afb55dac6 Mon Sep 17 00:00:00 2001 From: Vagner Santana Date: Wed, 28 Mar 2018 10:16:35 -0300 Subject: [PATCH] bump version --- dist/clappr-stats.min.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 dist/clappr-stats.min.js diff --git a/dist/clappr-stats.min.js b/dist/clappr-stats.min.js new file mode 100644 index 0000000..2d79921 --- /dev/null +++ b/dist/clappr-stats.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Clappr")):"function"==typeof define&&define.amd?define(["Clappr"],t):"object"==typeof exports?exports.ClapprStats=t(require("Clappr")):e.ClapprStats=t(e.Clappr)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(e){delete installedChunks[e]}function n(e){var t=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.charset="utf-8",n.src=f.p+""+e+"."+w+".hot-update.js",t.appendChild(n)}function r(e){return e=e||1e4,new Promise(function(t,n){if("undefined"==typeof XMLHttpRequest)return n(new Error("No browser support"));try{var r=new XMLHttpRequest,i=f.p+""+w+".hot-update.json";r.open("GET",i,!0),r.timeout=e,r.send(null)}catch(e){return n(e)}r.onreadystatechange=function(){if(4===r.readyState)if(0===r.status)n(new Error("Manifest request to "+i+" timed out."));else if(404===r.status)t();else if(200!==r.status&&304!==r.status)n(new Error("Manifest request to "+i+" failed."));else{try{var e=JSON.parse(r.responseText)}catch(e){return void n(e)}t(e)}}})}function i(e){var t=C[e];if(!t)return f;var n=function(n){return t.hot.active?(C[n]?C[n].parents.indexOf(e)<0&&C[n].parents.push(e):(T=[e],_=n),t.children.indexOf(n)<0&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),T=[]),f(n)};for(var r in f)Object.prototype.hasOwnProperty.call(f,r)&&"e"!==r&&Object.defineProperty(n,r,function(e){return{configurable:!0,enumerable:!0,get:function(){return f[e]},set:function(t){f[e]=t}}}(r));return n.e=function(e){function t(){N--,"prepare"===k&&(j[e]||l(e),0===N&&0===x&&d())}return"ready"===k&&s("prepare"),N++,f.e(e).then(t,function(e){throw t(),e})},n}function o(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:_!==e,active:!0,accept:function(e,n){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var r=0;r=0&&t._disposeHandlers.splice(n,1)},check:c,apply:p,status:function(e){if(!e)return k;P.push(e)},addStatusHandler:function(e){P.push(e)},removeStatusHandler:function(e){var t=P.indexOf(e);t>=0&&P.splice(t,1)},data:g[e]};return _=void 0,t}function s(e){k=e;for(var t=0;t0;){var o=i.pop(),s=o.id,a=o.chain;if((u=C[s])&&!u.hot._selfAccepted){if(u.hot._selfDeclined)return{type:"self-declined",chain:a,moduleId:s};if(u.hot._main)return{type:"unaccepted",chain:a,moduleId:s};for(var c=0;c=0||(d.hot._acceptedDependencies[s]?(n[l]||(n[l]=[]),r(n[l],[s])):(delete n[l],t.push(l),i.push({chain:a.concat([l]),id:l})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:n}}(l):{type:"disposed",moduleId:y};var E=!1,O=!1,P=!1,x="";switch(b.chain&&(x="\nUpdate propagation: "+b.chain.join(" -> ")),b.type){case"self-declined":n.onDeclined&&n.onDeclined(b),n.ignoreDeclined||(E=new Error("Aborted because of self decline: "+b.moduleId+x));break;case"declined":n.onDeclined&&n.onDeclined(b),n.ignoreDeclined||(E=new Error("Aborted because of declined dependency: "+b.moduleId+" in "+b.parentId+x));break;case"unaccepted":n.onUnaccepted&&n.onUnaccepted(b),n.ignoreUnaccepted||(E=new Error("Aborted because "+l+" is not accepted"+x));break;case"accepted":n.onAccepted&&n.onAccepted(b),O=!0;break;case"disposed":n.onDisposed&&n.onDisposed(b),P=!0;break;default:throw new Error("Unexception type "+b.type)}if(E)return s("abort"),Promise.reject(E);if(O){h[l]=v[l],r(p,b.outdatedModules);for(l in b.outdatedDependencies)Object.prototype.hasOwnProperty.call(b.outdatedDependencies,l)&&(d[l]||(d[l]=[]),r(d[l],b.outdatedDependencies[l]))}P&&(r(p,[b.moduleId]),h[l]=_)}var N=[];for(o=0;o0;)if(l=A.pop(),u=C[l]){var S={},I=u.hot._disposeHandlers;for(c=0;c=0&&M.parents.splice(j,1))}}var D,H;for(l in d)if(Object.prototype.hasOwnProperty.call(d,l)&&(u=C[l]))for(H=d[l],c=0;c=0&&u.children.splice(j,1);s("apply"),w=m;for(l in h)Object.prototype.hasOwnProperty.call(h,l)&&(e[l]=h[l]);var B=null;for(l in d)if(Object.prototype.hasOwnProperty.call(d,l)&&(u=C[l])){H=d[l];var F=[];for(o=0;o=0)continue;F.push(i)}for(o=0;o-1}function _(e,t){var n=this.__data__,r=g(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}function y(e){var t=-1,n=e?e.length:0;for(this.clear();++t0){var r=this._metrics.extra.bitratesHistory[this._metrics.extra.bitratesHistory.length-1];r.end=n,r.time=n-r.start}this._metrics.extra.bitratesHistory.push({start:this._now(),bitrate:t}),this._inc("changeLevel")}},{key:"stopReporting",value:function(){this._buildReport(),clearInterval(this._intervalId),this._newMetrics(),this.stopListening(),this.bindEvents()}},{key:"startTimers",value:function(){this._intervalId=setInterval(this._buildReport.bind(this),this._runEach),this._start("session"),this._start("startup")}},{key:"onFirstPlaying",value:function(){this.listenTo(this.container,c.Events.CONTAINER_TIMEUPDATE,this.onContainerUpdateWhilePlaying),this._start("watch"),this._stop("startup")}},{key:"playAfterPause",value:function(){this.listenTo(this.container,c.Events.CONTAINER_TIMEUPDATE,this.onContainerUpdateWhilePlaying),this._stop("pause"),this._start("watch")}},{key:"onPlay",value:function(){this._inc("play")}},{key:"onPause",value:function(){this._stop("watch"),this._start("pause"),this._inc("pause"),this.listenToOnce(this.container,c.Events.CONTAINER_PLAY,this.playAfterPause),this.stopListening(this.container,c.Events.CONTAINER_TIMEUPDATE,this.onContainerUpdateWhilePlaying)}},{key:"onSeek",value:function(e){this._inc("seek"),this._metrics.extra.watchHistory.push([1e3*e,1e3*e])}},{key:"onTimeUpdate",value:function(e){var t=1e3*e.current,n=1e3*e.total,r=this._metrics.extra.watchHistory.length;if(this._metrics.extra.duration=n,this._metrics.extra.currentTime=t,this._metrics.extra.watchedPercentage=t/n*100,0===r?this._metrics.extra.watchHistory.push([t,t]):this._metrics.extra.watchHistory[r-1][1]=t,this._metrics.extra.bitratesHistory.length>0){var i=this._metrics.extra.bitratesHistory[this._metrics.extra.bitratesHistory.length-1];i.end||(i.time=this._now()-i.start)}this._onCompletion()}},{key:"onContainerUpdateWhilePlaying",value:function(){this.container.playback.isPlaying()&&(this._stop("watch"),this._start("watch"))}},{key:"onBuffering",value:function(){this._inc("buffering"),this._start("buffering"),this.listenToOnce(this.container,c.Events.CONTAINER_STATE_BUFFERFULL,this.onBufferfull)}},{key:"onBufferfull",value:function(){this._stop("buffering"),this.listenToOnce(this.container,c.Events.CONTAINER_STATE_BUFFERING,this.onBuffering)}},{key:"onProgress",value:function(e){this._metrics.extra.buffersize=1e3*e.current}},{key:"_newMetrics",value:function(){this._metrics={counters:{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},extra:{playbackName:"",playbackType:"",bitratesHistory:[],bitrateWeightedMean:0,bitrateMostUsed:0,buffersize:0,watchHistory:[],watchedPercentage:0,bufferingPercentage:0,bandwidth:0,duration:0,currentTime:0}}}},{key:"_onCompletion",value:function(){var e=this._metrics.extra.watchedPercentage,n=this._completion.watch,r=-1!=this._completion.calls.indexOf(e);-1==n.indexOf(e)||r||(c.Log.info(this.name+" PERCENTAGE_EVENT: "+e),this._completion.calls.push(e),this.trigger(t.PERCENTAGE_EVENT,e))}},{key:"_buildReport",value:function(){this._stop("session"),this._start("session"),this._metrics.extra.playbackName=this._playbackName,this._metrics.extra.playbackType=this._playbackType,this._calculateBitrates(),this._calculatePercentages(),this._fetchFPS(),this._measureLatency(),this._measureBandwidth(),this.trigger(t.REPORT_EVENT,JSON.parse(JSON.stringify(this._metrics)))}},{key:"_fetchFPS",value:function(){var e={html5_video:this._html5FetchFPS,hls:this._html5FetchFPS,dash_shaka_playback:this._html5FetchFPS};e[this._playbackName]&&e[this._playbackName].call(this)}},{key:"_calculateBitrates",value:function(){var e=this._metrics.extra.bitratesHistory.map(function(e){return e.time}).reduce(function(e,t){return e+t},0);this._metrics.extra.bitrateWeightedMean=this._metrics.extra.bitratesHistory.map(function(e){return e.bitrate*e.time}).reduce(function(e,t){return e+t},0)/e,this._metrics.extra.bitratesHistory.length>0&&(this._metrics.extra.bitrateMostUsed=this._metrics.extra.bitratesHistory.slice().sort(function(e,t){return e.time0&&(this._metrics.extra.bufferingPercentage=this._metrics.timers.buffering/this._metrics.extra.duration*100)}},{key:"_html5FetchFPS",value:function(){var e=this.container.playback.el,t=e.webkitDecodedFrameCount||e.mozDecodedFrames||0,n=e.webkitDroppedFrameCount||e.mozParsedFrames-e.mozDecodedFrames||0,r=t-(this._lastDecodedFramesCount||0);this._metrics.counters.decodedFrames=t,this._metrics.counters.droppedFrames=n,this._metrics.counters.fps=r/(this._runEach/1e3),this._lastDecodedFramesCount=t}},{key:"_measureLatency",value:function(){var e=this;if(this._uriToMeasureLatency){var t,n=[],r=function(){t=n[2]-n[1],e._metrics.timers.latency=t};!function t(){if(n.push(e._now()),n.length>2)r();else{var i=new Image;i.onload=t,i.src=e._uriToMeasureLatency+"?"+Math.random()+"="+e._now()}}()}}},{key:"_measureBandwidth",value:function(){var e=this;if(this._urisToMeasureBandwidth&&this._bwMeasureCount%this._runBandwidthTestEvery==0){var t=0,n=function(n){var r=(e._urisToMeasureBandwidth[t-1].end-e._urisToMeasureBandwidth[t-1].start)/1e3,i=8*n.loaded/r;e._metrics.extra.bandwidth=i,e._urisToMeasureBandwidth.forEach(function(e){e.start=0,e.end=0,e.expired=!1,clearTimeout(e.timer)})};!function r(i){if(t>0&&(e._urisToMeasureBandwidth[t-1].end=e._now(),clearTimeout(e._urisToMeasureBandwidth[t-1].timer)),t>=e._urisToMeasureBandwidth.length||t>0&&e._urisToMeasureBandwidth[t-1].expired)n(i);else{var o=new XMLHttpRequest;o.open("GET",e._urisToMeasureBandwidth[t].url,!0),o.responseType="arraybuffer",o.onload=o.onabort=r,e._urisToMeasureBandwidth[t].start=e._now(),e._urisToMeasureBandwidth[t].timer=setTimeout(function(t){e._urisToMeasureBandwidth[t].expired=!0,o.abort()},e._urisToMeasureBandwidth[t].timeout,t),o.send()}t++}()}this._bwMeasureCount++}}]),t}(c.ContainerPlugin);t.default=d,d.REPORT_EVENT="clappr:stats:report",d.PERCENTAGE_EVENT="clappr:stats:percentage",e.exports=t.default},clappr:function(t,n){t.exports=e}})}); \ No newline at end of file diff --git a/package.json b/package.json index 9615f71..1343070 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clappr-stats", - "version": "0.1.3", + "version": "0.1.4", "description": "clappr playback stats report plugin", "main": "dist/clappr-stats.js", "repository": {