question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add view count to How-to and Research

See original GitHub issue

Component infos

Description

We want to have a view count on our How-to and Research pages.

Page related

Research and How-to pages.

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

Views How-to Views research

Icon

download

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:27 (22 by maintainers)

github_iconTop GitHub Comments

2reactions
chrismclarkecommented, Apr 26, 2022

@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:

  1. Use a new collection for tracking raw stats. E.g. add a howto_stats or similar endpoint to shared\db.ts that will hold the viewCount for each doc.

  2. 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

  3. 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)

  4. 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)

1reaction
AlfonsoGhisliericommented, Dec 15, 2022

Perfect, sounds good to me 😊

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found