Skip to content

Commit

Permalink
Merge pull request #13673 from woocommerce/track-app-password-site-url
Browse files Browse the repository at this point in the history
[Login] Track the site URL when detecting that Application Passwords are disabled
  • Loading branch information
hichamboushaba authored Mar 6, 2025
2 parents cb1d481 + c650211 commit 1016f24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class AnalyticsTracker private constructor(
private const val TRACKS_ANON_ID = "nosara_tracks_anon_id"
private const val EVENTS_PREFIX = "woocommerceandroid_"
private const val POS_EVENTS_PREFIX = "woocommerceandroid_pos_"
private const val KEY_SITE_URL = "site_url"
const val KEY_SITE_URL = "site_url"

const val IS_DEBUG = "is_debug"
const val KEY_ALREADY_READ = "already_read"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class ApplicationPasswordsNotifier @Inject constructor(
override fun onFeatureUnavailable(siteModel: SiteModel, networkError: WPAPINetworkError) {
trackGenerationFailure(
cause = GenerationFailureCause.FEATURE_DISABLED,
networkError = networkError
networkError = networkError,
additionalProperties = mapOf(
AnalyticsTracker.KEY_SITE_URL to siteModel.url
)
)
_featureUnavailableEvents.tryEmit(networkError)
}
Expand Down Expand Up @@ -65,7 +68,8 @@ class ApplicationPasswordsNotifier @Inject constructor(

private fun trackGenerationFailure(
cause: GenerationFailureCause,
networkError: WPAPINetworkError
networkError: WPAPINetworkError,
additionalProperties: Map<String, String> = emptyMap()
) {
val scenario = if (selectedSite.exists()) {
GenerationFailureScenario.REGENERATION
Expand All @@ -78,7 +82,7 @@ class ApplicationPasswordsNotifier @Inject constructor(
properties = mapOf(
AnalyticsTracker.KEY_SCENARIO to scenario.name.lowercase(),
AnalyticsTracker.KEY_CAUSE to cause.name.lowercase()
),
) + additionalProperties,
errorContext = networkError.javaClass.simpleName,
errorType = networkError.type.name,
errorDescription = networkError.message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ class LoginSiteCredentialsViewModel @Inject constructor(
)
)
} else {
analyticsTracker.track(AnalyticsEvent.APPLICATION_PASSWORDS_AUTHORIZATION_URL_NOT_AVAILABLE)
analyticsTracker.track(
AnalyticsEvent.APPLICATION_PASSWORDS_AUTHORIZATION_URL_NOT_AVAILABLE,
properties = mapOf(
AnalyticsTracker.KEY_SITE_URL to siteAddress
)
)
triggerEvent(ShowApplicationPasswordsUnavailableScreen(siteAddress, site.isJetpackConnected))
}
} else {
Expand Down

0 comments on commit 1016f24

Please sign in to comment.