1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROMEOS_SERVICES_ASSISTANT_ASSISTANT_INTERACTION_LOGGER_H_ 6 #define CHROMEOS_SERVICES_ASSISTANT_ASSISTANT_INTERACTION_LOGGER_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "chromeos/services/assistant/public/cpp/assistant_service.h" 12 13 namespace chromeos { 14 namespace assistant { 15 16 // A subscriber that will log all Assistant interactions. 17 // The interactions will be logged using 18 // VLOG(AssistantInteractionLogger::kVLogLevel) 19 class AssistantInteractionLogger : public AssistantInteractionSubscriber { 20 public: 21 // VLog level used for logging interactions. 22 constexpr static const int kVLogLevel = 1; 23 24 // Returns if the current logging level is high enough so that the traces 25 // will be printed. If not, there is no point in creating this class. 26 static bool IsLoggingEnabled(); 27 28 AssistantInteractionLogger(); 29 AssistantInteractionLogger(AssistantInteractionLogger&) = delete; 30 AssistantInteractionLogger& operator=(AssistantInteractionLogger&) = delete; 31 ~AssistantInteractionLogger() override; 32 33 // AssistantInteractionSubscriber implementation: 34 void OnInteractionStarted( 35 const AssistantInteractionMetadata& metadata) override; 36 37 void OnInteractionFinished( 38 AssistantInteractionResolution resolution) override; 39 40 void OnHtmlResponse(const std::string& response, 41 const std::string& fallback) override; 42 43 void OnSuggestionsResponse( 44 const std::vector<AssistantSuggestion>& response) override; 45 46 void OnTextResponse(const std::string& response) override; 47 48 void OnOpenUrlResponse(const GURL& url, bool in_background) override; 49 50 bool OnOpenAppResponse(const AndroidAppInfo& app_info) override; 51 52 void OnSpeechRecognitionStarted() override; 53 54 void OnSpeechRecognitionIntermediateResult( 55 const std::string& high_confidence_text, 56 const std::string& low_confidence_text) override; 57 58 void OnSpeechRecognitionEndOfUtterance() override; 59 60 void OnSpeechRecognitionFinalResult(const std::string& final_result) override; 61 62 void OnSpeechLevelUpdated(float speech_level) override; 63 64 void OnTtsStarted(bool due_to_error) override; 65 66 void OnWaitStarted() override; 67 }; 68 69 } // namespace assistant 70 } // namespace chromeos 71 72 #endif // CHROMEOS_SERVICES_ASSISTANT_ASSISTANT_INTERACTION_LOGGER_H_ 73