Statistik API
Statistik API
Section titled “Statistik API”Ab Version 1.3.0 kann das Update-System Statistiken senden!
Standardmäßig werden alle Statistiken an unseren Server gesendet, um die Nutzung und Forschung zu verstehen.
Wenn Sie diese Daten stattdessen an Ihren Server senden möchten, ändern Sie die Konfiguration unten:
// capacitor.config.json{ "appId": "**.***.**", "appName": "Name", "plugins": { "CapacitorUpdater": { "statsUrl": "YOUR_URL" } }}Datenstruktur
Section titled “Datenstruktur”Was Ihr Server erhält, ist:
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,}Sie können es auch mit einer leeren Zeichenfolge vollständig deaktivieren. Bedenken Sie, dass Statistiken privatfreundlich gestaltet sind und mir helfen, zu verstehen, wie die Leute das Plugin nutzen, um Probleme zu lösen und es zu verbessern.
Erwartetes „Kein Update“-Verhalten
Section titled “Erwartetes „Kein Update“-Verhalten”Wenn Ihr Update-Endpunkt keine neue Version hat, sollte er mit einer Fehlernutzlast wie der folgenden antworten:
{ "error": "no_new_version_available", "message": "No new version available" }Der Code error muss genau no_new_version_available sein. Der message kann eine beliebige Zeichenfolge sein (nur für Protokollierung/Debugging). Dies ist das erwartete Verhalten und wird weiterhin mit HTTP 200 zurückgegeben. Wenn Ihr Update-Endpunkt stattdessen eine 200-Antwort ohne url zurückgibt, behandelt das Plugin dies als Download-Fehler und sendet eine download_fail-Statistik.
Implementierungsbeispiel
Section titled “Implementierungsbeispiel”Hier ist ein Beispiel für Code in JavaScript zum Speichern der Statistiken des Plugins:
interface AppInfos { version_name: string action: 'ping' | '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' | 'download_manifest_start' | 'download_manifest_complete' | 'download_zip_start' | 'download_zip_complete' | 'download_manifest_file_fail' | 'download_manifest_checksum_fail' | 'download_manifest_brotli_fail' | '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' | 'cannotGetBundle' | 'checksum_fail' | 'NoChannelOrOverride' | 'setChannel' | 'getChannel' | 'rateLimited' | 'disableAutoUpdate' | 'InvalidIp' | 'keyMismatch' | 'blocked_by_server_url' 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' }}Dieser Endpunkt sollte einen JSON zurückgeben:
{ "status": "ok" }Aktionen
Section titled “Aktionen”Detaillierte Beschreibungen aller Aktionscodes und ihrer Bedeutung finden Sie in der Debugging-Dokumentation:
- Vom Gerät gesendete Aktionen: Siehe Abschnitt Debug-Dokumentation – Vom Gerät gesendet.
- Vom Backend gesendete Aktionen: Siehe Abschnitt Debug-Dokumentation – Vom Backend gesendet.