기능 플래그 및 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 키로 이동합니다.
- 새 키를 생성하기 위해 'Generate New Key'를 클릭합니다.
- 선택
all__CAPGO_KEEP_0__을 관리하는 장치 및 채널을 관리하는 모드 - __CAPGO_KEEP_0__에서 생성된 키를 복사하고 안전하게 백엔드 환경 변수에 저장하세요
- 키는 32자리 16진수 문자열입니다
- 클라이언트 측 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. 자체 할당(보안이 낮음)
이 방법은 장치가 직접 채널에 할당할 수 있지만 테스트에 유용하지만 프로덕션에는 보안이 낮습니다.
__CAPGO_KEEP_0__
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 대시보드의 채널 섹션으로 이동하세요
- 관리하고 싶은 채널 이름을 클릭하세요
- 채널 설정에서 '기기 자체 연관 허용'을 활성화하세요
- 변경 사항을 저장하세요
이 설정이 거짓일 경우, 이 채널을 호출하는 모든 시도는 실패합니다. 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
}
사용자 할당을 통한 A/B 테스트를 실행하세요:
- 채널 assignments 사용하기: 실제 운영 환경에서는 항상 백엔드 assignments 방법을 사용하세요
- 일관된 assignments: 사용자 ID나 다른 안정적인 식별자로 일관된 채널 assignments를 사용하세요
- 모니터링: 각 채널의 기능 사용률과 성능 지표를 추적하세요
- 격차 없는 출시: 작은 사용자 그룹부터 시작하여 점진적으로 확장하세요
- 명확한 문서화: 채널 전략과 목적을 문서화하세요
결론
By leveraging Capgo’s channel system, you can create more personalized app experiences and run A/B tests. For production use, always prefer the backend assignment method for better security and control.
__CAPGO_KEEP_0__ __CAPGO_KEEP_1__.
__CAPGO_KEEP_2__
__CAPGO_KEEP_3__ __CAPGO_KEEP_4__ __CAPGO_KEEP_5__ __CAPGO_KEEP_6__ __CAPGO_KEEP_7__ __CAPGO_KEEP_8__ __CAPGO_KEEP_9__ __CAPGO_KEEP_10__ __CAPGO_KEEP_11__ Beta 테스트 솔루션 __CAPGO_KEEP_0__ 버전 대상 솔루션 __CAPGO_KEEP_0__