I migrated analytics from Heroku to DigitalOcean

And it's far better

Posted by Giulio Magnifico on Monday, August 1, 2022

Some months ago I wrote about how this blog is “Google free” since I’m using the open source umami analytics service instead of Google Analytics.

And I wrote also that I was using it on a free instance of Heroku, but, after 6/7 months the things on Heroku became worse and worse, there were lots of issues.

One is that umami is using a new release of Next.js and Heroku hasn’t upgraded since months, so I wasn’t able to build the latest umami release (GitHub issue reported by lots of users)

Sometimes the pages were very slow to open/refresh, also the Heroku pages to log in.

I wasn’t able to save the 2FA code to Safari or 1Password, because the login page has a different address from the 2FA verification address (one is heroku.xyz, the other is verify.saleforce.xyz or something similar).

The most important is that I was receiving a weird email (with empty field DATABASE_URL and not working link) that my database was above 10,000rows and I had to upgrade to a 9$/month plan. But when I tried to do upgrade, the plan wasn’t available, and after few days my database was back again to 9,000rows, then again I received the email and my db was 12,000rows

heroku-disruption

So I was a bit disappointed by Heroku, and in the end I should have to pay 9$/month for a service that is not updated, annoying and slow.

Then I decided to migrate the stats on DigitalOcean. Where’s already hosted this blog, in order to have all on the same place that’s easier, comfortable and less expensive (!) because the lowest plan starts from 4$/month.

I created a new DigitalOcean droplet with the lowest plan, with 512 MB Memory, 10 GB Disk and Ubuntu 22.04 x64 (that can be easily upgrade for few $ more) then I followed the instructions to install umami with Docker-Compose here: How To Install Umami Web Analytics Software on Ubuntu 20.04 and in few minutes it was online. There’re lots of steps to take but all are easy.

Maybe the 512MB of ram is close to the edge, because I see always 80/90% of RAM usage but for now I’ll keep using it until it becomes slow and unresponsive. Then for a few extra dollars there’s the 1GB option.

Only issu is that I encountered some issues because umami wasn’t collecting any data in the beginning. So I started debugging and I found that my browser was blocking the umami JavaScript tracker with this error:

XMLHttpRequest cannot load https://umami.giuliomagnifico.blog/api/collect due to access control checks.

Origin https://giuliomagnifico.blog is not allowed by Access-Control-Allow-Origin. Status code: 204

I searched online and found I’m not the only one with this error: same issue on GitHub but it can be fixed by adding to nginx this parameter:

proxy_hide_header 'Access-Control-Allow-Origin';

I know nothing about these ”web server things”, but I think this should be implemented in the DigitalOcean tutorial inside the /etc/nginx/sites-available/umami.conf.

End: now umami is working, faster than Heroku, at half the price and with the latest version that can be easily upgrade via Docker… and I can also use the 2FA code with the macOS password manager. Good.