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

Add Debugging Mechanism for Apple News API Requests #1110

Closed
attackant opened this issue Apr 29, 2024 · 3 comments · Fixed by #1111
Closed

Add Debugging Mechanism for Apple News API Requests #1110

attackant opened this issue Apr 29, 2024 · 3 comments · Fixed by #1111
Assignees
Labels
enhancement New feature or request php Requires understanding PHP
Milestone

Comments

@attackant
Copy link

Description

Implement a debugging mechanism in the Apple News plugin that allows developers to easily preview the full API request data for a given post. The debugging feature should be easily accessible, but restricted to admin users only for security.

  1. Add a new debug_api() method to the Apple_Push class that outputs the API request data when a specific URL parameter (apple_news_debug) is present and the current user is an admin.
  2. The debug_api() method should output the post ID for context, followed by the JSON article data, asset bundles, and post metadata. The output should be clearly separated and formatted for readability.
  3. After outputting the debug data, the method should exit to prevent further execution and avoid actually sending the API request.
  4. Add a new "Debugging" section to the plugin that explains how to use the apple_news_debug parameter to preview API request data.

To test this feature:

  • Verify that the debug output is only shown when the URL param is present and the user is an admin
  • Confirm the output contains all expected API request data and is formatted properly
  • Ensure normal API requests are not affected when the debug parameter is not set

This debugging feature will be a valuable tool for plugin developers, making it much easier to diagnose API issues and validate the data being sent to Apple News.

Use Case

As a developer working on the Apple News plugin, I often need to see the exact data being sent to the Apple News API for a given post. This is necessary for validating the data and diagnosing any issues with the API requests. However, currently there's no easy way to inspect the full request payload, especially for data that's not included in the typical debug output, such as metadata added by custom rules.

@attackant attackant added the enhancement New feature or request label Apr 29, 2024
@attackant attackant self-assigned this Apr 29, 2024
@kevinfodness
Copy link
Member

I think we should add a menu option in the Apple News post list (like we have for Download, which downloads the article JSON) which previews what would be sent to the API. Same idea as what you have above, except making it easier to access by putting it in the same place where users already download article JSON. That interface is already restricted to users with manage_options by default (so, admins).

@attackant
Copy link
Author

attackant commented Apr 29, 2024

Sounds good, what release should this go in, do you think?

@kevinfodness
Copy link
Member

Closing since it's merged to the 2.5.0 branch, will be part of the release when it goes out

@kevinfodness kevinfodness added the php Requires understanding PHP label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request php Requires understanding PHP
Projects
None yet
2 participants