Devalytics - DIY detailed Dev.to Analytics

Archived Posts from previous blogs that might still be useful to someone.

Last modified 2020-10-07

Table of content
  1. Background
  2. Personal Goals going into Devalytics
  3. What I used
  4. Backend
  5. Frontend
  6. Set up your own Devalytics
  7. Firebase Setup
  8. Heroku Setup
  9. Netlify Setup
  10. Where to from here?

I am archiving this project because DEV has added a more in-depth analytics - The remaining portion of this post I will be leaving up because I think it's fairly educational

Background

I'm a huge math nerd and love creating dashboard/data visualization pages whenever I have the chance. Recently I had some time to work on a personal creative project and decided to tackle one that's been on my "it'd be cool to do this eventually" list - create a daily breakdown dashboard for Dev.to stats!

Personal Goals going into Devalytics

What I used

Backend

Frontend

The reasoning for all of these choices are familiarity and personal preference

Github Repo for Frontend

Set up your own Devalytics

Firebase Setup

  1. Sign up for/Log in to Firebase
  2. Create a new project (Name it however you'd like!)
  3. Set up a Service Account. This is located on your Project's Settings > Service Accounts > Create one for Node.js and save the .json file for reference later (For the Environment variables on Heroku).
  4. Configure a Firestore Database under Cloud Firestore > Create Database
  1. Set your Firestore rules as:
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read; allow write: if false; } } }

Heroku Setup

  1. Sign up for/Log in to a Heroku Account
  2. Create a new Heroku app (You can name it whatever you want)
  3. Fork the Devalytics GitHub Repo
  4. Connect the fork to your Heroku app in your app's dashboard under Deploy > Deployment Method
  5. Add Environment variables for Firebase & Service Account (Variable names listed below)
  6. Add the "Heroku Scheduler" add-on to your project and set it to run npm run daily once a day at whatever time you desire.

Your Dev.to API Key

Your Firebase Information (This is presented as a JSON object by firebase - var firebaseConfig)

The following Service Account Variables:

Netlify Setup

  1. Fork the front end repository
  2. Sign up for/Log in to a Netlify Account
  3. Create a new Netlify Site
  4. Link the new site to your fork of the Frontend repository
  1. Add Environment variables for Firebase (The same variables as the Firebase section from Heroku above):

Where to from here?

One of the unfortunate parts of Devalytics is the inability to backdate data - and if there's ever a day the Heroku script doesn't run for any reason, that day will be lost to the void. Because of that, I wanted to start collecting data as soon as I could, so that as I build more analytics into the site, it will be easier to verify everything is working properly since data will exist for more than 3 (low-activity) days.

Some additions I already know I'd like to add: