Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Sources/analytics-swift-singular/SegmentSingular.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ public class SingularDestination: DestinationPlugin, iOSLifecycle {
}

public func track(event: TrackEvent) -> TrackEvent? {
if let properties = event.properties?.dictionaryValue as? [String: Any], let revenue = extractRevenue(properties, key: "revenue") {
let currency = properties["currency"] as? String
analytics?.log(message: "Singular track revenue \(revenue)")
Singular.customRevenue(event.event, currency: currency, amount: revenue)
} else {
Singular.event(event.event)
}
// We don't need to edit the event or add any custom event
// The Segment event is properly propagated to Singular and
// marked as Revenue Event when needed.

// if let properties = event.properties?.dictionaryValue as? [String: Any], let revenue = extractRevenue(properties, key: "revenue") {
// let currency = properties["currency"] as? String
// analytics?.log(message: "Singular track revenue \(revenue)")
// Singular.customRevenue(event.event, currency: currency, amount: revenue, withAttributes: properties)
// } else {
// Singular.event(event.event)
// }
return event
}

Expand Down