Skip to content

Commit 1e1e4f8

Browse files
mormubisclaude
andcommitted
🎨 Fix formatting in .planning markdown files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a5eff71 commit 1e1e4f8

7 files changed

Lines changed: 254 additions & 20 deletions

File tree

‎.planning/codebase/ARCHITECTURE.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
**Overall:** Layered Event-Driven Architecture with Domain-Driven Design
88

99
**Key Characteristics:**
10+
1011
- Observable-based event system using pub/sub pattern (LifeCycle)
1112
- Clear dependency layering: core → rum-core → rum/logs/rum-react
1213
- Assembly pattern for event enrichment and transformation
@@ -16,34 +17,39 @@
1617
## Layers
1718

1819
**Core Layer:**
20+
1921
- Purpose: Foundation library providing shared utilities and primitives
2022
- Location: `packages/core/src`
2123
- Contains: Browser APIs, observables, transport, session management, configuration, error handling, telemetry
2224
- Depends on: None (base layer)
2325
- Used by: All other packages (rum-core, logs, rum-react, worker, flagging)
2426

2527
**RUM Core Layer:**
28+
2629
- Purpose: Real User Monitoring business logic without UI-specific features
2730
- Location: `packages/rum-core/src`
2831
- Contains: Event collection (views, actions, errors, resources, long tasks, vitals), RUM assembly, contexts, tracing
2932
- Depends on: @datadog/browser-core
3033
- Used by: rum, rum-slim, rum-react packages
3134

3235
**Product Layer:**
36+
3337
- Purpose: User-facing SDK packages with specific feature sets
3438
- Location: `packages/rum`, `packages/rum-slim`, `packages/logs`, `packages/rum-react`
3539
- Contains: Public APIs, entry points, product-specific features (session replay, profiling, React integration)
3640
- Depends on: core and/or rum-core
3741
- Used by: End-user applications
3842

3943
**Transport Layer:**
44+
4045
- Purpose: Data transmission to Datadog backend
4146
- Location: `packages/core/src/transport`, `packages/rum-core/src/transport`
4247
- Contains: Batching, compression, HTTP requests, event bridge, flush control
4348
- Depends on: Core utilities
4449
- Used by: Collection modules
4550

4651
**Browser Integration Layer:**
52+
4753
- Purpose: Browser API observation and instrumentation
4854
- Location: `packages/core/src/browser`, `packages/rum-core/src/browser`
4955
- Contains: XHR/Fetch observables, performance observables, DOM mutation tracking, location change tracking
@@ -73,6 +79,7 @@
7379
4. Rate limiters and telemetry track event volumes
7480

7581
**State Management:**
82+
7683
- Session state persisted in cookies/localStorage
7784
- View history maintained in memory with expiration
7885
- Context managers use Observable pattern for updates
@@ -81,58 +88,69 @@
8188
## Key Abstractions
8289

8390
**LifeCycle:**
91+
8492
- Purpose: Central event bus for SDK-internal communication
8593
- Examples: `packages/rum-core/src/domain/lifeCycle.ts`
8694
- Pattern: Type-safe pub/sub with enum-based event types (AUTO_ACTION_COMPLETED, RAW_RUM_EVENT_COLLECTED, RUM_EVENT_COLLECTED, etc.)
8795

8896
**Observable:**
97+
8998
- Purpose: Reactive data streams for browser events
9099
- Examples: `packages/core/src/tools/observable.ts`, `packages/core/src/browser/xhrObservable.ts`, `packages/core/src/browser/fetchObservable.ts`
91100
- Pattern: Subscribe/unsubscribe with typed callbacks, buffering support
92101

93102
**Collection Modules:**
103+
94104
- Purpose: Domain-specific event capture and processing
95105
- Examples: `packages/rum-core/src/domain/action/actionCollection.ts`, `packages/rum-core/src/domain/resource/resourceCollection.ts`, `packages/rum-core/src/domain/error/errorCollection.ts`
96106
- Pattern: Subscribe to observables, emit to LifeCycle, manage domain state
97107

98108
**Assembly:**
109+
99110
- Purpose: Event enrichment and transformation pipeline
100111
- Examples: `packages/rum-core/src/domain/assembly.ts`
101112
- Pattern: Combine raw events with contexts, apply hooks, validate modifications, emit assembled events
102113

103114
**Context Managers:**
115+
104116
- Purpose: Stateful context tracking with customer data
105117
- Examples: `packages/core/src/domain/contexts/userContext.ts`, `packages/rum-core/src/domain/contexts/viewHistory.ts`
106118
- Pattern: ContextManager interface with set/get/remove, validation, storage sync
107119

108120
**Batch:**
121+
109122
- Purpose: Event buffering and transmission
110123
- Examples: `packages/core/src/transport/batch.ts`
111124
- Pattern: Add messages to buffer, upsert by key, flush on trigger, encode before send
112125

113126
## Entry Points
114127

115128
**RUM Full (with Session Replay):**
129+
116130
- Location: `packages/rum/src/entries/main.ts`
117131
- Triggers: Application calls `datadogRum.init()`
118132
- Responsibilities: Initialize RUM core, start recorder API, start profiler API, create deflate encoder, expose DD_RUM global
119133

120134
**RUM Slim (without Session Replay):**
135+
121136
- Location: `packages/rum-slim/src/entries/main.ts`
122137
- Triggers: Application calls `datadogRum.init()`
123138
- Responsibilities: Initialize RUM core with stub recorder, lighter bundle size
124139

125140
**RUM Core Bootstrap:**
141+
126142
- Location: `packages/rum-core/src/boot/startRum.ts`
127143
- Triggers: Called by product packages (rum, rum-slim)
128144
- Responsibilities: Start all collection modules, initialize contexts, start transport, wire up LifeCycle subscriptions
129145

130146
**Logs:**
147+
131148
- Location: `packages/logs/src/entries/main.ts`
132149
- Triggers: Application calls `datadogLogs.init()`
133150
- Responsibilities: Initialize log collection, start transport, expose DD_LOGS global
134151

135152
**React Plugin:**
153+
136154
- Location: `packages/rum-react/src/entries/main.ts`
137155
- Triggers: Application passes plugin to `datadogRum.init()`
138156
- Responsibilities: React error boundary, performance tracking, React Router integration
@@ -142,6 +160,7 @@
142160
**Strategy:** Monitored execution with fallback to ensure SDK never breaks host application
143161

144162
**Patterns:**
163+
145164
- `monitor()` and `monitored()` decorators wrap SDK functions to catch and report internal errors
146165
- `catchUserErrors()` wraps user-provided callbacks to isolate user code failures
147166
- `trackRuntimeError()` reports SDK errors to telemetry without throwing
@@ -158,4 +177,4 @@
158177

159178
---
160179

161-
*Architecture analysis: 2026-01-21*
180+
_Architecture analysis: 2026-01-21_

0 commit comments

Comments
 (0)