Skip to content

Commit 236fe04

Browse files
authored
Merge branch 'trunk' into task/reduce-combine-publisher-use-in-aggregate-model
2 parents d1da65c + ea5408a commit 236fe04

File tree

49 files changed

+1340
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1340
-110
lines changed

WooCommerce/Classes/Analytics/AppStartupWaitingTimeTracker.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import protocol WooFoundation.Analytics
55
/// Tracks the waiting time for app startup, allowing to evaluate as analytics
66
/// how much time in seconds it took between the init and the final `end(action:)` function call.
77
///
8-
class AppStartupWaitingTimeTracker: WaitingTimeTracker {
8+
final class AppStartupWaitingTimeTracker: WaitingTimeTracker {
99

1010
/// All actions tracked in the app startup waiting time.
1111
///
@@ -21,8 +21,8 @@ class AppStartupWaitingTimeTracker: WaitingTimeTracker {
2121
private(set) var startupActionsPending = StartupAction.allCases
2222

2323
init(analyticsService: Analytics = ServiceLocator.analytics,
24-
currentTimeInMillis: @escaping () -> TimeInterval = { Date().timeIntervalSince1970 }) {
25-
super.init(trackScenario: .appStartup, analyticsService: analyticsService, currentTime: currentTimeInMillis)
24+
currentTimestampSeconds: @escaping () -> TimeInterval = { Date().timeIntervalSince1970 }) {
25+
super.init(trackScenario: .appStartup, analyticsService: analyticsService, currentTimestampSeconds: currentTimestampSeconds)
2626
}
2727

2828
/// Ends the waiting time for the provided startup action.

WooCommerce/Classes/Analytics/WaitingTimeTracker.swift

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,46 @@ import protocol WooFoundation.Analytics
77
///
88
class WaitingTimeTracker {
99
private let trackScenario: WooAnalyticsEvent.WaitingTime.Scenario
10-
private let currentTime: () -> TimeInterval
10+
private let currentTimestampSeconds: () -> TimeInterval
1111
private let analyticsService: Analytics
1212
private let waitingStartedTimestamp: TimeInterval
1313

14+
enum TrackingUnit {
15+
case seconds
16+
case milliseconds
17+
}
18+
1419
init(trackScenario: WooAnalyticsEvent.WaitingTime.Scenario,
1520
analyticsService: Analytics = ServiceLocator.analytics,
16-
currentTime: @escaping () -> TimeInterval = { Date().timeIntervalSince1970 }
21+
currentTimestampSeconds: @escaping () -> TimeInterval = { Date().timeIntervalSince1970 }
1722
) {
1823
self.trackScenario = trackScenario
1924
self.analyticsService = analyticsService
20-
self.currentTime = currentTime
21-
waitingStartedTimestamp = currentTime()
25+
self.currentTimestampSeconds = currentTimestampSeconds
26+
waitingStartedTimestamp = currentTimestampSeconds()
2227
}
2328

24-
/// End the waiting time by evaluating the elapsed time from the init,
25-
/// and sending it as an analytics event, in seconds.
29+
/// Default `end()` method to preserve interface compatibility. By default, tracks in `.seconds`
2630
///
2731
func end() {
28-
let elapsedTime = currentTime() - waitingStartedTimestamp
29-
let analyticsEvent = WooAnalyticsEvent.WaitingTime.waitingFinished(scenario: trackScenario, elapsedTime: elapsedTime)
30-
analyticsService.track(event: analyticsEvent)
32+
end(using: .seconds)
3133
}
3234

3335
/// End the waiting time by evaluating the elapsed time from the init,
34-
/// and sending it as an analytics event, in milliseconds
36+
/// and sending it as an analytics event.
3537
///
36-
func endInMilliseconds() {
37-
let elapsedTimeMs = (currentTime() - waitingStartedTimestamp) * 1000
38-
let analyticsEvent = WooAnalyticsEvent.WaitingTime.waitingFinished(scenario: trackScenario, elapsedTime: elapsedTimeMs)
38+
/// - Parameter trackingUnit: Defines whether the elapsed time should be tracked in `.seconds` or `.milliseconds` (default is `.seconds`).
39+
///
40+
func end(using trackingUnit: TrackingUnit = .seconds) {
41+
let elapsedTime = calculateElapsedTime(in: trackingUnit)
42+
let analyticsEvent = WooAnalyticsEvent.WaitingTime.waitingFinished(scenario: trackScenario, elapsedTime: elapsedTime)
3943
analyticsService.track(event: analyticsEvent)
4044
}
45+
46+
/// Calculates elapsed time in the specified tracking unit.
47+
///
48+
private func calculateElapsedTime(in trackingUnit: TrackingUnit) -> TimeInterval {
49+
let elapsedTime = currentTimestampSeconds() - waitingStartedTimestamp
50+
return trackingUnit == .milliseconds ? elapsedTime * 1000 : elapsedTime
51+
}
4152
}

WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentOnboardingAdaptor.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ final class CardPresentPaymentsOnboardingPresenterAdaptor: CardPresentPaymentsOn
99

1010
private let readinessUseCase: CardPresentPaymentsReadinessUseCase
1111

12-
private let onboardingViewModel: CardPresentPaymentsOnboardingViewModel
12+
private var onboardingViewModel: CardPresentPaymentsOnboardingViewModel {
13+
CardPresentPaymentsOnboardingViewModel(useCase: onboardingUseCase)
14+
}
1315

1416
private var readinessSubscription: AnyCancellable?
1517

@@ -20,7 +22,6 @@ final class CardPresentPaymentsOnboardingPresenterAdaptor: CardPresentPaymentsOn
2022
init(stores: StoresManager = ServiceLocator.stores) {
2123
onboardingUseCase = CardPresentPaymentsOnboardingUseCase(stores: stores)
2224
readinessUseCase = CardPresentPaymentsReadinessUseCase(onboardingUseCase: onboardingUseCase, stores: stores)
23-
onboardingViewModel = CardPresentPaymentsOnboardingViewModel(useCase: onboardingUseCase)
2425
onboardingScreenViewModelPublisher = onboardingScreenViewModelSubject.eraseToAnyPublisher()
2526
}
2627

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import SwiftUI
2+
3+
extension Color {
4+
// MARK: - Primary Colors
5+
static var posPrimary: Color { Color(.posPrimary) }
6+
static var posOnPrimary: Color { Color(.posOnPrimary) }
7+
static var posPrimaryContainer: Color { Color(.posPrimaryContainer) }
8+
static var posOnPrimaryContainer: Color { Color(.posOnPrimaryContainer) }
9+
10+
// MARK: - Secondary Container Colors
11+
static var posSecondaryContainer: Color { Color(.posSecondaryContainer) }
12+
static var posOnSecondaryContainer: Color { Color(.posOnSecondaryContainer) }
13+
14+
// MARK: - Disabled Container Colors
15+
static var posDisabledContainer: Color { Color(.posDisabledContainer) }
16+
static var posOnDisabledContainer: Color { Color(.posOnDisabledContainer) }
17+
18+
// MARK: - Surface Colors
19+
static var posSurface: Color { Color(.posSurface) }
20+
static var posOnSurface: Color { Color(.posOnSurface) }
21+
static var posSurfaceDim: Color { Color(.posSurfaceDim) }
22+
static var posSurfaceBright: Color { Color(.posSurfaceBright) }
23+
static var posSurfaceContainerLowest: Color { Color(.posSurfaceContainerLowest) }
24+
static var posSurfaceContainerLow: Color { Color(.posSurfaceContainerLow) }
25+
static var posSurfaceContainerHighest: Color { Color(.posSurfaceContainerHighest) }
26+
27+
// MARK: - Surface Variant Colors
28+
static var posOnSurfaceVariantLowest: Color { Color(.posOnSurfaceVariantLowest) }
29+
static var posOnSurfaceVariantHighest: Color { Color(.posOnSurfaceVariantHighest) }
30+
31+
// MARK: - Inverse Surface Colors
32+
static var posInverseSurface: Color { Color(.posInverseSurface) }
33+
static var posOnInverseSurface: Color { Color(.posOnInverseSurface) }
34+
35+
// MARK: - Outline Colors
36+
static var posOutline: Color { Color(.posOutline) }
37+
static var posOutlineVariant: Color { Color(.posOutlineVariant) }
38+
39+
// MARK: - Status Colors
40+
static var posError: Color { Color(.posError) }
41+
static var posOnError: Color { Color(.posOnError) }
42+
static var posSuccess: Color { Color(.posSuccess) }
43+
static var posOnSuccess: Color { Color(.posOnSuccess) }
44+
static var posAlert: Color { Color(.posAlert) }
45+
static var posOnAlert: Color { Color(.posOnAlert) }
46+
47+
// MARK: - Text Colors
48+
static var posTextPrimary: Color { Color(.posTextPrimary) }
49+
static var posTextSecondary: Color { Color(.posTextSecondary) }
50+
static var posTextTertiary: Color { Color(.posTextTertiary) }
51+
52+
// MARK: - Other
53+
static var posShadow: Color { Color(.posShadow) }
54+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x18",
9+
"green" : "0x66",
10+
"red" : "0xF1"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x18",
27+
"green" : "0x66",
28+
"red" : "0xF1"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0xDE",
9+
"green" : "0xDC",
10+
"red" : "0xDC"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x5E",
27+
"green" : "0x57",
28+
"red" : "0x50"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x38",
9+
"green" : "0x36",
10+
"red" : "0xD6"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x38",
27+
"green" : "0x36",
28+
"red" : "0xD6"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x17",
9+
"green" : "0x15",
10+
"red" : "0x10"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0xFF",
27+
"green" : "0xFF",
28+
"red" : "0xFF"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0xFF",
9+
"green" : "0xFF",
10+
"red" : "0xFF"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0xFF",
27+
"green" : "0xFF",
28+
"red" : "0xFF"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

0 commit comments

Comments
 (0)