Skip to content

Commit

Permalink
Merge branch 'develop' into feat/Setup-Calendar-Synchronization-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok committed Jul 9, 2024
2 parents bd46905 + 5f4268c commit 6756630
Show file tree
Hide file tree
Showing 113 changed files with 2,441 additions and 849 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.

21 changes: 20 additions & 1 deletion Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
141F1D302B7328D4009E81EB /* WebviewCookiesUpdateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 141F1D2F2B7328D4009E81EB /* WebviewCookiesUpdateProtocol.swift */; };
142EDD6C2B831D1400F9F320 /* BranchSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 142EDD6B2B831D1400F9F320 /* BranchSDK */; };
14769D3C2B9822EE00AB36D4 /* CoreAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14769D3B2B9822EE00AB36D4 /* CoreAnalytics.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 @@ -346,11 +349,14 @@
0E13E9173C9C4CFC19F8B6F2 /* Pods-App-Core.debugstage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Core.debugstage.xcconfig"; path = "Target Support Files/Pods-App-Core/Pods-App-Core.debugstage.xcconfig"; sourceTree = "<group>"; };
141F1D2F2B7328D4009E81EB /* WebviewCookiesUpdateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebviewCookiesUpdateProtocol.swift; sourceTree = "<group>"; };
14769D3B2B9822EE00AB36D4 /* CoreAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreAnalytics.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 @@ -732,6 +738,7 @@
0770DE7728D0C49E006D8A5D /* Base */ = {
isa = PBXGroup;
children = (
9784D47C2BF7761F00AFEFFF /* FullScreenErrorView */,
064987882B4D69FE0071642A /* Webview */,
E0D586352B314CD3009B4BA7 /* LogistrationBottomView.swift */,
02A4833B29B8C57800D33F33 /* DownloadView.swift */,
Expand Down Expand Up @@ -784,6 +791,14 @@
path = Analytics;
sourceTree = "<group>";
};
9784D47C2BF7761F00AFEFFF /* FullScreenErrorView */ = {
isa = PBXGroup;
children = (
9784D47D2BF7762800AFEFFF /* FullScreenErrorView.swift */,
);
path = FullScreenErrorView;
sourceTree = "<group>";
};
BA30427C2B20B235009B64B7 /* SocialAuth */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -874,6 +889,7 @@
02CA59832BD7DDBE00D517AA /* DashboardConfig.swift */,
A53A32342B233DEC005FE38A /* ThemeConfig.swift */,
E0D586192B2FF74C009B4BA7 /* DiscoveryConfig.swift */,
14D912D82C2553C70077CCCE /* FullStoryConfig.swift */,
);
path = Config;
sourceTree = "<group>";
Expand All @@ -891,6 +907,7 @@
children = (
E09179FC2B0F204D002AB695 /* ConfigTests.swift */,
BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */,
14D912DA2C257E9E0077CCCE /* FullStoryConfigTests.swift */,
);
path = Configuration;
sourceTree = "<group>";
Expand Down Expand Up @@ -1078,6 +1095,7 @@
buildActionMask = 2147483647;
files = (
BAD9CA422B2B140100DE790A /* AgreementConfigTests.swift in Sources */,
14D912DB2C257E9E0077CCCE /* FullStoryConfigTests.swift in Sources */,
E09179FD2B0F204E002AB695 /* ConfigTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1144,7 +1162,9 @@
0260E58028FD792800BBBE18 /* WebUnitViewModel.swift in Sources */,
02A4833A29B8A9AB00D33F33 /* DownloadManager.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 */,
064987992B4D69FF0071642A /* WebViewScriptInjectionProtocol.swift in Sources */,
Expand Down Expand Up @@ -1235,7 +1255,6 @@
02F164372902A9EB0090DDEF /* StringExtension.swift in Sources */,
0231CDBE2922422D00032416 /* CSSInjector.swift in Sources */,
064987982B4D69FF0071642A /* CSSInjectionProtocol.swift in Sources */,
BAAD62C62AFCF00B000E6103 /* CustomDisclosureGroup.swift in Sources */,
029EE3ED2BF6650500F64F33 /* Bundle.swift in Sources */,
BADB3F5B2AD6EC56004D5CFA /* ResultExtension.swift in Sources */,
0236961928F9A26900EEF206 /* AuthRepository.swift in Sources */,
Expand Down
20 changes: 20 additions & 0 deletions 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 All @@ -28,13 +30,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 @@ -124,6 +136,10 @@ public enum AnalyticsEvent: String {
case whatnewPopup = "WhatsNew:Pop up Viewed"
case whatnewDone = "WhatsNew:Done"
case whatnewClose = "WhatsNew:Close"
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 @@ -205,6 +221,10 @@ public enum EventBIValue: String {
case whatnewPopup = "edx.bi.app.whats_new.popup.viewed"
case whatnewDone = "edx.bi.app.whats_new.done"
case whatnewClose = "edx.bi.app.whats_new.close"
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 @@ -31,6 +31,7 @@ public protocol ConfigProtocol {
var segment: SegmentConfig { get }
var program: DiscoveryConfig { get }
var URIScheme: 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,15 +8,24 @@
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 getCourseDates = Notification.Name("getCourseDates")
static let refreshEnrollments = Notification.Name("refreshEnrollments")
}

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

0 comments on commit 6756630

Please sign in to comment.