diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c6a7d3b..d2e3e537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -613,6 +613,11 @@ set(lspSOURCES ${SOURCE_DIR}/lsp/minified.js ) + +if (NOT DEFINED NOGA ) + list(APPEND lspSOURCES ${SOURCE_DIR}/lsp/analytics.js) +endif() + add_custom_command(OUTPUT ${BINARY_DIR}/generated/server.html COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR="${SOURCE_DIR}" -DlspSOURCES="${lspSOURCES}" -P ${SOURCE_DIR}/CMakeServHtml.txt DEPENDS ${lspSOURCES} ${SOURCE_DIR}/CMakeServHtml.txt ${SOURCE_DIR}/lsp/main.css ${SOURCE_DIR}/lsp/header.html ${SOURCE_DIR}/lsp/footer.html diff --git a/lsp/analytics.js b/lsp/analytics.js new file mode 100644 index 00000000..6fb2e971 --- /dev/null +++ b/lsp/analytics.js @@ -0,0 +1,14 @@ + +//Google analytics. Can be fully disabled on request (or, if compiling yourself, add the NOGA=1 cmake flag). +//Is also disabled if the browser has the do not track flag setting turned on. +var oldTab = UI.showTab; +UI.showTab = function(){ +  var r = oldTab.apply(this,arguments); +  if ((!navigator.doNotTrack) && (mist.user.loggedin)) { +    UI.elements.main.append( +      $("").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+arguments[0])+"&dh=MI."+(mist.data.LTS ? "Pro" : "OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1,position:"absolute",left:"-1000px"}) +    ); +  } +  return r; +}; + diff --git a/lsp/minified.js b/lsp/minified.js index 2167fabe..804fd180 100644 --- a/lsp/minified.js +++ b/lsp/minified.js @@ -202,8 +202,7 @@ mist.data.capabilities.cpu[h],f.content.push({header:"CPU #"+(Number(h)+1),body: {capabilities:true})},3E4);break;case "Email for Help":h=$.extend({},mist.data);delete h.statistics;delete h.totals;delete h.clients;delete h.capabilities;h=JSON.stringify(h);h="Version: "+mist.data.config.version+"\n\nConfig:\n"+h;n={};d.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.
A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:n,index:"name"}, value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:h,pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send", "function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:n,success:function(a){a=$("").html(a);a.find("script").remove();d.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:d.append($("

").text("This tab does not exist."))}d.find(".field").filter(function(){var a=$(this).getval(); -return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}});!navigator.doNotTrack&&mist.user.loggedin&&d.append($("").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+a)+"&dh=MI."+(mist.data.LTS?"Pro":"OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1, -position:"absolute",left:"-1000px"}))}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; +return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));var e={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e= $("").text("The connection timed out. ");break;case "abort":e=$("").text("The connection was aborted. ");break;default:e=$("").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("
")).append($("").text(e)).append($("").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(e){log("Receive",$.extend(true,{},e),"as reply to", d.sendData);delete mist.user.loggedin;switch(e.authorize.status){case "OK":if("streams"in e)if(e.streams)if("incomplete list"in e.streams){delete e.streams["incomplete list"];$.extend(mist.data.streams,e.streams)}else mist.data.streams=e.streams;else mist.data.streams={};var g=$.extend({},e),h=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],o;for(o in g)h.indexOf(o)==-1&&delete g[o];if("bandwidth"in b&&!("bandwidth"in e))g.bandwidth=null;$.extend(mist.data, diff --git a/lsp/mist.js b/lsp/mist.js index fdf1d43f..95b99396 100644 --- a/lsp/mist.js +++ b/lsp/mist.js @@ -5865,13 +5865,6 @@ var UI = { return false; } }); - - if ((!navigator.doNotTrack) && (mist.user.loggedin)) { - ///GA tracking; only if connected - $main.append( - $("").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+tab)+"&dh=MI."+(mist.data.LTS ? "Pro" : "OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1,position:"absolute",left:"-1000px"}) - ); - } } };