diff --git a/connections/core.h b/connections/core.h index d159767a67..08f0e379ba 100644 --- a/connections/core.h +++ b/connections/core.h @@ -52,8 +52,9 @@ class Core { explicit Core(ServiceControllerRouter* router); // Client needs to call this constructor if analytics logger is needed. Core(::nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id, ServiceControllerRouter* router) - : client_(event_logger), router_(router) {} + : client_(event_logger, nearby_share_version_id), router_(router) {} ~Core(); Core(Core&&); Core& operator=(Core&&); diff --git a/connections/implementation/analytics/analytics_recorder.cc b/connections/implementation/analytics/analytics_recorder.cc index daa7bc213e..5f353180a3 100644 --- a/connections/implementation/analytics/analytics_recorder.cc +++ b/connections/implementation/analytics/analytics_recorder.cc @@ -103,8 +103,10 @@ using ::nearby::analytics::EventLogger; using SafeDisconnectionResult = ::location::nearby::analytics::proto:: ConnectionsLog::EstablishedConnection::SafeDisconnectionResult; -AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger) - : event_logger_(event_logger) { +AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger, + absl::string_view nearby_share_version_id) + : event_logger_(event_logger), + nearby_share_version_id_(nearby_share_version_id) { NEARBY_LOGS(INFO) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_; LogStartSession(); @@ -710,6 +712,10 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) { ConnectionsLog connections_log; connections_log.set_event_type(ERROR_CODE); connections_log.set_version(kVersion); + if (!nearby_share_version_id_.empty()) { + connections_log.set_nearby_sharing_sdk_version( + nearby_share_version_id_); + } connections_log.set_allocated_error_code(error_code); NEARBY_VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log=" @@ -798,6 +804,10 @@ void AnalyticsRecorder::LogClientSessionLocked() { connections_log.set_event_type(CLIENT_SESSION); connections_log.set_allocated_client_session(client_session.release()); connections_log.set_version(kVersion); + if (!nearby_share_version_id_.empty()) { + connections_log.set_nearby_sharing_sdk_version( + nearby_share_version_id_); + } NEARBY_VLOG(1) << "AnalyticsRecorder LogClientSession connections_log=" << connections_log.DebugString(); // NOLINT @@ -812,6 +822,9 @@ void AnalyticsRecorder::LogEvent(EventType event_type) { ConnectionsLog connections_log; connections_log.set_event_type(event_type); connections_log.set_version(kVersion); + if (!nearby_share_version_id_.empty()) { + connections_log.set_nearby_sharing_sdk_version(nearby_share_version_id_); + } NEARBY_VLOG(1) << "AnalyticsRecorder LogEvent connections_log=" << connections_log.DebugString(); // NOLINT diff --git a/connections/implementation/analytics/analytics_recorder.h b/connections/implementation/analytics/analytics_recorder.h index 7145f1ac5f..d5ae5c41ae 100644 --- a/connections/implementation/analytics/analytics_recorder.h +++ b/connections/implementation/analytics/analytics_recorder.h @@ -41,7 +41,8 @@ namespace analytics { class AnalyticsRecorder { public: - explicit AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger); + explicit AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger, + absl::string_view nearby_share_version_id); virtual ~AnalyticsRecorder(); // TODO(edwinwu): Implement to pass real values for AdvertisingMetadata and @@ -359,6 +360,7 @@ class AnalyticsRecorder { // Not owned by AnalyticsRecorder. Pointer must refer to a valid object // that outlives the one constructed. ::nearby::analytics::EventLogger *event_logger_; + const std::string nearby_share_version_id_; SingleThreadExecutor serial_executor_; // Protects all sub-protos reading and writing in ConnectionLog. diff --git a/connections/implementation/analytics/analytics_recorder_test.cc b/connections/implementation/analytics/analytics_recorder_test.cc index a2bc091edf..a60e1db43f 100644 --- a/connections/implementation/analytics/analytics_recorder_test.cc +++ b/connections/implementation/analytics/analytics_recorder_test.cc @@ -75,6 +75,8 @@ using ::testing::Not; using ::testing::proto::Partially; constexpr absl::Duration kDefaultTimeout = absl::Milliseconds(1000); +constexpr absl::string_view kNearbyShareVersionId = { + "major.minor.build.revision"}; class FakeEventLogger : public MockEventLogger { public: @@ -142,7 +144,7 @@ class FakeEventLogger : public MockEventLogger { TEST(AnalyticsRecorderTest, SessionOnlyLoggedOnceWorks) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.LogSession(); analytics_recorder.LogSession(); @@ -159,7 +161,7 @@ TEST(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedAdvertisingCalls) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(strategy, /*mediums=*/{BLE, BLUETOOTH}); analytics_recorder.OnStopAdvertising(); @@ -201,7 +203,7 @@ TEST(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedDiscoveryCalls) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery( strategy, /*mediums=*/{BLE, BLUETOOTH}, @@ -255,7 +257,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(strategy, mediums); analytics_recorder.OnStartDiscovery(strategy, mediums); @@ -351,7 +353,7 @@ TEST(AnalyticsRecorderTest, AdvertiserConnectionRequestsWorks) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -418,7 +420,7 @@ TEST(AnalyticsRecorderTest, DiscoveryConnectionRequestsWorks) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -486,7 +488,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -544,7 +546,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -598,7 +600,7 @@ TEST(AnalyticsRecorderTest, TEST(AnalyticsRecorderTest, SuccessfulIncomingConnectionAttempt) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -656,7 +658,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); auto connections_attempt_metadata_params = analytics_recorder.BuildConnectionAttemptMetadataParams( @@ -728,7 +730,7 @@ TEST(AnalyticsRecorderTest, UnfinishedEstablishedConnectionsAddedAsUnfinished) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -780,7 +782,7 @@ TEST(AnalyticsRecorderTest, OutgoingPayloadUpgraded) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -859,7 +861,7 @@ TEST(AnalyticsRecorderTest, UpgradeAttemptWorks) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -933,7 +935,7 @@ TEST(AnalyticsRecorderTest, StartListeningForIncomingConnectionsWorks) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartedIncomingConnectionListening( connections::Strategy::kP2pStar); @@ -983,7 +985,7 @@ TEST(AnalyticsRecorderTest, StartListeningForIncomingConnectionsWorks) { TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectly) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{WEB_RTC}); @@ -1010,7 +1012,7 @@ TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectly) { TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForUnknownDescription) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{BLUETOOTH}); @@ -1040,7 +1042,7 @@ TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForUnknownDescription) { TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForCommonError) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{BLUETOOTH}); @@ -1067,7 +1069,7 @@ TEST(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForCommonError) { TEST(AnalyticsRecorderTest, CheckIfSessionWasLogged) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); // LogSession to count down client_session_done_latch. analytics_recorder.LogSession(); @@ -1083,7 +1085,7 @@ TEST(AnalyticsRecorderTest, ConstructAnalyticsRecorder) { &start_client_session_done_latch); // Call the constructor to count down the session_done_latch. - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result()); std::vector event_types = event_logger.GetLoggedEventTypes(); @@ -1099,7 +1101,7 @@ TEST(AnalyticsRecorderTest, &start_client_session_done_latch); // Call the constructor to count down the start_client_session_done_latch. - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result()); // Log start client session once. @@ -1128,7 +1130,7 @@ TEST(AnalyticsRecorderTest, &start_client_session_done_latch); // Call the constructor to count down the start_client_session_done_latch. - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result()); // Log start client session once. @@ -1165,7 +1167,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -1268,7 +1270,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -1374,7 +1376,7 @@ TEST(AnalyticsRecorderTest, ClearcActiveConnectionsAfterSessionWasLogged) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(strategy, mediums); @@ -1469,7 +1471,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLE, BLUETOOTH}); @@ -1613,7 +1615,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar, /*mediums=*/{BLUETOOTH}); @@ -1655,7 +1657,7 @@ TEST(AnalyticsRecorderTest, NotLogSameStrategySessionProtoAfterSessionWasLogged) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); //// Via OnStartAdvertising, current_strategy_session_is set in //// UpdateStrategySessionLocked. @@ -1711,7 +1713,7 @@ TEST(AnalyticsRecorderTest, NotLogDuplicateAdvertisingPhaseAfterSessionWasLogged) { CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartAdvertising( connections::Strategy::kP2pStar, @@ -1790,7 +1792,7 @@ TEST(AnalyticsRecorderTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); analytics_recorder.OnStartDiscovery( strategy, {BLUETOOTH}, /*is_extended_advertisement_supported=*/true, @@ -1870,7 +1872,7 @@ TEST(AnalyticsRecorderOnConnectionClosedTest, CountDownLatch client_session_done_latch(1); FakeEventLogger event_logger(client_session_done_latch); - AnalyticsRecorder analytics_recorder(&event_logger); + AnalyticsRecorder analytics_recorder(&event_logger, kNearbyShareVersionId); // via OnStartAdvertising, current_strategy_session_ is set in // UpdateStrategySessionLocked. diff --git a/connections/implementation/client_proxy.cc b/connections/implementation/client_proxy.cc index 174a1a4044..96f559ed8c 100644 --- a/connections/implementation/client_proxy.cc +++ b/connections/implementation/client_proxy.cc @@ -86,11 +86,12 @@ bool IsFeatureUseStableEndpointIdEnabled() { constexpr absl::Duration ClientProxy::kHighPowerAdvertisementEndpointIdCacheTimeout; -ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger) +ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id) : client_id_(Prng().NextInt64()) { NEARBY_LOGS(INFO) << "ClientProxy ctor event_logger=" << event_logger; - analytics_recorder_ = - std::make_unique(event_logger); + analytics_recorder_ = std::make_unique( + event_logger, nearby_share_version_id); error_code_recorder_ = std::make_unique( [this](const ErrorCodeParams& params) { analytics_recorder_->OnErrorCode(params); diff --git a/connections/implementation/client_proxy.h b/connections/implementation/client_proxy.h index 881c160577..73a09fdc29 100644 --- a/connections/implementation/client_proxy.h +++ b/connections/implementation/client_proxy.h @@ -65,8 +65,8 @@ class ClientProxy final { static constexpr absl::Duration kHighPowerAdvertisementEndpointIdCacheTimeout = absl::Seconds(30); - explicit ClientProxy( - ::nearby::analytics::EventLogger* event_logger = nullptr); + explicit ClientProxy(::nearby::analytics::EventLogger* event_logger = nullptr, + absl::string_view nearby_share_version_id = {}); ~ClientProxy(); ClientProxy(ClientProxy&&) = default; ClientProxy& operator=(ClientProxy&&) = default; diff --git a/internal/proto/analytics/connections_log.proto b/internal/proto/analytics/connections_log.proto index fb9819ffb7..b7ba938626 100644 --- a/internal/proto/analytics/connections_log.proto +++ b/internal/proto/analytics/connections_log.proto @@ -27,7 +27,7 @@ option objc_class_prefix = "GNCP"; // Top-level log proto for Nearby Connections. // LINT.IfChange(ConnectionsLog) -// Next Tag: 7 +// Next Tag: 8 message ConnectionsLog { // The type of this log. optional location.nearby.proto.connections.EventType event_type = 1; @@ -55,6 +55,10 @@ message ConnectionsLog { // Reference: http://shortn/_9smZZ8CTD6, http://shortn/_Y08gVwZRKc optional string files_migration_phase = 6; + // The version of Nearby Sharing SDK. It is passed from NearbySharing SDK. + optional string nearby_sharing_sdk_version = 7 + /* type = ST_SOFTWARE_ID */; + // Encapsulates one session of a client connected to Nearby Connections API. message ClientSession { // Elapsed time in milliseconds between Client connect and diff --git a/sharing/nearby_connections_manager_factory.cc b/sharing/nearby_connections_manager_factory.cc index e34dd0bee5..4175635ba5 100644 --- a/sharing/nearby_connections_manager_factory.cc +++ b/sharing/nearby_connections_manager_factory.cc @@ -16,6 +16,7 @@ #include +#include "absl/strings/string_view.h" #include "internal/analytics/event_logger.h" #include "internal/platform/device_info.h" #include "internal/platform/task_runner.h" @@ -30,11 +31,13 @@ std::unique_ptr NearbyConnectionsManagerFactory::CreateConnectionsManager( nearby::TaskRunner* connections_callback_task_runner, Context* context, nearby::DeviceInfo& device_info, - nearby::analytics::EventLogger* event_logger) { + nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id) { return std::make_unique( connections_callback_task_runner, context, *context->GetConnectivityManager(), device_info, - std::make_unique(event_logger)); + std::make_unique(event_logger, + nearby_share_version_id)); } } // namespace nearby::sharing diff --git a/sharing/nearby_connections_manager_factory.h b/sharing/nearby_connections_manager_factory.h index f22da1ef1e..44db2d9513 100644 --- a/sharing/nearby_connections_manager_factory.h +++ b/sharing/nearby_connections_manager_factory.h @@ -17,6 +17,7 @@ #include +#include "absl/strings/string_view.h" #include "internal/analytics/event_logger.h" #include "internal/platform/device_info.h" #include "internal/platform/task_runner.h" @@ -34,7 +35,8 @@ class NearbyConnectionsManagerFactory { static std::unique_ptr CreateConnectionsManager( nearby::TaskRunner* connections_callback_task_runner, Context* context, nearby::DeviceInfo& device_info, - nearby::analytics::EventLogger* event_logger = nullptr); + nearby::analytics::EventLogger* event_logger = nullptr, + absl::string_view nearby_share_version_id = {}); private: NearbyConnectionsManagerFactory() = default; diff --git a/sharing/nearby_connections_service_impl.cc b/sharing/nearby_connections_service_impl.cc index a11da2a60f..3ebd90422b 100644 --- a/sharing/nearby_connections_service_impl.cc +++ b/sharing/nearby_connections_service_impl.cc @@ -49,9 +49,10 @@ Core* GetService(NearbyConnectionsService::HANDLE handle) { } // namespace NearbyConnectionsServiceImpl::NearbyConnectionsServiceImpl( - nearby::analytics::EventLogger* event_logger) { + nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id) { static ServiceControllerRouter* router = new ServiceControllerRouter(); - static Core* core = new Core(event_logger, router); + static Core* core = new Core(event_logger, nearby_share_version_id, router); service_handle_ = core; } diff --git a/sharing/nearby_connections_service_impl.h b/sharing/nearby_connections_service_impl.h index 11ce97d3f0..e241e6cc96 100644 --- a/sharing/nearby_connections_service_impl.h +++ b/sharing/nearby_connections_service_impl.h @@ -35,7 +35,8 @@ namespace sharing { class NearbyConnectionsServiceImpl : public NearbyConnectionsService { public: explicit NearbyConnectionsServiceImpl( - nearby::analytics::EventLogger* event_logger = nullptr); + nearby::analytics::EventLogger* event_logger = nullptr, + absl::string_view nearby_share_version_id = {}); NearbyConnectionsServiceImpl() = delete; ~NearbyConnectionsServiceImpl() override; diff --git a/sharing/nearby_sharing_service_factory.cc b/sharing/nearby_sharing_service_factory.cc index d0770162c4..000fc03973 100644 --- a/sharing/nearby_sharing_service_factory.cc +++ b/sharing/nearby_sharing_service_factory.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "internal/analytics/event_logger.h" #include "internal/platform/task_runner.h" #include "sharing/analytics/analytics_recorder.h" @@ -40,7 +41,8 @@ NearbySharingServiceFactory* NearbySharingServiceFactory::GetInstance() { NearbySharingService* NearbySharingServiceFactory::CreateSharingService( SharingPlatform& sharing_platform, analytics::AnalyticsRecorder* analytics_recorder, - ::nearby::analytics::EventLogger* event_logger) { + ::nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id) { if (nearby_sharing_service_ != nullptr) { return nullptr; } @@ -52,7 +54,8 @@ NearbySharingService* NearbySharingServiceFactory::CreateSharingService( auto nearby_connections_manager = NearbyConnectionsManagerFactory::CreateConnectionsManager( service_thread.get(), context_.get(), - sharing_platform.GetDeviceInfo(), event_logger); + sharing_platform.GetDeviceInfo(), + event_logger, nearby_share_version_id); nearby_sharing_service_ = std::make_unique( std::move(service_thread), context_.get(), sharing_platform, diff --git a/sharing/nearby_sharing_service_factory.h b/sharing/nearby_sharing_service_factory.h index c7a60cacc0..a06f8a8115 100644 --- a/sharing/nearby_sharing_service_factory.h +++ b/sharing/nearby_sharing_service_factory.h @@ -17,6 +17,7 @@ #include +#include "absl/strings/string_view.h" #include "internal/analytics/event_logger.h" #include "sharing/analytics/analytics_recorder.h" #include "sharing/internal/api/sharing_platform.h" @@ -33,7 +34,8 @@ class NearbySharingServiceFactory { NearbySharingService* CreateSharingService( nearby::sharing::api::SharingPlatform& sharing_platform, analytics::AnalyticsRecorder* analytics_recorder, - nearby::analytics::EventLogger* event_logger); + nearby::analytics::EventLogger* event_logger, + absl::string_view nearby_share_version_id); private: NearbySharingServiceFactory() = default;