content: /**
   * Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *     http://aws.amazon.com/apache2.0/
   *
   * or in the "license" file accompanying this file. This file is distributed
   * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
   * express or implied. See the License for the specific language governing
   * permissions and limitations under the License.
   */
  package com.amazon.analytics.logger;
  
  
  import android.app.Activity;
  import android.content.Context;
  import android.util.Log;
  
  import java.util.HashMap;
  
  import com.amazon.analytics.AnalyticsTags;
  import com.amazon.analytics.CustomAnalyticsTags;
  import com.amazon.analytics.IAnalytics;
  
  /**
   * An implementation of the analytics framework that logs the data
   * collected by the analytics framework.
   */
  public class LoggerAnalytics implements IAnalytics {
  
      private static final String TAG = LoggerAnalytics.class.getSimpleName();
  
      /**
       * Name used for implementation creator registration to Module Manager.
       */
      static final String IMPL_CREATOR_NAME = LoggerAnalytics.class.getSimpleName();
  
      private CustomAnalyticsTags mCustomTags = new CustomAnalyticsTags();
  
      /**
       * {@inheritDoc}
       *
       * @param context The application context.
       */
      @Override
      public void configure(Context context) {
  
          mCustomTags.init(context, R.string.logger_analytics_custom_tags);
  
          Log.d(TAG, "Configuration done.");
      }
  
      /**
       * {@inheritDoc}
       *
       * @param activity The activity to log.
       * @param active   True if data collecting should be active; False if collecting should
       *                 be paused.
       */
      @Override
      public void collectLifeCycleData(Activity activity, boolean active) {
  
          Log.d(TAG, "Collecting life cycle data for activity: " + activity.toString() + ", active: "
                  + active);
      }
  
      /**
       * {@inheritDoc}
       *
       * @param data Map of Strings to Objects that represent data that is necessary.
       */
      @Override
      public void trackAction(HashMap<String, Object> data) {
  
          String action = (String) data.get(AnalyticsTags.ACTION_NAME);
  
          HashMap<String, Object> attributes =
                  (HashMap<String, Object>) data.get(AnalyticsTags.ATTRIBUTES);
  
          Log.d(TAG, "Tracking action " + mCustomTags.getCustomTag(action) + " with attributes: "
                  + String.valueOf(mCustomTags.getCustomTags(attributes)));
      }
  
      /**
       * {@inheritDoc}
       *
       * @param screen The screen that is displayed.
       */
      @Override
      public void trackState(String screen) {
  
          Log.d(TAG, "Tracking screen " + screen);
      }
  
      /**
       * {@inheritDoc}
       */
      @Override
      public void trackCaughtError(String errorMessage, Throwable t) {
  
          Log.e(TAG, errorMessage, t);
      }
  }
  