Skip to content

Clearer API error logging + branded base URL (v0.1.12)#1

Merged
mohn93 merged 12 commits into
mainfrom
fix/error-logging
Jun 22, 2026
Merged

Clearer API error logging + branded base URL (v0.1.12)#1
mohn93 merged 12 commits into
mainfrom
fix/error-logging

Conversation

@mohn93

@mohn93 mohn93 commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

Released as v0.1.12. Two themes:

  1. Branded API base URL — default baseUrl switched from the raw Supabase functions URL to https://api.pushfire.app/functions/v1/ (same endpoint; keeps the backend project ref out of the SDK and logs).
  2. Clearer API error logging & propagation — a failed request now produces one clear log line and a structured exception, instead of a misleading "Unexpected error" plus duplicate vague lines.

What changed

API client (lib/src/api/pushfire_api_client.dart)

  • Structured PushFireApiExceptions now propagate untouched — a non-2xx response preserves statusCode, code, and responseBody (previously re-wrapped into a generic exception with statusCode == null).
  • Timeouts are labeled (PushFireNetworkException, "timed out after Ns") instead of "Unexpected error".
  • One clear error line via the new PushFireLogger.logApiError, e.g. API error: PATCH update-subscriber -> HTTP 401 code=missing_auth msg="Missing authorization header".
  • HTTP client is now injectable for testing.

Logging hygiene (4 services + impl)

  • "Log once, at the throw site": removed the duplicate 'X failed' lines that fired at every layer for a single failure.
  • Swallowed, non-fatal failures (auto-register, FCM refresh, permission-on-resume) downgraded errorwarning.

Deliberate non-changes (decided during design)

  • Request/response bodies are logged raw — no PII masking, no truncation.
  • All logging stays gated behind enableLogging (default false); failures are silent unless logging is enabled (they still surface via the thrown exception).

Testing

  • New test/api/pushfire_api_client_test.dart (8 tests): structured-error preservation, the "not re-wrapped" regression, 5xx, non-JSON body fallback, SocketException, and timeout — via MockClient (no new deps).
  • Full suite: 362 passing, flutter analyze clean.

Notes

  • Backward compatible: the base-URL change is a transparent equivalent (verified same sb-project-ref); the error change preserves more info. No public API signature changes.
  • Design spec & implementation plan live in the monorepo under docs/superpowers/{specs,plans}/2026-06-22-sdk-error-logging*.

🤖 Generated with Claude Code

@mohn93 mohn93 merged commit 8388288 into main Jun 22, 2026
3 checks passed
@mohn93 mohn93 deleted the fix/error-logging branch June 22, 2026 15:21
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.

1 participant