Skip to content

Commit

Permalink
[ITDS-73] refactor: #56 - GA 이벤트 호출방식 수정
Browse files Browse the repository at this point in the history
- 각 화면당 불필요한 import FirebaseAnalytics 제거
- parameter 값 추후 논의 필요(예시: 어떤 공고를 선택했는지 공고 id 값 전달이 필요한 경우)
  • Loading branch information
wongbingg committed Jan 19, 2025
1 parent da34707 commit 2b24c80
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import RxSwift
import RxCocoa
import PinLayout
import FlexLayout
import FirebaseAnalytics

public final class JobCategoryView: UIView {
private enum Metric {
Expand Down Expand Up @@ -121,10 +120,9 @@ public final class JobCategoryView: UIView {
.map { (indexPath, dataList) in
let category = ContestCategory.init(rawValue: dataList[indexPath.row]) ?? .all
switch category {
case .all: Analytics.logEvent(GA.전체칩, parameters: nil)
case .design: Analytics.logEvent(GA.디자인칩, parameters: nil)
// case .develop: Analytics.logEvent(GA.개발칩, parameters: nil)
case .idea: Analytics.logEvent(GA.기획아이디어칩, parameters: nil)
case .all: GA.logEvent(.전체칩)
case .design: GA.logEvent(.디자인칩)
case .idea: GA.logEvent(.기획아이디어칩)
}
return category
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import MozipCore
import FlexLayout
import RxCocoa
import RxSwift
import FirebaseAnalytics

public final class OrderDropDownMenu: UIView {
// MARK: - Properties
Expand Down Expand Up @@ -50,15 +49,15 @@ public final class OrderDropDownMenu: UIView {

latestLabel.rxGesture.tap
.map { _ in
Analytics.logEvent(GA.최신순버튼, parameters: nil)
GA.logEvent(.최신순버튼)
return true
}
.bind(to: isLatestOrder)
.disposed(by: disposeBag)

oldestLabel.rxGesture.tap
.map { _ in
Analytics.logEvent(GA.마감순버튼, parameters: nil)
GA.logEvent(.마감순버튼)
return false
}
.bind(to: isLatestOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import RxSwift
import RxCocoa
import PinLayout
import FlexLayout
import FirebaseAnalytics

public final class PostOrderControlView: UIView {

Expand Down Expand Up @@ -84,7 +83,7 @@ public final class PostOrderControlView: UIView {
private func bind() {
orderButton.rxGesture.tap
.bind(with: self) { owner, _ in
Analytics.logEvent(GA.정렬버튼, parameters: nil)
GA.logEvent(.정렬버튼)
let currentValue = owner.isOrderButtonTappedRelay.value
owner.isOrderButtonTappedRelay.accept(!currentValue)
}
Expand Down
61 changes: 34 additions & 27 deletions Targets/MozipCore/Sources/GA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@
// Copyright © 2025 MOZIP. All rights reserved.
//

import Foundation
import FirebaseAnalytics

public struct GA {
// 로그인 화면
public static let 카카오버튼 = "kakao_login_button_selected"
public static let 애플버튼 = "apple_login_button_selected"

// 홈 화면 - 네비게이션바 영역
public static let 마이페이지버튼 = "profile_button_selected"
public static let 검색버튼 = "search_button_selected"
public static func logEvent(_ event: Event) {
Analytics.logEvent(event.rawValue, parameters: nil)
}

// 홈 화면 - 스크롤 영역
public static let 배너이미지 = "banner_image_selected"
public static let 공모전더보기버튼 = "contest_more_selected"
public static let 해커톤더보기버튼 = "hackathon_more_selected"
public static let IT동아리더보기버튼 = "it_club_more_selected"

// 공고 리스트 - 상단 카테고리 칩
public static let 전체칩 = "contest_all_chip_selected"
public static let 개발칩 = "contest_develop_chip_selected"
public static let 디자인칩 = "contest_design_chip_selected"
public static let 기획아이디어칩 = "contest_idea_chip_selected"

// 공고 리스트 - 정렬버튼
public static let 정렬버튼 = "array_menu_selected"
public static let 최신순버튼 = "latest_array_selected"
public static let 마감순버튼 = "oldest_array_selected"

// 공고 상세
public static let 지원하기버튼 = "apply_button_selected"
public static let 공유버튼 = "share_button_selected"
public enum Event: String {
// 로그인 화면
case 카카오버튼 = "kakao_login_button_selected"
case 애플버튼 = "apple_login_button_selected"

// 홈 화면 - 네비게이션바 영역
case 마이페이지버튼 = "profile_button_selected"
case 검색버튼 = "search_button_selected"

// 홈 화면 - 스크롤 영역
case 배너이미지 = "banner_image_selected"
case 공모전더보기버튼 = "contest_more_selected"
case 해커톤더보기버튼 = "hackathon_more_selected"
case IT동아리더보기버튼 = "it_club_more_selected"

// 공고 리스트 - 상단 카테고리 칩
case 전체칩 = "contest_all_chip_selected"
case 개발칩 = "contest_develop_chip_selected"
case 디자인칩 = "contest_design_chip_selected"
case 기획아이디어칩 = "contest_idea_chip_selected"

// 공고 리스트 - 정렬버튼
case 정렬버튼 = "array_menu_selected"
case 최신순버튼 = "latest_array_selected"
case 마감순버튼 = "oldest_array_selected"

// 공고 상세
case 지원하기버튼 = "apply_button_selected"
case 공유버튼 = "share_button_selected"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import FlexLayout
import PinLayout
import ReactorKit
import RxCocoa
import FirebaseAnalytics

final class HomeViewController: BaseViewController<HomeReactor>, Coordinatable {

Expand Down Expand Up @@ -196,23 +195,23 @@ private extension HomeViewController {
navigationBar.myPageButtonTapObservable
.asSignal(onErrorJustReturn: ())
.emit(with: self) { owner, _ in
Analytics.logEvent(GA.마이페이지버튼, parameters: nil)
GA.logEvent(.마이페이지버튼)
AppProperties.accessToken == .init() ? owner.coordinator?.pushLoginPage() : owner.coordinator?.pushMyPage()
}
.disposed(by: disposeBag)

navigationBar.searchButtonTapObservable
.asSignal(onErrorJustReturn: ())
.emit(with: self) { owner, _ in
Analytics.logEvent(GA.검색버튼, parameters: nil)
GA.logEvent(.검색버튼)
owner.coordinator?.pushPostSearch()
}
.disposed(by: disposeBag)

bannerView.bannerTapObservable
.asSignal(onErrorJustReturn: .stub())
.emit(with: self) { owner, banner in
Analytics.logEvent(GA.배너이미지, parameters: nil)
GA.logEvent(.배너이미지)
owner.coordinator?.pushPostDetail(id: banner.infoPostID)
}
.disposed(by: disposeBag)
Expand All @@ -223,9 +222,9 @@ private extension HomeViewController {
let postHeaders = owner.reactor?.currentState.postHeaders ?? []
let postKind = postHeaders[indexPath.section]
switch postKind {
case .공모전: Analytics.logEvent(GA.공모전더보기버튼, parameters: nil)
case .해커톤: Analytics.logEvent(GA.해커톤더보기버튼, parameters: nil)
case .동아리: Analytics.logEvent(GA.IT동아리더보기버튼, parameters: nil)
case .공모전: GA.logEvent(.공모전더보기버튼)
case .해커톤: GA.logEvent(.해커톤더보기버튼)
case .동아리: GA.logEvent(.IT동아리더보기버튼)
}
owner.coordinator?.pushPostList(postKind: postKind)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import MozipCore
import DomainLayer

import ReactorKit
import FirebaseAnalytics

final class LoginReactor: Reactor {

Expand Down Expand Up @@ -53,15 +52,15 @@ final class LoginReactor: Reactor {
private func didTapKakaoLoginButtonMutation() -> Observable<Mutation> {
return loginUseCase.tryKakaoLogin()
.do(onNext: { _ in
Analytics.logEvent(GA.카카오버튼, parameters: nil)
GA.logEvent(.카카오버튼)
})
.map { .setUserToken(userToken: $0) }
}

private func didTapAppleLoginButtonMutation() -> Observable<Mutation> {
return loginUseCase.tryAppleLogin()
.do(onNext: { _ in
Analytics.logEvent(GA.애플버튼, parameters: nil)
GA.logEvent(.애플버튼)
})
.map { .setUserToken(userToken: $0) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import FlexLayout
import PinLayout
import ReactorKit
import RxCocoa
import FirebaseAnalytics

final class PostDetailViewController: BaseViewController<PostDetailReactor>, Coordinatable, Alertable {

Expand Down Expand Up @@ -367,15 +366,15 @@ private extension PostDetailViewController {
shareButton.rx.tap
.asSignal()
.emit(with: self, onNext: { owner, _ in
Analytics.logEvent(GA.공유버튼, parameters: nil)
GA.logEvent(.공유버튼)
owner.showActivityController()
})
.disposed(by: disposeBag)

showMoreButton.tapObservable
.asSignal(onErrorSignalWith: .empty())
.emit(with: self, onNext: { owner, _ in
Analytics.logEvent(GA.지원하기버튼, parameters: nil)
GA.logEvent(.지원하기버튼)
guard let reactor = owner.reactor else { return }
owner.coordinator?.pushWebView(urlString: reactor.currentState.post.postUrlString)
})
Expand Down

0 comments on commit 2b24c80

Please sign in to comment.