You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
77
77
val name = telemetryMap["name"] as?String?:return
78
78
79
79
@Suppress("UNCHECKED_CAST")
80
-
val data = telemetryMap["data"] as?Map<String, Any> ?:return
80
+
val data = telemetryMap["data"] as?Map<String, Any?> ?:return
81
81
82
82
TelemetryService.getInstance().record(project) {
83
83
datum(name) {
@@ -90,7 +90,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
Copy file name to clipboardExpand all lines: plugins/amazonq/shared/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImplTest.kt
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,36 @@ class AmazonQLanguageClientImplTest {
81
81
)
82
82
}
83
83
84
+
@Test
85
+
fun`telemetryEvent handles null`() {
86
+
val telemetryService = mockk<TelemetryService>(relaxed =true)
87
+
mockkObject(TelemetryService)
88
+
every { TelemetryService.getInstance() } returns telemetryService
89
+
90
+
val builderCaptor = slot<MetricEvent.Builder.() -> Unit>()
91
+
every { telemetryService.record(project, capture(builderCaptor)) } returns Unit
92
+
93
+
val event =mapOf(
94
+
"name" to "test_event",
95
+
"data" to mapOf(
96
+
"key1" to null,
97
+
)
98
+
)
99
+
100
+
sut.telemetryEvent(event)
101
+
102
+
val builder =DefaultMetricEvent.builder()
103
+
builderCaptor.captured.invoke(builder)
104
+
105
+
val metricEvent = builder.build()
106
+
val datum = metricEvent.data.first()
107
+
108
+
assertThat(datum.name).isEqualTo("test_event")
109
+
assertThat(datum.metadata).contains(
110
+
entry("key1", "null"),
111
+
)
112
+
}
113
+
84
114
@Test
85
115
fun`telemetryEvent handles event with result field`() {
86
116
val telemetryService = mockk<TelemetryService>(relaxed =true)
0 commit comments