Skip to content

Commit

Permalink
Remove unneeded guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Camji55 committed Jul 11, 2023
1 parent c293a6c commit 68a5bf8
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions MixpanelServiceKit/MixpanelService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,7 @@ public final class MixpanelService: Service {

extension MixpanelService: AnalyticsService {
public func recordAnalyticsEvent(_ name: String, withProperties properties: [AnyHashable: Any]?, outOfSession: Bool) {
guard let properties else {
return
}

var mappedProperties: [String: MixpanelType] = [:]
for (key, value) in properties {
guard let key = key as? String else {
return
}

guard let value = value as? MixpanelType else {
return
}

mappedProperties[key] = value
}

client?.track(event: name, properties: mappedProperties)
client?.track(event: name, properties: mappedProperties(from: properties))
}

public func recordIdentify(_ property: String, value: String) {
Expand All @@ -106,3 +89,18 @@ extension KeychainManager {
}

fileprivate let MixpanelTokenService = "MixpanelToken"

private extension MixpanelService {
func mappedProperties(from properties: [AnyHashable: Any]?) -> [String: MixpanelType] {
guard let properties else { return [:] }
var mappedProperties: [String: MixpanelType] = [:]

for (key, value) in properties {
if let key = key as? String, let value = value as? MixpanelType {
mappedProperties[key] = value
}
}

return mappedProperties
}
}

0 comments on commit 68a5bf8

Please sign in to comment.