Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Fix tracker bug - call callback function when ignoring event (#2947)
RobertJoonase27e29250b61
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0f56d780f9..59b8abcbf6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.- Ability to change domain for existing site (requires numeric IDs data migration, instructions will be provided separately) UI + API (`PUT /api/v1/sites`)### Fixed+- Fix tracker bug - call callback function even when event is ignored- Make goal-filtered CSV export return only unique_conversions timeseries in the 'visitors.csv' file- Stop treating page filter as an entry page filter- City report showing N/A instead of city names with imported data plausible/analytics#2675diff --git a/tracker/src/plausible.js b/tracker/src/plausible.jsindex 4a0645a67c..b89da3bdf1 100644--- a/tracker/src/plausible.js+++ b/tracker/src/plausible.js@@ -11,8 +11,9 @@{{/if}}var endpoint = scriptEl.getAttribute('data-api') || defaultEndpoint(scriptEl)- function warn(reason) {- console.warn('Ignoring Event: ' + reason);+ function onIgnoredEvent(reason, options) {+ if (reason) console.warn('Ignoring Event: ' + reason);+ options && options.callback && options.callback()}function defaultEndpoint(el) {@@ -29,12 +30,16 @@function trigger(eventName, options) {{{#unless local}}- if (/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(location.hostname) || location.protocol === 'file:') return warn('localhost');- if (window._phantom || window.__nightmare || window.navigator.webdriver || window.Cypress) return;+ if (/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(location.hostname) || location.protocol === 'file:') {+ return onIgnoredEvent('localhost', options)+ }+ if (window._phantom || window.__nightmare || window.navigator.webdriver || window.Cypress) {+ return onIgnoredEvent(null, options)+ }{{/unless}}try {if (window.localStorage.plausible_ignore === 'true') {- return warn('localStorage flag')+ return onIgnoredEvent('localStorage flag', options)}} catch (e) {@@ -47,7 +52,7 @@var isIncluded = !dataIncludeAttr || (dataIncludeAttr && dataIncludeAttr.split(',').some(pathMatches))var isExcluded = dataExcludeAttr && dataExcludeAttr.split(',').some(pathMatches)- if (!isIncluded || isExcluded) return warn('exclusion rule')+ if (!isIncluded || isExcluded) return onIgnoredEvent('exclusion rule', options)}function pathMatches(wildcardPath) {