跳转到正文

统计数据

Statistics API 端点提供有关您的应用和组织的详细分析数据。您可以跟踪不同时间段内的月活跃用户数(MAU)、存储使用量和带宽消耗。这些数据对于监控应用增长、资源使用情况以及规划容量至关重要。

  • MAU(月活跃用户数):过去 30 天内访问您应用的唯一设备数量
  • 存储空间:以字节为单位存储的所有 bundle 和资源的总大小
  • 带宽:以字节为单位的 bundle 下载总数据传输量
  1. 定期监控: 定期查看统计数据,跟踪增长和使用模式
  2. 资源规划: 利用存储和带宽指标进行容量规划
  3. 用户参与度: 跟踪 MAU,了解用户参与度趋势
  4. 成本管理: 监控资源使用情况以优化成本

获取特定应用的统计数据。此端点适用于监控单个应用的性能。

interface StatsQuery {
from: Date // Start date for the statistics (format: YYYY-MM-DD)
to: Date // End date for the statistics (format: YYYY-MM-DD)
}
终端窗口
curl -H "authorization: your-api-key" \
"https://api.capgo.app/statistics/app/com.demo.app/?from=2024-01-01&to=2024-02-01"
[
{
"date": "2024-01-01",
"mau": 1500,
"storage": 536870912, // 512MB in bytes
"bandwidth": 1073741824 // 1GB in bytes
},
{
"date": "2024-01-02",
"mau": 1550,
"storage": 537919488, // 513MB in bytes
"bandwidth": 1074790400 // 1.01GB in bytes
}
]

GET /statistics/org/:org_id/

“GET /statistics/org/:org_id/” 章节

获取指定组织的统计数据,适合监控组织级用量。

interface StatsQuery {
from: Date // Start date for the statistics (format: YYYY-MM-DD)
to: Date // End date for the statistics (format: YYYY-MM-DD)
breakdown: boolean // default false, optional if true it return the breakdown by app
noAccumulate: boolean // default false, optional if true it will not accumulate data and just return day by day result
}
终端窗口
curl -H "authorization: your-api-key" \
"https://api.capgo.app/statistics/org/046a36ac-e03c-4590-9257-bd6c9dba9ee8/?from=2024-01-01&to=2024-02-01"
[
{
"date": "2024-01-01",
"mau": 10000,
"storage": 536870912, // 512MB in bytes
"bandwidth": 1073741824 // 1GB in bytes
},
{
"date": "2024-01-02",
"mau": 10200,
"storage": 537919488, // 513MB in bytes
"bandwidth": 1074790400 // 1.01GB in bytes
}
]

获取您有权访问的所有组织的聚合统计数据。非常适合整体使用情况监控。

interface StatsQuery {
from: Date // Start date for the statistics (format: YYYY-MM-DD)
to: Date // End date for the statistics (format: YYYY-MM-DD)
}
终端窗口
curl -H "authorization: your-api-key" \
"https://api.capgo.app/statistics/user/?from=2024-01-01&to=2024-02-01"
[
{
"date": "2024-01-01",
"mau": 25000,
"storage": 1073741824, // 1GB in bytes
"bandwidth": 2147483648 // 2GB in bytes
},
{
"date": "2024-01-02",
"mau": 25500,
"storage": 1074790400, // 1.01GB in bytes
"bandwidth": 2148532224 // 2.01GB in bytes
}
]

获取指定应用的 bundle 使用统计,展示指定时间段内 bundle(版本)在用户中的分布情况。

interface BundleUsageQuery {
from: Date // Start date for the statistics (format: YYYY-MM-DD)
to: Date // End date for the statistics (format: YYYY-MM-DD)
}
终端窗口
curl -H "authorization: your-api-key" \
"https://api.capgo.app/statistics/app/com.demo.app/bundle_usage?from=2024-01-01&to=2024-02-01"
{
"labels": ["2024-01-01", "2024-01-02", "2024-01-03"],
"datasets": [
{
"label": "1.0.0",
"data": [60.5, 58.2, 55.3]
},
{
"label": "1.0.1",
"data": [39.5, 41.8, 44.7]
}
]
}

所有错误均采用以下文档中描述的标准错误格式: API 概览.

常见的错误场景及其响应:

// The API key cannot read this app (HTTP 401)
{
"error": "no_access_to_app",
"message": "No access to app",
"moreInfo": { "data": "6aa76066-55ef-4238-ade6-0b32334a4097" }
}
// The API key cannot read this organization (HTTP 401)
{
"error": "no_access_to_organization",
"message": "No access to organization",
"moreInfo": { "data": "6aa76066-55ef-4238-ade6-0b32334a4097" }
}
// Organization statistics require an active plan (HTTP 402)
{
"error": "subscription_required",
"message": "Organization subscription required or plan invalid",
"moreInfo": { "orgId": "046a36ac-e03c-4590-9257-bd6c9dba9ee8", "isPayingAndGoodPlan": false }
}
// User statistics when the user belongs to no organization (HTTP 401)
{
"error": "no_organizations_found",
"message": "No organizations found",
"moreInfo": { "data": "6aa76066-55ef-4238-ade6-0b32334a4097" }
}
  1. 增长追踪:监控 MAU 随时间的增长情况
  2. 资源优化:追踪存储和带宽用量以优化成本
  3. 容量规划:利用趋势规划未来的资源需求
  4. 使用报告:为利益相关者定期生成使用报告
  5. Bundle(版本)分布分析:通过 bundle 使用统计,了解用户在不同 app bundle(版本)上的分布情况
  1. 对比周期: 查看环比或同比趋势
  2. 追踪比例: 监控单用户带宽或单应用存储占用
  3. 设置告警: 针对异常使用量激增创建告警
  4. 定期备份: 定期导出统计数据进行历史分析
  5. Bundle (版本) 采用率: 利用 bundle 使用情况追踪新 bundle (版本) 的采用率

如果你正在使用 统计数据 要规划存储和文件处理,请将其与 @capgo/capacitor-data-storage-sqlite 关于 @capgo/capacitor-data-storage-sqlite 中的实现细节, 使用 @capgo/capacitor-data-storage-sqlite 关于使用 @capgo/capacitor-data-storage-sqlite 的原生能力, @capgo/capacitor-file 关于 @capgo/capacitor-file 中的实现细节, 使用 @capgo/capacitor-file 用于“使用 @capgo/capacitor-file”中的原生能力,以及 @capgo/capacitor-uploader 了解 @capgo/capacitor-uploader. 的实现细节

发布健康状态、错误与原生构建

章节标题:“发布健康状态、错误与原生构建”

使用 监控 API 用于原生和更新器诊断、带元数据的日志、实时发布 dashboard 统计,以及原生构建状态和日志快照。这些读取操作也由两个账户 MCP 服务器提供。

读取原生版本采用率和每日活跃设备数,针对 from 以及 to 日期。响应包含 labels,chart datasets, latestVersion, activeDevices, previousPeriodActiveDevices,以及 dailyPlatformActive.

dailyPlatformActive 是一个对象,包含 labels 作为日期字符串,以及 android, ios, electron, unknown,以及 total 作为与这些日期对齐的数字数组。它不是行数组。活跃设备的次要读取在不可用时会降级为空数据;空值并不能证明没有设备处于活跃状态。