Stellar Insights uses Sentry for comprehensive frontend error tracking, including:
- Real-time error notifications
- Source map support for readable stack traces
- User context and breadcrumbs for debugging
- Release tracking for version correlation
- Error sampling and filtering
Create .env.local with Sentry configuration:
# Sentry DSN for frontend error tracking
NEXT_PUBLIC_SENTRY_DSN=https://your-key@sentry.io/your-project-id
# Application version for release tracking
NEXT_PUBLIC_APP_VERSION=1.0.0
# Sentry CLI configuration for source map uploads
SENTRY_AUTH_TOKEN=your-auth-token
SENTRY_ORG=your-org
SENTRY_PROJECT=your-projectnpm install --save-dev @sentry/cli
# or
brew install getsentry/tools/sentry-cliSource maps are automatically uploaded during the build process:
npm run build
# Automatically uploads source maps to SentryOr manually:
./frontend/scripts/upload-sourcemaps.shErrors are automatically tagged with user information:
import * as Sentry from "@sentry/nextjs";
// Set user context
Sentry.setUser({
id: userId,
email: userEmail,
username: userName,
});
// Clear user context on logout
Sentry.setUser(null);Breadcrumbs track user actions leading up to an error:
import * as Sentry from "@sentry/nextjs";
// Automatic breadcrumbs for:
// - Console logs
// - DOM interactions
// - Network requests
// - Page navigation
// - XHR requests
// Manual breadcrumb
Sentry.addBreadcrumb({
category: 'user-action',
message: 'User clicked button',
level: 'info',
data: { buttonId: 'submit-btn' },
});Errors are correlated with application releases:
// Release is set from NEXT_PUBLIC_APP_VERSION
// Allows filtering errors by version in Sentry dashboardConfigure error sampling rate:
// In sentry.client.config.js
Sentry.init({
errorSampleRate: 1.0, // 100% for now
// Adjust to 0.1 for 10% sampling in production
});import { logger } from '@/lib/logger';
try {
// Some operation
} catch (error) {
logger.error('Operation failed', error, {
operation: 'fetchData',
endpoint: '/api/data',
});
}import * as Sentry from "@sentry/nextjs";
try {
// Code that might fail
} catch (error) {
Sentry.captureException(error, {
tags: {
section: 'payment',
action: 'process',
},
extra: {
amount: 100,
currency: 'USD',
},
});
}import * as Sentry from "@sentry/nextjs";
Sentry.captureMessage('User action completed', 'info', {
tags: {
action: 'export',
},
});- Go to sentry.io
- Select your organization and project
- View errors in the Issues tab
- By Release: Filter errors by application version
- By User: Find all errors for a specific user
- By Tag: Filter by custom tags (section, action, etc.)
- By Environment: Separate development, staging, production
- Click on an issue to view full stack trace
- Source maps enable readable file names and line numbers
- View breadcrumbs leading up to the error
Certain errors are automatically ignored:
ignoreErrors: [
'chrome-extension://',
'moz-extension://',
'NetworkError',
'Network request failed',
],Customize what gets sent to Sentry:
beforeSend(event, hint) {
// Filter out errors from browser extensions
if (event.exception) {
const error = hint.originalException;
if (error && typeof error === 'string' && error.includes('chrome-extension')) {
return null;
}
}
return event;
}Sentry.captureException(error, {
tags: {
feature: 'payment-processing',
severity: 'critical',
user_action: 'checkout',
},
});Sentry.captureException(error, {
extra: {
userId: user.id,
orderId: order.id,
amount: order.total,
},
});Sentry.addBreadcrumb({
category: 'api-call',
message: 'Fetching user data',
level: 'info',
data: { endpoint: '/api/users/123' },
});Sentry.setUser({
id: userId,
email: userEmail,
username: userName,
});The logger automatically redacts:
- Stellar addresses (G...)
- API keys
- Email addresses
- Passwords and tokens
- Verify
SENTRY_AUTH_TOKENis set - Check release version matches
NEXT_PUBLIC_APP_VERSION - Run:
./frontend/scripts/upload-sourcemaps.sh - Verify in Sentry dashboard: Settings → Releases
- Check
NEXT_PUBLIC_SENTRY_DSNis correct - Verify environment is not development (errors only sent in production)
- Check browser console for Sentry errors
- Verify error sampling rate is > 0
- Adjust
errorSampleRateto sample errors - Add more filters in
ignoreErrors - Use
beforeSendto filter specific errors