From 5fd5ee19e8275a6420902d7fc317bc55ee2ba0cd Mon Sep 17 00:00:00 2001 From: Adrian Muzyka Date: Wed, 28 Aug 2024 07:55:17 +0200 Subject: [PATCH] RDK-51273: Support Sift 1.0 by default, add License headers --- Analytics/Analytics.conf.in | 1 + Analytics/Analytics.config | 3 +- Analytics/CMakeLists.txt | 3 +- .../AnalyticsImplementation.cpp | 18 ++ .../Implementation/AnalyticsImplementation.h | 18 ++ .../Backend/AnalyticsBackend.cpp | 18 ++ .../Implementation/Backend/AnalyticsBackend.h | 18 ++ .../Implementation/Backend/CMakeLists.txt | 16 ++ .../Backend/Sift/CMakeLists.txt | 16 ++ .../Backend/Sift/SiftBackend.cpp | 209 +++++++++++------- .../Implementation/Backend/Sift/SiftBackend.h | 18 ++ .../Backend/Sift/SiftConfig.cpp | 209 ++++++++++++------ .../Implementation/Backend/Sift/SiftConfig.h | 44 +++- 13 files changed, 428 insertions(+), 163 deletions(-) diff --git a/Analytics/Analytics.conf.in b/Analytics/Analytics.conf.in index a37c47a59f..c8ea66e069 100644 --- a/Analytics/Analytics.conf.in +++ b/Analytics/Analytics.conf.in @@ -9,6 +9,7 @@ configuration.add("deviceosname", "@PLUGIN_ANALYTICS_DEVICE_OS_NAME@") if boolean("@PLUGIN_ANALYTICS_SIFT_BACKEND_ENABLED@"): sift = JSON() + sift.add("schema2", "@PLUGIN_ANALYTICS_SIFT_2_0_ENABLED@") sift.add("commonschema", "@PLUGIN_ANALYTICS_SIFT_COMMON_SCHEMA@") sift.add("env", "@PLUGIN_ANALYTICS_SIFT_ENV@") sift.add("productname", "@PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME@") diff --git a/Analytics/Analytics.config b/Analytics/Analytics.config index e0c3e45aa7..a78833fe54 100644 --- a/Analytics/Analytics.config +++ b/Analytics/Analytics.config @@ -7,13 +7,14 @@ set (startuporder ${PLUGIN_ANALYTICS_STARTUPORDER}) endif() map() - kv(deviceosversion ${PLUGIN_ANALYTICS_DEVICE_OS_VERSION}) + kv(deviceosname ${PLUGIN_ANALYTICS_DEVICE_OS_NAME}) end() ans(configuration) if(PLUGIN_ANALYTICS_SIFT_BACKEND_ENABLED) map() + kv(schema2 ${PLUGIN_ANALYTICS_SIFT_2_0_ENABLED}) kv(commonschema ${PLUGIN_ANALYTICS_SIFT_COMMON_SCHEMA}) kv(env ${PLUGIN_ANALYTICS_SIFT_ENV}) kv(productname ${PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME}) diff --git a/Analytics/CMakeLists.txt b/Analytics/CMakeLists.txt index cc710c98d0..07ccd7147e 100644 --- a/Analytics/CMakeLists.txt +++ b/Analytics/CMakeLists.txt @@ -36,9 +36,10 @@ set(PLUGIN_ANALYTICS_AUTOSTART "false" CACHE STRING "Automatically start Analyti set(PLUGIN_ANALYTICS_DEVICE_OS_NAME "rdk" CACHE STRING "Device OS name") set(PLUGIN_ANALYTICS_SIFT_BACKEND_ENABLED ${PLUGIN_ANALYTICS_SIFT_BACKEND} CACHE BOOL "Enable Sift backend configuration") +set(PLUGIN_ANALYTICS_SIFT_2_0_ENABLED "false" CACHE STRING "Enable Sift 2.0 schema") set(PLUGIN_ANALYTICS_SIFT_COMMON_SCHEMA "entos/common/v1" CACHE STRING "Sift common schema") set(PLUGIN_ANALYTICS_SIFT_ENV "prod" CACHE STRING "Sift environment") -set(PLUGIN_ANALYTICS_SIFT_PRODUCT_NAME "entos-immerse" CACHE STRING "Sift product name") +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_MAX_RANDOMISATION_WINDOW_TIME 300 CACHE STRING "Sift max randomisation window time of posting queued events") diff --git a/Analytics/Implementation/AnalyticsImplementation.cpp b/Analytics/Implementation/AnalyticsImplementation.cpp index ac137c5bd1..e423717a9e 100644 --- a/Analytics/Implementation/AnalyticsImplementation.cpp +++ b/Analytics/Implementation/AnalyticsImplementation.cpp @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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 "AnalyticsImplementation.h" #include "Backend/AnalyticsBackend.h" #include "UtilsLogging.h" diff --git a/Analytics/Implementation/AnalyticsImplementation.h b/Analytics/Implementation/AnalyticsImplementation.h index affb4d417f..ae1b50509f 100644 --- a/Analytics/Implementation/AnalyticsImplementation.h +++ b/Analytics/Implementation/AnalyticsImplementation.h @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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. + */ #pragma once #include "../Module.h" diff --git a/Analytics/Implementation/Backend/AnalyticsBackend.cpp b/Analytics/Implementation/Backend/AnalyticsBackend.cpp index 75d6dc2da4..b75a26fe76 100644 --- a/Analytics/Implementation/Backend/AnalyticsBackend.cpp +++ b/Analytics/Implementation/Backend/AnalyticsBackend.cpp @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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 "Module.h" #include "AnalyticsBackend.h" diff --git a/Analytics/Implementation/Backend/AnalyticsBackend.h b/Analytics/Implementation/Backend/AnalyticsBackend.h index 2dd2953f91..1a714a232f 100644 --- a/Analytics/Implementation/Backend/AnalyticsBackend.h +++ b/Analytics/Implementation/Backend/AnalyticsBackend.h @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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. + */ #pragma once #include diff --git a/Analytics/Implementation/Backend/CMakeLists.txt b/Analytics/Implementation/Backend/CMakeLists.txt index a2af1afa82..408da5fd91 100644 --- a/Analytics/Implementation/Backend/CMakeLists.txt +++ b/Analytics/Implementation/Backend/CMakeLists.txt @@ -1,4 +1,20 @@ +# If not stated otherwise in this file or this component's license file the +# following copyright and licenses apply: +# +# Copyright 2020 RDK Management +# +# 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 +# +# http://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. set(TARGET_LIB ${NAMESPACE}${PLUGIN_NAME}Backends) add_library(${TARGET_LIB} STATIC) diff --git a/Analytics/Implementation/Backend/Sift/CMakeLists.txt b/Analytics/Implementation/Backend/Sift/CMakeLists.txt index 7a1e39b6e5..bd727dd9a3 100644 --- a/Analytics/Implementation/Backend/Sift/CMakeLists.txt +++ b/Analytics/Implementation/Backend/Sift/CMakeLists.txt @@ -1,3 +1,19 @@ +# If not stated otherwise in this file or this component's license file the +# following copyright and licenses apply: +# +# Copyright 2020 RDK Management +# +# 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 +# +# http://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. set(TARGET_LIB ${NAMESPACE}${PLUGIN_NAME}SiftBackend) add_library(${TARGET_LIB} STATIC) diff --git a/Analytics/Implementation/Backend/Sift/SiftBackend.cpp b/Analytics/Implementation/Backend/Sift/SiftBackend.cpp index e63a4b29d7..57011de74b 100644 --- a/Analytics/Implementation/Backend/Sift/SiftBackend.cpp +++ b/Analytics/Implementation/Backend/Sift/SiftBackend.cpp @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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 "SiftBackend.h" #include "UtilsLogging.h" @@ -147,92 +165,125 @@ namespace WPEFramework bool SiftBackend::SendEventInternal(const Event &event, const SiftConfig::Config &config) { - // Sift 2.0 schema JsonObject eventJson = JsonObject(); - //TODO: Sift does not accept: eventJson["common_schema"] = config.commonSchema; - if (!config.env.empty()) + if (config.schema2Enabled) { - eventJson["env"] = config.env; - } - eventJson["product_name"] = config.productName; - eventJson["product_version"] = config.productVersion; - eventJson["event_schema"] = config.productName + "/" + event.eventName + "/" + event.eventVersion; - eventJson["event_name"] = event.eventName; - eventJson["timestamp"] = event.epochTimestamp; - eventJson["event_id"] = GenerateRandomUUID(); - eventJson["event_source"] = event.eventSource; - eventJson["event_source_version"] = event.eventSourceVersion; - if (!event.cetList.empty()) - { - JsonArray cetList = JsonArray(); - for (const std::string &cet : event.cetList) + // Sift 2.0 schema + eventJson["common_schema"] = config.commonSchema; + if (!config.env.empty()) { - cetList.Add(cet); + eventJson["env"] = config.env; } - eventJson["cet_list"] = cetList; - } - eventJson["logger_name"] = config.loggerName; - eventJson["logger_version"] = config.loggerVersion; - eventJson["partner_id"] = config.partnerId; - if (config.activated) - { - eventJson["xbo_account_id"] = config.xboAccountId; - eventJson["xbo_device_id"] = config.xboDeviceId; - eventJson["activated"] = config.activated; - } - eventJson["device_model"] = config.deviceModel; - eventJson["device_type"] = config.deviceType; - eventJson["device_timezone"] = std::stoi(config.deviceTimeZone); - eventJson["device_os_name"] = config.deviceOsName; - eventJson["device_os_version"] = config.deviceOsVersion; - eventJson["platform"] = config.platform; - eventJson["device_manufacturer"] = config.deviceManufacturer; - eventJson["authenticated"] = config.authenticated; - eventJson["session_id"] = config.sessionId; - eventJson["proposition"] = config.proposition; - if (!config.retailer.empty()) - { - eventJson["retailer"] = config.retailer; - } - if (!config.jvAgent.empty()) - { - eventJson["jv_agent"] = config.jvAgent; - } - if (!config.coam.empty()) - { - eventJson["coam"] = JsonValue(config.coam == "true"); - } - eventJson["device_serial_number"] = config.deviceSerialNumber; - if (!config.deviceFriendlyName.empty()) - { - eventJson["device_friendly_name"] = config.deviceFriendlyName; - } - if (!config.deviceMacAddress.empty()) - { - eventJson["device_mac_address"] = config.deviceMacAddress; - } - if (!config.country.empty()) - { - eventJson["country"] = config.country; - } - if (!config.region.empty()) - { - eventJson["region"] = config.region; - } - if (!config.accountType.empty()) - { - eventJson["account_type"] = config.accountType; - } - if (!config.accountOperator.empty()) - { - eventJson["operator"] = config.accountOperator; + eventJson["product_name"] = config.productName; + eventJson["product_version"] = config.productVersion; + eventJson["event_schema"] = config.productName + "/" + event.eventName + "/" + event.eventVersion; + eventJson["event_name"] = event.eventName; + eventJson["timestamp"] = event.epochTimestamp; + eventJson["event_id"] = GenerateRandomUUID(); + eventJson["event_source"] = event.eventSource; + eventJson["event_source_version"] = event.eventSourceVersion; + if (!event.cetList.empty()) + { + JsonArray cetList = JsonArray(); + for (const std::string &cet : event.cetList) + { + cetList.Add(cet); + } + eventJson["cet_list"] = cetList; + } + eventJson["logger_name"] = config.loggerName; + eventJson["logger_version"] = config.loggerVersion; + eventJson["partner_id"] = config.partnerId; + if (config.activated) + { + eventJson["xbo_account_id"] = config.xboAccountId; + eventJson["xbo_device_id"] = config.xboDeviceId; + eventJson["activated"] = config.activated; + } + eventJson["device_model"] = config.deviceModel; + eventJson["device_type"] = config.deviceType; + eventJson["device_timezone"] = std::stoi(config.deviceTimeZone); + eventJson["device_os_name"] = config.deviceOsName; + eventJson["device_os_version"] = config.deviceOsVersion; + eventJson["platform"] = config.platform; + eventJson["device_manufacturer"] = config.deviceManufacturer; + eventJson["authenticated"] = config.authenticated; + eventJson["session_id"] = config.sessionId; + eventJson["proposition"] = config.proposition; + if (!config.retailer.empty()) + { + eventJson["retailer"] = config.retailer; + } + if (!config.jvAgent.empty()) + { + eventJson["jv_agent"] = config.jvAgent; + } + if (!config.coam.empty()) + { + eventJson["coam"] = JsonValue(config.coam == "true"); + } + eventJson["device_serial_number"] = config.deviceSerialNumber; + if (!config.deviceFriendlyName.empty()) + { + eventJson["device_friendly_name"] = config.deviceFriendlyName; + } + if (!config.deviceMacAddress.empty()) + { + eventJson["device_mac_address"] = config.deviceMacAddress; + } + if (!config.country.empty()) + { + eventJson["country"] = config.country; + } + if (!config.region.empty()) + { + eventJson["region"] = config.region; + } + if (!config.accountType.empty()) + { + eventJson["account_type"] = config.accountType; + } + if (!config.accountOperator.empty()) + { + eventJson["operator"] = config.accountOperator; + } + if (!config.accountDetailType.empty()) + { + eventJson["account_detail_type"] = config.accountDetailType; + } + + eventJson["event_payload"] = JsonObject(event.eventPayload); } - if (!config.accountDetailType.empty()) + else { - eventJson["account_detail_type"] = config.accountDetailType; - } + //Sift 1.0 + eventJson["event_name"] = event.eventName; + eventJson["event_schema"] = config.productName + "/" + event.eventName + "/" + event.eventVersion; + eventJson["event_payload"] = JsonObject(event.eventPayload); + eventJson["session_id"] = config.sessionId; + eventJson["event_id"] = GenerateRandomUUID(); + + if (!config.accountId.empty() && !config.deviceId.empty() && !config.partnerId.empty()) + { + eventJson["account_id"] = config.accountId; + eventJson["device_id"] = config.deviceId; + eventJson["partner_id"] = config.partnerId; + } + else + { + std::cout << "Sift: Account ID, Device ID, or Partner ID is empty for: " << event.eventName << std::endl; + } - eventJson["event_payload"] = JsonObject(event.eventPayload); + eventJson["app_name"] = config.deviceAppName; + eventJson["app_ver"] = config.deviceAppVersion; + eventJson["device_model"] = config.deviceModel; + eventJson["device_timezone"] = std::stoi(config.deviceTimeZone); + eventJson["platform"] = config.platform; + eventJson["os_ver"] = config.deviceSoftwareVersion; + eventJson["device_language"] = ""; // Empty for now + eventJson["timestamp"] = event.epochTimestamp; + eventJson["device_type"] = config.deviceType; + } // TODO: push to persistent queue instead of sending array JsonArray eventArray = JsonArray(); diff --git a/Analytics/Implementation/Backend/Sift/SiftBackend.h b/Analytics/Implementation/Backend/Sift/SiftBackend.h index 41a1bf4519..cac39d91dd 100644 --- a/Analytics/Implementation/Backend/Sift/SiftBackend.h +++ b/Analytics/Implementation/Backend/Sift/SiftBackend.h @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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. + */ #pragma once #include "../AnalyticsBackend.h" diff --git a/Analytics/Implementation/Backend/Sift/SiftConfig.cpp b/Analytics/Implementation/Backend/Sift/SiftConfig.cpp index 8538fcf351..73d1824dca 100644 --- a/Analytics/Implementation/Backend/Sift/SiftConfig.cpp +++ b/Analytics/Implementation/Backend/Sift/SiftConfig.cpp @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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 "SiftConfig.h" #include "UtilsLogging.h" @@ -32,12 +50,14 @@ namespace WPEFramework SiftConfig() : Core::JSON::Container() + , Schema2(false) , CommonSchema() , Env() , ProductName() , LoggerName() , LoggerVersion() { + Add(_T("schema2"), &Schema2); Add(_T("commonschema"), &CommonSchema); Add(_T("env"), &Env); Add(_T("productname"), &ProductName); @@ -47,6 +67,7 @@ namespace WPEFramework ~SiftConfig() = default; public: + Core::JSON::Boolean Schema2; Core::JSON::String CommonSchema; Core::JSON::String Env; Core::JSON::String ProductName; @@ -299,78 +320,114 @@ namespace WPEFramework mMutex.lock(); - bool activatedValid = mConfig.activated? - (!mConfig.xboDeviceId.empty() && !mConfig.xboAccountId.empty()) : true; - - //Sift 2.0 required fields - bool valid = ( !mConfig.commonSchema.empty() - && !mConfig.productName.empty() - && !mConfig.productVersion.empty() - && !mConfig.loggerName.empty() - && !mConfig.loggerVersion.empty() - && !mConfig.partnerId.empty() - && activatedValid - && !mConfig.deviceModel.empty() - && !mConfig.deviceType.empty() - && !mConfig.deviceTimeZone.empty() - && !mConfig.deviceOsName.empty() - && !mConfig.deviceOsVersion.empty() - && !mConfig.platform.empty() - && !mConfig.deviceManufacturer.empty() - && !mConfig.sessionId.empty() - && !mConfig.proposition.empty() - && !mConfig.deviceSerialNumber.empty() - && !mConfig.deviceMacAddress.empty() ); - - LOGINFO( " commonSchema: %s," - " productName: %s," - " productVersion: %s," - " loggerName: %s," - " loggerVersion: %s," - " partnerId: %s," - " activatedValid %d," - " deviceModel: %s," - " deviceType: %s," - " deviceTimeZone: %s," - " deviceOsName: %s," - " deviceOsVersion: %s," - " platform: %s," - " deviceManufacturer: %s," - " sessionId: %s," - " proposition: %s," - " deviceSerialNumber: %s," - " deviceMacAddress: %s,", - mConfig.commonSchema.c_str(), - mConfig.productName.c_str(), - mConfig.productVersion.c_str(), - mConfig.loggerName.c_str(), - mConfig.loggerVersion.c_str(), - mConfig.partnerId.c_str(), - activatedValid, - mConfig.deviceModel.c_str(), - mConfig.deviceType.c_str(), - mConfig.deviceTimeZone.c_str(), - mConfig.deviceOsName.c_str(), - mConfig.deviceOsVersion.c_str(), - mConfig.platform.c_str(), - mConfig.deviceManufacturer.c_str(), - mConfig.sessionId.c_str(), - mConfig.proposition.c_str(), - mConfig.deviceSerialNumber.c_str(), - mConfig.deviceMacAddress.c_str()); + bool valid = false; + + if (mConfig.schema2Enabled) + { + //Sift 2.0 requires attributes + bool activatedValid = mConfig.activated ? (!mConfig.xboDeviceId.empty() + && !mConfig.xboAccountId.empty()) : true; + + valid = ( !mConfig.url.empty() + && !mConfig.apiKey.empty() + && !mConfig.sessionId.empty() + && !mConfig.commonSchema.empty() + && !mConfig.productName.empty() + && !mConfig.productVersion.empty() + && !mConfig.loggerName.empty() + && !mConfig.loggerVersion.empty() + && !mConfig.partnerId.empty() + && activatedValid + && !mConfig.deviceModel.empty() + && !mConfig.deviceType.empty() + && !mConfig.deviceTimeZone.empty() + && !mConfig.deviceOsName.empty() + && !mConfig.deviceOsVersion.empty() + && !mConfig.platform.empty() + && !mConfig.deviceManufacturer.empty() + && !mConfig.sessionId.empty() + && !mConfig.proposition.empty() + && !mConfig.deviceSerialNumber.empty() + && !mConfig.deviceMacAddress.empty()); + + LOGINFO(" commonSchema: %s," + " productName: %s," + " productVersion: %s," + " loggerName: %s," + " loggerVersion: %s," + " partnerId: %s," + " activatedValid %d," + " deviceModel: %s," + " deviceType: %s," + " deviceTimeZone: %s," + " deviceOsName: %s," + " deviceOsVersion: %s," + " platform: %s," + " deviceManufacturer: %s," + " sessionId: %s," + " proposition: %s," + " deviceSerialNumber: %s," + " deviceMacAddress: %s,", + mConfig.commonSchema.c_str(), + mConfig.productName.c_str(), + mConfig.productVersion.c_str(), + mConfig.loggerName.c_str(), + mConfig.loggerVersion.c_str(), + mConfig.partnerId.c_str(), + activatedValid, + mConfig.deviceModel.c_str(), + mConfig.deviceType.c_str(), + mConfig.deviceTimeZone.c_str(), + mConfig.deviceOsName.c_str(), + mConfig.deviceOsVersion.c_str(), + mConfig.platform.c_str(), + mConfig.deviceManufacturer.c_str(), + mConfig.sessionId.c_str(), + mConfig.proposition.c_str(), + mConfig.deviceSerialNumber.c_str(), + mConfig.deviceMacAddress.c_str()); + + if (valid) + { + if (mConfig.deviceType == "TV") + { + mConfig.deviceType = "IPTV"; + } + else if (mConfig.deviceType == "IPSETTOPBOX") + { + mConfig.deviceType = "IPSTB"; + } + } + } + else //Sift 1.0 required attributes + { + valid = (!mConfig.url.empty() + && !mConfig.apiKey.empty() + && !mConfig.sessionId.empty() + && !mConfig.productName.empty() + && !mConfig.deviceAppName.empty() + && !mConfig.deviceAppVersion.empty() + && !mConfig.deviceModel.empty() + && !mConfig.deviceTimeZone.empty() + && !mConfig.platform.empty() + && !mConfig.deviceSoftwareVersion.empty() + && !mConfig.deviceType.empty()); + + LOGINFO("%s, %s, %s, %s, %s, %s, %s", + mConfig.productName.c_str(), + mConfig.deviceAppName.c_str(), + mConfig.deviceAppVersion.c_str(), + mConfig.deviceModel.c_str(), + mConfig.platform.c_str(), + mConfig.deviceSoftwareVersion.c_str(), + mConfig.deviceType.c_str()); + } if (valid) { - if (mConfig.deviceType == "TV") - { - mConfig.deviceType = "IPTV"; - } - else if (mConfig.deviceType == "IPSETTOPBOX") - { - mConfig.deviceType = "IPSTB"; - } config = mConfig; } + mMutex.unlock(); return valid; } @@ -383,11 +440,10 @@ namespace WPEFramework void SiftConfig::InitializeKeysMap() { - //Based on SIFT 2.0 properties - //Device info based on SIFT 2.0 properties + //SIFT 2.0 attributes from persistent storage mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceHardwareModel"] = &mConfig.deviceModel; mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceType"] = &mConfig.deviceType; - mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["devicePlatform"] = &mConfig.platform;//TODO: in ripple equal to 'proposition' + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["devicePlatform"] = &mConfig.platform; mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["modelNumber"] = &mConfig.deviceOsVersion; mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["manufacturer"] = &mConfig.deviceManufacturer; mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["serialNumber"] = &mConfig.deviceSerialNumber; @@ -406,7 +462,13 @@ namespace WPEFramework //TODO: Values provided by AS but should be provided by RDK mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceTimeZone"] = &mConfig.deviceTimeZone; - + //SIFT 1.0 attributes from persistent storage + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceSoftwareVersion"] = &mConfig.deviceSoftwareVersion; + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceAppName"] = &mConfig.deviceAppName; + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceAppVersion"] = &mConfig.deviceAppVersion; + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["accountId"] = &mConfig.accountId; + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["deviceId"] = &mConfig.deviceId; + mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["partnerId"] = &mConfig.partnerId; //TODO: Sift cloud configuration - move to plugin config? (at least url) mKeysMap[PERSISTENT_STORE_ANALYTICS_NAMESPACE]["sift_url"] = &mConfig.url; @@ -429,12 +491,13 @@ namespace WPEFramework } else { + mConfig.schema2Enabled = config.Sift.Schema2.Value(); mConfig.commonSchema = config.Sift.CommonSchema.Value(); mConfig.env = config.Sift.Env.Value(); - mConfig.productName = "entos-immerse";//config.Sift.ProductName.Value(); + mConfig.productName = config.Sift.ProductName.Value(); mConfig.loggerName = config.Sift.LoggerName.Value(); mConfig.loggerVersion = config.Sift.LoggerVersion.Value(); - mConfig.deviceOsName = "rdk";//config.DeviceOsName.Value(); + mConfig.deviceOsName = config.DeviceOsName.Value(); SYSLOG(Logging::Startup, (_T("Parsed config: '%s', '%s', '%s', '%s', '%s', '%s'."), mConfig.commonSchema.c_str(), mConfig.env.c_str(), diff --git a/Analytics/Implementation/Backend/Sift/SiftConfig.h b/Analytics/Implementation/Backend/Sift/SiftConfig.h index 8029a8ebc7..75c92cfc35 100644 --- a/Analytics/Implementation/Backend/Sift/SiftConfig.h +++ b/Analytics/Implementation/Backend/Sift/SiftConfig.h @@ -1,3 +1,21 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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 + * + * http://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. + */ #pragma once #include "../../../Module.h" @@ -15,17 +33,18 @@ namespace WPEFramework public: struct Config { + bool schema2Enabled; // Sift 2.0 decoration std::string commonSchema; std::string env; std::string productName; - std::string productVersion; //TODO: in persistent or /system/information/entertainmentOSVersion + std::string productVersion; std::string loggerName; std::string loggerVersion; - std::string partnerId; // from authservice - std::string xboAccountId; // from authservice ServiceAccountId - std::string xboDeviceId; // from authservice XDeviceId - bool activated; // from authservice IF (authservice getActivationStatus returns activation-state = activated) then TRUE + std::string partnerId; + std::string xboAccountId; + std::string xboDeviceId; + bool activated; std::string deviceModel; std::string deviceType; std::string deviceTimeZone; @@ -33,15 +52,15 @@ namespace WPEFramework std::string deviceOsVersion; std::string platform; std::string deviceManufacturer; - bool authenticated; // set to true if the event is to be SAT authenticated - std::string sessionId; // TODO: should be auto generated, but for now we will use sessionId from file + bool authenticated; + std::string sessionId; std::string proposition; std::string retailer; std::string jvAgent; std::string coam; - std::string deviceSerialNumber; // /system/information serialNumber + std::string deviceSerialNumber; std::string deviceFriendlyName; - std::string deviceMacAddress; // /system/information MACAddress + std::string deviceMacAddress; std::string country; std::string region; std::string accountType; @@ -51,6 +70,13 @@ namespace WPEFramework // TODO: read in SiftUploader std::string url; std::string apiKey; + + // Sift 1.0 atributes that left + std::string deviceSoftwareVersion; + std::string deviceAppName; + std::string deviceAppVersion; + std::string accountId; + std::string deviceId; }; SiftConfig(const SiftConfig &) = delete;