Skip to content

Commit c35ce19

Browse files
authored
CM-37864 - Integrate Sentry (#73)
1 parent 6aeff1f commit c35ce19

File tree

19 files changed

+181
-7
lines changed

19 files changed

+181
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
if: ${{ github.event_name == 'workflow_dispatch' }}
9898
env:
9999
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
100+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
100101
run: ./gradlew publishPlugin
101102

102103
# test:

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
## [Unreleased]
66

7+
## [1.9.2] - 2024-07-15
8+
9+
- Integrate Sentry
10+
711
## [1.9.1] - 2024-06-25
812

913
- Remove forgotten "coming soon" from SAST
@@ -93,6 +97,8 @@
9397

9498
The first public release of the plugin.
9599

100+
[1.9.2]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.2
101+
96102
[1.9.1]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.1
97103

98104
[1.9.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.0
@@ -129,4 +135,4 @@ The first public release of the plugin.
129135

130136
[1.0.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.0.0
131137

132-
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.4.0...HEAD
138+
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.9.2...HEAD

build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
1111
alias(libs.plugins.changelog) // Gradle Changelog Plugin
1212
alias(libs.plugins.kover) // Gradle Kover Plugin
13+
alias(libs.plugins.sentry)
1314
}
1415

1516
group = properties("pluginGroup").get()
@@ -66,6 +67,20 @@ koverReport {
6667
}
6768
}
6869

70+
// Configure Sentry
71+
sentry {
72+
includeDependenciesReport = false
73+
74+
// Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.
75+
// This enables source context, allowing you to see your source
76+
// code as part of your stack traces in Sentry.
77+
includeSourceContext = true
78+
79+
org = "cycode"
80+
projectName = "intellij-platform-plugin"
81+
authToken = environment("SENTRY_AUTH_TOKEN")
82+
}
83+
6984
tasks {
7085
wrapper {
7186
gradleVersion = properties("gradleVersion").get()
@@ -124,6 +139,7 @@ tasks {
124139

125140
publishPlugin {
126141
dependsOn("patchChangelog")
142+
dependsOn("sentryUploadSourceBundleJava")
127143
token = environment("PUBLISH_TOKEN")
128144
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
129145
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.cycode.plugin
44
pluginName = Cycode
55
pluginRepositoryUrl = https://github.com/cycodehq/intellij-platform-plugin
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.9.1
7+
pluginVersion = 1.9.2
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 211.1

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ kotlin = "1.9.20"
1010
changelog = "2.2.0"
1111
gradleIntelliJPlugin = "1.17.1"
1212
kover = "0.7.3"
13+
sentry = "4.9.0"
1314

1415
[libraries]
1516
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
@@ -22,3 +23,4 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
2223
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
2324
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2425
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
26+
sentry = { id = "io.sentry.jvm.gradle", version.ref = "sentry" }

src/main/kotlin/com/cycode/plugin/Consts.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cycode.plugin
22

3+
import com.cycode.plugin.utils.getPluginVersion
34
import com.intellij.openapi.application.PathManager
45
import com.intellij.openapi.util.SystemInfo
56

@@ -16,12 +17,17 @@ private fun getDefaultCliPath(): String {
1617
return "${Consts.PLUGIN_PATH}/cycode"
1718
}
1819

20+
private fun getSentryReleaseVersion(): String {
21+
val appName = CycodeBundle.message("appName")
22+
val version = getPluginVersion()
23+
return "$appName@${version}"
24+
}
1925

2026
class Consts {
2127
companion object {
2228
val PLUGIN_PATH = PathManager.getPluginsPath() + "/cycode-intellij-platform-plugin"
2329
val DEFAULT_CLI_PATH = getDefaultCliPath()
24-
const val REQUIRED_CLI_VERSION = "1.10.1"
30+
const val REQUIRED_CLI_VERSION = "1.10.3"
2531

2632
const val CLI_GITHUB_ORG = "cycodehq"
2733
const val CLI_GITHUB_REPO = "cycode-cli"
@@ -30,5 +36,11 @@ class Consts {
3036

3137
const val PLUGIN_AUTO_SAVE_FLUSH_INITIAL_DELAY_SEC = 0L
3238
const val PLUGIN_AUTO_SAVE_FLUSH_DELAY_SEC = 5L
39+
40+
const val SENTRY_DSN = "https://0f0524e8d03a4283702a10ed4b6e03d0@o1026942.ingest.us.sentry.io/4507543885774848"
41+
const val SENTRY_DEBUG = false
42+
val SENTRY_RELEASE = getSentryReleaseVersion()
43+
const val SENTRY_SAMPLE_RATE = 1.0
44+
const val SENTRY_SEND_DEFAULT_PII = false
3345
}
3446
}

src/main/kotlin/com/cycode/plugin/activities/PostStartupActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package com.cycode.plugin.activities
22

33
import com.cycode.plugin.annotators.CycodeAnnotator
4+
import com.cycode.plugin.sentry.SentryInit
45
import com.cycode.plugin.services.cycode
56
import com.intellij.openapi.diagnostic.thisLogger
67
import com.intellij.openapi.project.Project
78
import com.intellij.openapi.startup.StartupActivity
89

910
class PostStartupActivity : StartupActivity.DumbAware {
1011
override fun runActivity(project: Project) {
12+
SentryInit.init()
13+
1114
// we are using singleton here because runActivity is called for each project
1215
CycodeAnnotator.INSTANCE.registerForAllLangs()
1316

src/main/kotlin/com/cycode/plugin/cli/CliWrapper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.intellij.execution.process.ProcessOutputTypes
1414
import com.intellij.openapi.diagnostic.thisLogger
1515
import com.intellij.openapi.util.Key
1616
import com.intellij.util.io.BaseOutputReader
17+
import io.sentry.Sentry
1718
import java.io.File
1819
import java.nio.charset.Charset
1920

@@ -104,6 +105,7 @@ class CliWrapper(val executablePath: String, val workDirectory: String? = null)
104105
val result: CliError = mapper.readValue(stdout)
105106
return CliResult.Error(result)
106107
} catch (e: Exception) {
108+
Sentry.captureException(e)
107109
thisLogger().error("Failed to parse ANY CLI output: $stdout", e)
108110
}
109111

src/main/kotlin/com/cycode/plugin/cli/UserAgent.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package com.cycode.plugin.cli
22

3+
import com.cycode.plugin.CycodeBundle
34
import com.cycode.plugin.cli.models.IDEUserAgent
5+
import com.cycode.plugin.utils.getPluginVersion
46
import com.fasterxml.jackson.databind.ObjectMapper
57
import com.fasterxml.jackson.databind.PropertyNamingStrategies
6-
import com.intellij.ide.plugins.PluginManagerCore
78
import com.intellij.openapi.application.ApplicationInfo
8-
import com.intellij.openapi.extensions.PluginId
99

1010
private fun retrieveIDEInfo(): IDEUserAgent {
1111
val appInfo = ApplicationInfo.getInstance()
1212

13-
val appName = "jetbrains_plugin"
14-
val appVersion = PluginManagerCore.getPlugin(PluginId.getId("com.cycode.plugin"))?.version ?: "unknown"
13+
val appName = CycodeBundle.message("appName")
14+
val appVersion = getPluginVersion()
1515
val envName = appInfo.versionName
1616
val envVersion = appInfo.fullVersion
1717

src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@ package com.cycode.plugin.cli.models
33
data class AuthCheckResult(
44
val result: Boolean,
55
val message: String,
6+
val data: AuthCheckResultData,
7+
)
8+
9+
data class AuthCheckResultData(
10+
val userId: String,
11+
val tenantId: String,
612
)

0 commit comments

Comments
 (0)