DyeLight includes a built-in telemetry system that helps diagnose synchronization issues between the textarea and React state. This is especially useful for hard-to-reproduce bugs.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ragaeeb/dyelight/llms.txt
Use this file to discover all available pages before exploring further.
Enabling debug mode
Add thedebug prop to enable telemetry collection:
Debug mode has minimal performance impact but should generally be disabled in production unless troubleshooting specific issues.
Using the exportForAI() method
The exportForAI() ref method generates a comprehensive JSON report that can be analyzed by AI models:
- Enable debug mode - Add
debug={true}to your DyeLight component - Reproduce the issue - Use the component normally until the bug occurs
- Export the report - Call
ref.current?.exportForAI()to get a JSON report - Get AI diagnosis:
- Go to claude.ai or chat.openai.com
- Paste the exported JSON
- Ask: “Please analyze this DyeLight debug report and identify the issue”
- Get instant diagnosis - The AI will identify the root cause and suggest fixes
What’s included in debug reports
The telemetry system captures comprehensive diagnostic data:Event timeline
Every interaction is recorded with millisecond precision:onChangeevents from user typing/pasting- Auto-resize operations
- Scroll synchronization
- Style synchronization between textarea and overlay
State snapshots
At each event, the system captures:- DOM value vs React state value
- Textarea and overlay geometry (width, height, scroll position)
- Selection range (cursor position)
- Layout deltas between textarea and overlay
Automatic issue detection
The system pre-identifies common problems:- Rapid successive events - Events firing less than 2ms apart indicate race conditions
- Excessive resize operations - More resizes than value changes suggests infinite
ResizeObserverloop - Large paste operations - Pastes >100 characters that may trigger sync issues
- Layout thrashing - High frequency of sync operations
Timing information
Each event includes:- Absolute timestamp (ISO format)
- Time since last event (milliseconds)
- Event category (
user,state,sync,system)
Browser metadata
The report includes environmental context:- User agent string
- Platform information
- Component version
- Total event count and timespan
Telemetry system architecture
The telemetry system is implemented insrc/telemetry.ts and uses several optimization strategies:
Value deduplication
Large text values (>1000 characters) are stored once in avalueRegistry and referenced as <REF:value_N>. This prevents the JSON from becoming huge when users paste large blocks of text.
Event categorization
Events are categorized for easier analysis:user: Direct user interactions (typing, pasting, selection changes)state: Programmatic state changes (setValue, etc.)sync: Layout synchronization operations (syncStyles,syncScroll)system: Periodic snapshots and background tasks
Memory management
The telemetry system maintains a circular buffer of events:Debug mode options
| Prop | Type | Default | Description |
|---|---|---|---|
debug | boolean | false | Enable telemetry collection |
debugMaxEvents | number | 1000 | Maximum events to retain in memory |
Common issue patterns
The AI analysis looks for these patterns:State desynchronization
- Multiple
onChangehandlers bound to the textarea - Direct DOM manipulation from external code
- Race conditions during paste operations
Race conditions
Events firing less than 2ms apart:- Double-bound event listeners
- Need for debouncing in user code
Infinite resize loop
More resize events than value changes indicates aResizeObserver feedback loop: