From 6c02136b37843786ec7890e141589c562ae9f027 Mon Sep 17 00:00:00 2001 From: James Yoo Date: Mon, 27 Jun 2022 17:04:08 -0700 Subject: [PATCH] Adding editor jump analytics (#56) * Adding editor jump analytics * Bumping version from 1.1.0 -> 1.2.0 --- gradle.properties | 2 +- .../jyoo980/reachhover/actions/StartupAction.kt | 13 +++++++++++++ .../jyoo980/reachhover/analytics/LogWriter.kt | 3 ++- .../analytics/listeners/EditorSelectionListener.kt | 14 ++++++++++++++ .../analytics/{ => listeners}/FileListener.kt | 4 +++- src/main/resources/META-INF/plugin.xml | 4 ++-- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/com/github/jyoo980/reachhover/actions/StartupAction.kt create mode 100644 src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/EditorSelectionListener.kt rename src/main/kotlin/com/github/jyoo980/reachhover/analytics/{ => listeners}/FileListener.kt (75%) diff --git a/gradle.properties b/gradle.properties index 4b1420a..cb64ea0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.jyoo980.reachhover pluginName = reach-hover # SemVer format -> https://semver.org -pluginVersion = 1.1.0 +pluginVersion = 1.2.0 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. diff --git a/src/main/kotlin/com/github/jyoo980/reachhover/actions/StartupAction.kt b/src/main/kotlin/com/github/jyoo980/reachhover/actions/StartupAction.kt new file mode 100644 index 0000000..a4f7e73 --- /dev/null +++ b/src/main/kotlin/com/github/jyoo980/reachhover/actions/StartupAction.kt @@ -0,0 +1,13 @@ +package com.github.jyoo980.reachhover.actions + +import com.github.jyoo980.reachhover.analytics.listeners.EditorSelectionListener +import com.intellij.openapi.editor.EditorFactory +import com.intellij.openapi.project.Project +import com.intellij.openapi.startup.StartupActivity + +class StartupAction : StartupActivity { + + override fun runActivity(project: Project) { + EditorFactory.getInstance().eventMulticaster.addCaretListener(EditorSelectionListener()) + } +} diff --git a/src/main/kotlin/com/github/jyoo980/reachhover/analytics/LogWriter.kt b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/LogWriter.kt index f5a7227..8bda9df 100644 --- a/src/main/kotlin/com/github/jyoo980/reachhover/analytics/LogWriter.kt +++ b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/LogWriter.kt @@ -49,5 +49,6 @@ enum class EventType { REACH_HOVER_INVOKED, FILE_OPEN, FILE_CLOSED, - MOUSE_CLICK + MOUSE_CLICK, + CURSOR_JUMP, } diff --git a/src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/EditorSelectionListener.kt b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/EditorSelectionListener.kt new file mode 100644 index 0000000..cab2248 --- /dev/null +++ b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/EditorSelectionListener.kt @@ -0,0 +1,14 @@ +package com.github.jyoo980.reachhover.analytics.listeners + +import com.github.jyoo980.reachhover.analytics.EventType +import com.github.jyoo980.reachhover.analytics.LogWriter +import com.intellij.openapi.editor.event.CaretEvent +import com.intellij.openapi.editor.event.CaretListener + +class EditorSelectionListener : CaretListener { + + override fun caretPositionChanged(event: CaretEvent) { + val editorType = event.editor.editorKind + LogWriter.write("Jump occurred in editor of type: $editorType", EventType.CURSOR_JUMP) + } +} diff --git a/src/main/kotlin/com/github/jyoo980/reachhover/analytics/FileListener.kt b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/FileListener.kt similarity index 75% rename from src/main/kotlin/com/github/jyoo980/reachhover/analytics/FileListener.kt rename to src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/FileListener.kt index 966dc31..35fc38f 100644 --- a/src/main/kotlin/com/github/jyoo980/reachhover/analytics/FileListener.kt +++ b/src/main/kotlin/com/github/jyoo980/reachhover/analytics/listeners/FileListener.kt @@ -1,5 +1,7 @@ -package com.github.jyoo980.reachhover.analytics +package com.github.jyoo980.reachhover.analytics.listeners +import com.github.jyoo980.reachhover.analytics.EventType +import com.github.jyoo980.reachhover.analytics.LogWriter import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.intellij.openapi.vfs.VirtualFile diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 89da5c8..4098e65 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -12,14 +12,14 @@ implementation="com.github.jyoo980.reachhover.listeners.EditorHoverListener"/> - +