Home | History | Annotate | Download | only in internal
      1 /*
      2  * Copyright (C) 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.google.android.setupcompat.logging.internal;
     18 
     19 import android.content.Context;
     20 import androidx.annotation.IntDef;
     21 import androidx.annotation.StringDef;
     22 import com.google.android.setupcompat.logging.MetricKey;
     23 import java.lang.annotation.Retention;
     24 import java.lang.annotation.RetentionPolicy;
     25 
     26 /** Constant values used by {@link com.google.android.setupcompat.logging.SetupMetricsLogger}. */
     27 public interface SetupMetricsLoggingConstants {
     28 
     29   /** Enumeration of supported metric types logged to SetupWizard. */
     30   @Retention(RetentionPolicy.SOURCE)
     31   @IntDef({MetricType.CUSTOM_EVENT, MetricType.COUNTER_EVENT, MetricType.DURATION_EVENT})
     32   @interface MetricType {
     33     /**
     34      * MetricType constant used when logging {@link
     35      * com.google.android.setupcompat.logging.CustomEvent}.
     36      */
     37     int CUSTOM_EVENT = 1;
     38     /**
     39      * MetricType constant used when logging {@link com.google.android.setupcompat.logging.Timer}.
     40      */
     41     int DURATION_EVENT = 2;
     42 
     43     /**
     44      * MetricType constant used when logging counter value using {@link
     45      * com.google.android.setupcompat.logging.SetupMetricsLogger#logCounter(Context, MetricKey,
     46      * int)}.
     47      */
     48     int COUNTER_EVENT = 3;
     49 
     50     /** MetricType constant used for internal logging purposes. */
     51     int INTERNAL = 100;
     52   }
     53 
     54   /** Keys of the bundle used while logging data to SetupWizard. */
     55   @Retention(RetentionPolicy.SOURCE)
     56   @StringDef({
     57     MetricBundleKeys.METRIC_KEY,
     58     MetricBundleKeys.METRIC_KEY_BUNDLE,
     59     MetricBundleKeys.CUSTOM_EVENT,
     60     MetricBundleKeys.CUSTOM_EVENT_BUNDLE,
     61     MetricBundleKeys.TIME_MILLIS_LONG,
     62     MetricBundleKeys.COUNTER_INT
     63   })
     64   @interface MetricBundleKeys {
     65     /**
     66      * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
     67      * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
     68      *
     69      * @deprecated Use {@link #METRIC_KEY_BUNDLE} instead.
     70      */
     71     @Deprecated String METRIC_KEY = "MetricKey";
     72 
     73     /**
     74      * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
     75      * value being a parcelable of type {@link com.google.android.setupcompat.logging.CustomEvent}.
     76      *
     77      * @deprecated Use {@link #CUSTOM_EVENT_BUNDLE} instead.
     78      */
     79     @Deprecated String CUSTOM_EVENT = "CustomEvent";
     80 
     81     /**
     82      * This key will be set when {@code metricType} is {@link MetricType#DURATION_EVENT} with the
     83      * value of type {@code long} representing the {@code duration} in milliseconds for the given
     84      * {@link MetricKey}.
     85      */
     86     String TIME_MILLIS_LONG = "timeMillis";
     87 
     88     /**
     89      * This key will be set when {@code metricType} is {@link MetricType#COUNTER_EVENT} with the
     90      * value of type {@code int} representing the {@code counter} value logged for the given {@link
     91      * MetricKey}.
     92      */
     93     String COUNTER_INT = "counter";
     94 
     95     /**
     96      * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
     97      * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
     98      */
     99     String METRIC_KEY_BUNDLE = "MetricKey_bundle";
    100 
    101     /**
    102      * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
    103      * value being a Bundle which can be used to read {@link
    104      * com.google.android.setupcompat.logging.CustomEvent}.
    105      */
    106     String CUSTOM_EVENT_BUNDLE = "CustomEvent_bundle";
    107   }
    108 }
    109