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

[Feat] #92 Amplitude 설정 #93

Merged
merged 2 commits into from
Jul 25, 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
18 changes: 18 additions & 0 deletions .package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"pins" : [
{
"identity" : "amplitude-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/amplitude/Amplitude-Swift",
"state" : {
"branch" : "main",
"revision" : "df08b88cca1035d36b54efa01ce0d2b4ad43419d"
}
},
{
"identity" : "analytics-connector-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/amplitude/analytics-connector-ios.git",
"state" : {
"revision" : "e2ca17ac735bcbc48b13062484541702ef45153d",
"version" : "1.0.3"
}
},
{
"identity" : "appauth-ios",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions Projects/App/Sources/App/Root/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 com.adultOfNineteen. All rights reserved.
//

import AmplitudeSwift
import Foundation
import GoogleSignIn
import KakaoSDKAuth
Expand Down Expand Up @@ -40,6 +41,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

AmplitudeProvider.initProvider(apiKey: APIKeys.amplitudeApiKey)
KakaoSDK.initSDK(appKey: APIKeys.kakaoAppKey)

self.window = UIWindow(frame: UIScreen.main.bounds)
Expand Down
46 changes: 46 additions & 0 deletions Projects/App/Sources/App/Utils/AmplitudeProvider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AmplitudeProvider.swift
// Winey
//
// Created by 정도현 on 7/14/24.
// Copyright © 2024 Winey. All rights reserved.
//

import AmplitudeSwift
import Foundation

/// Ampltiude Event에 필요한 case를 정의합니다.
public enum AmplitudeEvent: String {
case tappedAnalysis
}

final class AmplitudeProvider: ObservableObject {

/// AmplitudeProvider의 싱글톤 객체. AmplitudeProvider를 사용하기 전 우선적으로 초기화되어야 합니다.
static let shared = AmplitudeProvider()

private var amplitude: Amplitude?

private init() {
amplitude = nil
}

/// Amplitude 싱글톤 객체를 초기화 합니다. (Amplitude APIKey 사용)
public static func initProvider(apiKey: String) {
AmplitudeProvider.shared.initialize(apiKey: apiKey)
}

private func initialize(apiKey: String) {
amplitude = Amplitude(
configuration: Configuration(
apiKey: apiKey,
defaultTracking: .ALL
)
)
}

/// 특정 이벤트를 호출합니다.
func track(event: AmplitudeEvent) {
self.amplitude?.track(eventType: event.rawValue)
}
}