Skip to content

Commit

Permalink
fix: ios app crash when the Cordova agent receives responses in the f…
Browse files Browse the repository at this point in the history
…orm of blobs or array buffers (newrelic#86)
  • Loading branch information
ndesai-newrelic authored May 1, 2024
1 parent d08b005 commit 7792e72
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

# 6.2.9
* A crash issue in the iOS app has been resolved when the Cordova agent receives responses in the form of blobs or array buffers.
* The native iOS agent has been updated to version 7.4.11, which brings performance enhancements and bug fixes.
* Similarly, the native Android agent has been upgraded to version 7.3.1, improving stability and introducing new features.


# 6.2.8
*
* Updated native iOS Agent: We've upgraded the native iOS agent to version 7.4.10, which includes performance improvements and bug fixes.
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.8",
"version": "6.2.9",
"description": "New Relic Cordova Plugin for iOS and Android",
"repo": "https://github.com/newrelic/newrelic-cordova-plugin/",
"scripts": {
Expand Down
8 changes: 4 additions & 4 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.8">
id="newrelic-cordova-plugin" version="6.2.9">
<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.8" />
<preference name="PLUGIN_VERSION" default="6.2.9" />
<preference name="CRASH_REPORTING_ENABLED" default="true" />
<preference name="DISTRIBUTED_TRACING_ENABLED" default="true" />
<preference name="INTERACTION_TRACING_ENABLED" default="true" />
Expand Down Expand Up @@ -73,7 +73,7 @@
<source url="https://cdn.cocoapods.org/" />
</config>
<pods use-frameworks="true">
<pod name="NewRelicAgent" spec="7.4.10" />
<pod name="NewRelicAgent" spec="7.4.11" />
</pods>
</podspec>

Expand All @@ -83,7 +83,7 @@

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

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
4 changes: 2 additions & 2 deletions src/android/NewRelicCordovaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
traceHeadersMap = new Gson().fromJson(String.valueOf(traceAttributes), Map.class);
}

JSONObject params = args.getJSONObject(8);
Object params = args.get(8);
Map<String,String> paramsMap = new HashMap<>();
if (params != null) {
if (params instanceof JSONObject) {
paramsMap = new Gson().fromJson(String.valueOf(params), Map.class);
}

Expand Down
23 changes: 21 additions & 2 deletions src/ios/NewRelicCordovaPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,30 @@ - (void)noticeHttpTransaction:(CDVInvokedUrlCommand *)command {
NSNumber* bytesreceived = [command.arguments objectAtIndex:6];
NSString* body = [command.arguments objectAtIndex:7];

NSDictionary* params;
if([command.arguments objectAtIndex:8] == [NSNull null] ){
params = nil;
}
else {params = [command.arguments objectAtIndex:8];
}

NSDictionary* traceAttributes;
if([command.arguments objectAtIndex:9] == [NSNull null] ){
traceAttributes = nil;
}
else {
traceAttributes = [command.arguments objectAtIndex:9];
}

NSURL *nsurl = [NSURL URLWithString:url];
NSData* data = [body dataUsingEncoding:NSUTF8StringEncoding];
NSData* data;
if (body == [NSNull null]) {
data = nil;
} else {
data = [body dataUsingEncoding:NSUTF8StringEncoding];
}

[NewRelic noticeNetworkRequestForURL:nsurl httpMethod:method startTime:[startTime doubleValue] endTime:[endTime doubleValue] responseHeaders:nil statusCode:(long)[status integerValue] bytesSent:(long)[bytesSent integerValue] bytesReceived:(long)[bytesreceived integerValue] responseData:data traceHeaders:nil andParams:nil];
[NewRelic noticeNetworkRequestForURL:nsurl httpMethod:method startTime:[startTime doubleValue] endTime:[endTime doubleValue] responseHeaders:nil statusCode:(long)[status integerValue] bytesSent:(long)[bytesSent integerValue] bytesReceived:(long)[bytesreceived integerValue] responseData:data traceHeaders:traceAttributes andParams:params];
}

- (void)crashNow:(CDVInvokedUrlCommand *)command {
Expand Down

0 comments on commit 7792e72

Please sign in to comment.