|
61 | 61 | #include "cuttlefish/host/commands/cvd/instances/lock/instance_lock.h" |
62 | 62 | #include "cuttlefish/host/commands/cvd/instances/operator_client.h" |
63 | 63 | #include "cuttlefish/host/commands/cvd/instances/reset_client_utils.h" |
| 64 | +#include "cuttlefish/host/commands/cvd/metrics/is_enabled.h" |
64 | 65 | #include "cuttlefish/host/commands/cvd/utils/common.h" |
65 | 66 | #include "cuttlefish/host/commands/cvd/utils/interrupt_listener.h" |
66 | 67 | #include "cuttlefish/host/commands/cvd/utils/subprocess_waiter.h" |
| 68 | +#include "cuttlefish/host/commands/metrics/proto/cf_metrics_protos.h" |
| 69 | +#include "cuttlefish/host/commands/metrics/utils.h" |
67 | 70 | #include "cuttlefish/host/libs/config/config_constants.h" |
68 | 71 | #include "cuttlefish/host/libs/config/cuttlefish_config.h" |
| 72 | +#include "cuttlefish/host/libs/metrics/metrics_defs.h" |
69 | 73 |
|
70 | 74 | namespace cuttlefish { |
71 | 75 | namespace { |
@@ -617,6 +621,43 @@ Result<void> CvdStartCommandHandler::LaunchDevice( |
617 | 621 |
|
618 | 622 | CF_EXPECT(subprocess_waiter_.Setup(launch_command)); |
619 | 623 |
|
| 624 | + LOG(INFO) |
| 625 | + << "By using this Android Virtual Device, you agree to Google Terms of " |
| 626 | + "Service (https://policies.google.com/terms). The Google Privacy " |
| 627 | + "Policy (https://policies.google.com/privacy) describes how Google " |
| 628 | + "handles information generated as you use Google services."; |
| 629 | + if (kEnableCvdMetrics) { |
| 630 | + static constexpr int kLogSourceId = 1753; |
| 631 | + static constexpr char kLogSourceStr[] = "CUTTLEFISH_METRICS"; |
| 632 | + static constexpr int kCppClientType = |
| 633 | + 19; // C++ native client type (clientanalytics.proto) |
| 634 | + // |
| 635 | + LOG(INFO) << "This will automatically send diagnostic information to " |
| 636 | + "Google, such as crash reports and usage data from the host " |
| 637 | + "machine managing the Android Virtual Device."; |
| 638 | + CuttlefishLogEvent cf_log_event; |
| 639 | + |
| 640 | + cf_log_event.set_session_id("cvd-todo-session"); |
| 641 | + |
| 642 | + LogRequest request_proto; |
| 643 | + request_proto.set_log_source(kLogSourceId); |
| 644 | + request_proto.set_log_source_name(kLogSourceStr); |
| 645 | + |
| 646 | + ClientInfo& client_info = *request_proto.mutable_client_info(); |
| 647 | + client_info.set_client_type(kCppClientType); |
| 648 | + |
| 649 | + LogEvent& log_event = *request_proto.add_log_event(); |
| 650 | + log_event.set_event_time_ms(metrics::GetEpochTimeMs()); |
| 651 | + log_event.set_source_extension(cf_log_event.SerializeAsString()); |
| 652 | + |
| 653 | + std::string request_string = request_proto.SerializeAsString(); |
| 654 | + MetricsExitCodes reporting_outcome = |
| 655 | + metrics::PostRequest(request_string, metrics::ClearcutServer::kProd); |
| 656 | + if (reporting_outcome != MetricsExitCodes::kSuccess) { |
| 657 | + LOG(ERROR) << "Issue reporting metrics: " << reporting_outcome; |
| 658 | + } |
| 659 | + } |
| 660 | + |
620 | 661 | auto acloud_compat_action_result = AcloudCompatActions(group, envs, request); |
621 | 662 | if (!acloud_compat_action_result.ok()) { |
622 | 663 | LOG(ERROR) << acloud_compat_action_result.error().FormatForEnv(); |
|
0 commit comments