Skip to content

Commit

Permalink
Merge pull request #247 from thingineeer/#246---GA-추가-구현
Browse files Browse the repository at this point in the history
[Feat] #246 - Google Analytics 코드를 추가 및 전체 코드 개선 하였습니다.
  • Loading branch information
thingineeer authored Jan 16, 2024
2 parents fce69df + b8e3e1e commit 1872784
Show file tree
Hide file tree
Showing 28 changed files with 293 additions and 179 deletions.
1 change: 1 addition & 0 deletions Runnect-iOS/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ disabled_rules:
- legacy_constructor
- unused_setter_value
- file_length
- void_function_in_ternary

included:
- Runnect-iOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-FIRAnalyticsDebugEnabled"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
Expand Down
20 changes: 14 additions & 6 deletions Runnect-iOS/Runnect-iOS/Global/Analytics/GAEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ import Foundation

struct GAEvent {
struct View {

// 진입 화면
static let viewHome = "view_home" // 앱 실행
static let viewSocialLogin = "view_social_login"

// 코스발견
static let viewCourseSearch = "view_course_search"
static let viewCourseDetail = "view_course_detail"
static let viewUserProfile = "view_user_profile"
static let viewCourseUpload = "view_course_upload"

// 마이페이지
static let viewSuccessLogout = "view_success_logout"
static let viewSuccessWithdraw = "view_success_withdraw"
}

struct Button {
Expand Down Expand Up @@ -43,15 +55,13 @@ struct GAEvent {
static let clickUploadButton = "click_upload_button"
static let clickTrySearchCourse = "click_try_search_course"
static let clickTryBanner = "click_try_banner"
static let clickSearchCourse = "click_search_course"
static let clickCourseDetail = "click_course_detail"
static let clickShare = "click_share"
static let clickUserProfile = "click_user_profile"
static let clickScrapPageStartCourse = "click_scrap_page_start_course"
static let clickUploadCourse = "click_upload_course"
static let clickCourseUpload = "click_course_upload"

/// 보관함
static let clickMyStorageCourseStart = "click_my_storage_course_start"
static let clickMyStorageCourseDrawingStart = "click_my_storage_course_drawing_start"
static let clickMyStorageTryModify = "click_my_storage_try_modify"
static let clickMyStorageTryRemove = "click_my_storage_try_remove"
static let clickScrapCourse = "click_scrap_course"
Expand All @@ -64,8 +74,6 @@ struct GAEvent {
static let clickCourseUploadInUploadedCourse = "click_course_upload_in_uploaded_course"
static let clickTryLogout = "click_try_logout"
static let clickTryWithdraw = "click_try_withdraw"
static let clickSuccessLogout = "click_success_logout"
static let clickSuccessWithdraw = "click_success_withdraw"

/// 방문자 모드
static let clickJoinInCourseDrawing = "click_join_in_course_drawing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum GestureType {
case pan(UIPanGestureRecognizer = .init())
case pinch(UIPinchGestureRecognizer = .init())
case edge(UIScreenEdgePanGestureRecognizer = .init())

func get() -> UIGestureRecognizer {
switch self {
case let .tap(tapGesture):
Expand All @@ -33,51 +34,55 @@ enum GestureType {
}
}

extension UIGestureRecognizer {
struct GesturePublisher: Publisher {
typealias Output = GestureType
typealias Failure = Never
private let view: UIView
private let gestureType: GestureType
init(view: UIView, gestureType: GestureType) {
self.view = view
self.gestureType = gestureType
}

func receive<S>(subscriber: S) where S: Subscriber,
GesturePublisher.Failure == S.Failure,
GesturePublisher.Output == S.Input {
let subscription = GestureSubscription(
subscriber: subscriber,
view: view,
gestureType: gestureType
)
subscriber.receive(subscription: subscription)
}
struct GesturePublisher: Publisher {
typealias Output = GestureType
typealias Failure = Never

private let view: UIView
private let gestureType: GestureType

init(view: UIView, gestureType: GestureType) {
self.view = view
self.gestureType = gestureType
}

class GestureSubscription<S: Subscriber>: Subscription where S.Input == GestureType, S.Failure == Never {
private var subscriber: S?
private var gestureType: GestureType
private var view: UIView
init(subscriber: S, view: UIView, gestureType: GestureType) {
self.subscriber = subscriber
self.view = view
self.gestureType = gestureType
configureGesture(gestureType)
}
private func configureGesture(_ gestureType: GestureType) {
let gesture = gestureType.get()
gesture.addTarget(self, action: #selector(handler))
view.addGestureRecognizer(gesture)
}
func request(_ demand: Subscribers.Demand) { }
func cancel() {
subscriber = nil
}
@objc
private func handler() {
_ = subscriber?.receive(gestureType)
}
func receive<S>(subscriber: S) where S: Subscriber,
Failure == S.Failure,
Output == S.Input {
let subscription = GestureSubscription(
subscriber: subscriber,
view: view,
gestureType: gestureType
)
subscriber.receive(subscription: subscription)
}
}

class GestureSubscription<S: Subscriber>: Subscription where S.Input == GestureType, S.Failure == Never {
private var subscriber: S?
private var gestureType: GestureType
private var view: UIView

init(subscriber: S, view: UIView, gestureType: GestureType) {
self.subscriber = subscriber
self.view = view
self.gestureType = gestureType
configureGesture(gestureType)
}

func request(_ demand: Subscribers.Demand) { }

func cancel() {
subscriber = nil
}

private func configureGesture(_ gestureType: GestureType) {
let gesture = gestureType.get()
gesture.addTarget(self, action: #selector(handler))
view.addGestureRecognizer(gesture)
}

@objc private func handler() {
_ = subscriber?.receive(gestureType)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "ios 앱 배너.png",
"filename" : "ios배너x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ios 앱 배너@2x.png",
"filename" : "ios배너x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ios 앱 배너@3x.png",
"filename" : "ios배너x3.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class RNMapView: UIView {
@Published var pathDistance: Double = 0
@Published var markerCount = 0

var eventSubject = PassthroughSubject<Array<Double>, Never>()
var eventSubject = PassthroughSubject<[Double], Never>()

private let screenWidth = UIScreen.main.bounds.width
private let screenHeight = UIScreen.main.bounds.height
Expand Down
4 changes: 2 additions & 2 deletions Runnect-iOS/Runnect-iOS/Network/Service/NetworkProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import Moya

class NetworkProvider<Provider: TargetType> : MoyaProvider<Provider> {
func request<Model: Codable>(target: Provider, instance: Model.Type , vc: UIViewController, completion: @escaping(Model) -> ()){
class NetworkProvider<Provider: TargetType>: MoyaProvider<Provider> {
func request<Model: Codable>(target: Provider, instance: Model.Type, vc: UIViewController, completion: @escaping(Model) -> Void) {
self.request(target) { result in
switch result {
/// 서버 통신 성공
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ final class CourseDetailVC: UIViewController {
setLayout()
setAddTarget()
setRefreshControl()
analyze(screenName: "코스 상세 페이지")
analyze(screenName: GAEvent.View.viewCourseDetail)
self.hideTabBar(wantsToHide: true)
}

Expand Down Expand Up @@ -177,6 +177,8 @@ extension CourseDetailVC {
return
}

analyze(buttonName: GAEvent.Button.clickShare)

let publicCourse = model.publicCourse
let title = publicCourse.title
let courseId = publicCourse.id // primaryKey
Expand Down Expand Up @@ -231,6 +233,9 @@ extension CourseDetailVC {
self.showToast(message: "회원만 조회 가능 합니다.")
return
}

analyze(screenName: GAEvent.Button.clickUserProfile)

guard let userId = self.userId else {return}
let userProfile = UserProfileVC()
userProfile.setUserId(userId: userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,20 @@ extension MarathonMapCollectionViewCell {

private func scrapCourse(publicCourseId: Int, scrapTF: Bool) {
LoadingIndicator.showLoading()

scrapProvider.request(.createAndDeleteScrap(publicCourseId: publicCourseId, scrapTF: scrapTF)) { [weak self] response in
LoadingIndicator.hideLoading()
defer {
LoadingIndicator.hideLoading()
}

guard let self = self else { return }

switch response {
case .success(let result):
let status = result.statusCode
if 200..<300 ~= status {
print("스크랩 성공")
}
if status >= 400 {
} else if status >= 400 {
print("400 error")
}
case .failure(let error):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ extension CourseDiscoveryVC {
return
}

analyze(buttonName: GAEvent.Button.clickUploadButton)

let nextVC = MyCourseSelectVC()
nextVC.delegate = self
self.navigationController?.pushViewController(nextVC, animated: true)
Expand Down Expand Up @@ -552,5 +554,14 @@ extension CourseDiscoveryVC: TitleCollectionViewCellDelegate {
sort = ordering
self.courseList.removeAll()
getCourseData(pageNo: pageNo)

switch ordering {
case "date":
analyze(buttonName: GAEvent.Button.clickDate)
case "scrap":
analyze(buttonName: GAEvent.Button.clickScrap)
default:
break
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ final class CourseSearchVC: UIViewController {
setDelegate()
layout()
setTabBar()
analyze(screenName: GAEvent.View.viewCourseSearch)
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -228,6 +229,7 @@ extension CourseSearchVC {
do {
let responseDto = try result.map(BaseResponse<PickedMapListResponseDto>.self)
guard let data = responseDto.data else { return }
self.analyze(buttonName: GAEvent.Button.clickTrySearchCourse)
self.setData(data: data.publicCourses)
} catch {
self.setData(data: [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CourseUploadVC: UIViewController {
setKeyboardNotification()
setTapGesture()
addKeyboardObserver()
analyze(screenName: GAEvent.View.viewCourseUpload)
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down Expand Up @@ -95,8 +96,8 @@ extension CourseUploadVC {
courseModel.departure.town,
courseModel.departure.name
]
.compactMap { $0 }
.joined(separator: " ")
.compactMap { $0 }
.joined(separator: " ")

self.departureInfoView.setDescriptionText(description: departureString)
}
Expand Down Expand Up @@ -192,6 +193,8 @@ extension CourseUploadVC {

@objc func uploadButtonDidTap() {
self.uploadCourse()

analyze(buttonName: GAEvent.Button.clickCourseUpload)
}
}

Expand Down Expand Up @@ -264,7 +267,7 @@ extension CourseUploadVC {
make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16)
make.height.equalTo(35)
}

dividerView.snp.makeConstraints { make in
make.top.equalTo(courseTitleTextField.snp.bottom).offset(0)
make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ extension CourseDrawingHomeVC {
// MARK: - @objc Function
extension CourseDrawingHomeVC {
@objc private func pushToDepartureSearchVC() {

analyze(buttonName: GAEvent.Button.clickCourseDrawing)

let departureSearchVC = DepartureSearchVC()
departureSearchVC.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(departureSearchVC, animated: true)
Expand Down
Loading

0 comments on commit 1872784

Please sign in to comment.