-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acbe89d
commit e612696
Showing
9 changed files
with
1,015 additions
and
105 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...plitudeSwiftUIExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "analytics-connector-ios", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/amplitude/analytics-connector-ios.git", | ||
"state" : { | ||
"revision" : "e2ca17ac735bcbc48b13062484541702ef45153d", | ||
"version" : "1.0.3" | ||
} | ||
}, | ||
{ | ||
"identity" : "experiment-ios-client", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/amplitude/experiment-ios-client", | ||
"state" : { | ||
"revision" : "6a94d70915b3756daae2a989fa57f03c19547c67", | ||
"version" : "1.13.5" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import UIKit | ||
|
||
public class UserInteractionEvent: BaseEvent { | ||
|
||
public enum InteractionValue { | ||
case tap(dead: Bool = false) | ||
case longPress(dead: Bool = false) | ||
case rageTap | ||
case focusGained | ||
case focusLost(didTextFieldChange: Bool = false) | ||
case sliderChanged(to: Int) | ||
|
||
var description: String { | ||
switch self { | ||
case .tap(let dead): return dead ? "Dead Tapped" : "Tapped" | ||
case .longPress(let dead): return dead ? "Dead Long Pressed" : "Long Pressed" | ||
case .rageTap: return "Rage Tapped" | ||
case .focusGained: return "Focus Gained" | ||
case .focusLost(let didTextFieldChange): | ||
return didTextFieldChange ? "Focus Lost After Text Modification" : "Focus Lost" | ||
case .sliderChanged(let percentage): | ||
return "Value Changed To \(percentage)%" | ||
} | ||
} | ||
} | ||
|
||
convenience init(_ interactionValue: InteractionValue, label: String? = nil, value: String? = nil, type: UIAccessibilityTraits = .none) { | ||
self.init(eventType: Constants.AMP_USER_INTERACTION_EVENT, eventProperties: [ | ||
Constants.AMP_INTERACTION_PROPERTY: interactionValue.description, | ||
Constants.AMP_ELEMENT_LABEL_PROPERTY: label, | ||
Constants.AMP_ELEMENT_VALUE_PROPERTY: value, | ||
Constants.AMP_ELEMENT_TYPE_PROPERTY: type.stringify() | ||
]) | ||
} | ||
} | ||
|
||
extension UIAccessibilityTraits { | ||
func stringify() -> String? { | ||
var strings = [String]() | ||
if contains(.adjustable) { strings.append("Adjustable") } | ||
if contains(.allowsDirectInteraction) { strings.append("Allows Direct Interaction") } | ||
if contains(.button) { strings.append("Button") } | ||
if contains(.causesPageTurn) { strings.append("Causes Page Turn") } | ||
if contains(.header) { strings.append("Header") } | ||
if contains(.image) { strings.append("Image") } | ||
if contains(.keyboardKey) { strings.append("Keyboard Key") } | ||
if contains(.link) { strings.append("Link") } | ||
if contains(.notEnabled) { strings.append("Not Enabled") } | ||
if contains(.playsSound) { strings.append("Plays Sound") } | ||
if contains(.searchField) { strings.append("Search Field") } | ||
if contains(.selected) { strings.append("Selected") } | ||
if contains(.startsMediaSession) { strings.append("Starts Media Session") } | ||
if contains(.staticText) { strings.append("Static Text") } | ||
if contains(.summaryElement) { strings.append("Summary Element") } | ||
if contains(.tabBar) { strings.append("Tab Bar") } | ||
if contains(.updatesFrequently) { strings.append("Updates Frequently") } | ||
|
||
return strings.isEmpty ? nil : strings.joined(separator: ", ") | ||
} | ||
} |
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
Oops, something went wrong.