Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Fetch Instrumentation and HttpHeader Tracking #79

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ typings/
.env
.idea

package-lock.json
package-lock.json
.vscode/
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

# 6.2.5

### New in this release
* fetch instrumentation for http request
* Adds configurable request header instrumentation to network events
The agent will now produce network event attributes for select header values if the headers are detected on the request. The header names to instrument are passed into the agent when started.
* Upgrading the native iOS agent to version 7.4.8.
* Upgrading the native Android agent to version 7.2.0.


# 6.2.4

### New in this release
* Upgraded native Android agent to v7.1.0

# 6.2.3

### New in this release
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ By default, these configurations are already set to true on agent start.
NewRelic.shutdown();
```

### [addHTTPHeadersTrackingFor(...)](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers/)
> This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in NR1.
```js
NewRelic.addHTTPHeadersTrackingFor(["Car"]);
```

### [httpRequestBodyCaptureEnabled](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/android-agent-configuration-feature-flags/#ff-withHttpResponseBodyCaptureEnabled)(enabled: boolean) : void;
> Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.
```js
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.4",
"version": "6.2.5",
"description": "New Relic Cordova Plugin for iOS and Android",
"repo": "https://github.com/newrelic/newrelic-cordova-plugin/",
"scripts": {
Expand Down
12 changes: 6 additions & 6 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.4">
id="newrelic-cordova-plugin" version="6.2.5">
<name>NewRelic</name>
<description>New Relic Cordova Plugin for iOS and Android</description>
<author>New Relic</author>
Expand All @@ -18,16 +18,16 @@
<engine name="cordova-android" version=">=5.0.0" />
</engines>

<preference name="PLUGIN_VERSION" default="6.2.4" />
<preference name="PLUGIN_VERSION" default="6.2.5" />
<preference name="CRASH_REPORTING_ENABLED" default="true" />
<preference name="DISTRIBUTED_TRACING_ENABLED" default="true" />
<preference name="INTERACTION_TRACING_ENABLED" default="true" />
<preference name="DEFAULT_INTERACTIONS_ENABLED" default="true" />
<preference name="LOGGING_ENABLED" default="true" />
<preference name="LOG_LEVEL" default="default" />
<preference name="WEB_VIEW_INSTRUMENTATION" default="true" />
<preference name="COLLECTOR_ADDRESS" default="mobile-collector.newrelic.com" />
<preference name="CRASH_COLLECTOR_ADDRESS" default="mobile-crash.newrelic.com" />
<preference name="COLLECTOR_ADDRESS" default="x" />
<preference name="CRASH_COLLECTOR_ADDRESS" default="x" />
<preference name="FEDRAMP_ENABLED" default="false" />
<preference name="CONSOLE_LOGS_ENABLED" default="true" />

Expand Down Expand Up @@ -71,7 +71,7 @@
<source url="https://cdn.cocoapods.org/" />
</config>
<pods use-frameworks="true">
<pod name="NewRelicAgent" spec="7.4.6" />
<pod name="NewRelicAgent" spec="7.4.8" />
</pods>
</podspec>

Expand All @@ -81,7 +81,7 @@

<platform name="android">
<preference name="ANDROID_APP_TOKEN" default="x" />
<preference name="ANDROID_AGENT_VER" default="7.0.0" />
<preference name="ANDROID_AGENT_VER" default="7.2.0" />

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
182 changes: 121 additions & 61 deletions src/android/NewRelicCordovaPlugin.java

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/ios/NewRelicCordovaPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@

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

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

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

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

@end
27 changes: 27 additions & 0 deletions src/ios/NewRelicCordovaPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,31 @@ - (void)shutdown:(CDVInvokedUrlCommand *)command {
[NewRelic shutdown];
}

- (void)addHTTPHeadersTrackingFor:(CDVInvokedUrlCommand *) command{
NSArray* headers = [command.arguments objectAtIndex:0];
[NewRelic addHTTPHeaderTrackingFor:headers];

}

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

CDVPluginResult* pluginResult = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: @{@"headersList": @"[]"}];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

}

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

CDVPluginResult* pluginResult = nil;

NSDictionary<NSString*,NSString*>* headers = [NewRelic generateDistributedTracingHeaders];

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:headers];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

}

@end
3 changes: 3 additions & 0 deletions types/newrelic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ export function httpRequestBodyCaptureEnabled(
cb: any,
fail: any
): void;
export function addHTTPHeadersTrackingFor(name: string, cb: any, fail: any,headers:string[]): void;
export function getHTTPHeadersTrackingFor(name: string, cb: any, fail: any): Promise<any>;
export function generateDistributedTracingHeaders(name: string, cb: any, fail: any): Promise<any>;
Loading
Loading