Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.03.17) [Feat]: Amplitude 기능 업데이트 #52

Merged
merged 3 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AVIRO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1781,9 +1781,9 @@
C5DBF8392B3A6DAB00668B0D /* Feature */ = {
isa = PBXGroup;
children = (
C5503B5A2B9F51D10050643F /* Wellcome */,
C5D93D9D2A581E9100629C39 /* Tutorial */,
C567C14D2A5658C700D4B426 /* Login */,
C5503B5A2B9F51D10050643F /* Wellcome */,
C5EB50ED2A1C76FC00B29CC1 /* Home */,
C5351B722A1B369000116D50 /* Enroll */,
C5AAEB472B2F044000507C73 /* Challenge */,
Expand Down Expand Up @@ -2661,7 +2661,7 @@
CODE_SIGN_ENTITLEMENTS = AVIRO/AVIRO.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = C4K2HXA435;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AVIRO/App/Info.plist;
Expand Down Expand Up @@ -2698,7 +2698,7 @@
CODE_SIGN_ENTITLEMENTS = AVIRO/AVIRO.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = C4K2HXA435;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AVIRO/App/Info.plist;
Expand Down
20 changes: 13 additions & 7 deletions AVIRO/App/AppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class AppController {
private var userKey: String?

private let keychain = KeychainSwift()
private let amplitude = AmplitudeUtility()

private var window: UIWindow!
private var rootViewController: UIViewController? {
Expand Down Expand Up @@ -100,14 +101,19 @@ final class AppController {
// MARK: TabBar View
private func setTabBarView() {
DispatchQueue.main.async { [weak self] in
let tabBarVC = AVIROTabBarController()
guard let self = self else { return }

tabBarVC.setViewControllers(with: [
TabBarType.home,
TabBarType.plus,
TabBarType.challenge
])
self?.rootViewController = tabBarVC
let tabBarVC = AVIROTabBarController.create(
amplitude: self.amplitude,
type: [
TabBarType.home,
TabBarType.plus,
TabBarType.challenge
]
)

self.rootViewController = tabBarVC

tabBarVC.selectedIndex = 0
}
}
Expand Down
185 changes: 121 additions & 64 deletions AVIRO/Custom/Utility/AmplitudeUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,57 @@ import AmplitudeSwift

// MARK: Amplitude
enum AMType: String {
case signUp = "Sign Up"
case withdrawal = "Withdrawal"

case login = "Login"
case logout = "Logout"

case requestPlaceInfo = "Request to Edit Place Info"

case searchHSV = "Search In HomeSearchView"

case popupPlace = "Pop Up"

case afterUploadPlace = "Upload Place"
case afterUploadReview = "Upload Review"
case afterEditMenu = "Edit Menu Table"
case signUp = "user_sign up"
case withdrawal = "user_withdrawal"
case userLogin = "user_login"
case userLogout = "user_logout"

case placeUpload = "place_upload"
case reviewUpload = "review_upload"

case placeEdit = "place_edit"
case placeSearch = "place_serach"
case placePresent = "place_present"
case menuEdit = "menu_edit"

case challPresent = "chall_present"
case placeListPresent = "placeList_present"
case reviewListPresent = "reviewList_present"
case bookmarkListPresent = "bookmarkList_present"
case levelupDidMove = "level_up_didMove"
case levelupDidNotMove = "level_up_didNotMove"

case wellcomeClick = "wellcome_click"
case wellcomeNoShow = "wellcome_noShow"
case wellcomeClose = "wellcome_close"
}

protocol AmplitudeProtocol {
func setupUser(with userId: String)
func withdrawalUser()
func signUp(with userId: String)
func withdrawal()
func login()
func logout()
func popupPlace(with place: String)
func editMenu(with place: String, beforeMenus: [AVIROMenu], afterMenus: [AVIROMenu])
func searchPlace(with query: String)
func uploadPlace(with place: String)
func uploadReview(with place: String, review: String)
func requestEditPlace(with place: String)

func placeUpload(with place: String)
func reviewUpload(with place: String, review: String)

func placePresent(with place: String)
func placeSearch(with query: String)

func placeEdit(with place: String)
func menuEdit(with place: String, beforeMenus: [AVIROMenu], afterMenus: [AVIROMenu])

func challengePresent()
func placeListPresent()
func reviewListPresent()
func bookmarkListPresent()

func levelupDidMove(with level: Int)
func levelupDidNotMove(with level: Int)

func wellcomeClick()
func wellcomeNoShow()
func wellcomeClose()
}

final class AmplitudeUtility: AmplitudeProtocol {
Expand All @@ -55,13 +78,13 @@ final class AmplitudeUtility: AmplitudeProtocol {
}

// MARK: Setup User
func setupUser(with userId: String) {
func signUp(with userId: String) {
amplitude?.setUserId(userId: userId)
amplitude?.track(eventType: AMType.signUp.rawValue)
}

// MARK: Withdrawal User
func withdrawalUser() {
func withdrawal() {
amplitude?.track(eventType: AMType.withdrawal.rawValue)
}

Expand All @@ -74,24 +97,24 @@ final class AmplitudeUtility: AmplitudeProtocol {
identify.set(property: "version", value: SystemUtility.appVersion ?? "")

amplitude?.identify(identify: identify)
amplitude?.track(eventType: AMType.login.rawValue)
amplitude?.track(eventType: AMType.userLogin.rawValue)
}

// MARK: Logout
func logout() {
amplitude?.track(eventType: AMType.logout.rawValue)
amplitude?.track(eventType: AMType.userLogout.rawValue)
}

// MARK: Popup Place
func popupPlace(with place: String) {
func placePresent(with place: String) {
amplitude?.track(
eventType: AMType.popupPlace.rawValue,
eventType: AMType.placePresent.rawValue,
eventProperties: ["Place": place]
)
}

// MARK: Edit Menu
func editMenu(with place: String, beforeMenus: [AVIROMenu], afterMenus: [AVIROMenu]) {
func menuEdit(with place: String, beforeMenus: [AVIROMenu], afterMenus: [AVIROMenu]) {
var beforeMenusString = ""

for (index, menu) in beforeMenus.enumerated() {
Expand All @@ -107,7 +130,7 @@ final class AmplitudeUtility: AmplitudeProtocol {
}

amplitude?.track(
eventType: AMType.afterEditMenu.rawValue,
eventType: AMType.menuEdit.rawValue,
eventProperties: [
"Place": place,
"BeforeChangedMenuArray": beforeMenusString,
Expand All @@ -117,25 +140,25 @@ final class AmplitudeUtility: AmplitudeProtocol {
}

// MARK: Search Place
func searchPlace(with query: String) {
func placeSearch(with query: String) {
amplitude?.track(
eventType: AMType.searchHSV.rawValue,
eventType: AMType.placeSearch.rawValue,
eventProperties: ["Query": query]
)
}

// MARK: Upload Place
func uploadPlace(with place: String) {
func placeUpload(with place: String) {
amplitude?.track(
eventType: AMType.afterUploadPlace.rawValue,
eventType: AMType.placeUpload.rawValue,
eventProperties: ["Place": place]
)
}

// MARK: Upload Review
func uploadReview(with place: String, review: String) {
func reviewUpload(with place: String, review: String) {
amplitude?.track(
eventType: AMType.afterUploadReview.rawValue,
eventType: AMType.reviewUpload.rawValue,
eventProperties: [
"Place": place,
"Review": review
Expand All @@ -144,53 +167,87 @@ final class AmplitudeUtility: AmplitudeProtocol {
}

// MARK: Request Edit Place
func requestEditPlace(with place: String) {
func placeEdit(with place: String) {
amplitude?.track(
eventType: AMType.requestPlaceInfo.rawValue,
eventType: AMType.placeEdit.rawValue,
eventProperties: ["Place": place]
)
}
}

final class AmplitudeUtilityDummy: AmplitudeProtocol {
func setupUser(with userId: String) {
return
}

func withdrawalUser() {
return
func challengePresent() {
amplitude?.track(eventType: AMType.challPresent.rawValue)
}

func login() {
return
func placeListPresent() {
amplitude?.track(eventType: AMType.placeListPresent.rawValue)
}

func logout() {
return
func reviewListPresent() {
amplitude?.track(eventType: AMType.reviewListPresent.rawValue)
}

func popupPlace(with place: String) {
return
func bookmarkListPresent() {
amplitude?.track(eventType: AMType.bookmarkListPresent.rawValue)
}

func editMenu(with place: String, beforeMenus: [AVIROMenu], afterMenus: [AVIROMenu]) {
return
func levelupDidMove(with level: Int) {
amplitude?.track(
eventType: AMType.levelupDidMove.rawValue,
eventProperties: ["level": level]
)
}

func searchPlace(with query: String) {
return
func levelupDidNotMove(with level: Int) {
amplitude?.track(
eventType: AMType.levelupDidMove.rawValue,
eventProperties: ["level": level]
)
}

func uploadPlace(with place: String) {
return
func wellcomeClick() {
amplitude?.track(eventType: AMType.wellcomeClick.rawValue)
}

func uploadReview(with place: String, review: String) {
return
func wellcomeNoShow() {
amplitude?.track(eventType: AMType.wellcomeNoShow.rawValue)
}

func requestEditPlace(with place: String) {
return
func wellcomeClose() {
amplitude?.track(eventType: AMType.wellcomeClose.rawValue)
}

}

final class AmplitudeUtilityDummy: AmplitudeProtocol {
func signUp(with userId: String) { return }
func withdrawal() { return }
func login() { return }
func logout() { return }

func placeUpload(with place: String) { return }
func reviewUpload(
with place: String,
review: String
) { return }

func placePresent(with place: String) { return }
func placeSearch(with query: String) { return }

func placeEdit(with place: String) { return }
func menuEdit(
with place: String,
beforeMenus: [AVIROMenu],
afterMenus: [AVIROMenu]
) { return }

func challengePresent() { return }
func placeListPresent() { return }
func reviewListPresent() { return }
func bookmarkListPresent() { return }

func levelupDidMove(with level: Int) { return }
func levelupDidNotMove(with level: Int) { return }

func wellcomeClick() { return }
func wellcomeNoShow() { return }
func wellcomeClose() { return }
}
7 changes: 6 additions & 1 deletion AVIRO/Custom/Utility/SystemUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ struct SystemUtility {
static let appStoreOpenUrlString = "itms-apps://itunes.apple.com/app/apple-store/\(APP.appId.rawValue)"

func latestVersion() -> String? {
guard let url = URL(string: "http://itunes.apple.com/lookup?id=\(APP.appId.rawValue)&t=\(Date().timeIntervalSince1970)"),
guard let url = URL(string:
"""
http://itunes.apple.com/
lookup?id=\(APP.appId.rawValue)&
t=\(Date().timeIntervalSince1970)
"""),
let data = try? Data(contentsOf: url),
let json = try? JSONSerialization.jsonObject(
with: data,
Expand Down
Loading