[kotlin] Prolonged the K2 mode Feedback form and show it only to K1 switchers

^KTIJ-33261 fixed

GitOrigin-RevId: d7c1e643ff85db066f45db856eaa06d487e50e90
This commit is contained in:
Frederik Haselmeier
2025-02-27 01:26:26 +00:00
committed by intellij-monorepo-bot
parent c739298b65
commit e626f95ec0
3 changed files with 4 additions and 29 deletions
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.onboarding.FeedbackNotificationWithKotlinLogo
class K2FeedbackSurveyConfig : InIdeFeedbackSurveyConfig {
override val surveyId: String = "k2_feedback"
override val lastDayOfFeedbackCollection: LocalDate = LocalDate(2025, 4, 1)
override val lastDayOfFeedbackCollection: LocalDate = LocalDate(2026, 1, 1)
override val requireIdeEAP: Boolean = false
private val suitableIdeVersion: String = Registry.stringValue("k2.feedback.survey.ide.version.number")
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginModeProvider
import org.jetbrains.kotlin.idea.base.util.containsNonScriptKotlinFile
import org.jetbrains.kotlin.idea.base.util.runReadActionInSmartMode
import java.time.Duration
import java.time.Instant
internal const val K2_SINCE_NOT_DEFINED = -1L
@@ -99,30 +98,6 @@ class K2UserTracker : PersistentStateComponent<K2UserTrackerState> {
}
if (!projectContainsNonScriptKotlinFile) return false
if (switchedToK1) {
return true
} else {
val k2Chosen = if (forUnitTests) {
k2PluginModeForTests
} else {
KotlinPluginModeProvider.currentPluginMode == KotlinPluginMode.K2
}
if (!k2Chosen) {
LOG.debug("Not showing the K2 feedback dialog because the user doesn't use K2")
return false
} else {
// The following condition is needed if a user had always been on K2 even before the survey started
if (state.k2UserSince == K2_SINCE_NOT_DEFINED) {
state.k2UserSince = Instant.now().epochSecond
}
val k2UserSince = Instant.ofEpochSecond(state.k2UserSince) // k2UserSince might be initialized here on the first access
val durationSinceK2User = Duration.between(k2UserSince, Instant.now())
LOG.debug("Duration since user became a K2 Kotlin user: ${durationSinceK2User.toDays()} day(s)")
return durationSinceK2User > Duration.ofSeconds(
Registry.intValue("minimum.usage.time.before.showing.k2.survey").toLong()
)
}
}
return switchedToK1
}
}
@@ -61,7 +61,7 @@ class K2UserTrackerTest: LightJavaCodeInsightFixtureTestCase() {
assertFalse(instance.state.userSawSurvey)
}
fun `test show dialog if more than one day on K2`() {
fun `test do not show dialog if more than one day on K2 and still on K2`() {
val instance = createInstance()
instance.state.k2UserSince = Instant.now().epochSecond.minus(346000) // They've been on K2 for 4+ days 4 * 24 * 60 * 60 + 400
instance.state.lastSavedPluginMode = PluginModes.K2.value
@@ -69,6 +69,6 @@ class K2UserTrackerTest: LightJavaCodeInsightFixtureTestCase() {
assertFalse(instance.state.userSawSurvey)
assertTrue(instance.shouldShowK2FeedbackDialog(project))
assertFalse(instance.shouldShowK2FeedbackDialog(project))
}
}