mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Remove experiments_log.proto.
PiperOrigin-RevId: 626095230
This commit is contained in:
committed by
Copybara-Service
parent
540ebba9b4
commit
dbb6550c2f
@@ -17,7 +17,6 @@
|
||||
COMPILED_PROTO_PATH="compiled_proto"
|
||||
|
||||
${PROTOC} --cpp_out=${COMPILED_PROTO_PATH} internal/proto/analytics/connections_log.proto
|
||||
${PROTOC} --cpp_out=${COMPILED_PROTO_PATH} internal/proto/analytics/experiments_log.proto
|
||||
${PROTOC} --cpp_out=${COMPILED_PROTO_PATH} internal/proto/analytics/fast_pair_log.proto
|
||||
${PROTOC} --cpp_out=${COMPILED_PROTO_PATH} sharing/proto/analytics/nearby_sharing_log.proto
|
||||
${PROTOC} --cpp_out=${COMPILED_PROTO_PATH} proto/fast_pair_enums.proto
|
||||
|
||||
@@ -28,7 +28,6 @@ cc_library(
|
||||
],
|
||||
deps = [
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//internal/proto/analytics:experiments_log_cc_proto",
|
||||
"//internal/proto/analytics:fast_pair_log_cc_proto",
|
||||
"//sharing/proto/analytics:sharing_log_cc_proto",
|
||||
],
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#define NEARBY_ANALYTICS_EVENT_LOGGER_H_
|
||||
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "internal/proto/analytics/experiments_log.pb.h"
|
||||
#include "internal/proto/analytics/fast_pair_log.pb.h"
|
||||
#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
|
||||
|
||||
@@ -36,10 +35,6 @@ class EventLogger {
|
||||
const location::nearby::analytics::proto::ConnectionsLog& message) = 0;
|
||||
virtual void Log(const sharing::analytics::proto::SharingLog& message) = 0;
|
||||
virtual void Log(const nearby::proto::fastpair::FastPairLog& message) = 0;
|
||||
|
||||
// Configure experiment parameters used by this logger.
|
||||
virtual void ConfigureExperiments(
|
||||
const experiments::ExperimentsLog& message) = 0;
|
||||
};
|
||||
|
||||
} // namespace analytics
|
||||
|
||||
@@ -33,9 +33,6 @@ class MockEventLogger : public ::nearby::analytics::EventLogger {
|
||||
(override));
|
||||
MOCK_METHOD(void, Log, (const nearby::proto::fastpair::FastPairLog& message),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(void, ConfigureExperiments,
|
||||
(const experiments::ExperimentsLog& message), (override));
|
||||
};
|
||||
|
||||
} // namespace nearby::analytics
|
||||
|
||||
@@ -56,21 +56,6 @@ cc_proto_library(
|
||||
deps = [":connections_log_proto"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "experiments_log_proto",
|
||||
srcs = ["experiments_log.proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "experiments_log_cc_proto",
|
||||
visibility = [
|
||||
"//internal/analytics:__pkg__",
|
||||
"//location/nearby/analytics/cpp/logging:__subpackages__",
|
||||
"//location/nearby/cpp/experiments:__subpackages__",
|
||||
],
|
||||
deps = [":experiments_log_proto"],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "proto_analytics_test",
|
||||
size = "small",
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package nearby.experiments;
|
||||
|
||||
// import "storage/datapol/annotations/proto/semantic_annotations.proto";
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
option java_outer_classname = "ExperimentsLogProtos";
|
||||
option java_package = "com.google.nearby.experiments";
|
||||
// option (datapol.file_vetting_status) = "latest";
|
||||
|
||||
// This proto encapsulates the experiments info to identify which logs belong
|
||||
// to which experiments. It's passed from Phenotype
|
||||
// (google3/location/nearby/cpp/experiments) to Clearcut event logger
|
||||
// (google3/location/nearby/analytics/cpp/logging/) so that the event logger
|
||||
// can generate the experiment-based Rasta metrics (go/rasta-overview).
|
||||
// NextId: 3
|
||||
message ExperimentsLog {
|
||||
// Experiment token associated with the Mendel config package.
|
||||
optional bytes experiment_token = 1
|
||||
/* type = ST_EXPERIMENT_ID */;
|
||||
|
||||
// Zwieback cookie shared between Phenotype and Clearcut clients so that
|
||||
// Rasta metrics can reflect the correct population of devices.
|
||||
optional string zwieback_cookie = 2
|
||||
/* type = ST_ZWIEBACK_ID */;
|
||||
}
|
||||
@@ -109,7 +109,6 @@ cc_library(
|
||||
"nearby_file_handler.cc",
|
||||
"nearby_share_profile_info_provider_impl.cc",
|
||||
"nearby_sharing_decoder_impl.cc",
|
||||
"nearby_sharing_event_logger.cc",
|
||||
"nearby_sharing_service.cc",
|
||||
"nearby_sharing_service_extension.cc",
|
||||
"nearby_sharing_service_factory.cc",
|
||||
@@ -137,7 +136,6 @@ cc_library(
|
||||
"nearby_file_handler.h",
|
||||
"nearby_share_profile_info_provider_impl.h",
|
||||
"nearby_sharing_decoder_impl.h",
|
||||
"nearby_sharing_event_logger.h",
|
||||
"nearby_sharing_service.h",
|
||||
"nearby_sharing_service_extension.h",
|
||||
"nearby_sharing_service_factory.h",
|
||||
@@ -297,7 +295,6 @@ cc_test(
|
||||
"nearby_connections_types_test.cc",
|
||||
"nearby_file_handler_test.cc",
|
||||
"nearby_share_profile_info_provider_impl_test.cc",
|
||||
"nearby_sharing_event_logger_test.cc",
|
||||
"nearby_sharing_service_extension_test.cc",
|
||||
"nearby_sharing_service_impl_test.cc",
|
||||
"nearby_sharing_service_test.cc",
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// Copyright 2022 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/nearby_sharing_event_logger.h"
|
||||
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "sharing/common/nearby_share_prefs.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
|
||||
using ::nearby::sharing::api::PreferenceManager;
|
||||
|
||||
NearbySharingEventLogger::NearbySharingEventLogger(
|
||||
const PreferenceManager& preference_manager,
|
||||
nearby::analytics::EventLogger* event_logger)
|
||||
: preference_manager_(preference_manager), event_logger_(event_logger) {}
|
||||
|
||||
NearbySharingEventLogger::~NearbySharingEventLogger() = default;
|
||||
|
||||
void NearbySharingEventLogger::Log(
|
||||
const location::nearby::analytics::proto::ConnectionsLog& message) {
|
||||
if (event_logger_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingIsAnalyticsEnabledName, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event_logger_->Log(message);
|
||||
}
|
||||
|
||||
void NearbySharingEventLogger::Log(
|
||||
const sharing::analytics::proto::SharingLog& message) {
|
||||
if (event_logger_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingIsAnalyticsEnabledName, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event_logger_->Log(message);
|
||||
}
|
||||
|
||||
void NearbySharingEventLogger::Log(
|
||||
const nearby::proto::fastpair::FastPairLog& message) {
|
||||
if (event_logger_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingIsAnalyticsEnabledName, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event_logger_->Log(message);
|
||||
}
|
||||
|
||||
void NearbySharingEventLogger::ConfigureExperiments(
|
||||
const experiments::ExperimentsLog& message) {
|
||||
if (event_logger_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingIsAnalyticsEnabledName, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event_logger_->ConfigureExperiments(message);
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
@@ -1,49 +0,0 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_NEARBY_SHARING_EVENT_LOGGER_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_NEARBY_SHARING_EVENT_LOGGER_H_
|
||||
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
|
||||
// Nearby Sharing SDK needs to enable/disable of the event logger according to
|
||||
// user settings. NearbySharingEventLogger skips analytics logging if analytics
|
||||
// logging is disabled.
|
||||
class NearbySharingEventLogger : public nearby::analytics::EventLogger {
|
||||
public:
|
||||
NearbySharingEventLogger(
|
||||
const nearby::sharing::api::PreferenceManager& preference_manager,
|
||||
nearby::analytics::EventLogger* event_logger);
|
||||
~NearbySharingEventLogger() override;
|
||||
|
||||
void Log(const location::nearby::analytics::proto::ConnectionsLog& message)
|
||||
override;
|
||||
void Log(const sharing::analytics::proto::SharingLog& message) override;
|
||||
void Log(const nearby::proto::fastpair::FastPairLog& message) override;
|
||||
void ConfigureExperiments(
|
||||
const experiments::ExperimentsLog& message) override;
|
||||
|
||||
private:
|
||||
const nearby::sharing::api::PreferenceManager& preference_manager_;
|
||||
nearby::analytics::EventLogger* const event_logger_;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_NEARBY_SHARING_EVENT_LOGGER_H_
|
||||
@@ -1,101 +0,0 @@
|
||||
// Copyright 2022 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/nearby_sharing_event_logger.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "internal/analytics/mock_event_logger.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/common/nearby_share_prefs.h"
|
||||
#include "sharing/internal/test/fake_preference_manager.h"
|
||||
#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
|
||||
#include "google/protobuf/message_lite.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
namespace {
|
||||
using ::location::nearby::proto::sharing::EventCategory;
|
||||
using ::location::nearby::proto::sharing::EventType;
|
||||
using ::nearby::analytics::MockEventLogger;
|
||||
using ::nearby::sharing::analytics::proto::SharingLog;
|
||||
using ::testing::An;
|
||||
|
||||
class NearbySharingEventLoggerTest : public ::testing::Test {
|
||||
public:
|
||||
NearbySharingEventLoggerTest() = default;
|
||||
|
||||
void SetUp() override {
|
||||
event_logger_ = std::make_unique<MockEventLogger>();
|
||||
sharing_event_logger_ = std::make_unique<NearbySharingEventLogger>(
|
||||
preference_manager_, event_logger_.get());
|
||||
}
|
||||
|
||||
void SetEventLogger(bool enabled) {
|
||||
preference_manager_.SetBoolean(prefs::kNearbySharingIsAnalyticsEnabledName,
|
||||
enabled);
|
||||
}
|
||||
|
||||
MockEventLogger* event_logger() { return event_logger_.get(); }
|
||||
|
||||
std::unique_ptr<SharingLog> GetTestEvent() {
|
||||
auto sharing_log =
|
||||
std::unique_ptr<SharingLog>(SharingLog::default_instance().New());
|
||||
sharing_log->set_event_category(EventCategory::SETTINGS_EVENT);
|
||||
sharing_log->set_event_type(EventType::TAP_HELP);
|
||||
|
||||
auto tap_help =
|
||||
analytics::proto::SharingLog::TapHelp::default_instance().New();
|
||||
|
||||
sharing_log->set_allocated_tap_help(tap_help);
|
||||
return sharing_log;
|
||||
}
|
||||
|
||||
NearbySharingEventLogger* sharing_event_logger() {
|
||||
return sharing_event_logger_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
nearby::FakePreferenceManager preference_manager_;
|
||||
std::unique_ptr<MockEventLogger> event_logger_;
|
||||
std::unique_ptr<NearbySharingEventLogger> sharing_event_logger_;
|
||||
};
|
||||
|
||||
TEST_F(NearbySharingEventLoggerTest, LogEventWhenEnabled) {
|
||||
SetEventLogger(true);
|
||||
EXPECT_CALL(*event_logger(), Log(An<const SharingLog&>()))
|
||||
.WillOnce([&](const SharingLog& message) {
|
||||
EXPECT_EQ(message.event_category(), EventCategory::SETTINGS_EVENT);
|
||||
EXPECT_EQ(message.event_type(), EventType::TAP_HELP);
|
||||
});
|
||||
|
||||
std::unique_ptr<SharingLog> event = GetTestEvent();
|
||||
sharing_event_logger()->Log(*event);
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingEventLoggerTest, NoLogEventWhenDisabled) {
|
||||
SetEventLogger(false);
|
||||
EXPECT_CALL(*event_logger(), Log(An<const SharingLog&>())).Times(0);
|
||||
|
||||
std::unique_ptr<SharingLog> event = GetTestEvent();
|
||||
sharing_event_logger()->Log(*event);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "sharing/internal/public/context_impl.h"
|
||||
#include "sharing/nearby_connections_manager_factory.h"
|
||||
#include "sharing/nearby_sharing_decoder_impl.h"
|
||||
#include "sharing/nearby_sharing_event_logger.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_service_impl.h"
|
||||
|
||||
@@ -40,25 +39,23 @@ NearbySharingServiceFactory* NearbySharingServiceFactory::GetInstance() {
|
||||
NearbySharingService* NearbySharingServiceFactory::CreateSharingService(
|
||||
LinkType link_type,
|
||||
SharingPlatform& sharing_platform,
|
||||
std::unique_ptr<::nearby::analytics::EventLogger> event_logger) {
|
||||
::nearby::analytics::EventLogger* event_logger) {
|
||||
if (nearby_sharing_service_ != nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context_ =
|
||||
std::make_unique<ContextImpl>(sharing_platform);
|
||||
base_event_logger_ = std::move(event_logger);
|
||||
sharing_event_logger_ = std::make_unique<NearbySharingEventLogger>(
|
||||
sharing_platform.GetPreferenceManager(), base_event_logger_.get());
|
||||
event_logger_ = event_logger;
|
||||
decoder_ = std::make_unique<NearbySharingDecoderImpl>();
|
||||
nearby_connections_manager_ =
|
||||
auto nearby_connections_manager =
|
||||
NearbyConnectionsManagerFactory::CreateConnectionsManager(
|
||||
link_type, context_.get(), sharing_platform.GetDeviceInfo(),
|
||||
sharing_event_logger_.get());
|
||||
event_logger_);
|
||||
|
||||
nearby_sharing_service_ = std::make_unique<NearbySharingServiceImpl>(
|
||||
context_.get(), sharing_platform, decoder_.get(),
|
||||
std::move(nearby_connections_manager_), sharing_event_logger_.get());
|
||||
std::move(nearby_connections_manager), event_logger_);
|
||||
|
||||
return nearby_sharing_service_.get();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "sharing/internal/api/sharing_platform.h"
|
||||
#include "sharing/internal/public/context.h"
|
||||
#include "sharing/nearby_connections_manager.h"
|
||||
#include "sharing/nearby_sharing_decoder.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
|
||||
@@ -37,16 +36,14 @@ class NearbySharingServiceFactory {
|
||||
NearbySharingService* CreateSharingService(
|
||||
LinkType link_type,
|
||||
nearby::sharing::api::SharingPlatform& sharing_platform,
|
||||
std::unique_ptr<::nearby::analytics::EventLogger> event_logger);
|
||||
::nearby::analytics::EventLogger* event_logger);
|
||||
|
||||
private:
|
||||
NearbySharingServiceFactory() = default;
|
||||
|
||||
std::unique_ptr<Context> context_;
|
||||
std::unique_ptr<::nearby::analytics::EventLogger> base_event_logger_;
|
||||
std::unique_ptr<::nearby::analytics::EventLogger> sharing_event_logger_;
|
||||
::nearby::analytics::EventLogger* event_logger_ = nullptr;
|
||||
std::unique_ptr<NearbySharingDecoder> decoder_;
|
||||
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager_;
|
||||
std::unique_ptr<NearbySharingService> nearby_sharing_service_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user