// Battery voltage has millivolt precision.
MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(battery_v, kMemfaultMetricType_Unsigned, 1000)

// libc heap usage
MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(memory_pct_max, kMemfaultMetricType_Unsigned, 100)

#include "ports/freertos/config/memfault_metrics_heartbeat_freertos_config.def"

// LSM6DSO accelerometer diagnostics
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_last_x_mg, kMemfaultMetricType_Signed)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_last_y_mg, kMemfaultMetricType_Signed)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_last_z_mg, kMemfaultMetricType_Signed)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_sample_age_ms, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_read_age_ms, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_interrupt_age_ms, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_wake_age_ms, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_double_tap_age_ms, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_state_flags, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_i2c_error_count, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_consecutive_errors, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_interrupt_count, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_wake_events, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(accel_lsm6dso_double_tap_events, kMemfaultMetricType_Unsigned)

// Number of times that the user has pressed the back button, and it would
// have caused a force quit but we realized that the KernelMain task had
// just gone out to lunch and the user didn't ask for that at all
// (FIRM-425).
MEMFAULT_METRICS_KEY_DEFINE(firm_425_back_button_long_presses_cancelled, kMemfaultMetricType_Unsigned)

// AppMessage metrics
MEMFAULT_METRICS_KEY_DEFINE(app_message_sent_count, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(app_message_received_count, kMemfaultMetricType_Unsigned)

///// Curated Pebble Analytics Metrics (~70 total) /////

// System Health & Stability
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SYSTEM_CRASH_CODE, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SYSTEM_CRASH_LR, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_DEVICE_UP_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_KERNEL_HEAP_MIN_HEADROOM_BYTES, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_STACK_FREE_KERNEL_MAIN, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_STACK_FREE_KERNEL_BACKGROUND, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_STACK_FREE_NEWTIMERS, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_PFS_SPACE_FREE_KB, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_CRASHED_COUNT, kMemfaultMetricType_Unsigned)

// Battery & Power
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BATTERY_PERCENT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BATTERY_VOLTAGE_DELTA, kMemfaultMetricType_Signed)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BATTERY_PERCENT_DELTA, kMemfaultMetricType_Signed)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BATTERY_CHARGE_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BATTERY_PLUGGED_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_CPU_RUNNING_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_CPU_STOP_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_CPU_SLEEP_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BACKLIGHT_ON_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BACKLIGHT_ON_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_VIBRATOR_ON_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_VIBRATOR_ON_COUNT, kMemfaultMetricType_Unsigned)

// User Interaction
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_BUTTON_PRESSED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_STATIONARY_TIME_MINUTES, kMemfaultMetricType_Unsigned)

// Accelerometer Health & Activity
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_SAMPLE_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_RESET_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_FIFO_OVERRUN_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_SHAKE_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_DOUBLE_TAP_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_PEEK_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ACCEL_XYZ_DELTA, kMemfaultMetricType_Unsigned)

// Hardware I/O Health
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_I2C_ERROR_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_I2C_MAX_TRANSFER_DURATION_TICKS, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_FLASH_READ_BYTES_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_FLASH_WRITE_BYTES_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_FLASH_ERASE_COUNT, kMemfaultMetricType_Unsigned)

// Phone Call Handling
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_PHONE_CALL_INCOMING_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_PHONE_CALL_TIME, kMemfaultMetricType_Unsigned)

// Notifications
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_RECEIVED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_RECEIVED_DND_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_DISMISSED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_CLOSED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_BYTE_IN_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_PARSE_ERROR_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_NOTIFICATION_ANCS_SMS_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_REMINDER_RECEIVED_COUNT, kMemfaultMetricType_Unsigned)

// App Usage
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_ROCKY_LAUNCH_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_ROCKY_CRASHED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_USER_LAUNCH_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_QUICK_LAUNCH_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_THROTTLED_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_APP_NOTIFIED_DISCONNECTED_COUNT, kMemfaultMetricType_Unsigned)

// User Preferences
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SETTING_BACKLIGHT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SETTING_SHAKE_TO_LIGHT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SETTING_BACKLIGHT_INTENSITY_PCT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SETTING_BACKLIGHT_TIMEOUT_SEC, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_SETTING_VIBRATION_STRENGTH, kMemfaultMetricType_Unsigned)

// Display & UI
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_WATCH_ONLY_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_DISPLAY_UPDATES_PER_HOUR, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_FPGA_REPROGRAM_COUNT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_STRING_KEY_DEFINE(active_watchface_name, 96)

// Watchface usage metrics (per-watchface, tracked for current/default watchface)
MEMFAULT_METRICS_KEY_DEFINE(watchface_total_time_secs, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(watchface_launch_count, kMemfaultMetricType_Unsigned)

// Health/HRM
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_HRM_ACCEL_DATA_MISSING, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_HRM_ON_TIME, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_HRM_WATCHDOG_TIMEOUT, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(ANALYTICS_DEVICE_METRIC_ALARM_SOUNDED_COUNT, kMemfaultMetricType_Unsigned)
