Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

number of people currently viewing an article #18

Open
QuincyLarson opened this issue Nov 20, 2017 · 10 comments
Open

number of people currently viewing an article #18

QuincyLarson opened this issue Nov 20, 2017 · 10 comments

Comments

@QuincyLarson
Copy link

No description provided.

@TheHollidayInn
Copy link

If you are looking into real time solutions: https://github.com/amark/gun has been pretty good for me so far.

@QuincyLarson
Copy link
Author

@TheHollidayInn have you ever seen this used with Google Analytics data? Is there an open source implementation you could point to? That could save us a lot of time.

@TheHollidayInn
Copy link

Ah, I think using something like Gun would be closer to a homemade solution. It looks like Using the Google Analytics Real Time Data api to filter by the current page would work as well! I can create a PR for that if this issue is open.

@QuincyLarson
Copy link
Author

@TheHollidayInn Yes - if we can figure out a way to do this using the API without having to keep an intermediary database, that would be much simpler. We would welcome a PR for this, if you want to take a crack at it :)

@TheHollidayInn
Copy link

Something to note, there is a limit to the analytics real time api (also it is in beta):

Example: Calculating a Refresh Interval
If you expect to make regular requests for real time data, you should select a reasonable refresh interval based on your expected usage.

For example, a single Google Analytics view (profile) has a daily quota limit of 10,000 requests per day. In a single day, if you expect to make 6,000 queries to the Core Reporting API for a single view (profile), then you will have a quota of 4,000 requests remaining for that view (profile).

Suppose you decide to use the Real Time Reporting API to implement 3 real time dashboards that run all day querying for real time data from the same view (profile). Each dashboard can make approximately 1,333 queries per day (4,000 queries / 3 dashboards). There are 86,400 seconds in a day. Thus the refresh interval for each dashboard must be greater than 65 seconds (86,400 / 1,333) so that the total number of daily requests for the view (profile) is below the 4,000 daily limit.

I may be wrong, but does this exceed your traffic expectations? The limit is pretty small for a real time approach.

@QuincyLarson
Copy link
Author

@TheHollidayInn We could get the activity for all the pages once every 10 seconds, and that would be less than 10,000 requests a day. That would be near-instantaneous enough for our features. We could then stream those data to the open pages.

Honestly, I have no idea how to do this, but I know that sites like lichess.org have really good real-time analytics on how many games are going on, how many people are watching a game, etc. We'd like to have similar metrics for freeCodeCamp News. Maybe Google Analytics is the wrong approach.

lichess_org_ _free_online_chess

top_rated_tv__sacrifice_to_jashin_vs_aiwaeco22_ _lichess_org

@TheHollidayInn
Copy link

Sounds good! Let me start with that. Doing this is not too difficult. I can still try with google analytics, and it would probably work.

Another option is using socket.io, but we would need to a server to serve the websocket connection. I'm pretty sure gatsby is only static.

@QuincyLarson
Copy link
Author

@TheHollidayInn OK - great! Thanks for looking into this.

We might be able to add a component that isn't static. Kind of like how our full text search bar works even though it's embedded into a static Gatsby page.

@TheHollidayInn
Copy link

Np! I just meant that it is static in the sense that it doesn't have a server (it still has interactive js).

@QuincyLarson
Copy link
Author

QuincyLarson commented Dec 23, 2017

@TheHollidayInn OK - it sounds like we're on the same page then :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants