|
5 | 5 | ## Tech Debt |
6 | 6 |
|
7 | 7 | **Generated Type Files:** |
| 8 | + |
8 | 9 | - Issue: Large generated type files (2000+ lines) from JSON schemas are checked into version control |
9 | 10 | - 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) |
10 | 11 | - Impact: These files have `/* eslint-disable */` at the top, bypassing all linting rules. Changes to schemas regenerate massive diffs making code review difficult |
11 | 12 | - Fix approach: Consider generating these at build time rather than checking into source control, or split schemas into smaller logical units |
12 | 13 |
|
13 | 14 | **Old Cookie Migration Code:** |
| 15 | + |
14 | 16 | - Issue: Migration code for old cookie format is permanently kept in codebase |
15 | 17 | - Files: `packages/core/src/domain/session/oldCookiesMigration.ts` |
16 | 18 | - 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` |
17 | 19 | - Fix approach: Establish deprecation timeline and removal date for old cookie support after sufficient adoption of new format |
18 | 20 |
|
19 | 21 | **Deprecated API Surface:** |
| 22 | + |
20 | 23 | - Issue: Multiple deprecated APIs still exported and maintained |
21 | 24 | - Files: |
22 | 25 | - `packages/rum-slim/src/entries/main.ts` - `RumGlobal` type deprecated in favor of `DatadogRum` |
|
27 | 30 | - Fix approach: Add deprecation warnings with timeline, document migration path, remove in next major version |
28 | 31 |
|
29 | 32 | **TypeScript Type Safety Bypasses:** |
| 33 | + |
30 | 34 | - Issue: 225 instances of `@ts-ignore`, `@ts-expect-error`, and eslint disables across 84 files |
31 | 35 | - Files: Widespread across packages, particularly in test files but also in production code |
32 | 36 | - Impact: Weakens type safety guarantees. Some legitimate (browser API compatibility), but indicates areas where types don't accurately model reality |
33 | 37 | - 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 |
34 | 38 |
|
35 | 39 | **Performance API Polyfills:** |
| 40 | + |
36 | 41 | - Issue: Multiple browser capability polyfills maintained for older browser support |
37 | 42 | - Files: |
38 | 43 | - `packages/rum-core/src/domain/view/viewMetrics/interactionCountPolyfill.ts` - Chrome-specific convention for interaction counting |
|
42 | 47 | - Fix approach: Define minimum supported browser versions and remove polyfills for features universally supported |
43 | 48 |
|
44 | 49 | **Type Coercion Through 'as any':** |
| 50 | + |
45 | 51 | - Issue: Extensive use of type assertions to bypass TypeScript checking |
46 | 52 | - Files: Spread throughout codebase, many instances of `as unknown as Type` patterns |
47 | 53 | - Impact: Runtime type mismatches not caught at compile time |
|
50 | 56 | ## Known Bugs |
51 | 57 |
|
52 | 58 | **Firefox Worker Error Handling:** |
| 59 | + |
53 | 60 | - Symptoms: Deflate worker errors handled differently across browsers |
54 | 61 | - Files: `packages/rum/src/domain/deflate/deflateWorker.ts` (line 88) |
55 | 62 | - Trigger: Worker initialization failure - Chromium throws exception, Firefox fires error event |
56 | 63 | - Workaround: Code handles both patterns. Comment references https://bugzilla.mozilla.org/show_bug.cgi?id=1736865#c2 |
57 | 64 |
|
58 | 65 | **Safari CSP Worker Failure:** |
| 66 | + |
59 | 67 | - Symptoms: Worker fails under CSP restrictions but doesn't trigger expected logging |
60 | 68 | - Files: `test/e2e/scenario/transport.scenario.ts` (line 38-41) |
61 | 69 | - Trigger: Content Security Policy blocks worker in Safari/WebKit |
62 | 70 | - Workaround: Test marked with `test.fixme` for webkit. Non-deflate requests still sent as fallback |
63 | 71 |
|
64 | 72 | **Edge Viewport Resize Inaccuracy:** |
| 73 | + |
65 | 74 | - Symptoms: ViewportResize record data is off by almost 20px in Edge |
66 | 75 | - Files: `test/e2e/scenario/recorder/viewports.scenario.ts` (line 33) |
67 | 76 | - Trigger: Viewport resize operations in Microsoft Edge |
68 | 77 | - Workaround: Test skipped for Edge browser with `test.fixme` |
69 | 78 |
|
70 | 79 | **Session Replay Race Condition:** |
| 80 | + |
71 | 81 | - Symptoms: Last segment may not be sent before page unload when using Web Worker |
72 | 82 | - Files: `test/e2e/lib/framework/flushEvents.ts` (lines 10-23) |
73 | 83 | - Trigger: Fast page navigation where Worker async communication completes after beforeunload event |
|
77 | 87 | ## Security Considerations |
78 | 88 |
|
79 | 89 | **Data Sanitization:** |
| 90 | + |
80 | 91 | - Risk: User-provided data needs careful sanitization before sending to intake |
81 | 92 | - Files: `packages/core/src/tools/serialisation/sanitize.ts` |
82 | 93 | - 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` |
83 | 94 | - Recommendations: Regular security audit of sanitization logic, especially for prototype pollution and XSS vectors |
84 | 95 |
|
85 | 96 | **Internal APIs Exposed:** |
| 97 | + |
86 | 98 | - Risk: Internal modules exported with semver warning |
87 | 99 | - Files: `packages/rum/src/entries/internal.ts`, `packages/rum/src/entries/internalSynthetics.ts` |
88 | 100 | - Current mitigation: Warning comment states "not intended for public usages, and won't follow semver" |
89 | 101 | - Recommendations: Separate internal packages or use module boundaries to prevent external consumption |
90 | 102 |
|
91 | 103 | **Console Logging:** |
| 104 | + |
92 | 105 | - Risk: 26 instances of console usage in production code (not counting tests) |
93 | 106 | - Files: `packages/core/src/tools/display.ts`, `packages/core/src/domain/console/consoleObservable.ts`, `packages/logs/src/domain/configuration.ts` |
94 | 107 | - Current mitigation: Mostly instrumentation of console for monitoring purposes |
|
97 | 110 | ## Performance Bottlenecks |
98 | 111 |
|
99 | 112 | **Large Type Definition Files:** |
| 113 | + |
100 | 114 | - Problem: Parsing and type-checking 2000+ line generated type files |
101 | 115 | - Files: `packages/rum-core/src/rumEvent.types.ts` (2148 lines) |
102 | 116 | - Cause: Complex RUM event schema with many union types and nested structures |
103 | 117 | - Improvement path: Split into smaller interface files imported by main types, or use type generation with imports |
104 | 118 |
|
105 | 119 | **Mutation Batching Complexity:** |
| 120 | + |
106 | 121 | - Problem: DOM mutation tracking requires careful throttling to avoid performance impact |
107 | 122 | - Files: `packages/rum/src/domain/record/mutationBatch.ts` |
108 | 123 | - Cause: Need to balance between batching mutations (16ms min delay) and not blocking UI (100ms max delay) |
109 | 124 | - Improvement path: Current implementation uses requestIdleCallback, but may need additional tuning for mutation-heavy SPAs |
110 | 125 |
|
111 | 126 | **Timer and Interval Usage:** |
| 127 | + |
112 | 128 | - Problem: Multiple setTimeout/setInterval usages could accumulate |
113 | 129 | - Files: Spread across 20+ files including `packages/core/src/tools/timer.ts`, session management, transport retry logic |
114 | 130 | - Cause: Various features need polling or delayed execution |
|
117 | 133 | ## Fragile Areas |
118 | 134 |
|
119 | 135 | **Public API Surface (`rumPublicApi.ts`):** |
| 136 | + |
120 | 137 | - Files: `packages/rum-core/src/boot/rumPublicApi.ts` (843 lines) |
121 | 138 | - 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 |
122 | 139 | - Safe modification: Always use existing patterns for adding new methods. Test all initialization paths. Check for proper cleanup in stop/destroy |
123 | 140 | - Test coverage: Heavy test coverage in `packages/rum-core/src/boot/rumPublicApi.spec.ts` (952 lines) but complex state management |
124 | 141 |
|
125 | 142 | **Configuration Validation:** |
| 143 | + |
126 | 144 | - Files: `packages/rum-core/src/domain/configuration/configuration.ts` (553 lines) |
127 | 145 | - Why fragile: Handles configuration validation, defaults, remote configuration overrides. Many deprecated options maintained for backward compatibility |
128 | 146 | - Safe modification: Add new config options through existing validation patterns. Always provide defaults. Test with remote configuration enabled |
129 | 147 | - Test coverage: `packages/rum-core/src/domain/configuration/configuration.spec.ts` (692 lines) |
130 | 148 |
|
131 | 149 | **DOM Mutation Tracking:** |
| 150 | + |
132 | 151 | - Files: `packages/rum/src/domain/record/trackers/trackMutation.ts` (262 lines), `packages/rum/src/domain/record/serialization/serializeNode.ts` (211 lines) |
133 | 152 | - 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 |
134 | 153 | - Safe modification: Test extensively across browsers. Watch for memory leaks from retained node references. Verify behavior with MutationObserver timing |
135 | 154 | - Test coverage: `packages/rum/src/domain/record/trackers/trackMutation.spec.ts` (1218 lines) |
136 | 155 |
|
137 | 156 | **Worker Communication:** |
| 157 | + |
138 | 158 | - Files: `packages/rum/src/domain/deflate/deflateWorker.ts` |
139 | 159 | - Why fragile: Cross-browser worker instantiation differences. CSP restrictions. Async communication timing issues |
140 | 160 | - Safe modification: Always provide fallback when worker fails. Test CSP scenarios. Handle both exception and error event patterns |
|
143 | 163 | ## Scaling Limits |
144 | 164 |
|
145 | 165 | **Event Size Limits:** |
| 166 | + |
146 | 167 | - Current capacity: Single event max 256KB, sanitize defaults to 220KB for user data |
147 | 168 | - Limit: Large context objects or deeply nested structures hit size limits |
148 | 169 | - Scaling path: Document size limits prominently. Provide guidance on summarizing large contexts |
149 | 170 |
|
150 | 171 | **Test Suite Size:** |
| 172 | + |
151 | 173 | - Current capacity: 221 test spec files in packages directory alone |
152 | 174 | - Limit: Test execution time growing. E2E tests require BrowserStack or local browser setup |
153 | 175 | - Scaling path: Parallelize test execution. Consider splitting test suites by feature area. Use test.only/test.skip judiciously (currently no skipped tests found) |
154 | 176 |
|
155 | 177 | **Monorepo Package Count:** |
| 178 | + |
156 | 179 | - Current capacity: 10 packages (core, rum, rum-core, rum-react, rum-slim, logs, worker, flagging) |
157 | 180 | - Limit: Dependency management complexity. Build orchestration with yarn workspaces |
158 | 181 | - Scaling path: Current structure is reasonable. Consider federation if package count grows significantly |
159 | 182 |
|
160 | 183 | ## Dependencies at Risk |
161 | 184 |
|
162 | 185 | **Custom json-schema-to-typescript Fork:** |
| 186 | + |
163 | 187 | - Risk: Using fork `bcaudan/json-schema-to-typescript#bcaudan/add-readonly-support` |
164 | 188 | - Impact: Generates all type definition files. If fork becomes unmaintained, can't update schema generation |
165 | 189 | - Migration plan: Consider upstreaming readonly support patch to main project or find alternative code generation |
166 | 190 |
|
167 | 191 | **React Router v7 Major Update:** |
| 192 | + |
168 | 193 | - Risk: Recently updated to v7 (commit 92971947c) |
169 | 194 | - Impact: Breaking changes may affect rum-react package router integration |
170 | 195 | - Migration plan: Monitor for issues in `packages/rum-react/src/domain/reactRouter/` integration code |
171 | 196 |
|
172 | 197 | ## Missing Critical Features |
173 | 198 |
|
174 | 199 | **Progressive Loading Type Definitions:** |
| 200 | + |
175 | 201 | - Problem: All type definitions loaded together in 2000+ line files |
176 | 202 | - Blocks: IDE performance in large projects, slow TypeScript compilation |
177 | 203 | - Priority: Medium - affects developer experience but not runtime |
178 | 204 |
|
179 | 205 | **Worker Fallback Strategy Documentation:** |
| 206 | + |
180 | 207 | - Problem: Worker failure modes handled but not well documented |
181 | 208 | - Blocks: Customer debugging of CSP or worker issues |
182 | 209 | - Priority: Medium - works in practice but support burden |
183 | 210 |
|
184 | 211 | ## Test Coverage Gaps |
185 | 212 |
|
186 | 213 | **Browser Extension Context:** |
| 214 | + |
187 | 215 | - What's not tested: Extensive manual testing needed for developer extension |
188 | 216 | - Files: `developer-extension/` directory has limited automated test coverage |
189 | 217 | - Risk: Regressions in extension-specific features (panel UI, settings persistence) |
190 | 218 | - Priority: Medium - extension is developer tool not customer-facing |
191 | 219 |
|
192 | 220 | **Error Boundary Edge Cases:** |
| 221 | + |
193 | 222 | - What's not tested: React error boundary with concurrent mode, Suspense boundaries |
194 | 223 | - Files: `packages/rum-react/src/domain/error/errorBoundary.tsx` |
195 | 224 | - Risk: Newer React features may interact unexpectedly with error tracking |
196 | 225 | - Priority: Low - basic error boundary well tested |
197 | 226 |
|
198 | 227 | **Remote Configuration Overrides:** |
| 228 | + |
199 | 229 | - What's not tested: All combinations of local config + remote config overrides |
200 | 230 | - Files: `packages/rum-core/src/domain/configuration/remoteConfiguration.ts` |
201 | 231 | - Risk: Unexpected behavior when remote config conflicts with local settings |
|
204 | 234 |
|
205 | 235 | --- |
206 | 236 |
|
207 | | -*Concerns audit: 2026-01-21* |
| 237 | +_Concerns audit: 2026-01-21_ |
0 commit comments