From 637ce2fc23c19871466f64968924398ab62f76da Mon Sep 17 00:00:00 2001 From: Konrad Dysput Date: Fri, 27 Oct 2023 16:44:41 +0200 Subject: [PATCH] Add session attribute and backtrace reporter name to every error report --- .../models/json/BacktraceAttributes.java | 18 +++--------------- .../library/services/BacktraceMetrics.java | 2 -- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/backtrace-library/src/main/java/backtraceio/library/models/json/BacktraceAttributes.java b/backtrace-library/src/main/java/backtraceio/library/models/json/BacktraceAttributes.java index 66921073..ebfde757 100644 --- a/backtrace-library/src/main/java/backtraceio/library/models/json/BacktraceAttributes.java +++ b/backtrace-library/src/main/java/backtraceio/library/models/json/BacktraceAttributes.java @@ -50,7 +50,7 @@ public class BacktraceAttributes { /** * Metrics session ID */ - private static String sessionId; + private static String sessionId = UUID.randomUUID().toString(); /** * Create instance of Backtrace Attribute @@ -84,12 +84,6 @@ public BacktraceAttributes(Context context, BacktraceReport report, Map getComplexAttributes() { @@ -126,6 +120,8 @@ private void setAppInformation() { // But we keep version attribute name as to not break any customer workflows this.attributes.put("version", version); } + this.attributes.put("application.session", sessionId); + this.attributes.put("backtrace.agent", "backtrace-android"); this.attributes.put("backtrace.version", BacktraceClient.version); } @@ -257,12 +253,4 @@ public Map getAllAttributes() { attributes.putAll(this.complexAttributes); return attributes; } - - public static void enableMetrics() { - BacktraceAttributes.isMetricsEnabled = true; - - // Create a session ID for metrics session tracking - String sessionId = UUID.randomUUID().toString(); - BacktraceAttributes.sessionId = sessionId; - } } diff --git a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceMetrics.java b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceMetrics.java index a61b08d7..d1fc1043 100644 --- a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceMetrics.java +++ b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceMetrics.java @@ -160,8 +160,6 @@ public void enable(BacktraceMetricsSettings settings, String uniqueEventName) { } setStartupUniqueEventName(uniqueEventName); this.settings = settings; - BacktraceAttributes.enableMetrics(); - try { startMetricsEventHandlers(backtraceApi); sendStartupEvent();