diff --git a/analytics.js b/analytics.js index 07ea7184f..54c7ee1ae 100644 --- a/analytics.js +++ b/analytics.js @@ -1,8 +1,18 @@ -/** - * Google Analytics - */ -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-319188-14', 'jit.si'); - ga('send', 'pageview'); \ No newline at end of file +(function (ctx) { + function Analytics() { + /** + * Google Analytics + */ + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); + ga('create', 'UA-319188-14', 'jit.si'); + ga('send', 'pageview'); + } + + Analytics.prototype.sendEvent = function (action, data) { + ga('send', 'event', 'jit.si', action); + }; + + ctx.Analytics = Analytics; +}(window)); \ No newline at end of file diff --git a/modules/UI/toolbars/BottomToolbar.js b/modules/UI/toolbars/BottomToolbar.js index 330c8c747..0cf0f9a7a 100644 --- a/modules/UI/toolbars/BottomToolbar.js +++ b/modules/UI/toolbars/BottomToolbar.js @@ -1,15 +1,19 @@ /* global $ */ var PanelToggler = require("../side_pannels/SidePanelToggler"); var UIUtil = require("../util/UIUtil"); +var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter"); var buttonHandlers = { "bottom_toolbar_contact_list": function () { + AnalyticsAdapter.sendEvent('bottomtoolbar.contacts.toggled'); BottomToolbar.toggleContactList(); }, "bottom_toolbar_film_strip": function () { + AnalyticsAdapter.sendEvent('bottomtoolbar.filmstrip.toggled'); BottomToolbar.toggleFilmStrip(); }, "bottom_toolbar_chat": function () { + AnalyticsAdapter.sendEvent('bottomtoolbar.chat.toggled'); BottomToolbar.toggleChat(); } }; diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js index c41d91c69..824a7050c 100644 --- a/modules/UI/toolbars/Toolbar.js +++ b/modules/UI/toolbars/Toolbar.js @@ -10,6 +10,7 @@ var Authentication = require("../authentication/Authentication"); var UIUtil = require("../util/UIUtil"); var AuthenticationEvents = require("../../../service/authentication/AuthenticationEvents"); +var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter"); var roomUrl = null; var sharedKey = ''; @@ -18,55 +19,87 @@ var recordingToaster = null; var buttonHandlers = { "toolbar_button_mute": function () { + if (APP.RTC.localAudio.isMuted()) { + AnalyticsAdapter.sendEvent('toolbar.audio.unmuted'); + } else { + AnalyticsAdapter.sendEvent('toolbar.audio.muted'); + } return APP.UI.toggleAudio(); }, "toolbar_button_camera": function () { + if (APP.RTC.localVideo.isMuted()) { + AnalyticsAdapter.sendEvent('toolbar.video.enabled'); + } else { + AnalyticsAdapter.sendEvent('toolbar.video.disabled'); + } return APP.UI.toggleVideo(); }, /*"toolbar_button_authentication": function () { return Toolbar.authenticateClicked(); },*/ "toolbar_button_record": function () { + AnalyticsAdapter.sendEvent('toolbar.recording.toggled'); return toggleRecording(); }, "toolbar_button_security": function () { + if (sharedKey) { + AnalyticsAdapter.sendEvent('toolbar.lock.disabled'); + } else { + AnalyticsAdapter.sendEvent('toolbar.lock.enabled'); + } return Toolbar.openLockDialog(); }, "toolbar_button_link": function () { + AnalyticsAdapter.sendEvent('toolbar.invite.clicked'); return Toolbar.openLinkDialog(); }, "toolbar_button_chat": function () { + AnalyticsAdapter.sendEvent('toolbar.chat.toggled'); return BottomToolbar.toggleChat(); }, "toolbar_button_prezi": function () { + AnalyticsAdapter.sendEvent('toolbar.prezi.clicked'); return Prezi.openPreziDialog(); }, "toolbar_button_etherpad": function () { + AnalyticsAdapter.sendEvent('toolbar.etherpad.clicked'); return Etherpad.toggleEtherpad(0); }, "toolbar_button_desktopsharing": function () { + if (APP.desktopsharing.isUsingScreenStream) { + AnalyticsAdapter.sendEvent('toolbar.screen.disabled'); + } else { + AnalyticsAdapter.sendEvent('toolbar.screen.enabled'); + } return APP.desktopsharing.toggleScreenSharing(); }, "toolbar_button_fullScreen": function() { + AnalyticsAdapter.sendEvent('toolbar.fullscreen.enabled'); UIUtil.buttonClick("#toolbar_button_fullScreen", "icon-full-screen icon-exit-full-screen"); return Toolbar.toggleFullScreen(); }, "toolbar_button_sip": function () { + AnalyticsAdapter.sendEvent('toolbar.sip.clicked'); return callSipButtonClicked(); }, "toolbar_button_dialpad": function () { + AnalyticsAdapter.sendEvent('toolbar.sip.dialpad.clicked'); return dialpadButtonClicked(); }, "toolbar_button_settings": function () { + AnalyticsAdapter.sendEvent('toolbar.settings.toggled'); PanelToggler.toggleSettingsMenu(); }, "toolbar_button_hangup": function () { + AnalyticsAdapter.sendEvent('toolbar.hangup'); return hangup(); }, "toolbar_button_login": function () { + AnalyticsAdapter.sendEvent('toolbar.authenticate.login.clicked'); Toolbar.authenticateClicked(); }, "toolbar_button_logout": function () { + AnalyticsAdapter.sendEvent('toolbar.authenticate.logout.clicked'); // Ask for confirmation messageHandler.openTwoButtonDialog( "dialog.logoutTitle", @@ -418,18 +451,18 @@ var Toolbar = (function (my) { * Opens the invite link dialog. */ my.openLinkDialog = function () { - var inviteAttreibutes; + var inviteAttributes; if (roomUrl === null) { - inviteAttreibutes = 'data-i18n="[value]roomUrlDefaultMsg" value="' + + inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' + APP.translation.translateString("roomUrlDefaultMsg") + '"'; } else { - inviteAttreibutes = "value=\"" + encodeURI(roomUrl) + "\""; + inviteAttributes = "value=\"" + encodeURI(roomUrl) + "\""; } messageHandler.openTwoButtonDialog("dialog.shareLink", null, null, '', + inviteAttributes + ' onclick="this.select();" readonly>', false, "dialog.Invite", function (e, v) { diff --git a/modules/statistics/AnalyticsAdapter.js b/modules/statistics/AnalyticsAdapter.js new file mode 100644 index 000000000..8492c1123 --- /dev/null +++ b/modules/statistics/AnalyticsAdapter.js @@ -0,0 +1,15 @@ +function NoopAnalytics() {} +NoopAnalytics.prototype.sendEvent = function () {}; + +function AnalyticsAdapter() { + var AnalyticsImpl = window.Analytics || NoopAnalytics; + this.analytics = new AnalyticsImpl(); +} + +AnalyticsAdapter.prototype.sendEvent = function (action, data) { + try { + this.analytics.sendEvent.apply(this.analytics, arguments); + } catch (ignored) {} +}; + +module.exports = new AnalyticsAdapter(); \ No newline at end of file