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

Track monetized and non-monetized time properly #98

Merged

Conversation

sharon-wang
Copy link
Member

Fixes: #79

Previously, we assumed that as soon as we see a payment pointer on a website (at an origin), that the origin is always considered to be monetized. So, once we decided that an origin is monetized, any time spent on the site was considered monetized time spent on the site. However, this is a flawed assumption, since sites such as YouTube may only contain payment pointers (meta tags) on specific videos and not others. So, some of the time spent on the site is monetized and some is non-monetized. This PR updates how we track time by checking for a payment pointer as we track time, to store
time spent properly.

We no longer store detailed data for every single origin -- only monetized origins are stored. Additionally, counting monetized
visits and associated functions have been removed as they were not being used or were redundant. The isCurrentlyMonetized field has been removed from AkitaOriginData as it was a major part of the problematic monetized time tracking. The text in the top site detail has been updated to point out that the time is monetized time, just to be clear.

@sharon-wang
Copy link
Member Author

I've tested this with the Coil extension installed and I'm seeing the correct outcome.

Test steps

  1. Ensure Coil is installed and user is logged in
  2. Install Akita from scratch (no existing data)
  3. Go to a web monetized YouTube vid such as https://www.youtube.com/watch?v=sApKXmwhg4g&ab_channel=Simmer.io
  4. Watch the video for X minutes
  5. Open Akita
  6. Hover on top site circle for YouTube, see that X minutes of monetized time on the site is indicated
  7. Go to the YouTube homepage (not a monetized page) and stay there for Y minutes
  8. Open Akita
  9. Hover on top site circle for YouTube, see that X minutes of monetized time on the site is still indicated, since the Y minutes on the homepage do not count as monetized time

@sharon-wang
Copy link
Member Author

Also a note that you may need to install Akita from scratch again, since the data storage has changed. You might see weird behaviour in the UI otherwise.

Copy link
Member

@vezwork vezwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to test locally now. I have one question:

Currently you are counting any time on a page containing a monetization tag as monetized. I'm wondering what your thoughts are on instead not counting time as monetized until after the cachedPaymentPointer is validated? Then the monetized time would match more closely with the amount of time you see the monetized Akita extension icon, and invalid payment pointers would not count for monetized time.

src/content_main.js Show resolved Hide resolved
src/main.js Outdated Show resolved Hide resolved
src/main.js Outdated Show resolved Hide resolved
src/main.js Outdated Show resolved Hide resolved
@sharon-wang
Copy link
Member Author

Currently you are counting any time on a page containing a monetization tag as monetized. I'm wondering what your thoughts are on instead not counting time as monetized until after the cachedPaymentPointer is validated? Then the monetized time would match more closely with the amount of time you see the monetized Akita extension icon, and invalid payment pointers would not count for monetized time.

The cachedPaymentPointer would have already been validated 1 second prior (previous setInterval iteration). We could move setting previousStoreTime = currentTime; to after the paymentPointerOnPage is validated and cachedPaymentPointer is set to paymentPointerOnPage?

@vezwork
Copy link
Member

vezwork commented Dec 29, 2020

The cachedPaymentPointer would have already been validated 1 second prior (previous setInterval iteration).

There is no garantee that the cachedPaymentPointer has been validated. For example: if isPaymentPointerValid was called to check if the cachedPaymentPointer was valid, but it came back as invalid, cachedPaymentPointer would still be non-null, or it's quite possible and even most likely that validation will take more than 1 second and cachedPaymentPointer would also be non-null in that case.

We could move setting previousStoreTime = currentTime; to after the paymentPointerOnPage is validated and cachedPaymentPointer is set to paymentPointerOnPage?

I think something along these lines could work but my suggestion would be just to change line 145 to

const isMonetizedTime = cachedPaymentPointer !== null && await isPaymentPointerRecentlyValidated(cachedPaymentPointer);

This should work, noting that time before the payment pointer is validated is not counted as monetized time even after the payment pointer is validated. I think this is reasonable since it is necessary to validate a payment pointer before monetization starts.

@vezwork
Copy link
Member

vezwork commented Dec 29, 2020

Found a bug in my testing:

Github is showing up as a top monetized site although it shouldn't be. Strangely, the UI even says that github has no monetized time.
This is only happening after I visit another site which is actually monetized.

Copy link
Member Author

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new changes to storeDataIntoAkitaFormat/storeDataIntoAkitaFormatNonMonetized fixes the issue in #98 (comment)

src/content_main.js Outdated Show resolved Hide resolved
Copy link
Member

@vezwork vezwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes, I would say they improve the code quality and are clear. Just one issue about repeated validations otherwise this looks great.

src/content_main.js Outdated Show resolved Hide resolved
src/content_main.js Outdated Show resolved Hide resolved
src/content_main.js Show resolved Hide resolved
src/content_main.js Show resolved Hide resolved
@vezwork
Copy link
Member

vezwork commented Dec 29, 2020

Just did some more testing and everything is working great :)

@vezwork
Copy link
Member

vezwork commented Dec 30, 2020

Thanks for the changes, looks great! Please squash and merge.

Previously, we assumed that as soon as we see a payment pointer on
a website (at an origin), that the origin is always considered to
be monetized. So, once we decided that an origin is monetized, any
time spent on the site was considered monetized time spent on the
site. However, this is a flawed assumption, since sites such as
YouTube may only contain payment pointers (meta tags) on specific
videos and not others. So, some of the time spent on the site is
monetized and some is non-monetized. This PR updates how we track
time by checking for a payment pointer as we track time, to store
time spent properly.

We no longer store detailed data for every single origin -- only
monetized origins are stored. Additionally, counting monetized
visits and associated functions have been removed as they were
not being used or were redundant. The `isCurrentlyMonetized` field
has been removed from AkitaOriginData as it was a major part of
the problematic monetized time tracking. The text in the top site
detail has been updated to point out that the time is monetized
time, just to be clear.

Signed-off-by: sharon-wang <[email protected]>
@sharon-wang sharon-wang merged commit b4cdb93 into esse-dev:master Dec 30, 2020
@sharon-wang sharon-wang deleted the storetimewithpaymentpointer branch December 30, 2020 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] On sites with monetized AND non-monetized pages, non-monetized pages count for monetized time
2 participants