Skip to content

Commit

Permalink
RDK-51273: Support Sift 1.0 by default, add License headers
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 committed Aug 28, 2024
1 parent 84cdb21 commit 37d0037
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 163 deletions.
1 change: 1 addition & 0 deletions Analytics/Analytics.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@")
Expand Down
3 changes: 2 additions & 1 deletion Analytics/Analytics.config
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
3 changes: 2 additions & 1 deletion Analytics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 18 additions & 0 deletions Analytics/Implementation/AnalyticsImplementation.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
18 changes: 18 additions & 0 deletions Analytics/Implementation/AnalyticsImplementation.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
18 changes: 18 additions & 0 deletions Analytics/Implementation/Backend/AnalyticsBackend.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
18 changes: 18 additions & 0 deletions Analytics/Implementation/Backend/AnalyticsBackend.h
Original file line number Diff line number Diff line change
@@ -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 <map>
Expand Down
16 changes: 16 additions & 0 deletions Analytics/Implementation/Backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
16 changes: 16 additions & 0 deletions Analytics/Implementation/Backend/Sift/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
209 changes: 130 additions & 79 deletions Analytics/Implementation/Backend/Sift/SiftBackend.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 37d0037

Please sign in to comment.