跳过内容

通道

Capgo 中的通道是管理应用程序更新的核心机制。它们允许您控制用户何时接收更新,启用 A/B 测试、分阶段发布和平台特定更新等功能。

通道代表应用程序更新的分发轨迹。每个通道都可以配置特定的规则和约束:

  • 包(版本)控制: 指定用户接收的包(版本)
  • 平台目标: 目标特定平台(iOS/Android/Electron)
  • 更新策略: 控制更新的分发方式
  • 设备限制: 控制哪些设备可以访问更新

频道配置选项

频道配置选项
  • 公共: 将该频道设置为新设备的默认频道。
  • 禁用原生应用版本更新: 在设备的原生应用版本新于频道的稳定包时,防止更新。
  • 禁用自动更新: 控制更新行为(major, minor, metadata, patch, 或) none).
  • ios/android/electron: 当前给管理一个类型器某版。
  • : 当前给管理类型器某版。: 当前给管理类型器某版。
  • : 当前给管理类型器某版。, : 当前给管理类型器某版。, : 当前给管理类型器某版。, : 当前给管理类型器某版。: 当前给管理类型器某版。
  • : 当前给管理类型器某版。: 当前给管理类型器某版。 : 当前给管理类型器某版。.

最佳实践

最佳实践部分
  1. 测试频道:为内部验证建立测试频道
  2. 分阶段发布:使用多个频道进行渐进式更新部署
  3. 平台分离:根据需要为iOS、Android和Electron创建独立频道
  4. 打包(版本)控制:使用 semantic versioning 为更新路径提供清晰的路径

https://api.capgo.app/channel/

Create or update a channel configuration.

type DisableAutoUpdate = "major" | "minor" | "metadata" | "patch" | "none"
type AutoPauseAction = "pause" | "rollback" | "notify"
interface ChannelSet {
app_id: string
channel: string
version?: string | null // stable bundle name
public?: boolean
disableAutoUpdateUnderNative?: boolean
disableAutoUpdate?: DisableAutoUpdate
ios?: boolean
android?: boolean
electron?: boolean
allow_device_self_set?: boolean
allow_emulator?: boolean
allow_device?: boolean
allow_dev?: boolean
allow_prod?: boolean
// Progressive rollout (camelCase is preferred)
rolloutVersion?: string | number | null // target bundle name or ID
rolloutPercentage?: number // 0–100
rolloutPercentageBps?: number // 0–10000; takes precedence when both are set
rolloutEnabled?: boolean
rolloutPaused?: boolean // input-only convenience flag
rolloutPausedAt?: string | null // ISO timestamp or null
rolloutPauseReason?: string | null
rolloutCacheTtlSeconds?: number // 60–31536000
rollback?: boolean
promoteToStable?: boolean
// Rollout auto-pause policy
autoPauseEnabled?: boolean
autoPauseWindowMinutes?: number
autoPauseFailureRateBps?: number | null
autoPauseConfidence?: number
autoPauseMinAttempts?: number | null
autoPauseMinFailures?: number | null
autoPauseAction?: AutoPauseAction
autoPauseCooldownMinutes?: number
}

For rollout and auto-pause fields, the API also accepts the equivalent snake_case __CAPGO_KEEP_0__也支持等效的表单形式,如 rollout_versionauto_pause_enabled。如果同时提供两种形式,驼峰式值优先。 rollback 仅支持 camelCase 格式。

要发布目标需要一个已有的渠道。它必须有一个稳定的捆绑包已经分配或通过 version 在同一个 POST 请求中。 rollbackpromoteToStable 这些是终端操作;请勿将它们与彼此结合。

为已有的 production 渠道配置 5% 的发布:

终端窗口
curl -X POST \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "com.example.app",
"channel": "production",
"rolloutVersion": "1.3.0",
"rolloutPercentage": 5,
"rolloutEnabled": true,
"rolloutCacheTtlSeconds": 2592000,
"autoPauseEnabled": true,
"autoPauseFailureRateBps": 500,
"autoPauseMinAttempts": 100,
"autoPauseAction": "pause"
}' \
https://api.capgo.app/channel/
{
"status": "ok"
}

POST 是一个插入或更新操作,仅返回其状态。 通过 GET 请求读取结果的通道配置。

为了实现最少权限的 PR 预览,需要在此端点上 authorization: $CAPGO_API_KEYcapgkey: $CAPGO_API_KEYx-api-key header 不被 Channels API 接受。

一个 app_preview 密钥可以创建一个新的非公开预览频道。 创建自动为该密钥分配一个仅限于该频道的通道作用域生命周期绑定。 该角色不包括 channel.update_settings,因此无法使用 POST 更新现有的频道,包括现有的默认频道或主频道。

离开 public __CAPGO_KEEP_0__ (或设置为 false)用于 PR 预览频道。使用 bundle upload --channel 为创建和上传流程而不是将 POST 视为一般预览频道 upsert。

https://api.capgo.app/channel/

获取频道信息。返回每页 50 个频道。没有 channel,响应是一个数组。有 channel,响应是一个频道对象。

  • app_id:必填。您的应用程序 ID
  • page: Optional. 分页的页数
  • channel: Optional. 指定要检索的特定频道名称
终端窗口
# Get all channels
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=com.example.app"
# Get a specific channel
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=com.example.app&channel=production"
# Get the next page
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=com.example.app&page=1"
interface Channel {
id: number
created_at: string
updated_at: string
name: string
app_id: string
created_by: string
public: boolean
disableAutoUpdateUnderNative: boolean
disableAutoUpdate: DisableAutoUpdate
allow_device_self_set: boolean
allow_emulator: boolean
allow_device: boolean
allow_dev: boolean
allow_prod: boolean
version: { id: number, name: string } | null // stable bundle
// These three response identifiers intentionally use snake_case.
rollout_version: number | null
rollout_id: string
rollout_version_info: { id: number, name: string } | null
rolloutPercentageBps: number
rolloutEnabled: boolean
rolloutPausedAt: string | null
rolloutPauseReason: string | null
rolloutCacheTtlSeconds: number
autoPauseEnabled: boolean
autoPauseWindowMinutes: number
autoPauseFailureRateBps: number | null
autoPauseConfidence: number
autoPauseMinAttempts: number | null
autoPauseMinFailures: number | null
autoPauseAction: AutoPauseAction
autoPauseCooldownMinutes: number
autoPauseLastTriggeredAt: string | null
autoPauseLastCheckedAt: string | null
}

rolloutPaused 是一个只用于输入的快捷方式,不会返回。暂停的滚动更新由一个非空值表示 rolloutPausedAt.

[
{
"id": 1,
"name": "production",
"app_id": "com.example.app",
"version": { "id": 1, "name": "1.2.0" },
"rollout_version": 2,
"rollout_id": "e60c19c9-2e65-4e0d-bc06-d1f5b4f96276",
"rollout_version_info": { "id": 2, "name": "1.3.0" },
"rolloutPercentageBps": 500,
"rolloutEnabled": true,
"rolloutPausedAt": null,
"rolloutCacheTtlSeconds": 2592000,
"autoPauseEnabled": true,
"autoPauseFailureRateBps": 500,
"autoPauseAction": "pause"
}
]

https://api.capgo.app/channel/

删除一个频道。请注意,这将影响所有使用此频道的设备。

interface Channel {
channel: string
app_id: string
delete_bundle?: boolean // also delete the linked bundle
}
终端窗口
curl -X DELETE \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "com.example.app",
"channel": "beta"
}' \
https://api.capgo.app/channel/
{
"status": "ok"
}

使用 delete_bundle: true, an app_preview 一个key可以原子性地清理它创建的通道和其关联的未共享包。该key不接收一般 bundle.delete 权限。

终端窗口
curl -X DELETE \
-H "capgkey: $CAPGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"app_id": "com.example.app",
"channel": "pr-123",
"delete_bundle": true
}' \
https://api.capgo.app/channel/

常见错误场景和响应:

// Channel not found
{
"error": "Channel not found",
"status": "KO"
}
// Invalid bundle (version) format
{
"error": "Invalid version format. Use semantic versioning",
"status": "KO"
}
// Invalid update policy
{
"error": "Invalid disableAutoUpdate value",
"status": "KO"
}
// Permission denied
{
"error": "Insufficient permissions to manage channels",
"status": "KO"
}
  1. 测试版
{
"app_id": "com.example.app",
"channel": "beta",
"version": "1.2.0-beta",
"public": false,
"allow_emulator": true,
"allow_dev": true
}
  1. 生产发布
{
"app_id": "com.example.app",
"channel": "production",
"version": "1.2.0",
"public": true,
"disableAutoUpdate": "minor"
}
  1. 平台特定更新
{
"app_id": "com.example.app",
"channel": "ios-hotfix",
"version": "1.2.1",
"ios": true,
"android": false
}

如果您正在使用 频道 来规划频道路由和分阶段发布,连接它与 频道 来获取频道的实施细节在频道中, 频道 来获取频道的实施细节在频道中, Beta 测试解决方案 来获取产品工作流程在 Beta 测试解决方案中, 版本目标解决方案 来获取产品工作流程在版本目标解决方案中,和 Capgo 环境最佳实践:使用一个移动应用ID进行分阶段发布 为实际环境中的Capgo环境最佳实践:使用一个移动应用ID进行分期.