chore(debug): add gated HTTP tracer + e2e production profile#473
Open
Clap404 wants to merge 13 commits into
Open
chore(debug): add gated HTTP tracer + e2e production profile#473Clap404 wants to merge 13 commits into
Clap404 wants to merge 13 commits into
Conversation
`HttpClient::traceLog()` appends to `<module-root>/trace.log` (host- visible via the e2e bind-mount). Hooked in: - `HttpClient::exec()` — request URL + response status/body (500B) - `CloudSyncClient::upload()` — jobId, shopId, items, fullSync, url - `apiHealthCheck` / `apiShopContent` controllers via `HttpClient::traceIncoming()` — method, URI, remote, auth presence, ctype, UA, body TODO comments mark the gate spot for a later env-driven toggle. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CloudSync routes sync requests to apiShopContent only when the module reports v4+. The dev placeholder `0.0.0` made every sync land on legacy controllers (apiOrders, apiInfo, …) that this module no longer ships, so PrestaShop 404'd before our controllers ran — looking like sync never fired at all. Makefile's replace_version rewrites this at zip build from the git tag, so prod zips were unaffected. This commit lives on the debug branch only; do not merge to main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add traceLog calls in ApiShopContentService::handleDataSync and SynchronizationService::sendFullSync / sendIncrementalSync so we can see where a sync request stops short of reaching CloudSyncClient::upload (empty data, auth failure, wrong branch). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Trace only writes when PrestaShop debug mode is on. No new config key, no install/uninstall hook touch, no toggle outside the standard defines_custom.inc.php flip. Drops the scattered TODO placeholders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The shared prestashop-base environment carries DEBUG_MODE=true, but docker-compose `environment` list overrides replace the whole list instead of merging, so prestashop-prod was inheriting nothing from base — leaving _PS_MODE_DEV_ at its default false. The in-module tracer (gated by debug mode) stayed silent unless we patched defines.inc.php by hand. Re-add DEBUG_MODE=true to the prestashop-prod environment so flashlight picks it up on boot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Default trace destination becomes trace-YYYY-MM-DD.log so each day gets its own file and old ones can be archived/dropped without touching the live file. PS_EVENTBUS_TRACE_FILE still wins as an explicit override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hoist the trace lines into three private static helpers (traceEntry / traceAuthorize / traceBranch) so handleDataSync's cognitive complexity stays under sonar's 15 threshold (php:S3776). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the production-profile docs from the debug branch — they belong in a separate PR if we want to ship them, not bundled with the fixes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
$data already typed array<mixed>; phpstan flagged the narrowed checks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds a self-contained tracing mechanism for ps_eventbus, gated by PrestaShop debug mode (
_PS_MODE_DEV_). No behavioural change in prod zips.What it logs
Each line lands in
trace-YYYY-MM-DD.logat the module root (rotates per day).apiHealthCheck/apiShopContent: method, URI, remote IP, Authorization presence, content-type, UA, body (500B).HttpClient::exec: target URL, response status, body (500B).jobId,shopId, item count, fullSync flag, target URL.handleDataSyncentry,authorize()result,sendFullSync/sendIncrementalSyncbranch + row count, "skip upload: data empty" reason.Gate
HttpClient::isTraceEnabled()returnsdefined('_PS_MODE_DEV_') && _PS_MODE_DEV_. Helpers no-op when off, so prod zips ship with the helpers compiled in but silent.e2e production profile
e2e-env/docker-compose.yml:productionprofile withprestashop-prod+cloudflared-prodservices that mount.config.prod.phpoverconfig.php, exposing the shop via the Cloudflare tunnel for real ps-accounts.prestashop-prodcarriesDEBUG_MODE=trueso flashlight flips_PS_MODE_DEV_on boot (the sharedprestashop-baseenv was being silently overridden by service-level env lists).cloudsync-mockandreverse-proxyconstrained to non-production profiles.0.0.0to4.0.0inps_eventbus.php/config.xmlso CloudSync routes toapiShopContentwhen mounted from raw source. Makefile'sreplace_versionstill rewrites this at zip-build from the git tag, so prod zips are unaffected.Test plan
_PS_MODE_DEV_=false→ trace file not created.DEBUG_MODE=trueflips_PS_MODE_DEV_=true→ trace file written.handleDataSync).🤖 Generated with Claude Code