diff --git a/clients/go/error_reporter.go b/clients/go/error_reporter.go
new file mode 100644
index 0000000..934e11d
--- /dev/null
+++ b/clients/go/error_reporter.go
@@ -0,0 +1,326 @@
+// Package errorreporter is a lightweight client for errors.bitreport.pt.
+//
+// Drop this file (and go.mod) into any Go 1.21+ project. Zero external dependencies.
+//
+// Usage:
+//
+// import errorreporter "pt.bitreport/errors-go"
+//
+// func main() {
+// errorreporter.Init(errorreporter.Config{Token: os.Getenv("ERROR_REPORTING_TOKEN")})
+// defer errorreporter.Flush()
+// ...
+// if err := doSomething(); err != nil {
+// errorreporter.ReportError(err, nil)
+// }
+// }
+//
+// Environment variables:
+//
+// ERROR_REPORTING_TOKEN — ingest API key (required)
+// ERROR_REPORTING_ENDPOINT — base URL (default: https://errors.bitreport.pt)
+// ERROR_REPORTING_DISABLED — set to "1" to disable
+// ERROR_REPORTING_PROJECT_NAME — display name (optional)
+// ERROR_REPORTING_PROJECT_SLUG — stable product slug (optional)
+// ERROR_REPORTING_GITEA_REPO — canonical owner/repo on Gitea (optional)
+package errorreporter
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "os"
+ "runtime"
+ "strings"
+ "sync"
+ "time"
+)
+
+const (
+ defaultEndpoint = "https://errors.bitreport.pt"
+ batchSize = 25
+ flushInterval = 5 * time.Second
+ httpTimeout = 8 * time.Second
+)
+
+// Config holds reporter configuration. All fields are optional; unset fields
+// fall back to the corresponding environment variable.
+type Config struct {
+ Token string
+ Endpoint string
+ Disabled bool
+ ProjectName string
+ ProjectSlug string
+ GiteaRepo string
+}
+
+type ingestEvent struct {
+ SchemaVersion int `json:"schema_version"`
+ OccurredAt string `json:"occurred_at"`
+ Level string `json:"level"`
+ Message string `json:"message"`
+ Stacktrace string `json:"stacktrace,omitempty"`
+ Context map[string]interface{} `json:"context,omitempty"`
+}
+
+var (
+ mu sync.Mutex
+ cfg Config
+ queue []ingestEvent
+ flushTimer *time.Timer
+ httpClient = &http.Client{Timeout: httpTimeout}
+)
+
+// Init initialises the reporter. Call once at startup before any Report* calls.
+func Init(c Config) {
+ mu.Lock()
+ defer mu.Unlock()
+
+ cfg.Token = coalesce(c.Token, os.Getenv("ERROR_REPORTING_TOKEN"))
+ ep := coalesce(c.Endpoint, os.Getenv("ERROR_REPORTING_ENDPOINT"), defaultEndpoint)
+ cfg.Endpoint = strings.TrimRight(ep, "/")
+ cfg.Disabled = c.Disabled || os.Getenv("ERROR_REPORTING_DISABLED") == "1"
+ cfg.ProjectName = coalesce(c.ProjectName, os.Getenv("ERROR_REPORTING_PROJECT_NAME"))
+ cfg.ProjectSlug = coalesce(c.ProjectSlug, os.Getenv("ERROR_REPORTING_PROJECT_SLUG"))
+ cfg.GiteaRepo = coalesce(c.GiteaRepo, os.Getenv("ERROR_REPORTING_GITEA_REPO"))
+}
+
+// ReportError reports an error with an optional context map.
+func ReportError(err error, ctx map[string]interface{}) {
+ mu.Lock()
+ tok, dis, pn, ps, gr, ep := cfg.Token, cfg.Disabled, cfg.ProjectName, cfg.ProjectSlug, cfg.GiteaRepo, cfg.Endpoint
+ mu.Unlock()
+
+ if dis || tok == "" || err == nil {
+ return
+ }
+ _ = ep // used via snapshot; referenced in send
+
+ buf := make([]byte, 8192)
+ n := runtime.Stack(buf, false)
+ stack := string(buf[:n])
+
+ filePath, lineNum := callerInfo()
+
+ c := map[string]interface{}{
+ "error_type": typeName(err),
+ }
+ if filePath != "" {
+ c["file_path"] = filePath
+ }
+ if lineNum > 0 {
+ c["line_number"] = lineNum
+ }
+ if pn != "" {
+ c["project_name"] = pn
+ }
+ if ps != "" {
+ c["project_slug"] = ps
+ }
+ if gr != "" {
+ c["gitea_repo"] = gr
+ }
+ for k, v := range ctx {
+ c[k] = v
+ }
+
+ enqueue(ingestEvent{
+ SchemaVersion: 1,
+ OccurredAt: nowISO(),
+ Level: "error",
+ Message: err.Error(),
+ Stacktrace: stack,
+ Context: c,
+ })
+}
+
+// ReportMessage reports a plain string message at the given level.
+// level must be one of: "error", "warning", "info", "critical".
+func ReportMessage(message, level string, ctx map[string]interface{}) {
+ mu.Lock()
+ tok, dis, pn, ps, gr := cfg.Token, cfg.Disabled, cfg.ProjectName, cfg.ProjectSlug, cfg.GiteaRepo
+ mu.Unlock()
+
+ if dis || tok == "" {
+ return
+ }
+ if level == "" {
+ level = "error"
+ }
+
+ c := map[string]interface{}{}
+ if pn != "" {
+ c["project_name"] = pn
+ }
+ if ps != "" {
+ c["project_slug"] = ps
+ }
+ if gr != "" {
+ c["gitea_repo"] = gr
+ }
+ for k, v := range ctx {
+ c[k] = v
+ }
+
+ ev := ingestEvent{
+ SchemaVersion: 1,
+ OccurredAt: nowISO(),
+ Level: level,
+ Message: message,
+ }
+ if len(c) > 0 {
+ ev.Context = c
+ }
+ enqueue(ev)
+}
+
+// Flush sends all queued events synchronously. Call before process exit (e.g. via defer).
+func Flush() {
+ mu.Lock()
+ if flushTimer != nil {
+ flushTimer.Stop()
+ flushTimer = nil
+ }
+ batch := make([]ingestEvent, len(queue))
+ copy(batch, queue)
+ queue = queue[:0]
+ mu.Unlock()
+
+ send(batch)
+}
+
+// RecoverAndReport is a deferred helper that catches a panic, reports it, flushes,
+// then re-panics so the runtime still terminates the goroutine normally.
+//
+// defer errorreporter.RecoverAndReport(nil)
+func RecoverAndReport(ctx map[string]interface{}) {
+ if r := recover(); r != nil {
+ var err error
+ switch v := r.(type) {
+ case error:
+ err = v
+ default:
+ err = fmt.Errorf("%v", v)
+ }
+ ReportError(err, ctx)
+ Flush()
+ panic(r)
+ }
+}
+
+// --- internals ---
+
+func enqueue(ev ingestEvent) {
+ var toSend []ingestEvent
+
+ mu.Lock()
+ queue = append(queue, ev)
+ if len(queue) >= batchSize {
+ toSend = make([]ingestEvent, len(queue))
+ copy(toSend, queue)
+ queue = queue[:0]
+ } else if flushTimer == nil {
+ flushTimer = time.AfterFunc(flushInterval, flushAsync)
+ }
+ mu.Unlock()
+
+ if toSend != nil {
+ go send(toSend)
+ }
+}
+
+func flushAsync() {
+ mu.Lock()
+ flushTimer = nil
+ if len(queue) == 0 {
+ mu.Unlock()
+ return
+ }
+ batch := make([]ingestEvent, len(queue))
+ copy(batch, queue)
+ queue = queue[:0]
+ mu.Unlock()
+
+ send(batch)
+}
+
+func send(events []ingestEvent) {
+ if len(events) == 0 {
+ return
+ }
+ mu.Lock()
+ tok := cfg.Token
+ ep := cfg.Endpoint
+ mu.Unlock()
+
+ for i := 0; i < len(events); i += batchSize {
+ end := i + batchSize
+ if end > len(events) {
+ end = len(events)
+ }
+ sendBatch(tok, ep, events[i:end])
+ }
+}
+
+func sendBatch(token, endpoint string, events []ingestEvent) {
+ body, err := json.Marshal(map[string]interface{}{"events": events})
+ if err != nil {
+ return
+ }
+ req, err := http.NewRequest(http.MethodPost, endpoint+"/v1/ingest/events", bytes.NewReader(body))
+ if err != nil {
+ return
+ }
+ req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("Authorization", "Bearer "+token)
+ resp, err := httpClient.Do(req)
+ if err != nil {
+ return
+ }
+ resp.Body.Close()
+}
+
+func nowISO() string {
+ t := time.Now().UTC()
+ ms := t.Nanosecond() / 1e6
+ return fmt.Sprintf("%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
+ t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), ms)
+}
+
+func callerInfo() (string, int) {
+ pcs := make([]uintptr, 16)
+ // skip: runtime.Callers, callerInfo, ReportError/ReportMessage
+ n := runtime.Callers(3, pcs)
+ frames := runtime.CallersFrames(pcs[:n])
+ for {
+ f, more := frames.Next()
+ if !strings.HasSuffix(f.File, "error_reporter.go") {
+ return f.File, f.Line
+ }
+ if !more {
+ break
+ }
+ }
+ return "", 0
+}
+
+func typeName(err error) string {
+ if err == nil {
+ return ""
+ }
+ t := fmt.Sprintf("%T", err)
+ if idx := strings.LastIndex(t, "."); idx >= 0 {
+ return t[idx+1:]
+ }
+ return t
+}
+
+func coalesce(vals ...string) string {
+ for _, v := range vals {
+ if v != "" {
+ return v
+ }
+ }
+ return ""
+}
diff --git a/clients/go/error_reporter_test.go b/clients/go/error_reporter_test.go
new file mode 100644
index 0000000..ef64716
--- /dev/null
+++ b/clients/go/error_reporter_test.go
@@ -0,0 +1,187 @@
+package errorreporter_test
+
+import (
+ "encoding/json"
+ "errors"
+ "net/http"
+ "net/http/httptest"
+ "sync"
+ "testing"
+ "time"
+
+ errorreporter "pt.bitreport/errors-go"
+)
+
+// captureServer starts a test HTTP server that collects posted request bodies.
+func captureServer(t *testing.T) (*httptest.Server, *[]map[string]interface{}, *sync.Mutex) {
+ t.Helper()
+ var mu sync.Mutex
+ var bodies []map[string]interface{}
+
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ var body map[string]interface{}
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ t.Logf("decode error: %v", err)
+ return
+ }
+ mu.Lock()
+ bodies = append(bodies, body)
+ mu.Unlock()
+ w.WriteHeader(http.StatusOK)
+ }))
+ t.Cleanup(srv.Close)
+ return srv, &bodies, &mu
+}
+
+func TestReportError(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{Token: "test-tok", Endpoint: srv.URL})
+ errorreporter.ReportError(errors.New("something failed"), nil)
+ errorreporter.Flush()
+
+ mu.Lock()
+ defer mu.Unlock()
+ if len(*bodies) != 1 {
+ t.Fatalf("expected 1 request, got %d", len(*bodies))
+ }
+ events := (*bodies)[0]["events"].([]interface{})
+ if len(events) != 1 {
+ t.Fatalf("expected 1 event, got %d", len(events))
+ }
+ ev := events[0].(map[string]interface{})
+ if ev["level"] != "error" {
+ t.Errorf("level = %v, want error", ev["level"])
+ }
+ if ev["message"] != "something failed" {
+ t.Errorf("message = %v, want 'something failed'", ev["message"])
+ }
+ if ev["schema_version"].(float64) != 1 {
+ t.Errorf("schema_version = %v, want 1", ev["schema_version"])
+ }
+ if ev["stacktrace"] == "" {
+ t.Error("expected non-empty stacktrace")
+ }
+ ctx := ev["context"].(map[string]interface{})
+ if ctx["error_type"] == "" {
+ t.Error("expected non-empty error_type in context")
+ }
+}
+
+func TestReportMessage(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{Token: "test-tok", Endpoint: srv.URL})
+ errorreporter.ReportMessage("disk nearly full", "warning", map[string]interface{}{"used_pct": 95})
+ errorreporter.Flush()
+
+ mu.Lock()
+ defer mu.Unlock()
+ if len(*bodies) != 1 {
+ t.Fatalf("expected 1 request, got %d", len(*bodies))
+ }
+ ev := (*bodies)[0]["events"].([]interface{})[0].(map[string]interface{})
+ if ev["level"] != "warning" {
+ t.Errorf("level = %v, want warning", ev["level"])
+ }
+ if ev["message"] != "disk nearly full" {
+ t.Errorf("message = %v, want 'disk nearly full'", ev["message"])
+ }
+ ctx := ev["context"].(map[string]interface{})
+ if ctx["used_pct"].(float64) != 95 {
+ t.Errorf("used_pct = %v, want 95", ctx["used_pct"])
+ }
+}
+
+func TestProjectContext(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{
+ Token: "test-tok",
+ Endpoint: srv.URL,
+ ProjectName: "Test App",
+ ProjectSlug: "test-app",
+ GiteaRepo: "org/test-app",
+ })
+ errorreporter.ReportMessage("hello", "info", nil)
+ errorreporter.Flush()
+
+ mu.Lock()
+ defer mu.Unlock()
+ ctx := (*bodies)[0]["events"].([]interface{})[0].(map[string]interface{})["context"].(map[string]interface{})
+ if ctx["project_name"] != "Test App" {
+ t.Errorf("project_name = %v", ctx["project_name"])
+ }
+ if ctx["project_slug"] != "test-app" {
+ t.Errorf("project_slug = %v", ctx["project_slug"])
+ }
+ if ctx["gitea_repo"] != "org/test-app" {
+ t.Errorf("gitea_repo = %v", ctx["gitea_repo"])
+ }
+}
+
+func TestDisabledSkipsRequests(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{Token: "test-tok", Endpoint: srv.URL, Disabled: true})
+ errorreporter.ReportMessage("should not send", "error", nil)
+ errorreporter.Flush()
+
+ mu.Lock()
+ defer mu.Unlock()
+ if len(*bodies) != 0 {
+ t.Errorf("expected 0 requests when disabled, got %d", len(*bodies))
+ }
+}
+
+func TestNoTokenSkipsRequests(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{Token: "", Endpoint: srv.URL})
+ errorreporter.ReportMessage("no token", "error", nil)
+ errorreporter.Flush()
+
+ mu.Lock()
+ defer mu.Unlock()
+ if len(*bodies) != 0 {
+ t.Errorf("expected 0 requests without token, got %d", len(*bodies))
+ }
+}
+
+func TestAuthorizationHeader(t *testing.T) {
+ var capturedAuth string
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ capturedAuth = r.Header.Get("Authorization")
+ w.WriteHeader(http.StatusOK)
+ }))
+ t.Cleanup(srv.Close)
+
+ errorreporter.Init(errorreporter.Config{Token: "my-secret-token", Endpoint: srv.URL})
+ errorreporter.ReportMessage("auth check", "info", nil)
+ errorreporter.Flush()
+
+ if capturedAuth != "Bearer my-secret-token" {
+ t.Errorf("Authorization = %q, want 'Bearer my-secret-token'", capturedAuth)
+ }
+}
+
+func TestBatchFlushOnSize(t *testing.T) {
+ srv, bodies, mu := captureServer(t)
+
+ errorreporter.Init(errorreporter.Config{Token: "test-tok", Endpoint: srv.URL})
+ for i := 0; i < 25; i++ {
+ errorreporter.ReportMessage("msg", "info", nil)
+ }
+ // Allow time for background goroutine triggered by batch overflow
+ time.Sleep(200 * time.Millisecond)
+
+ mu.Lock()
+ defer mu.Unlock()
+ total := 0
+ for _, b := range *bodies {
+ total += len(b["events"].([]interface{}))
+ }
+ if total != 25 {
+ t.Errorf("expected 25 events total across batches, got %d", total)
+ }
+}
diff --git a/clients/go/examples/basic_usage.go b/clients/go/examples/basic_usage.go
new file mode 100644
index 0000000..475ee8a
--- /dev/null
+++ b/clients/go/examples/basic_usage.go
@@ -0,0 +1,46 @@
+//go:build ignore
+
+// Basic usage example for the BitReport Go error reporter.
+//
+// Run with:
+//
+// ERROR_REPORTING_TOKEN=your_token go run basic_usage.go
+package main
+
+import (
+ "errors"
+ "fmt"
+ "os"
+
+ errorreporter "pt.bitreport/errors-go"
+)
+
+func main() {
+ errorreporter.Init(errorreporter.Config{
+ Token: os.Getenv("ERROR_REPORTING_TOKEN"),
+ ProjectName: "My Go App",
+ ProjectSlug: "my-go-app",
+ })
+ defer errorreporter.Flush()
+
+ // Report a plain message
+ errorreporter.ReportMessage("Application started", "info", nil)
+
+ // Report a warning with extra context
+ errorreporter.ReportMessage("Cache miss", "warning", map[string]interface{}{
+ "cache_key": "user:42",
+ })
+
+ // Report an error
+ if err := riskyOperation(); err != nil {
+ errorreporter.ReportError(err, map[string]interface{}{
+ "operation": "riskyOperation",
+ })
+ }
+
+ fmt.Println("Events sent. Check your errors.bitreport.pt dashboard.")
+}
+
+func riskyOperation() error {
+ return errors.New("something went wrong")
+}
diff --git a/clients/go/go.mod b/clients/go/go.mod
new file mode 100644
index 0000000..5cb05a4
--- /dev/null
+++ b/clients/go/go.mod
@@ -0,0 +1,3 @@
+module pt.bitreport/errors-go
+
+go 1.21
diff --git a/clients/java/examples/BasicUsage.java b/clients/java/examples/BasicUsage.java
new file mode 100644
index 0000000..d9c1465
--- /dev/null
+++ b/clients/java/examples/BasicUsage.java
@@ -0,0 +1,40 @@
+import pt.bitreport.errors.ErrorReporter;
+
+import java.util.Map;
+
+/**
+ * Basic usage example for the BitReport Java error reporter.
+ *
+ * Compile and run:
+ * javac -cp path/to/bitreport-errors-1.0.0.jar BasicUsage.java
+ * ERROR_REPORTING_TOKEN=your_token java -cp .:path/to/bitreport-errors-1.0.0.jar BasicUsage
+ */
+public class BasicUsage {
+ public static void main(String[] args) {
+ ErrorReporter.init(ErrorReporter.Config.builder()
+ .token(System.getenv("ERROR_REPORTING_TOKEN"))
+ .projectName("My Java App")
+ .projectSlug("my-java-app")
+ .build());
+
+ // Always flush before the JVM exits
+ Runtime.getRuntime().addShutdownHook(new Thread(ErrorReporter::flush));
+
+ // Report a plain message
+ ErrorReporter.reportMessage("Application started", "info", null);
+
+ // Report a warning with context
+ ErrorReporter.reportMessage("Cache miss", "warning", Map.of("cache_key", "user:42"));
+
+ // Report a caught exception
+ try {
+ int result = Integer.parseInt("not-a-number");
+ } catch (NumberFormatException e) {
+ ErrorReporter.reportError(e, Map.of("input", "not-a-number"));
+ }
+
+ // Flush synchronously so the example does not exit with pending events
+ ErrorReporter.flush();
+ System.out.println("Events sent. Check your errors.bitreport.pt dashboard.");
+ }
+}
diff --git a/clients/java/pom.xml b/clients/java/pom.xml
new file mode 100644
index 0000000..9dd939d
--- /dev/null
+++ b/clients/java/pom.xml
@@ -0,0 +1,46 @@
+
+
+ 4.0.0
+
+ pt.bitreport
+ bitreport-errors
+ 1.0.0
+ jar
+
+ BitReport Error Reporter
+ Lightweight Java client for errors.bitreport.pt
+ https://errors.bitreport.pt
+
+
+ 11
+ ${java.version}
+ ${java.version}
+ UTF-8
+ 5.10.2
+
+
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.version}
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.2.5
+
+
+
+
diff --git a/clients/java/src/main/java/pt/bitreport/errors/ErrorReporter.java b/clients/java/src/main/java/pt/bitreport/errors/ErrorReporter.java
new file mode 100644
index 0000000..d9aa1a5
--- /dev/null
+++ b/clients/java/src/main/java/pt/bitreport/errors/ErrorReporter.java
@@ -0,0 +1,366 @@
+package pt.bitreport.errors;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * BitReport Error Reporter — Java client for errors.bitreport.pt ingest API.
+ *
+ *
Drop this file into any Java 11+ project. Zero external dependencies.
+ *
+ *
Usage:
+ *
{@code
+ * ErrorReporter.init(ErrorReporter.Config.builder()
+ * .token(System.getenv("ERROR_REPORTING_TOKEN"))
+ * .projectSlug("my-java-app")
+ * .build());
+ *
+ * try {
+ * riskyOperation();
+ * } catch (Exception e) {
+ * ErrorReporter.reportError(e, Map.of("operation", "riskyOperation"));
+ * }
+ *
+ * // Before shutdown:
+ * ErrorReporter.flush();
+ * }
+ *
+ * Environment variables:
+ *
+ * - {@code ERROR_REPORTING_TOKEN} — ingest API key (required)
+ * - {@code ERROR_REPORTING_ENDPOINT} — base URL (default: https://errors.bitreport.pt)
+ * - {@code ERROR_REPORTING_DISABLED} — set to "1" to disable
+ * - {@code ERROR_REPORTING_PROJECT_NAME} — display name (optional)
+ * - {@code ERROR_REPORTING_PROJECT_SLUG} — stable product slug (optional)
+ * - {@code ERROR_REPORTING_GITEA_REPO} — canonical owner/repo on Gitea (optional)
+ *
+ */
+public final class ErrorReporter {
+
+ private static final String DEFAULT_ENDPOINT = "https://errors.bitreport.pt";
+ private static final int BATCH_SIZE = 25;
+ private static final long FLUSH_MS = 5_000L;
+ private static final int TIMEOUT_MS = 8_000;
+ private static final DateTimeFormatter ISO_FMT =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneOffset.UTC);
+
+ // --- Config ---
+
+ public static final class Config {
+ final String token;
+ final String endpoint;
+ final boolean disabled;
+ final String projectName;
+ final String projectSlug;
+ final String giteaRepo;
+
+ private Config(Builder b) {
+ this.token = coalesce(b.token, env("ERROR_REPORTING_TOKEN"));
+ this.endpoint = stripTrailingSlash(
+ coalesce(b.endpoint, env("ERROR_REPORTING_ENDPOINT"), DEFAULT_ENDPOINT));
+ this.disabled = b.disabled || "1".equals(env("ERROR_REPORTING_DISABLED"));
+ this.projectName = coalesce(b.projectName, env("ERROR_REPORTING_PROJECT_NAME"));
+ this.projectSlug = coalesce(b.projectSlug, env("ERROR_REPORTING_PROJECT_SLUG"));
+ this.giteaRepo = coalesce(b.giteaRepo, env("ERROR_REPORTING_GITEA_REPO"));
+ }
+
+ public static Builder builder() { return new Builder(); }
+
+ public static final class Builder {
+ private String token = "";
+ private String endpoint = "";
+ private boolean disabled = false;
+ private String projectName = "";
+ private String projectSlug = "";
+ private String giteaRepo = "";
+
+ public Builder token(String v) { this.token = v != null ? v : ""; return this; }
+ public Builder endpoint(String v) { this.endpoint = v != null ? v : ""; return this; }
+ public Builder disabled(boolean v) { this.disabled = v; return this; }
+ public Builder projectName(String v) { this.projectName = v != null ? v : ""; return this; }
+ public Builder projectSlug(String v) { this.projectSlug = v != null ? v : ""; return this; }
+ public Builder giteaRepo(String v) { this.giteaRepo = v != null ? v : ""; return this; }
+ public Config build() { return new Config(this); }
+ }
+ }
+
+ // --- Shared state ---
+
+ private static final AtomicReference CONFIG = new AtomicReference<>(
+ Config.builder().build());
+
+ private static final List