機能フラグとA/Bテストのためのチャンネルの使用方法
Capgoのチャンネルシステムは、ユーザーを分割し機能へのアクセスを制御するための柔軟な方法を提供します。Capgoには、プランの管理やA/Bテストの機能は組み込まれていませんが、チャンネル割り当てを自分で管理することで、これらの機能を実装できます。
チャンネルの理解
Capgoのチャンネルでは、以下のことができます:
- 特定ユーザーグループを機能に合わせてターゲット
- チャネルを異なるユーザーに割り当ててA/Bテスト
- 新機能を段階的にリリース
- ベータテストプログラムの作成
チャネル割り当て方法
1. バックエンド割り当て (推奨)
この方法はより安全です。次の手順が含まれます。
- デバイスIDをアップデーターから取得
- バックエンドに送信
- バックエンドはデバイスにCapgo APIを呼び出して割り当てます
実装方法はこちら
import { CapacitorUpdater } from '@capgo/capacitor-updater'
// Get device ID
const getDeviceId = async () => {
const { deviceId } = await CapacitorUpdater.getDeviceId()
return deviceId
}
// Send device ID to your backend
const assignToChannel = async (channel: string) => {
const deviceId = await getDeviceId()
// Your backend will call Capgo API to assign the device
await yourBackend.assignDeviceToChannel(deviceId, channel)
}
バックエンド実装
あなたのバックエンドには
- API キーを取得するには、Capgo ダッシュボードにアクセスしてください
- Capgo API を呼び出して、デバイスをチャンネルに割り当てます
API キーを取得するには
- Capgo ダッシュボードにログインしてください
- 設定 > API キーに移動してください
- 「新しいキーを生成」ボタンをクリックしてください
- モードを選択して、デバイスとチャンネルの管理を行います
all生成されたキーを安全にバックエンド環境変数に保存してください - キーは 32 桁の 16 進数の文字列になります
- これは、クライアントサイドの __CAPGO_KEEP_0__ では暴露してはならない秘密のキーです
- code
Node.jsの例:
import axios from 'axios'
const CAPGO_API_KEY = 'your_api_key'
const CAPGO_API_URL = 'https://api.capgo.app'
async function assignDeviceToChannel(deviceId: string, channel: string) {
try {
const response = await axios.post(
`${CAPGO_API_URL}/device`,
{
app_id: 'YOUR_APP_ID',
device_id: deviceId,
channel: channel
},
{
headers: {
'authorization': CAPGO_API_KEY,
'Content-Type': 'application/json'
}
}
)
return response.data
} catch (error) {
console.error('Failed to assign device to channel:', error)
throw error
}
}
バックエンドも
- ユーザーの権限を検証する
- すべてのチャンネル割り当てをログする
- レート制限をハンドルする
- 失敗した割り当てに対してリトライロジックを実装する
2. 自動割り当て(セキュリティが低い)
この方法では、デバイスが直接チャンネルに割り当てられる。テストに便利ですが、生産環境ではセキュリティが低い:
import { CapacitorUpdater } from '@capgo/capacitor-updater'
// Assign device to channel
const assignToChannel = async (channel: string) => {
await CapacitorUpdater.setChannel(channel)
}
// Get current channel
const getCurrentChannel = async () => {
const { channel } = await CapacitorUpdater.getChannel()
return channel
}
ユーザーがチャンネルに自動割り当てできるようにするには、Capgo ダッシュボードでこの機能を有効にする必要があります:
- Capgo ダッシュボードのチャンネルセクションに移動する
- 管理したいチャンネル名をクリックする
- チャンネル設定で、「デバイスがチャンネルに自動割り当てることを許可する」を有効にする
- 変更を保存
この設定がfalseの場合、チャンネルを指定して呼び出そうとすると失敗します。 setChannel 機能フラグの実装
機能へのアクセスを制御するには、チャンネルを使用してください。
A/Bテストの実装
const isFeatureEnabled = async (feature: string) => {
// Example: Check if user is in beta channel
const channel = await getCurrentChannel()
return channel === 'beta'
}
ユーザーを異なるチャンネルに割り当ててA/Bテストを実行してください。
ベストプラクティス
const assignToABTest = async (userId: string) => {
// Use consistent hashing to assign users
const hash = await hashUserId(userId)
const variant = hash % 2 === 0 ? 'variant-a' : 'variant-b'
await assignToChannel(variant)
return variant
}
バックエンド割り当てを使用してください。生産環境では、常にバックエンド割り当てを使用してください。
- 一貫した割り当てユーザーIDまたは他の安定した識別子を使用して、一貫したチャンネル割り当てを実行してください。
- 変更を保存この設定がfalseの場合、チャンネルを指定して呼び出そうとすると失敗します。
- 監視: 各チャンネルごとに機能使用状況とパフォーマンスメトリクスを追跡する
- 段階的なロールアウト: 小さなユーザーセグメントから始めて段階的に拡大する
- 明確なドキュメント: チャンネル戦略と目的をドキュメント化する
結論
: Capgoのチャンネルシステムを活用することで、より個別のアプリエクスペリエンスを作成し、A/Bテストを実行できます。生産環境では、セキュリティと制御のためにバックエンド割り当てメソッドを優先することをお勧めします。
詳細については、 チャンネル管理に関するドキュメント.
続けて
チャンネルを使用して機能フラグとA/Bテストを行う方法の使用方法 How to Use Channels for Feature Flags and A/B Testing to plan channel routing and staged rollout, connect it with チャンネル context:Capgo release channels feature name. Page/area: Capgo solutions marketing page. Role: Short UI label or navigation item. Seen in: page solutions/white-label.astro. Message key `solutions_white_label_visual_cell2_value` (Solutions White Label Visual Cell2 Value). for the implementation detail in Channels チャンネル context:Capgo release channels feature name. Page/area: Capgo solutions marketing page. Role: Short UI label or navigation item. Seen in: page solutions/white-label.astro. Message key `solutions_white_label_visual_cell2_value` (Solutions White Label Visual Cell2 Value). for the implementation detail in Channels チャンネル context:Capgo release channels feature name. Page/area: Capgo solutions marketing page. Role: Short UI label or navigation item. Seen in: page solutions/white-label.astro. Message key `solutions_white_label_visual_cell2_value` (Solutions White Label Visual Cell2 Value). for the implementation detail in Channels ベータテストソリューション (Beta Testing Solution)の製品ワークフローについては、