Skip to content
Snippets Groups Projects
Unverified Commit 56b485f2 authored by Martin DONADIEU's avatar Martin DONADIEU Committed by GitHub
Browse files

feat: add variant local (#1218)

* Update plausible.js

* feat: add new variant

* feat: add allow-localhost

* Update tracker.ex

* Update compile.js

* Update plausible.js

* Update tracker.ex

* Update compile.js

* Update plausible.js
parent c3c6c082
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ defmodule PlausibleWeb.Tracker do ...@@ -3,7 +3,7 @@ defmodule PlausibleWeb.Tracker do
use Agent use Agent
custom_script_name = Application.get_env(:plausible, :custom_script_name) 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] base_filenames = ["plausible", custom_script_name]
# Generates Power Set of all variants # Generates Power Set of all variants
......
...@@ -16,7 +16,7 @@ function compilefile(input, output, templateVars = {}) { ...@@ -16,7 +16,7 @@ function compilefile(input, output, templateVars = {}) {
fs.writeFileSync(output, result.code) 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()); 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')) compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.js'))
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
function trigger(eventName, options) { 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 (/^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 (window.phantom || window._phantom || window.__nightmare || window.navigator.webdriver || window.Cypress) return;
if (plausible_ignore=="true") return warn('localStorage flag') if (plausible_ignore=="true") return warn('localStorage flag')
{{#if exclusions}} {{#if exclusions}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment