Exception for new tracking code
Past Issues Searched
- [x] I have searched open and closed issues to make sure that the bug has not yet been reported
Issue is a Bug Report
- [x] This is a bug report and not a feature request, nor asking for self-hosted support
Using official Plausible Cloud hosting or self-hosting?
Self-hosting
Describe the bug
For newly defined sites, the new dedicated tracking script does not work, and Plausible is crashing.
Old tracking scripts are ok when migrating to the new one. But newly defined sites are not.
All problems are resolved after restarting the container.
Screenshots
Environment
- OS: Ubuntu 22.04.4 LTS
- Browser: Firefox
- Browser Version: 145.0.1 (64-bit)
- Plausible Version: v3.1.0
I am having the same issue, except for me it's newly-created sites that don't work, but old ones do. Restarting the container seems to fix the issue too.
Thanks for your report @hatamiarash7! Thanks for sharing your experience @ItalyPaleAle!
I'm looking into this right now and it doesn't reproduce on my locally running CE 3.1.0 instance. Can you share the full server error (omitting anything sensitive)? What are the steps you use to create a new site?
Hi, here's the server log I have from when trying to load the script in browser: This server error occurred for me after upgrading to the 3.1.0 release but only for the first site I created after the upgrade, any subsequent sites created on plausible, even for the same domain, works fine with serving the script.
plausible-1 | 07:28:01.511 [error] #PID<0.81964.0> running PlausibleWeb.Endpoint (connection #PID<0.81963.0>, stream id 1) terminated
plausible-1 | Server: <redacted>:80 (http)
plausible-1 | Request: GET /js/pa-4H954SisddMuXrtxBMSRL.js
plausible-1 | ** (exit) an exception was raised:
plausible-1 | ** (CaseClauseError) no case clause matching: ["!function(){var e,t,n,i={};function o(e,t,n){window.fetch&&fetch(e,{method:\"POST\",headers:{\"Content-Type\":\"text/plain\"},keepalive:!0,body:JSON.stringify(t)}).then(function(e){n&&n.callback&&n.callback({status:e.status})}).catch(function(e){n&&n.callback&&n.callback({error:e})})}var a=!1,r=location.href,s={},u=-1,l=0,c=0;function d(){var a=f();if(!e&&(u<n||a>=3e3)){u=n;var d={n:\"engagement\",sd:Math.round(n/t*100),d:i.domain,u:r,p:s,e:a,v:33};l=0,c=0,i.hashBasedRouting&&(d.h=1),o(i.endpoint,d)}}function p(){\"visible\"===document.visibilityState&&document.hasFocus()&&0===l?l=Date.now():\"hidden\"!==document.visibilityState&&document.hasFocus()||(c=f(),l=0,d())}function f(){return l?c+(Date.now()-l):c}function v(){var e=document.body||{},t=document.documentElement||{};return Math.max(e.scrollHeight||0,e.offsetHeight||0,e.clientHeight||0,t.scrollHeight||0,t.offsetHeight||0,t.clientHeight||0)}function w(){var e=document.body||{},n=document.documentElement||{},i=window.innerHeight||n.clientHeight||0,o=window.scrollY||n.scrollTop||e.scrollTop||0;return t<=i?t:o+i}function m(f,m){var h,b,y=\"pageview\"===f;if(y&&a&&(d(),t=v(),n=w()),!i.captureOnLocalhost){if(/^localhost$|^127(\\.[0-9]+){0,2}\\.[0-9]+$|^\\[::1?\\]$/.test(location.hostname)||\"file:\"===location.protocol)return g(f,m,\"localhost\");if((window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)&&!window.__plausible)return g(f,m)}try{if(\"true\"===window.localStorage.plausible_ignore)return g(f,m,\"localStorage flag\")}catch(e){}var L={};L.n=f,L.v=33;var k=m&&(m.u||m.url);if(L.u=k||location.href,L.d=i.domain,L.r=document.referrer||null,m&&m.props&&(L.p=m.props),m&&!1===m.interactive&&(L.i=!1),m&&m.revenue&&(L.$=m.revenue),i.customProperties){var b=i.customProperties;\"function\"==typeof b&&(b=i.customProperties(f)),\"object\"==typeof b&&(L.p=Object.assign({},b,L.p))}if(i.hashBasedRouting&&(L.h=1),\"function\"==typeof i.transformRequest&&!(L=i.transformRequest(L)))return g(f,m,\"transformRequest\");y&&(e=!1,r=(h=L).u,s=h.p,u=-1,c=0,l=Date.now(),a||(document.addEventListener(\"visibilitychange\",p),window.addEventListener(\"blur\",p),window.addEventListener(\"focus\",p),a=!0)),o(i.endpoint,L,m)}function g(t,n,o){o&&i.logging&&console.warn(\"Ignoring Event: \"+o),n&&n.callback&&n.callback(),\"pageview\"===t&&(e=!0)}var h=[\"pdf\",\"xlsx\",\"docx\",\"txt\",\"rtf\",\"csv\",\"exe\",\"key\",\"pps\",\"ppt\",\"pptx\",\"7z\",\"pkg\",\"rar\",\"gz\",\"zip\",\"avi\",\"mov\",\"mp4\",\"mpeg\",\"wmv\",\"midi\",\"mp3\",\"wav\",\"wma\",\"dmg\"];function b(e){return e&&e.tagName&&\"a\"===e.tagName.toLowerCase()}function y(e){if(\"auxclick\"!==e.type||1===e.button){var t,n=function(e){for(;e&&(void 0===e.tagName||!b(e)||!e.href);)e=e.parentNode;return e}(e.target),o=n&&\"string\"==typeof n.href&&n.href.split(\"?\")[0];if(!E(n,0)){if(i.outboundLinks&&(t=n)&&\"string\"==typeof t.href&&t.host&&t.host!==location.host)return L(e,n,{name:\"Outbound Link: Click\",props:{url:n.href}});if(i.fileDownloads&&function(e){if(!e)return!1;var t=e.split(\".\").pop();return h.some(function(e){return e===t})}(o))return L(e,n,{name:\"File Download\",props:{url:o}})}}}function L(e,t,n){var i;(i={props:n.props}).revenue=n.revenue,m(n.name,i)}function k(e){var t=e&&e.classList;if(t){for(var n=0;n<t.length;n++)if(t.item(n).match(/plausible-event-name(=|--)(.+)/))return!0}return!1}function E(e,t){return!!e&&!(t>3)&&(!!k(e)||E(e.parentNode,t+1))}function x(e){var t=k(e)?e:e&&e.parentNode,n={name:null,props:{}};n.revenue={};var i=t&&t.classList;if(!i)return n;for(var o=0;o<i.length;o++){var a,r,s=i.item(o),u=s.match(/plausible-event-(.+)(=|--)(.+)/);u&&(a=u[1],r=u[3].replace(/\\+/g,\" \"),\"name\"==a.toLowerCase()?n.name=r:n.props[a]=r);var l=s.match(/plausible-revenue-(.+)(=|--)(.+)/);l&&(a=l[1],r=l[3],n.revenue[a]=r)}return n}function S(e){let o=Object.assign(a=e||{},{autoCapturePageviews:!1!==a.autoCapturePageviews,logging:!1!==a.logging,lib:a.lib||\"web\"});if(window.plausible&&window.plausible.l){o.logging&&console.warn(\"Plausible analytics script was already initialized, skipping init\");return}Object.assign(i={endpoint:\"https://plausible.8bitlabs.dev/api/event\",domain:\"siddhamarma.in\",formSubm" <> ..., "!function(){var e,t,n,i={};function o(e,t,n){window.fetch&&fetch(e,{method:\"POST\",headers:{\"Content-Type\":\"text/plain\"},keepalive:!0,body:JSON.stringify(t)}).then(function(e){n&&n.callback&&n.callback({status:e.status})}).catch(function(e){n&&n.callback&&n.callback({error:e})})}var a=!1,r=location.href,s={},u=-1,l=0,c=0;function d(){var a=f();if(!e&&(u<n||a>=3e3)){u=n;var d={n:\"engagement\",sd:Math.round(n/t*100),d:i.domain,u:r,p:s,e:a,v:33};l=0,c=0,i.hashBasedRouting&&(d.h=1),o(i.endpoint,d)}}function p(){\"visible\"===document.visibilityState&&document.hasFocus()&&0===l?l=Date.now():\"hidden\"!==document.visibilityState&&document.hasFocus()||(c=f(),l=0,d())}function f(){return l?c+(Date.now()-l):c}function v(){var e=document.body||{},t=document.documentElement||{};return Math.max(e.scrollHeight||0,e.offsetHeight||0,e.clientHeight||0,t.scrollHeight||0,t.offsetHeight||0,t.clientHeight||0)}function w(){var e=document.body||{},n=document.documentElement||{},i=window.innerHeight||n.clientHeight||0,o=window.scrollY||n.scrollTop||e.scrollTop||0;return t<=i?t:o+i}function m(f,m){var h,b,y=\"pageview\"===f;if(y&&a&&(d(),t=v(),n=w()),!i.captureOnLocalhost){if(/^localhost$|^127(\\.[0-9]+){0,2}\\.[0-9]+$|^\\[::1?\\]$/.test(location.hostname)||\"file:\"===location.protocol)return g(f,m,\"localhost\");if((window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)&&!window.__plausible)return g(f,m)}try{if(\"true\"===window.localStorage.plausible_ignore)return g(f,m,\"localStorage flag\")}catch(e){}var L={};L.n=f,L.v=33;var k=m&&(m.u||m.url);if(L.u=k||location.href,L.d=i.domain,L.r=document.referrer||null,m&&m.props&&(L.p=m.props),m&&!1===m.interactive&&(L.i=!1),m&&m.revenue&&(L.$=m.revenue),i.customProperties){var b=i.customProperties;\"function\"==typeof b&&(b=i.customProperties(f)),\"object\"==typeof b&&(L.p=Object.assign({},b,L.p))}if(i.hashBasedRouting&&(L.h=1),\"function\"==typeof i.transformRequest&&!(L=i.transformRequest(L)))return g(f,m,\"transformRequest\");y&&(e=!1,r=(h=L).u,s=h.p,u=-1,c=0,l=Date.now(),a||(document.addEventListener(\"visibilitychange\",p),window.addEventListener(\"blur\",p),window.addEventListener(\"focus\",p),a=!0)),o(i.endpoint,L,m)}function g(t,n,o){o&&i.logging&&console.warn(\"Ignoring Event: \"+o),n&&n.callback&&n.callback(),\"pageview\"===t&&(e=!0)}var h=[\"pdf\",\"xlsx\",\"docx\",\"txt\",\"rtf\",\"csv\",\"exe\",\"key\",\"pps\",\"ppt\",\"pptx\",\"7z\",\"pkg\",\"rar\",\"gz\",\"zip\",\"avi\",\"mov\",\"mp4\",\"mpeg\",\"wmv\",\"midi\",\"mp3\",\"wav\",\"wma\",\"dmg\"];function b(e){return e&&e.tagName&&\"a\"===e.tagName.toLowerCase()}function y(e){if(\"auxclick\"!==e.type||1===e.button){var t,n=function(e){for(;e&&(void 0===e.tagName||!b(e)||!e.href);)e=e.parentNode;return e}(e.target),o=n&&\"string\"==typeof n.href&&n.href.split(\"?\")[0];if(!E(n,0)){if(i.outboundLinks&&(t=n)&&\"string\"==typeof t.href&&t.host&&t.host!==location.host)return L(e,n,{name:\"Outbound Link: Click\",props:{url:n.href}});if(i.fileDownloads&&function(e){if(!e)return!1;var t=e.split(\".\").pop();return h.some(function(e){return e===t})}(o))return L(e,n,{name:\"File Download\",props:{url:o}})}}}function L(e,t,n){var i;(i={props:n.props}).revenue=n.revenue,m(n.name,i)}function k(e){var t=e&&e.classList;if(t){for(var n=0;n<t.length;n++)if(t.item(n).match(/plausible-event-name(=|--)(.+)/))return!0}return!1}function E(e,t){return!!e&&!(t>3)&&(!!k(e)||E(e.parentNode,t+1))}function x(e){var t=k(e)?e:e&&e.parentNode,n={name:null,props:{}};n.revenue={};var i=t&&t.classList;if(!i)return n;for(var o=0;o<i.length;o++){v (truncated)
plausible-1 | 07:41:56.739 [notice] Elixir.Plausible.Cache.Warmer running &Plausible.Shield.HostnameRuleCache.refresh_all/1 on hostname_allowlist_by_domain...
This happened to me on multiple new sites - often with the behavior that the script works first, and then starts to return the 500 error a day or so later.
I'm having the same issue with a fresh v3.1.0 install on Ubuntu 24.04 on a dedicated server. Plausible works at first, but after a few hundred visitors, the tracking script fails to load and returns a 500 Internal Server Error.
Restarting Docker containers makes it work again, but I'm not sure if or when the issue will recur.
I'm having the same issue with a fresh v3.1.0 install on Ubuntu 24.04 on a dedicated server. Plausible works at first, but after a few hundred visitors, the tracking script fails to load and returns a 500 Internal Server Error.
Restarting Docker containers makes it work again, but I'm not sure if or when the issue will recur.
Damn, sorry to hear that @ducbao414. That's a higher reoccurrence rate than I understood previously. I will raise the urgency on getting it fixed.
I'm having the same issue with a fresh v3.1.0 install on Ubuntu 24.04 on a dedicated server. Plausible works at first, but after a few hundred visitors, the tracking script fails to load and returns a 500 Internal Server Error. Restarting Docker containers makes it work again, but I'm not sure if or when the issue will recur.
Damn, sorry to hear that @ducbao414. That's a higher reoccurrence rate than I understood previously. I will raise the urgency on getting it fixed.
Thanks @apata! And thanks for making this awesome GA4 replacement.
Regarding the issue, I figured out what is causing it https://github.com/plausible/analytics/discussions/5884#discussioncomment-15271936 and I am working on a fix now.