Last active
July 18, 2019 19:12
-
-
Save quintonpryce/c5b8f75caac569803cccc62b1f630537 to your computer and use it in GitHub Desktop.
Analytics Parameters Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleParameter: AnalyticsParameter { | |
public var parameter: ParameterType | |
public typealias ParameterType = [AnyHashable: Any] | |
init(parameters: [AnyHashable: Any]) { | |
self.parameter = parameters | |
} | |
} | |
enum ExampleParameterEnum { | |
case selectedSegment(Int) | |
case exampleMultiple(Int, Bool, Float) | |
public var parameter: ExampleParameter { | |
switch self { | |
case let .selectedSegment(int): | |
return ExampleParameter(parameters: [ "Selected Segment": int ]) | |
case let .exampleMultiple(int, bool, float): | |
let double = Double(float) | |
return ExampleParameter(parameters: [ "Selected Segment": int, | |
"Switch State": bool, | |
"Slider Position": double ]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment