Add view count to How-to and Research
See original GitHub issueComponent infos
Description
We want to have a view count on our How-to and Research pages.
Page related
Build suggestion
- It will be build using the aggregations.
- Ideally there is some sort of logic that only counts one visit per hour. (To prevent it being mis-used by refreshing 200 times in a row)
- Should be released for
beta-testers
first. So we can test it
Mockup
Icon
Issue Analytics
- State:
- Created a year ago
- Comments:27 (22 by maintainers)
Top Results From Across the Web
How Does YouTube Count Views? It's more tricky than you think!
Experts believe that after 4 or 5 views in one day, YouTube stops adding new views to a video's view count number.
Read more >A Simple Explanation of How YouTube Counts Views - Ecwid
If you're looking for an easy way to understand YouTube view counts, Ecwid has a simple explanation and some tips on how to...
Read more >How to Get More Views on YouTube: 16 Tips that Actually Work
If you want to get more views on YouTube, you need to respond to viewer comments, create video playlists, design attention-grabbing thumbnails and...
Read more >Adding a view count counter and making app more efficient
I want to have a stylish swipeable counter on the Main Activity that says the total views of all the videos in the...
Read more >How to display Word Count | Roam Research - YouTube
In this video, I explored two use cases for the word counter in Roam Research to embed Google Calendar to have a note...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ryanwbass Thanks for taking this on. There might be a bit of added challenge with this one with the best place to actually store this information. The natural place to think would be the howto itself, adding a
viewCount
property and just increasing by 1 any time the howto page is loaded except this will mean howto docs are constantly updated and the entire doc will need to be synced across all users many times (which is a costly set of db read operations)There’s also the not-unlikely scenario that a howto could be viewed by multiple users at similar times, meaning that any client-side updates could easily become out of sync (e.g. two users both increment the count from 2->3 before having the chance to sync the others’ update).
So I think I’d recommend a few things:
Use a new collection for tracking raw stats. E.g. add a
howto_stats
or similar endpoint toshared\db.ts
that will hold the viewCount for each doc.Feel free to make a first pass implementing everything with client-side UI and logic (e.g. the button, the logic to increment the viewcount and limit spamming etc.). I wouldn’t worry to much about being clever with the spamming code, if someone is determined they will always find a way around so I expect something like a localstorage entry should be fine to at least prevent repeated refresh. If we ever want more accurate stats we can use google analytics that tracks things like IPs for anti-spam
Consider moving the increment code to a firebase function which can use special field-value increment functions instead of relying on manual calculation (I can help with this)
Consider adding an aggregation to collate all viewcount stats into a single doc for easier consumption in the frontend. I can help with this (we have a pending pr to make backend dev a bit easier using docker emulators instead of firebase server)
Perfect, sounds good to me 😊