File tree Expand file tree Collapse file tree 5 files changed +29
-3
lines changed
WooFoundationCore/Analytics
Yosemite/PointOfSale/Items
WooCommerce/Classes/Analytics Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,15 @@ struct POSItemFetchAnalytics: POSItemFetchAnalyticsTracking {
4646
4747 /// Tracks when a local search results fetch completes
4848 /// - Parameters:
49- /// - milliseconds : The time taken to fetch results in milliseconds
49+ /// - millisecondsSinceRequestSent : The time taken to fetch results in milliseconds
5050 /// - totalItems: The total number of items found in the search
5151 func trackSearchLocalResultsFetchComplete( millisecondsSinceRequestSent: Int , totalItems: Int ) {
52- // TODO: Implement analytics event for local search results
53- // This will be implemented in the final PR
52+ analytics. track (
53+ event: . PointOfSale. pointOfSaleSearchResultsFetched (
54+ itemType: itemType,
55+ resultsCount: totalItems,
56+ millisecondsSinceRequestSent: millisecondsSinceRequestSent
57+ )
58+ )
5459 }
5560}
Original file line number Diff line number Diff line change @@ -305,6 +305,17 @@ extension WooAnalyticsEvent {
305305 ] )
306306 }
307307
308+ static func pointOfSaleSearchResultsFetched( itemType: POSItemType ,
309+ resultsCount: Int ,
310+ millisecondsSinceRequestSent: Int ) -> WooAnalyticsEvent {
311+ WooAnalyticsEvent ( statName: . pointOfSaleSearchResultsFetched,
312+ properties: [
313+ Key . sourceView: SourceView ( itemType: itemType) . rawValue,
314+ Key . resultsCount: " \( resultsCount) " ,
315+ Key . millisecondsSinceRequestSent: " \( millisecondsSinceRequestSent) "
316+ ] )
317+ }
318+
308319 static func pointOfSaleItemsFetched( itemType: POSItemType ,
309320 totalItems: Int ) -> WooAnalyticsEvent {
310321 WooAnalyticsEvent ( statName: . pointOfSaleItemsFetched,
Original file line number Diff line number Diff line change @@ -1275,6 +1275,7 @@ public enum WooAnalyticsStat: String {
12751275 case pointOfSaleKeyboardDismissedInSearch = " keyboard_dismissed_in_search "
12761276 case pointOfSaleItemsNextPageLoaded = " items_next_page_loaded "
12771277 case pointOfSaleSearchRemoteResultsFetched = " search_remote_results_fetched "
1278+ case pointOfSaleSearchResultsFetched = " search_results_fetched "
12781279 case pointOfSaleBarcodeScanningMenuItemTapped = " barcode_scanning_menu_item_tapped "
12791280 case pointOfSaleBarcodeScanningExplanationDialogShown = " barcode_scanning_explanation_dialog_shown "
12801281 case pointOfSaleBarcodeScannerSetupFlowShown = " barcode_scanner_setup_flow_shown "
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ public struct PointOfSaleLocalSearchPurchasableItemFetchStrategy: PointOfSalePur
2626 }
2727
2828 public func fetchProducts( pageNumber: Int ) async throws -> PagedItems < POSProduct > {
29+ let startTime = Date ( )
30+
2931 // Get total count and persisted products in one transaction
3032 let ( persistedProducts, totalCount) = try await grdbManager. databaseConnection. read { db in
3133 let totalCount = try PersistedProduct
@@ -49,6 +51,12 @@ public struct PointOfSaleLocalSearchPurchasableItemFetchStrategy: PointOfSalePur
4951
5052 let hasMorePages = ( pageNumber * pageSize) < totalCount
5153
54+ if pageNumber == 1 {
55+ let milliseconds = Int ( Date ( ) . timeIntervalSince ( startTime) * Double( MSEC_PER_SEC) )
56+ analytics. trackSearchLocalResultsFetchComplete ( millisecondsSinceRequestSent: milliseconds,
57+ totalItems: totalCount)
58+ }
59+
5260 return PagedItems ( items: products,
5361 hasMorePages: hasMorePages,
5462 totalItems: totalCount)
Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ private extension TracksProvider {
150150 WooAnalyticsStat . pointOfSaleKeyboardDismissedInSearch,
151151 WooAnalyticsStat . pointOfSaleItemsNextPageLoaded,
152152 WooAnalyticsStat . pointOfSaleSearchRemoteResultsFetched,
153+ WooAnalyticsStat . pointOfSaleSearchResultsFetched,
153154 WooAnalyticsStat . pointOfSaleBarcodeScanningMenuItemTapped,
154155 WooAnalyticsStat . pointOfSaleBarcodeScanningExplanationDialogShown,
155156 WooAnalyticsStat . pointOfSaleBarcodeScannerSetupFlowShown,
You can’t perform that action at this time.
0 commit comments