Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a8719c8 authored by Garfield Tan's avatar Garfield Tan
Browse files

Separate rootVisited metrics into 2 categories

...for file managers and file pickers respectively.

Test: Automatic tests pass. Smoke manual tests.

Bug: 34157898
Change-Id: Iad861fff1a5fdebaa2ad6742ef3bb26d60df70b6
(cherry picked from commit 045ce6bc)
parent a06bcfc2
Loading
Loading
Loading
Loading
+29 −6
Original line number Diff line number Diff line
@@ -57,7 +57,10 @@ public final class Metrics {

    // These strings have to be whitelisted in tron. Do not change them.
    private static final String COUNT_LAUNCH_ACTION = "docsui_launch_action";
    private static final String COUNT_ROOT_VISITED = "docsui_root_visited";
    private static final String COUNT_ROOT_VISITED_IN_MANAGER
            = "docsui_root_visited_in_manager";
    private static final String COUNT_ROOT_VISITED_IN_PICKER
            = "docsui_root_visited_in_picker";
    private static final String COUNT_OPEN_MIME = "docsui_open_mime";
    private static final String COUNT_CREATE_MIME = "docsui_create_mime";
    private static final String COUNT_GET_CONTENT_MIME = "docsui_get_content_mime";
@@ -148,6 +151,13 @@ public final class Metrics {
    @Retention(RetentionPolicy.SOURCE)
    public @interface Mime {}

    public static final int FILES_SCOPE = 1;
    public static final int PICKER_SCOPE = 2;

    @IntDef({ FILES_SCOPE, PICKER_SCOPE })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ContextScope {}

    // Codes representing different kinds of file operations. These are used for bucketing
    // operations in the COUNT_FILEOP_{SYSTEM|EXTERNAL} histograms.
    // Do not change or rearrange these values, that will break historical data. Only add to the
@@ -410,23 +420,36 @@ public final class Metrics {
    }

    /**
     * Logs a root visited event. Call this when the user visits on a root in the RootsFragment.
     * Logs a root visited event in file managers. Call this when the user
     * taps on a root in {@link com.android.documentsui.sidebar.RootsFragment}.
     *
     * @param context
     * @param scope
     * @param info
     */
    public static void logRootVisited(Context context, RootInfo info) {
        logHistogram(context, COUNT_ROOT_VISITED, sanitizeRoot(info));
    public static void logRootVisited(
            Context context, @ContextScope int scope, RootInfo info) {
        switch (scope) {
            case FILES_SCOPE:
                logHistogram(context, COUNT_ROOT_VISITED_IN_MANAGER,
                        sanitizeRoot(info));
                break;
            case PICKER_SCOPE:
                logHistogram(context, COUNT_ROOT_VISITED_IN_PICKER,
                        sanitizeRoot(info));
                break;
        }
    }

    /**
     * Logs an app visited event. Call this when the user visits on an app in the RootsFragment.
     * Logs an app visited event in file pickers. Call this when the user visits
     * on an app in the RootsFragment.
     *
     * @param context
     * @param info
     */
    public static void logAppVisited(Context context, ResolveInfo info) {
        logHistogram(context, COUNT_ROOT_VISITED, sanitizeRoot(info));
        logHistogram(context, COUNT_ROOT_VISITED_IN_PICKER, sanitizeRoot(info));
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa

    @Override
    public void openRoot(RootInfo root) {
        Metrics.logRootVisited(mActivity, root);
        Metrics.logRootVisited(mActivity, Metrics.FILES_SCOPE, root);
        mActivity.onRootPicked(root);
    }

+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T

    @Override
    public void openRoot(RootInfo root) {
        Metrics.logRootVisited(mActivity, root);
        Metrics.logRootVisited(mActivity, Metrics.PICKER_SCOPE, root);
        mActivity.onRootPicked(root);
    }