You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor channel management documentation and update database schema
- Updated documentation for channel API endpoints in Japanese, Korean, and Chinese to improve clarity and consistency.
- Enhanced channel operations section to include detailed request and response formats, including error handling.
- Revised database schema to include new fields for device restrictions and channel configurations.
- Modified Supabase types to reflect changes in the database schema, adding support for device-specific settings.
@@ -14,7 +14,7 @@ Channels are a core mechanism for managing app updates in Capgo. In self-hosted
14
14
15
15
Channels allow you to:
16
16
-**Control update distribution**: Assign different app versions to different user groups
17
-
-**A/B testing**: Test new features with specific user segments
17
+
-**A/B testing**: Test new features with specific user segments
18
18
-**Staged rollouts**: Gradually deploy updates to minimize risk
19
19
-**Environment separation**: Separate development, staging, and production updates
20
20
@@ -36,9 +36,9 @@ Configure the channel endpoint URL in your `capacitor.config.json`:
36
36
37
37
The plugin performs different channel operations that your endpoint needs to handle:
38
38
39
-
### 1. Get Channel (GET Request)
39
+
### 1. List Compatible Channels (GET Request)
40
40
41
-
When the plugin calls `getChannel()`, it sends a GET request to retrieve the device's current channel assignment.
41
+
When the plugin calls `listChannels()`, it sends a GET request to retrieve all channels that are compatible with the device. This returns channels that match the device's environment (dev/prod, emulator/real device) and allow either public access or self-assignment.
42
42
43
43
#### Request Format
44
44
```typescript
@@ -48,7 +48,59 @@ When the plugin calls `getChannel()`, it sends a GET request to retrieve the dev
48
48
"Content-Type": "application/json"
49
49
}
50
50
51
-
// Query parameters or body:
51
+
// Query parameters:
52
+
interfaceListChannelsRequest {
53
+
app_id:string
54
+
platform:"ios"|"android"
55
+
is_emulator:boolean
56
+
is_prod:boolean
57
+
key_id?:string
58
+
}
59
+
```
60
+
61
+
#### Response Format
62
+
```json
63
+
[
64
+
{
65
+
"id": 1,
66
+
"name": "production",
67
+
"public": true,
68
+
"allow_self_set": false
69
+
},
70
+
{
71
+
"id": 2,
72
+
"name": "beta",
73
+
"public": false,
74
+
"allow_self_set": true
75
+
}
76
+
]
77
+
```
78
+
79
+
#### Understanding Channel Types
80
+
81
+
The response includes two important flags for each channel:
82
+
83
+
-**`public: true`**: This is a **default channel**. Devices cannot self-assign to it using `setChannel()`. Instead, if a device removes its channel assignment (using `unsetChannel()`), it will automatically receive updates from this public channel if it matches the device's conditions.
84
+
85
+
-**`allow_self_set: true`**: This is a **self-assignable channel**. Devices can explicitly assign themselves to this channel using `setChannel()`. This is useful for beta testing, A/B testing, or allowing users to opt-in to specific update tracks.
86
+
87
+
:::note
88
+
A channel can be either `public` OR `allow_self_set`, but typically not both. Public channels serve as the default fallback, while self-assignable channels require explicit opt-in.
89
+
:::
90
+
91
+
### 2. Get Channel (PUT Request)
92
+
93
+
When the plugin calls `getChannel()`, it sends a PUT request to retrieve the device's current channel assignment.
94
+
95
+
#### Request Format
96
+
```typescript
97
+
// PUT /api/channel_self
98
+
// Headers:
99
+
{
100
+
"Content-Type": "application/json"
101
+
}
102
+
103
+
// Body:
52
104
interfaceGetChannelRequest {
53
105
device_id:string
54
106
app_id:string
@@ -57,6 +109,10 @@ interface GetChannelRequest {
57
109
version_build:string
58
110
version_code:string
59
111
version_name:string
112
+
is_emulator:boolean
113
+
is_prod:boolean
114
+
defaultChannel?:string
115
+
channel?:string// For newer plugin versions, contains local channel override
60
116
}
61
117
```
62
118
@@ -71,7 +127,7 @@ interface GetChannelRequest {
71
127
}
72
128
```
73
129
74
-
### 2. Set Channel (POST Request)
130
+
### 3. Set Channel (POST Request)
75
131
76
132
When the plugin calls `setChannel()`, it sends a POST request to assign the device to a specific channel.
77
133
@@ -87,6 +143,8 @@ interface SetChannelRequest {
87
143
version_build:string
88
144
version_code:string
89
145
version_name:string
146
+
is_emulator:boolean
147
+
is_prod:boolean
90
148
}
91
149
```
92
150
@@ -99,7 +157,29 @@ interface SetChannelRequest {
99
157
}
100
158
```
101
159
102
-
### 3. Unset Channel (DELETE Request)
160
+
#### Error Cases
161
+
162
+
When a device tries to assign itself to a **public channel** (one with `public: true`), your endpoint should return an error:
163
+
164
+
```json
165
+
{
166
+
"status": "error",
167
+
"error": "public_channel_self_set_not_allowed",
168
+
"message": "This channel is public and does not allow device self-assignment. Unset the channel and the device will automatically use the public channel."
169
+
}
170
+
```
171
+
172
+
When a device tries to assign itself to a channel that doesn't allow self-assignment:
173
+
174
+
```json
175
+
{
176
+
"status": "error",
177
+
"error": "channel_self_set_not_allowed",
178
+
"message": "This channel does not allow devices to self associate"
179
+
}
180
+
```
181
+
182
+
### 4. Unset Channel (DELETE Request)
103
183
104
184
When the plugin calls `unsetChannel()`, it sends a DELETE request to remove the device's channel assignment.
105
185
@@ -144,20 +224,20 @@ interface ChannelResponse {
144
224
exportconst handler =async (event) => {
145
225
const method =event.httpMethod||event.method
146
226
const body =JSON.parse(event.body||'{}') asChannelRequest
0 commit comments