一键导入
source-map-setup
Configure source maps for readable stack traces. Use when setting up error tracking, debugging production issues, or configuring build tools.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Configure source maps for readable stack traces. Use when setting up error tracking, debugging production issues, or configuring build tools.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Instrument API requests with spans and distributed tracing. Use when tracking request latency or debugging API issues.
Monitor JavaScript bundle size and execution performance. Use when tracking bundle size, identifying large chunks, or optimizing load performance.
Measure and optimize Core Web Vitals (LCP, INP, CLS). Use when implementing CWV tracking or debugging performance.
Set up error tracking with actionable context. Use when configuring error capture or error boundaries.
Measure SSR hydration timing and issues. Use when tracking hydration performance, debugging hydration mismatches, or optimizing SSR/SSG applications.
Plan what to measure in web applications. Use when starting observability or prioritizing instrumentation.
| name | source-map-setup |
| description | Configure source maps for readable stack traces. Use when setting up error tracking, debugging production issues, or configuring build tools. |
| triggers | ["source maps","readable stack traces","minified errors","debug production","symbolication","upload source maps"] |
| priority | 1 |
Make production stack traces readable by uploading source maps to your error tracking service.
Without source maps:
TypeError: Cannot read property 'x' of undefined
at e.render (main.a1b2c3.js:1:45678)
at t.update (main.a1b2c3.js:1:12345)
With source maps:
TypeError: Cannot read property 'x' of undefined
at ProductCard.render (src/components/ProductCard.tsx:45:12)
at CartList.update (src/features/cart/CartList.tsx:78:8)
// vite.config.ts
import { sentryVitePlugin } from '@sentry/vite-plugin';
export default defineConfig({
build: {
sourcemap: true, // Generate source maps
},
plugins: [
sentryVitePlugin({
org: 'your-org',
project: 'your-project',
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
filesToDeleteAfterUpload: ['**/*.map'], // Don't deploy maps
},
}),
],
});
// next.config.js
const { withSentryConfig } = require('@sentry/nextjs');
module.exports = withSentryConfig(
{
// Your Next.js config
},
{
org: 'your-org',
project: 'your-project',
silent: true,
widenClientFileUpload: true,
hideSourceMaps: true, // Don't expose in production
}
);
// esbuild.config.ts
import * as Sentry from '@sentry/esbuild-plugin';
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
sourcemap: true,
plugins: [
Sentry.sentryEsbuildPlugin({
org: 'your-org',
project: 'your-project',
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});
// vite.config.ts (SvelteKit uses Vite)
import { sentrySvelteKit } from '@sentry/sveltekit';
export default defineConfig({
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: 'your-org',
project: 'your-project',
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
sveltekit(),
],
});
# Install CLI
npm install @sentry/cli --save-dev
# Upload manually (CI/CD)
sentry-cli sourcemaps upload \
--org your-org \
--project your-project \
--release "1.0.0" \
./dist
// datadog-ci upload
// In CI/CD:
// npx @datadog/datadog-ci sourcemaps upload ./dist \
// --service your-service \
// --release-version 1.0.0 \
// --minified-path-prefix /static/js
// newrelic.js
exports.config = {
app_name: ['Your App'],
browser_monitoring: {
enable: true,
debug: false,
},
// Source maps uploaded via CLI or agent
};
# .github/workflows/deploy.yml
- name: Upload Source Maps
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
npx sentry-cli releases new ${{ github.sha }}
npx sentry-cli sourcemaps upload \
--release ${{ github.sha }} \
--url-prefix '~/' \
./dist
npx sentry-cli releases finalize ${{ github.sha }}
// next.config.js - automatic with @sentry/nextjs
module.exports = withSentryConfig(nextConfig, {
// Vercel automatically sets VERCEL_GIT_COMMIT_SHA
release: process.env.VERCEL_GIT_COMMIT_SHA,
});
| Approach | Pros | Cons |
|---|---|---|
| Upload & delete | Secure, no exposure | Requires CI/CD setup |
| Hidden source maps | Simple | Still on server |
| Private source maps | Full control | Complex setup |
Best practice: Upload to error tracking service, then delete from build output.
// Vite config
sentryVitePlugin({
sourcemaps: {
filesToDeleteAfterUpload: ['**/*.map'],
},
});
# Verify upload worked
sentry-cli releases files YOUR_RELEASE list
# Test with a real error
throw new Error('Test source maps');
Check in Sentry/Datadog that:
| Issue | Cause | Fix |
|---|---|---|
| Still minified | Maps not uploaded | Check CI/CD logs |
| Wrong lines | Version mismatch | Ensure release matches |
| Missing files | Incorrect path prefix | Set --url-prefix correctly |
| Partial mapping | Tree shaking | Upload all chunks |
skills/error-tracking for error captureskills/bundle-performance for build optimizationreferences/frameworks/*.md - Framework-specific setupreferences/platforms/*.md - Vendor-specific guides