File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
ViewRelated/Products/Add Product Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1689,6 +1689,15 @@ extension WooAnalyticsEvent {
16891689//
16901690extension WooAnalyticsEvent {
16911691 enum ProductsOnboarding {
1692+ enum Keys : String {
1693+ case type
1694+ }
1695+
1696+ enum CreationType : String {
1697+ case manual
1698+ case template
1699+ }
1700+
16921701 /// Tracks when a store is eligible for products onboarding
16931702 ///
16941703 static func storeIsEligible( ) -> WooAnalyticsEvent {
@@ -1700,5 +1709,11 @@ extension WooAnalyticsEvent {
17001709 static func bannerCTATapped( ) -> WooAnalyticsEvent {
17011710 WooAnalyticsEvent ( statName: . productsOnboardingCTATapped, properties: [ : ] )
17021711 }
1712+
1713+ /// Trackas when the merchants selects a product creation type.
1714+ ///
1715+ static func productCreationTypeSelected( type: CreationType ) -> WooAnalyticsEvent {
1716+ WooAnalyticsEvent ( statName: . addProductCreationTypeSelected, properties: [ Keys . type. rawValue: type. rawValue] )
1717+ }
17031718 }
17041719}
Original file line number Diff line number Diff line change @@ -424,6 +424,7 @@ public enum WooAnalyticsStat: String {
424424
425425 // MARK: Add Product Events
426426 //
427+ case addProductCreationTypeSelected = " add_product_creation_type_selected "
427428 case addProductTypeSelected = " add_product_product_type_selected "
428429 case addProductPublishTapped = " add_product_publish_tapped "
429430 case addProductSaveAsDraftTapped = " add_product_save_as_draft_tapped "
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ private extension AddProductCoordinator {
8989 comment: " Message title of bottom sheet for selecting a template or manual product " )
9090 let viewProperties = BottomSheetListSelectorViewProperties ( title: title)
9191 let command = ProductCreationTypeSelectorCommand { selectedCreationType in
92- // TODO: Add analytics
92+ self . trackProductCreationType ( selectedCreationType )
9393 self . presentProductTypeBottomSheet ( creationType: selectedCreationType)
9494 }
9595 let productTypesListPresenter = BottomSheetListSelectorPresenter ( viewProperties: viewProperties, command: command)
@@ -225,9 +225,23 @@ private extension AddProductCoordinator {
225225
226226 /// Presents an general error notice using the system notice presenter.
227227 ///
228- private func presentErrorNotice( ) {
228+ func presentErrorNotice( ) {
229229 let notice = Notice ( title: NSLocalizedString ( " There was a problem creating the template product. " ,
230230 comment: " Title for the error notice when creating a template product " ) )
231231 ServiceLocator . noticePresenter. enqueue ( notice: notice)
232232 }
233+
234+ /// Tracks the selected product creation type.
235+ ///
236+ func trackProductCreationType( _ type: ProductCreationType ) {
237+ let analyticsType : WooAnalyticsEvent . ProductsOnboarding . CreationType = {
238+ switch type {
239+ case . template:
240+ return . template
241+ case . manual:
242+ return . manual
243+ }
244+ } ( )
245+ ServiceLocator . analytics. track ( event: . ProductsOnboarding. productCreationTypeSelected ( type: analyticsType) )
246+ }
233247}
You can’t perform that action at this time.
0 commit comments