Core Principles
The SDK architecture is built on several key principles:1. Modular Design
Each package has a specific purpose:- Core packages provide foundational functionality
- Platform SDKs adapt the core to specific environments
- Framework integrations provide framework-specific features
- Integration packages add optional functionality
2. Layered Architecture
The SDK is organized in layers, from low-level to high-level:3. Shared Types and Interfaces
All packages share common types and interfaces defined in@sentry/core, ensuring consistency across the SDK.
The
@sentry/types package is deprecated. All types should be imported from @sentry/core instead.4. Build-Time Optimization
The SDK uses build-time flags like__DEBUG_BUILD__ to enable tree-shaking of debug code:
Package Categories
Core Packages
These packages provide the foundation for all other packages:@sentry/core- Base SDK implementation, interfaces, types, and core functionality@sentry/browser-utils- Browser-specific utilities and instrumentation@sentry/node-core- Node.js core logic (excludes OpenTelemetry instrumentation)
Platform SDKs
Platform SDKs provide environment-specific implementations:@sentry/browser- Browser SDK + CDN bundles@sentry/node- Node.js SDK with OpenTelemetry instrumentation@sentry/bun- Bun runtime SDK@sentry/deno- Deno runtime SDK@sentry/cloudflare- Cloudflare Workers SDK@sentry/vercel-edge- Vercel Edge runtime SDK
Framework Integrations
These packages integrate Sentry with popular frameworks:@sentry/react- React error boundaries and hooks@sentry/vue- Vue error handler integration@sentry/angular- Angular error handler@sentry/svelte- Svelte error handler@sentry/nextjs- Next.js with client/server integration@sentry/nuxt- Nuxt with client/server integration@sentry/sveltekit- SvelteKit with client/server integration@sentry/remix- Remix framework integration@sentry/astro- Astro framework integration@sentry/gatsby- Gatsby framework integration@sentry/nestjs- NestJS framework integration
Serverless SDKs
@sentry/aws-serverless- AWS Lambda functions@sentry/google-cloud-serverless- Google Cloud Functions
User Experience Packages
@sentry/replay-internal- Session Replay implementation@sentry/replay-canvas- Canvas recording for Replay@sentry/replay-worker- Web Worker for Replay compression@sentry/feedback- User feedback widget
Development Packages
Located indev-packages/, these support SDK development:
browser-integration-tests- Playwright browser testse2e-tests- E2E tests for 70+ framework combinationsnode-integration-tests- Node.js integration testscloudflare-integration-tests- Cloudflare Workers teststest-utils- Shared test utilitiesrollup-utils- Build utilities
Key Concepts
Hubs and Scopes
The SDK uses a Hub & Scope architecture to manage state:- Hub - Container for the current client and scope stack
- Scope - Contains context data (user, tags, breadcrumbs, etc.)
- Client - Processes and sends events to Sentry
Integrations
Integrations extend SDK functionality:Transports
Transports handle sending events to Sentry:- Browser:
fetchorXHR - Node.js:
httporhttps - Edge: Platform-specific APIs
Instrumentation
The SDK automatically instruments:- Errors and uncaught exceptions
- HTTP requests
- Database queries
- User interactions
- Performance metrics
Data Flow
Here’s how an error flows through the SDK:Build System
The monorepo uses:- Yarn Workspaces - Dependency management across packages
- Nx - Task orchestration, caching, and affected analysis
- Rollup - Bundling and transpilation
- TypeScript - Type checking and
.d.tsgeneration
Dependency Graph
Packages depend on each other in a directed acyclic graph (DAG):- Build packages in the correct order
- Run tests for affected packages
- Cache build outputs
AI Integrations
AI provider integrations are organized by runtime:- Core instrumentation:
packages/core/src/tracing/{provider}/ - Node.js integration:
packages/node/src/integrations/tracing/{provider}/ - Edge runtime:
packages/cloudflare/src/integrations/tracing/{provider}.ts
Version Support
The SDK maintains backwards compatibility where possible and provides bug fixes and feature updates based on community demand and usage.Next Steps
- Learn about the monorepo structure
- Explore individual packages
- Understand the development workflow