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

Display X/Twitter API rate limits #354

Merged
merged 15 commits into from
Dec 18, 2024

Conversation

s3rgiosan
Copy link
Member

@s3rgiosan s3rgiosan commented Dec 16, 2024

Description of the Change

Display X/Twitter API rate limits

How to test the Change

Changelog Entry

Added - Admin dashboard widget for easy access to API usage statistics.
Changed - Display API usage statistics in the "Autopost to X/Twitter" block editor panel.

Credits

Props @s3rgiosan

Checklist:

@s3rgiosan
Copy link
Member Author

Dashboard widget
Screenshot 2024-12-16 at 17 07 19

Block editor
Screenshot 2024-12-16 at 17 07 15

@s3rgiosan s3rgiosan marked this pull request as ready for review December 16, 2024 17:14
@s3rgiosan s3rgiosan requested review from iamdharmesh and removed request for dkotter and jeffpaul December 16, 2024 17:14
Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR, @s3rgiosan! This looks great and tests well. I just have a few points to discuss before we conclude and mark this as ready for merge:

  1. The rate limit for the 15-minute window is very high (1079999 out of 1080000). I don't think it will ever be utilized. How about we drop displaying it and only show the 24-hour limit for the user and app?

  2. In the Block editor panel, the note under the limits currently appears for each account. Maybe we should display it only once, similar to how it's done for the dashboard widget. Additionally, how about keeping the rate limits data hidden until the account toggle is enabled?

Screenshot 2024-12-17 at 4 04 16 PM

Thank you.

includes/core.php Outdated Show resolved Hide resolved
@s3rgiosan
Copy link
Member Author

Hi @iamdharmesh

The rate limit for the 15-minute window is very high (1079999 out of 1080000). I don't think it will ever be utilized. How about we drop displaying it and only show the 24-hour limit for the user and app?

Agreed. Since those headers are already being stored, they'll be available if we ever need to display them. I've removed them from both the dashboard and the block editor panel.

In the Block editor panel, the note under the limits currently appears for each account. Maybe we should display it only once, similar to how it's done for the dashboard widget. Additionally, how about keeping the rate limits data hidden until the account toggle is enabled?

Both things were addressed. Can you review again?

Thanks!

@iamdharmesh
Copy link
Member

Hi @s3rgiosan,

Thanks for the quick updates on this; it looks great now. Apologies for bringing up one more thing to discuss. As we are using the same app for all accounts, it would be great if the limits could be updated for each account whenever a tweet is posted from any account. Currently, it only reflects on the account from which the tweet was made. This is not a major issue and only comes into play when multiple accounts are connected to the site (which is not always the case), but I just wanted to hear your thoughts on this. Otherwise, everything looks good to me.

Screenshot 2024-12-17 at 6 04 05 PM

Thank you.

@s3rgiosan
Copy link
Member Author

@iamdharmesh Does the plugin support multiple connected apps, or is it limited to a single one? If it's limited to one, we could store the app's rate limits at a global level instead of per account. Alternatively, whenever a tweet is made, we could iterate through all accounts to update their corresponding app limit values.

@iamdharmesh
Copy link
Member

@iamdharmesh Does the plugin support multiple connected apps, or is it limited to a single one?

@s3rgiosan it is limited to a single app. All user accounts are connected using the same app.

@s3rgiosan
Copy link
Member Author

Thanks. I'll take a look and update the PR

@s3rgiosan
Copy link
Member Author

Hi @iamdharmesh — I’ve updated the PR as requested. The limits are now displayed per user account, followed by the app limits. The app limits are fetched from the first user account.
When a tweet is sent, only the user account that sent the tweet gets its user-specific limits updated, and all user accounts are updated for "global" and app limits.

Dashboard
Screenshot 2024-12-17 at 23 34 42

With one account
Screenshot 2024-12-17 at 23 42 09

With more than one account
Screenshot 2024-12-17 at 23 41 50

Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

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

@s3rgiosan Thanks for making all the changes here! Things look good, test well, and are ready to be merged.

Note: I made some minor changes to fix the user rate limit reset issue for another user and updated the UI slightly

@iamdharmesh iamdharmesh merged commit 555ef0c into 10up:develop Dec 18, 2024
16 checks passed
@iamdharmesh iamdharmesh modified the milestones: Future Release, 2.3.0 Dec 18, 2024
@s3rgiosan s3rgiosan deleted the feature/rate-monitor branch December 18, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants