diff --git a/dist/videojs.ga.videocloud.js b/dist/videojs.ga.videocloud.js index 9a54697..27cab74 100644 --- a/dist/videojs.ga.videocloud.js +++ b/dist/videojs.ga.videocloud.js @@ -1,13 +1,16 @@ /* -* videojs-ga-videocloud - v0.4.2 - 2016-08-24 +* videojs-ga-videocloud - v0.4.2 - 2018-10-07 * Based on videojs-ga 0.4.2 -* Copyright (c) 2016 Michael Bensoussan +* Copyright (c) 2018 Michael Bensoussan * Licensed MIT */ (function() { - var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + var registerPlugin, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - videojs.plugin('ga', function(options) { + registerPlugin = videojs.registerPlugin || videojs.plugin; + + registerPlugin('ga', function(options) { var adStateRegex, currentVideo, dataSetupOptions, defaultLabel, defaultsEventsToTrack, end, endTracked, error, eventCategory, eventLabel, eventNames, eventsToTrack, fullscreen, getEventName, isInAdState, loaded, parsedOptions, pause, percentsAlreadyTracked, percentsPlayedInterval, play, player, referrer, resize, seekEnd, seekStart, seeking, sendbeacon, sendbeaconOverride, start, startTracked, timeupdate, tracker, trackerName, volumeChange, _this = this; if (options == null) { @@ -21,7 +24,7 @@ } player = this; dataSetupOptions = {}; - if (this.options()["data-setup"]) { + if (this.options_["data-setup"]) { parsedOptions = JSON.parse(this.options()["data-setup"]); if (parsedOptions.ga) { dataSetupOptions = parsedOptions.ga; diff --git a/dist/videojs.ga.videocloud.min.js b/dist/videojs.ga.videocloud.min.js index be332f3..7f94fab 100644 --- a/dist/videojs.ga.videocloud.min.js +++ b/dist/videojs.ga.videocloud.min.js @@ -1,7 +1,7 @@ /* -* videojs-ga-videocloud - v0.4.2 - 2016-08-24 +* videojs-ga-videocloud - v0.4.2 - 2018-10-07 * Based on videojs-ga 0.4.2 -* Copyright (c) 2016 Michael Bensoussan +* Copyright (c) 2018 Michael Bensoussan * Licensed MIT */ -(function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};videojs.plugin("ga",function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K;return null==b&&(b={}),y=document.createElement("a"),y.href=document.referrer,self!==top&&"preview-players.brightcove.net"===window.location.host&&"studio.brightcove.com"===y.hostname?void videojs.log("Google analytics plugin will not track events in Video Cloud Studio"):(x=this,e={},this.options()["data-setup"]&&(s=JSON.parse(this.options()["data-setup"]),s.ga&&(e=s.ga)),g=["player_load","video_load","percent_played","start","end","seek","play","pause","resize","volume_change","error","fullscreen"],n=b.eventsToTrack||e.eventsToTrack||g,v=b.percentsPlayedInterval||e.percentsPlayedInterval||10,k=b.eventCategory||e.eventCategory||"Brightcove Player",f=b.eventLabel||e.eventLabel,E=b.sendbeaconOverride||!1,b.debug=b.debug||!1,b.trackerName=b.trackerName||null,J="","string"==typeof b.trackerName&&(J=b.trackerName+"."),u=[],G=!1,i=!1,B=A=0,C=!1,l="",d="",m={video_load:"Video Load",percent_played:"Percent played",start:"Media Begin",seek_start:"Seek start",seek_end:"Seek end",play:"Media Play",pause:"Media Pause",error:"Error",fullscreen_exit:"Fullscreen Exited",fullscreen_enter:"Fullscreen Entered",resize:"Resize",volume_change:"Volume Change",player_load:"Player Load",end:"Media Complete"},p=function(a){return b.eventNames&&b.eventNames[a]?b.eventNames[a]:e.eventNames&&e.eventNames[a]?e.eventNames[a]:m[a]?m[a]:a},("players.brightcove.net"===window.location.host||"preview-players.brightcove.net"===window.location.host||""!==J)&&(I=b.tracker||e.tracker,I&&(!function(a,b,c,d,e,f,g){return a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){return(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create",I,"auto",b.trackerName),ga(J+"require","displayfeatures"))),c=/(\s|^)vjs-ad-(playing|loading)(\s|$)/,q=function(a){return c.test(a.el().className)},r=function(){q(x)||(l=f?f:x.mediainfo&&x.mediainfo.id?x.mediainfo.id+" | "+x.mediainfo.name:this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,""),x.mediainfo&&x.mediainfo.id&&x.mediainfo.id!==d&&(d=x.mediainfo.id,u=[],G=!1,i=!1,B=A=0,C=!1,a.call(n,"video_load")>=0&&D(p("video_load"),!0)))},H=function(){var b,c,d,e,f;if(!q(x)){for(b=Math.round(this.currentTime()),c=Math.round(this.duration()),e=Math.round(b/c*100),d=f=0;99>=f;d=f+=v)e>=d&&a.call(u,d)<0&&(a.call(n,"percent_played")>=0&&0!==e&&D(p("percent_played"),!0,d),e>0&&u.push(d));a.call(n,"seek")>=0&&(B=A,A=b,Math.abs(B-A)>1&&(C=!0,D(p("seek_start"),!1,B),D(p("seek_end"),!1,A)))}},h=function(){q(x)||i||(D(p("end"),!0),i=!0)},w=function(){var a;q(x)||(a=Math.round(this.currentTime()),D(p("play"),!0,a),C=!1)},F=function(){return!q(x)&&a.call(n,"start")>=0&&!G?(D(p("start"),!0),G=!0):void 0},t=function(){var a,b;q(x)||(a=Math.round(this.currentTime()),b=Math.round(this.duration()),a===b||C||D(p("pause"),!0,a))},K=function(){var a;a=this.muted()===!0?0:this.volume(),D(p("volume_change"),!1,a)},z=function(){D(p("resize")+" - "+this.width()+"*"+this.height(),!0)},j=function(){var a;a=Math.round(this.currentTime()),D(p("error"),!0,a)},o=function(){var a;a=Math.round(this.currentTime()),this.isFullscreen()?D(p("fullscreen_enter"),!1,a):D(p("fullscreen_exit"),!1,a)},D=function(a,c,d){E?E(k,a,l,d,c):window.ga?ga(J+"send","event",{eventCategory:k,eventAction:a,eventLabel:l,eventValue:d,nonInteraction:c}):window._gaq?_gaq.push(["_trackEvent",k,a,l,d,c]):b.debug&&videojs.log("Google Analytics not detected")},this.ready(function(){var b,c;return this.on("loadedmetadata",r),this.on("timeupdate",H),a.call(n,"end")>=0&&this.on("ended",h),a.call(n,"play")>=0&&this.on("play",w),a.call(n,"start")>=0&&this.on("playing",F),a.call(n,"pause")>=0&&this.on("pause",t),a.call(n,"volume_change")>=0&&this.on("volumechange",K),a.call(n,"resize")>=0&&this.on("resize",z),a.call(n,"error")>=0&&this.on("error",j),a.call(n,"fullscreen")>=0&&this.on("fullscreenchange",o),a.call(n,"player_load")>=0?(self!==top?(b=document.referrer,c=1):(b=window.location.href,c=0),E?E(k,p("player_load"),b,c,!0):window.ga?ga(J+"send","event",{eventCategory:k,eventAction:p("player_load"),eventLabel:b,eventValue:c,nonInteraction:!0}):window._gaq?_gaq.push(["_trackEvent",k,p("player_load"),b,c,!1]):videojs.log("Google Analytics not detected")):void 0}),{sendbeacon:D})})}).call(this); \ No newline at end of file +(function(){var $=[].indexOf||function(e){for(var t=0,n=this.length;t +registerPlugin = videojs.registerPlugin || videojs.plugin; + +registerPlugin 'ga', (options = {}) -> referrer = document.createElement('a') referrer.href = document.referrer @@ -18,7 +20,7 @@ videojs.plugin 'ga', (options = {}) -> # this loads options from the data-setup attribute of the video tag dataSetupOptions = {} - if @options()["data-setup"] + if @options_["data-setup"] parsedOptions = JSON.parse(@options()["data-setup"]) dataSetupOptions = parsedOptions.ga if parsedOptions.ga