-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/INTELLIJ-172-spr…
…ing-match
- Loading branch information
Showing
5 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...gin/src/main/kotlin/com/mongodb/jbplugin/observability/probe/CreateIndexIntentionProbe.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.mongodb.jbplugin.observability.probe | ||
|
||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.openapi.diagnostic.logger | ||
import com.intellij.psi.PsiElement | ||
import com.mongodb.jbplugin.meta.service | ||
import com.mongodb.jbplugin.mql.Node | ||
import com.mongodb.jbplugin.mql.components.HasSourceDialect | ||
import com.mongodb.jbplugin.observability.TelemetryEvent | ||
import com.mongodb.jbplugin.observability.TelemetryService | ||
import com.mongodb.jbplugin.observability.useLogMessage | ||
|
||
private val logger: Logger = logger<CreateIndexIntentionProbe>() | ||
|
||
/** | ||
* This probe is emitted when the user clicks on the Create Index | ||
* intention. | ||
*/ | ||
@Service | ||
class CreateIndexIntentionProbe { | ||
fun intentionClicked(query: Node<PsiElement>) { | ||
val telemetry by service<TelemetryService>() | ||
|
||
var dialect = query.component<HasSourceDialect>() ?: return | ||
val event = TelemetryEvent.CreateIndexIntentionEvent(dialect.name) | ||
telemetry.sendEvent(event) | ||
|
||
logger.info( | ||
useLogMessage("Create index quick action clicked.") | ||
.mergeTelemetryEventProperties(event) | ||
.build() | ||
) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...src/test/kotlin/com/mongodb/jbplugin/observability/probe/CreateIndexIntentionProbeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mongodb.jbplugin.observability.probe | ||
|
||
import com.intellij.openapi.application.Application | ||
import com.intellij.psi.PsiElement | ||
import com.mongodb.jbplugin.fixtures.IntegrationTest | ||
import com.mongodb.jbplugin.fixtures.mockLogMessage | ||
import com.mongodb.jbplugin.fixtures.withMockedService | ||
import com.mongodb.jbplugin.mql.Node | ||
import com.mongodb.jbplugin.mql.components.HasSourceDialect | ||
import com.mongodb.jbplugin.observability.TelemetryEvent | ||
import com.mongodb.jbplugin.observability.TelemetryService | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.verify | ||
|
||
@IntegrationTest | ||
internal class CreateIndexIntentionProbeTest { | ||
@Test | ||
fun `should send a CreateIndexIntentionEvent event`(application: Application) { | ||
val telemetryService = mock<TelemetryService>() | ||
val dialect = HasSourceDialect.DialectName.entries.toTypedArray().random() | ||
|
||
val query = Node<PsiElement?>(null, listOf(HasSourceDialect(dialect))) as Node<PsiElement> | ||
|
||
application.withMockedService(telemetryService) | ||
.withMockedService(mockLogMessage()) | ||
|
||
val probe = CreateIndexIntentionProbe() | ||
|
||
probe.intentionClicked(query) | ||
|
||
verify(telemetryService).sendEvent(TelemetryEvent.CreateIndexIntentionEvent(dialect)) | ||
} | ||
} |