Skip to content

Commit

Permalink
fix: handled null values for event attributes of custom event. (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndesai-newrelic authored May 29, 2024
1 parent 79f2370 commit 6eb2fbf
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,24 @@ class NewrelicMobilePlugin : FlutterPlugin, MethodCallHandler {
val eventName: String? = call.argument("eventName")
val eventAttributes: HashMap<String, Any>? = call.argument("eventAttributes")

val copyOfEventAttributes = eventAttributes?.clone() as HashMap<*, *>;
for (key in copyOfEventAttributes.keys) {
val value = copyOfEventAttributes[key]
if(value is HashMap<*, *>) {
for (k in value.keys) {
value[k]?.let { eventAttributes.put(k as String, it) };
if (eventAttributes == null) {
val eventRecorded = NewRelic.recordCustomEvent(eventType, eventName, null)
result.success(eventRecorded)
} else {
val copyOfEventAttributes = eventAttributes.clone() as HashMap<*, *>
for (key in copyOfEventAttributes.keys) {
val value = copyOfEventAttributes[key]
if(value is HashMap<*, *>) {
for (k in value.keys) {
value[k]?.let { eventAttributes.put(k as String, it) };
}
eventAttributes.remove(key)
}
eventAttributes.remove(key)
}
val eventRecorded =
NewRelic.recordCustomEvent(eventType, eventName, eventAttributes)
result.success(eventRecorded)
}
val eventRecorded =
NewRelic.recordCustomEvent(eventType, eventName, eventAttributes)
result.success(eventRecorded)
}
"startInteraction" -> {
val actionName: String? = call.argument("actionName")
Expand Down

0 comments on commit 6eb2fbf

Please sign in to comment.