From 76a2e7449d1e609d0d1a09b81c5715fdcd436f6c Mon Sep 17 00:00:00 2001 From: Mike Lambert Date: Mon, 8 Jun 2020 11:52:09 -0500 Subject: [PATCH] Analytics event tracking (#296) * Low-barrier platform instrumentation/tracking using Google Analytics events * Fixed logs/console/edit/help/config event tracking --- gui/dashboard/catalog/CatalogController.js | 8 ++++++-- gui/dashboard/dashboard/DashboardController.js | 12 ++++++++++-- gui/dashboard/dashboard/dashboard.html | 6 ++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/gui/dashboard/catalog/CatalogController.js b/gui/dashboard/catalog/CatalogController.js index 5f277272..7e830ddd 100644 --- a/gui/dashboard/catalog/CatalogController.js +++ b/gui/dashboard/catalog/CatalogController.js @@ -22,9 +22,9 @@ angular * @author lambert8 * @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views */ -.controller('CatalogController', [ '$scope', '$filter', '$interval', '$uibModal', '$location', '$log', '_', 'NdsLabsApi', 'Project', 'Stack', 'Stacks', +.controller('CatalogController', [ '$scope', '$filter', '$interval', '$uibModal', '$location', '$log', '_', 'Analytics', 'NdsLabsApi', 'Project', 'Stack', 'Stacks', 'StackService', 'Specs', 'clipboard', 'Vocabulary', 'RandomPassword', 'AuthInfo', 'ProductName', 'ApiUri', 'DashboardAppPath', 'HomePathSuffix', - function($scope, $filter, $interval, $uibModal, $location, $log, _, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, ProductName, ApiUri, DashboardAppPath, HomePathSuffix) { + function($scope, $filter, $interval, $uibModal, $location, $log, _, Analytics, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, ProductName, ApiUri, DashboardAppPath, HomePathSuffix) { "use strict"; $scope.productName = ProductName; @@ -145,6 +145,7 @@ angular var quickstartUrl = getQuickStartUrl(spec); console.log("Copying to clipboard:", quickstartUrl); clipboard.copyText(quickstartUrl); + Analytics.trackEvent('application', 'share-url', spec.key, 1, true); }; $scope.shareEmbed = function(spec) { @@ -157,6 +158,7 @@ angular var htmlString = 'Try ' + spec.label + ''; console.log("Copying to clipboard:", htmlString); clipboard.copyText(htmlString); + Analytics.trackEvent('application', 'share-embed', spec.key, 1, true); }; $scope.cloneSpec = function(spec) { @@ -250,6 +252,8 @@ angular // Install this app to etcd return NdsLabsApi.postStacks({ 'stack': app }).then(function(stack, xhr) { $log.debug("successfully posted to /projects/" + projectId + "/stacks!"); + + Analytics.trackEvent('application', 'add', spec.key, 1, true); // Add /the new stack to the UI Stacks.all.push(stack); diff --git a/gui/dashboard/dashboard/DashboardController.js b/gui/dashboard/dashboard/DashboardController.js index a08946f6..c01d769c 100755 --- a/gui/dashboard/dashboard/DashboardController.js +++ b/gui/dashboard/dashboard/DashboardController.js @@ -9,9 +9,9 @@ angular * @author lambert8 * @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views */ -.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AutoRefresh', 'AuthInfo', +.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Analytics', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AutoRefresh', 'AuthInfo', 'StackService', 'NdsLabsApi', 'ProductName', 'FileManager', 'QuickStart', - function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Project, RandomPassword, Stack, Stacks, Specs, AutoRefresh, AuthInfo, StackService, NdsLabsApi, + function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Analytics, Project, RandomPassword, Stack, Stacks, Specs, AutoRefresh, AuthInfo, StackService, NdsLabsApi, ProductName, FileManager, QuickStart) { "use strict"; @@ -79,6 +79,7 @@ angular 'stackId': stack.id }).then(function(data, xhr) { $log.debug('successfully started ' + stack.name); + Analytics.trackEvent('application', 'launch', stack.key, 1, true); }, function(headers) { $log.error('failed to start ' + stack.name); }).finally(function() { @@ -129,6 +130,7 @@ angular 'stackId': stack.id }).then(function(data, xhr) { $log.debug('successfully stopped ' + stack.name); + Analytics.trackEvent('application', 'shutdown', stack.key, 1, true); }, function(headers) { $log.error('failed to stop ' + stack.name); }) @@ -166,6 +168,8 @@ angular * @param {} service - the service to show logs for */ $scope.showLogs = function(service) { + Analytics.trackEvent('application', 'logs', service.service, 1, true); + // See 'app/dashboard/modals/logViewer/logViewer.html' $uibModal.open({ animation: true, @@ -186,6 +190,8 @@ angular * @param {} service - the service to show logs for */ $scope.showConfig = function(service) { + Analytics.trackEvent('application', 'config', service.service, 1, true); + // See 'app/dashboard/modals/logViewer/logViewer.html' $uibModal.open({ animation: true, @@ -248,6 +254,8 @@ angular 'stackId': stack.id }).then(function(data, xhr) { $log.debug('successfully deleted stack: ' + stack.name); + Analytics.trackEvent('application', 'delete', stack.key, 1, true); + Loading.set(Stacks.populate()); }, function(headers) { $log.error('failed to delete stack: ' + stack.name); diff --git a/gui/dashboard/dashboard/dashboard.html b/gui/dashboard/dashboard/dashboard.html index a3e7afe8..a776b324 100755 --- a/gui/dashboard/dashboard/dashboard.html +++ b/gui/dashboard/dashboard/dashboard.html @@ -118,6 +118,7 @@

{{ svc.service | specProperty:'label' }} @@ -142,7 +144,7 @@

+ ng-if="stack.status === 'stopped'" ga-track-event="['application', 'edit', svc.service, 1, true]"> @@ -172,7 +174,7 @@

- +