Skip to content

Commit

Permalink
fix:Custom attributes not passed along recordError on iOS #113 (#116)
Browse files Browse the repository at this point in the history
* fix:Custom attributes not passed along recordError on iOS #113

* Update Proguard Rules
  • Loading branch information
ndesai-newrelic authored Oct 4, 2024
1 parent 2c08645 commit 72cca21
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,20 @@ NewrelicMobile.instance

## Troubleshoot

No Http data appears:
**No Http data appears:**

Problem
**Problem**
After installing the Flutter agent and waiting at least 5 minutes, no http data appears in New Relic UI.

Solution
**Solution**
If no http data appears after you wait at least five minutes, check you are not overriding HttpOverrides.global inside your flutter app.


**Crash reports may not be sent when ProGuard rules are not properly configured for New Relic in hybrid Android applications.**

**Solution**:
Ensure proper ProGuard rules are added to your ProGuard configuration file. See ["Configuring ProGuard Rules"](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/configure-proguard-or-dexguard-android-apps/) in setup documentation.

## Uploading dSYM files

Our iOS agent includes a Swift script intended to be run from a build script in your target's build phases in XCode. The script automatically uploads dSYM files in the background (or converts your dSYM to the New Relic map file format), and then performs a background upload of the files needed for crash symbolication to New Relic.
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void main() {
networkErrorRequestEnabled: true,
networkRequestEnabled: true,
crashReportingEnabled: true,
interactionTracingEnabled: false,
interactionTracingEnabled: true,
httpResponseBodyCaptureEnabled: true,
loggingEnabled: true,
webViewInstrumentation: true,
Expand Down
1 change: 0 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
graphql_flutter: ^5.1.2
graphql: ^5.1.3
go_router: ^10.0.0
contentsquare: ^3.12.0



Expand Down
7 changes: 5 additions & 2 deletions ios/Classes/SwiftNewrelicMobilePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,19 @@ public class SwiftNewrelicMobilePlugin: NSObject, FlutterPlugin {
let reason = args!["reason"] as? String
let fatal = args!["fatal"] as? Bool
let stackTraceElements = args!["stackTraceElements"] as? [[String : Any]] ?? [[String : Any]]()
let eventAttributes = args?["attributes"] as? [String : Any]


let attributes: [String:Any] = [
var attributes: [String:Any] = [
"name": exceptionMessage ?? "Exception name not found",
"reason": reason ?? "Reason not found",
"cause": reason ?? "Reason not found",
"fatal": fatal ?? false,
"stackTraceElements": stackTraceElements
]

if let eventAttributes = eventAttributes {
attributes.merge(eventAttributes) { (current, _) in current }
}
NewRelic.recordHandledException(withStackTrace: attributes)

result("return")
Expand Down
10 changes: 10 additions & 0 deletions lib/newrelic_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ class NewrelicMobile {
}

final Map<String, dynamic> eventParams = Map<String, dynamic>.from(params);
if (attributes != null) {

for (final String key in attributes.keys) {
if (key == 'attributes') {
continue;
}
eventParams[key] = attributes[key];
}
}
eventParams.remove('stackTraceElements');
eventParams.remove('attributes');

NewrelicMobile.instance
.recordCustomEvent("Mobile Dart Errors", eventAttributes: eventParams);
Expand Down

0 comments on commit 72cca21

Please sign in to comment.