Skip to content

Commit

Permalink
Analytics event tracking (#296)
Browse files Browse the repository at this point in the history
* Low-barrier platform instrumentation/tracking using Google Analytics events

* Fixed logs/console/edit/help/config event tracking
  • Loading branch information
bodom0015 authored Jun 8, 2020
1 parent 02a14a6 commit 76a2e74
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions gui/dashboard/catalog/CatalogController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -157,6 +158,7 @@ angular
var htmlString = '<a href="' + quickstartUrl + '">Try ' + spec.label + '</a>';
console.log("Copying to clipboard:", htmlString);
clipboard.copyText(htmlString);
Analytics.trackEvent('application', 'share-embed', spec.key, 1, true);
};

$scope.cloneSpec = function(spec) {
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions gui/dashboard/dashboard/DashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
})
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions gui/dashboard/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ <h4>
{{ svc.service | specProperty:'label' }}
<a ng-repeat="endpt in svc.endpoints track by endpt.port" id="endpointLink"
uib-tooltip="Navigate to {{ svc.service | capitalize }} port {{ endpt.port }}"
ga-event-track="['application', 'endpoint', svc.key]"
ng-if="stack.status === 'started' && svc.status === 'ready'
&& endpt !== '' && ((stack.key | specProperty:'access') === 'external') && (endpt.protocol === 'http')" target="_blank"
ng-href="{{ endpt | externalHostPort }}"
Expand All @@ -132,6 +133,7 @@ <h4>
<!-- Console -->
<td class="text-center">
<a id="consoleBtn"
ga-track-event="['application', 'console', svc.service, 1, true]"
type="button" class="btn btn-default btn-xs" target="_blank" ng-href="/dashboard/home/{{ stack.id }}/console/{{ svc.service }}"
ng-disabled="svc.status !== 'ready'">
<i class="fa fa-terminal"></i>
Expand All @@ -142,7 +144,7 @@ <h4>
<td class="text-center">
<!-- ng-click="showConfig(svc)" -->
<a id="editServiceBtn" type="button" class="btn btn-default btn-xs" ng-href="/dashboard/home/{{ stack.id }}/edit/{{ svc.service }}"
ng-if="stack.status === 'stopped'">
ng-if="stack.status === 'stopped'" ga-track-event="['application', 'edit', svc.service, 1, true]">
<i class="fa fa-wrench"></i>
</a>

Expand Down Expand Up @@ -172,7 +174,7 @@ <h4>
</td>

<!-- Help Link -->
<td class="text-center"><a id="helpLink" ng-if="svc.service | specProperty:'info'" ng-href="{{ svc.service | specProperty:'info' }}" target="_blank"><i class="fa fa-fw fa-question-circle"></i></a></td>
<td class="text-center"><a id="helpLink" ng-if="svc.service | specProperty:'info'" ng-href="{{ svc.service | specProperty:'info' }}" target="_blank" ga-track-event="['application', 'help', svc.service, 1, true]"><i class="fa fa-fw fa-question-circle"></i></a></td>
</tr>

<!-- Add an artificial row (if necessary) for optional services -->
Expand Down

0 comments on commit 76a2e74

Please sign in to comment.