From 0fe57a189f9d719a3176a79ff8efebd93f92df1c Mon Sep 17 00:00:00 2001 From: Aydar Mukhametzyanov Date: Tue, 21 Jul 2026 10:54:23 +0200 Subject: [PATCH] [platform ui] IJPL-250522 Don't report the event on non-macOS machines (cherry picked from commit d25703768046ea3715c4c78b187f19c5f9d6eab6) (cherry picked from commit b9d098c63b582c85f8adc61880c1a5b9ee007789) IJ-MR-214629 GitOrigin-RevId: 50a5369971ba03038c7b9db4c0cd265f09282600 --- .../collectors/fus/os/SystemRuntimeCollector.kt | 4 +++- .../collectors/fus/os/SystemRuntimeCollectorTest.kt | 9 +++++++-- .../util/src/com/intellij/util/system/MacHardwareInfo.kt | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/internal/src/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollector.kt b/platform/platform-impl/internal/src/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollector.kt index f31f3f4a8254..02bedf231bf3 100644 --- a/platform/platform-impl/internal/src/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollector.kt +++ b/platform/platform-impl/internal/src/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollector.kt @@ -110,7 +110,9 @@ class SystemRuntimeCollector : ApplicationUsagesCollector() { result += OS_VM.metric(getOsVirtualization()) - result += MACBOOK_NEO.metric(MacHardwareInfo.isMacbookNeo) + MacHardwareInfo.isMacbookNeo?.let { + result += MACBOOK_NEO.metric(it) + } return result } diff --git a/platform/platform-tests/testSrc/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollectorTest.kt b/platform/platform-tests/testSrc/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollectorTest.kt index 629b90bfd2c1..14daa4c8354f 100644 --- a/platform/platform-tests/testSrc/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollectorTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/internal/statistic/collectors/fus/os/SystemRuntimeCollectorTest.kt @@ -3,10 +3,13 @@ package com.intellij.internal.statistic.collectors.fus.os import com.intellij.ReviseWhenPortedToJDK import com.intellij.testFramework.fixtures.BareTestFixtureTestCase +import com.intellij.util.system.LowLevelLocalMachineAccess +import com.intellij.util.system.OS import org.assertj.core.api.Assertions.assertThat import org.junit.Test class SystemRuntimeCollectorTest : BareTestFixtureTestCase() { + @OptIn(LowLevelLocalMachineAccess::class) @Test fun smoke() { val metrics = SystemRuntimeCollector().getMetrics().map { it.eventId to it.data.build() } @@ -35,7 +38,9 @@ class SystemRuntimeCollectorTest : BareTestFixtureTestCase() { assertThat(osVm["name"]).isNotNull.isNotIn("other", "unknown") } - val neo = metric("hardware.macbook.neo") - assertThat(neo["value"]).isIn(true, false) + if (OS.CURRENT == OS.macOS) { + val neo = metric("hardware.macbook.neo") + assertThat(neo["value"]).isIn(true, false) + } } } diff --git a/platform/util/src/com/intellij/util/system/MacHardwareInfo.kt b/platform/util/src/com/intellij/util/system/MacHardwareInfo.kt index ab56e1a1dcc1..cd70e4870591 100644 --- a/platform/util/src/com/intellij/util/system/MacHardwareInfo.kt +++ b/platform/util/src/com/intellij/util/system/MacHardwareInfo.kt @@ -18,8 +18,8 @@ import org.jetbrains.annotations.ApiStatus object MacHardwareInfo { private const val MACBOOK_NEO_MODEL_ID = "Mac17,5" - /** `true` when running on a MacBook Neo (`hw.model` == `Mac17,5`); `false` on any other machine or OS. */ - val isMacbookNeo: Boolean by lazy { modelIdentifier == MACBOOK_NEO_MODEL_ID } + /** `true` when running on a MacBook Neo (`hw.model` == `Mac17,5`); `null` on non-macOS machines. */ + val isMacbookNeo: Boolean? by lazy { modelIdentifier?.let { it == MACBOOK_NEO_MODEL_ID } } /** Hardware model identifier on macOS, e.g. `Mac17,5` or `MacBookPro14,3`; `null` on other OSes or when unavailable. */ private val modelIdentifier: String? by lazy {