Skip to content

Conversation

@thingineeer
Copy link
Collaborator

@thingineeer thingineeer commented Dec 28, 2023

🌱 작업한 내용

  • GA 달기

🌱 PR Point

  • GAManagerGAEvent 구조체로 작업을 하려는데 코드가 괜찮은지 ,,
    GA 다는 함수도 아직 전체적으로 넣진 않았어요 로그인 부분이나 초기 부분에 테스트로 심어놨습니다
    왜냐하면 싱글톤으로 만든 클래스가 괜찮은지 보기 위해서

  • 당연하지만 pod install 해줘야 합니다 ~~

  • GAManager는 싱글톤 전역으로 사용 하고자 합니다.

import FirebaseAnalytics

final class GAManager {
    static let shared = GAManager()
    
    private init() {}
    
    enum GAEventType {
        case screen(screenName: String)
        case button(buttonName: String)
        
        var eventName: String {
            switch self {
            case .screen:
                return "screen"
            case .button:
                return "button"
            }
        }
        
        var parameters: [String: Any]? {
            switch self {
            case .screen(let screenName):
                return ["screen": screenName]
            case .button(let buttonName):
                return ["button": buttonName]
            }
        }
    }
    
    func logEvent(eventType: GAEventType) {
        Analytics.logEvent(eventType.eventName, parameters: eventType.parameters)
    }
}
  • UIVIew, UIViewController + 에 메서드 오버로딩 으로 함수 구현 하였습니다.
extension UIViewController {
    func analyze(screenName: String) {
        GAManager.shared.logEvent(eventType: .screen(screenName: screenName))
    }
    
    func analyze(buttonName: String) {
        GAManager.shared.logEvent(eventType: .button(buttonName: buttonName))
    }
}

📸 스크린샷

📮 관련 이슈

@thingineeer thingineeer changed the title [Feat] #230 - GA 를 요구사항에 맞게 달 예정입니다. [Feat] #230 - Firebase Google Analytics Jan 2, 2024
Copy link
Collaborator

@513sojin 513sojin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다 ~ 특히나 Event 하나하나 변수로 만드는게 쉽지 않았을텐디 ..... 피드백 하나 남겨두긴 했는데 고민해봐도 좋을 것 같아요 !

Comment on lines 244 to 256
extension SignInSocialLoginVC {
private func analyze() {
GAManager.shared.logEvent(eventType: .screen(screenName: Event.View.viewSocialLogin))
}

private func kakaoLoginSuccessAnalyze() {
GAManager.shared.logEvent(eventType: .button(buttonName: Event.Button.clickKaKaoLogin))
}

private func appleLoginSuccessAnalyze() {
GAManager.shared.logEvent(eventType: .button(buttonName: Event.Button.clickAppleLogin))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 파악한 바로는 eventType에 해당하는 부분만 달라지는 것 같은데
GAManager.shared.logEvent(eventType:� )

UI 뷰컨 익스텐션으로

func analyze(_ eventType : EventType) {
  GAManager.shared.logEvent(eventType: eventType)
}

analyze(.screen(screenName: Event.View.viewSocialLogin))
analyze(.button(buttonName: Event.Button.clickKaKaoLogin))

이런식으로 만들어서 사용하면 GA가 필요한 부분마다 새로 함수를 만들지 않아도 될 것 같은데 어떠신가요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같은 VC에서 사용하는 것 중에 중복되는 부분이 있으니, 재사용해서 하는 게 낫다고 이해했는데 맞을까요!?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 마자여 !! 어차피 버튼에 단다고 해도 버튼 이벤트 처리를 뷰컨에서 할테니 UIViewController extension에 저기에 있는 analyze함수를 넣는게 어떻겠냐는 의견이었습니다 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인 완료 ~~


import Foundation

struct Event {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GAEvent 같이 조금 구체적인 이름은 어떨까요 ?!
저도 이벤트 주고 받을때 그냥 eventType 이런 식으로 많이 썼는데 다음에 코드 짤때는 좀 더 이름을 구체적으로 지어보려구요 ..^__^

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분 반영 하겠습니다 ~

Comment on lines 12 to 17
final class GAManager {
static let shared = GAManager()

private init() {}

enum EventType {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

싱글톤으로 작성한 부분도, 타입 나눈 것도 그렇고 확실히 ga 함수 다는게 쉬워질 것 같아요 !! 고민 많이 하셨을텐데 너무 좋다고 봅니다 👍🏻

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다 ~

@thingineeer thingineeer changed the title [Feat] #230 - Firebase Google Analytics [Feat] #230 - Firebase Google Analytics 작업을 진행 합니다. Jan 6, 2024
@thingineeer thingineeer merged commit 28497a5 into Runnect:develop Jan 6, 2024
@thingineeer thingineeer deleted the #230---GA-추가 branch January 6, 2024 07:39
@thingineeer thingineeer changed the title [Feat] #230 - Firebase Google Analytics 작업을 진행 합니다. [Feat] #230 - Firebase Google Analytics 작업을 진행 하였습니다. Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] #230 - GA 추가 작업

2 participants