Skip to content

Commit

Permalink
refactor: address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Nov 11, 2024
1 parent e4cc212 commit 60a8e94
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public struct StartupView: View {
searchQuery: searchQuery,
sourceScreen: .startup
)
viewModel.logAnalytics(searchQuery: nil)
viewModel.logAnalytics()
} label: {
Text(AuthLocalization.Startup.exploreAllCourses)
.underline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StartupViewModel: ObservableObject {
self.analytics = analytics
}

func logAnalytics(searchQuery: String?) {
func logAnalytics(searchQuery: String? = nil) {
if let searchQuery {
analytics.trackEvent(
.logistrationCoursesSearch,
Expand Down
4 changes: 2 additions & 2 deletions Core/Core/Analytics/CoreAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public enum AnalyticsEvent: String {
case bulkDeleteVideosSubsection = "Videos:Delete Subsection Videos"
case bulkDeleteVideosSection = "Videos:Delete Section Videos"
case videoLoaded = "Video:Loaded"
case videoChangeSpeed = "Video:Change Speed"
case videoSpeedChange = "Video:Change Speed"
case videoPlayed = "Video:Played"
case videoPaused = "Video:Paused"
case videoCompleted = "Video:Completed"
Expand Down Expand Up @@ -384,7 +384,7 @@ public enum EventBIValue: String {
case bulkDownloadVideosSection = "edx.bi.video.section.bulkdownload"
case bulkDeleteVideosSection = "edx.bi.app.video.delete.section"
case videoLoaded = "edx.bi.app.videos.loaded"
case videoChangeSpeed = "edx.bi.app.videos.speed.changed"
case videoSpeedChange = "edx.bi.app.videos.speed.changed"
case videoPlayed = "edx.bi.app.videos.played"
case videoPaused = "edx.bi.app.videos.paused"
case videoCompleted = "edx.bi.app.videos.completed"
Expand Down
4 changes: 2 additions & 2 deletions Course/Course/Presentation/CourseAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public protocol CourseAnalytics {

func videoPlayed(courseID: String, blockID: String, videoURL: String)

func videoChangeSpeed(
func videoSpeedChange(
courseID: String,
blockID: String,
videoURL: String,
Expand Down Expand Up @@ -255,7 +255,7 @@ class CourseAnalyticsMock: CourseAnalytics {

public func videoPlayed(courseID: String, blockID: String, videoURL: String) {}

public func videoChangeSpeed(
public func videoSpeedChange(
courseID: String,
blockID: String,
videoURL: String,
Expand Down
6 changes: 3 additions & 3 deletions Course/Course/Presentation/Video/VideoPlayerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class VideoPlayerViewModel: ObservableObject {
playerHolder.getRatePublisher()
.sink {[weak self] rate in
guard self?.isLoading == false else { return }
self?.trackVideoChangeSpeed(rate: rate)
self?.trackVideoSpeedChange(rate: rate)
}
.store(in: &subscription)

Expand Down Expand Up @@ -221,7 +221,7 @@ public class VideoPlayerViewModel: ObservableObject {
)
}

private func trackVideoChangeSpeed(rate: Float) {
private func trackVideoSpeedChange(rate: Float) {
if rate == 0 {
analytics?.videoPaused(
courseID: playerHolder.courseID,
Expand All @@ -244,7 +244,7 @@ public class VideoPlayerViewModel: ObservableObject {
videoURL: playerHolder.url?.absoluteString ?? ""
)
} else {
analytics?.videoChangeSpeed(
analytics?.videoSpeedChange(
courseID: playerHolder.courseID,
blockID: playerHolder.blockID,
videoURL: playerHolder.url?.absoluteString ?? "",
Expand Down
20 changes: 10 additions & 10 deletions Course/CourseTests/CourseMock.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2032,9 +2032,9 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
perform?(`courseID`, `blockID`, `videoURL`)
}

open func videoChangeSpeed(courseID: String, blockID: String, videoURL: String, oldSpeed: Float, newSpeed: Float, currentTime: Double, duration: Double) {
addInvocation(.m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>.value(`courseID`), Parameter<String>.value(`blockID`), Parameter<String>.value(`videoURL`), Parameter<Float>.value(`oldSpeed`), Parameter<Float>.value(`newSpeed`), Parameter<Double>.value(`currentTime`), Parameter<Double>.value(`duration`)))
let perform = methodPerformValue(.m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>.value(`courseID`), Parameter<String>.value(`blockID`), Parameter<String>.value(`videoURL`), Parameter<Float>.value(`oldSpeed`), Parameter<Float>.value(`newSpeed`), Parameter<Double>.value(`currentTime`), Parameter<Double>.value(`duration`))) as? (String, String, String, Float, Float, Double, Double) -> Void
open func videoSpeedChange(courseID: String, blockID: String, videoURL: String, oldSpeed: Float, newSpeed: Float, currentTime: Double, duration: Double) {
addInvocation(.m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>.value(`courseID`), Parameter<String>.value(`blockID`), Parameter<String>.value(`videoURL`), Parameter<Float>.value(`oldSpeed`), Parameter<Float>.value(`newSpeed`), Parameter<Double>.value(`currentTime`), Parameter<Double>.value(`duration`)))
let perform = methodPerformValue(.m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>.value(`courseID`), Parameter<String>.value(`blockID`), Parameter<String>.value(`videoURL`), Parameter<Float>.value(`oldSpeed`), Parameter<Float>.value(`newSpeed`), Parameter<Double>.value(`currentTime`), Parameter<Double>.value(`duration`))) as? (String, String, String, Float, Float, Double, Double) -> Void
perform?(`courseID`, `blockID`, `videoURL`, `oldSpeed`, `newSpeed`, `currentTime`, `duration`)
}

Expand Down Expand Up @@ -2080,7 +2080,7 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
case m_bulkDeleteVideosSection__courseID_courseIDsectionId_sectionIdvideos_videos(Parameter<String>, Parameter<String>, Parameter<Int>)
case m_videoLoaded__courseID_courseIDblockID_blockIDvideoURL_videoURL(Parameter<String>, Parameter<String>, Parameter<String>)
case m_videoPlayed__courseID_courseIDblockID_blockIDvideoURL_videoURL(Parameter<String>, Parameter<String>, Parameter<String>)
case m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>, Parameter<String>, Parameter<String>, Parameter<Float>, Parameter<Float>, Parameter<Double>, Parameter<Double>)
case m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(Parameter<String>, Parameter<String>, Parameter<String>, Parameter<Float>, Parameter<Float>, Parameter<Double>, Parameter<Double>)
case m_videoPaused__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(Parameter<String>, Parameter<String>, Parameter<String>, Parameter<Double>, Parameter<Double>)
case m_videoCompleted__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(Parameter<String>, Parameter<String>, Parameter<String>, Parameter<Double>, Parameter<Double>)

Expand Down Expand Up @@ -2292,7 +2292,7 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsVideourl, rhs: rhsVideourl, with: matcher), lhsVideourl, rhsVideourl, "videoURL"))
return Matcher.ComparisonResult(results)

case (.m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(let lhsCourseid, let lhsBlockid, let lhsVideourl, let lhsOldspeed, let lhsNewspeed, let lhsCurrenttime, let lhsDuration), .m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(let rhsCourseid, let rhsBlockid, let rhsVideourl, let rhsOldspeed, let rhsNewspeed, let rhsCurrenttime, let rhsDuration)):
case (.m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(let lhsCourseid, let lhsBlockid, let lhsVideourl, let lhsOldspeed, let lhsNewspeed, let lhsCurrenttime, let lhsDuration), .m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(let rhsCourseid, let rhsBlockid, let rhsVideourl, let rhsOldspeed, let rhsNewspeed, let rhsCurrenttime, let rhsDuration)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsCourseid, rhs: rhsCourseid, with: matcher), lhsCourseid, rhsCourseid, "courseID"))
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsBlockid, rhs: rhsBlockid, with: matcher), lhsBlockid, rhsBlockid, "blockID"))
Expand Down Expand Up @@ -2354,7 +2354,7 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
case let .m_bulkDeleteVideosSection__courseID_courseIDsectionId_sectionIdvideos_videos(p0, p1, p2): return p0.intValue + p1.intValue + p2.intValue
case let .m_videoLoaded__courseID_courseIDblockID_blockIDvideoURL_videoURL(p0, p1, p2): return p0.intValue + p1.intValue + p2.intValue
case let .m_videoPlayed__courseID_courseIDblockID_blockIDvideoURL_videoURL(p0, p1, p2): return p0.intValue + p1.intValue + p2.intValue
case let .m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(p0, p1, p2, p3, p4, p5, p6): return p0.intValue + p1.intValue + p2.intValue + p3.intValue + p4.intValue + p5.intValue + p6.intValue
case let .m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(p0, p1, p2, p3, p4, p5, p6): return p0.intValue + p1.intValue + p2.intValue + p3.intValue + p4.intValue + p5.intValue + p6.intValue
case let .m_videoPaused__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(p0, p1, p2, p3, p4): return p0.intValue + p1.intValue + p2.intValue + p3.intValue + p4.intValue
case let .m_videoCompleted__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(p0, p1, p2, p3, p4): return p0.intValue + p1.intValue + p2.intValue + p3.intValue + p4.intValue
}
Expand Down Expand Up @@ -2389,7 +2389,7 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
case .m_bulkDeleteVideosSection__courseID_courseIDsectionId_sectionIdvideos_videos: return ".bulkDeleteVideosSection(courseID:sectionId:videos:)"
case .m_videoLoaded__courseID_courseIDblockID_blockIDvideoURL_videoURL: return ".videoLoaded(courseID:blockID:videoURL:)"
case .m_videoPlayed__courseID_courseIDblockID_blockIDvideoURL_videoURL: return ".videoPlayed(courseID:blockID:videoURL:)"
case .m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration: return ".videoChangeSpeed(courseID:blockID:videoURL:oldSpeed:newSpeed:currentTime:duration:)"
case .m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration: return ".videoSpeedChange(courseID:blockID:videoURL:oldSpeed:newSpeed:currentTime:duration:)"
case .m_videoPaused__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration: return ".videoPaused(courseID:blockID:videoURL:currentTime:duration:)"
case .m_videoCompleted__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration: return ".videoCompleted(courseID:blockID:videoURL:currentTime:duration:)"
}
Expand Down Expand Up @@ -2438,7 +2438,7 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
public static func bulkDeleteVideosSection(courseID: Parameter<String>, sectionId: Parameter<String>, videos: Parameter<Int>) -> Verify { return Verify(method: .m_bulkDeleteVideosSection__courseID_courseIDsectionId_sectionIdvideos_videos(`courseID`, `sectionId`, `videos`))}
public static func videoLoaded(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>) -> Verify { return Verify(method: .m_videoLoaded__courseID_courseIDblockID_blockIDvideoURL_videoURL(`courseID`, `blockID`, `videoURL`))}
public static func videoPlayed(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>) -> Verify { return Verify(method: .m_videoPlayed__courseID_courseIDblockID_blockIDvideoURL_videoURL(`courseID`, `blockID`, `videoURL`))}
public static func videoChangeSpeed(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, oldSpeed: Parameter<Float>, newSpeed: Parameter<Float>, currentTime: Parameter<Double>, duration: Parameter<Double>) -> Verify { return Verify(method: .m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `oldSpeed`, `newSpeed`, `currentTime`, `duration`))}
public static func videoSpeedChange(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, oldSpeed: Parameter<Float>, newSpeed: Parameter<Float>, currentTime: Parameter<Double>, duration: Parameter<Double>) -> Verify { return Verify(method: .m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `oldSpeed`, `newSpeed`, `currentTime`, `duration`))}
public static func videoPaused(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, currentTime: Parameter<Double>, duration: Parameter<Double>) -> Verify { return Verify(method: .m_videoPaused__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `currentTime`, `duration`))}
public static func videoCompleted(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, currentTime: Parameter<Double>, duration: Parameter<Double>) -> Verify { return Verify(method: .m_videoCompleted__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `currentTime`, `duration`))}
}
Expand Down Expand Up @@ -2531,8 +2531,8 @@ open class CourseAnalyticsMock: CourseAnalytics, Mock {
public static func videoPlayed(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, perform: @escaping (String, String, String) -> Void) -> Perform {
return Perform(method: .m_videoPlayed__courseID_courseIDblockID_blockIDvideoURL_videoURL(`courseID`, `blockID`, `videoURL`), performs: perform)
}
public static func videoChangeSpeed(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, oldSpeed: Parameter<Float>, newSpeed: Parameter<Float>, currentTime: Parameter<Double>, duration: Parameter<Double>, perform: @escaping (String, String, String, Float, Float, Double, Double) -> Void) -> Perform {
return Perform(method: .m_videoChangeSpeed__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `oldSpeed`, `newSpeed`, `currentTime`, `duration`), performs: perform)
public static func videoSpeedChange(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, oldSpeed: Parameter<Float>, newSpeed: Parameter<Float>, currentTime: Parameter<Double>, duration: Parameter<Double>, perform: @escaping (String, String, String, Float, Float, Double, Double) -> Void) -> Perform {
return Perform(method: .m_videoSpeedChange__courseID_courseIDblockID_blockIDvideoURL_videoURLoldSpeed_oldSpeednewSpeed_newSpeedcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `oldSpeed`, `newSpeed`, `currentTime`, `duration`), performs: perform)
}
public static func videoPaused(courseID: Parameter<String>, blockID: Parameter<String>, videoURL: Parameter<String>, currentTime: Parameter<Double>, duration: Parameter<Double>, perform: @escaping (String, String, String, Double, Double) -> Void) -> Perform {
return Perform(method: .m_videoPaused__courseID_courseIDblockID_blockIDvideoURL_videoURLcurrentTime_currentTimeduration_duration(`courseID`, `blockID`, `videoURL`, `currentTime`, `duration`), performs: perform)
Expand Down
6 changes: 3 additions & 3 deletions OpenEdX/Managers/AnalyticsManager/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class AnalyticsManager: AuthorizationAnalytics,
logEvent(.videoPlayed, parameters: parameters)
}

public func videoChangeSpeed(
public func videoSpeedChange(
courseID: String,
blockID: String,
videoURL: String,
Expand All @@ -850,10 +850,10 @@ class AnalyticsManager: AuthorizationAnalytics,
EventParamKey.currentTime: currentTime,
EventParamKey.duration: duration,
EventParamKey.category: EventCategory.video,
EventParamKey.name: EventBIValue.videoChangeSpeed.rawValue
EventParamKey.name: EventBIValue.videoSpeedChange.rawValue
]

logEvent(.videoChangeSpeed, parameters: parameters)
logEvent(.videoSpeedChange, parameters: parameters)
}

public func videoPaused(
Expand Down

0 comments on commit 60a8e94

Please sign in to comment.