본문 바로가기

API 통계

GitHub

1.3.0 버전부터 업데이트 시스템에서 통계 데이터를 전송할 수 있습니다!

기본적으로 사용 현황 파악 및 연구를 위해 모든 통계 데이터가 Capgo 서버로 전송됩니다.

이 데이터를 자체 서버로 전송하려면 아래 설정을 변경하세요:

// capacitor.config.json
{
"appId": "**.***.**",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"statsUrl": "YOUR_URL"
}
}
}

서버가 받게 될 데이터는 다음과 같습니다:

interface AppInfosStats {
"action": "set", // can be set, delete, set_fail, reset, revert
// Then it's the same info as update
"app_id": "**.***.**", // app identifier in the store
"device_id": "*******", // unique id per app install
"platform": "ios", // or android, or electron
"custom_id": "user_1", // represent your user
"version_name": "1.2.3", // version of the web build
"version_build": "1.2.0", // version of the native build
"version_code": "120", // build number of the native build
"version_os": "16", // OS version of the device
"plugin_version": "4.0.0"// to make your api behave differently with different plugins
"is_emulator": false,
"is_prod": false,
}

빈 문자열로 완전히 비활성화할 수도 있습니다. 통계는 개인정보를 보호하는 방식으로 수집되며, 제가 플러그인 사용 현황을 파악해 문제를 해결하고 개선하는 데 도움이 됩니다.

예상되는 “업데이트 없음” 동작

“예상되는 ‘업데이트 없음’ 동작” 섹션

업데이트 엔드포인트에 새 버전이 없을 때, 다음과 같은 에러 페이로드를 응답해야 합니다:

{ "error": "no_new_version_available", "message": "No new version available" }

이 error code는 반드시 no_new_version_available. message 원하는 문자열로 지정할 수 있습니다(로깅/디버깅 용도). 이는 정상적인 동작이며 HTTP 응답과 함께 반환됩니다. 200만약 업데이트 엔드포인트에서 200 응답을 반환할 때 url가 포함되어 있지 않으면, 플러그인은 이를 다운로드 실패로 간주하고 download_fail 통계를 전송합니다.

플러그인 통계를 저장하기 위한 JavaScript code 예시입니다:

interface AppInfos {
version_name: string
action: 'delete' |
'reset' |
'set' |
'get' |
'set_fail' |
'update_fail' |
'download_fail' |
'windows_path_fail' |
'canonical_path_fail' |
'directory_path_fail' |
'unzip_fail' |
'low_mem_fail' |
'download_10' |
'download_20' |
'download_30' |
'download_40' |
'download_50' |
'download_60' |
'download_70' |
'download_80' |
'download_90' |
'download_complete' |
'decrypt_fail' |
'app_moved_to_foreground' |
'app_moved_to_background' |
'uninstall' |
'needPlanUpgrade' |
'missingBundle' |
'noNew' |
'disablePlatformIos' |
'disablePlatformAndroid' |
'disableAutoUpdateToMajor' |
'cannotUpdateViaPrivateChannel' |
'disableAutoUpdateToMinor' |
'disableAutoUpdateToPatch' |
'channelMisconfigured' |
'disableAutoUpdateMetadata' |
'disableAutoUpdateUnderNative' |
'disableDevBuild' |
'disableEmulator' |
'disablePlatformElectron' |
'disableProdBuild' |
'disableDevice' |
'customIdBlocked' |
'cannotGetBundle' |
'checksum_fail' |
'checksum_required' |
'NoChannelOrOverride' |
'setChannel' |
'getChannel' |
'rateLimited' |
'disableAutoUpdate' |
'keyMismatch' |
'ping' |
'InvalidIp' |
'blocked_by_server_url' |
'download_manifest_start' |
'download_manifest_complete' |
'download_zip_start' |
'download_zip_complete' |
'download_manifest_file_fail' |
'download_manifest_checksum_fail' |
'download_manifest_brotli_fail' |
'backend_refusal' |
'app_crash' |
'app_crash_native' |
'app_anr' |
'app_killed_low_memory' |
'app_killed_excessive_resource_usage' |
'app_initialization_failure' |
'app_memory_warning' |
'webview_javascript_error' |
'webview_unhandled_rejection' |
'webview_resource_error' |
'webview_security_policy_violation' |
'webview_unclean_restart' |
'webview_render_process_gone' |
'webview_content_process_terminated' |
'os_version_changed' |
'native_app_version_changed' |
'download_0'
version_build: string
version_code: string
version_os: string
plugin_version: string
platform: string
app_id: string
device_id: string
custom_id?: string
is_prod?: boolean
is_emulator?: boolean
}
export const handler: Handler = async (event) => {
const body = JSON.parse(event.body || '{}') as AppInfos
const {
platform,
app_id,
action,
version_code,
version_os,
device_id,
version_name,
version_build,
plugin_version,
} = body
console.log('update asked', platform,
app_id,
action,
version_os,
version_code,
device_id,
version_name,
version_build,
plugin_version)
// Save it in your database
return { status: 'ok' }
}

이 엔드포인트는 다음 JSON을 반환해야 합니다:

{ "status": "ok" }

모든 액션 코드와 그 의미에 대한 자세한 설명은 다음 디버깅 문서를 참조하세요:

통계 API에서 계속하기

“통계 API에서 계속하기” 섹션

사용 중이라면 통계 API 대시보드 및 API 운영을 계획하려면, 이를 다음과 연결하세요 @capgo/capacitor-updater 사용하기 네이티브 기능의 경우 @capgo/capacitor-updater 사용하기에서, API 개요 구현 세부 사항은 API 개요에서 소개 구현 세부 사항은 소개에서 API 키 API Keys의 구현 세부 사항은, 기기 Devices의 구현 세부 사항은.