Commit 90493ac3 by J. Cliff Dyer

Track push notification activity in analytics

When a course is updated, track whether or not a push notification is
sent.
parent 9378c8ff
...@@ -221,8 +221,11 @@ define([ ...@@ -221,8 +221,11 @@ define([
"coffee/spec/models/settings_grading_spec", "coffee/spec/models/textbook_spec", "coffee/spec/models/settings_grading_spec", "coffee/spec/models/textbook_spec",
"coffee/spec/models/upload_spec", "coffee/spec/models/upload_spec",
"coffee/spec/views/metadata_edit_spec", "coffee/spec/views/module_edit_spec", "coffee/spec/views/course_info_spec",
"coffee/spec/views/textbook_spec", "coffee/spec/views/upload_spec", "coffee/spec/views/metadata_edit_spec",
"coffee/spec/views/module_edit_spec",
"coffee/spec/views/textbook_spec",
"coffee/spec/views/upload_spec",
"js/spec/video/transcripts/utils_spec", "js/spec/video/transcripts/editor_spec", "js/spec/video/transcripts/utils_spec", "js/spec/video/transcripts/editor_spec",
"js/spec/video/transcripts/videolist_spec", "js/spec/video/transcripts/message_manager_spec", "js/spec/video/transcripts/videolist_spec", "js/spec/video/transcripts/message_manager_spec",
......
...@@ -123,6 +123,9 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model ...@@ -123,6 +123,9 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
# Verify the link is not rewritten when saved. # Verify the link is not rewritten when saved.
expect(requestSent.content).toEqual('/static/image.jpg') expect(requestSent.content).toEqual('/static/image.jpg')
# Verify that analytics are sent
expect(window.analytics.track).toHaveBeenCalled()
it "does rewrite links for preview", -> it "does rewrite links for preview", ->
# Create a new update. # Create a new update.
@createNewUpdate('/static/image.jpg') @createNewUpdate('/static/image.jpg')
...@@ -177,15 +180,22 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model ...@@ -177,15 +180,22 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
requestSent = JSON.parse(requests[requests.length - 1].requestBody) requestSent = JSON.parse(requests[requests.length - 1].requestBody)
expect(requestSent.push_notification_selected).toEqual(true) expect(requestSent.push_notification_selected).toEqual(true)
# Check that analytics send push_notification info
analytics_payload = window.analytics.track.calls[0].args[1]
expect(analytics_payload).toEqual(jasmine.objectContaining({'push_notification_selected': true}))
it "sends correct value for push_notification_selected when it is unselected", -> it "sends correct value for push_notification_selected when it is unselected", ->
requests = AjaxHelpers.requests(this); requests = AjaxHelpers.requests(this);
# unselect push notification # unselect push notification
@courseInfoEdit.$el.find('.toggle-checkbox').attr('checked', false); @courseInfoEdit.$el.find('.toggle-checkbox').attr('checked', false);
@courseInfoEdit.$el.find('.save-button').click() @courseInfoEdit.$el.find('.save-button').click()
requestSent = JSON.parse(requests[requests.length - 1].requestBody) requestSent = JSON.parse(requests[requests.length - 1].requestBody)
expect(requestSent.push_notification_selected).toEqual(false) expect(requestSent.push_notification_selected).toEqual(false)
# Check that analytics send push_notification info
analytics_payload = window.analytics.track.calls[0].args[1]
expect(analytics_payload).toEqual(jasmine.objectContaining({'push_notification_selected': false}))
describe "Course Handouts", -> describe "Course Handouts", ->
handoutsTemplate = readFixtures('course_info_handouts.underscore') handoutsTemplate = readFixtures('course_info_handouts.underscore')
......
...@@ -105,7 +105,8 @@ define(["js/views/baseview", "codemirror", "js/models/course_update", ...@@ -105,7 +105,8 @@ define(["js/views/baseview", "codemirror", "js/models/course_update",
analytics.track('Saved Course Update', { analytics.track('Saved Course Update', {
'course': course_location_analytics, 'course': course_location_analytics,
'date': this.dateEntry(event).val() 'date': this.dateEntry(event).val(),
'push_notification_selected': this.push_notification_selected(event)
}); });
}, },
...@@ -134,7 +135,7 @@ define(["js/views/baseview", "codemirror", "js/models/course_update", ...@@ -134,7 +135,7 @@ define(["js/views/baseview", "codemirror", "js/models/course_update",
// Variable stored for unit test. // Variable stored for unit test.
this.$modalCover = ModalUtils.showModalCover(false, this.$modalCover = ModalUtils.showModalCover(false,
function() { function() {
self.closeEditor(false) self.closeEditor(false);
} }
); );
}, },
...@@ -211,8 +212,9 @@ define(["js/views/baseview", "codemirror", "js/models/course_update", ...@@ -211,8 +212,9 @@ define(["js/views/baseview", "codemirror", "js/models/course_update",
// hide the push notification checkbox for subsequent edits to the Post // hide the push notification checkbox for subsequent edits to the Post
var push_notification_ele = this.$currentPost.find(".new-update-push-notification"); var push_notification_ele = this.$currentPost.find(".new-update-push-notification");
if (push_notification_ele) if (push_notification_ele) {
push_notification_ele.hide(); push_notification_ele.hide();
}
} }
ModalUtils.hideModalCover(this.$modalCover); ModalUtils.hideModalCover(this.$modalCover);
...@@ -231,12 +233,16 @@ define(["js/views/baseview", "codemirror", "js/models/course_update", ...@@ -231,12 +233,16 @@ define(["js/views/baseview", "codemirror", "js/models/course_update",
editor: function(event) { editor: function(event) {
var li = $(event.currentTarget).closest("li"); var li = $(event.currentTarget).closest("li");
if (li) return $(li).find("form").first(); if (li) {
return $(li).find("form").first();
}
}, },
dateEntry: function(event) { dateEntry: function(event) {
var li = $(event.currentTarget).closest("li"); var li = $(event.currentTarget).closest("li");
if (li) return $(li).find(".date").first(); if (li) {
return $(li).find(".date").first();
}
}, },
push_notification_selected: function(event) { push_notification_selected: function(event) {
...@@ -249,7 +255,6 @@ define(["js/views/baseview", "codemirror", "js/models/course_update", ...@@ -249,7 +255,6 @@ define(["js/views/baseview", "codemirror", "js/models/course_update",
} }
} }
} }
}); });
return CourseInfoUpdateView; return CourseInfoUpdateView;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment