DigitalCommons / land-explorer-front-end

React app for the Land Explorer front end
http://landexplorer.cc
GNU Affero General Public License v3.0
1 stars 0 forks source link

Analytics #202

Open lin-d-hop opened 1 year ago

lin-d-hop commented 1 year ago

Description

Analytics is broken. Let's get some basic analytics back up.

Acceptance Criteria

lin-d-hop commented 1 year ago

Crashes on the backend: -> PM2 runs backend. Has some built in monitoring. Can this send notifications?

rogup commented 1 year ago

I've spent a couple of hours researching options:

  1. PM2 does have error reporting, a dashboard showing crashes, and notifications, but this is only included in its paid offering 'PM2 Plus' https://pm2.io/pricing Trying to implement all of this ourselves with just the free version of PM2 would be a lot of work.

  2. Sentry seems to be one of the most popular out-of-the-box error tracking + aggregation tools. It has open source SDKs for most platforms, including React and Node https://github.com/getsentry/sentry-javascript, which seem very easy to plug in. However, it's not fully open source and self-hosting it is apparently difficult because it uses a lot of different technologies. https://develop.sentry.dev/self-hosted/

  3. Glitchtip is a fully open source, more lightweight alternative to Sentry, which can be used with Sentry's open source SDKs https://glitchtip.com/documentation. It can send email or webhook alerts, which can be integrated with Element. We can host it ourselves on Cloudron. Instructions for how to do this with docker-compose are here: https://glitchtip.com/documentation/install

Option 3 (Glitchtip + Sentry SDKs) looks like the best option to me. I think it will take 1-2 days to get something working, for both the backend and frontend. It also looks like we could use Glitchtip for our other websites if we want.

Out-of-the-box, it will track in real-time all unhandled errors that are thrown. There's then the option to send custom events from LX for errors that we handle but still want to track. And we can track app performance too, to find out where there are slow responses and bottlenecks.

It can also monitor uptime. We currently use Uptime Kuma for this, which we could eventually remove if we find that Glitchtip is just as reliable.

rogup commented 1 year ago

@lin-d-hop please can you review these options

lin-d-hop commented 1 year ago

Thanks for these options @rogup

Apparently Sentry have a free for OSS policy. Does using Sentry as a SaaS make any sense?

Looks like a list that is limited to event monitoring and error logs. Did you come across Datadog or Bugsnag? Or were they excluded? Did you consider anything for user analytics? Matomo for example?

rogup commented 1 year ago

@lin-d-hop I wasn't sure on DCC's policy on the software that we use, and how open-source it should be. I've seen that we generally use self-hosted, open source analytics-related solutions (e.g. Umami, Uptime Kuma) so was mainly looking at OSS for this too.

But if we're ok with it, yes, I think using Sentry as SaaS if we can get it free would work well and be low-cost from a development/maintenance perspective.

I was mainly looking at analytics for tracking errors, because I think these are the most important things to track that we don't currently, and was what motivated my suggestion of adding analytics. I came across Datadog, but it didn't seem very lightweight. It has a lot of features that are not really aimed at error tracking, unless we pay for an add-on.

I've just had a look at Bugsnag and it also looks good, but less widely used than Sentry and isn't open source. It has a free for OSS policy though, so maybe we can look into this if our Sentry application gets refused.

I didn't look into user analytics, which are different and usually use different tools. I think Umami currently gives us user analytics and is a more lightweight than Matomo.