Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeeksBLaBla stats #137

Open
aboullaite opened this issue May 29, 2020 · 18 comments
Open

GeeksBLaBla stats #137

aboullaite opened this issue May 29, 2020 · 18 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed Need To Discuss

Comments

@aboullaite
Copy link
Contributor

This is more of a discussion. Is there a way where we can get metrics and stats about viewers/listeners? How many hours people have watched/listened ?

@yjose
Copy link
Member

yjose commented May 29, 2020

Yeah, I think it's possible using Facebook graph API https://developers.facebook.com/docs/graph-api/reference/video/video_insights/
but I am not sure if we have access to videos created under the DevC group.

@yjose
Copy link
Member

yjose commented May 29, 2020

also, we can get podcast platforms analytics using anchor account, unfortunately, the only solution is to scrap data using cypress 😀(no open API for anchor)

@aboullaite
Copy link
Contributor Author

You can get videos info from group as well https://developers.facebook.com/docs/graph-api/reference/v7.0/group/videos

@aboullaite
Copy link
Contributor Author

@kafiil We want to get number of views and listeners! we need to get them from Facebook, youtube and anchor

@yjose
Copy link
Member

yjose commented Jun 17, 2020

In Case someone interested to work on this.
The idea is to add a new field for episode Node https://github.com/DevC-Casa/geeksblabla.com/blob/master/gatsby-node.js#L79
First, you need to create a function getViewsForVideoId that returns views number from Facebook API and then you can use it to create a new field for Episode Node called views.

lets me know if you need more info?

@yjose yjose added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 17, 2020
@yjose
Copy link
Member

yjose commented Jun 17, 2020

@ismailElazizi any idea when we need to add stats ( in the statistics section, the home page ) or for every episode card?

@zakariaelas
Copy link
Contributor

@yjose @aboullaite if possible, I would like to work on adding a views count for every episode by querying the Facebook Graph API. Also, don't you guys think it would be better to get this data at runtime on the client (because views change frequently), as opposed to build time ? I am bringing this up because @yjose mentioned creating a node field for each episode, which from what I know, implies getting data at build time.
Would love to hear your take on this 🙏

@yjose
Copy link
Member

yjose commented Jul 19, 2020

Yeah @zakariaelas Go ahead, but I think calculating views in the build time is better for page performance, take as example the 'blabla' page, i think it would be very slow as you need to fetch views for 50 episode at once, also fetching views require adding fb sdk to page which will increase load time too.
And we think to add global views to home page in statistics section and this would be hard to calculated in client side.

Regarding your point of view, i think it would be acceptable to update views every week as we need to rebuild the website on adding new episodes.

@zakariaelas
Copy link
Contributor

Thank you @yjose for the clear explanation. At first I thought the views count would appear on the detail view of every episode, which motivated a bit the idea behind realtime fetching. However, I totally agree with what you mentioned, and your approach is better 👌.

@yjose
Copy link
Member

yjose commented Jul 19, 2020

I would love if you can add it on episode card and episode view too.

@zakariaelas
Copy link
Contributor

Upon further inspection, it turns out the FB Graph API does not support stats for videos in facebook groups, but it does for pages.
From the facebook docs under limitations:

Insights for Videos on Users or Groups are not available

This would imply that some of the episodes would have an empty view count as not all episodes come from the facebook page.

What do you think @yjose ?

@yjose
Copy link
Member

yjose commented Jul 26, 2020

Hmm , I see

Maybe we can return an estimation for group videos, as you said this is a limitation from Facebook, so nothing we can do here.

I would recommend returning a random number between 2000 - 4000 views in groups Video 😁 , What you think?

@zakariaelas
Copy link
Contributor

zakariaelas commented Jul 26, 2020

Sounds good to me @yjose . I can't say much on the numbers though because I don't know if Facebook allows you to see the views count on their app as an administrator. I think it's definitely better than leaving other episodes' view count as blank.

On a side note, one of the administrators of the page will need to acquire an access token and add it as an env variable. This is because facebook only allows admins of a page to query for video insights.
In order to get the facebook token, please read this guide from the fb docs. These are the relevant steps summarized below:

  1. You will need to register your facebook account on the Facebook Developers platform.
  2. Get a short lived user access token from the Graph Explorer tool.
  3. Get a long lived user access token: This is particularly useful because it will allow you to get a permanent token, meaning you will not have to acquire a new one everytime you build (short lived access tokens expire in an hour for facebook pages).
  4. Get a page access token using the long lived user token from step 2 above. This token is what will allow the app to access information about videos published on the page.

Why do we need a user access token AND a page access token?

Just in case you are wondering just like I did, this answered it for me:

To get a Page access token, you will need a User access token. This User access token must be generated by a person who can perform the action on the Page.

@yjose
Copy link
Member

yjose commented Jul 26, 2020

thank you @zakariaelas for the great explanation, will generate tokens and back to you

@zakariaelas
Copy link
Contributor

@yjose you're welcome 👍 .

I played a bit with the positioning of the views count. Initially, I thought about having an "eye" icon just to save up some space, but I'm not sure how you guys would get the svg for that.

Anyways, please let me know what you think. Would love to hear other suggestions 😃 .

image

@yjose
Copy link
Member

yjose commented Jul 26, 2020

I think your solution is clean. Go gor it, i would recommend using x.x k format ( 2.1k) for episode with views more than 1k.

For the card. I am ok with it
For episode view. I would prefer it under date 🤔

@yjose
Copy link
Member

yjose commented Jul 27, 2020

@zakariaelas Unfortunately we need to wait for Facebook app review to make sure the access token will work as expected. this is something new that Facebook has implemented in the last few months due to all the data leaking controversy 😏

@zakariaelas
Copy link
Contributor

@yjose thank you for the feedback.

It's okay, i'll just keep working on my fork until you hear back from facebook 👍👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed Need To Discuss
Projects
None yet
Development

No branches or pull requests

3 participants