Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix application_store_snapshot event not showing up in Tracks #10575

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion WooCommerce/Classes/Yosemite/SiteSnapshotTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class SiteSnapshotTracker {
let paymentGatewaySnapshot = PaymentGatewaySnapshot(plugins: systemPlugins)
let properties: [String: Any] = PaymentGatewaySnapshot.Plugin.allCases.reduce(otherProperties) { partialResult, plugin in
var newResult = partialResult
newResult[plugin.rawValue] = paymentGatewaySnapshot.status(of: plugin).rawValue
newResult[plugin.eventPropertyName] = paymentGatewaySnapshot.status(of: plugin).rawValue
return newResult
}
analytics.track(.applicationSiteSnapshot, withProperties: properties)
Expand Down Expand Up @@ -69,6 +69,10 @@ private struct PaymentGatewaySnapshot {
case stripe = "woocommerce-gateway-stripe"
case square = "woocommerce-square"
case payPal = "woocommerce-paypal-payments"

var eventPropertyName: String {
rawValue.replacingOccurrences(of: "-", with: "_")
}
}

private let plugins: [SystemPlugin]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ final class SiteSnapshotTrackerTests: XCTestCase {
let eventProperties = try XCTUnwrap(analyticsProvider.receivedProperties.first)
XCTAssertEqual(eventProperties["orders_count"] as? Int64, 115)
XCTAssertEqual(eventProperties["products_count"] as? Int64, 98)
XCTAssertEqual(eventProperties["woocommerce-payments"] as? String, "installed_and_activated")
XCTAssertEqual(eventProperties["woocommerce-gateway-stripe"] as? String, "not_installed")
XCTAssertEqual(eventProperties["woocommerce-square"] as? String, "not_installed")
XCTAssertEqual(eventProperties["woocommerce-paypal-payments"] as? String, "installed_and_not_activated")
XCTAssertEqual(eventProperties["woocommerce_payments"] as? String, "installed_and_activated")
XCTAssertEqual(eventProperties["woocommerce_gateway_stripe"] as? String, "not_installed")
XCTAssertEqual(eventProperties["woocommerce_square"] as? String, "not_installed")
XCTAssertEqual(eventProperties["woocommerce_paypal_payments"] as? String, "installed_and_not_activated")
}

func test_event_is_not_tracked_when_the_site_snapshot_has_been_tracked() throws {
Expand Down