Meadow

Introducing Mochi β€” and thoughts on analytics and webmentions

I've been working on a new personal project for some months now. It started when I migrated my blog from Bearblog to a custom, statically generated site. I'm not one to obsess about analytics (but god knows I have done so in the past) but I do care about when other people comment on the things I've written in their own blogs. I'm always happy to read what they say, be it good or bad.

There's a cool technology floating around the Indie Webs called Webmentions, that is supposed to address exactly that issue. You write a post that tags my post and then let me know about it by sending an HTTP request to my Webmentions server. Sounds awfully technical for the average non-technical user, and it is.

I spent some time researching this and saw a pretty clear pattern: webmentions have been set up for almost all sites whose authors have a technical background (often using a custom built server). But in the sphere of non-technical bloggers, almost no one has the ability to receive webmentions.

Granted, there are some cool projects out there, (most notably webmentions.io) that try to make it easy for anyone to add a webmention endpoint, all through a web UI. Still, it's not super clear how to use it. Though it's good that it exists. From what I've seen this is the service that most non-technical people use.

But all of this is about "receiving" webmentions. The sending of webmentions is actually more complex and harder to do for the average non-technical person. The best solution I found for this is webmention.app, that finds and sends webmentions for every link in a given page. Still, it's a manual process, as the user needs to go to the app every time they want webmentions to be sent. It works, but it's tedious, meaning people won't do it consistently. There's the ability to automate it, but you need to write a script, which again is a barrier for non-technical folks.

At the time I was also experimenting with different analytics services, most notably Tinylytics and Umami. Both were great but I absolutely loved Tinylytics. So clean and simple to use. No weird, complex options. I realized that up until now my experience with analytics was constrained to corporate analytics: complex platforms catering to the "marketing department" with tools to improve revenue. Here, in Tinylytics, I'd found a platform that was truly aimed at the small web, with the average personal blogger in mind.

So I set up Tinylytics on my site, but at the same time I could feel a seed starting to germinate in the back of my mind: "how does it work?" As always, I gave myself to this thought and started experimenting with how I could go about building a simple analytics platform. It turned out to be a good technical challenge: hard enough to be fun, but easy enough not to be frustrating.

Functionality wise, the first version of Mochi was pretty much a carbon copy of Tinylytics, with some minor changes to accommodate the UX to my own personal preferences. Around this point I realized that I'd built a platform that could be useful for others, but I didn't really want to make it public yet. It being so similar to Tinylytics, I felt it was "immoral". So I sat on it. I kept using it as my analytics platform on my blog, but never announced it anywhere. I told myself I would keep it private until/unless it became a drastically different platform. For some months it was relegated to the background, I kept hacking on it when I had time, inspiration, or a bug, but it otherwise stood untouched. That is, until I started to seriously consider having it support Webmentions. In the past I'd of course already heard about them and even set up a webmentions endpoint with webmentions.io, but I quickly grew discouraged with the technology, as everyone seemed to have webmentions set up, but no one was sending them. I just put it down as another failed attempt at bridging the gap between the islands that are personal blogs.

Then I somehow stumbled on the spec. "Holy shit, this is really easy to implement and it would be a great feature for Mochi"! It became apparent that any analytics platform for the indie web also needed to support both the sending and receiving of webmentions.

After some more months of hacking I think I can now say that Mochi is that platform I envisioned all those months ago. I'm making this post as an invitation to anyone that wants to try it out. The project is open source and in the near future I really want to make it possible for anyone to easily self-host it should they want to.

Anyway, that's it πŸ€— if you do decide to try it out please let me know of any issues you encounter! The platform has some peculiar design choices (more on them below), and I don't know how the system will behave under stress. Currently, I'll only allow a max of 20 accounts to be created so I can see what happens, but if everything is stable then I'll quickly raise this number.

Oh, and I know some people don't like analytics. Know that you can still use the webmentions functionality without using the analytics tracker!

Notes on technical details

Mochi is built in Golang, which allows for building and distributing a single binary that's easy to deploy and lowers the entry barrier to self-hosting.

The main experiment I'm running with Mochi is the database: I'm using SQLite. This is mainly out of personal curiosity as I really want to see how the simpler SQLite holds up in this kind of application. To get around the "single concurrent writes" limitation what I'm doing is having a separate database file per user, and then there's a shared database for less common operations (e.g., user settings and webmentions). Having one DB per user turned out to be a neat idea as it also enforces privacy (data from one user is very unlikely to be shown to another), and it makes exporting and deleting a user really easy and safe (just export/delete their db file).

I think this should work, though the whole thing is still bound by the filesystem I/O speed. That's why I'm slowly increasing the allowed amount of accounts. We'll see. If it goes well I might do a follow-up post, as I think using SQLite is easier/better in most cases than requiring a more "powerful" hosted DB like PostgreSQL.

Another thing I'm experimenting with here are alternative modes of notifications. We all know that email is the golden standard, but from a developer's point of view it's so darn tedious to set up! So I thought "there are so many other communication services out there, why not use one of those?". So, for Mochi, I've initially decided to send notifications through a Discord bot. Not only is it free (sending emails can get expensive) but it was also extremely easy to set up, and it also gave me a chance to play with the Discord bot API 😊

Of course, the drawback here is that not everyone uses Discord, while most people do have email. But well, that's the benefit of building something that's "free", I can do what I want and I don't have any stakeholders telling me to do otherwise. I might start adding other notification backends in the future (Telegram? Mastodon?)

#blogging#hobbies#programming#technology