Skip to content

Commit aa0083d

Browse files
committed
Add an event property source to track the source of share product action.
1 parent 5943e28 commit aa0083d

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
extension WooAnalyticsEvent {
2+
enum ProductForm {
3+
/// Event property keys.
4+
private enum Key {
5+
static let source = "source"
6+
}
7+
8+
/// Tracked when the user taps on the button to share a product.
9+
static func productDetailShareButtonTapped(source: ShareProductSource) -> WooAnalyticsEvent {
10+
WooAnalyticsEvent(statName: .productDetailShareButtonTapped,
11+
properties: [Key.source: source.rawValue])
12+
}
13+
}
14+
}
15+
16+
extension WooAnalyticsEvent.ProductForm {
17+
/// Source of the share product action. The raw value is the event property value.
18+
enum ShareProductSource: String {
19+
/// From product form in the navigation bar.
20+
case productForm = "product_form"
21+
/// From product form > more menu in the navigation bar.
22+
case moreMenu = "more_menu"
23+
}
24+
}

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
281281

282282
if viewModel.canShareProduct() {
283283
actionSheet.addDefaultActionWithTitle(ActionSheetStrings.share) { [weak self] _ in
284-
ServiceLocator.analytics.track(.productDetailShareButtonTapped)
285-
self?.displayShareProduct()
284+
self?.displayShareProduct(source: .moreMenu)
286285
}
287286
}
288287

@@ -471,8 +470,7 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
471470
}
472471

473472
@objc private func shareProduct() {
474-
ServiceLocator.analytics.track(.productDetailShareButtonTapped)
475-
displayShareProduct()
473+
displayShareProduct(source: .productForm)
476474
}
477475

478476
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
@@ -863,7 +861,9 @@ private extension ProductFormViewController {
863861
WebviewHelper.launch(url, with: self)
864862
}
865863

866-
func displayShareProduct() {
864+
func displayShareProduct(source: WooAnalyticsEvent.ProductForm.ShareProductSource) {
865+
ServiceLocator.analytics.track(event: .ProductForm.productDetailShareButtonTapped(source: source))
866+
867867
guard let url = URL(string: product.permalink) else {
868868
return
869869
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
02490D1E284F3226002096EF /* ProductImagesSaverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02490D1D284F3226002096EF /* ProductImagesSaverTests.swift */; };
192192
024A543422BA6F8F00F4F38E /* DeveloperEmailChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024A543322BA6F8F00F4F38E /* DeveloperEmailChecker.swift */; };
193193
024A543622BA84DB00F4F38E /* DeveloperEmailCheckerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024A543522BA84DB00F4F38E /* DeveloperEmailCheckerTests.swift */; };
194+
024D4E842A1B4B630090E0E6 /* WooAnalyticsEvent+ProductForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024D4E832A1B4B630090E0E6 /* WooAnalyticsEvent+ProductForm.swift */; };
194195
024DF3052372ADCD006658FE /* KeyboardScrollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024DF3042372ADCD006658FE /* KeyboardScrollable.swift */; };
195196
024DF3072372C18D006658FE /* AztecUIConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024DF3062372C18D006658FE /* AztecUIConfigurator.swift */; };
196197
024DF3092372CA00006658FE /* EditorViewProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024DF3082372CA00006658FE /* EditorViewProperties.swift */; };
@@ -2481,6 +2482,7 @@
24812482
02490D1D284F3226002096EF /* ProductImagesSaverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductImagesSaverTests.swift; sourceTree = "<group>"; };
24822483
024A543322BA6F8F00F4F38E /* DeveloperEmailChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperEmailChecker.swift; sourceTree = "<group>"; };
24832484
024A543522BA84DB00F4F38E /* DeveloperEmailCheckerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperEmailCheckerTests.swift; sourceTree = "<group>"; };
2485+
024D4E832A1B4B630090E0E6 /* WooAnalyticsEvent+ProductForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WooAnalyticsEvent+ProductForm.swift"; sourceTree = "<group>"; };
24842486
024DF3042372ADCD006658FE /* KeyboardScrollable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardScrollable.swift; sourceTree = "<group>"; };
24852487
024DF3062372C18D006658FE /* AztecUIConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUIConfigurator.swift; sourceTree = "<group>"; };
24862488
024DF3082372CA00006658FE /* EditorViewProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorViewProperties.swift; sourceTree = "<group>"; };
@@ -7451,6 +7453,7 @@
74517453
02B21C5629C9EEF900C5623B /* WooAnalyticsEvent+StoreOnboarding.swift */,
74527454
DE621F6929D67E1B000DE3BD /* WooAnalyticsEvent+JetpackSetup.swift */,
74537455
02E222C729FBA60F004579A1 /* WooAnalyticsEvent+ProductFormAI.swift */,
7456+
024D4E832A1B4B630090E0E6 /* WooAnalyticsEvent+ProductForm.swift */,
74547457
);
74557458
path = Analytics;
74567459
sourceTree = "<group>";
@@ -11178,6 +11181,7 @@
1117811181
03BB9EA5292E2D0C00251E9E /* CardReaderConnectionController.swift in Sources */,
1117911182
B95112DA28BF79CA00D9578D /* PaymentsRoute.swift in Sources */,
1118011183
7E6A019F2725CD76001668D5 /* FilterProductCategoryListViewModel.swift in Sources */,
11184+
024D4E842A1B4B630090E0E6 /* WooAnalyticsEvent+ProductForm.swift in Sources */,
1118111185
CC53FB3C2757EC7200C4CA4F /* ProductSelectorViewModel.swift in Sources */,
1118211186
CCA1D5FE293F537400B40560 /* DeltaPercentage.swift in Sources */,
1118311187
4569D3C325DC008700CDC3E2 /* SiteAddress.swift in Sources */,

0 commit comments

Comments
 (0)