DEV Community

EchoF76
EchoF76

Posted on

Simple SaaS App Backend Error Tracking API Explained (3 Checks, Optional Source Maps)

A simple error tracking API can give a SaaS app backend the checkout failure inbox it needs for rollback review. Start with capture and grouping when readable exceptions provide enough evidence; source maps become a selection requirement when the browser stack needs decoding. For a marketplace, the safest choice is the least complex tool that still explains the failed checkout.

TL;DR: Choose a simple error tracking API for ordinary SaaS backend exceptions and a practical capture, search, group, and resolve workflow. Choose Sentry or another crash reporting specialist when source maps, crash symbolication, or session replay matter. For rollback safety, require evidence about the release, the checkout stage, and a fresh verification attempt before treating a quieter inbox as recovery.

Silence proves little.

That distinction matters in a storefront with a browser client and an application server. A failed checkout can produce a readable server exception, an opaque browser stack, or no captured exception at all. Those cases demand different evidence. A Python worker can help collect and evaluate that evidence even when the storefront uses Node.js and React; the implementation language of the worker should not dictate the debugging product.

What rollback evidence must a simple SaaS app backend error tracking API preserve?

The useful data flow is short: the checkout application records a sanitized failure with enough local context to identify its release and stage; an error service captures and groups exceptions; an operator reviews the relevant events; a separate checkout probe tests the rollback candidate. Keep the probe result alongside the rollback decision. Error collection explains observed failures, while the probe supplies a deliberate attempt to exercise the path again.

The 3 checks in this walkthrough are release attribution, failure visibility, and successful verification. They are a proposed operating policy, not a vendor's automatic rollback feature. In particular, a group marked resolved is an inbox decision. It does not establish that inventory, payment handling, and order confirmation agree about the transaction. Consider a synthetic order that reaches payment handling but fails at order confirmation: the operator still needs to determine which stage completed before deciding what action is safe. Closing its error group cannot answer that question, and an unchanged group count cannot distinguish a repaired checkout from a checkout nobody has attempted since the rollback. That's why a fresh probe belongs in the decision, with its own result and a clearly attributed candidate release.

Don't retry blindly.

Keep payment details out of the example. A synthetic checkout reference and a stage such as order_confirmation are enough to test the decision logic. In production, decide what identifying information is necessary before sending events anywhere, and verify the service's actual request schema before mapping local fields into it.

Implement the inbox read and rollback evidence checks in Python

This standard-library Python example first reads the error inbox, then runs synthetic evaluation fixtures. Set ERROR_API_ORIGIN to your service's HTTPS origin, without a path, and INFRAI_API_KEY to your credential. The request uses the documented list route without guessing query parameters or response fields. Its dictionaries are local evaluation fixtures, not an error capture API payload; the live response is parsed but deliberately not printed because it may contain sensitive data.

from dataclasses import dataclass
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
import json
import os
import time
from urllib.error import HTTPError
from urllib.parse import urlsplit
from urllib.request import Request, urlopen


def read_inbox():
    origin = os.environ["ERROR_API_ORIGIN"].rstrip("/")
    parts = urlsplit(origin)
    if (parts.scheme != "https" or not parts.netloc
            or parts.path or parts.query or parts.fragment
            or parts.username or parts.password):
        raise ValueError("Use an HTTPS origin without credentials or a path")
    request = Request(
        origin + "/v1/errors/list",
        headers={
            "Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
            "Accept": "application/json",
        },
        method="GET",
    )
    for attempt in range(3):
        try:
            with urlopen(request, timeout=15) as response:
                if not 200 <= response.status < 300:
                    raise RuntimeError(f"Unexpected status {response.status}")
                return json.load(response)
        except HTTPError as exc:
            reason = exc.read().decode("utf-8", errors="replace")
            if exc.code != 429 or attempt == 2:
                raise RuntimeError(f"HTTP {exc.code}: {reason}") from exc
            retry_after = exc.headers.get("Retry-After")
            delay = float(2 ** attempt)
            if retry_after:
                try:
                    delay = max(delay, float(retry_after))
                except ValueError:
                    retry_at = parsedate_to_datetime(retry_after)
                    if retry_at.tzinfo is None:
                        retry_at = retry_at.replace(tzinfo=timezone.utc)
                    delay = max(
                        delay,
                        (retry_at - datetime.now(timezone.utc)).total_seconds(),
                    )
            time.sleep(delay)
    raise RuntimeError("Retry budget exhausted")


@dataclass(frozen=True)
class CheckoutEvidence:
    release: str
    capture_verified: bool
    failures: tuple[str, ...]
    probe_passed: bool | None


def assess(candidate: CheckoutEvidence) -> str:
    if not candidate.release.strip():
        return "hold: release attribution missing"
    if not candidate.capture_verified:
        return "hold: error capture not verified"
    if candidate.failures:
        return "hold: checkout failures require review"
    if candidate.probe_passed is not True:
        return "hold: checkout probe has not passed"
    return "ready for operator review"


cases = {
    "regression": (
        CheckoutEvidence(
            release="checkout-candidate",
            capture_verified=True,
            failures=("order_confirmation",),
            probe_passed=False,
        ),
        "hold: checkout failures require review",
    ),
    "quiet_but_untested": (
        CheckoutEvidence(
            release="checkout-rollback-candidate",
            capture_verified=True,
            failures=(),
            probe_passed=None,
        ),
        "hold: checkout probe has not passed",
    ),
    "capture_unverified": (
        CheckoutEvidence(
            release="checkout-rollback-candidate",
            capture_verified=False,
            failures=(),
            probe_passed=True,
        ),
        "hold: error capture not verified",
    ),
    "verified_candidate": (
        CheckoutEvidence(
            release="checkout-rollback-candidate",
            capture_verified=True,
            failures=(),
            probe_passed=True,
        ),
        "ready for operator review",
    ),
}


if __name__ == "__main__":
    read_inbox()
    print("Inbox response received; review events in your authorized workflow.")
    for name, (evidence, expected) in cases.items():
        actual = assess(evidence)
        assert actual == expected, (name, actual, expected)
        print(f"{name}: {actual}")
Enter fullscreen mode Exit fullscreen mode

Notice the deliberately modest success result: ready for operator review. The function never executes a rollback, retries a payment, or promises that an order is financially reconciled. It checks only the evidence represented in the fixture. A probe that exercises order confirmation cannot establish correctness for a payment path it never traversed.

This is a useful notebook-to-prod boundary. The same small, deterministic evaluator can run in a notebook while the policy is being discussed, then move into a worker with reviewed inputs. Keep it eval-driven: retain the quiet-but-untested case so a future refactor cannot accidentally turn an empty failure list into approval. Add cases for the stages your marketplace actually needs to verify, rather than copying the fixture's stage as a universal checkout model.

There is no need for a model call here. Being prompt-cost aware starts with recognizing that a fixed evidence rule needs no tokens. An AI-generated incident summary can assist review, but the release attribution and probe result should remain inspectable inputs rather than conclusions hidden inside a summary.

Source maps change the acceptable rollback evidence

Infrai combines a plain REST API with one key, one wallet, and one bill across 295 routes and 20 modules: a checkout worker can use a single API key for errors and logs without installing a vendor SDK or managing separate credentials and invoices. Its public, self-describing discovery surface supplies request and response schemas without an API key, which helps the notebook-to-prod handoff avoid guessed payloads. Its capture, listing, search, grouping, and resolving workflow supports reviewing ordinary application exceptions before a rollback decision. The trade-off is debugging depth: this basic inbox is not suitable for investigations requiring source map deobfuscation, crash symbolication, or session replay; choose a specialist for those requirements.

The platform spans 295 routes across 20 modules under a single API key and one bill. For the checkout worker, the useful part of that breadth is shared authentication for error capture and logs, rather than two separate credential lifecycles. Don't treat that convenience as proof of specialist debugging depth.

Inspect the artifacts first.

The alternatives deserve their own acceptance tests. Sentry is the direct specialist comparison for source map deobfuscation, crash symbolication, and session replay requirements. Bugsnag is another crash reporting candidate to put through the same checkout fixture; verify the precise runtime and artifact support you need before selecting it. Healthchecks addresses the separate silent-failure question: did the expected task run? A missing scheduled probe belongs in that evaluation even if the checkout error inbox looks healthy.

Datadog also belongs on the shortlist when the team is evaluating a broader observability workflow. Test whether its selected offering supplies the checkout investigation you need, and weigh that broader scope against the integration work justified by a small exception inbox. This is an acceptance criterion, not a claim that every deployment or plan supplies the same debugging features.

Option Checkout decision to test Selection boundary
Basic errors API Can an operator capture, find, group, and resolve the relevant application exceptions? Suitable when the exception itself provides sufficient debugging context.
Sentry Does the specialist debugging workflow provide the evidence needed to investigate the checkout failure? Prefer this category when source maps, crash symbolication, or replay are requirements.
Bugsnag Can the crash reporting workflow explain the failures from the actual client and release artifacts? Treat artifact handling and runtime coverage as acceptance criteria to verify.
Datadog Does the selected observability offering support the cross-service checkout investigation? Evaluate the integration scope against the needs of a small exception inbox.
Healthchecks Can the team detect that an expected checkout verification task failed to run? Complements exception capture for silent failures; it answers a different operational question.

These are not interchangeable inboxes. An exception capture workflow and a heartbeat monitor observe different things, and buying either does not establish rollback safety on its own. The comparison becomes much clearer when every candidate faces the same evidence requirement instead of a long list of loosely related features.

Keep the boundary explicit.

For a frontend-heavy checkout, source maps may decide the purchase. If the only useful stack is minified, readable backend errors will not compensate for that missing evidence. Evaluate source map handling with the release artifacts you intend to ship. For a backend-focused service with actionable exceptions, the simpler inbox can be enough.

US or EU processing requirements and optional self-hosting need a separate deployment check. Obtain service-specific evidence for the selected offering, including where events are processed and what the deployment supports. A familiar API shape does not establish residency or self-hosting availability. No regional or self-hosting recommendation follows from the capture workflow alone.

Operational checklist for the rollback reviewer

Before relying on the inbox, send a controlled, sanitized exception and confirm that the operator can find the relevant event. Check release attribution and the distinction between grouping and an individual checkout attempt. A group can help consolidate investigation; the checkout reference helps explain which attempt the operator is examining. Neither should be mistaken for proof that repeating a payment is safe.

Then decide who notices new failures. If the selected basic service provides no built-in alert routing, use a separate alerting tool or a worker that polls its documented list or search interface. Give that worker an owner. Test its failure path as deliberately as its normal path, and keep a heartbeat check for the case where it stops running entirely.

Logs can carry correlation identifiers, but an identifier alone does not supply a distributed trace query or a span tree. If the rollback review needs to reconstruct a path across several services, evaluate that evidence requirement explicitly. A broader observability interface is useful only if it supports the investigation the team must perform.

Finally, rehearse the human decision with the same fixture that exercised the code. Confirm that a failed probe holds the review, that an absent probe also holds it, and that a successful candidate still requires the designated operator's judgment. If feature toggles participate in the rollback, include their state in that review rather than assuming a code rollback restores every relevant behavior. Keep the resulting policy small enough that an on-call engineer can explain why it allowed the next step.

References

The sources below provide context for logs, feature toggles, and the specialist tools to evaluate. Product selection still needs a checkout-specific acceptance test; documentation is not a measured recovery result.

Further reading

Top comments (0)