diff options
Diffstat (limited to 'src/com/android/dialer/logging')
-rw-r--r-- | src/com/android/dialer/logging/Logger.java | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/com/android/dialer/logging/Logger.java b/src/com/android/dialer/logging/Logger.java index 300707779..ee23dc8e7 100644 --- a/src/com/android/dialer/logging/Logger.java +++ b/src/com/android/dialer/logging/Logger.java @@ -17,11 +17,18 @@ package com.android.dialer.logging; import android.app.Activity; +import android.app.Fragment; +import android.text.TextUtils; +import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialerbind.ObjectFactory; import com.android.incallui.Call; +/** + * Single entry point for all logging/analytics-related work for all user interactions. + */ public abstract class Logger { + public static final String FRAGMENT_TAG_SEPARATOR = "#"; public static Logger getInstance() { return ObjectFactory.getLoggerInstance(); @@ -40,19 +47,49 @@ public abstract class Logger { } /** - * Logs an event indicating that a screen/fragment was displayed. + * Logs an event indicating that a fragment was displayed. + * + * @param fragment to log an event for. + */ + public static void logFragmentView(Fragment fragment) { + if (fragment == null) { + return; + } + + logScreenView(fragment.getClass().getSimpleName(), fragment.getActivity(), null); + } + + /** + * Logs an event indicating that a screen was displayed. * - * @param fragmentName of the displayed fragment. - * @param activity Parent activity of the fragment. - * @param tag Optional string used to provide additional information about the fragment. + * @param screenName of the displayed screen. + * @param activity Parent activity of the displayed screen. + * @param tag Optional string used to provide additional information about the screen. */ - public static void logScreenView(String fragmentName, Activity activity, String tag) { + public static void logScreenView(String screenName, Activity activity, String tag) { final Logger logger = getInstance(); if (logger != null) { - logger.logScreenViewImpl(fragmentName, activity, tag); + logger.logScreenViewImpl(getScreenNameWithTag(screenName, tag)); + } + + AnalyticsUtil.sendScreenView(screenName, activity, tag); + } + + /** + * Build a tagged version of the provided screenName if the tag is non-empty. + * + * @param screenName Name of the screen. + * @param tag Optional tag describing the screen. + * @return the unchanged screenName if the tag is {@code null} or empty, the tagged version of + * the screenName otherwise. + */ + public static String getScreenNameWithTag(String screenName, String tag) { + if (TextUtils.isEmpty(tag)) { + return screenName; } + return screenName + FRAGMENT_TAG_SEPARATOR + tag; } public abstract void logCallImpl(Call call); - public abstract void logScreenViewImpl(String fragmentName, Activity activity, String tag); + public abstract void logScreenViewImpl(String screenName); } |