newrelic/newrelic-flutter-agent

recordError() sends wrong appVersion on iOS

Closed this issue · 1 comments

Happening in version 1.0.4, it's an iOS-only bug.

When using recordError() on iOS the appVersion is being overwritten with the appBuild number.
This is pretty bad since it mixes two different values and would throw off all my existing charts in my dashboards apart from just being plain confusing when troubleshooting.

Looks like that's exactly what the code is currently doing in SwiftNewrelicMobilePlugin.swift

        case "recordError":
            let exceptionMessage = args!["exception"] as? String
            let reason = args!["reason"] as? String
            let fatal = args!["fatal"] as? Bool
            let stackTraceElements = args!["stackTraceElements"] as? [[String : Any]] ?? [[String : Any]]()
            let version = Bundle.main.infoDictionary?["CFBundleVersion"] ?? "1.0.3"


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

            NewRelic.recordHandledException(withStackTrace: attributes)

            result("return")

CFBundleVersion will return the app build number and not the "human readable" app version.
appBuild and appVersion are being set to the current app build number for iOS

In fact, it looks like there is no need to send those two params at all and if left out the data seems to flow as expected to the newrelic portal.

So probably just removing :

          "appBuild": version,
          "appVersion": version

might be enough here.

@asegurola we will check it from our side and fix it.