메뉴로 바로가기

statistic API

GitHub

statistic API

statistic API

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

기본적으로 모든 통계는 우리 서버로 전송됩니다. 사용량을 이해하고 연구하기 위해.

이 데이터를 서버로 보기를 원한다면 아래의 설정을 변경하세요.

// 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" }

__CAPGO_KEEP_0__는 정확히 error . 로깅/디버깅을 위해 사용하는 문자열이므로 code는 아무 문자열이든 될 수 있습니다. 이는 예상되는 동작이며 여전히 HTTP no_new_version_available. 에 반환됩니다. 업데이트 엔드포인트가 message 응답을 반환하고 200가 없을 때, 플러그인은 다운로드 실패로 간주하고 200 상태를 전송합니다. urlCopy to clipboard download_fail The __CAPGO_KEEP_0__ must be exactly __CAPGO_KEEP_0__ . The __CAPGO_KEEP_1__ can be any string you want (it’s only for logging/debugging). This is the expected behavior and it is still returned with HTTP __CAPGO_KEEP_2__ . If your update endpoint instead returns a __CAPGO_KEEP_3__ response without a __CAPGO_KEEP_4__ , the plugin will treat it as a download failure and send a __CAPGO_KEEP_5__ status.

Implementation Example

Implementation 예시

code 자바스크립트 예제입니다. plugin의 stats를 저장하는 예시입니다.

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" }

액션

액션

액션 코드와 그 의미에 대한 자세한 설명은 디버깅 문서를 참조하십시오.

Keep going from Statistics API

Keep going from Statistics API

이러한 기능을 사용 중이라면 Statistics API 대시보드와 API 연산을 계획하고 관리하기 위해 Using @capgo/capacitor-updater 자연스러운 기능을 위해 @capgo/capacitor-업데이터를 사용하세요. API 개요 API 구현 세부 정보를 위해 소개 소개 구현 세부 정보를 위해 API 키 API 키 구현 세부 정보를 위해, 그리고 장치 장치 구현 세부 정보를 위해.