diff --git a/lib/plausible_web/plugs/tracker.ex b/lib/plausible_web/plugs/tracker.ex index 54f0f54712d3f8ea2df3b2a745fa19a187925170..8b7e3b602c8f830aa41b1ed038e56243e7c544e3 100644 --- a/lib/plausible_web/plugs/tracker.ex +++ b/lib/plausible_web/plugs/tracker.ex @@ -3,7 +3,7 @@ defmodule PlausibleWeb.Tracker do use Agent custom_script_name = Application.get_env(:plausible, :custom_script_name) - base_variants = ["hash", "outbound-links", "exclusions", "compat"] + base_variants = ["hash", "outbound-links", "exclusions", "compat", "local"] base_filenames = ["plausible", custom_script_name] # Generates Power Set of all variants diff --git a/tracker/compile.js b/tracker/compile.js index 511ab31ff0c4fa565c6ac99ab36a818ac76081d8..fbffbe9b78c9938cc20e77bfeb6d9658f2d75baf 100644 --- a/tracker/compile.js +++ b/tracker/compile.js @@ -16,7 +16,7 @@ function compilefile(input, output, templateVars = {}) { fs.writeFileSync(output, result.code) } -const base_variants = ["hash", "outbound-links", "exclusions", "compat"] +const base_variants = ["hash", "outbound-links", "exclusions", "compat", "local"] const variants = [...g.clone.powerSet(base_variants)].filter(a => a.length > 0).map(a => a.sort()); compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.js')) diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js index f1a58cb928752e501b266c29125b0f66711e0224..4ca8a9069c62539780df3f1424dedcd7027b5f1a 100644 --- a/tracker/src/plausible.js +++ b/tracker/src/plausible.js @@ -33,7 +33,9 @@ function trigger(eventName, options) { + {{#if !local}} if (/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(location.hostname) || location.protocol === 'file:') return warn('localhost'); + {{/if}} if (window.phantom || window._phantom || window.__nightmare || window.navigator.webdriver || window.Cypress) return; if (plausible_ignore=="true") return warn('localStorage flag') {{#if exclusions}}