summaryrefslogtreecommitdiff
path: root/main/java/com/google/android/setupcompat/logging/internal/SetupMetricsLoggingConstants.java
blob: d4995b747896d0149a1d58cdcfbb4eb4373d9e2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.google.android.setupcompat.logging.internal;

import android.content.Context;
import androidx.annotation.IntDef;
import androidx.annotation.StringDef;
import com.google.android.setupcompat.logging.MetricKey;
import com.google.android.setupcompat.logging.ScreenKey;
import com.google.android.setupcompat.logging.SetupMetric;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/** Constant values used by {@link com.google.android.setupcompat.logging.SetupMetricsLogger}. */
public interface SetupMetricsLoggingConstants {

  /** Enumeration of supported metric types logged to SetupWizard. */
  @Retention(RetentionPolicy.SOURCE)
  @IntDef({
      MetricType.CUSTOM_EVENT,
      MetricType.DURATION_EVENT,
      MetricType.COUNTER_EVENT,
      MetricType.SETUP_COLLECTION_EVENT,
      MetricType.INTERNAL})
  @interface MetricType {
    /**
     * MetricType constant used when logging {@link
     * com.google.android.setupcompat.logging.CustomEvent}.
     */
    int CUSTOM_EVENT = 1;
    /**
     * MetricType constant used when logging {@link com.google.android.setupcompat.logging.Timer}.
     */
    int DURATION_EVENT = 2;

    /**
     * MetricType constant used when logging counter value using {@link
     * com.google.android.setupcompat.logging.SetupMetricsLogger#logCounter(Context, MetricKey,
     * int)}.
     */
    int COUNTER_EVENT = 3;

    /**
     * MetricType constant used when logging setup metric using {@link
     * com.google.android.setupcompat.logging.SetupMetricsLogger#logMetrics(Context, ScreenKey,
     * SetupMetric...)}.
     */
    int SETUP_COLLECTION_EVENT = 4;

    /** MetricType constant used for internal logging purposes. */
    int INTERNAL = 100;
  }

  /**
   * Enumeration of supported EventType of {@link MetricType#SETUP_COLLECTION_EVENT} logged to
   * SetupWizard. (go/suw-metrics-collection-api)
   */
  @Retention(RetentionPolicy.SOURCE)
  @IntDef({
      EventType.UNKNOWN,
      EventType.IMPRESSION,
      EventType.OPT_IN,
      EventType.WAITING_START,
      EventType.WAITING_END,
      EventType.ERROR,
  })
  @interface EventType {
    int UNKNOWN = 1;
    int IMPRESSION = 2;
    int OPT_IN = 3;
    int WAITING_START = 4;
    int WAITING_END = 5;
    int ERROR = 6;
  }

  /** Keys of the bundle used while logging data to SetupWizard. */
  @Retention(RetentionPolicy.SOURCE)
  @StringDef({
    MetricBundleKeys.METRIC_KEY,
    MetricBundleKeys.METRIC_KEY_BUNDLE,
    MetricBundleKeys.CUSTOM_EVENT,
    MetricBundleKeys.CUSTOM_EVENT_BUNDLE,
    MetricBundleKeys.TIME_MILLIS_LONG,
    MetricBundleKeys.COUNTER_INT,
    MetricBundleKeys.SCREEN_KEY_BUNDLE,
    MetricBundleKeys.SETUP_METRIC_BUNDLE,
  })
  @interface MetricBundleKeys {
    /**
     * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
     * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
     *
     * @deprecated Use {@link #METRIC_KEY_BUNDLE} instead.
     */
    @Deprecated String METRIC_KEY = "MetricKey";

    /**
     * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
     * value being a parcelable of type {@link com.google.android.setupcompat.logging.CustomEvent}.
     *
     * @deprecated Use {@link #CUSTOM_EVENT_BUNDLE} instead.
     */
    @Deprecated String CUSTOM_EVENT = "CustomEvent";

    /**
     * This key will be set when {@code metricType} is {@link MetricType#DURATION_EVENT} with the
     * value of type {@code long} representing the {@code duration} in milliseconds for the given
     * {@link MetricKey}.
     */
    String TIME_MILLIS_LONG = "timeMillis";

    /**
     * This key will be set when {@code metricType} is {@link MetricType#COUNTER_EVENT} with the
     * value of type {@code int} representing the {@code counter} value logged for the given {@link
     * MetricKey}.
     */
    String COUNTER_INT = "counter";

    /**
     * {@link MetricKey} of the data being logged. This will be set when {@code metricType} is
     * either {@link MetricType#COUNTER_EVENT} or {@link MetricType#DURATION_EVENT}.
     */
    String METRIC_KEY_BUNDLE = "MetricKey_bundle";

    /**
     * This key will be used when {@code metricType} is {@link MetricType#CUSTOM_EVENT} with the
     * value being a Bundle which can be used to read {@link
     * com.google.android.setupcompat.logging.CustomEvent}.
     */
    String CUSTOM_EVENT_BUNDLE = "CustomEvent_bundle";

    /**
     * This key will be used when {@code metricType} is {@link MetricType#SETUP_COLLECTION_EVENT}
     * with the value being a Bundle which can be used to read {@link ScreenKey}
     */
    String SCREEN_KEY_BUNDLE = "ScreenKey_bundle";

    /**
     * This key will be used when {@code metricType} is {@link MetricType#SETUP_COLLECTION_EVENT}
     * with the value being a Bundle which can be used to read {@link SetupMetric}
     */
    String SETUP_METRIC_BUNDLE = "SetupMetric_bundle";
  }
}