diff --git a/Storage/Storage/Model/Feature Announcements/FeatureAnnouncementCampaign.swift b/Storage/Storage/Model/Feature Announcements/FeatureAnnouncementCampaign.swift index 7bb10bc0dfd..349d7a205cc 100644 --- a/Storage/Storage/Model/Feature Announcements/FeatureAnnouncementCampaign.swift +++ b/Storage/Storage/Model/Feature Announcements/FeatureAnnouncementCampaign.swift @@ -4,6 +4,9 @@ public enum FeatureAnnouncementCampaign: String, Codable, Equatable { case upsellCardReaders = "upsell_card_readers" case linkedProductsPromo = "linked_products_promo" case productsOnboarding = "products_onboarding_first_product" + case IPP_COD = "ipp_not_user" + case IPP_firstTransaction = "ipp_new_user" + case IPP_powerUsers = "ipp_heavy_user" /// Added for use in `test_setFeatureAnnouncementDismissed_with_another_campaign_previously_dismissed_keeps_values_for_both` /// This can be removed when we have a second campaign, which can be used in the above test instead. diff --git a/WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift b/WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift index 40bb8587656..f8431affde3 100644 --- a/WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift +++ b/WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift @@ -75,6 +75,10 @@ extension WooAnalyticsEvent { case orderCreation = "order_creation" /// Shown in beta feature banner for coupon management. case couponManagement = "coupon_management" + /// Shown in IPP banner for different number of IPP transactions. + case IPP_COD = "ipp_not_user" + case IPP_firstTransaction = "ipp_new_user" + case IPP_powerUsers = "ipp_heavy_user" } /// The action performed on the survey screen. @@ -599,6 +603,55 @@ extension WooAnalyticsEvent { } } +// MARK: - InPersonPayments Feedback Banner +// +extension WooAnalyticsEvent { + enum InPersonPaymentsFeedback { + /// Possible sources for IPP feedback + /// + enum Source: String { + fileprivate static let key = "source" + case orderList = "order_list" // Only one source for the moment + } + + /// Keys + /// + private enum Keys { + static let campaign = "campaign_name" + static let source = "source" + static let remindLater = "remind_later" + } + + static func shown(source: Source, campaign: FeatureAnnouncementCampaign) -> WooAnalyticsEvent { + WooAnalyticsEvent( + statName: .IPPbannerShown, // survey_banner_shown + properties: [ + Keys.source: source.rawValue, // order_list + Keys.campaign: campaign.rawValue, // "ipp_not_user/ipp_new_user/ipp_heavy_user" + ]) + } + + static func ctaTapped(source: Source, campaign: FeatureAnnouncementCampaign) -> WooAnalyticsEvent { + WooAnalyticsEvent(statName: .IPPbannerTapped, // survey_banner_cta_tapped + properties: [ + Keys.source: source.rawValue, // order_list + Keys.campaign: campaign.rawValue // "ipp_not_user/ipp_new_user/ipp_heavy_user" + ]) + } + + static func dismissed(source: Source, + campaign: FeatureAnnouncementCampaign, + remindLater: Bool) -> WooAnalyticsEvent { + WooAnalyticsEvent(statName: .IPPbannerDismissed, // survey_banner_dismissed + properties: [ + Keys.source: source.rawValue, // order_list + Keys.campaign: campaign.rawValue, // "ipp_not_user/ipp_new_user/ipp_heavy_user" + Keys.remindLater: remindLater + ]) + } + } +} + // MARK: - Feature Announcement Card extension WooAnalyticsEvent { diff --git a/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift b/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift index 05f1ae7c74b..0d666068ded 100644 --- a/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift +++ b/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift @@ -687,6 +687,11 @@ public enum WooAnalyticsStat: String { case featureCardDismissed = "feature_card_dismissed" case featureCardCtaTapped = "feature_card_cta_tapped" + // MARK: In-Person Payments survey feedback events + case IPPbannerShown = "survey_banner_shown" + case IPPbannerTapped = "survey_banner_cta_tapped" + case IPPbannerDismissed = "survey_banner_dismissed" + // MARK: Just In Time Messages events case justInTimeMessageCallToActionTapped = "jitm_cta_tapped" case justInTimeMessageDismissTapped = "jitm_dismissed" diff --git a/WooCommerce/Classes/System/WooConstants.swift b/WooCommerce/Classes/System/WooConstants.swift index f1f3986e7bd..78c7d6b049d 100644 --- a/WooCommerce/Classes/System/WooConstants.swift +++ b/WooCommerce/Classes/System/WooConstants.swift @@ -159,6 +159,15 @@ extension WooConstants { case inAppFeedback = "https://automattic.survey.fm/woo-app-general-feedback-user-survey" #endif + /// URLs for the different IPP surveys + /// +#if DEBUG + case IPP_COD, IPP_firstTransaction, IPP_powerUsers = "https://automattic.survey.fm/woo-app-ipp-in-app-feedback-testing" +#else + case IPP_COD = "https://automattic.survey.fm/woo-app-–-cod-survey" + case IPP_firstTransaction = "https://automattic.survey.fm/woo-app-–-ipp-first-transaction-survey" + case IPP_powerUsers = "https://automattic.survey.fm/woo-app-–-ipp-survey-for-power-users" +#endif /// URL for the products feedback survey /// case productsFeedback = "https://automattic.survey.fm/woo-app-feature-feedback-products" diff --git a/WooCommerce/Classes/ViewRelated/Survey/SurveyViewController.swift b/WooCommerce/Classes/ViewRelated/Survey/SurveyViewController.swift index 96fac6c4f03..fcb5f088377 100644 --- a/WooCommerce/Classes/ViewRelated/Survey/SurveyViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Survey/SurveyViewController.swift @@ -68,6 +68,9 @@ extension SurveyViewController { case addOnsI1 case orderCreation case couponManagement + case IPP_COD + case IPP_firstTransaction + case IPP_powerUsers fileprivate var url: URL { switch self { @@ -102,12 +105,27 @@ extension SurveyViewController { .asURL() .tagPlatform("ios") .tagAppVersion(Bundle.main.bundleVersion()) + case .IPP_COD: + return WooConstants.URLs.IPP_COD + .asURL() + .tagPlatform("ios") + .tagAppVersion(Bundle.main.bundleVersion()) + case .IPP_firstTransaction: + return WooConstants.URLs.IPP_firstTransaction + .asURL() + .tagPlatform("ios") + .tagAppVersion(Bundle.main.bundleVersion()) + case .IPP_powerUsers: + return WooConstants.URLs.IPP_powerUsers + .asURL() + .tagPlatform("ios") + .tagAppVersion(Bundle.main.bundleVersion()) } } fileprivate var title: String { switch self { - case .inAppFeedback: + case .inAppFeedback, .IPP_COD, .IPP_firstTransaction, .IPP_powerUsers: return Localization.title case .productsFeedback, .shippingLabelsRelease3Feedback, .addOnsI1, .orderCreation, .couponManagement: return Localization.giveFeedback @@ -129,6 +147,12 @@ extension SurveyViewController { return .orderCreation case .couponManagement: return .couponManagement + case .IPP_COD: + return .IPP_COD + case .IPP_firstTransaction: + return .IPP_firstTransaction + case .IPP_powerUsers: + return .IPP_powerUsers } } }