Serializing an error to a String in a SWIFT Custom Event failing to produce an event

We’re trying to serialize an error into a custom event using the iOS Swift library. The code is firing. We get a success response (which we all know doesn’t mean anything real), and we don’t get the custom event showing up in our Explorer or NRQL interface. I’m imagining there’s an issue with serializing the Error into a String, but I can’t figure out what it could/should be to resolve it.

Help me obiwan kenobi, you’re my only hope.

Also, hi. :wave:

else if let error = error as? Swift.DecodingError {
        NewRelic.recordCustomEvent("SwiftDecodingError", attributes: [
            "reason": String(describing: error)
        return APIFailure.decodingFailed(error: error)

If you enable the iOS agent’s logging, are there any messages that recording the custom event failed? (Enable logging info, here: iOS manual installation | New Relic Documentation)

If you put a “test” string in place of error, is the custom event recorded/sent?

You may also want to try recordError: recordError (iOS SDK API) | New Relic Documentation

Popping in just to send an enthusiastic :wave: to you @joel.worrall! Hope all is well!

Hi right at ya @hross! :wink:

@dmurray, we’ll give those a shot and circle back posthaste Monday. Thank you.


The recordError worked… although I would love to better understand the constraints that would cause the recordEvent to fail. However, I have a follow up clarification: is recordError writing an event to MobileRequestError?

hey @joel.worrall

recordError reports as a handled exception event and can be viewed in either the Handled Exceptions page in New Relic, or in Crash Analysis event trails. You can also query the event type MobileHandledException via NRQL.

Were you able to capture any logs with the agent’s logging enabled when using recordCustomEvent? That may offer some additional insight into why it was not properly captured.

This topic was automatically closed after 365 days. New replies are no longer allowed.