Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM-43972 - Fix usage of internal API in 2025.1 #84

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
plugins.gradle.org
teamcity.jetbrains.com
www.jetbrains.com
downloads.gradle.org

- name: Maximize Build Space
run: |
Expand All @@ -44,7 +45,7 @@ jobs:
uses: actions/checkout@v4

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation[email protected]
uses: gradle/actions/wrapper-validation@v3

- name: Setup Java
uses: actions/setup-java@v3
Expand All @@ -53,7 +54,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/[email protected]
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

Expand Down Expand Up @@ -189,7 +190,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/[email protected]
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

## [2.4.1] - 2025-01-29

- Fix usage of internal API in 2025.1

## [2.4.0] - 2025-01-20

- Add support for IDEs 2025.1
Expand Down Expand Up @@ -139,6 +143,8 @@

The first public release of the plugin.

[2.4.1]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.4.1

[2.4.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.4.0

[2.3.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.3.0
Expand Down Expand Up @@ -195,4 +201,4 @@ The first public release of the plugin.

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

[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.4.0...HEAD
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.4.1...HEAD
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.cycode.plugin
pluginName = Cycode
pluginRepositoryUrl = https://github.com/cycodehq/intellij-platform-plugin
# SemVer format -> https://semver.org
pluginVersion = 2.4.0
pluginVersion = 2.4.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 231
Expand Down
20 changes: 13 additions & 7 deletions src/main/kotlin/com/cycode/plugin/sentry/SentryErrorReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.cycode.plugin.sentry

import com.cycode.plugin.Consts
import com.cycode.plugin.CycodeBundle
import com.intellij.diagnostic.IdeaReportingEvent
import com.intellij.ide.DataManager
import com.intellij.idea.IdeaLogger
import com.intellij.openapi.actionSystem.CommonDataKeys
Expand All @@ -18,8 +17,16 @@ import io.sentry.Sentry
import io.sentry.SentryEvent
import io.sentry.SentryLevel
import java.awt.Component
import java.io.PrintWriter
import java.io.StringWriter


fun getStackTraceAsString(throwable: Throwable): String {
val sw = StringWriter()
throwable.printStackTrace(PrintWriter(sw))
return sw.toString()
}

class SentryErrorReporter : ErrorReportSubmitter() {
override fun getReportActionText(): String {
return CycodeBundle.message("reportActionButton")
Expand All @@ -38,20 +45,19 @@ class SentryErrorReporter : ErrorReportSubmitter() {
object : Task.Backgroundable(project, CycodeBundle.message("sentryReporting"), false) {
override fun run(indicator: ProgressIndicator) {
for (ideaEvent in events) {
if (ideaEvent !is IdeaReportingEvent) {
continue
}

val event = SentryEvent()
event.level = SentryLevel.ERROR
event.release = Consts.SENTRY_RELEASE
event.throwable = ideaEvent.data.throwable
event.throwable = ideaEvent.throwable
event.serverName = ""

event.extras = mapOf(
"message" to ideaEvent.data.message,
"message" to ideaEvent.message,
"additional_info" to additionalInfo,
"last_action" to IdeaLogger.ourLastActionId,
// before 2025.1 it will contain more useful information
// since 2025.1 throwable is close to the original
"stacktrace" to getStackTraceAsString(ideaEvent.throwable)
)

Sentry.captureEvent(event)
Expand Down
12 changes: 5 additions & 7 deletions src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ object SentryInit {
}

fun setupScope(userId: String, tenantId: String) {
Sentry.configureScope { scope ->
scope.setTag("tenant_id", tenantId)
scope.user = User().apply {
id = userId
data = mapOf("tenant_id" to tenantId)
}
}
Sentry.setTag("tenant_id", tenantId)
Sentry.setUser(User().apply {
id = userId
data = mapOf("tenant_id" to tenantId)
})
}

private fun isSentryDisabled(): Boolean {
Expand Down