Allow disabling link tracking with .no-track-link (#4160)

This commit is contained in:
Peter Lejeck 2016-04-11 08:39:49 -07:00 committed by Robin Ward
parent 491c473e4e
commit 9bba68ed74
2 changed files with 6 additions and 1 deletions

View File

@ -11,7 +11,7 @@ export default {
if (Discourse.Utilities.selectedText() !== "") { return false; }
var $link = $(e.currentTarget);
if ($link.hasClass('lightbox') || $link.hasClass('mention-group')) { return true; }
if ($link.hasClass('lightbox') || $link.hasClass('mention-group') || $link.hasClass('no-track-link')) { return true; }
var href = $link.attr('href') || $link.data('href'),
$article = $link.closest('article'),

View File

@ -27,6 +27,7 @@ module("lib:click-track", {
<a id="inside-onebox" href="http://www.google.com">google.com<span class="badge">1</span></a>
<a id="inside-onebox-forced" class="track-link" href="http://www.google.com">google.com<span class="badge">1</span></a>
</div>
<a class="no-track-link" href="http://www.google.com">google.com</a>
<a id="same-site" href="http://discuss.domain.com">forum</a>
<a class="attachment" href="http://discuss.domain.com/uploads/default/1234/1532357280.txt">log.txt</a>
<a class="hashtag" href="http://discuss.domain.com">#hashtag</a>
@ -57,6 +58,10 @@ test("it calls preventDefault when clicking on an a", function() {
ok(DiscourseURL.redirectTo.calledOnce);
});
test("does not track clicks when forcibly disabled", function() {
ok(track(generateClickEventOn('.no-track-link')));
});
test("does not track clicks on back buttons", function() {
ok(track(generateClickEventOn('.back')));
});