Sentry for AI

repository·main·Indexed 42 days ago

https://github.com/getsentry/sentry-for-ai

A skill source repository that provides AI coding assistants with the context and tools to set up Sentry, debug production issues, and configure monitoring via natural language. It supports assistants including Claude Code, Codex, Cursor, and Grok, and provides a skill library and the Sentry MCP server to enable tasks like project instrumentation, issue triage, and code review.

Tokens
407.3K
Snippets
970
Records
1.3K
Agent score
53%

What's inside Sentry for AI

  1. What is included in the Sentry Codex plugin

    main

    The Sentry plugin for Codex provides a comprehensive suite of AI-driven Sentry workflows, including:

    • Full Sentry skill library: Includes SDK setup wizards for various platforms, debugging production issues, code review with Sentry context, and monitoring configuration.
    • Sentry MCP server: Access to the hosted Sentry MCP server for querying your Sentry environment.

    Note on Skill Discovery: To prevent context crowding, most skills are hidden behind entry-point skills. They are configured via Codex's agents/openai.yaml (with policy.allow_implicit_invocation: false) and surface on demand when needed by the model.

  2. What is included in the Sentry plugin for Claude Code

    main

    The Sentry plugin provides a comprehensive set of capabilities to Claude Code:

    • Full Sentry skill library: Includes SDK setup wizards for various platforms, debugging workflows for production issues, code-review workflows with Sentry context, and monitoring configuration.
    • Sentry MCP server: Access to the hosted Sentry MCP server to allow Claude to query your Sentry environment.

    Note on Model Context: To prevent crowding the model's context, most skills are hidden behind router skills using disable-model-invocation and are loaded on demand. Only a few router skills are always available.

  3. What is included in the Sentry Grok plugin

    main

    The Sentry plugin for Grok provides several key capabilities:

    • Full Sentry skill library: Includes SDK setup wizards for any platform, debugging and code-review workflows, and feature setup.
    • Sentry MCP server: Access to the hosted Sentry MCP server for querying your Sentry environment.

    Note on Skill Loading: To prevent crowding the model's context, most skills are hidden behind router skills using disable-model-invocation and are loaded on demand. Only a few router skills are always available.

  4. What is included in the Sentry for Cursor plugin

    main

    The Sentry plugin for Cursor provides several capabilities to integrate Sentry workflows directly into your AI-assisted coding environment:

    • Sentry Skill Library: Includes SDK setup wizards for various platforms, debugging workflows for production issues, code review with Sentry context, and monitoring configuration.
    • Sentry MCP Server: Provides access to the hosted Sentry MCP server, allowing Cursor to query your Sentry environment directly.
  5. When to use the Sentry Next.js SDK

    main

    The Sentry Next.js SDK is an opinionated setup wizard designed to provide complete Sentry coverage across three runtimes: browser, Node.js server, and Edge.

    Use this SDK when you need to:

    • Add Sentry to a Next.js application (supports Next.js 13+).
    • Configure error monitoring for server actions, server components, or edge runtime errors.
    • Implement tracing (server-side request tracing and client-side navigation).
    • Enable Session Replay for user-facing applications.
    • Set up logging, profiling, AI monitoring (OpenAI, Anthropic, Vercel AI SDK), or Crons.
  6. Sentry Android SDK Setup Overview

    main

    The Sentry Android SDK provides comprehensive observability for Android applications, supporting both Kotlin and Java codebases. It is designed to handle error monitoring, performance tracing, profiling, session replay, and logging.

    Core Capabilities:

    • Error Monitoring: Automatically captures uncaught exceptions, Application Not Responding (ANR) events, and native (NDK) crashes.
    • Tracing: Auto-instruments the Activity lifecycle, app startup performance, HTTP requests, and database queries.
    • Session Replay: Records screen captures and user interactions to provide visual context for debugging (requires API 26+).

    Enhanced Observability Options:

    • Profiling: Continuous UI profiling or transaction-based sampling for performance analysis.
    • Logging: Structured logs via Sentry.logger(), with support for a Timber bridge.
    • User Feedback: Collection of user-submitted bug reports from within the application.
  7. Monitor scheduled jobs with Sentry Crons

    main

    Sentry Crons (job monitoring) tracks whether scheduled tasks run on time, succeed, and complete within expected durations. Sentry alerts you if a job:

    • Misses its scheduled start time (checkin margin exceeded)
    • Takes too long to complete (maxRuntime exceeded)
    • Fails (status "error")

    Minimum SDK Requirements:

    • @sentry/node ≥7.51.1 for captureCheckIn and withMonitor.
    • instrumentNodeCron / instrumentCron ≥7.92.0.
    • instrumentNodeSchedule ≥7.93.0.
    • failureIssueThreshold / recoveryThreshold ≥8.7.0.
    • isolateTrace in MonitorConfig ≥10.28.0.
  8. Setup Sentry Cocoa SDK for Apple Platforms

    main

    The Sentry Cocoa SDK provides error monitoring, tracing, profiling, session replay, logging, and metrics for Apple platforms (iOS, macOS, tvOS, watchOS, and visionOS). It supports both SwiftUI and UIKit frameworks.

    • Error Monitoring: Captures crashes, app hangs, watchdog terminations, and NSError/Swift errors.
    • Tracing: Provides auto-instrumentation for app launch, network requests, UIViewController transitions, file I/O, and Core Data.

    Enhanced Observability Features

    • Profiling: Recommended for production iOS/macOS apps to monitor UI performance via configureProfiling.
    • Session Replay: Available for user-facing iOS apps (verify masking requirements for specific builds).
    • Logging: Enables structured log capture, especially if the project already uses os.log or CocoaLumberjack.
    • Metrics: Available for Swift apps (SDK 9.12+) to track aggregate counters, gauges, or distributions.
    • User Feedback: Allows apps to collect in-app bug reports with screenshots.

    Unsupported Features

    • Crons: Backend only.
    • AI Monitoring: JS/Python only.
  9. Multi-hop migration strategy

    main

    When upgrading across multiple major versions (e.g., v7 to v9), do not jump directly to the target version. Instead, follow this pattern:

    1. Upgrade one major version at a time: Apply v7→v8 changes, verify, then proceed to v8→v9.
    2. Update package versions once: You can bump to the final target version in package.json, but apply the necessary code changes incrementally.
    3. Use version-specific grep patterns: Find code needing changes at each specific step.
    4. Test after each logical migration step: Do not wait until all code changes are complete to run tests.
  10. How auto-instrumentation layers work in Sentry Android

    main

    Sentry Android uses a three-tier approach to instrumentation:

    1. Tier 1: Build-time bytecode (Gradle Plugin): Uses the io.sentry:sentry-android-gradle-plugin to inject instrumentation into Room/SQLite, File I/O, OkHttp, and Jetpack Compose without requiring source code changes.
    2. Tier 2: Runtime (SDK integrations): Opt-in integrations that monitor Activity/Fragment lifecycles, OkHttp requests, SQLite queries, Navigation, and User Interactions.
    3. Tier 3: Manual: Using the public Sentry.startTransaction() and ISpan.startChild() APIs to instrument your own custom logic.

    To ensure Tier 2 auto-instrumented spans (like OkHttp or SQLite) correctly attach to your manual Tier 3 transactions, you must set options.isBindToScope = true during initialization.

  11. Understand Sentry Laravel Middleware

    main

    The Laravel SDK automatically registers several middleware to handle request lifecycle and tracing:

    • SetRequestMiddleware: Converts and caches a PSR-7 request early to prevent upload parsing failures.
    • SetRequestIpMiddleware: Sets the request IP on the Sentry scope.
    • FlushEventsMiddleware: Flushes pending events in the terminate() phase after the response is sent.
    • Tracing\Middleware: Automatically prepended to the middleware stack to record full boot time.

    Performance Note: On FastCGI, the terminate() phase runs after the response is sent, so Sentry uploads do not add user-visible latency. On non-FastCGI environments (like RoadRunner or the built-in PHP server), the response may be delayed by the Sentry upload. In these cases, it is recommended to use a local Relay proxy.