Skip to content

Commit

Permalink
Merge pull request #8321 from wordpress-mobile/fix/add_missing_tracki…
Browse files Browse the repository at this point in the history
…ng_of_cancelling_jetpack_install

Add additional tracking for remote install
  • Loading branch information
0nko authored Sep 17, 2018
2 parents 2e9826b + 3d0a4b7 commit 886601a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import kotlinx.android.synthetic.main.toolbar.*
import org.wordpress.android.R
import org.wordpress.android.analytics.AnalyticsTracker.Stat.INSTALL_JETPACK_CANCELLED
import org.wordpress.android.ui.JetpackConnectionUtils.trackWithSource
import org.wordpress.android.ui.JetpackRemoteInstallFragment.Companion.TRACKING_SOURCE_KEY

class JetpackRemoteInstallActivity : AppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -27,4 +30,12 @@ class JetpackRemoteInstallActivity : AppCompatActivity() {
}
return super.onOptionsItemSelected(item)
}

override fun onBackPressed() {
trackWithSource(
INSTALL_JETPACK_CANCELLED,
intent.getSerializableExtra(TRACKING_SOURCE_KEY) as JetpackConnectionSource
)
super.onBackPressed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.ViewModel
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.fluxc.Dispatcher
import org.wordpress.android.fluxc.generated.JetpackActionBuilder
import org.wordpress.android.fluxc.model.SiteModel
Expand Down Expand Up @@ -89,12 +90,15 @@ class JetpackRemoteInstallViewModel
fun onEventsUpdated(event: OnJetpackInstalled) {
val site = siteModel ?: return
if (event.isError) {
AnalyticsTracker.track(AnalyticsTracker.Stat.INSTALL_JETPACK_REMOTE_FAILED)
mutableViewState.postValue(Error { startRemoteInstall(site) })
return
}
if (event.success) {
AnalyticsTracker.track(AnalyticsTracker.Stat.INSTALL_JETPACK_REMOTE_COMPLETED)
mutableViewState.postValue(Installed { connectJetpack(site.id) })
} else {
AnalyticsTracker.track(AnalyticsTracker.Stat.INSTALL_JETPACK_REMOTE_FAILED)
mutableViewState.postValue(Error { startRemoteInstall(site) })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ public enum Stat {
INSTALL_JETPACK_SELECTED,
INSTALL_JETPACK_CANCELLED,
INSTALL_JETPACK_COMPLETED,
INSTALL_JETPACK_REMOTE_COMPLETED,
INSTALL_JETPACK_REMOTE_FAILED,
CONNECT_JETPACK_SELECTED,
CONNECT_JETPACK_FAILED,
PUSH_NOTIFICATION_RECEIVED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "install_jetpack_canceled";
case INSTALL_JETPACK_COMPLETED:
return "install_jetpack_completed";
case INSTALL_JETPACK_REMOTE_COMPLETED:
return "install_jetpack_remote_completed";
case INSTALL_JETPACK_REMOTE_FAILED:
return "connect_jetpack_remote_failed";
case CONNECT_JETPACK_SELECTED:
return "connect_jetpack_selected";
case CONNECT_JETPACK_FAILED:
Expand Down

0 comments on commit 886601a

Please sign in to comment.