Skip to content

Commit

Permalink
Add campaign parameters to the screen event (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiosdev authored Oct 19, 2023
1 parent c7bd9b5 commit 36feca6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/SegmentFirebase/FirebaseDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 36feca6

Please sign in to comment.