How microsoft/clarity works
Main Components
• Clarity-JS: This is the client-side instrumentation library that runs on user websites. It captures user interactions, layout changes, and performance metrics.
• Clarity-Decode: This backend (or server-side) module receives the raw telemetry data and decodes it into its original, interpretable format.
• Clarity-DevTools: A Chromium-based devtools extension that helps in generating live captures and debugging sessions on the fly.
Out the Relationships and Interactions
• Clarity-JS component as a key part of the client-side instrumentation. Note that it is responsible for capturing various types of user interactions (clicks, scrolling, input events, layout changes, performance metrics, etc.).
• Clarity-Decode as a backend service that processes incoming data, decodes various formats (interaction, layout, performance, etc.) and prepares it for visualization.
Architectural Patterns and Design Principles
• Specify that the system uses event-driven data capture and pipeline processing, where the telemetry flows from client detection to server decoding and finally to session replay visualization.
Relevant Technologies and Frameworks
• Languages/Frameworks: All packages are written in TypeScript.
• Build Tools: Use of Rollup (as seen in rollup.config.ts files) for bundling.
• Package Management: Managed via Lerna, highlighting a monorepo structure.
• Additionally, note any relevant configurations like ESLint/TSLint configurations and TypeScript definitions (d.ts files) that enforce strong typing across the packages.
Essential Elements
• Annotations: Optionally annotate with key design decisions such as “modular design with Lerna” or “privacy-first data handling”.