Skip to content

Commit

Permalink
✨ Add Firebase Analytics for tracking user behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteHyun committed Apr 8, 2024
1 parent d84ce8c commit fe82f63
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 1 deletion.
30 changes: 30 additions & 0 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
BA4FB9C52BA1BC5B00ED03C4 /* NoticeAPI in Frameworks */ = {isa = PBXBuildFile; productRef = BA4FB9C42BA1BC5B00ED03C4 /* NoticeAPI */; };
BA4FB9C72BA1BC5B00ED03C4 /* NoticeAPISupport in Frameworks */ = {isa = PBXBuildFile; productRef = BA4FB9C62BA1BC5B00ED03C4 /* NoticeAPISupport */; };
BA73DDC42BC17912009EE718 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BA73DDC32BC17912009EE718 /* GoogleService-Info.plist */; };
BA73DDC72BC179F6009EE718 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = BA73DDC62BC179F6009EE718 /* FirebaseAnalytics */; };
BA73DDCB2BC179F6009EE718 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = BA73DDCA2BC179F6009EE718 /* FirebaseCrashlytics */; };
BA849A342B8F4F36004495BF /* ProductConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */; };
BA849A372B8F4FC0004495BF /* MockPaginatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA849A362B8F4FC0004495BF /* MockPaginatable.swift */; };
BA8E83242B8EF83B00FE968C /* ProductConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */; };
Expand Down Expand Up @@ -187,9 +189,11 @@
BAB6212E2BB13CD100877FC3 /* NetworkAPIKit in Frameworks */,
BA0623D82B68E51400A0A3B2 /* Log in Frameworks */,
BA0564092B6248EA003D6DC7 /* HomeAPI in Frameworks */,
BA73DDC72BC179F6009EE718 /* FirebaseAnalytics in Frameworks */,
BAE5ADB02BAD61D000176ADE /* CreditsAPI in Frameworks */,
BAB569612B639F3000D1E0F9 /* DesignSystem in Frameworks */,
BAE5EDB42BB1450100FC4B78 /* NetworkMonitor in Frameworks */,
BA73DDCB2BC179F6009EE718 /* FirebaseCrashlytics in Frameworks */,
E55DD5182B9370D100AA63C0 /* SearchAPI in Frameworks */,
E55DD51A2B9370D100AA63C0 /* SearchAPISupport in Frameworks */,
);
Expand Down Expand Up @@ -563,6 +567,8 @@
BAE5ADB12BAD61D000176ADE /* CreditsAPISupport */,
BAB6212D2BB13CD100877FC3 /* NetworkAPIKit */,
BAE5EDB32BB1450100FC4B78 /* NetworkMonitor */,
BA73DDC62BC179F6009EE718 /* FirebaseAnalytics */,
BA73DDCA2BC179F6009EE718 /* FirebaseCrashlytics */,
);
productName = "PyeonHaeng-iOS";
productReference = BAA4D9A92B5A1795005999F8 /* PyeonHaeng-iOS.app */;
Expand Down Expand Up @@ -621,6 +627,9 @@
ja,
);
mainGroup = BAA4D9A02B5A1795005999F8;
packageReferences = (
BA73DDC52BC179F6009EE718 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
productRefGroup = BAA4D9AA2B5A1795005999F8 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -1271,6 +1280,17 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
BA73DDC52BC179F6009EE718 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 10.23.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BA0564082B6248EA003D6DC7 /* HomeAPI */ = {
isa = XCSwiftPackageProductDependency;
Expand All @@ -1296,6 +1316,16 @@
isa = XCSwiftPackageProductDependency;
productName = NoticeAPISupport;
};
BA73DDC62BC179F6009EE718 /* FirebaseAnalytics */ = {
isa = XCSwiftPackageProductDependency;
package = BA73DDC52BC179F6009EE718 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAnalytics;
};
BA73DDCA2BC179F6009EE718 /* FirebaseCrashlytics */ = {
isa = XCSwiftPackageProductDependency;
package = BA73DDC52BC179F6009EE718 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseCrashlytics;
};
BAB569602B639F3000D1E0F9 /* DesignSystem */ = {
isa = XCSwiftPackageProductDependency;
productName = DesignSystem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "748c7837511d0e6a507737353af268484e1745e2",
"version" : "1.2024011601.1"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "c218c2054299b15ae577e818bbba16084d3eabe6",
"version" : "10.18.2"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "888f0b6026e2441a69e3ee2ad5293c7a92031e62",
"version" : "10.23.1"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "c7a5917ebe48d69f421aadf154ef3969c8b7f12d",
"version" : "10.23.1"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "a637d318ae7ae246b02d7305121275bc75ed5565",
"version" : "9.4.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "26c898aed8bed13b8a63057ee26500abbbcb8d55",
"version" : "7.13.1"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "e9fad491d0673bdda7063a0341fb6b47a30c5359",
"version" : "1.62.2"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "9534039303015a84837090d20fa21cae6e5eadb6",
"version" : "3.3.2"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "43aaef65e0c665daadf848761d560e446d350d3d",
"version" : "1.22.4"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "9f0c76544701845ad98716f3f6a774a892152bcb",
"version" : "1.26.0"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
ReferencedContainer = "container:PyeonHaeng-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-FIRDebugEnabled"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
Expand Down
2 changes: 2 additions & 0 deletions PyeonHaeng-iOS/Sources/PyeonHaengApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import DesignSystem
import FirebaseCore
import NetworkMonitor
import SwiftUI

Expand All @@ -17,6 +18,7 @@ struct PyeonHaengApp: App {
init() {
FontRegistrar.registerFonts() // 앱을 실행하기 전에 폰트를 로드합니다.
setupNavigationBarAppearance()
FirebaseApp.configure()
}

var body: some Scene {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import DesignSystem
import Entity
import FirebaseAnalytics
import SwiftUI

// MARK: - ConvenienceSelectBottomSheetView
Expand All @@ -24,6 +25,7 @@ struct ConvenienceSelectBottomSheetView<ViewModel>: View where ViewModel: HomeVi

ForEach(ConvenienceStore.allCases, id: \.self) { store in
Button {
Analytics.logEvent("change_conveniencestore", parameters: ["promotion": store.rawValue])
viewModel.trigger(.changeConvenienceStore(store))
dismiss()
} label: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import DesignSystem
import Entity
import FirebaseAnalytics
import SwiftUI

// MARK: - PromotionSelectBottomSheetView
Expand Down Expand Up @@ -41,6 +42,7 @@ struct PromotionSelectBottomSheetView<ViewModel>: View where ViewModel: HomeView
private var promotionButtons: some View {
ForEach(Promotion.allCases, id: \.self) { promotion in
Button {
Analytics.logEvent("change_promotion", parameters: ["promotion": promotion.rawValue])
viewModel.changePromotion(to: promotion)
dismiss()
} label: {
Expand Down
2 changes: 2 additions & 0 deletions PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import DesignSystem
import FirebaseAnalytics
import SwiftUI

// MARK: - HomeView
Expand Down Expand Up @@ -76,6 +77,7 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
}
}
}
.analyticsScreen(name: "main_countent", class: "\(Self.self)")
.tint(.accent)
.fullScreenCover(isPresented: $isOnboardingSheetOpen) {
OnboardingView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import DesignSystem
import FirebaseAnalytics
import SwiftUI

// MARK: - ProductInfoView
Expand Down Expand Up @@ -37,5 +38,10 @@ struct ProductInfoView<ViewModel>: View where ViewModel: ProductInfoViewModelRep
.onAppear {
viewModel.trigger(.fetchProduct)
}
.analyticsScreen(
name: "product_info_content",
class: "\(Self.self)",
extraParameters: ["product": viewModel.state.product.name]
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import DesignSystem
import Entity
import FirebaseAnalytics
import SwiftUI

// MARK: - SearchView
Expand Down Expand Up @@ -79,6 +80,7 @@ struct SearchView<ViewModel>: View where ViewModel: SearchViewModelRepresentable
}
}
}
.analyticsScreen(name: "search_content", class: "\(Self.self)")
.toolbar {
ToolbarItem(placement: .principal) {
SearchTextField<ViewModel>(text: $text)
Expand Down Expand Up @@ -111,7 +113,10 @@ private struct SearchTextField<ViewModel>: View where ViewModel: SearchViewModel
lineWidth: Metrics.textFieldBorderWidth
)
}
.onSubmit { viewModel.trigger(.textChanged(text)) }
.onSubmit {
Analytics.logEvent("search_product", parameters: ["product": text])
viewModel.trigger(.textChanged(text))
}
if !text.isEmpty {
Button {
text = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import DesignSystem
import FirebaseAnalytics
import SwiftUI

// MARK: - SettingsItem
Expand Down Expand Up @@ -35,6 +36,7 @@ struct SettingsView: View {
.scrollDisabled(true)
.navigationTitle("설정")
.navigationBarTitleDisplayMode(.inline)
.analyticsScreen(name: "settings_content", class: "\(Self.self)")
}
}

Expand Down

0 comments on commit fe82f63

Please sign in to comment.