Clarity
A behavioral analytics library that uses dom mutations and user interactions to generate aggregated insights.
Ask AI about Clarity
Powered by Claude · Grounded in docs
I know everything about Clarity. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Clarity
Clarity is an open-source behavioral analytics library written in typescript, with two key goals: privacy & performance.
It helps you understand how users view and use your website across all modern devices and browsers. Understanding how users navigate, interact and browse your website can provide new insights about your users. Empathizing with your users and seeing where features fail or succeed can help improve your product, grow revenue and improve user retention.
It's the same code that powers Microsoft's hosted behavioral analytics solution: https://clarity.microsoft.com. If you would like to see a demo of how it works, checkout live demo.
We encourage the community to join us in building the best behavioral analytics library, that puts privacy first and prioritizes performance.
Project Structure
-
clarity-js: Instrumentation code that goes on the website and tracks user interactions as well as layout changes.
-
clarity-decode: Code, which usually runs on the server, decodes incoming data back into its original format.
-
clarity-visualize: It takes the decoded data from clarity-decode and turns it back into pixel-perfect session replay.
-
clarity-devtools: Devtools extension for chromium based browsers to generate live captures against any website.
Releasing new version
-
Bump Version
yarn bump-version -
Submit Changes
- Commit updated files
- Push changes
- Create PR
Examples
Here are some example sessions on popular websites visualized to demonstrate the telemetry captured:
Privacy Notice
Clarity handles sensitive data with care. By default sensitive content on the page is masked before uploading to the server. Additionally, Clarity offers several masking configuration options to ensure you are in full control of your data.
Claude Code Setup (Optional)
If you're using Claude Code for development, this repository includes:
CLAUDE.md- Project context and development guidelines automatically loaded by Claude.mcp.json- MCP (Model Context Protocol) server configuration for enhanced Git operations
Prerequisites for MCP Server
-
Install Python 3:
python3 --version # Verify installation -
Install the Git MCP Server:
pip3 install mcp-server-git
Enable MCP Server
The repository includes a .mcp.json file that configures the Git MCP server. To enable it:
Option 1: Auto-enable (Recommended)
Add to your .claude/settings.local.json:
{
"enableAllProjectMcpServers": true
}
Option 2: Explicit approval Claude Code will prompt you to approve the MCP server on first use.
What It Provides
- CLAUDE.md: Persistent instructions for Claude including build commands, testing, architecture, and coding standards
- Git MCP Server: Enhanced Git operations through natural language (commit history, diffs, branch management, etc.)
Improving Clarity
If you haven't already done so, start contributing by following instructions here.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Happy coding!
