Skip to content

feat(integrations): details modal and Run now for integration logs#4757

Open
chickenn00dle wants to merge 14 commits into
trunkfrom
feat/improve-integrations-activity-logs
Open

feat(integrations): details modal and Run now for integration logs#4757
chickenn00dle wants to merge 14 commits into
trunkfrom
feat/improve-integrations-activity-logs

Conversation

@chickenn00dle
Copy link
Copy Markdown
Contributor

@chickenn00dle chickenn00dle commented May 26, 2026

All Submissions:

Changes proposed in this Pull Request:

Adds two affordances to the per-integration activity logs view (Audience › Integrations › Logs) to make troubleshooting Action Scheduler retries practical:

  • View details — opens a modal showing the full action payload (decoded args, with extended_args preferred when the indexed column was truncated), metadata (action ID, group, scheduled date, attempts, last attempt), and the per-action Action Scheduler log trail.
  • Run now — for pending actions only, runs the Action Scheduler action immediately and refreshes the row with the post-run status. Mirrors WooCommerce's default AS admin behavior.

Both REST endpoints sit behind the existing wizard permission gate. The detail endpoint validates that the action belongs to the integration before responding, returning a generic 404 on cross-group access so other-group actions can't be probed through it. Errors thrown by the action's callback during a Run are surfaced as a 200 response with status: 'failed' and the last AS log message — AS itself records the failure and writes the log, so the UI just refetches and shows the result in a snackbar.

Follow-up to #4671 per Miguel's non-blocking review feedback.

Closes DSGNEWS-160.

Screenshot 2026-05-26 at 17 40 36

How to test the changes in this Pull Request:

  1. Spin up an isolated env: n env create dsgnews-160 --worktree newspack-plugin:feat/improve-integrations-activity-logs --up && n setup --env dsgnews-160 --yes --woocommerce.
  2. Visit Newspack › Audience › Integrations and open the Logs view for an integration that has scheduled actions (Mailchimp, ActiveCampaign, etc.). If you need to generate fixtures, register a reader or trigger a data event so the integration enqueues actions.
  3. On a pending row, open the row "…" menu → View details. Verify the modal shows: event label + status badge, action ID, scheduled (GMT), group, attempts, last attempt (or ), pretty-printed args JSON in a <pre> block, and the AS log list.
  4. On a pending row, click Run now. Verify a success snackbar appears ("Action completed.") and the row's status flips to Success in place.
  5. On a row whose hook callback fails (or temporarily break a callback to force one), click Run now. Verify a failure snackbar shows the AS log message and the row flips to Failed.
  6. On any complete, failed, or canceled row, confirm Run now is hidden from the row menu but View details still opens correctly.
  7. Force a not-found state: open View details, then rewrite the action_id segment of the request in the devtools network tab and re-issue. The modal should show "This action no longer exists."
  8. If you can catch an in-progress action in the list, confirm its status badge renders as "In progress" (no raw-string fallback).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Automated tests were intentionally not added — Action Scheduler is heavy to mock for low value here. Verification is via the manual QA steps above in an isolated env. PHP/JS/SCSS linting and n build all pass.

chickenn00dle and others added 12 commits May 26, 2026 12:48
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d unset

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the Audience → Integrations → Logs experience by adding per-action troubleshooting tools: a details modal (full payload + Action Scheduler log trail) and a “Run now” action for pending jobs, backed by new wizard-gated REST endpoints.

Changes:

  • Add DataViews row actions for View details (modal) and Run now (POST + refresh + snackbar).
  • Introduce shared JS constants/helpers for status labeling (including in-progress) and timestamp formatting.
  • Add REST endpoints to fetch per-action detail (including extended args) and to synchronously run pending actions, plus Action Scheduler helper methods to fetch a single action and its logs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/wizards/audience/views/integrations/style.scss Adds styling for the new action-details modal layout (meta grid, args pre block, logs list).
src/wizards/audience/views/integrations/logs-view.js Adds DataViews row actions: details modal + “Run now” trigger with notices and refetch.
src/wizards/audience/views/integrations/log-details-modal.js New modal component that fetches and renders action payload, metadata, and AS log entries.
src/wizards/audience/views/integrations/constants.js New shared constants for API base, status map (incl. in-progress), and timestamp formatting.
includes/wizards/audience/class-audience-integrations.php Registers two new REST routes and implements detail + run handlers with integration ownership checks.
includes/reader-activation/class-integrations.php Adds action_belongs_to_integration() helper to gate per-integration action access.
includes/class-action-scheduler.php Adds helper methods to fetch a single AS action and normalized per-action logs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chickenn00dle chickenn00dle changed the title feat(audience): details modal and Run now for integration logs feat(integrations): details modal and Run now for integration logs May 26, 2026
@chickenn00dle chickenn00dle marked this pull request as ready for review May 26, 2026 18:50
@chickenn00dle chickenn00dle requested a review from a team as a code owner May 26, 2026 18:50
@chickenn00dle chickenn00dle self-assigned this May 26, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants