Skip to content

Add diagnostic logging to in-app support form submission#4414

Draft
joashrajin wants to merge 1 commit into
trunkfrom
fix/pcios-686-support-form-diagnostic-logging
Draft

Add diagnostic logging to in-app support form submission#4414
joashrajin wants to merge 1 commit into
trunkfrom
fix/pcios-686-support-form-diagnostic-logging

Conversation

@joashrajin

Copy link
Copy Markdown
Contributor

Refs PCIOS-686

The in-app Support form (Profile → Help & Feedback → Contact Support) shows the "Oops something went wrong" alert when both submit attempts fail. The submit code path currently emits zero log entries — HTTP status, response body, and URLError details are all discarded before the alert fires. Customer-reported failures (e.g. Zendesk #11265549, #11173685) are therefore impossible to diagnose from exported logs.

This PR is strictly additive diagnostics. Retry behaviour, alert copy, and the public API used by views are unchanged.

Changes

  • ZendeskSupportService
    • import PocketCastsUtils for FileLog
    • Log POST URL on every attempt (with baseURL / newBaseURL label)
    • Log HTTP status + response-body excerpt (≤256 bytes) on non-2xx
    • Log URLError code + description on transport failures
    • Log "submit succeeded" on success
    • Enrich SupportRequestError.serverError to carry statusCode and bodyExcerpt; add .invalidResponse for non-HTTPURLResponse
  • MessageSupportViewModel
    • Log every submitRequest entry (with isRetrying flag)
    • Log the recursive retry trigger and the final user-visible failure

Why this matters

Today, when a customer reports "submit failed", we have nothing actionable — no status code to tell auth/rate-limit/server-down apart, no body to surface a Zendesk validation message, no signal whether both URLs failed or just one. After this change, a single exported log file pinpoints which Zendesk endpoint failed and why.

To test

  1. Build & run on a simulator/device.
  2. Open Profile → Help & Feedback → Contact Support, fill in the form, tap Submit.
  3. Profile → Help & Feedback → Logs — confirm new entries appear:
    • ZendeskSupportService: POST https://… (baseURL)
    • ZendeskSupportService: baseURL submit succeeded — HTTP 201 (or similar)
  4. To exercise the failure path, temporarily point baseURL and newBaseURL at an invalid host (in the relevant ZDConfig), submit again, and confirm:
    • MessageSupportViewModel: submitRequest — isRetrying: false, …
    • ZendeskSupportService: baseURL submit failed — …
    • MessageSupportViewModel: submit failed on first attempt — retrying via newBaseURL. …
    • MessageSupportViewModel: submit failed after retry — surfacing error: …
    • The "Oops something went wrong" alert appears.

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary. (Diagnostic-only — not user-facing; CHANGELOG entry skipped.)
  • I have considered adding unit tests for my changes. (No existing tests for ZendeskSupportService; the behaviour change is purely logging output.)
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics. (N/A — no analytics changes.)

Note: I couldn't run a full Xcode build locally (only Command Line Tools installed). swiftc -parse passes; CI will provide the real type-check signal.

The in-app support form ("Profile > Help & Feedback > Contact Support")
shows "Oops something went wrong" when submission fails, but the submit
code path emits zero log entries — HTTP status, response body, and
URLError details are all discarded before the alert fires. That makes
customer-reported failures (PCIOS-686) impossible to diagnose from
exported logs.

This change is strictly additive diagnostics:
- ZendeskSupportService: log POST URL, HTTP status, response body excerpt
  (≤256 bytes), and URLError details on failure. Enrich serverError with
  the status code and body excerpt.
- MessageSupportViewModel: log submit attempts, the recursive retry
  trigger, and the final user-visible failure.

Retry behavior, alert copy, and the public API surface used by views are
unchanged.

Refs: PCIOS-686
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

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