AgentSkillsCN

bugsnag

直接从 Bugsnag API 获取 Bugsnag 错误事件数据。当您需要分析在 Bugsnag 中记录的生产环境错误、崩溃或异常时,可选用此技能。

SKILL.md
--- frontmatter
name: bugsnag
description: Fetch Bugsnag error event data directly from the Bugsnag API. Use when you need to analyze production errors, crashes, or exceptions tracked in Bugsnag.

Bugsnag Error Event Fetcher

This skill fetches raw error event data from Bugsnag and provides it directly for analysis. It's designed to work in cloud sandboxes without any dependencies.

When to Use This Skill

Use this skill when you need to:

  • Analyze production errors and crashes from Bugsnag
  • Investigate error patterns across multiple events
  • Debug issues reported by users
  • Review error context (stacktraces, breadcrumbs, device info, metadata)

How to Use

Simply provide a Bugsnag dashboard URL containing an event_id:

bash
python scripts/bugsnag.py "https://app.bugsnag.com/org/project/errors/abc?event_id=123456"

The script will:

  1. Extract the event_id from the URL
  2. Fetch the full event data from Bugsnag API
  3. Output the raw JSON event data

Authentication

The script looks for your Bugsnag auth token in this order:

  1. Environment variable - export BUGSNAG_AUTH_TOKEN=your-token-here
  2. ~/.codex/config.toml - Configure in [mcp_servers.smartbear].env.BUGSNAG_AUTH_TOKEN
  3. Embedded in script - Edit scripts/bugsnag.py and set EMBEDDED_TOKEN = "your-token-here"

Getting a Bugsnag Token

  1. Log in to Bugsnag
  2. Go to Settings → Data Access
  3. Generate a new token with read permissions
  4. Copy the token

Setting Up Authentication

Option 1: Environment variable (recommended)

bash
export BUGSNAG_AUTH_TOKEN=your-token-here
python scripts/bugsnag.py "URL"

Option 2: Config file (persistent)

bash
# Add to ~/.codex/config.toml:
[mcp_servers.smartbear.env]
BUGSNAG_AUTH_TOKEN = "your-token-here"

Option 3: Embed in script (convenient for non-sensitive environments)

python
# Edit scripts/bugsnag.py, line ~38:
EMBEDDED_TOKEN = "your-bugsnag-token-here"

What You Get

The script outputs raw JSON with complete event data:

  • Error class and message
  • Full stacktrace with code frames
  • ALL breadcrumbs (no truncation)
  • Device and app information
  • Complete metadata (Timer, auth, counter, etc.)
  • User information
  • Feature flags and correlation

This is the same data you see in Bugsnag dashboard, but in structured JSON format perfect for analysis.

Examples

Basic Usage

bash
python scripts/bugsnag.py "https://app.bugsnag.com/myorg/myapp/errors/abc?event_id=123"

With Custom Project ID

By default, the script uses project ID 5e7e6984e2a5fe0014dbf1a8. To override:

python
# Edit scripts/bugsnag.py, line ~41:
DEFAULT_PROJECT_ID = "your-project-id-here"

Analyzing Multiple Events

bash
for url in event1_url event2_url event3_url; do
  echo "=== Fetching $url ==="
  python scripts/bugsnag.py "$url"
done

Understanding the Output

Key fields in the JSON output:

  • exceptions[0].error_class - Type of error (e.g., "NullPointerException")
  • exceptions[0].message - Error message
  • exceptions[0].stacktrace - Array of stack frames
  • breadcrumbs - User actions leading to error
  • metaData - Custom metadata (Timer, counter, etc.)
  • device - Device information
  • app - App version and state
  • user - User identification

Alternative: cURL Version

If Python isn't available, use this bash/curl one-liner:

bash
# Set your token
TOKEN="your-token-here"
EVENT_ID="697448c0016289a055ed0000"
PROJECT_ID="5e7e6984e2a5fe0014dbf1a8"

curl -H "Authorization: token $TOKEN" \
     -H "Accept: application/json" \
     "https://api.bugsnag.com/projects/$PROJECT_ID/events/$EVENT_ID"

Troubleshooting

"Could not find event_id in URL"

  • Make sure the URL contains ?event_id=... or &event_id=...
  • Example: https://app.bugsnag.com/.../errors/abc?event_id=123

"Authentication failed" or "401 Unauthorized"

  • Check your token is valid
  • Verify token has read permissions for events
  • Make sure token is set in one of the three locations

"Project not found" or "Event not found"

  • Verify the project ID is correct
  • Check the event_id is valid
  • Ensure your token has access to this project

Security Notes

  • Embedded tokens: Only use in trusted/non-shared environments
  • ~/keys file: Make sure it's not world-readable (chmod 600 ~/keys)
  • Environment variables: Preferred for CI/CD and shared environments
  • Never commit tokens to version control