mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
FIX: don't track clicks on links in quotes
This commit is contained in:
parent
c069488560
commit
ad15049ef0
@ -12,7 +12,15 @@ export default {
|
||||
if (Discourse.Utilities.selectedText() !== "") { return false; }
|
||||
|
||||
var $link = $(e.currentTarget);
|
||||
if ($link.hasClass('lightbox') || $link.hasClass('mention-group') || $link.hasClass('no-track-link')) { return true; }
|
||||
|
||||
// don't track lightboxes, group mentions or links with disabled tracking
|
||||
if ($link.hasClass('lightbox') || $link.hasClass('mention-group') ||
|
||||
$link.hasClass('no-track-link') || $link.hasClass('hashtag')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// don't track links in quotes or in elided part
|
||||
if ($link.parents('aside.quote,.elided').length) { return true; }
|
||||
|
||||
var href = $link.attr('href') || $link.data('href'),
|
||||
$article = $link.closest('article,.excerpt,#revisions'),
|
||||
@ -20,7 +28,8 @@ export default {
|
||||
topicId = $('#topic').data('topic-id') || $article.data('topic-id'),
|
||||
userId = $link.data('user-id');
|
||||
|
||||
if (!href || href.trim().length === 0 || href.indexOf("mailto:") === 0) { return; }
|
||||
if (!href || href.trim().length === 0) { return false; }
|
||||
if (href.indexOf("mailto:") === 0) { return true; }
|
||||
|
||||
if (!userId) userId = $article.data('user-id');
|
||||
|
||||
|
@ -85,7 +85,7 @@ test("does not track clicks on quote buttons", function() {
|
||||
});
|
||||
|
||||
test("does not track clicks on category badges", () => {
|
||||
ok(!track(generateClickEventOn('.hashtag')));
|
||||
ok(track(generateClickEventOn('.hashtag')));
|
||||
});
|
||||
|
||||
test("removes the href and put it as a data attribute", function() {
|
||||
|
@ -79,7 +79,7 @@ test("does not track clicks on quote buttons", function() {
|
||||
});
|
||||
|
||||
test("does not track clicks on category badges", () => {
|
||||
ok(!track(generateClickEventOn('.hashtag')));
|
||||
ok(track(generateClickEventOn('.hashtag')));
|
||||
});
|
||||
|
||||
test("removes the href and put it as a data attribute", function() {
|
||||
|
@ -31,6 +31,10 @@ module("lib:click-track", {
|
||||
<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>
|
||||
<a class="mailto" href="mailto:foo@bar.com">email-me</a>
|
||||
<aside class="quote">
|
||||
<a class="inside-quote" href="http://discuss.domain.com">foobar</a>
|
||||
</aside>
|
||||
</article>
|
||||
</div>`);
|
||||
}
|
||||
@ -66,12 +70,20 @@ test("does not track clicks on back buttons", function() {
|
||||
ok(track(generateClickEventOn('.back')));
|
||||
});
|
||||
|
||||
test("does not track clicks in quotes", function() {
|
||||
ok(track(generateClickEventOn('.inside-quote')));
|
||||
});
|
||||
|
||||
test("does not track clicks on quote buttons", function() {
|
||||
ok(track(generateClickEventOn('.quote-other-topic')));
|
||||
});
|
||||
|
||||
test("does not track clicks on category badges", () => {
|
||||
ok(!track(generateClickEventOn('.hashtag')));
|
||||
ok(track(generateClickEventOn('.hashtag')));
|
||||
});
|
||||
|
||||
test("does not track clicks on mailto", function() {
|
||||
ok(track(generateClickEventOn('.mailto')));
|
||||
});
|
||||
|
||||
test("removes the href and put it as a data attribute", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user