From 21c11c2bb23a615744c499c0fed55cc3ed7069ca Mon Sep 17 00:00:00 2001 From: Nick Quaranto Date: Mon, 9 Sep 2019 03:41:37 -0400 Subject: [PATCH] Use Discourse.getURL for /clicks/track so clicks can be tracked on relative URLs (#8079) --- app/assets/javascripts/discourse/lib/ajax.js.es6 | 2 +- app/assets/javascripts/discourse/lib/click-track.js.es6 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/ajax.js.es6 b/app/assets/javascripts/discourse/lib/ajax.js.es6 index e2f28ce32e2..c5468e11951 100644 --- a/app/assets/javascripts/discourse/lib/ajax.js.es6 +++ b/app/assets/javascripts/discourse/lib/ajax.js.es6 @@ -153,7 +153,7 @@ export function ajax() { if ( args.type && args.type.toUpperCase() !== "GET" && - url !== "/clicks/track" && + url !== Discourse.getURL("/clicks/track") && !Discourse.Session.currentProp("csrfToken") ) { promise = new Ember.RSVP.Promise((resolve, reject) => { diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index 438915c13ff..42a65623a6b 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -102,9 +102,9 @@ export default { data.append("url", href); data.append("post_id", postId); data.append("topic_id", topicId); - navigator.sendBeacon("/clicks/track", data); + navigator.sendBeacon(Discourse.getURL("/clicks/track"), data); } else { - trackPromise = ajax("/clicks/track", { + trackPromise = ajax(Discourse.getURL("/clicks/track"), { type: "POST", data: { url: href,