Statistics View IntelliJ Plugin

Overview

icon

Statistics View IntelliJ Plugin

Build Version Downloads Rating

StatisticsView IntelliJ plugin enables logging IDE code browsing activities and shows aggregated statistical information (e.g. accumulated file opened times) in the IDE Project view.

The plugin aims to provide some helpful insight into IDE users' productivity. You can also do some data mining & visualizations base on the raw event logs.

More information can be found on GitHub.

demo

Installation

  • StatisticsView can be installed from an IntelliJ IDE via Settings | Plugins. See the detailed instructions from the JetBrains guide.
  • Alternatively, download the latest plugin zip file from the GitHub release and install manually via Settings | Plugins | Install plugin from disk

Usage

The plugin registers a title bar button in the Project tool window, which provides the following menu options:

  • Enable Logging: activate/deactivate logging for the current IDE project. The title bar button is displayed in the toggled state when activated, thus users could have fewer worries about unexpected background logging behaviors.
  • Project View:
    • Show File Statistics: show/hide aggregated statistical information of each file, e.g. "Last viewed" summary information and accumulated file viewed duration. When IDE frame is deactivated, the duration time is not accounted for.
    • Show Directory Statistics: show the percentage of viewed files in each directory.
    • Hide Viewed Files: hide viewed files from the Project view. Empty middle directories are also hidden.
  • Statistics Data:
    • Clear Statistics Data: clear old raw events and pre-aggregated results for the current project. Note that it doesn't turn off logging simultaneously. Be careful that this operation is unrecoverable.
    • Show Data File: locate the current project's event log file in Finder/Explorer.

How it works

This plugin is highly inspired by activity-tracker as well as some components of the intellij-community project. Apart from recording events, StatisticsView tries to provide some real-time analytical features integrated with the IDE, e.g. adding additional info in the Project view.

Event

StatisticsView subscribes to listeners provided by the IntelliJ Platform for various IDE events, such as file opened, code completion, jump to definition, etc.

For current version (1.0.0) StatisticsView only handles file opened/closed & IDE activated/deactivated events.

Whenever an event is received, StatisticsView records the event type, timestamp, and fileUri (only if the event is file related). StatisticsView won't process events for files that are not valid source files (e.g. binary files, library folders, intentionally "marked as excluded" directories would be ignored).

Data storage

StatisticsView saves events directly to a disk file to ensure minimal dependency. This brings some limitations, such as it could be impossible to make complex queries on the file-based datasets, e.g. filter by time range, group by directory, etc. Since we need to show summarized information in real-time in the IDE Project view, the query could only be performed against some pre-aggregated data structure in memory.

The write load is relatively low (10+ writes per second at most after debounced / dedup) and events could be safely queued on a file writer and saved to disk periodically in the background thread which would not impact IDE performance.

This pre-aggregated hashMap + async file writer practice couldn't handle back-filling situations: e.g. when the user performs a file renamed action in IDE, events with the previous fileUri should be updated.

So if you are accumulating the event logs for a very long period of time, better migrate the raw data into some external data storage (e.g. TSDB) and perform your data analysis offline.

Data format

For the current version (1.0.0), each event is serialized into JSON string format, which could change in future versions.

JSON serialization is picked by its simplicity (provided by kotlinx.serialization API out-of-box), and it is easier to parse line by line via shell scripts.

Example of log file:

{"ts":1661075776169,"action":"IDE_ACTIVATED","file":"","tags":{}}
{"ts":1661075789662,"action":"FILE_OPENED","file":"/README.md","tags":{"FILE_LINE_OF_CODE":"14"}}
{"ts":1661075798429,"action":"FILE_CLOSED","file":"/README.md","tags":{"FILE_LINE_OF_CODE":"14"}}
{"ts":1661075798429,"action":"FILE_OPENED","file":"/src/main/kotlin/org/yh/statistics/listener/MyFileEditorManagerListener.kt","tags":{"FILE_LINE_OF_CODE":"49"}}
{"ts":1661075799293,"action":"FILE_CLOSED","file":"/src/main/kotlin/org/yh/statistics/listener/MyFileEditorManagerListener.kt","tags":{"FILE_LINE_OF_CODE":"49"}}
{"ts":1661075839459,"action":"FILE_OPENED","file":"/src/main/kotlin/org/yh/statistics/view/MyViewTreeStructureProvider.kt","tags":{"FILE_LINE_OF_CODE":"43"}}
{"ts":1661075841073,"action":"FILE_CLOSED","file":"/src/main/kotlin/org/yh/statistics/view/MyViewTreeStructureProvider.kt","tags":{"FILE_LINE_OF_CODE":"43"}}
{"ts":1661075841073,"action":"FILE_OPENED","file":"/src/main/kotlin/org/yh/statistics/view/MyViewNodeDecorator.kt","tags":{"FILE_LINE_OF_CODE":"71"}}
{"ts":1661075850804,"action":"IDE_DEACTIVATED","file":"","tags":{}}

Impact on IDE (FAQ)

Performance

  1. If I enable logging all the time, will it slow down IDE startup?
    • No. Long-running & IO-bound tasks (e.g. serialize/deserialize events data, R/W log file) are executed on the pooled thread and will not affect the IDE responsiveness. You can check the startup cost for plugins using the IntelliJ IDE's built-in diagnostic tools: IDE Help | Diagnostic Tools | Analyze Plugin Startup Performance:
    • diagnostic
    • IDE events handling are performed in the event dispatch thread (EDT) which will not block the UI thread.
  2. Since events keep accumulating, will they eat up my memory?
    • The raw events are queued in memory and written to the disk file periodically, and once the writing is done, they are cleared from the queue and got garbage collected.
  3. The only negative performance impact is the Project view if you turn on Show File Statistics/Show Directory Statistics which adds statistical information next to each file/directory node. The ProjectView rendering finishes instantly most of the time, however if the project consists of a huge amount of files, the total rendering cost could be significant. If you encounter some sluggishness with the Project view, just turn off the Show ... Statistics actions, and turn on them when you need to see the statistical information.

Data

  1. Where is the raw event log stored?
    • The raw event log (stat.log) is saved in the project .idea folder, and IDE doesn't need your permission to read/write from somewhere other than the current project's folder. It's by nature project-wide, and you won't bother cleaning up the log once you delete the IDE project. It would also be less likely to mess up your VCS since most projects' .idea folder is already ignored.
  2. Can I safely share the log file with someone else?
    • Sure. No personal identity information (e.g. username, hostname) is logged, and all fileUri are saved as the relative path to the project root.
  3. Any telemetry or data reporting?
    • No and never.
  4. Log rotation / data compression
    • Will be provided in v1.0.2.

Data analysis & IDE productivity [WIP]

Note: most of this part is not closely related to the duty of the StatisticsView plugin. There are many similarities between IDE code activities and microservices observability concepts.

Import event data into PostgreSQL [Experimental]

checkout data-analysis-poc for a k8s manifest for importing event logs into PostgreSQL and visualizing in Grafana dashboard

grafana dashboard

Acknowledgment

You might also like...
IntelliJ-based IDEs Protobuf Language Plugin that provides Protobuf language support.
IntelliJ-based IDEs Protobuf Language Plugin that provides Protobuf language support.

IntelliJ Protobuf Language Plugin Reference Inspired by protobuf-jetbrains-plugin and intellij-protobuf-editor. Descriptor IntelliJ-based IDEs Protobu

Plugin for IntelliJ-based IDEs folding root files in the ProjectView
Plugin for IntelliJ-based IDEs folding root files in the ProjectView

Foldable ProjectView The Foldable ProjectView is a plugin for the IntelliJ-based IDEs that lets you fold files located in the root of your project. Av

IntelliJ plugin that provides a modern and powerful byte code analyzer tool window.
IntelliJ plugin that provides a modern and powerful byte code analyzer tool window.

IntelliJ Byte Code Analyzer Plugin This IntelliJ plugin provides a modern and powerful byte code analyzer tool window. Its supports Java, Kotlin, Groo

✈️ IDE plugin for the IntelliJ platform which adds GitHub Copilot support. (VERY WIP)
✈️ IDE plugin for the IntelliJ platform which adds GitHub Copilot support. (VERY WIP)

JetBrains Copilot GitHub Copilot support for the IntellIJ Platform. Installation Download the latest release. Select the Install Plugin from Disk opti

A plugin that adds support for rs2asm files to IntelliJ.

Rs2Asm This plugin adds some simple features when interacting with rs2asm files. Features Syntax highlighting Autocompletion for label names and instr

 IntelliJ Platform Plugin Template
IntelliJ Platform Plugin Template

IntelliJ Platform Plugin Template is a repository that provides a pure template to make it easier to create a new plugin project (check the Creating a repository from a template article).

IntelliJ IDEA / PhpStorm InertiaJS Plugin

PhpStorm and IntelliJ IDEA Inertia.js Plugin Provides support in PhpStorm and IntelliJ IDEA Ultimate for Inertia.js. 💡 GitHub Issues: feature request

A playground to development intellij plugin

pluginExporlor Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get familiar with the template documentation. Verify the plu

Developer ToolBox IntelliJ Plugin

developer-toolbox Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get familiar with the template documentation. Verify the

IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea

IntelliJ Idea Astor Plugin IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea. It communicates with a local/remote program

null 4 Aug 28, 2021
Intellij-platform-plugin-template - IntelliJ Platform Plugin Template

IntelliJ Platform Plugin Template TL;DR: Click the Use this template button and

null 0 Jan 1, 2022
Kirill Rakhman 4 Sep 15, 2022
eventbus-intellij-plugin 3.8 0.0 L1 Java Plugin to navigate between events posted by EventBus.

eventbus-intellij-plugin Plugin to navigate between events posted by EventBus. Post to onEvent and onEvent to Post Install There are two ways. Prefere

Shinnosuke Kugimiya 315 Aug 8, 2022
A Intellij platform plugin to view truetype font file(.ttf) that includes icon glyphs usually

Icon Font Viewer 一个用于查看.ttf字体文件的Intellij平台(支持IDEA/Android Studio等)的插件,通常用于展示icon

null 7 Oct 22, 2022
IntelliJ Plugin for Android Parcelable boilerplate code generation.

IntelliJ/Android Studio Plugin for Android Parcelable boilerplate code generation This tool generates an Android Parcelable implementation based on fi

Michał Charmas 2.1k Dec 27, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022
IntelliJ / Android Studio plugin for Android Holo Colors

This project is not maintained anymore. Holo Colors doesn't make sense since the introduction of Material Design and the ability to set the primary co

Jérôme Van Der Linden 644 Nov 10, 2022
Android Studio & IntelliJ Plugin for sort xml by name="xxx".

AndroidXmlSorter Android Studio & IntelliJ Plugin for sort xml by name="xxx". Options Insert space between difference prefix ('Snake Case', 'Camel Cas

Kaoru Tsutsumishita 102 Nov 29, 2022
IntelliJ plugin that provides some useful utilities to support the daily work with Gradle.

IntelliJ Gradle Utilities Plugin This IntelliJ plugin provides some useful utilities to support the daily work with Gradle. It's available on the offi

Marcel Kliemannel 6 Jul 29, 2022