> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentcat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Client-Side Redaction

> Sanitize sensitive data before it leaves your environment with custom redaction functions.

AgentCat provides powerful client-side redaction capabilities, allowing you to sanitize sensitive information before it ever leaves your environment. This ensures that sensitive data never reaches our servers.

## How it works

You can provide a custom redaction function when initializing AgentCat tracking:

<CodeGroup>
  ```typescript Typescript theme={null}
  import * as agentcat from "agentcat";

  agentcat.track(mcpServer, "proj_YOUR_PROJECT_ID", {
    redactSensitiveInformation: async (text) => {
      let result = text;
      result = result.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, "<email>");
      result = result.replace(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, "<ip>");
      return result;
    },
  });

  ```

  ```python Python theme={null}
  import agentcat

  import re

  def redact_sensitive_data(text):
      result = text
      result = re.sub(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', '<email>', result)
      result = re.sub(r'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b', '<ip>', result)
      return result

  agentcat.track(server, "proj_YOUR_PROJECT_ID", agentcat.AgentCatOptions(
      redact_sensitive_information=redact_sensitive_data,
  ))
  ```

  ```go Go theme={null}
  import mcpcat "github.com/mcpcat/mcpcat-go-sdk/officialsdk"
  // For mark3labs/mcp-go: import mcpcat "github.com/mcpcat/mcpcat-go-sdk/mcpgo"

  mcpcat.Track(s, "proj_YOUR_PROJECT_ID", &mcpcat.Options{
      RedactSensitiveInformation: func(text string) string {
          result := text
          result = regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`).ReplaceAllString(result, "<email>")
          result = regexp.MustCompile(`\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b`).ReplaceAllString(result, "<ip>")
          return result
      },
  })
  ```
</CodeGroup>

## Key Features

* **Recursive Application**: Redaction is applied to all string values in event data, including nested objects and arrays
* **Protected Fields**: Essential analytics fields (like `sessionId`, `projectId`, `eventType`) are preserved to maintain functionality
* **Type Preservation**: Non-string values (numbers, booleans, dates) are preserved without modification
* **Error Handling**: If redaction fails, the entire event is skipped to prevent accidental data leakage
