Skip to content

Commit

Permalink
Nr 258545 log forwarding (#95)
Browse files Browse the repository at this point in the history
* feat:added log forwarding for cordova.

* feat: log forwarding for mobile
  • Loading branch information
ndesai-newrelic authored Jul 22, 2024
1 parent 539f3f9 commit 852195b
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 102 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

# 7.0.0

## New Features

1. Application Exit Information
- Added ApplicationExitInfo to data reporting
- Enabled by default

2. Log Forwarding to New Relic
- Implement static API for sending logs to New Relic
- Can be enabled/disabled in your mobile application's entity settings page

## Improvements

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

# 6.2.10

* Improvements
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,51 @@ By default, these configurations are already set to true on agent start.
NewRelic.httpRequestBodyCaptureEnabled(true);
```
## [logInfo] (message: string): void;
> Logs an informational message.
```js
NewRelic.logInfo("User logged in successfully");
```
## [logDebug] (message: string): void;
> Logs a debug message.
```js
NewRelic.logDebug("Debug message");
```
## [logVerbose] (message: string): void;
> Logs a verbose message, typically used for extensive informational events that are useful in tracing the application's execution in a more detailed manner.
```js
NewRelic.logVerbose("Verbose message detailing step-by-step execution");
```
## [logWarn] (message: string): void;
> Logs a warning message. Warning messages are typically used to indicate a potential issue or to highlight situations that are not necessarily errors, but which may require attention or could lead to errors if ignored.
```js
NewRelic.logWarn("Warning message indicating a potential issue");
```
## [logError] (message: string): void;
> Logs an error message. Error messages are used to indicate a failure or problem that has occurred in the application. These are critical messages that usually require immediate attention.
```js
NewRelic.logError("Error message indicating a failure");
```
## [log] (level: string, message: string): void;
> Logs a message with a specified level. The level indicates the severity or importance of the message. Common levels include "info", "warn", "error", "debug", and "verbose".
```js
NewRelic.log("INFO", "User logged in successfully");
```
## [logAttributes] (attributes: {[key: string]: boolean | number | string}): void;
> Logs multiple attributes at once by passing a map of key-value pairs. This method allows for the efficient addition of contextual information to logs, enhancing the diagnostic capability of logged events.
```js
NewRelic.logAttributes({
"userID": 12345,
"sessionID": "abcde12345",
"isLoggedIn": true,
"message":"this is test",
"level":"INFO"
});
```
## Error Reporting
### recordError(err: [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error), attributes?: {[key: string]: boolean | number | string}) : void;
Records JavaScript errors for Cordova. It is useful to add this method by adding it to the error handler of the framework that you are using. Here are some examples below:
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": "6.2.10",
"version": "7.0.0",
"description": "New Relic Cordova Plugin for iOS and Android",
"repo": "https://github.com/newrelic/newrelic-cordova-plugin/",
"scripts": {
Expand Down
13 changes: 8 additions & 5 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="6.2.10">
id="newrelic-cordova-plugin" version="7.0.0">
<name>NewRelic</name>
<description>New Relic Cordova Plugin for iOS and Android</description>
<author>New Relic</author>
Expand All @@ -18,7 +18,7 @@
<engine name="cordova-android" version=">=5.0.0" />
</engines>

<preference name="PLUGIN_VERSION" default="6.2.9" />
<preference name="PLUGIN_VERSION" default="7.0.0" />
<preference name="CRASH_REPORTING_ENABLED" default="true" />
<preference name="DISTRIBUTED_TRACING_ENABLED" default="true" />
<preference name="INTERACTION_TRACING_ENABLED" default="true" />
Expand All @@ -33,6 +33,8 @@
<preference name="CONSOLE_LOGS_ENABLED" default="true" />
<preference name="NEW_EVENT_SYSTEM_ENABLED" default="true" />
<preference name="BACKGROUND_REPORTING_ENABLED" default="false" />
<preference name="LOG_REPORTING_ENABLED" default="true" />


<platform name="ios">
<preference name="IOS_APP_TOKEN" default="x" />
Expand All @@ -59,6 +61,7 @@
<preference name="CONSOLE_LOGS_ENABLED" value="$CONSOLE_LOGS_ENABLED" />
<preference name="NEW_EVENT_SYSTEM_ENABLED" value="$NEW_EVENT_SYSTEM_ENABLED" />
<preference name="BACKGROUND_REPORTING_ENABLED" value="$BACKGROUND_REPORTING_ENABLED" />
<preference name="LOG_REPORTING_ENABLED" value="$LOG_REPORTING_ENABLED" />
<param name="ios-package" value="NewRelicCordovaPlugin" onload="true" />
</feature>
</config-file>
Expand All @@ -76,7 +79,7 @@
<source url="https://cdn.cocoapods.org/" />
</config>
<pods use-frameworks="true">
<pod name="NewRelicAgent" spec="7.4.12" />
<pod name="NewRelicAgent" spec="7.5.0" />
</pods>
</podspec>

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

<platform name="android">
<preference name="ANDROID_APP_TOKEN" default="x" />
<preference name="ANDROID_AGENT_VER" default="7.3.1" />
<preference name="ANDROID_AGENT_VER" default="7.5.0" />

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -118,7 +121,7 @@
<preference name="CONSOLE_LOGS_ENABLED" value="$CONSOLE_LOGS_ENABLED" />
<preference name="NEW_EVENT_SYSTEM_ENABLED" value="$NEW_EVENT_SYSTEM_ENABLED" />
<preference name="BACKGROUND_REPORTING_ENABLED" value="$BACKGROUND_REPORTING_ENABLED" />

<preference name="LOG_REPORTING_ENABLED" value="$LOG_REPORTING_ENABLED" />
</config-file>

<source-file src="src/android/NewRelicCordovaPlugin.java"
Expand Down
Loading

0 comments on commit 852195b

Please sign in to comment.