Skip to content

Commit

Permalink
Merge pull request #223 from ScottDowne/ensure-clicks
Browse files Browse the repository at this point in the history
Ensure clicks go through, even if metrics url is undefined.
  • Loading branch information
glogiotatidis authored Dec 23, 2016
2 parents 7664fbb + 6eda060 commit 4323e51
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions snippets/base/templates/base/includes/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,16 @@ function sendMetric(metric, callback, href) {
{% if preview %}
console.log("[preview mode] Sending metric: " + metric);
if (callback) {
callback();
setTimeout(callback);
}
return;
{% else %}
if ((Math.random() > SNIPPET_METRICS_SAMPLE_RATE) || (!metric)) {
if (!SNIPPET_METRICS_URL || (Math.random() > SNIPPET_METRICS_SAMPLE_RATE) || (!metric)) {
if (callback) {
callback();
// setTimeout is here because when metrics succeeds the callback is async.
// When we don't use metrics, we should be consistent and
// fire the callback async too.
setTimeout(callback);
}
return;
}
Expand Down

0 comments on commit 4323e51

Please sign in to comment.