{
    "slug": "error_tracking",
    "term": "Error Tracking",
    "category": "observability",
    "difficulty": "beginner",
    "short": "Automatically capturing, grouping, and alerting on application errors in production — with full stack traces, breadcrumbs, and user context.",
    "long": "Error tracking tools (Sentry, Bugsnag, Rollbar) catch unhandled exceptions and send them to a central dashboard where errors are grouped by fingerprint (similar stack traces), counted, and alerted on. Key features: stack traces with source maps, user context (who was affected), release tracking (which deploy introduced the error), breadcrumbs (events leading up to the error), and performance monitoring integration. Essential for knowing about errors before users report them.",
    "aliases": [
        "Sentry",
        "Bugsnag",
        "Rollbar",
        "exception tracking"
    ],
    "tags": [
        "observability",
        "debugging",
        "php",
        "devops"
    ],
    "misconception": "Log files are sufficient for error tracking — logs require manual investigation; error tracking tools automatically surface, group, deduplicate, and alert on new errors in real time.",
    "why_it_matters": "Without error tracking, you learn about production exceptions from user complaints — error tracking notifies you within seconds of a new error type appearing.",
    "common_mistakes": [
        "Not filtering out expected exceptions (404s, validation errors) — alert fatigue from noise buries real bugs.",
        "Not attaching user context — 'who was affected' is often the most important debugging context.",
        "Not linking errors to deploys — 'did this error start after the last deployment?' is a critical question.",
        "Not setting alert thresholds — getting paged for every single error occurrence vs only on new error types or rate spikes."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "structured_logging",
        "opentelemetry",
        "observability",
        "incident_response"
    ],
    "prerequisites": [
        "structured_logging",
        "error_handling",
        "alerting"
    ],
    "refs": [
        "https://docs.sentry.io/platforms/php/"
    ],
    "bad_code": "// Error visible only in log file:\ntry {\n    processOrder($order);\n} catch (Exception $e) {\n    error_log('Order processing failed: ' . $e->getMessage());\n    // Buried in /var/log/php/error.log\n    // Discovered when customer calls support 2 days later\n}",
    "good_code": "// Sentry captures with full context:\n\\Sentry\\init(['dsn' => getenv('SENTRY_DSN')]);\n\\Sentry\\configureScope(function (\\Sentry\\State\\Scope $scope): void {\n    $scope->setUser(['id' => $userId, 'email' => $userEmail]);\n});\ntry {\n    processOrder($order);\n} catch (Exception $e) {\n    \\Sentry\\captureException($e); // Full stack trace, user context, automatic alert\n    throw $e; // Still propagate\n}",
    "quick_fix": "Install Sentry (free tier) with composer require sentry/sentry-sdk — one line of configuration gives you error grouping, stack traces, breadcrumbs, and release tracking",
    "severity": "high",
    "effort": "low",
    "created": "2026-03-15",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/error_tracking",
        "html_url": "https://codeclaritylab.com/glossary/error_tracking",
        "json_url": "https://codeclaritylab.com/glossary/error_tracking.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Error Tracking](https://codeclaritylab.com/glossary/error_tracking) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/error_tracking"
            }
        }
    }
}