# getsentry/sentry-react-native architecture

> Architecture diagram of the GitHub repository getsentry/sentry-react-native, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/getsentry/sentry-react-native
- Repository: https://github.com/getsentry/sentry-react-native

## Overview

##### Main Components

a. JavaScript Layer
- Core SDK Module
- Integration Modules
- React Native Bridge
- Performance Monitoring
- Error Tracking
- Replay System

b. Native Layers
- iOS (Objective-C/Swift) Implementation
- Android (Java/Kotlin) Implementation
- Platform-specific Error Handlers
- Native Crash Reporting

c. External Components
- Sentry Backend Service
- Source Map Processing
- Symbolication Services

**┌─────────────────────────────────────────────────────────┐**
- React Native App                        │
- ┤
- Sentry SDK Core                         │
- ┬─────────────────┬──────────────────┤
- JS Layer        │  Bridge Layer   │   Native Layer   │

- Error Tracking  │ - Native Modules│ - iOS SDK        │
- Performance     │ - Event Bridge  │ - Android SDK    │
- Breadcrumbs     │ - Method Calls  │ - Crash Reporter │
- Session Tracking│                 │ - Native Traces  │
- ┬───────┴────────┬────────┴────────┬─────────┘

- ▼                ▼                 ▼
**┌─────────────────────────────────────────────────────────┐**
- Sentry Backend                         │
- ┘

##### Key Interactions to Highlight

a. Data Flow
- Error capture path from JS to Native
- Performance monitoring data collection
- Event buffering and transmission
- Source map processing flow

b. Integration Points
- React Native bridge communication
- Native crash handling
- Performance monitoring hooks
- Network request monitoring

##### Implementation Details

Technical details such as:
- Native module registration
- Event buffering system
- Offline storage implementation
- Automatic instrumentation points
- SDK initialization flow

##### Additional Elements

- Version compatibility notes
- Integration points with Expo
- Hermes support indicators
- RAM bundle handling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph RNApp["React Native Application"]
        App["React Native App"]
    end

    subgraph SDKCore["Sentry SDK Core"]
        CoreSDK["Core SDK Module"]:::core
        click CoreSDK "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/index.ts"

        subgraph JSLayer["JavaScript Layer"]
            ErrorTracking["Error Tracking"]:::js
            click ErrorTracking "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/client.ts"
            
            PerfMon["Performance Monitoring"]:::js
            click PerfMon "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/src/js/tracing/"
            
            Breadcrumbs["Breadcrumbs"]:::js
            
            SessionTrack["Session Tracking"]:::js
            click SessionTrack "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/scope.ts"
            
            Replay["Replay System"]:::js
            click Replay "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/src/js/replay/"
            
            Profiling["Performance Profiling"]:::js
            click Profiling "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/src/js/profiling/"
            
            Integrations["Integration Modules"]:::js
            click Integrations "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/src/js/integrations/"
        end

        subgraph BridgeLayer["Bridge Layer"]
            NativeMod["Native Modules"]:::bridge
            click NativeMod "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/NativeRNSentry.ts"
            
            EventBridge["Event Bridge"]:::bridge
            click EventBridge "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/wrapper.ts"
            
            MethodCalls["Method Calls"]:::bridge
        end

        subgraph NativeLayer["Native Layer"]
            iOSSDK["iOS SDK"]:::native
            click iOSSDK "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/ios/"
            
            AndroidSDK["Android SDK"]:::native
            click AndroidSDK "https://github.com/getsentry/sentry-react-native/tree/main/packages/core/android/"
            
            CrashReporter["Native Crash Reporter"]:::native
            click CrashReporter "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/integrations/nativelinkederrors.ts"
            
            NativeTraces["Native Traces"]:::native
            
            ErrorHandlers["Native Error Handlers"]:::native
            click ErrorHandlers "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/src/js/integrations/reactnativeerrorhandlers.ts"
        end
    end

    subgraph Backend["Sentry Backend Services"]
        SentryBE["Sentry Backend"]:::backend
        SourceMaps["Source Map Processing"]:::backend
        click SourceMaps "https://github.com/getsentry/sentry-react-native/blob/main/packages/core/scripts/copy-debugid.js"
        Symbolication["Symbolication Services"]:::backend
    end

    %% Connections
    App --> CoreSDK
    CoreSDK --> JSLayer
    CoreSDK --> BridgeLayer
    CoreSDK --> NativeLayer
    
    NativeMod <--> iOSSDK
    NativeMod <--> AndroidSDK
    EventBridge --> SentryBE
    CrashReporter --> SentryBE
    ErrorTracking --> EventBridge
    PerfMon --> EventBridge
    
    SentryBE --> SourceMaps
    SentryBE --> Symbolication

    %% Styles
    classDef core fill:#2ecc71,stroke:#27ae60,stroke-width:2px
    classDef js fill:#3498db,stroke:#2980b9,stroke-width:2px
    classDef bridge fill:#e67e22,stroke:#d35400,stroke-width:2px
    classDef native fill:#e74c3c,stroke:#c0392b,stroke-width:2px
    classDef backend fill:#9b59b6,stroke:#8e44ad,stroke-width:2px

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        JSComp["JavaScript Component"]:::js
        BridgeComp["Bridge Component"]:::bridge
        NativeComp["Native Component"]:::native
        BackendComp["Backend Service"]:::backend
    end
```
