alleyinteractive / apple-news

The Publish to Apple News plugin enables your WordPress blog content to be published to your Apple News channel.
https://wordpress.org/plugins/publish-to-apple-news/
GNU General Public License v3.0
152 stars 70 forks source link

Add Debugging Mechanism for Apple News API Requests #1110

Closed attackant closed 1 month ago

attackant commented 2 months ago

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:

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.

kevinfodness commented 2 months ago

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 commented 2 months ago

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

kevinfodness commented 1 month ago

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