diff --git a/Sources/SegmentFirebase/FirebaseDestination.swift b/Sources/SegmentFirebase/FirebaseDestination.swift index 8690508..dc5ce08 100644 --- a/Sources/SegmentFirebase/FirebaseDestination.swift +++ b/Sources/SegmentFirebase/FirebaseDestination.swift @@ -116,12 +116,18 @@ public class FirebaseDestination: DestinationPlugin { public func screen(event: ScreenEvent) -> ScreenEvent? { if let eventName = event.name { + var parameters: [String: Any] = [FirebaseAnalytics.AnalyticsParameterScreenName: eventName] + + if let campaign = event.context?.dictionaryValue?["campaign"] as? [String: Any] { + let campaignParameters = returnMappedFirebaseParameters(campaign, for: FirebaseDestination.campaignMappedKeys) + parameters = parameters.merging(campaignParameters) { (current, _) in current } + } + FirebaseAnalytics.Analytics.logEvent(FirebaseAnalytics.AnalyticsEventScreenView, - parameters: [FirebaseAnalytics.AnalyticsParameterScreenName: eventName]) + parameters: parameters) analytics?.log(message: "Firebase setScreenName \(eventName)") } - return event } }