Skip to content

Commit c471b37

Browse files
committed
chore: remove planning
1 parent 806364b commit c471b37

File tree

7 files changed

+200
-9
lines changed

7 files changed

+200
-9
lines changed

.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_

.planning/codebase/CONCERNS.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
## Tech Debt
66

77
**Generated Type Files:**
8+
89
- Issue: Large generated type files (2000+ lines) from JSON schemas are checked into version control
910
- Files: `packages/rum-core/src/rumEvent.types.ts` (2148 lines), `packages/core/src/domain/telemetry/telemetryEvent.types.ts` (926 lines), `packages/rum/src/types/sessionReplay.ts` (991 lines)
1011
- Impact: These files have `/* eslint-disable */` at the top, bypassing all linting rules. Changes to schemas regenerate massive diffs making code review difficult
1112
- Fix approach: Consider generating these at build time rather than checking into source control, or split schemas into smaller logical units
1213

1314
**Old Cookie Migration Code:**
15+
1416
- Issue: Migration code for old cookie format is permanently kept in codebase
1517
- Files: `packages/core/src/domain/session/oldCookiesMigration.ts`
1618
- Impact: Code comment states "This migration should remain in the codebase as long as older versions are available/live", creating indefinite technical debt. Maintains legacy cookie names `_dd`, `_dd_r`, `_dd_l`
1719
- Fix approach: Establish deprecation timeline and removal date for old cookie support after sufficient adoption of new format
1820

1921
**Deprecated API Surface:**
22+
2023
- Issue: Multiple deprecated APIs still exported and maintained
2124
- Files:
2225
- `packages/rum-slim/src/entries/main.ts` - `RumGlobal` type deprecated in favor of `DatadogRum`
@@ -27,12 +30,14 @@
2730
- Fix approach: Add deprecation warnings with timeline, document migration path, remove in next major version
2831

2932
**TypeScript Type Safety Bypasses:**
33+
3034
- Issue: 225 instances of `@ts-ignore`, `@ts-expect-error`, and eslint disables across 84 files
3135
- Files: Widespread across packages, particularly in test files but also in production code
3236
- Impact: Weakens type safety guarantees. Some legitimate (browser API compatibility), but indicates areas where types don't accurately model reality
3337
- Fix approach: Audit each bypass to determine if it's masking a real type error. Consider using more specific type guards or updating type definitions
3438

3539
**Performance API Polyfills:**
40+
3641
- Issue: Multiple browser capability polyfills maintained for older browser support
3742
- Files:
3843
- `packages/rum-core/src/domain/view/viewMetrics/interactionCountPolyfill.ts` - Chrome-specific convention for interaction counting
@@ -42,6 +47,7 @@
4247
- Fix approach: Define minimum supported browser versions and remove polyfills for features universally supported
4348

4449
**Type Coercion Through 'as any':**
50+
4551
- Issue: Extensive use of type assertions to bypass TypeScript checking
4652
- Files: Spread throughout codebase, many instances of `as unknown as Type` patterns
4753
- Impact: Runtime type mismatches not caught at compile time
@@ -50,24 +56,28 @@
5056
## Known Bugs
5157

5258
**Firefox Worker Error Handling:**
59+
5360
- Symptoms: Deflate worker errors handled differently across browsers
5461
- Files: `packages/rum/src/domain/deflate/deflateWorker.ts` (line 88)
5562
- Trigger: Worker initialization failure - Chromium throws exception, Firefox fires error event
5663
- Workaround: Code handles both patterns. Comment references https://bugzilla.mozilla.org/show_bug.cgi?id=1736865#c2
5764

5865
**Safari CSP Worker Failure:**
66+
5967
- Symptoms: Worker fails under CSP restrictions but doesn't trigger expected logging
6068
- Files: `test/e2e/scenario/transport.scenario.ts` (line 38-41)
6169
- Trigger: Content Security Policy blocks worker in Safari/WebKit
6270
- Workaround: Test marked with `test.fixme` for webkit. Non-deflate requests still sent as fallback
6371

6472
**Edge Viewport Resize Inaccuracy:**
73+
6574
- Symptoms: ViewportResize record data is off by almost 20px in Edge
6675
- Files: `test/e2e/scenario/recorder/viewports.scenario.ts` (line 33)
6776
- Trigger: Viewport resize operations in Microsoft Edge
6877
- Workaround: Test skipped for Edge browser with `test.fixme`
6978

7079
**Session Replay Race Condition:**
80+
7181
- Symptoms: Last segment may not be sent before page unload when using Web Worker
7282
- Files: `test/e2e/lib/framework/flushEvents.ts` (lines 10-23)
7383
- Trigger: Fast page navigation where Worker async communication completes after beforeunload event
@@ -77,18 +87,21 @@
7787
## Security Considerations
7888

7989
**Data Sanitization:**
90+
8091
- Risk: User-provided data needs careful sanitization before sending to intake
8192
- Files: `packages/core/src/tools/serialisation/sanitize.ts`
8293
- Current mitigation: Comprehensive sanitize function that handles cyclic references, limits size to 220KB, transforms unserializable types. Referenced in `packages/rum-core/src/boot/rumPublicApi.ts`
8394
- Recommendations: Regular security audit of sanitization logic, especially for prototype pollution and XSS vectors
8495

8596
**Internal APIs Exposed:**
97+
8698
- Risk: Internal modules exported with semver warning
8799
- Files: `packages/rum/src/entries/internal.ts`, `packages/rum/src/entries/internalSynthetics.ts`
88100
- Current mitigation: Warning comment states "not intended for public usages, and won't follow semver"
89101
- Recommendations: Separate internal packages or use module boundaries to prevent external consumption
90102

91103
**Console Logging:**
104+
92105
- Risk: 26 instances of console usage in production code (not counting tests)
93106
- Files: `packages/core/src/tools/display.ts`, `packages/core/src/domain/console/consoleObservable.ts`, `packages/logs/src/domain/configuration.ts`
94107
- Current mitigation: Mostly instrumentation of console for monitoring purposes
@@ -97,18 +110,21 @@
97110
## Performance Bottlenecks
98111

99112
**Large Type Definition Files:**
113+
100114
- Problem: Parsing and type-checking 2000+ line generated type files
101115
- Files: `packages/rum-core/src/rumEvent.types.ts` (2148 lines)
102116
- Cause: Complex RUM event schema with many union types and nested structures
103117
- Improvement path: Split into smaller interface files imported by main types, or use type generation with imports
104118

105119
**Mutation Batching Complexity:**
120+
106121
- Problem: DOM mutation tracking requires careful throttling to avoid performance impact
107122
- Files: `packages/rum/src/domain/record/mutationBatch.ts`
108123
- Cause: Need to balance between batching mutations (16ms min delay) and not blocking UI (100ms max delay)
109124
- Improvement path: Current implementation uses requestIdleCallback, but may need additional tuning for mutation-heavy SPAs
110125

111126
**Timer and Interval Usage:**
127+
112128
- Problem: Multiple setTimeout/setInterval usages could accumulate
113129
- Files: Spread across 20+ files including `packages/core/src/tools/timer.ts`, session management, transport retry logic
114130
- Cause: Various features need polling or delayed execution
@@ -117,24 +133,28 @@
117133
## Fragile Areas
118134

119135
**Public API Surface (`rumPublicApi.ts`):**
136+
120137
- Files: `packages/rum-core/src/boot/rumPublicApi.ts` (843 lines)
121138
- Why fragile: Central orchestration point for entire RUM SDK. Manages initialization state, lifecycle, context managers. Many edge cases around already-initialized state and race conditions
122139
- Safe modification: Always use existing patterns for adding new methods. Test all initialization paths. Check for proper cleanup in stop/destroy
123140
- Test coverage: Heavy test coverage in `packages/rum-core/src/boot/rumPublicApi.spec.ts` (952 lines) but complex state management
124141

125142
**Configuration Validation:**
143+
126144
- Files: `packages/rum-core/src/domain/configuration/configuration.ts` (553 lines)
127145
- Why fragile: Handles configuration validation, defaults, remote configuration overrides. Many deprecated options maintained for backward compatibility
128146
- Safe modification: Add new config options through existing validation patterns. Always provide defaults. Test with remote configuration enabled
129147
- Test coverage: `packages/rum-core/src/domain/configuration/configuration.spec.ts` (692 lines)
130148

131149
**DOM Mutation Tracking:**
150+
132151
- Files: `packages/rum/src/domain/record/trackers/trackMutation.ts` (262 lines), `packages/rum/src/domain/record/serialization/serializeNode.ts` (211 lines)
133152
- Why fragile: Complex logic for tracking and serializing DOM changes. Must handle shadow DOM, iframes, special element types. Comments mention "race condition" and "timing issue" concerns
134153
- Safe modification: Test extensively across browsers. Watch for memory leaks from retained node references. Verify behavior with MutationObserver timing
135154
- Test coverage: `packages/rum/src/domain/record/trackers/trackMutation.spec.ts` (1218 lines)
136155

137156
**Worker Communication:**
157+
138158
- Files: `packages/rum/src/domain/deflate/deflateWorker.ts`
139159
- Why fragile: Cross-browser worker instantiation differences. CSP restrictions. Async communication timing issues
140160
- Safe modification: Always provide fallback when worker fails. Test CSP scenarios. Handle both exception and error event patterns
@@ -143,59 +163,69 @@
143163
## Scaling Limits
144164

145165
**Event Size Limits:**
166+
146167
- Current capacity: Single event max 256KB, sanitize defaults to 220KB for user data
147168
- Limit: Large context objects or deeply nested structures hit size limits
148169
- Scaling path: Document size limits prominently. Provide guidance on summarizing large contexts
149170

150171
**Test Suite Size:**
172+
151173
- Current capacity: 221 test spec files in packages directory alone
152174
- Limit: Test execution time growing. E2E tests require BrowserStack or local browser setup
153175
- Scaling path: Parallelize test execution. Consider splitting test suites by feature area. Use test.only/test.skip judiciously (currently no skipped tests found)
154176

155177
**Monorepo Package Count:**
178+
156179
- Current capacity: 10 packages (core, rum, rum-core, rum-react, rum-slim, logs, worker, flagging)
157180
- Limit: Dependency management complexity. Build orchestration with yarn workspaces
158181
- Scaling path: Current structure is reasonable. Consider federation if package count grows significantly
159182

160183
## Dependencies at Risk
161184

162185
**Custom json-schema-to-typescript Fork:**
186+
163187
- Risk: Using fork `bcaudan/json-schema-to-typescript#bcaudan/add-readonly-support`
164188
- Impact: Generates all type definition files. If fork becomes unmaintained, can't update schema generation
165189
- Migration plan: Consider upstreaming readonly support patch to main project or find alternative code generation
166190

167191
**React Router v7 Major Update:**
192+
168193
- Risk: Recently updated to v7 (commit 92971947c)
169194
- Impact: Breaking changes may affect rum-react package router integration
170195
- Migration plan: Monitor for issues in `packages/rum-react/src/domain/reactRouter/` integration code
171196

172197
## Missing Critical Features
173198

174199
**Progressive Loading Type Definitions:**
200+
175201
- Problem: All type definitions loaded together in 2000+ line files
176202
- Blocks: IDE performance in large projects, slow TypeScript compilation
177203
- Priority: Medium - affects developer experience but not runtime
178204

179205
**Worker Fallback Strategy Documentation:**
206+
180207
- Problem: Worker failure modes handled but not well documented
181208
- Blocks: Customer debugging of CSP or worker issues
182209
- Priority: Medium - works in practice but support burden
183210

184211
## Test Coverage Gaps
185212

186213
**Browser Extension Context:**
214+
187215
- What's not tested: Extensive manual testing needed for developer extension
188216
- Files: `developer-extension/` directory has limited automated test coverage
189217
- Risk: Regressions in extension-specific features (panel UI, settings persistence)
190218
- Priority: Medium - extension is developer tool not customer-facing
191219

192220
**Error Boundary Edge Cases:**
221+
193222
- What's not tested: React error boundary with concurrent mode, Suspense boundaries
194223
- Files: `packages/rum-react/src/domain/error/errorBoundary.tsx`
195224
- Risk: Newer React features may interact unexpectedly with error tracking
196225
- Priority: Low - basic error boundary well tested
197226

198227
**Remote Configuration Overrides:**
228+
199229
- What's not tested: All combinations of local config + remote config overrides
200230
- Files: `packages/rum-core/src/domain/configuration/remoteConfiguration.ts`
201231
- Risk: Unexpected behavior when remote config conflicts with local settings
@@ -204,4 +234,4 @@
204234

205235
---
206236

207-
*Concerns audit: 2026-01-21*
237+
_Concerns audit: 2026-01-21_

0 commit comments

Comments
 (0)