跳转到正文

统计数据

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

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

GET /statistics/app/:app_id/

“GET /statistics/app/:app_id/” 章节

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

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 bundles (版本) 中的分布情况
  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. 的实现细节