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

Add theme, color mode and Linux platform version to tags reported to Sentry (#660) #1329

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ dependencies {
implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'io.sentry:sentry:6.24.0'

implementation 'com.jsoftbiz:os-platform-finder:1.1'

// when updating the versions here, also update them in AsciiDocDownloaderUtil for dynamic download
testImplementation 'org.asciidoctor:asciidoctorj-diagram:2.2.9'
testImplementation 'org.asciidoctor:asciidoctorj-pdf:2.3.7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diagnostic.SubmittedReportInfo;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import com.jsoftbiz.utils.OS;
import io.sentry.DuplicateEventDetectionEventProcessor;
import io.sentry.ILogger;
import io.sentry.Sentry;
Expand All @@ -30,6 +33,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.UIManager;
import java.nio.charset.StandardCharsets;
import java.util.Formatter;
import java.util.HashMap;
Expand Down Expand Up @@ -113,6 +117,11 @@ public boolean isEnabled(@Nullable SentryLevel level) {

event.setTag("java_vendor", SystemInfo.JAVA_VENDOR);
event.setTag("java_version", SystemInfo.JAVA_VERSION);
event.setTag("ui_theme", getUiTheme());
event.setTag("ui_dark", getUiMode());
if (SystemInfoRt.isLinux) {
event.setTag("linux_platform", getLinuxPlatformName());
}

// clear the server name, as it is of no use to analyze the error
event.setServerName(null);
Expand Down Expand Up @@ -234,4 +243,16 @@ private static void fillActivePlugins(Contexts contexts) {
contexts.put("active plugins", activePlugins);
}
}

private static String getUiTheme() {
return UIManager.getLookAndFeel().getName();
}

private static String getUiMode() {
return String.valueOf(EditorColorsManager.getInstance().isDarkEditor());
}

private static String getLinuxPlatformName() {
return OS.OS.getPlatformName();
}
}