> ## Documentation Index
> Fetch the complete documentation index at: https://hfh-d7a4d643-mintlify-d7bc03a0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 分析你的文档

> 使用 mint analytics 命令直接从终端查看流量、搜索查询、用户反馈和 AI 助手对话。

`mint analytics` 命令让你可以从终端访问[文档分析](/zh/optimize/analytics)。这对于通过脚本生成分析报告、将数据导入其他工具以及在不打开仪表板的情况下进行快速检查非常有用。

<div id="prerequisites">
  ## 前提条件
</div>

你必须登录才能使用分析命令。运行 `mint login` 来使用你的 Mintlify 账户进行身份验证。

有关身份验证的详细信息，请参阅[本地预览](/zh/cli/preview#log-in-for-search-and-assistant)。

<div id="view-key-metrics">
  ## 查看关键指标
</div>

显示浏览量、访客数、搜索量、反馈和助手使用情况的摘要：

```bash theme={null}
mint analytics stats
```

使用选项按日期范围或页面进行筛选：

* `--from`：开始日期，格式为 `YYYY-MM-DD`。默认为 7 天前。
* `--to`：结束日期，格式为 `YYYY-MM-DD`。默认为今天。
* `--page`：筛选特定页面路径。

```bash Example analytics stats flags theme={null}
mint analytics stats --from 2025-01-01 --to 2025-01-31
mint analytics stats --page /quickstart
```

<div id="view-search-analytics">
  ## 查看搜索分析
</div>

查看用户的搜索内容，包括命中次数和点击率：

```bash theme={null}
mint analytics search
```

使用选项按查询字符串或页面筛选：

* `--query`：按搜索查询子字符串筛选。
* `--page`：筛选特定页面路径。

```bash Example analytics search flags theme={null}
mint analytics search --query "authentication"

mint analytics search --page /api-reference
```

<div id="view-feedback">
  ## 查看反馈
</div>

查看用户在文档页面上提交的反馈：

```bash theme={null}
mint analytics feedback
```

使用选项按页面汇总反馈，或筛选代码片段反馈：

* `--type`：按页面或代码片段汇总反馈。默认为页面。
* `--page`：筛选特定页面路径。

```bash Example analytics feedback flags theme={null}
mint analytics feedback --type page
mint analytics feedback --type code
```

<div id="view-assistant-conversations">
  ## 查看助手对话
</div>

列出 AI 助手的最近对话和对话分类：

```bash theme={null}
mint analytics conversation list
mint analytics conversation buckets list
```

每个列表输出都包含每个条目的 ID。将该 ID 传递给相应的 `view` 命令以查看完整详情：

```bash theme={null}
mint analytics conversation view <conversation-id>
mint analytics conversation buckets view <bucket-id>
```

<div id="choose-an-output-format">
  ## 选择输出格式
</div>

所有分析命令默认使用 `plain` 输出，即制表符分隔，适合导入其他工具。使用 `--format` 更改输出：

```bash theme={null}
mint analytics stats --format table    # 带颜色的格式化表格
mint analytics stats --format json     # 原始 JSON
mint analytics stats --format graph    # 水平条形图
```

CLI 会自动检测 AI 代理环境（如 Claude Code 或非交互式终端），并默认使用 JSON 输出。

<div id="set-defaults-with-config">
  ## 使用 config 设置默认值
</div>

为避免重复输入常用选项，可以使用 `mint config` 设置默认值。配置保存在 `~/.config/mintlify/config.json` 中。

当你运行 `mint login` 时，CLI 会设置 `subdomain` 键。如果你有多个部署，CLI 会提示你选择一个。你可以随时使用 `mint config set subdomain <subdomain>` 覆盖默认值。

可用的配置键：

| 键           | 描述                              |
| ----------- | ------------------------------- |
| `subdomain` | 分析命令的默认子域名。由 `mint login` 命令设置。 |
| `dateFrom`  | 分析查询的默认开始日期（`YYYY-MM-DD`）。      |
| `dateTo`    | 分析查询的默认结束日期（`YYYY-MM-DD`）。      |

```bash Example configs theme={null}
mint config set subdomain my-docs
mint config set dateFrom 2025-01-01
```

设置后，分析命令会自动使用这些值：

```bash theme={null}
# 使用已配置的子域名和 dateFrom，无需选项
mint analytics stats
```

要查看或清除某个值，请运行：

```bash theme={null}
mint config get subdomain
mint config clear subdomain
```
