Skip to content

Commit bf710fb

Browse files
committed
Inject analytics through environment in PointOfSaleEntryPointView
1 parent 8a122dc commit bf710fb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

WooCommerce/Classes/POS/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ struct PointOfSaleEntryPointView: View {
88
@StateObject private var posModalManager = POSModalManager()
99
@State private var posEntryPointController: POSEntryPointController
1010
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
11-
@Environment(\.posAnalytics) private var analytics
1211

1312
private let onPointOfSaleModeActiveStateChange: ((Bool) -> Void)
1413
private let itemsController: PointOfSaleItemsControllerProtocol
@@ -21,6 +20,7 @@ struct PointOfSaleEntryPointView: View {
2120
private let searchHistoryService: POSSearchHistoryProviding
2221
private let popularPurchasableItemsController: PointOfSaleItemsControllerProtocol
2322
private let barcodeScanService: PointOfSaleBarcodeScanServiceProtocol
23+
private let analytics: POSAnalyticsProviding
2424

2525
init(itemsController: PointOfSaleItemsControllerProtocol,
2626
purchasableItemsSearchController: PointOfSaleSearchingItemsControllerProtocol,
@@ -33,7 +33,8 @@ struct PointOfSaleEntryPointView: View {
3333
searchHistoryService: POSSearchHistoryProviding,
3434
popularPurchasableItemsController: PointOfSaleItemsControllerProtocol,
3535
barcodeScanService: PointOfSaleBarcodeScanServiceProtocol,
36-
posEligibilityChecker: POSEntryPointEligibilityCheckerProtocol) {
36+
posEligibilityChecker: POSEntryPointEligibilityCheckerProtocol,
37+
analytics: POSAnalyticsProviding) {
3738
self.onPointOfSaleModeActiveStateChange = onPointOfSaleModeActiveStateChange
3839

3940
self.itemsController = itemsController
@@ -47,6 +48,7 @@ struct PointOfSaleEntryPointView: View {
4748
self.popularPurchasableItemsController = popularPurchasableItemsController
4849
self.barcodeScanService = barcodeScanService
4950
self.posEntryPointController = POSEntryPointController(eligibilityChecker: posEligibilityChecker)
51+
self.analytics = analytics
5052
}
5153

5254
var body: some View {
@@ -77,6 +79,7 @@ struct PointOfSaleEntryPointView: View {
7779
barcodeScanService: barcodeScanService)
7880
}
7981
.environmentObject(posModalManager)
82+
.environment(\.posAnalytics, analytics)
8083
.injectKeyboardObserver()
8184
.onAppear {
8285
onPointOfSaleModeActiveStateChange(true)
@@ -103,7 +106,8 @@ struct PointOfSaleEntryPointView: View {
103106
searchHistoryService: PointOfSalePreviewHistoryService(),
104107
popularPurchasableItemsController: PointOfSalePreviewItemsController(),
105108
barcodeScanService: PointOfSalePreviewBarcodeScanService(),
106-
posEligibilityChecker: POSTabEligibilityChecker(siteID: 0))
109+
posEligibilityChecker: POSTabEligibilityChecker(siteID: 0),
110+
analytics: POSPreviewAnalytics())
107111
}
108112

109113
#endif

WooCommerce/Classes/POS/TabBar/POSTabCoordinator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ private extension POSTabCoordinator {
137137
analyticsProvider: analyticsAdapter
138138
),
139139
barcodeScanService: barcodeScanService,
140-
posEligibilityChecker: eligibilityChecker
140+
posEligibilityChecker: eligibilityChecker,
141+
analytics: analyticsAdapter
141142
)
142-
.environment(\.posAnalytics, analyticsAdapter)
143143
let hostingController = UIHostingController(rootView: posView)
144144
hostingController.modalPresentationStyle = .fullScreen
145145
viewControllerToPresent.present(hostingController, animated: true)

0 commit comments

Comments
 (0)