Files
cwd/docs/api/public/analytics.md
anghunk 3b429bf82c docs: 补充多站点数据隔离的配置和API文档
- 在站点隔离配置文档中详细说明 siteId 的使用方法和注意事项
- 为公开API接口添加 siteId 查询参数和请求头说明
- 更新前端配置文档,明确 siteId 为可选参数并说明默认值
- 修正常见问题中的表述和格式问题
2026-02-09 15:00:19 +08:00

2.0 KiB
Raw Blame History

访问统计

页面访问统计接口,用于记录和分析页面访问数据。

记录页面访问

POST /api/analytics/visit

前端组件在加载时调用此接口,记录页面访问数据,用于后台访问统计分析。

  • 方法:POST
  • 路径:/api/analytics/visit
  • 鉴权:不需要

请求头

名称 必填 示例
Content-Type application/json

请求体

{
  "postSlug": "https://example.com/blog/hello-world",
  "postTitle": "博客标题",
  "postUrl": "https://example.com/blog/hello-world"
}

请求头

名称 必填 示例
Content-Type application/json
X-Site-Id blog

字段说明:

字段名 类型 必填 说明
postSlug string 文章唯一标识符,window.location.origin + window.location.pathname
postTitle string 文章标题,用于后台展示页面名称
postUrl string 文章 URL用于后台展示页面链接和域名统计

请求头说明:

名称 必填 说明
X-Site-Id 站点 ID用于多站点数据隔离默认 default

成功响应

  • 状态码:200
{
  "success": true
}

错误响应

  • 缺少 postSlug

    • 状态码:400
    {
      "message": "postSlug is required"
    }
    
  • 服务器内部错误:

    • 状态码:500
    {
      "message": "记录访问数据失败"
    

! }