From 5b9d3bebad74989caa34362d68a6e8008e92a5d4 Mon Sep 17 00:00:00 2001 From: ndesai Date: Mon, 30 Sep 2024 16:26:00 -0500 Subject: [PATCH] fix: log attributes method is throwing expection in android --- CHANGELOG.md | 9 ++++ .../Editor/TestUnityDependencies.xml | 6 +-- com.newrelic.agent/Scripts/NewRelicAgent.cs | 45 ++++++++++++++++++- package.json | 2 +- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb65fb..153f57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.4.1 + + +## Improvements + +- Native Android agent updated to version 7.6.0 +- Native iOS agent updated to version 7.5.2 +- Bug fixes for Log Attributes method + ## 1.4.0 ## New Features diff --git a/com.newrelic.agent/Editor/TestUnityDependencies.xml b/com.newrelic.agent/Editor/TestUnityDependencies.xml index e1a77f9..1b3b8dd 100644 --- a/com.newrelic.agent/Editor/TestUnityDependencies.xml +++ b/com.newrelic.agent/Editor/TestUnityDependencies.xml @@ -1,11 +1,11 @@ - - + + - + https://github.com/CocoaPods/Specs diff --git a/com.newrelic.agent/Scripts/NewRelicAgent.cs b/com.newrelic.agent/Scripts/NewRelicAgent.cs index e173551..ecfb8d9 100644 --- a/com.newrelic.agent/Scripts/NewRelicAgent.cs +++ b/com.newrelic.agent/Scripts/NewRelicAgent.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading; using UnityEngine.SceneManagement; +using System.Collections; #if UNITY_IPHONE || UNITY_ANDROID using NewRelic.Native; #endif @@ -749,7 +750,7 @@ static public void NoticeNetworkFailure(string url, { if (validatePluginImpl()) { - instance.agentInstance.noticeNetworkFailure(url, httpMethod, startTime,endTime, failureCode, message); + instance.agentInstance.noticeNetworkFailure(url, httpMethod, startTime, endTime, failureCode, message); } } @@ -1041,10 +1042,13 @@ static public void Log(NewRelicAgent.AgentLogLevel level, String message) { if (validatePluginImpl()) { + String logLevel = LogLevelString(level); instance.agentInstance.Log(level, message); } } + + /// /// Logs a set of attributes. /// @@ -1053,11 +1057,50 @@ static public void LogAttributes(Dictionary attributes) { if (validatePluginImpl()) { + + + + if ((attributes.ContainsKey("level") && attributes.GetValueOrDefault("level").GetType() == typeof(AgentLogLevel))) + { + attributes["level"] = LogLevelString((AgentLogLevel)attributes.GetValueOrDefault("level")); + } + + + instance.agentInstance.LogAttributes(attributes); } } + public static String LogLevelString(AgentLogLevel agentLogLevel) + { + + String logLevel = "INFO"; + + if (agentLogLevel.Equals(AgentLogLevel.DEBUG)) + { + logLevel = "DEBUG"; + } + else if (agentLogLevel.Equals(AgentLogLevel.ERROR)) + { + logLevel = "ERROR"; + } + else if (agentLogLevel.Equals(AgentLogLevel.INFO)) + { + logLevel = "INFO"; + } + else if (agentLogLevel.Equals(AgentLogLevel.VERBOSE)) + { + logLevel = "VERBOSE"; + } + else if (agentLogLevel.Equals(AgentLogLevel.WARNING)) + { + logLevel = "WARN"; + } + + + return logLevel; + } } } diff --git a/package.json b/package.json index 2a46ef6..fc0c72a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.newrelic.agent", - "version": "1.4.0", + "version": "1.4.1", "displayName": "NewRelic SDK", "description": "NewRelic's Unity SDK lets you bring the deep, introspective and native debugging power of NewRelic into your Unity game or application.", "unity": "2019.1",