メインコンテンツにジャンプする
チュートリアル

機能フラグとA/Bテストのためのチャンネルの使用方法

Capgoのチャンネルを使用して機能フラグとA/Bテストを実行する方法を学びましょう。ユーザーを自分で割り当てるか、バックエンドを使用して割り当てることができます。

マーティン・ドナディエ

マーティン・ドナディエ

コンテンツマーケター

機能フラグとA/Bテストのためのチャンネルの使用方法

機能フラグとA/Bテストのためのチャンネルの使用方法

Capgoのチャンネルシステムは、ユーザーを分割し機能へのアクセスを制御するための柔軟な方法を提供します。Capgoには、プランの管理やA/Bテストの機能は組み込まれていませんが、チャンネル割り当てを自分で管理することで、これらの機能を実装できます。

チャンネルの理解

Capgoのチャンネルでは、以下のことができます:

  • 特定ユーザーグループを機能に合わせてターゲット
  • チャネルを異なるユーザーに割り当ててA/Bテスト
  • 新機能を段階的にリリース
  • ベータテストプログラムの作成

チャネル割り当て方法

この方法はより安全です。次の手順が含まれます。

  1. デバイスIDをアップデーターから取得
  2. バックエンドに送信
  3. バックエンドはデバイスに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)
}

バックエンド実装

あなたのバックエンドには

  1. API キーを取得するには、Capgo ダッシュボードにアクセスしてください
  2. Capgo API を呼び出して、デバイスをチャンネルに割り当てます

API キーを取得するには

  1. Capgo ダッシュボードにログインしてください
  2. 設定 > API キーに移動してください
  3. 「新しいキーを生成」ボタンをクリックしてください
  4. モードを選択して、デバイスとチャンネルの管理を行います all 生成されたキーを安全にバックエンド環境変数に保存してください
  5. キーは 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 ダッシュボードでこの機能を有効にする必要があります:

  1. Capgo ダッシュボードのチャンネルセクションに移動する
  2. 管理したいチャンネル名をクリックする
  3. チャンネル設定で、「デバイスがチャンネルに自動割り当てることを許可する」を有効にする
  4. 変更を保存

この設定が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
}

バックエンド割り当てを使用してください。生産環境では、常にバックエンド割り当てを使用してください。

  1. 一貫した割り当てユーザーIDまたは他の安定した識別子を使用して、一貫したチャンネル割り当てを実行してください。
  2. 変更を保存この設定がfalseの場合、チャンネルを指定して呼び出そうとすると失敗します。
  3. 監視: 各チャンネルごとに機能使用状況とパフォーマンスメトリクスを追跡する
  4. 段階的なロールアウト: 小さなユーザーセグメントから始めて段階的に拡大する
  5. 明確なドキュメント: チャンネル戦略と目的をドキュメント化する

結論

: 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)の製品ワークフローについては、

リアルタイム更新の Capacitor アプリ

When a web-layer bug is live, ship the fix through Capgo instead of waiting days for app store approval. Users get the update in the background while native changes stay in the normal review path.

ウェブ層のバグが実行中の場合、__CAPGO_KEEP_0__ を使用して修正を配信するのを待つのではなく、数日間待つ必要のないアプリ ストアの承認を待つ必要があります。ユーザーはバックグラウンドで更新を受け取り、ネイティブの変更は通常のレビュー パスを通じて実行されます。

コンテキスト:Capgo マーケティング ウェブサイト。役割:サポートする説明文またはメタ ディスクリプション。見つける場所:コンポーネント GetStarted.astro。Capgo の製品/ブランド名と開発者用語をそのまま保存。

マーティンから人間のサポート

Capgo gives you the best insights you need to create a truly professional mobile app.