diff --git a/platform/tips-of-the-day/intellij.platform.tips.iml b/platform/tips-of-the-day/intellij.platform.tips.iml index b46f1b17fa10..3be5bb0b72eb 100644 --- a/platform/tips-of-the-day/intellij.platform.tips.iml +++ b/platform/tips-of-the-day/intellij.platform.tips.iml @@ -40,6 +40,7 @@ + \ No newline at end of file diff --git a/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt b/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt index bdcdd19c9e8b..b5e54cc824ff 100644 --- a/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt +++ b/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt @@ -9,12 +9,18 @@ import com.intellij.platform.feedback.impl.FeedbackRequestData import com.intellij.platform.feedback.impl.FeedbackRequestType import com.intellij.platform.feedback.impl.submitFeedback import com.intellij.util.xmlb.annotations.XMap +import kotlinx.datetime.Clock +import kotlinx.datetime.TimeZone +import kotlinx.datetime.periodUntil +import kotlinx.datetime.toKotlinInstant import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put @Service @State(name = "TipsFeedback", storages = [Storage(value = "tips-feedback.xml", roamingType = RoamingType.DISABLED)]) class TipsFeedback : SimplePersistentStateComponent(State()) { + private val timeScopeForResultCollectionInDays = 120 + fun getLikenessState(tipId: String): Boolean? { return state.tipToLikeness[tipId] } @@ -35,6 +41,12 @@ class TipsFeedback : SimplePersistentStateComponent(State()) } fun scheduleFeedbackSending(tipId: String, likenessState: Boolean) { + val buildDate = ApplicationInfo.getInstance().buildDate + val buildToCurrentPeriod = buildDate.toInstant().toKotlinInstant().periodUntil(Clock.System.now(), TimeZone.currentSystemDefault()) + if (buildToCurrentPeriod.days > timeScopeForResultCollectionInDays) { + return + } + val dataJsonObject = buildJsonObject { put("format_version", FEEDBACK_FORMAT_VERSION) put("tip_id", tipId)