From b3f3d0c3e3d89dfbcdf8d2964d55a8f698b481dd Mon Sep 17 00:00:00 2001 From: "Alexey.Merkulov" Date: Tue, 21 Jan 2025 12:59:41 +0100 Subject: [PATCH] IJPL-171506 Implement trial survey ABT-32 IJ-MR-152914 (cherry picked from commit a5c47204f33b7736eaac962cd9c1b32855f7a25e) (cherry picked from commit bfcf2844796b9bccefa7db3607a8f0cb73517e42) IJ-CR-154529 GitOrigin-RevId: 9f5d59cfc83c084e294704c70fe63374fc783b02 --- .../intellij.platform.experiment.xml | 2 + .../ab/temporary/ShowTrialSurveyOption.kt | 36 +++++++++++ .../resources/messages/IdeBundle.properties | 8 +++ .../survey/IdeSurveyCollector.kt | 19 ++++++ .../welcomeScreen/survey/TrialSurveyUtils.kt | 63 +++++++++++++++++++ .../src/META-INF/PlatformExtensions.xml | 2 + 6 files changed, 130 insertions(+) create mode 100644 platform/experiment/src/com/intellij/platform/experiment/ab/temporary/ShowTrialSurveyOption.kt create mode 100644 platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/IdeSurveyCollector.kt create mode 100644 platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/TrialSurveyUtils.kt diff --git a/platform/experiment/resources/intellij.platform.experiment.xml b/platform/experiment/resources/intellij.platform.experiment.xml index 8230a36c1788..2adfd8f43a2b 100644 --- a/platform/experiment/resources/intellij.platform.experiment.xml +++ b/platform/experiment/resources/intellij.platform.experiment.xml @@ -15,6 +15,8 @@ implementationClass="com.intellij.platform.experiment.ab.impl.statistic.ABExperimentCountCollector"/> + + diff --git a/platform/experiment/src/com/intellij/platform/experiment/ab/temporary/ShowTrialSurveyOption.kt b/platform/experiment/src/com/intellij/platform/experiment/ab/temporary/ShowTrialSurveyOption.kt new file mode 100644 index 000000000000..728a2d6f9610 --- /dev/null +++ b/platform/experiment/src/com/intellij/platform/experiment/ab/temporary/ShowTrialSurveyOption.kt @@ -0,0 +1,36 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.platform.experiment.ab.temporary + +import com.intellij.openapi.application.ApplicationInfo +import com.intellij.platform.experiment.ab.impl.experiment.ABExperiment +import com.intellij.platform.experiment.ab.impl.experiment.ABExperimentOption +import com.intellij.platform.experiment.ab.impl.experiment.ABExperimentOptionId +import com.intellij.platform.experiment.ab.impl.option.ABExperimentOptionGroupSize +import com.intellij.util.PlatformUtils +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Internal +class ShowTrialSurveyOption : ABExperimentOption { + override val id: ABExperimentOptionId = ABExperimentOptionId("showTrialSurvey") + + override fun getGroupSizeForIde(isPopularIde: Boolean): ABExperimentOptionGroupSize { + return ABExperimentOptionGroupSize(128) + } + + override fun checkIdeIsSuitable(): Boolean = PlatformUtils.isIdeaUltimate() + + /** + * Experiment should be available only in 2024.3.3 + */ + override fun checkIdeVersionIsSuitable(): Boolean { + val appInfo = ApplicationInfo.getInstance() + return appInfo.majorVersion == "2024" && appInfo.minorVersion == "3.3" + } + + @Suppress("CompanionObjectInExtension") + companion object { + @JvmStatic + val isTrialSurveyEnabled: Boolean get() = System.getProperty("test.ide.trial.survey", "false").toBoolean() || + ABExperiment.getABExperimentInstance().isExperimentOptionEnabled(ShowTrialSurveyOption::class.java) + } +} diff --git a/platform/platform-api/resources/messages/IdeBundle.properties b/platform/platform-api/resources/messages/IdeBundle.properties index 89f6ae814fef..f49ad58e73fe 100644 --- a/platform/platform-api/resources/messages/IdeBundle.properties +++ b/platform/platform-api/resources/messages/IdeBundle.properties @@ -3144,3 +3144,11 @@ popup.text.non.commercial.usage=Non-commercial use only

With your
  • Switch to a trial or paid license at any time
  • Agreement for non-commercial use\

    Plans and pricing popup.license.button.non.commercial.usage=Manage Licenses\u2026 + + +trial.survey.learn=I want to learn how to use a specific feature, language, or framework +trial.survey.check.for.daily=I am evaluating whether it will be useful for my daily tasks +trial.survey.check.new.features=I am evaluating new features introduced in the latest release +trial.survey.waiting.license=I am waiting for a license from my employer +trial.survey.no.goal=I do not have a specific goal +trial.survey.another.reason=My reason is not listed here diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/IdeSurveyCollector.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/IdeSurveyCollector.kt new file mode 100644 index 000000000000..629dbed6e0ff --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/IdeSurveyCollector.kt @@ -0,0 +1,19 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.wm.impl.welcomeScreen.survey + +import com.intellij.internal.statistic.eventLog.EventLogGroup +import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector + +internal object IdeSurveyCollector : CounterUsagesCollector() { + private val GROUP = EventLogGroup("ide.survey", 1) + + val trialSurveyAnswer = EventFields.Enum("answer") + val answerIndex = EventFields.Int("index") + + private val trialSurveyAnsweredEvent = GROUP.registerEvent("trial.survey.answered", trialSurveyAnswer, answerIndex) + + fun logTrialSurveyAnswered(answer: TrialSurveyOptions, index: Int) = trialSurveyAnsweredEvent.log(answer, index) + + override fun getGroup(): EventLogGroup = GROUP +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/TrialSurveyUtils.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/TrialSurveyUtils.kt new file mode 100644 index 000000000000..8775ba99acb3 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/survey/TrialSurveyUtils.kt @@ -0,0 +1,63 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.wm.impl.welcomeScreen.survey + +import com.intellij.ide.IdeBundle +import com.intellij.openapi.ui.DialogPanel +import com.intellij.openapi.util.NlsContexts +import com.intellij.ui.dsl.builder.TopGap +import com.intellij.ui.dsl.builder.bind +import com.intellij.ui.dsl.builder.panel +import com.intellij.util.ui.JBInsets +import com.intellij.util.ui.JBUI +import org.jetbrains.annotations.ApiStatus +import javax.swing.JButton +import javax.swing.JComponent + +internal enum class TrialSurveyOptions(@NlsContexts.RadioButton val text: String) { + Unselected(""), + Learn(IdeBundle.message("trial.survey.learn")), + CheckForDaily(IdeBundle.message("trial.survey.check.for.daily")), + CheckNewFeatures(IdeBundle.message("trial.survey.check.new.features")), + WaitingLicense(IdeBundle.message("trial.survey.waiting.license")), + NoGoal(IdeBundle.message("trial.survey.no.goal")), + AnotherReason(IdeBundle.message("trial.survey.another.reason")), +} + +@ApiStatus.Internal +fun trialSurveyPanel(createButtonsPanel: (JButton) -> JComponent, activateTrialButtonFn: (() -> Unit) -> JButton): DialogPanel { + var chosenOption: Pair = TrialSurveyOptions.Unselected to -1 + + lateinit var panel: DialogPanel + + val activateTrialButton = activateTrialButtonFn { + reportSurveyAnswer(chosenOption) + panel.apply() + } + //LicenseDialogComponents.adjustStartTrialButtonText(model, activateTrialButton) + activateTrialButton.isEnabled = false + + val options = (TrialSurveyOptions.entries - TrialSurveyOptions.Unselected - TrialSurveyOptions.AnotherReason).shuffled() + + TrialSurveyOptions.AnotherReason + panel = panel { + buttonsGroup { + for ((index, value) in options.withIndex()) { + row { + val option = value to index + radioButton(value.text, option).onChanged { activateTrialButton.isEnabled = true } + } + } + }.bind({ chosenOption }, { chosenOption = it }) + + row { + cell(createButtonsPanel(activateTrialButton)) + }.topGap(TopGap.MEDIUM) + } + + panel.border = JBUI.Borders.empty(JBInsets(0, 36, 0, 36)) + return panel +} + +private fun reportSurveyAnswer(chosenOption: Pair) { + val (value, order) = chosenOption + IdeSurveyCollector.logTrialSurveyAnswered(value, order) +} diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 088969aa559c..c0777872860b 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -631,6 +631,8 @@ +