diff --git a/common/lib/xmodule/xmodule/modulestore/courseware_index.py b/common/lib/xmodule/xmodule/modulestore/courseware_index.py index 4375ef3242..48b726d355 100644 --- a/common/lib/xmodule/xmodule/modulestore/courseware_index.py +++ b/common/lib/xmodule/xmodule/modulestore/courseware_index.py @@ -178,26 +178,3 @@ class CoursewareSearchIndexer(object): event_name, data ) - - try: - if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(settings, 'SEGMENT_IO_LMS_KEY'): - # Google Analytics - log index content request - import analytics - - analytics.track( - event_name, - data, - context={ - 'Google Analytics': { - 'clientId': tracking_context.get('client_id') - } - } - ) - except Exception: # pylint: disable=broad-except - # Capturing all exceptions thrown while tracking analytics events. We do not want - # an operation to fail because of an analytics event, so we will capture these - # errors in the logs. - log.exception( - u'Unable to emit %s event for content indexing.', - event_name, - ) diff --git a/lms/static/js/search/views/search_item_view.js b/lms/static/js/search/views/search_item_view.js index b5150529e2..53f9f2e79c 100644 --- a/lms/static/js/search/views/search_item_view.js +++ b/lms/static/js/search/views/search_item_view.js @@ -32,6 +32,14 @@ define([ return this; }, + /** + * Redirect to a URL. Mainly useful for mocking out in tests. + * @param {string} url The URL to redirect to. + */ + redirect: function(url) { + window.location.href = url; + }, + logSearchItem: function(event) { event.preventDefault(); var target = this.model.id; @@ -47,13 +55,7 @@ define([ "result_position": (page * pageSize + index), "result_link": target }); - window.analytics.track('"edx.course.search.result_selected"', { - category: 'courseware_search', - search_term: searchTerm, - result_position: (page * pageSize + index), - result_link: target - }); - window.location.href = link; + this.redirect(link); } }); diff --git a/lms/static/js/spec/search/search_spec.js b/lms/static/js/spec/search/search_spec.js index 4b22afe6b0..34ca36f22d 100644 --- a/lms/static/js/spec/search/search_spec.js +++ b/lms/static/js/spec/search/search_spec.js @@ -117,6 +117,18 @@ define([ expect(this.item.$el).toContainHtml(breadcrumbs); }); + it('log request on follow item link', function () { + this.model.collection = new SearchCollection([this.model], { course_id: 'edx101' }); + this.item.render(); + // Mock the redirect call + spyOn(this.item, 'redirect').andCallFake( function() {} ); + spyOn(this.item, 'logSearchItem').andCallThrough(); + var link = this.item.$el.find('a'); + expect(link.length).toBe(1); + link.trigger('click'); + expect(this.item.redirect).toHaveBeenCalled(); + }); + });