From b81d169e2a81dde3ecd9bf66e393d84d04ec7bda Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Tue, 23 Apr 2019 23:07:02 +0300 Subject: [PATCH] FIX: Do not track user mentions. --- .../discourse/components/discourse-topic.js.es6 | 8 -------- .../discourse/components/links-redirect.js.es6 | 8 -------- .../javascripts/discourse/components/user-stream.js.es6 | 8 -------- app/assets/javascripts/discourse/lib/click-track.js.es6 | 6 +++++- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/discourse/components/discourse-topic.js.es6 b/app/assets/javascripts/discourse/components/discourse-topic.js.es6 index 4e7496db6d0..8d657ff8a71 100644 --- a/app/assets/javascripts/discourse/components/discourse-topic.js.es6 +++ b/app/assets/javascripts/discourse/components/discourse-topic.js.es6 @@ -84,14 +84,6 @@ export default Ember.Component.extend( "click.discourse-redirect", ".cooked a, a.track-link", function(e) { - const $target = $(e.target); - if ( - $target.hasClass("mention") || - $target.parents(".expanded-embed").length - ) { - return false; - } - return ClickTrack.trackClick(e); } ); diff --git a/app/assets/javascripts/discourse/components/links-redirect.js.es6 b/app/assets/javascripts/discourse/components/links-redirect.js.es6 index a84a14012ac..fdb5c11a487 100644 --- a/app/assets/javascripts/discourse/components/links-redirect.js.es6 +++ b/app/assets/javascripts/discourse/components/links-redirect.js.es6 @@ -5,14 +5,6 @@ export default Ember.Component.extend({ this._super(...arguments); this.$().on("click.discourse-redirect", "#revisions a", function(e) { - const $target = $(e.target); - if ( - $target.hasClass("mention") || - $target.parents(".expanded-embed").length - ) { - return false; - } - return ClickTrack.trackClick(e); }); }, diff --git a/app/assets/javascripts/discourse/components/user-stream.js.es6 b/app/assets/javascripts/discourse/components/user-stream.js.es6 index 8b16ea66252..52e4b0faa91 100644 --- a/app/assets/javascripts/discourse/components/user-stream.js.es6 +++ b/app/assets/javascripts/discourse/components/user-stream.js.es6 @@ -32,14 +32,6 @@ export default Ember.Component.extend(LoadMore, { this.$().on("click.details-disabled", "details.disabled", () => false); this.$().on("click.discourse-redirect", ".excerpt a", function(e) { - const $target = $(e.target); - if ( - $target.hasClass("mention") || - $target.parents(".expanded-embed").length - ) { - return false; - } - return ClickTrack.trackClick(e); }); }.on("didInsertElement"), diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index f3468b69841..11432753862 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -10,7 +10,7 @@ export function isValidLink($link) { // - links with disabled tracking // - category links // - quote back button - if ($link.is(".lightbox, .mention-group, .no-track-link, .hashtag, .back")) { + if ($link.is(".lightbox, .mention, .mention-group, .no-track-link, .hashtag, .back")) { return false; } @@ -19,6 +19,10 @@ export function isValidLink($link) { return false; } + if ($link.parents(".expanded-embed").length !== 0) { + return false; + } + return ( $link.hasClass("track-link") || $link.closest(".hashtag, .badge-category, .onebox-result, .onebox-body")