From c4223d55e89b5480b7d1a3e0498e19a9b5221665 Mon Sep 17 00:00:00 2001 From: ndesai-newrelic <89222514+ndesai-newrelic@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:24:14 -0500 Subject: [PATCH 1/2] Console debug issue (#185) * merge from main (#167) * fix: disabled Interaction Flag Default false for React Native Agent (#165) * chore(deps): bump rexml in /NewRelicExampleApp/React-Native-Test-App (#163) Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.2.8. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.2.8) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: added backgroudnReporting and NewEventSystem Configuration (#168) #159 * chore: uodate Native Android Agent and Expo configs (#175) #172 * test: fix alphabetical order and add log values in jest mock (#176) --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Felipe Mengatto * fix: fix the dependancies issue in 1.4.0 #180 * feat: add distributedTracing feature Flag * docs: release 1.4.2 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Felipe Mengatto --- CHANGELOG.md | 12 +++ README.md | 74 ++++++++++++------- .../com/NewRelic/NRMModularAgentModule.java | 6 ++ index.js | 8 +- ios/bridge/NRMModularAgent.m | 4 + new-relic/__tests__/new-relic.spec.js | 9 ++- package.json | 4 +- 7 files changed, 81 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 987d516..bdc412a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 1.4.2 + +## New Features + +1. **Distributed Tracing Control** + - Introducing a new feature flag: `distributedTracingEnabled`, providing the ability to enable or disable distributed tracing functionality. + +## Bug Fixes + +- Addressed an issue where console debug logs were incorrectly displayed as console errors. + + ## 1.4.1 ## New Features diff --git a/README.md b/README.md index 00d18a3..120d14c 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,10 @@ import {Platform} from 'react-native'; // iOS Specific // Optional: Enable or disable to use our new, more stable, event system for iOS agent. - newEventSystemEnabled:false + newEventSystemEnabled:false, + + // Optional: Enable or disable distributed tracing. + distributedTracingEnabled: true, }; @@ -126,33 +129,50 @@ AppToken is platform-specific. You need to generate the seprate token for Androi ### Android Setup 1. Install the New Relic native Android agent ([instructions here](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/install-android-apps-gradle-android-studio)). -2. Update `build.gradle`: - ```groovy - buildscript { - ... - repositories { - ... - mavenCentral() - } - dependencies { - ... - classpath "com.newrelic.agent.android:agent-gradle-plugin:7.5.0" - } - } - ``` - -3. Update `app/build.gradle`: -```groovy -plugins { - id 'newrelic' -} -``` -For legacy plugin application: -```groovy -apply plugin: 'newrelic' -``` -4. Make sure your app requests INTERNET and ACCESS_NETWORK_STATE permissions by adding these lines to your `AndroidManifest.xml` +2. Add the following changes to Apply Gradle Plugin: + +If you are using Plugins DSL to Apply the NewRelic Gradle Plugin, make the following changes: + +In android/settings.gradle: + ```groovy + plugins { + id "com.android.application" version "7.4.2" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "com.newrelic.agent.android" version "7.5.1" apply false // <-- include this + } + ``` + +In android/app/build.gradle: + ```groovy + plugins { + id "com.android.application" + id "kotlin-android" + id "com.newrelic.agent.android" //<-- include this + } + ``` + +Or, if you are using the traditional way to apply the plugin: + ```groovy + buildscript { + ... + repositories { + ... + mavenCentral() + } + dependencies { + ... + classpath "com.newrelic.agent.android:agent-gradle-plugin:7.5.1" + } + } + ``` + +Apply the NewRelic plugin to the top of the android/app/build.gradle file: + ```groovy + apply plugin: "com.android.application" + apply plugin: 'newrelic' // <-- include this + ``` +3. Make sure your app requests INTERNET and ACCESS_NETWORK_STATE permissions by adding these lines to your `AndroidManifest.xml` ``` diff --git a/android/src/main/java/com/NewRelic/NRMModularAgentModule.java b/android/src/main/java/com/NewRelic/NRMModularAgentModule.java index 1d2fad1..d10b38a 100644 --- a/android/src/main/java/com/NewRelic/NRMModularAgentModule.java +++ b/android/src/main/java/com/NewRelic/NRMModularAgentModule.java @@ -118,6 +118,12 @@ public void startAgent(String appKey, String agentVersion, String reactNativeVer NewRelic.disableFeature(FeatureFlag.BackgroundReporting); } + if ((Boolean) agentConfig.get("distributedTracingEnabled")) { + NewRelic.enableFeature(FeatureFlag.DistributedTracing); + } else { + NewRelic.disableFeature(FeatureFlag.DistributedTracing); + } + Map strToLogLevel = new HashMap<>(); strToLogLevel.put("ERROR", AgentLog.ERROR); strToLogLevel.put("WARNING", AgentLog.WARN); diff --git a/index.js b/index.js index a6581b6..b0f8bc6 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,8 @@ class NewRelic { fedRampEnabled: false, offlineStorageEnabled: true, backgroundReportingEnabled: false, - newEventSystemEnabled: true + newEventSystemEnabled: false, + distributedTracingEnabled: true, }; } @@ -638,6 +639,7 @@ class NewRelic { const defaultLog = console.log; const defaultWarn = console.warn; const defaultError = console.error; + const defaultDebug = console.debug; const self = this; console.log = function () { @@ -655,7 +657,7 @@ class NewRelic { console.debug = function () { self.sendConsole('debug', arguments); - defaultError.apply(console, arguments); + defaultDebug.apply(console, arguments); } @@ -675,7 +677,7 @@ class NewRelic { }else { this.logInfo("[CONSOLE][LOG]" +argsStr); } - + } } diff --git a/ios/bridge/NRMModularAgent.m b/ios/bridge/NRMModularAgent.m index 71a20f9..1308e5d 100644 --- a/ios/bridge/NRMModularAgent.m +++ b/ios/bridge/NRMModularAgent.m @@ -78,6 +78,10 @@ - (dispatch_queue_t)methodQueue{ if ([[agentConfig objectForKey:@"newEventSystemEnabled"]boolValue] == YES) { [NewRelic enableFeatures:NRFeatureFlag_NewEventSystem]; } + + if ([[agentConfig objectForKey:@"distributedTracingEnabled"]boolValue] == NO) { + [NewRelic enableFeatures:NRFeatureFlag_DistributedTracing]; + } //Default is NRLogLevelWarning NRLogLevels logLevel = NRLogLevelWarning; diff --git a/new-relic/__tests__/new-relic.spec.js b/new-relic/__tests__/new-relic.spec.js index f695965..85aee81 100644 --- a/new-relic/__tests__/new-relic.spec.js +++ b/new-relic/__tests__/new-relic.spec.js @@ -85,9 +85,9 @@ describe('New Relic', () => { expect(NewRelic.agentConfiguration.fedRampEnabled).toBe(false); expect(NewRelic.agentConfiguration.nativeCrashReportingEnabled).toBe(true); expect(NewRelic.agentConfiguration.offlineStorageEnabled).toBe(true); - expect(NewRelic.agentConfiguration.newEventSystemEnabled).toBe(true); + expect(NewRelic.agentConfiguration.newEventSystemEnabled).toBe(false); expect(NewRelic.agentConfiguration.backgroundReportingEnabled).toBe(false); - + expect(NewRelic.agentConfiguration.distributedTracingEnabled).toBe(true); }); it('should change default agent configuration when configuration is passed into the start call', () => { @@ -107,7 +107,8 @@ describe('New Relic', () => { nativeCrashReportingEnabled:false, offlineStorageEnabled:false, newEventSystemEnabled:false, - backgroundReportingEnabled:true + backgroundReportingEnabled:true, + distributedTracingEnabled: false }; NewRelic.startAgent("12345", customerConfiguration); @@ -128,7 +129,7 @@ describe('New Relic', () => { expect(NewRelic.agentConfiguration.nativeCrashReportingEnabled).toBe(false); expect(NewRelic.agentConfiguration.newEventSystemEnabled).toBe(false); expect(NewRelic.agentConfiguration.backgroundReportingEnabled).toBe(true); - + expect(NewRelic.agentConfiguration.distributedTracingEnabled).toBe(false); }); it('should set the analytics event flag', () => { diff --git a/package.json b/package.json index 99fc261..8773eb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "newrelic-react-native-agent", - "version": "1.4.1", + "version": "1.4.2", "description": "A New Relic Mobile Agent for React Native", "main": "./index.js", "types": "./dist/index.d.ts", @@ -92,7 +92,7 @@ }, "sdkVersions": { "ios": { - "newrelic": "7.5.0" + "newrelic": "~>7.5.1" }, "android": { "newrelic": "7.5.+", From 7a5e709149f53ab274fc3c572b0ba4f2b70e740a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:40:49 -0500 Subject: [PATCH 2/2] chore(deps): bump rexml in /NewRelicExampleApp/React-Native-Test-App (#191) Bumps [rexml](https://github.com/ruby/rexml) from 3.2.8 to 3.3.3. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.8...v3.3.3) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- NewRelicExampleApp/React-Native-Test-App/Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NewRelicExampleApp/React-Native-Test-App/Gemfile.lock b/NewRelicExampleApp/React-Native-Test-App/Gemfile.lock index a286005..7ced230 100644 --- a/NewRelicExampleApp/React-Native-Test-App/Gemfile.lock +++ b/NewRelicExampleApp/React-Native-Test-App/Gemfile.lock @@ -71,21 +71,21 @@ GEM nap (1.1.0) netrc (0.11.0) public_suffix (4.0.7) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.3.3) + strscan ruby-macho (2.5.1) strscan (3.1.0) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.22.0) + xcodeproj (1.25.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - rexml (~> 3.2.4) + rexml (>= 3.3.2, < 4.0) PLATFORMS ruby