-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the first set of metrics to be tracked for Skate plugin, including * Whats New Panel: * When the What's new panel opened / closed * Feature Flag Annotator: * When user clicked on Houston link from feature flag annotation * Project Generator: * When the terminal opened and execute command to spin up ProjectGen UI Noted that for the WhatsNewPanel, I added a custom `WhatsNewToolWindowListener` to subscribe to the event for the window opened/closed. I followed the set up described [here](https://plugins.jetbrains.com/docs/intellij/plugin-listeners.html#defining-project-level-listeners) to set up the listener Testing: Example traces sent: https://analytics.tinyspeck.com/v3/explore/1000000001135498 <!-- ⬆ Put your description above this! ⬆ Please be descriptive and detailed. Please read our [Contributing Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md) and [Code of Conduct](https://slackhq.github.io/code-of-conduct). Don't worry about deleting this, it's not visible in the PR! -->
- Loading branch information
Showing
18 changed files
with
507 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Skate Plugin | ||
========================= | ||
|
||
An Intellij plugin that helps to improve local developer productivity by surfacing useful information in the IDE. | ||
|
||
We use this at Slack for s several use cases: | ||
* Announce updates, latest changes and improvements through "What's New" panel | ||
* Annotate Feature Flag to help easily access its setup | ||
* Generate API model translators when migrating legacy API | ||
* Create initial new subproject setup from `File` dropdown | ||
|
||
## Installation | ||
|
||
#### Artifactory | ||
1. Install `artifactory-authenticator` plugin from disk and authenticate with Artifactory | ||
2. Add custom plugin repository link from "Manage Plugin Repositories" | ||
3. Search "Skate" in the plugins marketplace and install it | ||
|
||
#### Local testing | ||
1. Build local version of the plugin with `./gradlew buildPlugin` | ||
2. Open IDE settings, then "Install Plugin from Disk..." | ||
|
||
## Implementation | ||
All registered plugin actions can be found in `skate.xml` config file | ||
|
||
## Tracing | ||
We're sending analytics for almost all Skate features to track user usage. To set this up, | ||
1. Register new feature event in `SkateTracingEvent` | ||
2. Use `SkateSpanBuilder` to create the span for event you want to track | ||
3. Make call to `SkateTraceReporter` to send up the traces | ||
|
||
## Publishing | ||
Run `publish-skate` Github Action to publish to the configured repository. | ||
|
||
Behind the scene the action's running`./gradlew :skate-plugin:uploadPluginToArtifactory` |
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
65 changes: 65 additions & 0 deletions
65
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/WhatsNewToolWindowListener.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,65 @@ | ||
/* | ||
* Copyright (C) 2023 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.slack.sgp.intellij | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import com.intellij.openapi.wm.ex.ToolWindowManagerListener | ||
import com.slack.sgp.intellij.SkateProjectServiceImpl.Companion.WHATS_NEW_PANEL_ID | ||
import com.slack.sgp.intellij.tracing.SkateSpanBuilder | ||
import com.slack.sgp.intellij.tracing.SkateTraceReporter | ||
import com.slack.sgp.intellij.tracing.SkateTracingEvent | ||
import com.slack.sgp.intellij.tracing.SkateTracingEvent.EventType.SKATE_WHATS_NEW_PANEL_CLOSED | ||
import com.slack.sgp.intellij.tracing.SkateTracingEvent.EventType.SKATE_WHATS_NEW_PANEL_OPENED | ||
import com.slack.sgp.intellij.util.isTracingEnabled | ||
import java.time.Instant | ||
|
||
/** Custom listener for WhatsNew Tool Window. */ | ||
class WhatsNewToolWindowListener(private val project: Project) : ToolWindowManagerListener { | ||
// Initial state of screen should be hidden | ||
private var wasVisible = false | ||
private val startTimestamp = Instant.now() | ||
|
||
override fun stateChanged(toolWindowManager: ToolWindowManager) { | ||
super.stateChanged(toolWindowManager) | ||
if (!project.isTracingEnabled()) return | ||
|
||
val skateSpanBuilder = SkateSpanBuilder() | ||
val toolWindow = toolWindowManager.getToolWindow(WHATS_NEW_PANEL_ID) ?: return | ||
val isVisible = toolWindow.isVisible | ||
val visibilityChanged = visibilityChanged(isVisible) | ||
|
||
if (visibilityChanged) { | ||
if (isVisible) { | ||
skateSpanBuilder.addSpanTag("event", SkateTracingEvent(SKATE_WHATS_NEW_PANEL_OPENED)) | ||
} else { | ||
skateSpanBuilder.addSpanTag("event", SkateTracingEvent(SKATE_WHATS_NEW_PANEL_CLOSED)) | ||
} | ||
SkateTraceReporter(project) | ||
.createPluginUsageTraceAndSendTrace( | ||
WHATS_NEW_PANEL_ID.replace('-', '_'), | ||
startTimestamp, | ||
skateSpanBuilder.getKeyValueList() | ||
) | ||
} | ||
} | ||
|
||
fun visibilityChanged(isVisible: Boolean): Boolean { | ||
val visibilityChanged = isVisible != wasVisible | ||
wasVisible = isVisible | ||
return visibilityChanged | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/tracing/SkateSpanBuilder.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,45 @@ | ||
/* | ||
* Copyright (C) 2023 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.slack.sgp.intellij.tracing | ||
|
||
import com.slack.sgp.tracing.KeyValue | ||
import com.slack.sgp.tracing.model.TagBuilder | ||
import com.slack.sgp.tracing.model.newTagBuilder | ||
|
||
class SkateSpanBuilder { | ||
private val keyValueList: TagBuilder = newTagBuilder() | ||
|
||
fun addSpanTag(key: String, value: String) { | ||
keyValueList.apply { key tagTo value } | ||
} | ||
|
||
fun addSpanTag(key: String, value: SkateTracingEvent) { | ||
keyValueList.apply { key tagTo value.type.name } | ||
} | ||
|
||
fun getKeyValueList(): List<KeyValue> { | ||
return keyValueList.toList() | ||
} | ||
} | ||
|
||
class SkateTracingEvent(val type: EventType) { | ||
enum class EventType { | ||
PROJECT_GEN_OPENED, | ||
HOUSTON_FEATURE_FLAG_URL_CLICKED, | ||
SKATE_WHATS_NEW_PANEL_OPENED, | ||
SKATE_WHATS_NEW_PANEL_CLOSED | ||
} | ||
} |
Oops, something went wrong.