Skip to content

Commit e6e1977

Browse files
committed
Add card_reader_model property to collect payment failed event and disconnect card reader event.
1 parent e1be2a5 commit e6e1977

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,10 @@ extension WooAnalyticsEvent {
612612
/// - countryCode: the country code of the store.
613613
/// - cardReaderModel: the model type of the card reader.
614614
///
615-
static func cardReaderConnectionSuccess(forGatewayID: String?, batteryLevel: Float?, countryCode: String, cardReaderModel: String) -> WooAnalyticsEvent {
615+
static func cardReaderConnectionSuccess(forGatewayID: String?,
616+
batteryLevel: Float?,
617+
countryCode: String,
618+
cardReaderModel: String) -> WooAnalyticsEvent {
616619
var properties = [
617620
Keys.cardReaderModel: cardReaderModel,
618621
Keys.countryCode: countryCode,
@@ -632,10 +635,12 @@ extension WooAnalyticsEvent {
632635
/// - forGatewayID: the plugin (e.g. "woocommerce-payments" or "woocommerce-gateway-stripe") to be included in the event properties in Tracks.
633636
/// - error: the error to be included in the event properties.
634637
/// - countryCode: the country code of the store.
638+
/// - cardReaderModel: the model type of the card reader.
635639
///
636-
static func cardReaderConnectionFailed(forGatewayID: String?, error: Error, countryCode: String) -> WooAnalyticsEvent {
640+
static func cardReaderConnectionFailed(forGatewayID: String?, error: Error, countryCode: String, cardReaderModel: String) -> WooAnalyticsEvent {
637641
WooAnalyticsEvent(statName: .cardReaderConnectionFailed,
638642
properties: [
643+
Keys.cardReaderModel: cardReaderModel,
639644
Keys.countryCode: countryCode,
640645
Keys.gatewayID: gatewayID(forGatewayID: forGatewayID),
641646
Keys.errorDescription: error.localizedDescription
@@ -649,10 +654,12 @@ extension WooAnalyticsEvent {
649654
/// - Parameters:
650655
/// - forGatewayID: the plugin (e.g. "woocommerce-payments" or "woocommerce-gateway-stripe") to be included in the event properties in Tracks.
651656
/// - countryCode: the country code of the store.
657+
/// - cardReaderModel: the model type of the card reader.
652658
///
653-
static func cardReaderDisconnectTapped(forGatewayID: String?, countryCode: String) -> WooAnalyticsEvent {
659+
static func cardReaderDisconnectTapped(forGatewayID: String?, countryCode: String, cardReaderModel: String) -> WooAnalyticsEvent {
654660
WooAnalyticsEvent(statName: .cardReaderDisconnectTapped,
655661
properties: [
662+
Keys.cardReaderModel: cardReaderModel,
656663
Keys.countryCode: countryCode,
657664
Keys.gatewayID: gatewayID(forGatewayID: forGatewayID)
658665
]

WooCommerce/Classes/ViewRelated/CardPresentPayments/CardReaderConnectionController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ private extension CardReaderConnectionController {
594594
ServiceLocator.analytics.track(
595595
event: WooAnalyticsEvent.InPersonPayments.cardReaderConnectionFailed(forGatewayID: self.gatewayID,
596596
error: error,
597-
countryCode: self.configuration.countryCode)
597+
countryCode: self.configuration.countryCode,
598+
cardReaderModel: candidateReader.readerType.model)
598599
)
599600
self.state = .connectingFailed(error)
600601
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsConnectedViewModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ final class CardReaderSettingsConnectedViewModel: CardReaderSettingsPresentedVie
250250
func disconnectReader() {
251251
ServiceLocator.analytics.track(
252252
event: WooAnalyticsEvent.InPersonPayments.cardReaderDisconnectTapped(
253-
forGatewayID: connectedGatewayID, countryCode: configuration.countryCode
253+
forGatewayID: connectedGatewayID,
254+
countryCode: configuration.countryCode,
255+
cardReaderModel: connectedReaderModel ?? ""
254256
)
255257
)
256258

0 commit comments

Comments
 (0)