Statistics API
Statistics API
Starting from version 1.3.0 the update system is able to send stats!
By default, all stats are sent to our server, to understand usage and research.
If you want to send this data to your server instead, change the config below:
// capacitor.config.json{ "appId": "**.***.**", "appName": "Name", "plugins": { "CapacitorUpdater": { "statsUrl": "YOUR_URL" } }}Data Structure
What your server will receive is:
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 "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,}You can also totally disable it, with an empty string. Keep in mind, statistics are made private friendly and help me to understand how people use the plugin, to resolve issues and improve it.
Implementation Example
Here is an example of code in JavaScript to save the stats of the plugin:
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' | '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' | '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' }}This endpoint should return a JSON:
{ "status": "ok" }Actions
Sent from the device
- ping: Internal test action used to verify the stats system is working correctly
- get: Info for downloading the new version has been sent to the device
- delete: When a bundle is deleted locally
- reset: When the app reset to the built-in bundle
- set: When app sets a new bundle
- set_fail: When app couldnβt find the ID of the bundle set
- update_fail: Send after the delay and
notifyAppReadynever called - download_fail: When download never finished
- download_complete: When download finish
- download_xx: Send every 10% of download ex: download_10, download_20, download_70
- windows_path_fail: The zip has files who contain windows path who are illegal
- canonical_path_fail: The path of files is not canonical
- directory_path_fail: There is an error in the path of zip files
- unzip_fail: Unzip failed
- low_mem_fail: Download failed because of low memory in the device
- decrypt_fail: Failed to decrypt the downloaded bundle
- checksum_fail: The new bundle failed to validate the checksum
- app_moved_to_foreground: The application entered the foreground state
- app_moved_to_background: The application entered the background state
- getChannel: The current channel for the device was queried
- setChannel: A channel was successfully set for the device
- uninstall: The application was uninstalled or Capgo data cleared
- blocked_by_server_url: The update was blocked by the server URL configuration
Sent from the backend
- InvalidIp: The user is located in a Google data center and the update is less than 4 hours old
- needPlanUpgrade: Indicates that you have reached the limit of your plan
- noNew: The device has the latest available version
- disablePlatformIos: The device is on the iOS platform, but that is disabled in the channel settings
- disablePlatformAndroid: The device is on the Android platform, but that is disabled in the channel settings
- disableAutoUpdate: Automatic updates are disabled in channel settings
- disableAutoUpdateUnderNative: The device has version that is higher than the channel update version
- disableAutoUpdateToMajor: Automatic updates to major versions are disabled in channel settings
- disableAutoUpdateToMinor: Automatic updates to minor versions are disabled in channel settings
- disableAutoUpdateToPatch: Automatic updates to patch versions are disabled in channel settings
- disableDevBuild: The device has a dev build, but that is disabled in the channel settings
- disableEmulator: The device is an emulator, but that is disabled in the channel settings
- disableAutoUpdateMetadata: Automatic updates based on metadata changes are disabled
- cannotGetBundle: An error occurred while trying to retrieve the bundle information
- cannotUpdateViaPrivateChannel: Device attempted an update via a private channel it doesnβt have access to
- channelMisconfigured: The channel configuration is invalid or incomplete
- missingBundle: The requested bundle was not found on the server
- NoChannelOrOverride: No channel is set for the device and no override is provided
- rateLimited: The device has been rate limited due to excessive requests