From f0a9ef21613a780e4c7975de47375fe7f21e3710 Mon Sep 17 00:00:00 2001 From: Nathan Sprenkle Date: Wed, 10 May 2023 10:28:35 -0400 Subject: [PATCH] feat: add video sharing config change signal (#32211) * feat: add tracking to video sharing options change * test: add tracking to video sharing options change --- .../js/spec/views/pages/course_outline_spec.js | 18 ++++++++++++++++++ .../js/views/course_video_sharing_enable.js | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index 327e5ec21d..6f49ade213 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -883,6 +883,24 @@ describe('CourseOutlinePage', function() { expect($('div.course-video-sharing')).not.toExist(); expect(selectedOption()).not.toExist(); }); + + it('tracks changes to video sharing option', function() { + createCourse({ + video_sharing_enabled: true, + video_sharing_options: 'all-on', + video_sharing_doc_url: 'http://rick.roll' + }); + + selectedOption().val('per-video').trigger('change'); + + expect(window.analytics.track).toHaveBeenCalledWith( + 'edx.social.video_sharing_options.changed', + { + course_id: 'mock-course', + video_sharing_options: 'per-video' + } + ); + }); }); describe('Section', function() { diff --git a/cms/static/js/views/course_video_sharing_enable.js b/cms/static/js/views/course_video_sharing_enable.js index 964bfc44d1..8104141a1a 100644 --- a/cms/static/js/views/course_video_sharing_enable.js +++ b/cms/static/js/views/course_video_sharing_enable.js @@ -29,6 +29,7 @@ define([ if (event.type === "change") { event.preventDefault(); this.updateVideoSharingConfiguration(event.target.value); + this.trackVideoSharingConfigurationChange(event.target.value); } }, @@ -38,6 +39,16 @@ define([ }); }, + trackVideoSharingConfigurationChange: function (value) { + window.analytics.track( + 'edx.social.video_sharing_options.changed', + { + course_id: this.model.id, + video_sharing_options: value + } + ); + }, + refresh: function () { this.model.fetch({ success: this.render.bind(this),