Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/sentry-sdk-patterns

@0d57af8
Run it yourself

Best practices for using Sentry SDK in TypeScript and Python. Use when implementing structured error context with scopes, breadcrumb strategies, beforeSend/beforeBreadcrumb filtering, custom fingerprinting, user context, or performance span creation. Trigger: "sentry best practices", "sentry patterns", "sentry sdk usage", "sentry scope", "sentry breadcrumbs", "sentry beforeSend", "sentry fingerprint".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/sentry-sdk-patterns

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈649 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Examples

Example: Implement Centralized Error Handler Request: "Create a reusable error handling module for our Node.js API" Result: Created lib/error-handler.ts with captureError() function wrapping Sentry.withScope(), typed severity levels mapped to Sentry levels, and tag/context/user/fingerprint support.

Example: Add Breadcrumb Trail for Checkout Flow Request: "Add debugging context for our checkout pipeline" Result: Added structured breadcrumb helpers (breadcrumb.auth(), breadcrumb.db(), breadcrumb.http(), breadcrumb.business()) providing a clear timeline leading up to any error in the checkout flow.

Example: Filter Noise with beforeSend Request: "We're getting flooded with ResizeObserver and network errors" Result: Configured beforeSend to drop ResizeObserver loop and Network request failed errors, plus scrub PII from user context and cookies.

Example: Fix Incorrect Issue Grouping Request: "Payment timeouts from different gateways are being grouped separately" Result: Added scope.setFingerprint(['payment-gateway-timeout', gatewayName]) to group all payment timeouts by gateway rather than by stack trace.

Python Context Manager Pattern

import sentry_sdk
from contextlib import contextmanager

@contextmanager
def sentry_scope(tags=None, context=None, user=None):
    """Reusable scoped context for Sentry events."""
    with sentry_sdk.new_scope() as scope:
        if tags:
            for key, value in tags.items():
                scope.set_tag(key, value)
        if context:
            for ctx_name, ctx_data in context.items():
                scope.set_context(ctx_name, ctx_data)
        if user:
            scope.set_user(user)
        yield scope

# Usage
with sentry_scope(
    tags={"operation": "sync", "source": "salesforce"},
    context={"sync": {"record_count": 500, "batch_id": batch_id}},
):
    perform_sync_operation()

TypeScript Async Error Wrapper

import * as Sentry from '@sentry/node';

export function withSentry<T>(
  fn: () => Promise<T>,
  context?: Record<string, unknown>,
): Promise<T> {
  return fn().catch((error) => {
    Sentry.withScope((scope) => {
      if (context) scope.setContext('operation', context);
      Sentry.captureException(error);
    });
    throw error;
  });
}

// Usage
const user = await withSentry(
  () => fetchUserData(userId),
  { userId, operation: 'fetchUser' },
);

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides standard developer guidance for using Sentry SDKs in TypeScript and Python, including error handling, performance spans, and PII scrubbing. No security risks were identified.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files Edits files
version
1.51.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatibility
Designed for Claude Code
All 4 allowed tools
ReadWriteEditGrep
Other metadata
tags
[
  "saas",
  "sentry",
  "python",
  "typescript",
  "best-practices",
  "error-handling"
]

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/sentry-sdk-patterns