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

Greaselion makes excessive calls to Twitter API #40

Merged
merged 3 commits into from
Jan 18, 2021

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Jan 18, 2021

Resolves brave/brave-browser#13578

Description

Limit the number of calls we make to the Twitter API to avoid rate limiting. In addition, cache fetched publisher info in a small LRU cache to avoid making unnecessary calls in the first place.

Test Plan

  • Clean profile
  • Launch Twitter
  • Visit various Twitter users using multiple tabs, switching tabs, scrolling, etc.
  • Ensure that we don't call https://api.twitter.com/1.1/users/show.json?screen_name={$user} more than once every 3 seconds

zenparsing
zenparsing previously approved these changes Jan 18, 2021
this.maxEntries = maxEntries
}

public get (key: string): T | null {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need public, since methods are public by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@jonathansampson
Copy link

I just built the PR and tested in Nightly on a fresh profile, looks good. Only a single call for publisher information was made across 2 profile tests. That said, these calls do appear to fire even when the user has not yet opted in to Brave Rewards. For instance, the calls are made before the user has clicked Start using Brave Rewards in the Rewards drop-down. We should check the state of this button/opt-in when evaluating the precondition for this script to run. I'll create a new issue for tracking this. It's not a regression, so not worth blocking, IMHO.

image

@emerick emerick merged commit c21c10f into master Jan 18, 2021
@emerick emerick deleted the rewards-twitter-fix-excessive-api-calls branch January 18, 2021 17:11
@emerick emerick mentioned this pull request Jan 18, 2021
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.

Greaselion makes excessive calls to Twitter API
3 participants