TrackMyEvents - An event tracking platform
Tags: linodehackathon, typescript, postgres, react
Published: 2023-02-20 14:51:39

## What I built
I built an event tracking system which enables users to track the activity on their applications (web or mobile) using a simple API call. It provides the user with various analytics like daily active users over the last month, page-wise event data & many more.

### Category Submission:
Smooth Shifters
Integration Innovators

### App Link
[https://track-my-events.vercel.app/](https://track-my-events.vercel.app/)
Login Credentials:
Email: test@example.com
Password: testpassword

### Screenshots
Dashboard
![Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c192rm0wngmzwf52c4jf.png)

Profile
![Profile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1chdy64pc5rjjsun9kw.png)

SDK Setup
![SDK Setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rt3ebai7w7lqhflpcmh3.png)

Login
![Login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18wh3fhtmvyb7anw483k.png)

Register
![Register](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3qu9fqropum1esk50ne.png)

### Description
TrackMyEvents is a platform based on a microservices architecture which enables users to track the activity on their applications (web or mobile) using a simple API call. It provides the user with various analytics like daily active users over the last month, page-wise event data & many more.

The tracking system uses PostgreSQL as its primary database & Redis Pub/Sub for queuing events to store events in the database asynchronously. React is used for the frontend.

### Link to Source Code
[https://github.com/chirgjin/track-my-events](https://github.com/chirgjin/track-my-events)

### Permissive License
MIT

## Background
Last year, I was looking for an event tracking solution which could provide me with high-level analytics for all the events along with the actual raw data which I can query at my convenience. However, I only found Google Analytics to be affordable and all other solutions were either not suited to my use case or very expensive. Due to this, I thought of making my own tracking solution as a test which proved to be very helpful to my learning.

### How I built it
Originally, the TrackMyEvents was using RedisStack as its primary database for everything but seeing that there was no managed Redis offering on Linode, I decided to switch Redis to PostgreSQL and used Prisma ORM for interacting with it. This was a new learning experience for me as I had never used Prisma earlier in any of my projects. While using Prisma I found out that while it has many good features (like awesome type safety & auto-completion), Prisma doesn't support DISTINCT in aggregations. In the tracking service, I had to compute various analytics for the users & most of them required COUNT DISTINCT functionality which led me to write raw queries for the analytic APIs which was also very fun & a new experience for me.

When building this project, I utilized Linode for various purposes:
- Managed PostgreSQL: I used a separate managed PostgreSQL database provided by Linode for tracking & user service
- Linode: I used a 1GB Nanode to host my Redis server for pub/sub & a 2 GB Linode to host all the 3 microservices.

During all of my earlier projects I used to follow Digital Ocean's guide for the VM's initial server setup but this time I followed Linode's [guide](https://www.linode.com/docs/products/compute/compute-instances/guides/set-up-and-secure/) which was quite a nice surprise for me. I found out for the first time about the `dpkg-reconfigure` & `hostnamectl` commands as well as hardening the SSH Access.


### Additional Resources/Info

#### Tech Stack
- Typescript + ExpressJs + Prisma ORM for backend
- Typescript + React.Js for frontend
- PostgreSQL for database
- Redis for Pub/Sub
- Vercel for frontend deployment

### Conclusion

Overall, this was a very fun & challenging hackathon for me. I got to learn many new things from both Linode's documentation as well as Prisma's. The one thing I would definitely take care of is to avoid Prisma when I have to do analytical work next time 😝 and instead look for other alternatives. Another thing I'd like to mention to the Linode team is that while there's a category for EdgeWorkers in this hackathon, I couldn't find any information on EdgeWorkers on their website & even when I filled the form on Akamai's website, I didn't get any response from them.

Thanks to the Linode & Dev team for this opportunity. I am looking forward to hosting more of my projects on Linode 😁