diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e105f53..e7314f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ MongoDB plugin for IntelliJ IDEA. ## [Unreleased] ### Added +* [INTELLIJ-11](https://jira.mongodb.org/browse/INTELLIJ-11): Flush pending analytics events before closing the IDE. ### Changed diff --git a/packages/jetbrains-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/TelemetryService.kt b/packages/jetbrains-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/TelemetryService.kt index 205d560f..b6b5ba62 100644 --- a/packages/jetbrains-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/TelemetryService.kt +++ b/packages/jetbrains-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/TelemetryService.kt @@ -24,12 +24,12 @@ internal class TelemetryService : AppLifecycleListener { init { ApplicationManager.getApplication() -.messageBus -.connect() -.subscribe( - AppLifecycleListener.TOPIC, - this - ) + .messageBus + .connect() + .subscribe( + AppLifecycleListener.TOPIC, + this + ) } fun sendEvent(event: TelemetryEvent) { diff --git a/packages/jetbrains-plugin/src/test/kotlin/com/mongodb/jbplugin/fixtures/IntegrationTestExtensions.kt b/packages/jetbrains-plugin/src/test/kotlin/com/mongodb/jbplugin/fixtures/IntegrationTestExtensions.kt index 5133293d..4f3eefb9 100644 --- a/packages/jetbrains-plugin/src/test/kotlin/com/mongodb/jbplugin/fixtures/IntegrationTestExtensions.kt +++ b/packages/jetbrains-plugin/src/test/kotlin/com/mongodb/jbplugin/fixtures/IntegrationTestExtensions.kt @@ -100,7 +100,7 @@ inline fun S.withMockedService(service * * ```kt * val myInfoService = mockRuntimeInformationService(userId = "hey") - * val myProject = mockProject(runtimeInformationService = myInfoService) + * project.withMockedService(myInfoService) * ``` * * @param userId @@ -120,8 +120,7 @@ internal fun mockRuntimeInformationService( jvmVersion: String = "42", buildVersion: String = "2024.2", applicationName: String = "Cool IDE" -): RuntimeInformationService = org.mockito.kotlin.mock() -.also { service -> +) = mock().also { service -> `when`(service.get()).thenReturn( RuntimeInformation( userId = userId, @@ -142,13 +141,12 @@ internal fun mockRuntimeInformationService( * * ```kt * val myLogMessage = mockLogMessage() - * val myProject = mockProject(logMessage = myLogMessage) + * project.withMockedService(myLogMessage) * ``` * * @return A new mocked LogMessage */ -internal fun mockLogMessage(): LogMessage = org.mockito.kotlin.mock() -.also { logMessage -> +internal fun mockLogMessage() = mock().also { logMessage -> `when`(logMessage.message(any())).then { message -> LogMessageBuilder(Gson(), message.arguments[0].toString()) }