Skip to content

Commit

Permalink
Add theme, color mode and Linux platform version to tags reported to …
Browse files Browse the repository at this point in the history
…Sentry (#660)
  • Loading branch information
vitalii-chura-axon committed Apr 14, 2023
1 parent c61dfd0 commit 5fc9a51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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.17.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.7'
testImplementation 'org.asciidoctor:asciidoctorj-pdf:2.3.6'
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();
}
}

0 comments on commit 5fc9a51

Please sign in to comment.