Skip to content

feat: support access logs — endpoint + auto-registration - #1544

Open
ludoviccardinale wants to merge 6 commits into
mainfrom
feat/support-logs-endpoint
Open

feat: support access logs — endpoint + auto-registration#1544
ludoviccardinale wants to merge 6 commits into
mainfrom
feat/support-logs-endpoint

Conversation

@ludoviccardinale

Copy link
Copy Markdown

Summary

  • Add `SupportLogs` front controller: lists and streams PS Checkout log files from `var/logs/`, secured by a per-shop Bearer token (`PS_CHECKOUT_SUPPORT_TOKEN`)
  • Add `SupportTokenService`: generates and stores a unique token per shop
  • Add `SupportRegistrationService`: auto-registers the shop with the support tool on each BO admin page load (24 h cooldown)
  • Add upgrade script `upgrade/upgrade-8.5.2.0.php`: provisions `PS_CHECKOUT_SUPPORT_TOKEN` for existing shops and resets registration cooldown
  • Fix `LoggerFileFinder::getFiles()`: skip files whose name suffix is not a valid date (e.g. Monolog channel files)

How it works

On first BO page load after install/upgrade, the module POSTs `{shopUrl, shopUuid, token}` to the support tool API. The support agent can then fetch logs directly from the merchant's shop using the token — no manual copy-paste needed.

The `SupportLogs` endpoint is a standard PS front controller secured by a Bearer token. It returns a JSON list of log files or streams a paginated file.

Related PRs

Test plan

  • `PS_CHECKOUT_SUPPORT_TOKEN` generated on install/upgrade
  • `GET SupportLogs` with valid token returns file list
  • `GET SupportLogs?file=...` streams log content
  • Invalid/missing token returns 401
  • `PS_CHECKOUT_SUPPORT_REGISTERED_AT` updated after auto-registration
  • `LoggerFileFinder` no longer crashes on channel-based log filenames

🤖 Generated with Claude Code

ludoviccardinale and others added 5 commits May 20, 2026 15:24
Add a public front controller (SupportLogs) that exposes paginated
log files to the PrestaShop support tool, protected by a per-shop
Bearer token stored in PS Configuration (PS_CHECKOUT_SUPPORT_TOKEN).
The token is generated at install time and can be viewed/rotated from
the backoffice debug panel via two new AJAX actions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…troller

Add SupportRegistrationService that periodically registers the shop
(UUID, URL, Bearer token) with the internal support tool API, triggered
from hookActionAdminControllerSetMedia with a 24h cooldown.

Rewrite SupportLogs front controller to list and stream log files
directly from var/logs/ without using LoggerFileFinder, avoiding a
crash caused by non-date filenames in the log directory.

Add PS_CHECKOUT_SUPPORT_TOOL_REGISTER_URL, PS_CHECKOUT_SUPPORT_API_KEY,
and PS_CHECKOUT_SUPPORT_REGISTERED_AT configuration keys.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generates PS_CHECKOUT_SUPPORT_TOKEN for all existing shops that don't
have one yet, and resets PS_CHECKOUT_SUPPORT_REGISTERED_AT so the
auto-registration with the support tool fires on the next admin page
load after the module is updated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove PS_CHECKOUT_SUPPORT_TOOL_REGISTER_URL and PS_CHECKOUT_SUPPORT_API_KEY
from PS Configuration (would always be empty for merchants). Read them
instead from the module .env via EnvInterface — same pattern as PayPal
credentials, filled at packaging time and never committed for production.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Files named with a Monolog channel prefix (e.g. ps_checkout-1-http-2026-05-06)
caused DateUtility::formatDate to throw, crashing the admin log viewer.
Skip those entries instead of aborting the whole listing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Matt75

Matt75 commented May 21, 2026

Copy link
Copy Markdown
Contributor

@ludoviccardinale Hello, the latest version is currently available on the 5.5.x branch. The main branch appears to be outdated and is still on 5.2.x.

@Matt75 Matt75 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please rebase on branch 5.5.x

- Delete SupportLogs front controller (ps8 + ps9)
- Delete SupportTokenService and SupportRegistrationService from core
- Remove DI entries from config/common.yml (ps8 + ps9)
- Remove use statement and hookActionAdminControllerSetMedia call from ps_checkout.php (ps8 + ps9)
- Remove upgrade-8.5.2.0.php (ps8 + ps9)
- Remove PS_CHECKOUT_SUPPORT_TOKEN and PS_CHECKOUT_SUPPORT_REGISTERED_AT from DefaultConfiguration

All support tooling functionality is now in the standalone ps_support_tooling module.

Co-Authored-By: Claude Sonnet 4.6 <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