Skip to content

Commit

Permalink
Merge pull request #5795 from adrianM27/analytics_phase2
Browse files Browse the repository at this point in the history
RDK-53677: Analytics plugin phase2
  • Loading branch information
anand-ky authored Oct 30, 2024
2 parents 98d61f3 + be3c8eb commit d4cd71a
Show file tree
Hide file tree
Showing 28 changed files with 919 additions and 444 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ jobs:
run: >
cd "${{github.workspace}}/ThunderInterfaces"
&&
git apply "${{github.workspace}}/rdkservices/Tests/L1Tests/patches/0001-Add-IAnalytics-interface-R2.patch"
&&
cd ..
- name: Build ThunderInterfaces
Expand Down Expand Up @@ -296,8 +294,6 @@ jobs:
-DPLUGIN_TEXTTOSPEECH=ON
-DPLUGIN_SYSTEMAUDIOPLAYER=ON
-DPLUGIN_MIRACAST=ON
-DPLUGIN_ANALYTICS=ON
-DPLUGIN_ANALYTICS_SIFT_BACKEND=ON
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/rdkservices -j8
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/L2-tests-R4-4-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ jobs:
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDK-51362-System-Mode-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-Add-IAnalytics-interface-R4.4.patch
cd ..
- name: Build ThunderInterfaces
Expand Down Expand Up @@ -278,6 +279,8 @@ jobs:
-DPLUGIN_L2Tests=ON
-DRDK_SERVICE_L2_TEST=ON
-DDS_FOUND=ON
-DPLUGIN_ANALYTICS=ON
-DPLUGIN_ANALYTICS_SIFT_BACKEND=ON
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/rdkservices -j8
Expand Down
1 change: 1 addition & 0 deletions Analytics/Analytics.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if boolean("@PLUGIN_ANALYTICS_SIFT_BACKEND_ENABLED@"):
sift.add("productname", "@PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME@")
sift.add("loggername", "@PLUGIN_ANALYTICS_SIFT_LOGGER_NAME@")
sift.add("loggerversion", "@PLUGIN_ANALYTICS_SIFT_LOGGER_VERSION@")
sift.add("platformdefault", "@PLUGIN_ANALYTICS_SIFT_PLATFORM_DEFAULT@")
sift.add("maxrandomisationwindowtime", "@PLUGIN_ANALYTICS_SIFT_MAX_RANDOMISATION_WINDOW_TIME@")
sift.add("maxeventsinpost", "@PLUGIN_ANALYTICS_SIFT_MAX_EVENTS_IN_POST@")
sift.add("maxretries", "@PLUGIN_ANALYTICS_SIFT_MAX_RETRIES@")
Expand Down
1 change: 1 addition & 0 deletions Analytics/Analytics.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if(PLUGIN_ANALYTICS_SIFT_BACKEND_ENABLED)
kv(productname ${PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME})
kv(loggername ${PLUGIN_ANALYTICS_SIFT_LOGGER_NAME})
kv(loggerversion ${PLUGIN_ANALYTICS_SIFT_LOGGER_VERSION})
kv(platformdefault ${PLUGIN_ANALYTICS_SIFT_PLATFORM_DEFAULT})
kv(maxrandomisationwindowtime, ${PLUGIN_ANALYTICS_SIFT_MAX_RANDOMISATION_WINDOW_TIME})
kv(maxeventsinpost, ${PLUGIN_ANALYTICS_SIFT_MAX_EVENTS_IN_POST})
kv(maxretries, ${PLUGIN_ANALYTICS_SIFT_MAX_RETRIES})
Expand Down
28 changes: 23 additions & 5 deletions Analytics/Analytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ namespace {
namespace Plugin {
SERVICE_REGISTRATION(Analytics, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);

Analytics::Analytics(): mConnectionId(0), mAnalytics(nullptr)
{
SYSLOG(Logging::Startup, (_T("Analytics Constructor")));
}

Analytics::~Analytics()
{
SYSLOG(Logging::Shutdown, (string(_T("Analytics Destructor"))));
}

/* virtual */ const string Analytics::Initialize(PluginHost::IShell* service)
{
ASSERT(service != nullptr);
mService = service;

ASSERT(mAnalytics == nullptr);

SYSLOG(Logging::Startup, (_T("Analytics::Initialize: PID=%u"), getpid()));

mService = service;

mAnalytics = service->Root<Exchange::IAnalytics>(mConnectionId, 2000, _T("AnalyticsImplementation"));
ASSERT(mAnalytics != nullptr);

Expand All @@ -58,7 +70,12 @@ namespace Plugin {
configConnection->Configure(service);
configConnection->Release();
}
RegisterAll();
// Invoking Plugin API register to wpeframework
Exchange::JAnalytics::Register(*this, mAnalytics);
}
else
{
SYSLOG(Logging::Startup, (_T("Analytics::Initialize: Failed to initialise Analytics plugin")));
}
// On success return empty, to indicate there is no error text.
return ((mAnalytics != nullptr))
Expand All @@ -68,10 +85,11 @@ namespace Plugin {

/* virtual */ void Analytics::Deinitialize(PluginHost::IShell* service)
{
TRACE(Trace::Information, (_T("Analytics::Deinitialize")));
SYSLOG(Logging::Shutdown, (string(_T("Analytics::Deinitialize"))));
ASSERT(service == mService);

if (mAnalytics != nullptr) {
Exchange::JAnalytics::Unregister(*this);

RPC::IRemoteConnection *connection(service->RemoteConnection(mConnectionId));
VARIABLE_IS_NOT_USED uint32_t result = mAnalytics->Release();
Expand All @@ -93,12 +111,12 @@ namespace Plugin {
connection->Release();
}
}
SYSLOG(Logging::Shutdown, (string(_T("Analytics de-initialised"))));
}

void Analytics::Deactivated(RPC::IRemoteConnection* connection)
{
if (connection->Id() == mConnectionId) {
TRACE(Trace::Information, (_T("Analytics::Deactivated")));

ASSERT(mService != nullptr);

Expand Down
23 changes: 4 additions & 19 deletions Analytics/Analytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "Module.h"

#include <interfaces/IAnalytics.h>
#include <interfaces/json/JsonData_Analytics.h>
#include <interfaces/json/JAnalytics.h>

namespace WPEFramework {

Expand All @@ -47,16 +49,8 @@ namespace WPEFramework {
Analytics& operator=(const Analytics&) = delete;

public:
Analytics():
mConnectionId(0),
mAnalytics(nullptr)
{
RegisterAll();
}
virtual ~Analytics()
{
UnregisterAll();
}
Analytics();
virtual ~Analytics();
virtual const string Initialize(PluginHost::IShell* shell) override;
virtual void Deinitialize(PluginHost::IShell* service) override;
virtual string Information() const override { return {}; }
Expand All @@ -68,18 +62,9 @@ namespace WPEFramework {
END_INTERFACE_MAP

static const string ANALYTICS_METHOD_SEND_EVENT;
static const string ANALYTICS_METHOD_SET_SESSION_ID;
static const string ANALYTICS_METHOD_SET_TIME_READY;

private:
void Deactivated(RPC::IRemoteConnection* connection);
// JSONRPC methods
void RegisterAll();
void UnregisterAll();

uint32_t SendEventWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t SetSessionIdWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t SetTimeReadyWrapper(const JsonObject& parameters, JsonObject& response);

private:
PluginHost::IShell* mService;
Expand Down
136 changes: 0 additions & 136 deletions Analytics/AnalyticsJsonRpc.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions Analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All notable changes to this RDK Service will be documented in this file.

For more details, refer to versioning section under Main README.

## [1.0.1] - 2024-10-16
- Support generation of sessionID, SysTime validation and limit nbr of external attributes for Sift

## [1.0.0] - 2024-07-25
### Added
- New RDK Service Analytics to handle analytics events and send them to dedicated backends
Expand Down
16 changes: 8 additions & 8 deletions Analytics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})

set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)

add_compile_definitions(ANALYTICS_MAJOR_VERSION=${VERSION_MAJOR})
add_compile_definitions(ANALYTICS_MINOR_VERSION=${VERSION_MINOR})
Expand All @@ -42,13 +42,14 @@ set(PLUGIN_ANALYTICS_SIFT_ENV "prod" CACHE STRING "Sift environment")
set(PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME "entos" CACHE STRING "Sift product name") #entos-immerse in Sift2.0
set(PLUGIN_ANALYTICS_SIFT_LOGGER_NAME "Analytics" CACHE STRING "Sift logger name")
set(PLUGIN_ANALYTICS_SIFT_LOGGER_VERSION "${MODULE_VERSION}" CACHE STRING "Sift logger version")
set(PLUGIN_ANALYTICS_SIFT_PLATFORM_DEFAULT "entos:rdk" CACHE STRING "Sift platform default value")
set(PLUGIN_ANALYTICS_SIFT_MAX_RANDOMISATION_WINDOW_TIME 300 CACHE STRING "Sift max randomisation window time of posting queued events")
set(PLUGIN_ANALYTICS_SIFT_MAX_EVENTS_IN_POST 10 CACHE STRING "Sift max events in post")
set(PLUGIN_ANALYTICS_SIFT_MAX_RETRIES 10 CACHE STRING "Sift max retries posting events")
set(PLUGIN_ANALYTICS_SIFT_MIN_RETRY_PERIOD 1 CACHE STRING "Sift min retry period seconds")
set(PLUGIN_ANALYTICS_SIFT_MAX_RETRY_PERIOD 30 CACHE STRING "Sift max retry period seconds")
set(PLUGIN_ANALYTICS_SIFT_EXPONENTIAL_PERIODIC_FACTOR 2 CACHE STRING "Sift exponential periodic factor")
set(PLUGIN_ANALYTICS_SIFT_STORE_PATH "/opt/persistent/sky/AnalyticsSiftStore" CACHE STRING "Sift store path")
set(PLUGIN_ANALYTICS_SIFT_STORE_PATH "/persistent/AnalyticsSiftStore" CACHE STRING "Sift store path")
set(PLUGIN_ANALYTICS_SIFT_STORE_EVENTS_LIMIT 1000 CACHE STRING "Sift store events limit")
set(PLUGIN_ANALYTICS_SIFT_URL "" CACHE STRING "Sift URL")

Expand All @@ -57,18 +58,18 @@ message("Setup ${MODULE_NAME} v${MODULE_VERSION}")
find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)
find_package(DS)
find_package(IARMBus)

add_library(${MODULE_NAME} SHARED
Analytics.cpp
AnalyticsJsonRpc.cpp
Implementation/AnalyticsImplementation.cpp
Module.cpp)

target_include_directories(${MODULE_NAME} PRIVATE Implementation)
target_include_directories(${MODULE_NAME} PRIVATE Implementation/SystemTime)
target_include_directories(${MODULE_NAME} PRIVATE ../)
target_include_directories(${MODULE_NAME} PRIVATE ../helpers)

add_subdirectory(Implementation/SystemTime)
add_subdirectory(Implementation/LocalStore)
add_subdirectory(Implementation/Backend)

Expand All @@ -83,9 +84,8 @@ target_link_libraries(${MODULE_NAME}
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
${DS_LIBRARIES}
${IARMBUS_LIBRARIES}
${MODULE_NAME}Backends)
${MODULE_NAME}Backends
${MODULE_NAME}SystemTime)

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
Expand Down
Loading

0 comments on commit d4cd71a

Please sign in to comment.