Skip to content

Commit

Permalink
chore: merge upstream develop into 2u develop (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir authored Jul 12, 2024
1 parent fa8eb3f commit 6b06d96
Show file tree
Hide file tree
Showing 112 changed files with 2,493 additions and 891 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ default_config/
I18N/
*.lproj/
!en.lproj/
/config_script/__pycache__
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import Core

public enum AuthMethod: Equatable {
case password
Expand Down Expand Up @@ -40,6 +41,7 @@ public protocol AuthorizationAnalytics {
func forgotPasswordClicked()
func resetPasswordClicked()
func resetPassword(success: Bool)
func authTrackScreenEvent(_ event: AnalyticsEvent, biValue: EventBIValue)
}

#if DEBUG
Expand All @@ -54,5 +56,6 @@ class AuthorizationAnalyticsMock: AuthorizationAnalytics {
public func forgotPasswordClicked() {}
public func resetPasswordClicked() {}
public func resetPassword(success: Bool) {}
public func authTrackScreenEvent(_ event: AnalyticsEvent, biValue: EventBIValue) {}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ public struct SignInView: View {
.hideNavigationBar()
.ignoresSafeArea(.all, edges: .horizontal)
.background(Theme.Colors.background.ignoresSafeArea(.all))
.onFirstAppear{
viewModel.trackScreenEvent()
}
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class SignInViewModel: ObservableObject {
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: .password)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
failure(error)
}
Expand Down Expand Up @@ -113,6 +114,7 @@ public class SignInViewModel: ObservableObject {
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: authMethod)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
failure(error, authMethod: authMethod)
}
Expand Down Expand Up @@ -145,5 +147,11 @@ public class SignInViewModel: ObservableObject {
func trackForgotPasswordClicked() {
analytics.forgotPasswordClicked()
}


func trackScreenEvent() {
analytics.authTrackScreenEvent(
.logistrationSignIn,
biValue: .logistrationSignIn
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public struct SignUpView: View {
.ignoresSafeArea(.all, edges: .horizontal)
.background(Theme.Colors.background.ignoresSafeArea(.all))
.hideNavigationBar()
.onFirstAppear{
viewModel.trackScreenEvent()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public class SignUpViewModel: ObservableObject {
analytics.registrationSuccess(method: authMetod.analyticsValue)
isShowProgress = false
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)

NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
isShowProgress = false
if case APIError.invalidGrant = error {
Expand Down Expand Up @@ -193,6 +193,7 @@ public class SignUpViewModel: ObservableObject {
analytics.userLogin(method: authMethod)
isShowProgress = false
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch {
update(fullName: response.name, email: response.email)
self.externalToken = response.token
Expand All @@ -212,4 +213,11 @@ public class SignUpViewModel: ObservableObject {
func trackCreateAccountClicked() {
analytics.createAccountClicked()
}

func trackScreenEvent() {
analytics.authTrackScreenEvent(
.logistrationRegister,
biValue: .logistrationRegister
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public struct StartupView: View {
.onTapGesture {
UIApplication.shared.endEditing()
}
.onFirstAppear {
viewModel.trackScreenEvent()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ public class StartupViewModel: ObservableObject {
analytics.trackEvent(.logistrationExploreAllCourses, biValue: .logistrationExploreAllCourses)
}
}

func trackScreenEvent() {
analytics.trackScreenEvent(.logistration, biValue: .logistration)
}
}
95 changes: 95 additions & 0 deletions Authorization/AuthorizationTests/AuthorizationMock.generated.swift

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
14DE13DA2BDF7E5E0059168F /* IAPConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14DE13D92BDF7E5E0059168F /* IAPConfig.swift */; };
14DE13DC2BDF83350059168F /* ServerConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14DE13DB2BDF83350059168F /* ServerConfig.swift */; };
14F8E66B2C0F4D1200E4EF69 /* RestoreInProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14F8E66A2C0F4D1200E4EF69 /* RestoreInProgressView.swift */; };
14D912D92C2553C70077CCCE /* FullStoryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D912D82C2553C70077CCCE /* FullStoryConfig.swift */; };
14D912DB2C257E9E0077CCCE /* FullStoryConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D912DA2C257E9E0077CCCE /* FullStoryConfigTests.swift */; };
9784D47E2BF7762800AFEFFF /* FullScreenErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9784D47D2BF7762800AFEFFF /* FullScreenErrorView.swift */; };
A51CDBE72B6D21F2009B6D4E /* SegmentConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51CDBE62B6D21F2009B6D4E /* SegmentConfig.swift */; };
A53A32352B233DEC005FE38A /* ThemeConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53A32342B233DEC005FE38A /* ThemeConfig.swift */; };
A595689B2B6173DF00ED4F90 /* BranchConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A595689A2B6173DF00ED4F90 /* BranchConfig.swift */; };
Expand Down Expand Up @@ -401,11 +404,14 @@
14DE13D92BDF7E5E0059168F /* IAPConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IAPConfig.swift; sourceTree = "<group>"; };
14DE13DB2BDF83350059168F /* ServerConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerConfig.swift; sourceTree = "<group>"; };
14F8E66A2C0F4D1200E4EF69 /* RestoreInProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreInProgressView.swift; sourceTree = "<group>"; };
14D912D82C2553C70077CCCE /* FullStoryConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullStoryConfig.swift; sourceTree = "<group>"; };
14D912DA2C257E9E0077CCCE /* FullStoryConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullStoryConfigTests.swift; sourceTree = "<group>"; };
1A154A95AF4EE85A4A1C083B /* Pods-App-Core.releasedev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.releasedev.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.releasedev.xcconfig"; sourceTree = "<group>"; };
2B7E6FE7843FC4CF2BFA712D /* Pods-App-Core.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debug.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debug.xcconfig"; sourceTree = "<group>"; };
349B90CD6579F7B8D257E515 /* Pods_App_Core.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App_Core.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B74C6685E416657F3C5F5A8 /* Pods-App-Core.releaseprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.releaseprod.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.releaseprod.xcconfig"; sourceTree = "<group>"; };
60153262DBC2F9E660D7E11B /* Pods-App-Core.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.release.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.release.xcconfig"; sourceTree = "<group>"; };
9784D47D2BF7762800AFEFFF /* FullScreenErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FullScreenErrorView.swift; sourceTree = "<group>"; };
9D5B06CAA99EA5CD49CBE2BB /* Pods-App-Core.debugdev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debugdev.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debugdev.xcconfig"; sourceTree = "<group>"; };
A51CDBE62B6D21F2009B6D4E /* SegmentConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentConfig.swift; sourceTree = "<group>"; };
A53A32342B233DEC005FE38A /* ThemeConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeConfig.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -838,6 +844,7 @@
0770DE7728D0C49E006D8A5D /* Base */ = {
isa = PBXGroup;
children = (
9784D47C2BF7761F00AFEFFF /* FullScreenErrorView */,
064987882B4D69FE0071642A /* Webview */,
E0D586352B314CD3009B4BA7 /* LogistrationBottomView.swift */,
02A4833B29B8C57800D33F33 /* DownloadView.swift */,
Expand Down Expand Up @@ -936,6 +943,14 @@
14DE13DB2BDF83350059168F /* ServerConfig.swift */,
);
path = ServerConfig;
sourceTree = "<group>";
};
9784D47C2BF7761F00AFEFFF /* FullScreenErrorView */ = {
isa = PBXGroup;
children = (
9784D47D2BF7762800AFEFFF /* FullScreenErrorView.swift */,
);
path = FullScreenErrorView;
sourceTree = "<group>";
};
BA30427C2B20B235009B64B7 /* SocialAuth */ = {
Expand Down Expand Up @@ -1028,6 +1043,7 @@
02CA59832BD7DDBE00D517AA /* DashboardConfig.swift */,
A53A32342B233DEC005FE38A /* ThemeConfig.swift */,
E0D586192B2FF74C009B4BA7 /* DiscoveryConfig.swift */,
14D912D82C2553C70077CCCE /* FullStoryConfig.swift */,
);
path = Config;
sourceTree = "<group>";
Expand All @@ -1046,6 +1062,7 @@
children = (
E09179FC2B0F204D002AB695 /* ConfigTests.swift */,
BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */,
14D912DA2C257E9E0077CCCE /* FullStoryConfigTests.swift */,
);
path = Configuration;
sourceTree = "<group>";
Expand Down Expand Up @@ -1236,6 +1253,7 @@
files = (
BAD9CA422B2B140100DE790A /* AgreementConfigTests.swift in Sources */,
14A832662BD8D5BD00E5654D /* Dictionary+SafeAccessTests.swift in Sources */,
14D912DB2C257E9E0077CCCE /* FullStoryConfigTests.swift in Sources */,
E09179FD2B0F204E002AB695 /* ConfigTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1308,7 +1326,9 @@
02A4833A29B8A9AB00D33F33 /* DownloadManager.swift in Sources */,
14DE13DC2BDF83350059168F /* ServerConfig.swift in Sources */,
06078B702BA49C3100576798 /* Dictionary+JSON.swift in Sources */,
9784D47E2BF7762800AFEFFF /* FullScreenErrorView.swift in Sources */,
027BD3AE2909475000392132 /* KeyboardScrollerOptions.swift in Sources */,
14D912D92C2553C70077CCCE /* FullStoryConfig.swift in Sources */,
BAFB99922B14E23D007D09F9 /* AppleSignInConfig.swift in Sources */,
141F1D302B7328D4009E81EB /* WebviewCookiesUpdateProtocol.swift in Sources */,
062C69B32C198337002BD311 /* PaymentSnackbarModifierViewModel.swift in Sources */,
Expand Down
21 changes: 20 additions & 1 deletion Core/Core/Analytics/CoreAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Foundation
public protocol CoreAnalytics {
func trackEvent(_ event: AnalyticsEvent, parameters: [String: Any]?)
func trackEvent(_ event: AnalyticsEvent, biValue: EventBIValue, parameters: [String: Any]?)
func trackScreenEvent(_ event: AnalyticsEvent, parameters: [String: Any]?)
func trackScreenEvent(_ event: AnalyticsEvent, biValue: EventBIValue, parameters: [String: Any]?)
func appreview(_ event: AnalyticsEvent, biValue: EventBIValue, action: String?, rating: Int?)
func videoQualityChanged(
_ event: AnalyticsEvent,
Expand Down Expand Up @@ -104,13 +106,23 @@ public extension CoreAnalytics {
func trackEvent(_ event: AnalyticsEvent, biValue: EventBIValue) {
trackEvent(event, biValue: biValue, parameters: nil)
}

func trackScreenEvent(_ event: AnalyticsEvent) {
trackScreenEvent(event, parameters: nil)
}

func trackScreenEvent(_ event: AnalyticsEvent, biValue: EventBIValue) {
trackScreenEvent(event, biValue: biValue, parameters: nil)
}
}

#if DEBUG
public class CoreAnalyticsMock: CoreAnalytics {
public init() {}
public func trackEvent(_ event: AnalyticsEvent, parameters: [String: Any]? = nil) {}
public func trackEvent(_ event: AnalyticsEvent, biValue: EventBIValue, parameters: [String: Any]?) {}
public func trackScreenEvent(_ event: AnalyticsEvent, parameters: [String: Any]?) {}
public func trackScreenEvent(_ event: AnalyticsEvent, biValue: EventBIValue, parameters: [String: Any]?) {}
public func appreview(_ event: AnalyticsEvent, biValue: EventBIValue, action: String? = nil, rating: Int? = 0) {}
public func videoQualityChanged(
_ event: AnalyticsEvent,
Expand Down Expand Up @@ -284,7 +296,10 @@ public enum AnalyticsEvent: String {
case courseUpgradeSuccess = "Payments: Course Upgrade Success"
case courseUpgradeUnfulfilledPurchaseInitiated = "Payments: Unfulfilled Purchase Initiated"
case courseUpgradeRestorePurchaseClicked = "Payments: Restore Purchases Clicked"

case logistration = "Logistration"
case logistrationSignIn = "Logistration:Sign In"
case logistrationRegister = "Logistration:Register"
case profileEdit = "Profile:Edit Profile"
}

public enum EventBIValue: String {
Expand Down Expand Up @@ -375,6 +390,10 @@ public enum EventBIValue: String {
case courseUpgradeSuccess = "edx.bi.app.payments.course_upgrade_success"
case courseUpgradeUnfulfilledPurchaseInitiated = "edx.bi.app.payments.unfulfilled_purchase.initiated"
case courseUpgradeRestorePurchaseClicked = "edx.bi.app.payments.restore_purchases.clicked"
case logistration = "edx.bi.app.logistration"
case logistrationSignIn = "edx.bi.app.logistration.signin"
case logistrationRegister = "edx.bi.app.logistration.register"
case profileEdit = "edx.bi.app.profile.edit"
}

public struct EventParamKey {
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public protocol ConfigProtocol {
var program: DiscoveryConfig { get }
var URIScheme: String { get }
var ecommerceURL: String? { get }
var fullStory: FullStoryConfig { get }
}

public enum TokenType: String {
Expand Down
30 changes: 30 additions & 0 deletions Core/Core/Configuration/Config/FullStoryConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// FullStoryConfig.swift
// Core
//
// Created by Saeed Bashir on 6/21/24.
//

import Foundation

private enum Keys: String, RawStringExtractable {
case enabled = "ENABLED"
case orgID = "ORG_ID"
}

public final class FullStoryConfig {
public var enabled: Bool = false
public var orgID: String = ""

init(dictionary: [String: AnyObject]) {
orgID = dictionary[Keys.orgID] as? String ?? ""
enabled = !orgID.isEmpty && dictionary[Keys.enabled] as? Bool ?? false
}
}

private let configKey = "FULLSTORY"
extension Config {
public var fullStory: FullStoryConfig {
FullStoryConfig(dictionary: self[configKey] as? [String: AnyObject] ?? [:])
}
}
2 changes: 2 additions & 0 deletions Core/Core/Data/CoreStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
public protocol CoreStorage {
var accessToken: String? {get set}
var refreshToken: String? {get set}
var pushToken: String? {get set}
var appleSignFullName: String? {get set}
var appleSignEmail: String? {get set}
var cookiesDate: String? {get set}
Expand All @@ -25,6 +26,7 @@ public protocol CoreStorage {
public class CoreStorageMock: CoreStorage {
public var accessToken: String?
public var refreshToken: String?
public var pushToken: String?
public var appleSignFullName: String?
public var appleSignEmail: String?
public var cookiesDate: String?
Expand Down
11 changes: 5 additions & 6 deletions Core/Core/Data/Persistence/CorePersistenceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ public protocol CorePersistenceProtocol {
func set(userId: Int)
func getUserID() -> Int?
func publisher() -> AnyPublisher<Int, Never>
func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality)
func nextBlockForDownloading() -> DownloadDataTask?
func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality) async
func nextBlockForDownloading() async -> DownloadDataTask?
func updateDownloadState(id: String, state: DownloadState, resumeData: Data?)
func deleteDownloadDataTask(id: String) throws
func deleteDownloadDataTask(id: String) async throws
func saveDownloadDataTask(_ task: DownloadDataTask)
func downloadDataTask(for blockId: String) -> DownloadDataTask?
func downloadDataTask(for blockId: String, completion: @escaping (DownloadDataTask?) -> Void)
func getDownloadDataTasks(completion: @escaping ([DownloadDataTask]) -> Void)
func getDownloadDataTasksForCourse(_ courseId: String, completion: @escaping ([DownloadDataTask]) -> Void)
func getDownloadDataTasks() async -> [DownloadDataTask]
func getDownloadDataTasksForCourse(_ courseId: String) async -> [DownloadDataTask]
}

public final class CoreBundle {
Expand Down
11 changes: 10 additions & 1 deletion Core/Core/Extensions/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
import Foundation

public extension Notification.Name {
static let userAuthorized = Notification.Name("userAuthorized")
static let userLoggedOut = Notification.Name("userLoggedOut")
static let onCourseEnrolled = Notification.Name("onCourseEnrolled")
static let onblockCompletionRequested = Notification.Name("onblockCompletionRequested")
static let onTokenRefreshFailed = Notification.Name("onTokenRefreshFailed")
static let onActualVersionReceived = Notification.Name("onActualVersionReceived")
static let onAppUpgradeAccountSettingsTapped = Notification.Name("onAppUpgradeAccountSettingsTapped")
static let onNewVersionAvaliable = Notification.Name("onNewVersionAvaliable")
static let webviewReloadNotification = Notification.Name("webviewReloadNotification")
static let onBlockCompletion = Notification.Name.init("onBlockCompletion")
static let onBlockCompletion = Notification.Name("onBlockCompletion")
static let shiftCourseDates = Notification.Name("shiftCourseDates")
static let profileUpdated = Notification.Name("profileUpdated")
static let unfullfilledTransctionsNotification = Notification.Name("unfullfilledTransctionsNotification")
static let courseUpgradeCompletionNotification = Notification.Name("CourseUpgradeCompletionNotification")
static let getCourseDates = Notification.Name("getCourseDates")
static let refreshEnrollments = Notification.Name("refreshEnrollments")
}

public extension Notification {
enum UserInfoKey: String {
case isForced
}
}
Loading

0 comments on commit 6b06d96

Please sign in to comment.