1 /* 2 * Copyright (C) 2022 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 package com.android.quicksearchbox 17 18 /** Interface for logging implementations. */ 19 interface Logger { 20 /** 21 * Called when QSB has started. 22 * 23 * @param latency User-visible start-up latency in milliseconds. 24 */ logStartnull25 fun logStart(onCreateLatency: Int, latency: Int, intentSource: String?) 26 27 /** 28 * Called when a suggestion is clicked. 29 * 30 * @param suggestionId Suggestion ID; 0-based position of the suggestion in the UI if the list is 31 * flat. 32 * @param suggestionCursor all the suggestions shown in the UI. 33 * @param clickType One of the SUGGESTION_CLICK_TYPE constants. 34 */ 35 fun logSuggestionClick(suggestionId: Long, suggestionCursor: SuggestionCursor?, clickType: Int) 36 37 /** 38 * The user launched a search. 39 * 40 * @param startMethod One of [.SEARCH_METHOD_BUTTON] or [.SEARCH_METHOD_KEYBOARD]. 41 * @param numChars The number of characters in the query. 42 */ 43 fun logSearch(startMethod: Int, numChars: Int) 44 45 /** The user launched a voice search. */ 46 fun logVoiceSearch() 47 48 /** 49 * The user left QSB without performing any action (click suggestions, search or voice search). 50 * 51 * @param suggestionCursor all the suggestions shown in the UI when the user left 52 * @param numChars The number of characters in the query typed when the user left. 53 */ 54 fun logExit(suggestionCursor: SuggestionCursor?, numChars: Int) 55 56 /** 57 * Logs the latency of a suggestion query to a specific source. 58 * 59 * @param result The result of the query. 60 */ 61 fun logLatency(result: SourceResult?) 62 63 companion object { 64 const val SEARCH_METHOD_BUTTON = 0 65 const val SEARCH_METHOD_KEYBOARD = 1 66 const val SUGGESTION_CLICK_TYPE_LAUNCH = 0 67 const val SUGGESTION_CLICK_TYPE_REFINE = 1 68 const val SUGGESTION_CLICK_TYPE_QUICK_CONTACT = 2 69 } 70 } 71