Skip to main content Inicio Creadores jeremylongshore claude-code-plugins-plus-skills sentry-local-dev-loop
sentry-local-dev-loop Configure Sentry for local development with environment-aware settings.
Use when setting up dev vs prod DSN routing, enabling debug mode,
tuning sample rates for local work, or testing source maps locally.
Trigger with phrases like "sentry local dev", "sentry development config",
"debug sentry locally", "sentry dev environment", "sentry spotlight".
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill sentry-local-dev-loopEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Más de este repositorio Implement user sign-up and sign-in flows with Clerk.
Use when building authentication UI, customizing sign-in experience,
or implementing OAuth social login.
Trigger with phrases like "clerk sign-in", "clerk sign-up",
"clerk login flow", "clerk OAuth", "clerk social login".
Implement session management and middleware with Clerk.
Use when managing user sessions, configuring route protection,
or implementing token refresh and custom JWT templates.
Trigger with phrases like "clerk session", "clerk middleware",
"clerk route protection", "clerk token", "clerk JWT".
Configure enterprise SSO, role-based access control, and organization management.
Use when implementing SSO integration, configuring role-based permissions,
or setting up organization-level controls.
Trigger with phrases like "clerk SSO", "clerk RBAC",
"clerk enterprise", "clerk roles", "clerk permissions", "clerk organizations".
Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
Explorador de archivos
4 archivos name sentry-local-dev-loop description Configure Sentry for local development with environment-aware settings.
Use when setting up dev vs prod DSN routing, enabling debug mode,
tuning sample rates for local work, or testing source maps locally.
Trigger with phrases like "sentry local dev", "sentry development config",
"debug sentry locally", "sentry dev environment", "sentry spotlight".
allowed-tools Read, Write, Edit, Bash(npm:*), Bash(node:*), Bash(npx:*), Bash(python:*), Grep, Glob version 1.51.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","sentry","development","debugging","workflow","devtools","environment"] compatibility Designed for Claude Code, also compatible with Codex and OpenClaw
Sentry Local Dev Loop
Overview
Configure Sentry for local development with environment-aware DSN routing, debug-mode verbosity, full-capture sample rates, beforeSend inspection, Sentry Spotlight for offline event viewing, and sentry-cli source map verification. All configuration uses environment variables so nothing leaks into commits.
Prerequisites
@sentry/node v8+ installed (TypeScript/Node) or sentry-sdk v2+ installed (Python)
Separate Sentry project created for development (different DSN from production)
.env file with SENTRY_DSN_DEV and NODE_ENV=development
Network access to *.ingest.sentry.io (or use Spotlight for fully offline work)
Instructions
Step 1 -- Environment-Aware Configuration
Create an initialization file that routes events to the correct Sentry project based on environment, enables debug logging in dev, and captures 100% of traces locally:
import * as Sentry from '@sentry/node' ;
const env = process.env .NODE_ENV || 'development' ;
const isDev = env !== 'production' ;
Sentry .init ({
dsn : isDev
? process.env .SENTRY_DSN_DEV
: process.env .SENTRY_DSN ,
environment : env,
release : isDev ? 'dev-local' : process.env .SENTRY_RELEASE ,
tracesSampleRate : isDev ? : ,
: isDev ? : ,
: isDev,
: isDev,
: isDev,
( ) {
(isDev) {
exc = event. ?. ?.[ ];
label = exc
?
: event. || ;
. ( );
. ( );
}
event;
},
( ) {
(isDev) {
duration = event. && event.
? ((event. - event. ) * ). ( )
: ;
. ( );
}
event;
},
});
1.0
0.1
sampleRate
1.0
1.0
debug
sendDefaultPii
spotlight
beforeSend
event, hint
if
const
exception
values
0
const
`${exc.type } : ${exc.value} `
message
'event'
console
log
`[Sentry Dev] ${label} `
console
log
` Tags: ${JSON .stringify(event.tags || {})} `
return
beforeSendTransaction
event
if
const
timestamp
start_timestamp
timestamp
start_timestamp
1000
toFixed
0
'?'
console
log
`[Sentry Dev] Transaction: ${event.transaction} (${duration} ms)`
return
Set up environment files to keep DSNs out of source:
SENTRY_DSN_DEV=https://examplePublicKey@o0.ingest.sentry.io/0
SENTRY_ENVIRONMENT=development
NODE_ENV=development
SENTRY_DSN=https://prodPublicKey@o0.ingest.sentry.io/0
SENTRY_ENVIRONMENT=production
SENTRY_RELEASE=v1.2.3
NODE_ENV=production
Add DSN safety to .gitignore:
.env
.env.development
.env.production
.env.local
Step 2 -- Local Verification and Performance Debugging Create a verification script that confirms the SDK works end-to-end and demonstrates Sentry.startSpan() for local performance profiling:
import * as Sentry from '@sentry/node' ;
async function verify ( ) {
const client = Sentry .getClient ();
if (!client) {
console .error ('Sentry SDK not initialized — run with --import ./instrument.mjs' );
process.exit (1 );
}
console .log ('--- Sentry Dev Loop Verification ---\n' );
console .log ('1. Sending test message...' );
Sentry .captureMessage ('Dev loop verification — captureMessage' , 'info' );
console .log ('2. Sending test exception...' );
try {
throw new Error ('Dev loop verification — captureException' );
} catch (e) {
const eventId = Sentry .captureException (e);
console .log (` Event ID: ${eventId} ` );
}
console .log ('3. Testing startSpan for performance...' );
await Sentry .startSpan (
{ name : 'dev.verification.database' , op : 'db.query' },
async (span) => {
await new Promise ((resolve ) => setTimeout (resolve, 150 ));
await Sentry .startSpan (
{ name : 'dev.verification.serialize' , op : 'serialize' },
async () => {
await new Promise ((resolve ) => setTimeout (resolve, 50 ));
}
);
}
);
console .log ('4. Testing breadcrumbs...' );
Sentry .addBreadcrumb ({
category : 'dev' ,
message : 'Verification script started' ,
level : 'info' ,
});
Sentry .addBreadcrumb ({
category : 'dev' ,
message : 'All checks passed' ,
level : 'info' ,
});
Sentry .captureMessage ('Dev verification complete with breadcrumbs' , 'info' );
console .log ('5. Flushing events...' );
const flushed = await Sentry .flush (5000 );
console .log (flushed
? '\nAll events sent — check Sentry dashboard or Spotlight UI'
: '\nFlush timed out — check DSN and network'
);
}
verify ();
Use Sentry.startSpan() in your application code to profile specific operations during development:
app.get ('/api/search' , async (req, res) => {
const results = await Sentry .startSpan (
{ name : 'search.execute' , op : 'db.query' , attributes : { 'search.query' : req.query .q } },
async () => {
return await db.search (req.query .q );
}
);
const formatted = await Sentry .startSpan (
{ name : 'search.format' , op : 'serialize' },
async () => {
return results.map (formatResult);
}
);
res.json (formatted);
});
Step 3 -- Sentry Spotlight and Offline Development Sentry Spotlight runs a local sidecar that intercepts Sentry events and displays them in a browser UI at http://localhost:8969 (Spotlight's default port) — no network required:
npx @spotlightjs/spotlight
The spotlight: true option in Step 1's Sentry.init() routes events to the local sidecar. This gives you a full Sentry-style event viewer without sending anything to sentry.io.
For fully offline development or CI environments with no Sentry access:
Sentry .init ({
dsn : '' ,
debug : false ,
});
Test source maps locally before deploying with sentry-cli:
npm install -g @sentry/cli
sentry-cli info
sentry-cli sourcemaps upload \
--org your-org \
--project your-dev-project \
--release dev-local \
./dist
sentry-cli sourcemaps explain \
--org your-org \
--project your-dev-project \
--release dev-local
Add a git pre-push hook to prevent hardcoded DSNs from leaking into the repo:
#!/bin/bash
set -e
if grep -rn "ingest\.sentry\.io" --include="*.ts" --include="*.js" \
--exclude-dir=node_modules --exclude-dir=dist src/ lib/; then
echo "ERROR: Hardcoded Sentry DSN found in source. Use environment variables."
exit 1
fi
Output
Environment-aware Sentry.init() routing dev events to a separate Sentry project
Debug logging printing captured events and transaction durations to the console
Verification script confirming captureMessage, captureException, and startSpan work
Sentry Spotlight integration for browsing events locally without network
Source map upload and verification workflow with sentry-cli
Pre-push hook preventing hardcoded DSNs from entering version control
Error Handling Error Cause Solution Events going to prod project Wrong DSN loaded for environment Verify SENTRY_DSN_DEV is set; log process.env.NODE_ENV at startup Debug output too verbose debug: true left on in productionGate with debug: isDev as shown in Step 1 Events not appearing in Spotlight Sidecar not running Run npx @spotlightjs/spotlight in a separate terminal Sentry.flush() times outNo network or invalid DSN Check DSN, test with curl https://sentry.io/api/0/ Rate-limited during dev 100% sample rate hitting project quota Use a dedicated dev project with separate quota Source maps not resolving Release mismatch between upload and init Ensure --release in sentry-cli matches release in Sentry.init() getClient() returns undefinedSDK not initialized before check Import instrument.mjs via --import flag before any app code beforeSend dropping eventsReturns undefined instead of event Always return event to keep it, or null to explicitly drop
Examples
TypeScript — Conditional Init Helper
import * as Sentry from '@sentry/node' ;
export function initSentry ( ) {
const env = process.env .NODE_ENV || 'development' ;
const isDev = env !== 'production' ;
if (isDev && !process.env .SENTRY_DSN_DEV ) {
console .log ('[Sentry] Skipped — no SENTRY_DSN_DEV configured' );
return ;
}
Sentry .init ({
dsn : isDev ? process.env .SENTRY_DSN_DEV : process.env .SENTRY_DSN ,
environment : env,
debug : isDev,
tracesSampleRate : isDev ? 1.0 : 0.1 ,
spotlight : isDev,
sendDefaultPii : isDev,
beforeSend (event ) {
if (isDev) {
const exc = event.exception ?.values ?.[0 ];
console .log (`[Sentry] ${exc?.type || 'Event' } : ${exc?.value || event.message} ` );
}
return event;
},
});
console .log (`[Sentry] Initialized for ${env} ` );
}
Python — Environment-Aware Setup
import os
import sentry_sdk
def init_sentry ():
env = os.getenv("SENTRY_ENVIRONMENT" , "development" )
is_dev = env != "production"
dsn = (
os.getenv("SENTRY_DSN_DEV" )
if is_dev
else os.getenv("SENTRY_DSN" )
)
if is_dev and not dsn:
print ("[Sentry] Skipped — no SENTRY_DSN_DEV configured" )
return
sentry_sdk.init(
dsn=dsn,
environment=env,
release="dev-local" if is_dev else os.getenv("SENTRY_RELEASE" ),
traces_sample_rate=1.0 if is_dev else 0.1 ,
sample_rate=1.0 ,
debug=is_dev,
spotlight=True if is_dev else False ,
before_send=_before_send_dev if is_dev else None ,
)
print (f"[Sentry] Initialized for {env} " )
def _before_send_dev (event, hint ):
"""Log events to console during local development."""
exc_info = hint.get("exc_info" )
if exc_info:
exc_type, exc_value, _ = exc_info
print (f"[Sentry Dev] {exc_type.__name__} : {exc_value} " )
elif event.get("message" ):
print (f"[Sentry Dev] Message: {event['message' ]} " )
return event
import os
import sentry_sdk
sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN_DEV" ),
debug=True ,
environment="verification" ,
spotlight=True ,
)
sentry_sdk.capture_message("Dev verification — Python" , "info" )
try :
raise ValueError("Dev verification error — Python" )
except Exception as e:
event_id = sentry_sdk.capture_exception(e)
print (f"Event ID: {event_id} " )
with sentry_sdk.start_span(op="test" , description="verification span" ):
import time
time.sleep(0.1 )
sentry_sdk.flush()
print ("Verification complete — check Sentry dashboard or Spotlight" )
Resources
Next Steps
sentry-multi-env-setup -- Extend to staging, canary, and multi-region environment routing
sentry-performance-tracing -- Production-grade tracing with custom spans and distributed traces
sentry-debug-bundle -- Advanced debugging with session replay and profiling
sentry-ci-integration -- Automate source map uploads and release creation in CI/CD