统计 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,}您也可以完全禁用它,使用一个空字符串。请记住,统计数据是私有的,帮助我了解人们如何使用插件,解决问题并改进它。
预期“无更新”行为
Section titled “预期“无更新”行为”当您的更新端点有 没有新版本,它应该以错误负载响应:
{ "error": "no_new_version_available", "message": "No new version available" }The error code必须完全相同 no_new_version_available。您可以输入任何字符串(它仅用于日志/调试)。这是预期的行为,它仍然会以 HTTP message 如果您的更新端点返回一个 200响应而没有 200 ,则插件将将其视为下载失败并发送一个 url统计。 download_fail 实现示例
这里是 JavaScript 中的 __CAPGO_KEEP_0__ 的示例,用于保存插件的统计数据:
复制到剪贴板Here is an example of code in JavaScript to save the stats of the plugin:
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' }}Implementation Example
{ "status": "ok" }操作
操作有关所有动作代码及其含义的详细描述,请参见调试文档:
- 设备发送的操作: 参见 调试文档 - 由设备发送 部分
- 后端发送的操作: 参见 调试文档 - 由后端发送 部分
Keep going from Statistics API
Section titled “Keep going from Statistics API”如果您正在使用 Statistics API 来规划仪表板和API操作,连接它到 使用@capgo/capacitor-updater 使用@capgo/capacitor-updater的本地能力 API概述 API概述的实现细节 介绍 介绍的实现细节 API密钥 对于在API Keys中实现的细节 设备 设备