Skip to content

Commit

Permalink
Fixed Segment Bug
Browse files Browse the repository at this point in the history
The unclear naming of JS properties has been clarified to avoid confusion with userId, userName, and name.
  • Loading branch information
clintonb committed Dec 12, 2014
1 parent 3e9cd9c commit 472019c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions analytics_dashboard/courses/views.py
Expand Up @@ -87,9 +87,9 @@ def get_context_data(self, **kwargs):
'courseId': self.course_id
},
'user': {
'userId': user.get_username(),
'userName': user.get_full_name(),
'userEmail': user.email,
'username': user.get_username(),
'name': user.get_full_name(),
'email': user.email,
'ignoreInReporting': self._ignore_in_reporting(user)
},
})
Expand Down
30 changes: 13 additions & 17 deletions analytics_dashboard/static/js/test/specs/tracking-view-spec.js
Expand Up @@ -5,6 +5,13 @@ define(['models/course-model', 'models/tracking-model', 'models/user-model', 'vi

describe('Tracking View', function () {

var userDetails = {
username: 'edX',
name: 'Ed Xavier',
email: 'edx@example.com',
ignoreInReporting: true
};

it('should call segment with application key and page', function () {
var view;

Expand All @@ -24,16 +31,9 @@ define(['models/course-model', 'models/tracking-model', 'models/user-model', 'vi
});

it('should call segment with user information', function () {
var view;

view = new TrackingView({
var view = new TrackingView({
model: new TrackingModel(),
userModel: new UserModel({
userId: 'myId',
userName: 'MyName',
userEmail: 'myemail@edx.org',
ignoreInReporting: true
})
userModel: new UserModel(userDetails)
});

// mock segment
Expand All @@ -43,9 +43,9 @@ define(['models/course-model', 'models/tracking-model', 'models/user-model', 'vi

view.logUser();

expect(view.segment.identify).toHaveBeenCalledWith('myId', {
username: 'MyName',
email: 'myemail@edx.org',
expect(view.segment.identify).toHaveBeenCalledWith(userDetails.username, {
name: userDetails.name,
email: userDetails.email,
ignoreInReporting: true
});
});
Expand Down Expand Up @@ -77,11 +77,7 @@ define(['models/course-model', 'models/tracking-model', 'models/user-model', 'vi
segmentApplicationId: 'applicationId',
page: 'mypage'
});
userModel.set({
userId: 'myId',
userName: 'My Name',
userEmail: 'myemail@edx.org'
});
userModel.set(userDetails);

// check to see if the methods were called
expect(view.segment.identify).toHaveBeenCalled();
Expand Down
6 changes: 3 additions & 3 deletions analytics_dashboard/static/js/views/tracking-view.js
Expand Up @@ -105,9 +105,9 @@ define(['backbone', 'underscore', 'utils/utils'],
logUser: function () {
var self = this,
userModel = self.options.userModel;
self.segment.identify(userModel.get('userId'), {
username: userModel.get('userName'),
email: userModel.get('userEmail'),
self.segment.identify(userModel.get('username'), {
name: userModel.get('name'),
email: userModel.get('email'),
ignoreInReporting: userModel.get('ignoreInReporting')
});
},
Expand Down

0 comments on commit 472019c

Please sign in to comment.