Skip to content

Commit

Permalink
Ecommerce implementation (matomo-org#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Krainik committed Aug 8, 2018
1 parent 6839db6 commit c84280a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions MatomoTracker/EcommerceUpdate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ public class EcommerceUpdate {

let (offset, element) = arg

let data = try JSONSerialization.data(withJSONObject: element.value, options: [])
let jsonValue = String.init(data: data, encoding: String.Encoding.utf8) ?? ""

return CustomVariable(index: UInt(offset), name: element.key, value: jsonValue)
if let stringValue = element as? String {
return CustomVariable(index: UInt(offset), name: element.key, value: stringValue)
} else {
let data = try JSONSerialization.data(withJSONObject: element.value, options: [])
let jsonValue = String.init(data: data, encoding: String.Encoding.utf8) ?? ""

return CustomVariable(index: UInt(offset), name: element.key, value: jsonValue)
}
}
}

Expand Down

0 comments on commit c84280a

Please sign in to comment.