mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Refactor AnalyticsRecorder into a pure abstract interface
PiperOrigin-RevId: 921794969
This commit is contained in:
committed by
Copybara-Service
parent
83b35985a8
commit
173da32391
@@ -24,6 +24,7 @@ cc_library(
|
||||
"//connections:__subpackages__",
|
||||
"//location/nearby/analytics/cpp:__subpackages__",
|
||||
"//location/nearby/cpp/experiments:__subpackages__",
|
||||
"//location/nearby/sharing/lib:__subpackages__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
|
||||
+6
-9
@@ -464,10 +464,10 @@ cc_library(
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform:types",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//location/nearby/sharing/lib/rpc:fake_nearby_share_client",
|
||||
"//location/nearby/sharing/lib/rpc:sharing_rpc_client",
|
||||
"//location/nearby/sharing/lib/sync:sync_manager",
|
||||
"//sharing/analytics",
|
||||
"//sharing/certificates",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/internal/api:platform",
|
||||
@@ -661,8 +661,8 @@ cc_test(
|
||||
"//location/nearby/sharing/lib/account:fake_account_manager",
|
||||
"//location/nearby/sharing/lib/account:mock_account_manager",
|
||||
"//location/nearby/sharing/lib/account:signin_attempt",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//location/nearby/sharing/lib/rpc:fake_nearby_share_client",
|
||||
"//sharing/analytics",
|
||||
"//sharing/certificates",
|
||||
"//sharing/certificates:test_support",
|
||||
"//sharing/common",
|
||||
@@ -868,16 +868,14 @@ cc_test(
|
||||
":nearby_connection_impl",
|
||||
":paired_key_verification_runner",
|
||||
":share_session",
|
||||
":share_session_usage",
|
||||
":test_support",
|
||||
":transfer_metadata",
|
||||
":transfer_metadata_matchers",
|
||||
":types",
|
||||
"//internal/analytics:mock_event_logger",
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//sharing/analytics",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//sharing/certificates:test_support",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
@@ -931,8 +929,8 @@ cc_test(
|
||||
"//internal/network:url",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//net/proto2/contrib/parse_proto:parse_text_proto",
|
||||
"//sharing/analytics",
|
||||
"//sharing/certificates:test_support",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/proto:wire_format_cc_proto",
|
||||
@@ -952,7 +950,6 @@ cc_test(
|
||||
":attachments",
|
||||
":connection_types",
|
||||
":nearby_connection_impl",
|
||||
":paired_key_verification_runner",
|
||||
":share_session",
|
||||
":share_session_usage",
|
||||
":test_support",
|
||||
@@ -963,8 +960,8 @@ cc_test(
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//proto:sharing_enums_cc_proto",
|
||||
"//sharing/analytics",
|
||||
"//sharing/internal/public:logging",
|
||||
"//sharing/proto:wire_format_cc_proto",
|
||||
"//sharing/proto/analytics:sharing_log_cc_proto",
|
||||
@@ -1033,7 +1030,7 @@ cc_test(
|
||||
":types",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//internal/test",
|
||||
"//sharing/analytics",
|
||||
"//location/nearby/sharing/lib/analytics",
|
||||
"//sharing/certificates",
|
||||
"//sharing/certificates:test_support",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
|
||||
@@ -13,15 +13,11 @@
|
||||
# limitations under the License.
|
||||
|
||||
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
||||
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "analytics",
|
||||
srcs = [
|
||||
"analytics_recorder.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"analytics_device_settings.h",
|
||||
"analytics_information.h",
|
||||
@@ -29,38 +25,12 @@ cc_library(
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//internal/analytics:event_logger",
|
||||
"//proto:sharing_enums_cc_proto",
|
||||
"//sharing:attachments",
|
||||
"//sharing:types",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/proto:enums_cc_proto",
|
||||
"//sharing/proto/analytics:sharing_log_cc_proto",
|
||||
"@com_google_absl//absl/random",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_protobuf//:protobuf",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "analytics_test",
|
||||
srcs = ["analytics_recorder_test.cc"],
|
||||
deps = [
|
||||
":analytics",
|
||||
"//internal/analytics:mock_event_logger",
|
||||
"//internal/platform/implementation:platform_impl",
|
||||
"//proto:sharing_enums_cc_proto",
|
||||
"//sharing:attachments",
|
||||
"//sharing:types",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/proto:enums_cc_proto",
|
||||
"//sharing/proto:wire_format_cc_proto",
|
||||
"//sharing/proto/analytics:sharing_log_cc_proto",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"@com_google_protobuf//:protobuf",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,838 +0,0 @@
|
||||
// Copyright 2022-2023 Google LLC
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// https://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.
|
||||
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "google/protobuf/duration.pb.h"
|
||||
#include "absl/random/random.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
#include "sharing/share_target.h"
|
||||
#include "sharing/wifi_credentials_attachment.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace analytics {
|
||||
namespace {
|
||||
|
||||
using ::location::nearby::proto::sharing::DeviceRelationship;
|
||||
using ::location::nearby::proto::sharing::DeviceType;
|
||||
using ::location::nearby::proto::sharing::EstablishConnectionStatus;
|
||||
using ::location::nearby::proto::sharing::EventCategory;
|
||||
using ::location::nearby::proto::sharing::EventType;
|
||||
using ::location::nearby::proto::sharing::OSType;
|
||||
using ::location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus;
|
||||
using ::location::nearby::proto::sharing::ShowNotificationStatus;
|
||||
using ::location::nearby::proto::sharing::Visibility;
|
||||
|
||||
using ::nearby::sharing::analytics::proto::SharingLog;
|
||||
using ::nearby::sharing::proto::DataUsage;
|
||||
using ::nearby::sharing::proto::DeviceVisibility;
|
||||
|
||||
DeviceRelationship GetLoggerDeviceRelationship(
|
||||
const ShareTarget& share_target) {
|
||||
if (share_target.for_self_share) {
|
||||
return DeviceRelationship::IS_SELF;
|
||||
} else if (share_target.is_known) {
|
||||
return DeviceRelationship::IS_CONTACT;
|
||||
} else {
|
||||
return DeviceRelationship::IS_STRANGER;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceType GetLoggerDeviceType(ShareTargetType type) {
|
||||
switch (type) {
|
||||
case ShareTargetType::kLaptop:
|
||||
return DeviceType::LAPTOP;
|
||||
case ShareTargetType::kPhone:
|
||||
return DeviceType::PHONE;
|
||||
case ShareTargetType::kTablet:
|
||||
return DeviceType::TABLET;
|
||||
default:
|
||||
return DeviceType::UNKNOWN_DEVICE_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
Visibility GetLoggerVisibility(DeviceVisibility visibility) {
|
||||
switch (visibility) {
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS:
|
||||
return Visibility::CONTACTS_ONLY;
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_SELECTED_CONTACTS:
|
||||
return Visibility::SELECTED_CONTACTS_ONLY;
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_EVERYONE:
|
||||
return Visibility::EVERYONE;
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_SELF_SHARE:
|
||||
return Visibility::SELF_SHARE;
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_HIDDEN:
|
||||
return Visibility::HIDDEN;
|
||||
case DeviceVisibility::DEVICE_VISIBILITY_UNSPECIFIED:
|
||||
default:
|
||||
return Visibility::UNKNOWN_VISIBILITY;
|
||||
}
|
||||
}
|
||||
|
||||
location::nearby::proto::sharing::DataUsage GetLoggerDataUsage(
|
||||
DataUsage data_usage) {
|
||||
switch (data_usage) {
|
||||
case DataUsage::OFFLINE_DATA_USAGE:
|
||||
return location::nearby::proto::sharing::DataUsage::OFFLINE;
|
||||
case DataUsage::ONLINE_DATA_USAGE:
|
||||
return location::nearby::proto::sharing::DataUsage::ONLINE;
|
||||
case DataUsage::WIFI_ONLY_DATA_USAGE:
|
||||
return location::nearby::proto::sharing::DataUsage::WIFI_ONLY;
|
||||
default:
|
||||
return location::nearby::proto::sharing::DataUsage::UNKNOWN_DATA_USAGE;
|
||||
}
|
||||
}
|
||||
|
||||
void SetShareTargetInfo(SharingLog::ShareTargetInfo* share_target_info,
|
||||
ShareTargetType device_type,
|
||||
DeviceRelationship relationship,
|
||||
OSType os_type = OSType::UNKNOWN_OS_TYPE) {
|
||||
share_target_info->set_device_relationship(relationship);
|
||||
share_target_info->set_device_type(GetLoggerDeviceType(device_type));
|
||||
if (os_type == OSType::UNKNOWN_OS_TYPE &&
|
||||
device_type == ShareTargetType::kPhone) {
|
||||
// If the device type is phone, just set the OS type to android because
|
||||
// no other phone OS for now.
|
||||
share_target_info->set_os_type(OSType::ANDROID);
|
||||
} else {
|
||||
share_target_info->set_os_type(os_type);
|
||||
}
|
||||
}
|
||||
|
||||
void SetShareTargetInfo(SharingLog::ShareTargetInfo* share_target_info,
|
||||
const ShareTarget& share_target,
|
||||
OSType os_type = OSType::UNKNOWN_OS_TYPE) {
|
||||
share_target_info->set_device_relationship(
|
||||
GetLoggerDeviceRelationship(share_target));
|
||||
share_target_info->set_device_type(GetLoggerDeviceType(share_target.type));
|
||||
if (os_type == OSType::UNKNOWN_OS_TYPE &&
|
||||
share_target.type == ShareTargetType::kPhone) {
|
||||
// If the device type is phone, just set the OS type to android because
|
||||
// no other phone OS for now.
|
||||
share_target_info->set_os_type(OSType::ANDROID);
|
||||
} else {
|
||||
share_target_info->set_os_type(os_type);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAttachmentInfo(SharingLog::AttachmentsInfo* attachments_info,
|
||||
const AttachmentContainer& attachments) {
|
||||
for (const auto& attachment : attachments.GetTextAttachments()) {
|
||||
SharingLog::TextAttachment::Type type =
|
||||
SharingLog::TextAttachment::UNKNOWN_TEXT_TYPE;
|
||||
switch (attachment.GetShareType()) {
|
||||
case ShareType::kPhone:
|
||||
type = SharingLog::TextAttachment::PHONE_NUMBER;
|
||||
break;
|
||||
case ShareType::kUrl:
|
||||
type = SharingLog::TextAttachment::URL;
|
||||
break;
|
||||
case ShareType::kAddress:
|
||||
type = SharingLog::TextAttachment::ADDRESS;
|
||||
break;
|
||||
case ShareType::kText:
|
||||
// Apply UNKNOWN_TEXT_TYPE for it based on analytics design.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SharingLog::TextAttachment* text_attachment =
|
||||
attachments_info->mutable_text_attachment()->Add();
|
||||
text_attachment->set_type(type);
|
||||
text_attachment->set_size_bytes(attachment.size());
|
||||
text_attachment->set_source_type(attachment.source_type());
|
||||
text_attachment->set_batch_id(attachment.batch_id());
|
||||
}
|
||||
|
||||
for (const auto& attachment : attachments.GetFileAttachments()) {
|
||||
SharingLog::FileAttachment::Type type =
|
||||
SharingLog::FileAttachment::UNKNOWN_FILE_TYPE;
|
||||
switch (attachment.GetShareType()) {
|
||||
case ShareType::kImageFile:
|
||||
type = SharingLog::FileAttachment::IMAGE;
|
||||
break;
|
||||
case ShareType::kVideoFile:
|
||||
type = SharingLog::FileAttachment::VIDEO;
|
||||
break;
|
||||
case ShareType::kAudioFile:
|
||||
type = SharingLog::FileAttachment::AUDIO;
|
||||
break;
|
||||
case ShareType::kPdfFile:
|
||||
case ShareType::kTextFile:
|
||||
case ShareType::kGoogleDocsFile:
|
||||
case ShareType::kGoogleSheetsFile:
|
||||
case ShareType::kGoogleSlidesFile:
|
||||
type = SharingLog::FileAttachment::DOCUMENT;
|
||||
break;
|
||||
case ShareType::kUnknownFile:
|
||||
// The default type is set to type.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SharingLog::FileAttachment* file_attachment =
|
||||
attachments_info->mutable_file_attachment()->Add();
|
||||
file_attachment->set_type(type);
|
||||
file_attachment->set_size_bytes(attachment.size());
|
||||
file_attachment->set_offset_bytes(0);
|
||||
file_attachment->set_source_type(attachment.source_type());
|
||||
file_attachment->set_batch_id(attachment.batch_id());
|
||||
}
|
||||
|
||||
for (const auto& attachment : attachments.GetWifiCredentialsAttachments()) {
|
||||
SharingLog::WifiCredentialsAttachment* wifi_credentials_attachment =
|
||||
attachments_info->mutable_wifi_credentials_attachment()->Add();
|
||||
wifi_credentials_attachment->set_source_type(attachment.source_type());
|
||||
wifi_credentials_attachment->set_batch_id(attachment.batch_id());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AnalyticsRecorder::NewEstablishConnection(
|
||||
int64_t session_id, EstablishConnectionStatus connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::ESTABLISH_CONNECTION);
|
||||
|
||||
auto* establish_connection = sharing_log->mutable_establish_connection();
|
||||
|
||||
establish_connection->set_session_id(session_id);
|
||||
establish_connection->set_status(connection_status);
|
||||
SetShareTargetInfo(establish_connection->mutable_share_target_info(),
|
||||
share_target);
|
||||
establish_connection->set_transfer_position(transfer_position);
|
||||
establish_connection->set_concurrent_connections(concurrent_connections);
|
||||
establish_connection->set_duration_millis(duration_millis);
|
||||
if (referrer_package.has_value()) {
|
||||
establish_connection->set_referrer_name(*referrer_package);
|
||||
}
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAcceptAgreements() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::ACCEPT_AGREEMENTS);
|
||||
|
||||
sharing_log->mutable_accept_agreements();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDeclineAgreements() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::DECLINE_AGREEMENTS);
|
||||
|
||||
sharing_log->mutable_decline_agreements();
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAddContact() {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::SETTINGS_EVENT, EventType::ADD_CONTACT);
|
||||
|
||||
sharing_log->mutable_add_contact();
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewRemoveContact() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::REMOVE_CONTACT);
|
||||
|
||||
sharing_log->mutable_remove_contact();
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewTapFeedback() {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::SETTINGS_EVENT, EventType::TAP_FEEDBACK);
|
||||
|
||||
sharing_log->mutable_tap_feedback();
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewTapHelp() {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::SETTINGS_EVENT, EventType::TAP_HELP);
|
||||
|
||||
sharing_log->mutable_tap_help();
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewLaunchDeviceContactConsent(
|
||||
::location::nearby::proto::sharing::ConsentAcceptanceStatus status) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::LAUNCH_CONSENT);
|
||||
|
||||
auto* launch_consent = sharing_log->mutable_launch_consent();
|
||||
launch_consent->set_status(status);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAdvertiseDevicePresenceEnd(int64_t session_id) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::ADVERTISE_DEVICE_PRESENCE_END);
|
||||
|
||||
auto* advertise_device_presence_end =
|
||||
sharing_log->mutable_advertise_device_presence_end();
|
||||
advertise_device_presence_end->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, DeviceVisibility visibility,
|
||||
::location::nearby::proto::sharing::SessionStatus status,
|
||||
DataUsage data_usage, std::optional<std::string> referrer_package) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::RECEIVING_EVENT,
|
||||
EventType::ADVERTISE_DEVICE_PRESENCE_START);
|
||||
|
||||
auto* advertise_device_presence_start =
|
||||
sharing_log->mutable_advertise_device_presence_start();
|
||||
advertise_device_presence_start->set_session_id(session_id);
|
||||
advertise_device_presence_start->set_visibility(
|
||||
GetLoggerVisibility(visibility));
|
||||
advertise_device_presence_start->set_status(status);
|
||||
advertise_device_presence_start->set_data_usage(
|
||||
GetLoggerDataUsage(data_usage));
|
||||
if (referrer_package.has_value()) {
|
||||
advertise_device_presence_start->set_referrer_name(*referrer_package);
|
||||
}
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDescribeAttachments(
|
||||
const AttachmentContainer& attachments) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::DESCRIBE_ATTACHMENTS);
|
||||
|
||||
auto* describe_attachments = sharing_log->mutable_describe_attachments();
|
||||
SetAttachmentInfo(describe_attachments->mutable_attachments_info(),
|
||||
attachments);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::DISCOVER_SHARE_TARGET);
|
||||
|
||||
auto* discover_share_target = sharing_log->mutable_discover_share_target();
|
||||
discover_share_target->set_session_id(session_id);
|
||||
auto* duration = discover_share_target->mutable_duration_since_scanning();
|
||||
duration->set_seconds(latency_since_scanning_start_millis / 1000);
|
||||
duration->set_nanos((latency_since_scanning_start_millis % 1000) * 1000000);
|
||||
SetShareTargetInfo(discover_share_target->mutable_share_target_info(),
|
||||
share_target);
|
||||
discover_share_target->set_session_id(session_id);
|
||||
discover_share_target->set_flow_id(flow_id);
|
||||
|
||||
discover_share_target->set_latency_since_activity_start_millis(
|
||||
latency_since_send_surface_registered_millis > 0
|
||||
? latency_since_send_surface_registered_millis
|
||||
: -1);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewEnableNearbySharing(
|
||||
::location::nearby::proto::sharing::NearbySharingStatus status) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::ENABLE_NEARBY_SHARING);
|
||||
|
||||
auto* enable_nearby_sharing = sharing_log->mutable_enable_nearby_sharing();
|
||||
enable_nearby_sharing->set_status(status);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewOpenReceivedAttachments(
|
||||
const AttachmentContainer& attachments, int64_t session_id) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::OPEN_RECEIVED_ATTACHMENTS);
|
||||
|
||||
auto* open_received_attachments =
|
||||
sharing_log->mutable_open_received_attachments();
|
||||
SetAttachmentInfo(open_received_attachments->mutable_attachments_info(),
|
||||
attachments);
|
||||
open_received_attachments->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id, ProcessReceivedAttachmentsStatus status) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::RECEIVING_EVENT,
|
||||
EventType::PROCESS_RECEIVED_ATTACHMENTS_END);
|
||||
|
||||
auto* process_received_attachments_end =
|
||||
sharing_log->mutable_process_received_attachments_end();
|
||||
process_received_attachments_end->set_status(status);
|
||||
process_received_attachments_end->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::RECEIVE_ATTACHMENTS_END);
|
||||
|
||||
auto* receive_attachments_end =
|
||||
sharing_log->mutable_receive_attachments_end();
|
||||
receive_attachments_end->set_session_id(session_id);
|
||||
receive_attachments_end->set_received_bytes(received_bytes);
|
||||
receive_attachments_end->set_status(status);
|
||||
if (referrer_package.has_value()) {
|
||||
receive_attachments_end->set_referrer_name(*referrer_package);
|
||||
}
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::RECEIVE_ATTACHMENTS_START);
|
||||
|
||||
auto* receive_attachments_start =
|
||||
sharing_log->mutable_receive_attachments_start();
|
||||
SetAttachmentInfo(receive_attachments_start->mutable_attachments_info(),
|
||||
attachments);
|
||||
receive_attachments_start->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::RECEIVE_FAST_INITIALIZATION);
|
||||
|
||||
auto* receive_fast_initialization =
|
||||
sharing_log->mutable_receive_initialization();
|
||||
|
||||
receive_fast_initialization->set_time_elapse_since_screen_unlock_millis(
|
||||
timeElapseSinceScreenUnlockMillis);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAcceptFastInitialization() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::ACCEPT_FAST_INITIALIZATION);
|
||||
|
||||
sharing_log->mutable_accept_fast_initialization();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDismissFastInitialization() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::DISMISS_FAST_INITIALIZATION);
|
||||
|
||||
sharing_log->mutable_dismiss_fast_initialization();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
::location::nearby::proto::sharing::OSType share_target_os_type) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::RECEIVE_INTRODUCTION);
|
||||
|
||||
auto* receive_introduction = sharing_log->mutable_receive_introduction();
|
||||
receive_introduction->set_session_id(session_id);
|
||||
SetShareTargetInfo(receive_introduction->mutable_share_target_info(),
|
||||
share_target, share_target_os_type);
|
||||
if (referrer_package.has_value()) {
|
||||
receive_introduction->set_referrer_name(*referrer_package);
|
||||
}
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewRespondToIntroduction(
|
||||
::location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::RESPOND_TO_INTRODUCTION);
|
||||
|
||||
auto* respond_to_introduction = sharing_log->mutable_respond_introduction();
|
||||
respond_to_introduction->set_session_id(session_id);
|
||||
respond_to_introduction->set_action(action);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewTapPrivacyNotification() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::TAP_PRIVACY_NOTIFICATION);
|
||||
|
||||
sharing_log->mutable_tap_privacy_notification();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDismissPrivacyNotification() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::RECEIVING_EVENT, EventType::DISMISS_PRIVACY_NOTIFICATION);
|
||||
|
||||
sharing_log->mutable_dismiss_privacy_notification();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewScanForShareTargetsEnd(int64_t session_id) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SCAN_FOR_SHARE_TARGETS_END);
|
||||
|
||||
auto* scan_for_share_targets_end =
|
||||
sharing_log->mutable_scan_for_share_targets_end();
|
||||
scan_for_share_targets_end->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
::location::nearby::proto::sharing::SessionStatus status,
|
||||
AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SCAN_FOR_SHARE_TARGETS_START);
|
||||
|
||||
auto* scan_for_share_targets_start =
|
||||
sharing_log->mutable_scan_for_share_targets_start();
|
||||
scan_for_share_targets_start->set_session_id(session_id);
|
||||
scan_for_share_targets_start->set_status(status);
|
||||
scan_for_share_targets_start->set_scan_type(
|
||||
static_cast<::location::nearby::proto::sharing::ScanType>(
|
||||
analytics_information.send_surface_state));
|
||||
scan_for_share_targets_start->set_flow_id(flow_id);
|
||||
if (referrer_package.has_value()) {
|
||||
scan_for_share_targets_start->set_referrer_name(*referrer_package);
|
||||
}
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package,
|
||||
::location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
::location::nearby::proto::sharing::OSType share_target_os_type) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SEND_ATTACHMENTS_END);
|
||||
|
||||
auto* send_attachments_end = sharing_log->mutable_send_attachments_end();
|
||||
send_attachments_end->set_session_id(session_id);
|
||||
send_attachments_end->set_sent_bytes(sent_bytes);
|
||||
SetShareTargetInfo(send_attachments_end->mutable_share_target_info(),
|
||||
share_target, share_target_os_type);
|
||||
send_attachments_end->set_status(status);
|
||||
send_attachments_end->set_transfer_position(transfer_position);
|
||||
send_attachments_end->set_concurrent_connections(concurrent_connections);
|
||||
send_attachments_end->set_duration_millis(duration_millis);
|
||||
if (referrer_package.has_value()) {
|
||||
send_attachments_end->set_referrer_name(*referrer_package);
|
||||
}
|
||||
send_attachments_end->set_connection_layer_status(connection_layer_status);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments,
|
||||
int transfer_position, int concurrent_connections,
|
||||
bool advanced_protection_enabled, bool advanced_protection_mismatch) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SEND_ATTACHMENTS_START);
|
||||
|
||||
auto* send_attachments_start = sharing_log->mutable_send_attachments_start();
|
||||
send_attachments_start->set_session_id(session_id);
|
||||
SetAttachmentInfo(send_attachments_start->mutable_attachments_info(),
|
||||
attachments);
|
||||
send_attachments_start->set_transfer_position(transfer_position);
|
||||
send_attachments_start->set_concurrent_connections(concurrent_connections);
|
||||
send_attachments_start->set_advanced_protection_enabled(
|
||||
advanced_protection_enabled);
|
||||
send_attachments_start->set_advanced_protection_mismatch(
|
||||
advanced_protection_mismatch);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendFastInitialization() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SEND_FAST_INITIALIZATION);
|
||||
|
||||
sharing_log->mutable_send_initialization();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::SENDING_EVENT, EventType::SEND_START);
|
||||
|
||||
auto* send_start = sharing_log->mutable_send_start();
|
||||
send_start->set_session_id(session_id);
|
||||
send_start->set_transfer_position(transfer_position);
|
||||
send_start->set_concurrent_connections(concurrent_connections);
|
||||
SetShareTargetInfo(send_start->mutable_share_target_info(), share_target);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
DeviceRelationship relationship,
|
||||
::location::nearby::proto::sharing::OSType share_target_os_type) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SEND_INTRODUCTION);
|
||||
auto* send_introduction = sharing_log->mutable_send_introduction();
|
||||
SetShareTargetInfo(send_introduction->mutable_share_target_info(),
|
||||
target_type, relationship, share_target_os_type);
|
||||
send_introduction->set_session_id(session_id);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections,
|
||||
::location::nearby::proto::sharing::OSType share_target_os_type) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SENDING_EVENT, EventType::SEND_INTRODUCTION);
|
||||
|
||||
auto* send_introduction = sharing_log->mutable_send_introduction();
|
||||
SetShareTargetInfo(send_introduction->mutable_share_target_info(),
|
||||
share_target, share_target_os_type);
|
||||
send_introduction->set_session_id(session_id);
|
||||
send_introduction->set_transfer_position(transfer_position);
|
||||
send_introduction->set_concurrent_connections(concurrent_connections);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSetVisibility(DeviceVisibility src_visibility,
|
||||
DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::SET_VISIBILITY);
|
||||
|
||||
auto* set_visibility = sharing_log->mutable_set_visibility();
|
||||
set_visibility->set_visibility(GetLoggerVisibility(dst_visibility));
|
||||
set_visibility->set_source_visibility(GetLoggerVisibility(src_visibility));
|
||||
set_visibility->set_duration_millis(duration_millis);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewDeviceSettings(AnalyticsDeviceSettings settings) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::DEVICE_SETTINGS);
|
||||
|
||||
auto* device_settings = sharing_log->mutable_device_settings();
|
||||
device_settings->set_data_usage(GetLoggerDataUsage(settings.data_usage));
|
||||
device_settings->set_device_name_size(settings.device_name_size);
|
||||
device_settings->set_is_show_notification_enabled(
|
||||
settings.is_fast_init_notification_enabled);
|
||||
device_settings->set_visibility(GetLoggerVisibility(settings.visibility));
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSetDataUsage(DataUsage original_preference,
|
||||
DataUsage preference) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::SET_DATA_USAGE);
|
||||
|
||||
auto* set_data_usage = sharing_log->mutable_set_data_usage();
|
||||
set_data_usage->set_original_preference(
|
||||
GetLoggerDataUsage(original_preference));
|
||||
set_data_usage->set_preference(GetLoggerDataUsage(preference));
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewAddQuickSettingsTile() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::ADD_QUICK_SETTINGS_TILE);
|
||||
|
||||
sharing_log->mutable_add_quick_settings_tile();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewRemoveQuickSettingsTile() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::REMOVE_QUICK_SETTINGS_TILE);
|
||||
|
||||
sharing_log->mutable_remove_quick_settings_tile();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewTapQuickSettingsTile() {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::TAP_QUICK_SETTINGS_TILE);
|
||||
|
||||
sharing_log->mutable_tap_quick_settings_tile();
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewToggleShowNotification(
|
||||
ShowNotificationStatus prev_status, ShowNotificationStatus current_status) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::TOGGLE_SHOW_NOTIFICATION);
|
||||
|
||||
auto* toggle_show_notification =
|
||||
sharing_log->mutable_toggle_show_notification();
|
||||
toggle_show_notification->set_current_status(current_status);
|
||||
toggle_show_notification->set_previous_status(prev_status);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewSetDeviceName(int device_name_size) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::SET_DEVICE_NAME);
|
||||
|
||||
auto* set_device_name = sharing_log->mutable_set_device_name();
|
||||
set_device_name->set_device_name_size(device_name_size);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewRequestSettingPermissions(
|
||||
::location::nearby::proto::sharing::PermissionRequestType type,
|
||||
::location::nearby::proto::sharing::PermissionRequestResult result) {
|
||||
std::unique_ptr<SharingLog> sharing_log = CreateSharingLog(
|
||||
EventCategory::SETTINGS_EVENT, EventType::REQUEST_SETTING_PERMISSIONS);
|
||||
|
||||
auto* request_setting_permissions =
|
||||
sharing_log->mutable_request_setting_permissions();
|
||||
request_setting_permissions->set_permission_type(type);
|
||||
request_setting_permissions->set_permission_request_result(result);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewInstallAPKStatus(
|
||||
::location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
::location::nearby::proto::sharing::ApkSource source) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::RECEIVING_EVENT, EventType::INSTALL_APK);
|
||||
|
||||
auto* install_apk_status = sharing_log->mutable_install_apk_status();
|
||||
install_apk_status->add_status(status);
|
||||
install_apk_status->add_source(source);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewVerifyAPKStatus(
|
||||
::location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
::location::nearby::proto::sharing::ApkSource source) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::RECEIVING_EVENT, EventType::VERIFY_APK);
|
||||
|
||||
auto* verify_apk_status = sharing_log->mutable_verify_apk_status();
|
||||
verify_apk_status->add_status(status);
|
||||
verify_apk_status->add_source(source);
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::NewRpcCallStatus(
|
||||
absl::string_view rpc_name,
|
||||
SharingLog::RpcCallStatus::RpcDirection direction,
|
||||
int error_code, absl::Duration latency) {
|
||||
std::unique_ptr<SharingLog> sharing_log =
|
||||
CreateSharingLog(EventCategory::RPC_EVENT, EventType::RPC_CALL_STATUS);
|
||||
|
||||
auto* rpc_call_status = sharing_log->mutable_rpc_call_status();
|
||||
rpc_call_status->set_rpc_name(std::string(rpc_name));
|
||||
rpc_call_status->set_direction(direction);
|
||||
rpc_call_status->set_error_code(error_code);
|
||||
rpc_call_status->set_latency_millis(absl::ToInt64Milliseconds(latency));
|
||||
|
||||
LogEvent(*sharing_log);
|
||||
}
|
||||
|
||||
// Start private methods.
|
||||
|
||||
std::unique_ptr<SharingLog> AnalyticsRecorder::CreateSharingLog(
|
||||
EventCategory event_category, EventType event_type) {
|
||||
auto sharing_log = std::make_unique<SharingLog>();
|
||||
sharing_log->set_event_category(event_category);
|
||||
sharing_log->set_event_type(event_type);
|
||||
sharing_log->mutable_event_metadata()->set_vendor_id(vendor_id_);
|
||||
return sharing_log;
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogEvent(const SharingLog& message) {
|
||||
if (event_logger_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
event_logger_->Log(message);
|
||||
}
|
||||
|
||||
int64_t AnalyticsRecorder::GenerateNextId() {
|
||||
absl::BitGen bit_gen;
|
||||
return absl::Uniform(bit_gen, 0, INT64_MAX - 1) + 1;
|
||||
}
|
||||
|
||||
} // namespace analytics
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
@@ -16,205 +16,195 @@
|
||||
#define THIRD_PARTY_NEARBY_SHARING_ANALYTICS_ANALYTICS_RECORDER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
#include "sharing/share_target.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace analytics {
|
||||
namespace nearby::sharing::analytics {
|
||||
|
||||
class AnalyticsRecorder {
|
||||
public:
|
||||
explicit AnalyticsRecorder(int32_t vendor_id,
|
||||
nearby::analytics::EventLogger* event_logger)
|
||||
: vendor_id_(vendor_id), event_logger_(event_logger) {}
|
||||
~AnalyticsRecorder() = default;
|
||||
enum class RpcDirection {
|
||||
kUnknown = 0,
|
||||
kIncoming = 1,
|
||||
kOutgoing = 2,
|
||||
};
|
||||
|
||||
void NewEstablishConnection(
|
||||
AnalyticsRecorder() = default;
|
||||
virtual ~AnalyticsRecorder() = default;
|
||||
|
||||
virtual void NewEstablishConnection(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus
|
||||
connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package);
|
||||
std::optional<std::string> referrer_package) = 0;
|
||||
|
||||
void NewAcceptAgreements();
|
||||
virtual void NewAcceptAgreements() = 0;
|
||||
|
||||
void NewDeclineAgreements();
|
||||
virtual void NewDeclineAgreements() = 0;
|
||||
|
||||
void NewAddContact();
|
||||
virtual void NewAddContact() = 0;
|
||||
|
||||
void NewRemoveContact();
|
||||
virtual void NewRemoveContact() = 0;
|
||||
|
||||
void NewTapFeedback();
|
||||
virtual void NewTapFeedback() = 0;
|
||||
|
||||
void NewTapHelp();
|
||||
virtual void NewTapHelp() = 0;
|
||||
|
||||
void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status);
|
||||
virtual void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status) = 0;
|
||||
|
||||
void NewAdvertiseDevicePresenceEnd(int64_t session_id);
|
||||
virtual void NewAdvertiseDevicePresenceEnd(int64_t session_id) = 0;
|
||||
|
||||
void NewAdvertiseDevicePresenceStart(
|
||||
virtual void NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, nearby::sharing::proto::DeviceVisibility visibility,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
nearby::sharing::proto::DataUsage data_usage,
|
||||
std::optional<std::string> referrer_package);
|
||||
std::optional<std::string> referrer_package) = 0;
|
||||
|
||||
void NewDescribeAttachments(const AttachmentContainer& attachments);
|
||||
virtual void NewDescribeAttachments(
|
||||
const AttachmentContainer& attachments) = 0;
|
||||
|
||||
void NewDiscoverShareTarget(
|
||||
virtual void NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis);
|
||||
int64_t latency_since_send_surface_registered_millis) = 0;
|
||||
|
||||
void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status);
|
||||
virtual void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status) = 0;
|
||||
|
||||
void NewOpenReceivedAttachments(const AttachmentContainer& attachments,
|
||||
int64_t session_id);
|
||||
virtual void NewOpenReceivedAttachments(
|
||||
const AttachmentContainer& attachments, int64_t session_id) = 0;
|
||||
|
||||
void NewProcessReceivedAttachmentsEnd(
|
||||
virtual void NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus
|
||||
status);
|
||||
status) = 0;
|
||||
|
||||
void NewReceiveAttachmentsEnd(
|
||||
virtual void NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package);
|
||||
std::optional<std::string> referrer_package) = 0;
|
||||
|
||||
void NewReceiveAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments);
|
||||
virtual void NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) = 0;
|
||||
|
||||
void NewReceiveFastInitialization(int64_t timeElapseSinceScreenUnlockMillis);
|
||||
virtual void NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) = 0;
|
||||
|
||||
void NewAcceptFastInitialization();
|
||||
virtual void NewAcceptFastInitialization() = 0;
|
||||
|
||||
void NewDismissFastInitialization();
|
||||
virtual void NewDismissFastInitialization() = 0;
|
||||
|
||||
void NewReceiveIntroduction(
|
||||
virtual void NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type);
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
|
||||
|
||||
void NewRespondToIntroduction(
|
||||
virtual void NewRespondToIntroduction(
|
||||
location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id);
|
||||
int64_t session_id) = 0;
|
||||
|
||||
void NewTapPrivacyNotification();
|
||||
virtual void NewTapPrivacyNotification() = 0;
|
||||
|
||||
void NewDismissPrivacyNotification();
|
||||
virtual void NewDismissPrivacyNotification() = 0;
|
||||
|
||||
void NewScanForShareTargetsEnd(int64_t session_id);
|
||||
virtual void NewScanForShareTargetsEnd(int64_t session_id) = 0;
|
||||
|
||||
void NewScanForShareTargetsStart(
|
||||
virtual void NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package);
|
||||
std::optional<std::string> referrer_package) = 0;
|
||||
|
||||
void NewSendAttachmentsEnd(
|
||||
virtual void NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections,
|
||||
int64_t duration_millis, std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type);
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
|
||||
|
||||
void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch);
|
||||
virtual void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch) = 0;
|
||||
|
||||
void NewSendFastInitialization();
|
||||
virtual void NewSendFastInitialization() = 0;
|
||||
|
||||
void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target);
|
||||
virtual void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) = 0;
|
||||
|
||||
void NewSendIntroduction(
|
||||
virtual void NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
location::nearby::proto::sharing::DeviceRelationship relationship,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type);
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
|
||||
|
||||
void NewSendIntroduction(
|
||||
virtual void NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
int transfer_position, int concurrent_connections,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type);
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
|
||||
|
||||
void NewSetVisibility(nearby::sharing::proto::DeviceVisibility src_visibility,
|
||||
nearby::sharing::proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis);
|
||||
virtual void NewSetVisibility(
|
||||
nearby::sharing::proto::DeviceVisibility src_visibility,
|
||||
nearby::sharing::proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) = 0;
|
||||
|
||||
void NewDeviceSettings(AnalyticsDeviceSettings settings);
|
||||
virtual void NewDeviceSettings(AnalyticsDeviceSettings settings) = 0;
|
||||
|
||||
void NewSetDataUsage(nearby::sharing::proto::DataUsage original_preference,
|
||||
nearby::sharing::proto::DataUsage preference);
|
||||
virtual void NewSetDataUsage(
|
||||
nearby::sharing::proto::DataUsage original_preference,
|
||||
nearby::sharing::proto::DataUsage preference) = 0;
|
||||
|
||||
void NewAddQuickSettingsTile();
|
||||
virtual void NewAddQuickSettingsTile() = 0;
|
||||
|
||||
void NewRemoveQuickSettingsTile();
|
||||
virtual void NewRemoveQuickSettingsTile() = 0;
|
||||
|
||||
void NewTapQuickSettingsTile();
|
||||
virtual void NewTapQuickSettingsTile() = 0;
|
||||
|
||||
void NewToggleShowNotification(
|
||||
virtual void NewToggleShowNotification(
|
||||
location::nearby::proto::sharing::ShowNotificationStatus prev_status,
|
||||
location::nearby::proto::sharing::ShowNotificationStatus current_status);
|
||||
location::nearby::proto::sharing::ShowNotificationStatus
|
||||
current_status) = 0;
|
||||
|
||||
void NewSetDeviceName(int device_name_size);
|
||||
virtual void NewSetDeviceName(int device_name_size) = 0;
|
||||
|
||||
void NewRequestSettingPermissions(
|
||||
virtual void NewRequestSettingPermissions(
|
||||
location::nearby::proto::sharing::PermissionRequestType type,
|
||||
location::nearby::proto::sharing::PermissionRequestResult result);
|
||||
location::nearby::proto::sharing::PermissionRequestResult result) = 0;
|
||||
|
||||
void NewInstallAPKStatus(
|
||||
virtual void NewInstallAPKStatus(
|
||||
location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source);
|
||||
location::nearby::proto::sharing::ApkSource source) = 0;
|
||||
|
||||
void NewVerifyAPKStatus(
|
||||
virtual void NewVerifyAPKStatus(
|
||||
location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source);
|
||||
location::nearby::proto::sharing::ApkSource source) = 0;
|
||||
|
||||
void NewRpcCallStatus(
|
||||
absl::string_view rpc_name,
|
||||
nearby::sharing::analytics::proto::SharingLog::RpcCallStatus::RpcDirection
|
||||
direction,
|
||||
int error_code, absl::Duration latency);
|
||||
virtual void NewRpcCallStatus(absl::string_view rpc_name,
|
||||
RpcDirection direction, int error_code,
|
||||
absl::Duration latency) = 0;
|
||||
|
||||
// Generates a random number for session ID or flow ID.
|
||||
int64_t GenerateNextId();
|
||||
|
||||
private:
|
||||
std::unique_ptr<nearby::sharing::analytics::proto::SharingLog>
|
||||
CreateSharingLog(
|
||||
location::nearby::proto::sharing::EventCategory event_category,
|
||||
location::nearby::proto::sharing::EventType event_type);
|
||||
void LogEvent(const nearby::sharing::analytics::proto::SharingLog& message);
|
||||
|
||||
const int32_t vendor_id_;
|
||||
nearby::analytics::EventLogger* event_logger_ = nullptr;
|
||||
virtual int64_t GenerateNextId() = 0;
|
||||
};
|
||||
|
||||
} // namespace analytics
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
} // namespace nearby::sharing::analytics
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_ANALYTICS_ANALYTICS_RECORDER_H_
|
||||
|
||||
@@ -1,901 +0,0 @@
|
||||
// Copyright 2022-2023 Google LLC
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// https://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.
|
||||
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "google/protobuf/duration.pb.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/analytics/mock_event_logger.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
#include "sharing/proto/wire_format.pb.h"
|
||||
#include "sharing/share_target.h"
|
||||
#include "sharing/text_attachment.h"
|
||||
|
||||
namespace nearby::sharing::analytics {
|
||||
namespace {
|
||||
|
||||
using ::location::nearby::proto::sharing::EventCategory;
|
||||
using ::location::nearby::proto::sharing::EventType;
|
||||
using ::location::nearby::proto::sharing::OSType;
|
||||
using ::nearby::analytics::MockEventLogger;
|
||||
using ::nearby::sharing::analytics::proto::SharingLog;
|
||||
using ::nearby::sharing::proto::DataUsage;
|
||||
using ::nearby::sharing::proto::DeviceVisibility;
|
||||
using ::testing::An;
|
||||
|
||||
constexpr absl::string_view kFileName = "fileName";
|
||||
constexpr absl::string_view kTextBody = "textBody";
|
||||
constexpr absl::string_view kFileDocumentName = "abc.pdf";
|
||||
constexpr absl::string_view kFileMimeType = "application/pdf";
|
||||
constexpr absl::string_view kTextMimeType = "text/plain";
|
||||
constexpr absl::string_view kAppPackageName = "com.google.android.youtube";
|
||||
|
||||
class AnalyticsRecorderTest : public ::testing::Test {
|
||||
public:
|
||||
AnalyticsRecorderTest() = default;
|
||||
~AnalyticsRecorderTest() override = default;
|
||||
|
||||
MockEventLogger& event_logger() { return event_logger_; }
|
||||
|
||||
AnalyticsRecorder analytics_recoder() { return analytics_recorder_; }
|
||||
|
||||
private:
|
||||
MockEventLogger event_logger_;
|
||||
AnalyticsRecorder analytics_recorder_{/*vendor_id=*/0, &event_logger_};
|
||||
};
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewEstablishConnection) {
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kPhone;
|
||||
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ESTABLISH_CONNECTION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.establish_connection().status(),
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus::
|
||||
CONNECTION_STATUS_SUCCESS);
|
||||
EXPECT_EQ(log.establish_connection().session_id(), 1);
|
||||
EXPECT_EQ(log.establish_connection().transfer_position(), 1);
|
||||
EXPECT_EQ(log.establish_connection().concurrent_connections(), 1);
|
||||
EXPECT_EQ(log.establish_connection().duration_millis(), 100);
|
||||
EXPECT_EQ(log.establish_connection().share_target_info().os_type(),
|
||||
location::nearby::proto::sharing::OSType::ANDROID);
|
||||
EXPECT_EQ(log.establish_connection().referrer_name(), kAppPackageName);
|
||||
});
|
||||
|
||||
analytics_recoder().NewEstablishConnection(
|
||||
1,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus::
|
||||
CONNECTION_STATUS_SUCCESS,
|
||||
share_target, 1, 1, 100, std::string(kAppPackageName));
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAcceptAgreements) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ACCEPT_AGREEMENTS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAcceptAgreements();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDeclineAgreements) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DECLINE_AGREEMENTS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewDeclineAgreements();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAddContact) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ADD_CONTACT);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAddContact();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewRemoveContact) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::REMOVE_CONTACT);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewRemoveContact();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewTapFeedback) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::TAP_FEEDBACK);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewTapFeedback();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewTapHelp) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::TAP_HELP);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewTapHelp();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewLaunchDeviceContactConsent) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::LAUNCH_CONSENT);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.launch_consent().status(),
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus::
|
||||
CONSENT_ACCEPTED);
|
||||
});
|
||||
|
||||
analytics_recoder().NewLaunchDeviceContactConsent(
|
||||
::location::nearby::proto::sharing::ConsentAcceptanceStatus::
|
||||
CONSENT_ACCEPTED);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAdvertiseDevicePresenceEnd) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ADVERTISE_DEVICE_PRESENCE_END);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.advertise_device_presence_end().session_id(), 100);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAdvertiseDevicePresenceEnd(100);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAdvertiseDevicePresenceStart) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ADVERTISE_DEVICE_PRESENCE_START);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.advertise_device_presence_start().visibility(),
|
||||
location::nearby::proto::sharing::Visibility::CONTACTS_ONLY);
|
||||
EXPECT_EQ(log.advertise_device_presence_start().status(),
|
||||
location::nearby::proto::sharing::SessionStatus::
|
||||
SUCCEEDED_SESSION_STATUS);
|
||||
EXPECT_EQ(log.advertise_device_presence_start().data_usage(),
|
||||
location::nearby::proto::sharing::DataUsage::OFFLINE);
|
||||
EXPECT_EQ(log.advertise_device_presence_start().referrer_name(),
|
||||
kAppPackageName);
|
||||
EXPECT_EQ(log.advertise_device_presence_start().session_id(), 100);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAdvertiseDevicePresenceStart(
|
||||
100, DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS,
|
||||
location::nearby::proto::sharing::SessionStatus::SUCCEEDED_SESSION_STATUS,
|
||||
DataUsage::OFFLINE_DATA_USAGE, std::string(kAppPackageName));
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDescribeAttachments) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DESCRIBE_ATTACHMENTS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment_size(),
|
||||
5);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(0)
|
||||
.size_bytes(),
|
||||
kTextBody.size());
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(0)
|
||||
.type(),
|
||||
SharingLog::TextAttachment::UNKNOWN_TEXT_TYPE);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(1)
|
||||
.type(),
|
||||
SharingLog::TextAttachment::PHONE_NUMBER);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(2)
|
||||
.type(),
|
||||
SharingLog::TextAttachment::URL);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(3)
|
||||
.type(),
|
||||
SharingLog::TextAttachment::ADDRESS);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment(4)
|
||||
.type(),
|
||||
SharingLog::TextAttachment::UNKNOWN_TEXT_TYPE);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment_size(),
|
||||
4);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment(0)
|
||||
.size_bytes(),
|
||||
2);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment(0)
|
||||
.type(),
|
||||
SharingLog::FileAttachment::IMAGE);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment(1)
|
||||
.type(),
|
||||
SharingLog::FileAttachment::DOCUMENT);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment(2)
|
||||
.type(),
|
||||
SharingLog::FileAttachment::AUDIO);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment(3)
|
||||
.type(),
|
||||
SharingLog::FileAttachment::DOCUMENT);
|
||||
});
|
||||
|
||||
std::unique_ptr<AttachmentContainer> attachments =
|
||||
AttachmentContainer::Builder(
|
||||
{TextAttachment(5, service::proto::TextMetadata::TEXT,
|
||||
std::string(kTextBody), kTextBody.size()),
|
||||
TextAttachment(6, service::proto::TextMetadata::PHONE_NUMBER,
|
||||
std::string(kTextBody), kTextBody.size()),
|
||||
TextAttachment(7, service::proto::TextMetadata::URL,
|
||||
std::string(kTextBody), kTextBody.size()),
|
||||
TextAttachment(8, service::proto::TextMetadata::ADDRESS,
|
||||
std::string(kTextBody), kTextBody.size()),
|
||||
TextAttachment(9, service::proto::TextMetadata::UNKNOWN,
|
||||
std::string(kTextBody), kTextBody.size())},
|
||||
{FileAttachment(1, 2, std::string(kFileName), "",
|
||||
service::proto::FileMetadata::IMAGE),
|
||||
FileAttachment(2, 3, std::string(kFileDocumentName),
|
||||
std::string(kFileMimeType),
|
||||
service::proto::FileMetadata::DOCUMENT),
|
||||
FileAttachment(3, 4, std::string(kFileName), "",
|
||||
service::proto::FileMetadata::AUDIO),
|
||||
FileAttachment(4, 5, std::string(kFileName),
|
||||
std::string(kTextMimeType),
|
||||
service::proto::FileMetadata::DOCUMENT)},
|
||||
{})
|
||||
.Build();
|
||||
|
||||
analytics_recoder().NewDescribeAttachments(*attachments);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, EmptyDescribeAttachments) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DESCRIBE_ATTACHMENTS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment_size(),
|
||||
0);
|
||||
EXPECT_EQ(log.describe_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment_size(),
|
||||
0);
|
||||
});
|
||||
|
||||
analytics_recoder().NewDescribeAttachments(AttachmentContainer());
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDiscoverShareTarget) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DISCOVER_SHARE_TARGET);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.discover_share_target().duration_since_scanning().nanos(),
|
||||
(2100 % 1000) * 1000000);
|
||||
EXPECT_EQ(
|
||||
log.discover_share_target().duration_since_scanning().seconds(),
|
||||
2100 / 1000);
|
||||
EXPECT_EQ(
|
||||
log.discover_share_target()
|
||||
.share_target_info()
|
||||
.device_relationship(),
|
||||
::location::nearby::proto::sharing::DeviceRelationship::IS_CONTACT);
|
||||
EXPECT_EQ(log.discover_share_target().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::LAPTOP);
|
||||
EXPECT_EQ(log.discover_share_target().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::UNKNOWN_OS_TYPE);
|
||||
EXPECT_EQ(log.discover_share_target().session_id(), 1);
|
||||
EXPECT_EQ(log.discover_share_target().flow_id(), 100);
|
||||
EXPECT_FALSE(log.discover_share_target().has_referrer_name());
|
||||
EXPECT_EQ(
|
||||
log.discover_share_target().latency_since_activity_start_millis(),
|
||||
2);
|
||||
});
|
||||
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kLaptop;
|
||||
share_target.is_incoming = true;
|
||||
share_target.is_known = true;
|
||||
|
||||
analytics_recoder().NewDiscoverShareTarget(share_target, 1, 2100, 100,
|
||||
std::nullopt, 2);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewEnableNearbySharing) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ENABLE_NEARBY_SHARING);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.enable_nearby_sharing().status(),
|
||||
location::nearby::proto::sharing::NearbySharingStatus::ON);
|
||||
});
|
||||
|
||||
analytics_recoder().NewEnableNearbySharing(
|
||||
::location::nearby::proto::sharing::NearbySharingStatus::ON);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewOpenReceivedAttachments) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::OPEN_RECEIVED_ATTACHMENTS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.open_received_attachments()
|
||||
.attachments_info()
|
||||
.text_attachment_size(),
|
||||
0);
|
||||
EXPECT_EQ(log.open_received_attachments()
|
||||
.attachments_info()
|
||||
.file_attachment_size(),
|
||||
0);
|
||||
EXPECT_EQ(log.open_received_attachments().session_id(), 1);
|
||||
});
|
||||
|
||||
analytics_recoder().NewOpenReceivedAttachments(AttachmentContainer(), 1);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewProcessReceivedAttachmentsEnd) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(),
|
||||
EventType::PROCESS_RECEIVED_ATTACHMENTS_END);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.process_received_attachments_end().session_id(), 1);
|
||||
EXPECT_EQ(
|
||||
log.process_received_attachments_end().status(),
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus::
|
||||
PROCESSING_STATUS_COMPLETE_PROCESSING_ATTACHMENTS);
|
||||
});
|
||||
|
||||
analytics_recoder().NewProcessReceivedAttachmentsEnd(
|
||||
1, location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus::
|
||||
PROCESSING_STATUS_COMPLETE_PROCESSING_ATTACHMENTS);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewReceiveAttachmentsEnd) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RECEIVE_ATTACHMENTS_END);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.receive_attachments_end().session_id(), 1);
|
||||
EXPECT_EQ(log.receive_attachments_end().received_bytes(), 2);
|
||||
EXPECT_EQ(
|
||||
log.receive_attachments_end().status(),
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus::
|
||||
COMPLETE_ATTACHMENT_TRANSMISSION_STATUS);
|
||||
EXPECT_EQ(log.receive_attachments_end().referrer_name(),
|
||||
kAppPackageName);
|
||||
});
|
||||
|
||||
analytics_recoder().NewReceiveAttachmentsEnd(
|
||||
1, 2,
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus::
|
||||
COMPLETE_ATTACHMENT_TRANSMISSION_STATUS,
|
||||
std::string(kAppPackageName));
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewReceiveAttachmentsStart) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RECEIVE_ATTACHMENTS_START);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.receive_attachments_start().session_id(), 1);
|
||||
EXPECT_EQ(log.receive_attachments_start()
|
||||
.attachments_info()
|
||||
.file_attachment_size(),
|
||||
0);
|
||||
});
|
||||
|
||||
analytics_recoder().NewReceiveAttachmentsStart(1, AttachmentContainer());
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewReceiveFastInitialization) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RECEIVE_FAST_INITIALIZATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.receive_initialization()
|
||||
.time_elapse_since_screen_unlock_millis(),
|
||||
1);
|
||||
});
|
||||
|
||||
analytics_recoder().NewReceiveFastInitialization(1);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAcceptFastInitialization) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ACCEPT_FAST_INITIALIZATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAcceptFastInitialization();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDismissFastInitialization) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DISMISS_FAST_INITIALIZATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewDismissFastInitialization();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewReceiveIntroduction) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RECEIVE_INTRODUCTION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.receive_introduction().session_id(), 1);
|
||||
EXPECT_EQ(log.receive_introduction().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::WINDOWS);
|
||||
EXPECT_EQ(log.receive_introduction().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::PHONE);
|
||||
EXPECT_EQ(log.receive_introduction().referrer_name(), kAppPackageName);
|
||||
});
|
||||
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kPhone;
|
||||
analytics_recoder().NewReceiveIntroduction(
|
||||
1, share_target, std::string(kAppPackageName), OSType::WINDOWS);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewRespondToIntroduction) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RESPOND_TO_INTRODUCTION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.respond_introduction().session_id(), 1);
|
||||
EXPECT_EQ(log.respond_introduction().action(),
|
||||
::location::nearby::proto::sharing::ResponseToIntroduction::
|
||||
ACCEPT_INTRODUCTION);
|
||||
});
|
||||
|
||||
analytics_recoder().NewRespondToIntroduction(
|
||||
::location::nearby::proto::sharing::ResponseToIntroduction::
|
||||
ACCEPT_INTRODUCTION,
|
||||
1);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewTapPrivacyNotification) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::TAP_PRIVACY_NOTIFICATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewTapPrivacyNotification();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDismissPrivacyNotification) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DISMISS_PRIVACY_NOTIFICATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewDismissPrivacyNotification();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewScanForShareTargetsEnd) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SCAN_FOR_SHARE_TARGETS_END);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.scan_for_share_targets_end().session_id(), 100);
|
||||
});
|
||||
|
||||
analytics_recoder().NewScanForShareTargetsEnd(100);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewScanForShareTargetsStart) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SCAN_FOR_SHARE_TARGETS_START);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.scan_for_share_targets_start().session_id(), 3);
|
||||
EXPECT_EQ(log.scan_for_share_targets_start().status(),
|
||||
::location::nearby::proto::sharing::SessionStatus::
|
||||
FAILED_SESSION_STATUS);
|
||||
EXPECT_EQ(log.scan_for_share_targets_start().flow_id(), 100);
|
||||
EXPECT_EQ(
|
||||
log.scan_for_share_targets_start().scan_type(),
|
||||
::location::nearby::proto::sharing::ScanType::FOREGROUND_SCAN);
|
||||
EXPECT_FALSE(log.scan_for_share_targets_start().has_referrer_name());
|
||||
});
|
||||
|
||||
analytics_recoder().NewScanForShareTargetsStart(
|
||||
3,
|
||||
::location::nearby::proto::sharing::SessionStatus::FAILED_SESSION_STATUS,
|
||||
AnalyticsInformation{SendSurfaceState::kForeground}, 100, std::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendAttachmentsEnd) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_ATTACHMENTS_END);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.send_attachments_end().session_id(), 1);
|
||||
EXPECT_EQ(log.send_attachments_end().sent_bytes(), 2);
|
||||
EXPECT_EQ(log.send_attachments_end().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::ANDROID);
|
||||
EXPECT_EQ(log.send_attachments_end().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::PHONE);
|
||||
EXPECT_EQ(log.send_attachments_end().transfer_position(), 1);
|
||||
EXPECT_EQ(log.send_attachments_end().concurrent_connections(), 2);
|
||||
EXPECT_EQ(log.send_attachments_end().duration_millis(), 100);
|
||||
EXPECT_EQ(
|
||||
log.send_attachments_end().status(),
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus::
|
||||
COMPLETE_ATTACHMENT_TRANSMISSION_STATUS);
|
||||
EXPECT_EQ(log.send_attachments_end().referrer_name(), kAppPackageName);
|
||||
});
|
||||
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kPhone;
|
||||
analytics_recoder().NewSendAttachmentsEnd(
|
||||
1, 2, share_target,
|
||||
::location::nearby::proto::sharing::AttachmentTransmissionStatus::
|
||||
COMPLETE_ATTACHMENT_TRANSMISSION_STATUS,
|
||||
1, 2, 100, std::string(kAppPackageName),
|
||||
::location::nearby::proto::sharing::ConnectionLayerStatus::
|
||||
CONNECTION_LAYER_STATUS_UNKNOWN,
|
||||
OSType::UNKNOWN_OS_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendAttachmentsStart) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_ATTACHMENTS_START);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.send_attachments_start().session_id(), 1);
|
||||
EXPECT_EQ(log.send_attachments_start()
|
||||
.attachments_info()
|
||||
.file_attachment_size(),
|
||||
0);
|
||||
EXPECT_EQ(log.send_attachments_start().transfer_position(), 100);
|
||||
EXPECT_EQ(log.send_attachments_start().concurrent_connections(), 200);
|
||||
EXPECT_EQ(log.send_attachments_start().advanced_protection_enabled(),
|
||||
true);
|
||||
EXPECT_EQ(log.send_attachments_start().advanced_protection_mismatch(),
|
||||
true);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSendAttachmentsStart(1, AttachmentContainer(), 100,
|
||||
200, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendFastInitialization) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_FAST_INITIALIZATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSendFastInitialization();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendStart) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_START);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.send_start().session_id(), 123);
|
||||
EXPECT_EQ(log.send_start().transfer_position(), 1);
|
||||
EXPECT_EQ(log.send_start().concurrent_connections(), 2);
|
||||
EXPECT_EQ(log.send_start().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::LAPTOP);
|
||||
EXPECT_EQ(log.send_start().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::UNKNOWN_OS_TYPE);
|
||||
});
|
||||
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kLaptop;
|
||||
share_target.is_known = true;
|
||||
share_target.is_incoming = true;
|
||||
analytics_recoder().NewSendStart(123, 1, 2, share_target);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendIntroductionWithRelationship) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_INTRODUCTION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.send_introduction().session_id(), 5);
|
||||
EXPECT_EQ(log.send_introduction().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::LAPTOP);
|
||||
EXPECT_EQ(log.send_introduction().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::MACOS);
|
||||
EXPECT_EQ(
|
||||
log.send_introduction().share_target_info().device_relationship(),
|
||||
::location::nearby::proto::sharing::DeviceRelationship::IS_CONTACT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSendIntroduction(
|
||||
ShareTargetType::kLaptop, 5,
|
||||
::location::nearby::proto::sharing::DeviceRelationship::IS_CONTACT,
|
||||
OSType::MACOS);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSendIntroduction) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SEND_INTRODUCTION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SENDING_EVENT);
|
||||
EXPECT_EQ(log.send_introduction().session_id(), 1);
|
||||
EXPECT_EQ(log.send_introduction().transfer_position(), 2);
|
||||
EXPECT_EQ(log.send_introduction().concurrent_connections(), 3);
|
||||
EXPECT_EQ(log.send_introduction().share_target_info().device_type(),
|
||||
::location::nearby::proto::sharing::DeviceType::LAPTOP);
|
||||
EXPECT_EQ(log.send_introduction().share_target_info().os_type(),
|
||||
::location::nearby::proto::sharing::OSType::UNKNOWN_OS_TYPE);
|
||||
});
|
||||
|
||||
ShareTarget share_target;
|
||||
share_target.device_name = "share_target";
|
||||
share_target.type = ShareTargetType::kLaptop;
|
||||
analytics_recoder().NewSendIntroduction(1, share_target, 2, 3,
|
||||
OSType::UNKNOWN_OS_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSetVisibility) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SET_VISIBILITY);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.set_visibility().duration_millis(), 100);
|
||||
EXPECT_EQ(log.set_visibility().source_visibility(),
|
||||
::location::nearby::proto::sharing::Visibility::EVERYONE);
|
||||
EXPECT_EQ(
|
||||
log.set_visibility().visibility(),
|
||||
::location::nearby::proto::sharing::Visibility::CONTACTS_ONLY);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSetVisibility(
|
||||
DeviceVisibility::DEVICE_VISIBILITY_EVERYONE,
|
||||
DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS, 100);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewDeviceSettings) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::DEVICE_SETTINGS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.device_settings().device_name_size(), 10);
|
||||
EXPECT_EQ(log.device_settings().visibility(),
|
||||
::location::nearby::proto::sharing::Visibility::EVERYONE);
|
||||
EXPECT_EQ(log.device_settings().data_usage(),
|
||||
::location::nearby::proto::sharing::DataUsage::WIFI_ONLY);
|
||||
EXPECT_EQ(log.device_settings().is_show_notification_enabled(), true);
|
||||
});
|
||||
|
||||
AnalyticsDeviceSettings device_settings;
|
||||
device_settings.device_name_size = 10;
|
||||
device_settings.data_usage = DataUsage::WIFI_ONLY_DATA_USAGE;
|
||||
device_settings.is_fast_init_notification_enabled = true;
|
||||
device_settings.visibility = DeviceVisibility::DEVICE_VISIBILITY_EVERYONE;
|
||||
analytics_recoder().NewDeviceSettings(device_settings);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSetDataUsage) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SET_DATA_USAGE);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.set_data_usage().preference(),
|
||||
::location::nearby::proto::sharing::DataUsage::OFFLINE);
|
||||
EXPECT_EQ(log.set_data_usage().original_preference(),
|
||||
::location::nearby::proto::sharing::DataUsage::WIFI_ONLY);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSetDataUsage(DataUsage::WIFI_ONLY_DATA_USAGE,
|
||||
DataUsage::OFFLINE_DATA_USAGE);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewAddQuickSettingsTile) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::ADD_QUICK_SETTINGS_TILE);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewAddQuickSettingsTile();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewRemoveQuickSettingsTile) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::REMOVE_QUICK_SETTINGS_TILE);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewRemoveQuickSettingsTile();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewTapQuickSettingsTile) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::TAP_QUICK_SETTINGS_TILE);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
});
|
||||
|
||||
analytics_recoder().NewTapQuickSettingsTile();
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewToggleShowNotification) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::TOGGLE_SHOW_NOTIFICATION);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(
|
||||
log.toggle_show_notification().previous_status(),
|
||||
::location::nearby::proto::sharing::ShowNotificationStatus::SHOW);
|
||||
EXPECT_EQ(log.toggle_show_notification().current_status(),
|
||||
::location::nearby::proto::sharing::ShowNotificationStatus::
|
||||
NOT_SHOW);
|
||||
});
|
||||
|
||||
analytics_recoder().NewToggleShowNotification(
|
||||
::location::nearby::proto::sharing::ShowNotificationStatus::SHOW,
|
||||
::location::nearby::proto::sharing::ShowNotificationStatus::NOT_SHOW);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewSetDeviceName) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::SET_DEVICE_NAME);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.set_device_name().device_name_size(), 16);
|
||||
});
|
||||
|
||||
analytics_recoder().NewSetDeviceName(16);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewRequestSettingPermissions) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::REQUEST_SETTING_PERMISSIONS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(log.request_setting_permissions().permission_type(),
|
||||
::location::nearby::proto::sharing::PermissionRequestType::
|
||||
PERMISSION_BLUETOOTH);
|
||||
EXPECT_EQ(
|
||||
log.request_setting_permissions().permission_request_result(),
|
||||
::location::nearby::proto::sharing::PermissionRequestResult::
|
||||
PERMISSION_GRANTED);
|
||||
});
|
||||
|
||||
analytics_recoder().NewRequestSettingPermissions(
|
||||
::location::nearby::proto::sharing::PermissionRequestType::
|
||||
PERMISSION_BLUETOOTH,
|
||||
::location::nearby::proto::sharing::PermissionRequestResult::
|
||||
PERMISSION_GRANTED);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewInstallAPKStatus) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::INSTALL_APK);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(log.install_apk_status().status(0),
|
||||
::location::nearby::proto::sharing::InstallAPKStatus::
|
||||
SUCCESS_INSTALLATION);
|
||||
EXPECT_EQ(
|
||||
log.install_apk_status().source(0),
|
||||
::location::nearby::proto::sharing::ApkSource::APK_FROM_SD_CARD);
|
||||
});
|
||||
|
||||
analytics_recoder().NewInstallAPKStatus(
|
||||
::location::nearby::proto::sharing::InstallAPKStatus::
|
||||
SUCCESS_INSTALLATION,
|
||||
::location::nearby::proto::sharing::ApkSource::APK_FROM_SD_CARD);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewVerifyAPKStatus) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::VERIFY_APK);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RECEIVING_EVENT);
|
||||
EXPECT_EQ(
|
||||
log.verify_apk_status().status(0),
|
||||
::location::nearby::proto::sharing::VerifyAPKStatus::INSTALLABLE);
|
||||
EXPECT_EQ(
|
||||
log.verify_apk_status().source(0),
|
||||
::location::nearby::proto::sharing::ApkSource::APK_FROM_SD_CARD);
|
||||
});
|
||||
|
||||
analytics_recoder().NewVerifyAPKStatus(
|
||||
::location::nearby::proto::sharing::VerifyAPKStatus::INSTALLABLE,
|
||||
::location::nearby::proto::sharing::ApkSource::APK_FROM_SD_CARD);
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, NewRpcCallStatus) {
|
||||
EXPECT_CALL(event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([](const SharingLog& log) {
|
||||
EXPECT_EQ(log.event_type(), EventType::RPC_CALL_STATUS);
|
||||
EXPECT_EQ(log.event_category(), EventCategory::RPC_EVENT);
|
||||
EXPECT_EQ(log.rpc_call_status().rpc_name(), "service.rpc_name");
|
||||
EXPECT_EQ(log.rpc_call_status().direction(),
|
||||
SharingLog::RpcCallStatus::OUTGOING);
|
||||
EXPECT_EQ(log.rpc_call_status().error_code(), 123);
|
||||
EXPECT_EQ(log.rpc_call_status().latency_millis(), 456);
|
||||
});
|
||||
|
||||
analytics_recoder().NewRpcCallStatus(
|
||||
"service.rpc_name", SharingLog::RpcCallStatus::OUTGOING, 123,
|
||||
absl::Milliseconds(456));
|
||||
}
|
||||
|
||||
TEST_F(AnalyticsRecorderTest, GenerateID) {
|
||||
int64_t id = analytics_recoder().GenerateNextId();
|
||||
EXPECT_GT(id, 0);
|
||||
int64_t id2 = analytics_recoder().GenerateNextId();
|
||||
EXPECT_NE(id2, id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace nearby::sharing::analytics
|
||||
@@ -20,31 +20,32 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
|
||||
#include "location/nearby/sharing/lib/sync/sync_manager.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/base/observer_list.h"
|
||||
#include "internal/platform/clock.h"
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/certificates/nearby_share_certificate_manager.h"
|
||||
#include "sharing/fake_nearby_connections_manager.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
#include "sharing/internal/test/fake_preference_manager.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_settings.h"
|
||||
#include "sharing/outgoing_targets_manager.h"
|
||||
#include "sharing/share_target.h"
|
||||
#include "sharing/share_target_discovered_callback.h"
|
||||
#include "sharing/transfer_metadata.h"
|
||||
#include "sharing/transfer_update_callback.h"
|
||||
#include "sharing/wrapped_share_target_discovered_callback.h"
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "location/nearby/sharing/lib/sync/sync_manager.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/fake_nearby_connections_manager.h"
|
||||
#include "sharing/internal/test/fake_preference_manager.h"
|
||||
#include "sharing/outgoing_targets_manager.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
@@ -157,7 +158,7 @@ class FakeNearbySharingService : public NearbySharingService {
|
||||
return connections_manager_;
|
||||
}
|
||||
FakeTaskRunner& fake_task_runner() { return service_thread_; }
|
||||
analytics::AnalyticsRecorder& analytics_recorder() {
|
||||
analytics::AnalyticsRecorderImpl& analytics_recorder() {
|
||||
return analytics_recorder_;
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ class FakeNearbySharingService : public NearbySharingService {
|
||||
FakeClock clock_;
|
||||
FakeTaskRunner service_thread_;
|
||||
FakeNearbyConnectionsManager connections_manager_;
|
||||
analytics::AnalyticsRecorder analytics_recorder_;
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder_;
|
||||
FakePreferenceManager preference_manager_;
|
||||
FakeNearbyIdentityClient identity_rpc_client_;
|
||||
std::unique_ptr<SyncManager> sync_manager_;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -36,7 +37,6 @@
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_compare.h" // IWYU pragma: keep
|
||||
#include "sharing/fake_nearby_connections_manager.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
@@ -186,8 +186,8 @@ class IncomingShareSessionTest : public ::testing::Test {
|
||||
FakeClock clock_;
|
||||
FakeTaskRunner task_runner_{&clock_, 1};
|
||||
nearby::analytics::MockEventLogger mock_event_logger_;
|
||||
analytics::AnalyticsRecorder analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
ShareTarget share_target_;
|
||||
MockFunction<void(const IncomingShareSession&, const TransferMetadata&)>
|
||||
transfer_metadata_callback_;
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/signin_attempt.h"
|
||||
#include "location/nearby/sharing/lib/account/fake_account_manager.h"
|
||||
#include "location/nearby/sharing/lib/account/mock_account_observer.h"
|
||||
#include "location/nearby/sharing/lib/account/signin_attempt.h"
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "location/nearby/sharing/lib/rpc/fake_nearby_share_client.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
@@ -55,7 +56,6 @@
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/advertisement_capabilities.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/certificates/fake_nearby_share_certificate_manager.h"
|
||||
#include "sharing/certificates/nearby_share_certificate_manager_impl.h"
|
||||
@@ -452,7 +452,7 @@ class NearbySharingServiceImplTest : public testing::Test {
|
||||
SetBluetoothIsPowered(true);
|
||||
SetScreenLocked(false);
|
||||
SetLanConnected(true);
|
||||
analytics_recorder_ = std::make_unique<analytics::AnalyticsRecorder>(
|
||||
analytics_recorder_ = std::make_unique<analytics::AnalyticsRecorderImpl>(
|
||||
/*vendor_id=*/0, /*event_logger=*/nullptr);
|
||||
|
||||
service_ = CreateService(std::move(fake_task_runner));
|
||||
@@ -1269,7 +1269,7 @@ class NearbySharingServiceImplTest : public testing::Test {
|
||||
nearby_fast_initiation_factory_;
|
||||
std::unique_ptr<NearbyConnectionImpl> connection_;
|
||||
StrictMock<MockAppInfo>* mock_app_info_ = nullptr;
|
||||
std::unique_ptr<analytics::AnalyticsRecorder> analytics_recorder_;
|
||||
std::unique_ptr<analytics::AnalyticsRecorderImpl> analytics_recorder_;
|
||||
std::unique_ptr<NearbySharingServiceImpl> service_;
|
||||
int expect_transfer_updates_count_ = 0;
|
||||
std::function<void()> expect_transfer_updates_callback_;
|
||||
@@ -4852,8 +4852,8 @@ TEST_F(NearbySharingServiceImplTest, RemoveIncomingPayloads) {
|
||||
unknown_file_paths_to_delete,
|
||||
UnorderedElementsAre(FilePath("test1.txt"), FilePath("test2.txt")));
|
||||
nearby::analytics::MockEventLogger mock_event_logger;
|
||||
analytics::AnalyticsRecorder analytics_recorder{/*vendor_id=*/0,
|
||||
&mock_event_logger};
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder{/*vendor_id=*/0,
|
||||
&mock_event_logger};
|
||||
ShareTarget share_target;
|
||||
share_target.is_incoming = true;
|
||||
IncomingShareSession session(
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "net/proto2/contrib/parse_proto/parse_text_proto.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
@@ -36,7 +37,6 @@
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/certificates/test_util.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
@@ -162,8 +162,8 @@ class OutgoingShareSessionTest : public ::testing::Test {
|
||||
FakeClock fake_clock_;
|
||||
FakeTaskRunner fake_task_runner_{&fake_clock_, 1};
|
||||
nearby::analytics::MockEventLogger mock_event_logger_;
|
||||
analytics::AnalyticsRecorder analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
ShareTarget share_target_;
|
||||
MockFunction<void(OutgoingShareSession&, const TransferMetadata&)>
|
||||
transfer_metadata_callback_;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -25,7 +26,6 @@
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/certificates/nearby_share_decrypted_public_certificate.h"
|
||||
#include "sharing/certificates/test_util.h"
|
||||
@@ -61,7 +61,7 @@ class OutgoingTargetsManagerTest : public ::testing::Test {
|
||||
FakeClock clock_;
|
||||
FakeTaskRunner service_thread_;
|
||||
FakeNearbyConnectionsManager connections_manager_;
|
||||
analytics::AnalyticsRecorder analytics_recorder_;
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder_;
|
||||
testing::MockFunction<void(const ShareTarget&)>
|
||||
share_target_discovered_callback_;
|
||||
testing::MockFunction<void(const ShareTarget&)>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "location/nearby/sharing/lib/analytics/analytics_recorder_impl.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -32,7 +33,6 @@
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/certificates/fake_nearby_share_certificate_manager.h"
|
||||
#include "sharing/fake_nearby_connections_manager.h"
|
||||
#include "sharing/nearby_connection.h"
|
||||
@@ -97,8 +97,8 @@ class TestShareSession : public ShareSession {
|
||||
FakeNearbyConnectionsManager connections_manager_;
|
||||
FakeDeviceInfo device_info_;
|
||||
nearby::analytics::MockEventLogger mock_event_logger_;
|
||||
analytics::AnalyticsRecorder analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
analytics::AnalyticsRecorderImpl analytics_recorder_{/*vendor_id=*/0,
|
||||
&mock_event_logger_};
|
||||
const bool is_incoming_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user