• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.google.android.setupcompat.logging.ScreenKey;
24 import com.google.android.setupcompat.logging.SetupMetric;
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /** Constant values used by {@link com.google.android.setupcompat.logging.SetupMetricsLogger}. */
29 public interface SetupMetricsLoggingConstants {
30 
31   /** Enumeration of supported metric types logged to SetupWizard. */
32   @Retention(RetentionPolicy.SOURCE)
33   @IntDef({
34       MetricType.CUSTOM_EVENT,
35       MetricType.DURATION_EVENT,
36       MetricType.COUNTER_EVENT,
37       MetricType.SETUP_COLLECTION_EVENT,
38       MetricType.INTERNAL})
39   @interface MetricType {
40     /**
41      * MetricType constant used when logging {@link
42      * com.google.android.setupcompat.logging.CustomEvent}.
43      */
44     int CUSTOM_EVENT = 1;
45     /**
46      * MetricType constant used when logging {@link com.google.android.setupcompat.logging.Timer}.
47      */
48     int DURATION_EVENT = 2;
49 
50     /**
51      * MetricType constant used when logging counter value using {@link
52      * com.google.android.setupcompat.logging.SetupMetricsLogger#logCounter(Context, MetricKey,
53      * int)}.
54      */
55     int COUNTER_EVENT = 3;
56 
57     /**
58      * MetricType constant used when logging setup metric using {@link
59      * com.google.android.setupcompat.logging.SetupMetricsLogger#logMetrics(Context, ScreenKey,
60      * SetupMetric...)}.
61      */
62     int SETUP_COLLECTION_EVENT = 4;
63 
64     /** MetricType constant used for internal logging purposes. */
65     int INTERNAL = 100;
66   }
67 
68   /**
69    * Enumeration of supported EventType of {@link MetricType#SETUP_COLLECTION_EVENT} logged to
70    * SetupWizard. (go/suw-metrics-collection-api)
71    */
72   @Retention(RetentionPolicy.SOURCE)
73   @IntDef({
74       EventType.UNKNOWN,
75       EventType.IMPRESSION,
76       EventType.OPT_IN,
77       EventType.WAITING_START,
78       EventType.WAITING_END,
79       EventType.ERROR,
80   })
81   @interface EventType {
82     int UNKNOWN = 1;
83     int IMPRESSION = 2;
84     int OPT_IN = 3;
85     int WAITING_START = 4;
86     int WAITING_END = 5;
87     int ERROR = 6;
88   }
89 
90   /** Keys of the bundle used while logging data to SetupWizard. */
91   @Retention(RetentionPolicy.SOURCE)
92   @StringDef({
93     MetricBundleKeys.METRIC_KEY,
94     MetricBundleKeys.METRIC_KEY_BUNDLE,
95     MetricBundleKeys.CUSTOM_EVENT,
96     MetricBundleKeys.CUSTOM_EVENT_BUNDLE,
97     MetricBundleKeys.TIME_MILLIS_LONG,
98     MetricBundleKeys.COUNTER_INT,
99     MetricBundleKeys.SCREEN_KEY_BUNDLE,
100     MetricBundleKeys.SETUP_METRIC_BUNDLE,
101   })
102   @interface MetricBundleKeys {
103     /**
104      * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
105      * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
106      *
107      * @deprecated Use {@link #METRIC_KEY_BUNDLE} instead.
108      */
109     @Deprecated String METRIC_KEY = "MetricKey";
110 
111     /**
112      * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
113      * value being a parcelable of type {@link com.google.android.setupcompat.logging.CustomEvent}.
114      *
115      * @deprecated Use {@link #CUSTOM_EVENT_BUNDLE} instead.
116      */
117     @Deprecated String CUSTOM_EVENT = "CustomEvent";
118 
119     /**
120      * This key will be set when {@code metricType} is {@link MetricType#DURATION_EVENT} with the
121      * value of type {@code long} representing the {@code duration} in milliseconds for the given
122      * {@link MetricKey}.
123      */
124     String TIME_MILLIS_LONG = "timeMillis";
125 
126     /**
127      * This key will be set when {@code metricType} is {@link MetricType#COUNTER_EVENT} with the
128      * value of type {@code int} representing the {@code counter} value logged for the given {@link
129      * MetricKey}.
130      */
131     String COUNTER_INT = "counter";
132 
133     /**
134      * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
135      * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
136      */
137     String METRIC_KEY_BUNDLE = "MetricKey_bundle";
138 
139     /**
140      * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
141      * value being a Bundle which can be used to read {@link
142      * com.google.android.setupcompat.logging.CustomEvent}.
143      */
144     String CUSTOM_EVENT_BUNDLE = "CustomEvent_bundle";
145 
146     /**
147      * This key will be used when {@code metricType} is {@link MetricType#SETUP_COLLECTION_EVENT}
148      * with the value being a Bundle which can be used to read {@link ScreenKey}
149      */
150     String SCREEN_KEY_BUNDLE = "ScreenKey_bundle";
151 
152     /**
153      * This key will be used when {@code metricType} is {@link MetricType#SETUP_COLLECTION_EVENT}
154      * with the value being a Bundle which can be used to read {@link SetupMetric}
155      */
156     String SETUP_METRIC_BUNDLE = "SetupMetric_bundle";
157   }
158 }
159