I built an advanced Dev.to dashboard with historic data using Next.js and Azure Functions đ
Do you ever watch your view count rise and wonder which posts are being read the most? I know I did.
That is one reason why I chose to develop my own Dev.to analytics dashboard to display historical data such as view, reaction and follower increase over the last 24 hours, 7 days and 30 days.
You can view the live dashboard here: devto-analytics.wallis.dev. Youâll notice that itâs styled to look like Dev.to.
Incredibly, Dev.to has recently added their own analytics page as well as having an âanalyticsâ option on each post (next to edit, manage). There are some differences between the built-in dashboard and mine.
Why build an analytics dashboard?
I really enjoy posting on Dev.to. I recently rewrote my whole website to use Dev.to as a CMS to enable myself to continue posting here while using my own site as the canonical URL.
I wanted, however, to see more in-depth information about each post such as view, reaction and follower increases over a given period of time. By default, I didnât have access to any data that would allow me to calculate any increases.
As a result, I ended up building my own analytics dashboard using Next.js, Tailwind CSS, Recharts, the Dev.to API and Azure Functions & Cosmos DB.
How I source the historical data
If youâve used the Dev.to API before, youâll have noticed that, for the moment, youâre unable to access any historical data. This makes it difficult to know how popular a post is over a given period of time (before the built-in analytics).
To record my historical data I created an Azure Function that saves my latest article and follower data, gathered using the Dev.to API, to a Azure Cosmos Database. The functions that save my article and follower data run every hour.
In addition, I created a couple of HTTP Azure Functions so that I can access the data.
If youâre wondering, Iâm entirely within the free tier on Azure â so it isnât costing me anything to record my historic data.
The dashboard
The dashboard consists of three pages:
- Home/overview page â basically an overview of my current stats and periodical view/reaction/comment/follower increases
- Breakdown graphs page â Charts that break down stats from the overview page so that I can easily see information such as what articles have been most read this week.
- Summary graphs page â Charts that display the increase of views/reactions/followers from hour-to-hour and day-to-day
You can view the dashboard implementation on GitHub.
The dashboardâs UI is based heavily on Dev.toâs styling. I wanted it to appear as an extension to Dev.toâs current implementation. The home page is styled to look like an advanced version of the Dev.to dashboard page that contains your general stat overview (total page views, reactions, comments) and a list of any draft and published articles.
Moreover, it was a lot of fun essentially cloning Dev.to to try to make the dashboard look as alike as possible. Try switching between the dashboard home page and your Dev.to dashboard in different tabs!
On my dashboard, Iâve added follower and last posted date to the overview stats â as I care about them more than âListingâs createdâ and âCredits availableâ. Most overview stats also contain two pieces of historical data. For page views, for example, Iâm displaying the total page view increase for the past 24 hours and the past 7 days.
Looking further down the page, youâll see a sortable list of my published posts containing the usual stats for each (views, reactions and comments). Iâve also added the 24 hours, 7 days and 30 day increase for each stat, for every post.
This page displays graphs that break down increases for views, reactions and comments. Its purpose is to show me what posts have been most popular over a given period of time.
While its styling is based on Dev.to, unlike the home page I havenât copied a specific Dev.to page.
The final page contains graphs that details how views, reactions and comments have increased over a period of time. Using this page I can interpret such information as if my follower increases have stagnated or are increasing at a good level.
Difference between my dashboard and the built-in analytics page
If youâve read this far youâre likely wondering what the difference between my dashboard and the built-in Dev.to analytics dashboard. The following is my opinion, let me know in the comments if you disagree.
What Dev.to built-in analytics does better:
What my dashboard does better:
- Integrates increases/historical data into the main dashboard screen better. Iâd love it if my Dev.to dashboard displayed my daily, weekly and monthly increases for each post.
- Displays follower and last posted date in the overview stats â I donât care about listings or credits. Moreover, Iâd love to display my current posting streak instead of the time since I last posted. This would help me ensure Iâm on track for my 16-week badge.
- The breakdown page makes it easy to see why my view count has risen.
Technical details
- Next.js â powers the dashboard.
- The built-in data fetching method
getStaticProps
is used to preload the article and follower data at build time. Incremental Static Regeneration rebuilds the page to minimise how out of date the initially served page is. - fetches the current article and follower data once the page has loaded.
- Combining
getStaticProps
anduseSWR
means that the dashboard loads fast, but will always display the most up-to-date data. - Azure Functions and Azure Cosmos DB
- Saves historical data gathered using the Dev.to API.
- Serves the data via a HTTP route for the UI to consume.
- Tailwind CSS â styling
- React-icons â various icons such as the question mark and GitHub icon on the navigation bar.
- Recharts â the chart library used on the graph pages
- TypeScript project references
Future improvements
There are few features that I want to add to the dashboard:
- Calculate and display my posting streak (by week) in the stat overview â should help with the 16-week streak badge.
- Average stats â such as average page views or followers gained per day.
- Predicted stats â days until I hit 100,000 page views for example.
Summary
In this post, Iâve introduced my Dev.to analytics dashboard that helps me understand how my stats are changing over time and identify popular posts.
Would you like to make your own dashboard like this? Have any thoughts on the dashboard? Let me know in the comments!
If you are looking to fork/clone my GitHub repository then Iâll need to make the documentation a little better đ â itâs pretty straightforward to do once your Azure Functions/Cosmos DB is set up.
P.S. Why isnât it password protected?
Iâm aware that by posting this blog Iâm allowing access to my private post data to anyone who stumbles across it. Iâm OK with this because:
- I want to show the dashboard off as a portfolio piece
- I want others to be able to copy/clone it so that they can see their own historical Dev.to data
- I couldnât come up with a reason to hide it. I understand why it is private by default but in my case, Iâm happy with others seeing it.
Let me know what you think of my Dev.to analytics dashboard!
Thanks for reading!
Originally published at https://wallis.dev.