Skip to content

Commit

Permalink
Merge pull request #109 from TeamHY2/Feature/#108-amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
Seokki-Kwon authored Nov 25, 2024
2 parents 71ac92d + 6262798 commit d54302e
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 57 deletions.
19 changes: 17 additions & 2 deletions HongikYeolgong2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
473E8EBA2CCEA702000F102C /* StudySessionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 473E8EB92CCEA702000F102C /* StudySessionResponseDTO.swift */; };
473E8EBC2CCEBEF3000F102C /* ModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 473E8EBB2CCEBEF3000F102C /* ModalView.swift */; };
4752A27D2CB96EB00073B784 /* CancleBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4752A27C2CB96EB00073B784 /* CancleBag.swift */; };
47581ED02CF01EB200A2EA31 /* AmplitudeSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 47581ECF2CF01EB200A2EA31 /* AmplitudeSwift */; };
475B86DD2CA1AEF7000534B2 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 475B86DC2CA1AEF7000534B2 /* HomeView.swift */; };
475B86DF2CA1AF1E000534B2 /* RecordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 475B86DE2CA1AF1E000534B2 /* RecordView.swift */; };
475B86E12CA1AF31000534B2 /* RankingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 475B86E02CA1AF31000534B2 /* RankingView.swift */; };
Expand Down Expand Up @@ -154,7 +155,6 @@
5E847A742CDBD52E0034C2A7 /* CalendarDataInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E847A732CDBD52E0034C2A7 /* CalendarDataInteractor.swift */; };
5E847A772CDBD5590034C2A7 /* AllStudyRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E847A762CDBD5590034C2A7 /* AllStudyRecord.swift */; };
5EAE88722CDF9B4500DCBA31 /* UserProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EAE88712CDF9B4500DCBA31 /* UserProfile.swift */; };
5ED93CD72CE2311D004A7931 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5ED93CD62CE2311D004A7931 /* GoogleService-Info.plist */; };
5ED93CDB2CE3690D004A7931 /* Secrets-prod.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 5ED93CDA2CE3690D004A7931 /* Secrets-prod.xcconfig */; };
98B5F00A2CDB362C007CF5FA /* Secrets-dev.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */; };
98B5F00C2CDB6226007CF5FA /* StudyTimeResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5F00B2CDB6226007CF5FA /* StudyTimeResponseDTO.swift */; };
Expand Down Expand Up @@ -334,7 +334,6 @@
5E847A732CDBD52E0034C2A7 /* CalendarDataInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarDataInteractor.swift; sourceTree = "<group>"; };
5E847A762CDBD5590034C2A7 /* AllStudyRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllStudyRecord.swift; sourceTree = "<group>"; };
5EAE88712CDF9B4500DCBA31 /* UserProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfile.swift; sourceTree = "<group>"; };
5ED93CD62CE2311D004A7931 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; };
5ED93CDA2CE3690D004A7931 /* Secrets-prod.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Secrets-prod.xcconfig"; sourceTree = "<group>"; };
98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Secrets-dev.xcconfig"; sourceTree = "<group>"; };
98B5F00B2CDB6226007CF5FA /* StudyTimeResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyTimeResponseDTO.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -364,6 +363,7 @@
47F71B592CDC68BC0044DEC5 /* FirebaseFirestoreCombine-Community in Frameworks */,
47F71B532CDC68BC0044DEC5 /* FirebaseAuthCombine-Community in Frameworks */,
47F71B632CDC813A0044DEC5 /* FirebaseFunctionsCombine-Community in Frameworks */,
47581ED02CF01EB200A2EA31 /* AmplitudeSwift in Frameworks */,
47C8154B2CE231810017EA24 /* SwiftJWT in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1073,6 +1073,7 @@
47F71B602CDC813A0044DEC5 /* FirebaseFunctions */,
47F71B622CDC813A0044DEC5 /* FirebaseFunctionsCombine-Community */,
47C8154A2CE231810017EA24 /* SwiftJWT */,
47581ECF2CF01EB200A2EA31 /* AmplitudeSwift */,
);
productName = HongikYeolgong2;
productReference = 47B1D4A82C9CB1740071B62B /* HongikYeolgong2.app */;
Expand Down Expand Up @@ -1149,6 +1150,7 @@
packageReferences = (
47F71B4F2CDC68BC0044DEC5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
47C815492CE231810017EA24 /* XCRemoteSwiftPackageReference "Swift-JWT" */,
47581ECE2CF01EB200A2EA31 /* XCRemoteSwiftPackageReference "Amplitude-Swift" */,
);
productRefGroup = 47B1D4A92C9CB1740071B62B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1731,6 +1733,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
47581ECE2CF01EB200A2EA31 /* XCRemoteSwiftPackageReference "Amplitude-Swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/amplitude/Amplitude-Swift";
requirement = {
branch = main;
kind = branch;
};
};
47C815492CE231810017EA24 /* XCRemoteSwiftPackageReference "Swift-JWT" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Kitura/Swift-JWT.git";
Expand All @@ -1750,6 +1760,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
47581ECF2CF01EB200A2EA31 /* AmplitudeSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 47581ECE2CF01EB200A2EA31 /* XCRemoteSwiftPackageReference "Amplitude-Swift" */;
productName = AmplitudeSwift;
};
47C8154A2CE231810017EA24 /* SwiftJWT */ = {
isa = XCSwiftPackageProductDependency;
package = 47C815492CE231810017EA24 /* XCRemoteSwiftPackageReference "Swift-JWT" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "37f87f153a7df0e69f7682478910cd31cbff8c536dc79a044414e38ba896c24f",
"originHash" : "2d278dd33b619da8a9340e2076758bc4da9f152353bae8b810225babaa366f5f",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand All @@ -10,6 +10,24 @@
"version" : "1.2024011602.0"
}
},
{
"identity" : "amplitude-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/amplitude/Amplitude-Swift",
"state" : {
"branch" : "main",
"revision" : "4097b2a7a0b8fc786c6feddc598f9f379de997af"
}
},
{
"identity" : "analytics-connector-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/amplitude/analytics-connector-ios.git",
"state" : {
"revision" : "decb203b5ce0e06091bbc5040acbf24fa85ebdce",
"version" : "1.3.0"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
private let cancleBag = CancelBag()
private let studySessionRepository: StudySessionRepository
private let timer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect()
private let addedTime: TimeInterval = .init(minutes: 31)
private let addedTime: TimeInterval = .init(hours: 6)

private var lastTime: Date?
private var subscription: AnyCancellable?
Expand Down
2 changes: 2 additions & 0 deletions HongikYeolgong2/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AmplitudeKey</key>
<string>$(AMPLITUDE_KEY)</string>
<key>AppleIdURL</key>
<string>$(APPLEID_API_URL)</string>
<key>BaseURL</key>
Expand Down
34 changes: 29 additions & 5 deletions HongikYeolgong2/Presentation/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
// Created by 권석기 on 9/23/24.
//

import SwiftUI
import Combine
import SwiftUI

import AmplitudeSwift

struct HomeView: View {
// MARK: - Properties
Expand Down Expand Up @@ -49,10 +51,10 @@ struct HomeView: View {
ActionButtonControllerView(
studySession: $studySession,
actions: .init(
endButtonTapped: { shouldShowEndUseModal.toggle() },
startButtonTapped: { shouldShowTimePicker.toggle() },
seatButtonTapped: { shouldShowWebView.toggle() },
addButtonTapped: { shouldShowAddTimeModal.toggle() }
endButtonTapped: endButtonTapped,
startButtonTapped: startButtonTapped,
seatButtonTapped: seatButtonTapped,
addButtonTapped: addButtonTapped
)
)

Expand Down Expand Up @@ -106,6 +108,28 @@ struct HomeView: View {
: studySessionInteractor.pauseStudy()
}
}
}

// MARK: - Helpers
extension HomeView {
func endButtonTapped() {
shouldShowEndUseModal.toggle()
Amplitude.instance.track(eventType: "StudyEndButton")
}

func startButtonTapped() {
shouldShowTimePicker.toggle()
Amplitude.instance.track(eventType: "StudyStartButton")
}

func seatButtonTapped() {
shouldShowWebView.toggle()
}

func addButtonTapped() {
shouldShowAddTimeModal.toggle()
Amplitude.instance.track(eventType: "StudyExtendButton")
}

func retryAction() {
weeklyStudyInteractor.getWeekyStudy(studyRecords: $studyRecords)
Expand Down
12 changes: 11 additions & 1 deletion HongikYeolgong2/Presentation/Root/HongikYeolgong2App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//

import SwiftUI
import AmplitudeSwift

@main
struct HongikYeolgong2App: App {
struct HongikYeolgong2App: App {
let enviroment = AppEnviroment.bootstrap()

var body: some Scene {
Expand All @@ -20,3 +21,12 @@ struct HongikYeolgong2App: App {
}
}
}

extension Amplitude {
static var instance = Amplitude(
configuration: Configuration(
apiKey: SecretKeys.ampliKey,
autocapture: [.sessions, .appLifecycles, .screenViews]
)
)
}
15 changes: 14 additions & 1 deletion HongikYeolgong2/Presentation/Root/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import AmplitudeSwift

enum Tab: CaseIterable {
case home
Expand Down Expand Up @@ -49,16 +50,28 @@ struct MainTabView: View {
TabView(selection: $currentTab,
content: {
HomeView()
.tag(Tab.home)
.tag(Tab.home)
.onAppear {
Amplitude.instance.track(eventType: "Home")
}

RecordView()
.tag(Tab.record)
.onAppear {
Amplitude.instance.track(eventType: "Record")
}

RankingView()
.tag(Tab.ranking)
.onAppear {
Amplitude.instance.track(eventType: "Ranking")
}

SettingView()
.tag(Tab.setting)
.onAppear {
Amplitude.instance.track(eventType: "Setting")
}
})
.overlay(alignment: .bottom) {
TabBarView(currentTab: $currentTab)
Expand Down
Loading

0 comments on commit d54302e

Please sign in to comment.