Skip to content

Commit

Permalink
feat: telemetry report local/cluster file opened (#483)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Feb 28, 2025
1 parent 235bd2f commit 1295e99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ open class ResourceEditorFactory protected constructor(
) {
return null
}
val telemetry = getTelemetryMessageBuilder().action(TelemetryService.NAME_PREFIX_EDITOR + "open")
return try {
val telemetry = createTelemetry(editor.file)
return try {
runAsync { TelemetryService.sendTelemetry(getKubernetesResourceInfo(editor.file, project), telemetry) }
val resourceEditor = createResourceEditor.invoke(editor, project)
resourceEditor.createToolbar()
Expand All @@ -134,6 +134,19 @@ open class ResourceEditorFactory protected constructor(
}
}

private fun createTelemetry(file: VirtualFile): TelemetryMessageBuilder.ActionMessage {
val isLocalFile = ResourceFile.isResourceFile(file)
return getTelemetryMessageBuilder().action(
"${TelemetryService.NAME_PREFIX_EDITOR} open ${
if (isLocalFile) {
"cluster file"
} else {
"local file"
}
} "
)
}

private fun onProjectClosed(resourceEditor: ResourceEditor): ProjectManagerListener {
return object : ProjectManagerListener {
override fun projectClosing(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ResourceEditorFactoryTest {
private val resource = createResource<HasMetadata>(deployment)
private val virtualFile: VirtualFile = mock {
on { isInLocalFileSystem } doReturn true
on { path } doReturn "skywalker"
}

private val fileEditor: FileEditor = mock<FileEditor>().apply {
Expand Down

0 comments on commit 1295e99

Please sign in to comment.