From 7be9e2d0689a811b5711a5489bf14bc73ad734bc Mon Sep 17 00:00:00 2001
From: David Christiandy <1299411+dvdchr@users.noreply.github.com>
Date: Thu, 9 Dec 2021 21:00:57 +0700
Subject: [PATCH] Add tracking for comment sharing intent

---
 .../Classes/Utility/Analytics/WPAnalyticsEvent.swift   | 10 ++++++++++
 .../Comments/CommentDetailViewController.swift         |  3 +++
 .../Reader/ReaderCommentsViewController.swift          |  4 ++++
 3 files changed, 17 insertions(+)

diff --git a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
index f584a51c8f3d..e2a60679eb4a 100644
--- a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
+++ b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
@@ -270,6 +270,10 @@ import Foundation
     case sharingButtonsEditMoreButtonToggled
     case sharingButtonsLabelChanged
 
+    // Comment Sharing
+    case readerArticleCommentShared
+    case siteCommentsCommentShared
+
     // People
     case peopleFilterChanged
     case peopleUserInvited
@@ -756,6 +760,12 @@ import Foundation
         case .sharingButtonsLabelChanged:
             return "sharing_buttons_label_changed"
 
+        // Comment Sharing
+        case .readerArticleCommentShared:
+            return "reader_article_comment_shared"
+        case .siteCommentsCommentShared:
+            return "site_comments_comment_shared"
+
         // People
         case .peopleFilterChanged:
             return "people_management_filter_changed"
diff --git a/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift b/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift
index 4d277b7c7523..fa838544ed92 100644
--- a/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift
+++ b/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift
@@ -590,6 +590,9 @@ private extension CommentDetailViewController {
             return
         }
 
+        // track share intent.
+        WPAnalytics.track(.siteCommentsCommentShared)
+
         let activityViewController = UIActivityViewController(activityItems: [commentURL as Any], applicationActivities: nil)
         activityViewController.popoverPresentationController?.sourceView = senderView
         present(activityViewController, animated: true, completion: nil)
diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift
index c482256045bf..eca61d653bc6 100644
--- a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift
+++ b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.swift
@@ -1,5 +1,6 @@
 import Foundation
 import UIKit
+import WordPressShared
 
 @objc public extension ReaderCommentsViewController {
     func shouldShowSuggestions(for siteID: NSNumber?) -> Bool {
@@ -104,6 +105,9 @@ import UIKit
             return
         }
 
+        // track share intent.
+        WPAnalytics.track(.readerArticleCommentShared)
+
         let activityViewController = UIActivityViewController(activityItems: [commentURL as Any], applicationActivities: nil)
         activityViewController.popoverPresentationController?.sourceView = sourceView
         present(activityViewController, animated: true, completion: nil)