Skip to content

Commit

Permalink
🔀 Google Analytics 연동 (#144)
Browse files Browse the repository at this point in the history
* 🙈 Add GoogleService-Info.plist to Resources folder.

* ✨ Add Firebase Analytics for tracking user behavior

* 👷 Add GoogleService-Info.plist as a GitHub Secret and decode in CI

* ✏️ Fix typo
  • Loading branch information
WhiteHyun authored May 6, 2024
1 parent 1431bf4 commit 7403f2f
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ jobs:
env:
APPCONFIG: ${{ secrets.XCCONFIG }}
run: |
mkdir XCConfig
mkdir -p XCConfig
echo $APPCONFIG | base64 --decode > ./XCConfig/Shared.xcconfig
- name: Create GoogleService-Info.plist
env:
GOOGLE_SERVICE_INFO_BASE64: ${{ secrets.GOOGLE_INFO_PLIST }}
run: |
echo $GOOGLE_SERVICE_INFO_BASE64 | base64 --decode > ./PyeonHaeng-iOS/Resources/GoogleService-Info.plist
- name: Set Default Scheme
run: |
scheme_list=$(xcodebuild -list -json | tr -d "\n")
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,10 @@ xcuserdata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings

XCConfig/*

# End of https://www.toptal.com/developers/gitignore/api/macos,xcode,swift,swiftpackagemanager

### Custom ###
XCConfig/*
GoogleService-Info.plist

34 changes: 34 additions & 0 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
BA4EA3602B6A37E10003DCE7 /* Entity in Frameworks */ = {isa = PBXBuildFile; productRef = BA4EA35F2B6A37E10003DCE7 /* Entity */; };
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 @@ -124,6 +127,7 @@
BA28F1A72B6157E90052855E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA402F7D2B85E31800E86AAD /* ConvenienceSelectBottomSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvenienceSelectBottomSheetView.swift; sourceTree = "<group>"; };
BA4EA35A2B6A00F70003DCE7 /* Entity */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Entity; sourceTree = "<group>"; };
BA73DDC32BC17912009EE718 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
BA849A362B8F4FC0004495BF /* MockPaginatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPaginatable.swift; sourceTree = "<group>"; };
BA8E83232B8EF83B00FE968C /* ProductConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductConfiguration.swift; sourceTree = "<group>"; };
BA9903552BBBD9F500DC3ED3 /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -185,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 @@ -254,6 +260,7 @@
BA28F1702B6152E90052855E /* Resources */ = {
isa = PBXGroup;
children = (
BA73DDC32BC17912009EE718 /* GoogleService-Info.plist */,
BA28F1A72B6157E90052855E /* Info.plist */,
BAA4D9B02B5A1796005999F8 /* Assets.xcassets */,
BA9903552BBBD9F500DC3ED3 /* InfoPlist.xcstrings */,
Expand Down Expand Up @@ -560,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 @@ -618,6 +627,9 @@
ja,
);
mainGroup = BAA4D9A02B5A1795005999F8;
packageReferences = (
BA73DDC52BC179F6009EE718 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
productRefGroup = BAA4D9AA2B5A1795005999F8 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -650,6 +662,7 @@
BA28F1A12B61572A0052855E /* Pretendard-Thin.otf in Resources */,
BA28F1A62B61572A0052855E /* Pretendard-Black.otf in Resources */,
BA28F1A52B61572A0052855E /* Pretendard-Light.otf in Resources */,
BA73DDC42BC17912009EE718 /* GoogleService-Info.plist in Resources */,
BA28F1A42B61572A0052855E /* Pretendard-ExtraBold.otf in Resources */,
BA28F1A02B61572A0052855E /* Pretendard-Regular.otf in Resources */,
BAA4D9B12B5A1796005999F8 /* Assets.xcassets in Resources */,
Expand Down Expand Up @@ -1267,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 @@ -1292,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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import SwiftUI

struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
@EnvironmentObject private var viewModel: ViewModel
@State private var convenienceStoreModalPresented: Bool = false
@State private var promotionModalPresented: Bool = false
@State private var convenienceStoreModalPresented = false
@State private var promotionModalPresented = false

var body: some View {
HStack {
Expand Down
4 changes: 3 additions & 1 deletion PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
//

import DesignSystem
import FirebaseAnalytics
import SwiftUI

// MARK: - HomeView

struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
@StateObject private var viewModel: ViewModel
@State private var isOnboardingSheetOpen = false
@AppStorage("isFirstLaunch") private var isFirstLaunch: Bool = false
@AppStorage("isFirstLaunch") private var isFirstLaunch = false
@Environment(\.injected) private var container

init(viewModel: @autoclosure @escaping () -> ViewModel) {
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 @@ -16,7 +16,7 @@ struct ProductInfoLineGraphView<ViewModel>: View where ViewModel: ProductInfoVie
@EnvironmentObject private var viewModel: ViewModel

@State private var offset: CGSize = .zero
@State private var index: Int = 0
@State private var index = 0
@State private var frameSize: CGSize = .zero
@State private var symbolLocations: [CGPoint] = []

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]
)
}
}
Loading

0 comments on commit 7403f2f

Please sign in to comment.