Skip to content

Commit

Permalink
fix: added console log instrumentation disable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ndesai-newrelic committed Sep 5, 2024
1 parent 903992f commit 0a0bda7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

# 7.0.1

## New Features and Improvements

Added a console log disable flag to optionally turn off console log instrumentation. This addresses loading issues some customers were experiencing with certain JavaScript files.

## Improvements

- Native Android agent updated to version 7.5.1
- Native iOS agent updated to version 7.5.1

# 7.0.0

## New Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newrelic-cordova-plugin",
"version": "7.0.0",
"version": "7.0.1",
"description": "New Relic Cordova Plugin for iOS and Android",
"repo": "https://github.com/newrelic/newrelic-cordova-plugin/",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="newrelic-cordova-plugin" version="7.0.0">
id="newrelic-cordova-plugin" version="7.0.1">
<name>NewRelic</name>
<description>New Relic Cordova Plugin for iOS and Android</description>
<author>New Relic</author>
Expand Down Expand Up @@ -79,7 +79,7 @@
<source url="https://cdn.cocoapods.org/" />
</config>
<pods use-frameworks="true">
<pod name="NewRelicAgent" spec="~>7.5.0" />
<pod name="NewRelicAgent" spec="~>7.5.1" />
</pods>
</podspec>

Expand All @@ -89,7 +89,7 @@

<platform name="android">
<preference name="ANDROID_APP_TOKEN" default="x" />
<preference name="ANDROID_AGENT_VER" default="7.5.+" />
<preference name="ANDROID_AGENT_VER" default="7.5.1" />

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
6 changes: 6 additions & 0 deletions src/android/NewRelicCordovaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ public void run() {
callbackContext.success(headers);
break;
}
case "getConsoleLogFeatureFlag": {
JSONObject consoleLogEnabled = new JSONObject();
consoleLogEnabled.put("consoleLogEnabled",preferences.getString("console_logs_enabled", "true"));
callbackContext.success(consoleLogEnabled);
break;
}
case "logInfo": {
final String message = args.getString(0);
NewRelic.logInfo(message);
Expand Down
2 changes: 2 additions & 0 deletions src/ios/NewRelicCordovaPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@

- (void)getHTTPHeadersTrackingFor:(CDVInvokedUrlCommand *) command;

- (void)getConsoleLogFeatureFlag:(CDVInvokedUrlCommand *) command;

- (void)generateDistributedTracingHeaders:(CDVInvokedUrlCommand *)command;

- (void)logInfo:(CDVInvokedUrlCommand *)command;
Expand Down
8 changes: 8 additions & 0 deletions src/ios/NewRelicCordovaPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ - (void)getHTTPHeadersTrackingFor:(CDVInvokedUrlCommand *) command{

}

- (void)getConsoleLogFeatureFlag:(CDVInvokedUrlCommand *) command{
NSDictionary* config = self.commandDelegate.settings;
CDVPluginResult* pluginResult = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: @{@"consoleLogEnabled": config[@"console_logs_enabled"]}];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

}

- (void)generateDistributedTracingHeaders:(CDVInvokedUrlCommand *)command {

CDVPluginResult* pluginResult = nil;
Expand Down
17 changes: 13 additions & 4 deletions www/js/newrelic.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
* @param args An array of arguments that are passed to the console log.
*/
sendConsole(type, args) {

NewRelic.getConsoleLogFeatureFlag().then((flag) => {

if(flag.consoleLogEnabled === 'true') {
const argsStr = JSON.stringify(args, getCircularReplacer());

switch (type) {
Expand All @@ -149,7 +153,8 @@
case 'assert':
this.logVerbose(`[CONSOLE][ASSERT]${argsStr}`);
break;
}
}}
});
},

send(name, args) {
Expand Down Expand Up @@ -362,6 +367,13 @@
});
},

getConsoleLogFeatureFlag: function (cb, fail) {

return new Promise(function (cb, fail) {
cordova.exec(cb, fail, "NewRelicCordovaPlugin", "getConsoleLogFeatureFlag");
});
},

generateDistributedTracingHeaders: function (cb, fail) {

return new Promise(function (cb, fail) {
Expand Down Expand Up @@ -504,8 +516,6 @@

if (this.readyState === this.HEADERS_RECEIVED) {
const contentTypeString = this.getResponseHeader('Content-Type');


if (this.getAllResponseHeaders()) {
const responseHeaders = this.getAllResponseHeaders().split('\r\n');
const responseHeadersDictionary = {};
Expand Down Expand Up @@ -582,7 +592,6 @@
var options = arguments[1];

return NewRelic.getHTTPHeadersTrackingFor().then((trackingHeadersList)=>{
console.log(trackingHeadersList);
return NewRelic.generateDistributedTracingHeaders().then((headers) => {
console.log(headers);
networkRequest.startTime = Date.now();
Expand Down

0 comments on commit 0a0bda7

Please sign in to comment.