Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.wordpress.android.R;
import org.wordpress.android.analytics.AnalyticsTracker;
import org.wordpress.android.networking.RestClientUtils;
import org.wordpress.android.ui.accounts.helpers.CreateUserAndBlog.Step;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.WPActivityUtils;
Expand Down Expand Up @@ -265,6 +267,12 @@ protected int getErrorMessageForErrorCode(String errorCode) {
protected enum ErrorType {USERNAME, PASSWORD, SITE_URL, EMAIL, TITLE, UNDEFINED}

public class ErrorListener implements RestRequest.ErrorListener {
private Step mStep;

public void setStep(Step step) {
mStep = step;
}

@Override
public void onErrorResponse(VolleyError error) {
String message = null;
Expand Down Expand Up @@ -301,6 +309,10 @@ public void onErrorResponse(VolleyError error) {
} else {
showError(messageId);
}

if (mStep == Step.CREATE_USER) {
AnalyticsTracker.track(AnalyticsTracker.Stat.CREATE_ACCOUNT_FAILED);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's about tracking the network error details in properties?
Something like the following code (that I didn't test)

Map<String, Object> properties = new HashMap<>();
properties.put("network_exception_class", error != null ? error.getClass().getCanonicalName() : "null");
properties.put("network_exception_message", error != null ?  error.getMessage() : "null");
if (error.networkResponse != null) {
     NetworkResponse networkResponse = error.networkResponse;
     if (networkResponse.data != null) {
             properties.put("network_exception_data",  new String(networkResponse.data)););
      }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @daniloercoli , good point. I actually looked into adding error info to that track prior to opening the PR but it seems that the useful error message can be deeper in the response's body. Most of onErrorResponse()'s code is about extracting the message after all. It seemed too complex for the purposes of this PR and decided to leave it out for a future PR if we see the need.

That said, let me know if you think this is a blocker and we should address it within this PR. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,22 @@ protected boolean specificShowError(int messageId) {
switch (getErrorType(messageId)) {
case USERNAME:
showUsernameError(messageId);

if (messageId == R.string.username_exists) {
AnalyticsTracker.track(AnalyticsTracker.Stat.CREATE_ACCOUNT_USERNAME_EXISTS);
}

return true;
case PASSWORD:
showPasswordError(messageId);
return true;
case EMAIL:
showEmailError(messageId);

if (messageId == R.string.email_exists) {
AnalyticsTracker.track(AnalyticsTracker.Stat.CREATE_ACCOUNT_EMAIL_EXISTS);
}

return true;
case SITE_URL:
showSiteUrlError(messageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public void onCreate(Bundle savedInstanceState) {
mInhibitMagicLogin = getActivity() != null
&& (getActivity().getIntent().getBooleanExtra(SignInActivity.EXTRA_INHIBIT_MAGIC_LOGIN, false)
|| !WPActivityUtils.isEmailClientAvailable(getActivity()));

track(Stat.LOGIN_ACCESSED, null);
}

@Override
Expand Down Expand Up @@ -663,6 +665,8 @@ private void createUserFragment() {
transaction.replace(R.id.fragment_container, newUserFragment);
transaction.addToBackStack(null);
transaction.commit();

track(Stat.CREATE_ACCOUNT_INITIATED, null);
}

private String getForgotPasswordURL() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private void validateUser() {
params.put("client_id", BuildConfig.OAUTH_APP_ID);
params.put("client_secret", BuildConfig.OAUTH_APP_SECRET);
mResponseHandler.setStep(Step.VALIDATE_USER);
mErrorListener.setStep(Step.VALIDATE_USER);
mRestClient.post(path, params, null, mResponseHandler, mErrorListener);
}

Expand All @@ -130,6 +131,7 @@ private void validateSite() {
params.put("client_id", BuildConfig.OAUTH_APP_ID);
params.put("client_secret", BuildConfig.OAUTH_APP_SECRET);
mResponseHandler.setStep(Step.VALIDATE_SITE);
mErrorListener.setStep(Step.VALIDATE_SITE);
mRestClient.post(path, params, null, mResponseHandler, mErrorListener);
}

Expand All @@ -143,6 +145,7 @@ private void createUser() {
params.put("client_id", BuildConfig.OAUTH_APP_ID);
params.put("client_secret", BuildConfig.OAUTH_APP_SECRET);
mResponseHandler.setStep(Step.CREATE_USER);
mErrorListener.setStep(Step.CREATE_USER);
mRestClient.post(path, params, null, mResponseHandler, mErrorListener);
}

Expand All @@ -165,6 +168,7 @@ public void onError(int errorMessageId, boolean twoStepCodeRequired, boolean htt
});

mResponseHandler.setStep(Step.AUTHENTICATE_USER);
mErrorListener.setStep(Step.AUTHENTICATE_USER);
}

private void createBlog() {
Expand All @@ -178,14 +182,15 @@ private void createBlog() {
params.put("client_id", BuildConfig.OAUTH_APP_ID);
params.put("client_secret", BuildConfig.OAUTH_APP_SECRET);
mResponseHandler.setStep(Step.CREATE_SITE);
mErrorListener.setStep(Step.CREATE_SITE);
WordPress.getRestClientUtils().post(path, params, null, mResponseHandler, mErrorListener);
}

public enum Step {
VALIDATE_USER, VALIDATE_SITE, CREATE_USER, AUTHENTICATE_USER, CREATE_SITE
}

private enum Mode {CREATE_USER_AND_BLOG, CREATE_BLOG_ONLY}
public enum Mode {CREATE_USER_AND_BLOG, CREATE_BLOG_ONLY}

public interface Callback {
void onStepFinished(Step step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public enum Stat {
OPENED_MY_PROFILE,
OPENED_PEOPLE_MANAGEMENT,
OPENED_PERSON,
CREATE_ACCOUNT_INITIATED,
CREATE_ACCOUNT_EMAIL_EXISTS,
CREATE_ACCOUNT_USERNAME_EXISTS,
CREATE_ACCOUNT_FAILED,
CREATED_ACCOUNT,
CREATED_SITE,
ACCOUNT_LOGOUT,
Expand All @@ -160,6 +164,7 @@ public enum Stat {
SUPPORT_USER_SENT_SCREENSHOT,
SUPPORT_USER_REVIEWED_THE_APP,
SUPPORT_USER_REPLIED_TO_HELPSHIFT,
LOGIN_ACCESSED,
LOGIN_MAGIC_LINK_EXITED,
LOGIN_MAGIC_LINK_FAILED,
LOGIN_MAGIC_LINK_OPENED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,30 @@ private AnalyticsTrackerMixpanelInstructionsForStat instructionsForStat(
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("People Management - Accessed Details");
break;
case CREATE_ACCOUNT_INITIATED:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Create Account Initiated");
instructions.setSuperPropertyAndPeoplePropertyToIncrement("number_of_times_create_account_initiated");
instructions.setCurrentDateForPeopleProperty("last_time_create_account_initiated");
break;
case CREATE_ACCOUNT_EMAIL_EXISTS:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Create Account Email Exists");
instructions.setSuperPropertyAndPeoplePropertyToIncrement("number_of_times_create_account_email_exists");
instructions.setCurrentDateForPeopleProperty("last_time_create_account_email_exists");
break;
case CREATE_ACCOUNT_USERNAME_EXISTS:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Create Account Username Exists");
instructions.setSuperPropertyAndPeoplePropertyToIncrement("number_of_times_create_account_username_exists");
instructions.setCurrentDateForPeopleProperty("last_time_create_account_username_exists");
break;
case CREATE_ACCOUNT_FAILED:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Create Account Failed");
instructions.setSuperPropertyAndPeoplePropertyToIncrement("number_of_times_create_account_failed");
instructions.setCurrentDateForPeopleProperty("last_time_create_account_failed");
break;
case CREATED_ACCOUNT:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Created Account");
Expand Down Expand Up @@ -950,6 +974,12 @@ private AnalyticsTrackerMixpanelInstructionsForStat instructionsForStat(
mixpanelInstructionsForEventName("Support - User Replied to Helpshift");
instructions.addSuperPropertyToFlag("support_user_replied_to_helpshift");
break;
case LOGIN_ACCESSED:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Login - Accessed");
instructions.setSuperPropertyAndPeoplePropertyToIncrement("number_of_times_login_accessed");
instructions.setCurrentDateForPeopleProperty("last_time_login_accessed");
break;
case LOGIN_MAGIC_LINK_EXITED:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Login - Magic Link exited");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "people_management_list_opened";
case OPENED_PERSON:
return "people_management_details_opened";
case CREATE_ACCOUNT_INITIATED:
return "account_create_initiated";
case CREATE_ACCOUNT_EMAIL_EXISTS:
return "account_create_email_exists";
case CREATE_ACCOUNT_USERNAME_EXISTS:
return "account_create_username_exists";
case CREATE_ACCOUNT_FAILED:
return "account_create_failed";
case CREATED_ACCOUNT:
return "account_created";
case CREATED_SITE:
Expand Down Expand Up @@ -504,6 +512,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "support_user_reviewed_the_app";
case SUPPORT_USER_REPLIED_TO_HELPSHIFT:
return "support_user_replied_to_helpshift";
case LOGIN_ACCESSED:
return "login_accessed";
case LOGIN_MAGIC_LINK_EXITED:
return "login_magic_link_exited";
case LOGIN_MAGIC_LINK_FAILED:
Expand Down