Skip to content

Commit

Permalink
adds events and google anlytics tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Jun 2, 2017
1 parent e344587 commit 0038cc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opal/static/js/opal/controllers/edit_item.js
@@ -1,7 +1,7 @@
angular.module('opal.controllers').controller(
'EditItemCtrl', function($scope, $timeout,
$modalInstance, $modal, $q,
ngProgressLite,
ngProgressLite, $analytics,
referencedata, metadata,
profile, item, episode) {
$scope.profile = profile;
Expand All @@ -19,6 +19,10 @@ angular.module('opal.controllers').controller(
return !_.isUndefined($scope.editing[item.columnName].id);
};

$analytics.eventTrack(item.columnName, {
category: "EditItem", label: episode.category_name
});

// This is the patient name displayed in the modal header
$scope.editingName = episode.getFullName();

Expand Down
10 changes: 10 additions & 0 deletions opal/static/js/test/edit_item.controller.test.js
Expand Up @@ -5,6 +5,7 @@ describe('EditItemCtrl', function (){
var item, Item, existingEpisode;
var dialog, Episode, episode, ngProgressLite, $q, $rootScope;
var Schema, $controller, controller, fakeModalInstance;
var $analytics;

var referencedata = {
dogs: ['Poodle', 'Dalmation'],
Expand Down Expand Up @@ -36,6 +37,7 @@ describe('EditItemCtrl', function (){
var episodeData = {
id: 123,
active: true,
category_name: "Inpatient",
prev_episodes: [],
next_episodes: [],
demographics: [{
Expand Down Expand Up @@ -122,6 +124,7 @@ describe('EditItemCtrl', function (){
module(function($provide) {
$provide.value('UserProfile', {load: function(){ return profile; }});
});
$analytics = jasmine.createSpyObj(["eventTrack"]);

inject(function($injector){
Item = $injector.get('Item');
Expand Down Expand Up @@ -163,6 +166,7 @@ describe('EditItemCtrl', function (){
episode : episode,
ngProgressLite: ngProgressLite,
referencedata: referencedata,
$analytics: $analytics
});

});
Expand All @@ -177,6 +181,12 @@ describe('EditItemCtrl', function (){
it('Should hoist metadata onto the scope', function () {
expect($scope.metadata).toBe(metadata);
});

it('should track analytics data', function(){
expect($analytics.eventTrack).toHaveBeenCalledWith(
"investigation", {category: "EditItem", label: "Inpatient"}
);
});
})

describe('editingMode()', function() {
Expand Down

0 comments on commit 0038cc1

Please sign in to comment.