1/** 2 * Copyright (c) 2023 The Nuevodevel Team. All rights reserved. 3 * Events plugin for video.js 4 * Version 3.0.0 5 */ 6!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],t):e.videojsEventTracking=t(e.videojs)}(this,function(e){"use strict";e="default"in e?e.default:e;var t,i=null,n="",r={sessionId:"",videoId:"",videoTitle:"",category:"",pauseCount:0,resumeCount:0,watchedTime:0,seekCount:0,bufferDuration:0},o=function(e){if(!e.match(/^([0-9]{1,3}\.){3}[0-9]{1,3}$/))return!1;var t=e.split(".");for(let e of t){if(Number(e)>255)return!1}return!0},a=function(e,t=8){if("::"===(e=e.toLowerCase()))return!0;if(!e.match(/^([0-9a-f]{0,4}:?){2,8}$/))return!1;if(":"===e[e.length-1]&&":"!==e[e.length-2])return!1;if(e.split("::").length>2)return!1;if(1===e.split("::").length&&e.split(":").length!==t)return!1;if(2===e.split("::").length){var i=e.split("::")[1];i=i.split(":");for(let e=0;e<i.length-1;e++)if(""===i[e])return!1}return!0},s=function(e){var[t,i]=p(e);return a(t,6)&&o(i)},u=function(e,t,i="0"){for(;e.length<t;)e+=i;return e},d=function(e,t,i="0"){for(;e.length<t;)e=i+e;return e},l=function(e,t){for(var i=[];e.length>0;){var n=e.substring(0,t);i.push(n),e=e.substring(t)}return i},c=function(e){return Number(e).toString(2)},g=function(e){return parseInt(e,2)},f=function(e){return e.split(".").map(e=>d(c(e),8)).join("")},v=function(e){return e.toString(16)},p=function(e){var t=e.lastIndexOf(":"),i=e.substring(0,t),n=e.substring(t+1);return":"===i[i.length-1]&&(i+=":"),[i,n]},h=function(e){var[t,i]=p(e),[n,r]=t.split("::");for(n=n.split(":"),r=void 0!==r?r.split(":"):[];n.length+r.length<6;)n.push("0");var o=n.concat(r);for(let e=0;e<o.length;e++)0===o[e].length&&(o[e]="0");return o.map(e=>parseInt(e,16)).map(e=>d(c(e),16)).join("")+f(i)},y=function(e){return l(e,8).map(g).join(".")},m=function(e){return function(e){var t=e.split(":"),i=0,n=null,r=!1,o=0,a=null;for(let e=0;e<t.length;e++)r?"0"===t[e]?o++:(o>i&&(i=o,n=a),r=!1,o=0,a=null):"0"===t[e]&&(r=!0,o=1,a=e);return null!==a&&o>i&&(i=o,n=a),i<2?e:t.slice(0,n).join(":")+"::"+t.slice(n+i).join(":")}(l(e,16).map(g).map(v).join(":"))},b=function(e,t){var i=function(e){var[t,i]=e.split("::");for(t=t.split(":"),i=void 0!==i?i.split(":"):[];t.length+i.length<8;)t.push("0");var n=t.concat(i);for(let e=0;e<n.length;e++)0===n[e].length&&(n[e]="0");return n.map(e=>parseInt(e,16)).map(e=>d(c(e),16)).join("")}(e).substring(0,t),n=u(i,128);return m(n)},T=function(e,t){var i,n,r,o,a,s,d=h(e).substring(0,t),l=u(d,128);return n=(i=l).substring(0,96),r=i.substring(96),o=m(n),a=y(r),":"!==(s=o)[s.length-1]&&(s+=":"),s+a},I=function(e,t=24,i=24){if("string"!=typeof e)return null;var n=function(e){return o(e)?"IPv4":a(e)?"IPv6":s(e)?"IPv6_4":"None"}(e=e.trim().toLowerCase());return"IPv4"===n?function(e,t){var i=f(e).substring(0,t),n=u(i,32);return y(n)}(e,t):"IPv6"===n?b(e,i):"IPv6_4"===n?function(e){return s(e)&&(!h(e).substring(0,96).includes("1")||!h(e).substring(0,80).includes("1")&&!h(e).substring(80,96).includes("0"))}(e)?T(e,t+96):T(e,i):null};function k(e,t,n){if(""!==e.trackingUrl&&navigator.sendBeacon&&"undefined"!==e.trackingUrl&&void 0!==e.trackingUrl&&""!==i.label&&""!==t){n=JSON.stringify(n);var r={sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,event:t,value:n};navigator.sendBeacon(e.trackingUrl,JSON.stringify(r))}}function w(e,t){""===i.label&&(i.label=i.id);""!==i.label&&""!==e&&(window.gtag?window.gtag("event",e,{event_category:i.category,event_label:i.label,value:t,eventNonInteraction:!0}):window._ga?window.ga("send","event",i.category,e,i.label,t,{transport:"beacon"}
6):window._gaq?window._gaq.push(["_trackEvent",i.category,e,i.label,t,!0,{transport:"beacon"}]):window._paq&&window._paq.push(["trackEvent",i.category,e,i.label,t]))}var _=function(e){var o=this,a=0,s=0,u=0,d=0,l=0,c=0,g=0,f=[],v=0,p=!1,h=function(){var e={event:"summary",initialLoadTime:g,totalDuration:d,watchedDuration:l,pauseCount:s,seekCount:a,bufferCount:u,lastTime:v,bufferDuration:c,video_id:"",video_category:"Videos",video_label:"",analytics:p};e.watchedDuration>1&&(e.analytics&&w("watchedTime",e.watchedDuration),null!==i&&k(o,"watchedTime",e.watchedDuration)),a=0,s=0,u=0,d=0,l=0,c=0,g=0,v=0,f=[]};if("function"==typeof window.addEventListener){var y=!1,m=function(e){y||("pagehide"===e.type?(y=!0,h(),i=null,n=""):"pageshow"===e.type&&clearTimeout(t),"visibilitychange"===e.type&&"hidden"===document.visibilityState&&(t=setTimeout(function(){h(),i=null,n=""},1e4)))};document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",m),window.addEventListener("beforeunload",function(e){h(),i=null,n=""})}o.on("ended",function(){var e={event:"summary",initialLoadTime:g,totalDuration:d,watchedTime:l,pauseCount:s,seekCount:a,bufferCount:u,lastTime:v,bufferDuration:c,video_id:"",video_category:"Videos",video_label:"",analytics:p,sessionId:i.uid};o&&o.trigger("track",e)}),o.on("dispose",function(){h(),i=null,n=""}),o.on("timeupdate",function(){var e=+o.currentTime().toFixed(0);0!==e&&(f.indexOf(e)<0&&f.push(e),l=f.length,i.watchedDuration=f.length,v=o.currentTime().toFixed(0),r.watchedTime=l)}),o.on("loadeddata",function(e,t){d=+o.duration().toFixed(0)}),o.on("track",function(e,t){switch(t.event){case"seek":a=t.seekCount;break;case"pause":s=t.pauseCount;break;case"buffered":u=t.bufferCount,c+=parseFloat(t.bufferTime),r.bufferDuration=c;break;case"loaded":g=t.initialLoadTime;break;case"start":o.analytics&&(p=!0)}})},x=function(e){this.on("dispose",function(){i={}}),this.on("loadeddata",function(){null!==i&&i.watchedDuration>1&&(this.analytics&&w("watchedTime",i.watchedDuration),k(this,"watchedTime",i.watchedDuration)),i={}}),this.on("playing",function(){clearTimeout(t);if(n!==this.currentSource()){if(n=this.currentSource(),null!==i){if(i.id&&"function"==typeof this.video_id&&i.id.length>0&&i.id===this.video_id())return void(r.videoId=i.id);if(i.label&&"function"==typeof this.video_title&&i.label.length>0&&i.label===this.video_title())return void(r.videoTitle=i.label)}i={},void 0!==this.trackingUrl?i.trackingUrl=this.trackingUrl:i.trackingUrl="";var e=Date.now();i.uid=r.sessionId=e,"function"==typeof this.video_title&&this.video_title()&&(i.label=r.videoTitle=this.video_title()),"function"==typeof this.video_id&&this.video_id()&&(i.id=r.videoId=this.video_id());var o=this.el_.className;i.category="Video",this.isAudio()&&(i.category="Audio"),o.indexOf("vjs-live")>-1&&(i.category="Live video"),r.category=i.category,this.trigger("track",{event:"firstPlay",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,initialPlayTime:this.currentTime().toFixed(0)}),k(this,"firstPlay",this.currentTime().toFixed(0)),function(e){var t="//ipapi.co/json/";if(e.abstractApiKey)var t="//ipgeolocation.abstractapi.com/v1/?api_key="+e.abstractApiKey;else if(e.ipdataApiKey)var t="//api.ipdata.co?api-key="+e.ipdataApiKey;!function(t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState&&200===r.status&&r.responseText){var t=r.responseText;t=JSON.parse(t);var n={ip_address:"Unknown",country:"N/A",country_code:"N/A",city:"N/A",region:"N/A"};Object.entries(t).forEach(e=>{const[t,i]=e;n[t]=i}),n.ip&&(n.ip_address=n.ip),n.country_name&&(n.country=n.country_name),t.ip_address&&(e.anonymizeIP?t.ip_address=I(t.ip_address):t.ip_address=t.ip_address),n.browser=-1!==navigator.userAgent.indexOf("Chrome")?"Google Chrome":-1!==navigator.userAgent.indexOf("Firefox")?"Mozilla Firefox":-1!==navigator.userAgent.indexOf("MSIE")?"Internet Exploder":-1!==navigator.userAgent.indexOf("Edge")?"Edge":-1!==navigator.userAgent.indexOf("Safari")?"Safari":-1!==navigator.userAgent.indexOf("Opera")?"Opera":-1!==navigator.userAgent.indexOf("YaBrowser")?"Yandex":"Other",n.device="undefined"!==window.orientation&&void 0!==window.orientation?"Mobile":"Desktop",i.userInfo=n,k(e,"user",i.userInfo),e.trigger("track",{event:"user",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,userInfo:n})}},r.open("GET",t,!0),r.send(null)}(t)}(this),this.analytics&&w("firstPlay",this.currentTime().toFixed(0))}})},C={analytics:!1,trackingUrl:void 0,abstractApiKey:void 0,ipdataApiKey:void 0,anonymizeIP:!1,base64:!1},A=function(n){try{n=e.obj.merge(C,n)}catch(t){n=e.mergeOtions(C,n)}this.analytics=n.analytics,this.anonymizeIP=n.anonymizeIP,this.abstractApiKey=n.abstractApiKey,this.ipdataApiKey=n.ipdataApiKey,this.trackingUrl=n.trackingUrl,this.base64=n.base64,this.get
6Summary=function(){return r},function(e){var t=this,n=0,o=null,a=!1,s=function(e){o&&clearTimeout(o),n=0,a=!1};t.on("dispose",s),t.on("loadstart",s),t.on("pause",function(){t.scrubbing()||t.seeking()||a||(o=setTimeout(function(){n++,r.pauseCount=n,t.trigger("track",{event:"pause",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,pauseCount:n})},300))})}.apply(this,arguments),function(e){var n=this,o=0,a=null,s=!1,u=function(e){a&&clearTimeout(a),o=0,s=!1};n.on("dispose",u),n.on("loadstart",u),n.on("ended",u),n.on("play",function(){n.scrubbing()||n.seeking()||s||n.currentTime()<1||(clearTimeout(t),a=setTimeout(function(){o++,r.resumeCount=o,n.trigger("track",{event:"resume",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,resumeCount:o})},300))})}.apply(this,arguments),function(e){var t=this;t.on("volumechange",function(){t.currentTime()>1&&(t.muted()&&t.trigger("track",{event:"mute",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label}),!0!==t.muted()&&t.trigger("track",{event:"unmute",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label}))})}.apply(this,arguments),function(e){var t=this;
6t.on("ratechanged",function(e,n){n.oldRate!==n.newRate&&t.trigger("track",{event:"rateChange",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,rate:n.newRate})})}.apply(this,arguments),function(e){var t=this,n=null,r=!1,o=!1,a=!1,s=0;this.on("loadstart",function(){n&&clearTimeout(n),r=!1,o=!1,a=!1,s=0}),this.on("pause",function(){a=!1,!t.scrubbing()||e.bufferingConfig&&e.bufferingConfig.includeScrub||(r=!0,n=setTimeout(function(){r=!1},200))}),this.on("waiting",function(){!1===a&&!1===r&&t.currentTime()>0&&(a=new Date,o=+t.currentTime().toFixed(2))}),this.on("timeupdate",function(){var e=+t.currentTime().toFixed(2);if(a&&e!==o){var n=(new Date-a)/1e3;a=!1,o=!1,s++,t.trigger("track",{event:"buffered",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,bufferTime:n.toFixed(3),bufferCount:s})}})}.apply(this,arguments),function(e){var t=this,n=!1,r=!1,o=!1,a=!0,s=!1,u=!0,d=!1,l=!0,c=!1,g=!0,f=0,v=0,p=0,h=0,y=function(e){n=!1,r=!0,o=!1,a=!0,s=!1,u=!0,d=!1,l=!0,c=!1,g=!0,f=0,v=0,p=0,h=0};t.on("dispose",y),t.on("loadstart",y),t.on("tracking:pause",function(){return v++}),t.on("tracking:resume",function(){return p++}),t.on("tracking:seek",function(){return h++}),t.on("timeupdate",function(){var e=t.currentTime().toFixed(0);f=+t.duration().toFixed(0),null!==i&&(n>0&&e>n&&e<s&&!1!==r&&(r=!1,t.trigger("track",{event:"10%",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,currentTime:e,duration:f}),t.analytics&&w("10%",n),k(t,"progress","10%")),s>0&&e>s&&e<d&&!1!==u&&(u=!1,t.trigger("track",{event:"25%",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,currentTime:e,duration:f}),t.analytics&&w("25%",s),k(t,"progress","25%")),d>0&&e>d&&e<c&&!1!==l&&(l=!1,t.trigger("track",{event:"50%",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,currentTime:e,duration:f}),t.analytics&&w("50%",d),k(t,"progress","50%")),c>0&&e>c&&e<o&&!1!==g&&(g=!1,t.trigger("track",{event:"75%",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,currentTime:e,duration:f}),t.analytics&&w("75%",c),k(t,"progress","75%")),o>0&&e>o&&!1!==a&&(a=!1,t.trigger("track",{event:"90%",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,currentTime:e,duration:f}),t.analytics&&w("90%",o),k(t,"progress","90%")))}),t.on("replay",function(){null!==i&&(this.trigger("track",{event:"replay",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label}),this.analytics&&w("replay",null),null!==i&&k(t,"replay",null))}),t.on("loadeddata",function(){if((f=+t.duration().toFixed(0))>0){var e=(f/4).toFixed(0),i=(f/10).toFixed(0),r=(.9*f).toFixed(0);o=+r,n=+i,s=+e,d=2*+e,c=3*+e}}),t.on("ended",function(){var e=this.duration();this.el_.className.indexOf("vjs-live")>-1&&(e=0),this.trigger("track",{event:"ended",sessionId:i.uid,videoId:i.id,category:i.category,videoTitle:i.title,duration:e}),this.analytics&&w("completed",e),null!==i&&k(this,"completed",e)}),t.on("fullscreenchange",function(){this.isFullscreen()?(this.trigger("track",{event:"enterFullscreen",sessionId:i.uid,videoId:i.id,category:i.category,videoTitle:i.label,mode:"on"}),this.analytics&&w("fullscreen",1),null!==i&&k(this,"fullscreen",1)):(this.trigger("track",{event:"exitFullscreen",sessionId:i.uid,videoId:i.id,category:i.category,videoTitle:i.label,mode:"on"}),this.analytics&&w("fullscreen",0),null!==i&&k(this,"fullscreen",0))})}.apply(this,arguments),x.apply(this,arguments),function(e){var t=this;if(!(t.el_.className.indexOf("vjs-live")>-1)){var n=0,o=0,a=function(){n=0,o=0};t.on("dispose",a),t.on("loadstart",a);var s=t.el().querySelector(".vjs-progress-holder");s.onmouseup=s.ontouchend=function(){o=t.currentTime().toFixed(2),n++,r.seekCount=n,setTimeout(function(){t.trigger("track",{event:"seek",sessionId:i.uid,videoId:i.id,category:i.category,videoTitle:i.label,seekTo:o,seekCount:n})},200)}}}.apply(this,arguments),_.apply(this,arguments),function(e){var t=this;t.on("resolutionchange",function(e,n){t.trigger("track",{event:"resolutionChange",sessionId:i.uid,category:i.category,videoId:i.id,videoTitle:i.label,resolution:n.res})})}.apply(this,arguments)},F=e.registerPlugin||e.plugin;return void 0===(e.getPlugin||e.plugin)("events")&&F("events",A),A.VERSION="2.0.0",A});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.