add info about used commit to sentry reports

This commit is contained in:
Julian Krings 2025-07-23 15:07:06 +02:00
parent 3949468a60
commit e5f2fee926
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2
3 changed files with 17 additions and 0 deletions

View File

@ -137,6 +137,14 @@ tasks {
"version" to rootProject.version,
"apiVersion" to apiVersion,
"main" to main,
"environment" to if (project.hasProperty("release")) "production" else "development",
"commit" to provider {
ProcessBuilder("git", "rev-parse", "HEAD")
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.start()
.inputStream.bufferedReader().readText().trim()
.takeIf { it.length == 40 } ?: "unknown"
}
)
filesMatching("**/plugin.yml") {
expand(inputs.properties)

View File

@ -23,9 +23,11 @@ import org.bstats.charts.SimplePie;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import oshi.SystemInfo;
import java.io.InputStreamReader;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.HashMap;
@ -45,6 +47,9 @@ public class Bindings {
if (settings.disableAutoReporting || Sentry.isEnabled() || Boolean.getBoolean("iris.suppressReporting")) return;
Iris.info("Enabling Sentry for anonymous error reporting. You can disable this in the settings.");
Iris.info("Your server ID is: " + ServerID.ID);
var resource = Iris.instance.getResource("plugin.yml");
YamlConfiguration desc = resource != null ? YamlConfiguration.loadConfiguration(new InputStreamReader(resource)) : new YamlConfiguration();
Sentry.init(options -> {
options.setDsn("https://b16ecc222e9c1e0c48faecacb906fd89@o4509451052646400.ingest.de.sentry.io/4509452722765904");
if (settings.debug) {
@ -55,6 +60,7 @@ public class Bindings {
options.setAttachServerName(false);
options.setEnableUncaughtExceptionHandler(false);
options.setRelease(Iris.instance.getDescription().getVersion());
options.setEnvironment(desc.getString("environment", "production"));
options.setBeforeSend((event, hint) -> {
if (suppress(event.getThrowable())) return null;
event.setTag("iris.safeguard", IrisSafeguard.mode());
@ -71,6 +77,7 @@ public class Bindings {
scope.setTag("server", Bukkit.getVersion());
scope.setTag("server.type", Bukkit.getName());
scope.setTag("server.api", Bukkit.getBukkitVersion());
scope.setTag("iris.commit", desc.getString("commit", "unknown"));
});
Runtime.getRuntime().addShutdownHook(new Thread(Sentry::close));
}

View File

@ -5,6 +5,8 @@ load: STARTUP
authors: [ cyberpwn, NextdoorPsycho, Vatuu ]
website: volmit.com
description: More than a Dimension!
environment: '${environment}'
commit: '${commit}'
commands:
iris:
aliases: [ ir, irs ]