API の統計情報
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
API の統計情報
「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" }この 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" }アクション
「Actions」セクションすべてのアクションコードとその意味の詳細については、デバッグドキュメントを参照してください:
- デバイスから送信されたアクション: 次を参照: デバッグドキュメント - デバイスから送信 セクション
- バックエンドから送信されたアクション: 次を参照: デバッグ用ドキュメント - バックエンドより送信 セクション
統計情報 API から次へ
「統計情報 API から次へ」というタイトルのセクション使用している場合 API の統計情報 ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-updater を使用する 「@capgo/capacitor-updater を使用する」のネイティブ機能については、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。