Skip to content

fix: classify log-delivery failures instead of reporting them as errors#104

Merged
crisryantan merged 1 commit into
developmentfrom
fix/log-delivery-failure-classification
Jun 24, 2026
Merged

fix: classify log-delivery failures instead of reporting them as errors#104
crisryantan merged 1 commit into
developmentfrom
fix/log-delivery-failure-classification

Conversation

@alexs-mparticle

Copy link
Copy Markdown
Collaborator

Summary

The kit's LoggingService.log() sends an INFO-level log fire-and-forget. When that POST failed, its onError callback re-reported the failure as an UNKNOWN_ERROR / ERROR-severity diagnostic.

Log-delivery failures are dominated by client-side network conditions — ad-blockers, offline clients, and WebView/CORS restrictions — which are common and benign. Reporting them at ERROR severity made them indistinguishable from genuine SDK errors and inflated the observed error rate with noise.

This PR reclassifies the signal rather than swallowing it (silently dropping it would also hide genuine server-side delivery failures):

  • ReportingTransport.send now inspects response.ok. fetch only rejects its promise on network failures; an HTTP 5xx resolves with ok === false and was previously swallowed entirely. A non-2xx response now throws an enriched DeliveryError carrying statusCode, so callers can distinguish server-side from client-side failure.
  • LoggingService.log classifies the failure. Network/client failures are reported as a WARNING with a new LOG_DELIVERY_FAILURE code; server-side (5xx) failures remain at ERROR severity so genuine delivery outages stay visible and independently alertable.

code and severity are free-form strings serialized into the request body with no downstream branching, so adding the code and changing the severity is not a breaking change.

Testing Plan

  • Updated the existing LoggingService failure test to assert the new WARNING / LOG_DELIVERY_FAILURE classification on a network rejection.
  • Added a test asserting a server-side 5xx is classified as ERROR / LOG_DELIVERY_FAILURE.
  • Added a transport test confirming a 5xx response (which fetch does not reject) is now surfaced rather than swallowed.
  • Full suite green (vitest run: 207 passing); eslint clean; bundle builds. dist/ is intentionally not included — it is regenerated by CI on merge per repo convention.

The kit's LoggingService POSTs an INFO log fire-and-forget; on send failure
its onError callback re-reported the failure as an UNKNOWN_ERROR / ERROR
diagnostic. Client-side network failures (ad-blockers, offline, WebView/CORS
restrictions) are common and benign, so this inflated the WSDK error rate with
noise that is indistinguishable from genuine SDK errors.

Two changes:
- ReportingTransport.send now inspects response.ok. fetch only rejects on
  network failures; an HTTP 5xx resolves with ok === false and was previously
  swallowed entirely. A non-2xx response now throws an enriched DeliveryError
  carrying statusCode so callers can tell server-side from client-side failure.
- LoggingService.log classifies the failure: network/client failures are
  reported as a WARNING with the new LOG_DELIVERY_FAILURE code; server-side
  (5xx) failures stay at ERROR severity so genuine delivery outages remain
  visible and independently alertable.

Tests updated to assert the new code/severity split and to cover the
previously-uncaught 5xx path.
@crisryantan
crisryantan merged commit cec8445 into development Jun 24, 2026
5 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 25, 2026
## [1.28.2](v1.28.1...v1.28.2) (2026-06-25)

### Bug Fixes

* classify log-delivery failures instead of reporting them as errors ([#104](#104)) ([cec8445](cec8445))
@mparticle-automation

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.28.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants