From 2ee9ce05472c8f5640a0bd37ef93ef71026a20a4 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Wed, 28 Aug 2024 19:53:25 +0300 Subject: [PATCH 1/8] fixed compilation for blueprint based projects --- Source/ConfigCat/Public/ConfigCatNetworkAdapter.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/ConfigCat/Public/ConfigCatNetworkAdapter.h b/Source/ConfigCat/Public/ConfigCatNetworkAdapter.h index 4edadba..d45072a 100644 --- a/Source/ConfigCat/Public/ConfigCatNetworkAdapter.h +++ b/Source/ConfigCat/Public/ConfigCatNetworkAdapter.h @@ -5,6 +5,8 @@ #include #include +#include + namespace configcat { class PollingMode; From 080c3f2fa1ddf3393e7b22581b5a36d6f49368c4 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Wed, 28 Aug 2024 19:54:10 +0300 Subject: [PATCH 2/8] replaced ensure with error --- Source/ConfigCat/Private/ConfigCatSubsystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index 6b9ba75..3b5786b 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -29,12 +29,12 @@ namespace { bool EnsureConfigCatClient(const std::shared_ptr& Client) { - if (ensure(Client)) + if (Client) { return true; } - UE_LOG(LogConfigCat, Warning, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); + UE_LOG(LogConfigCat, Error, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); return false; } From 28cd0f95a1bd6f1dc5d9069a3b6cc43eda074865 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Wed, 28 Aug 2024 19:56:58 +0300 Subject: [PATCH 3/8] added more visible error --- Source/ConfigCat/Private/ConfigCatSubsystem.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index 3b5786b..9626552 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -35,6 +35,11 @@ namespace } UE_LOG(LogConfigCat, Error, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); + if(GEngine) + { + GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); + } + return false; } From a6b0575d26d033bd61271455f76d103cd229fd4d Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Wed, 28 Aug 2024 20:00:16 +0300 Subject: [PATCH 4/8] added missing SDK key error message --- Source/ConfigCat/Private/ConfigCatSubsystem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index 9626552..27d0086 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -284,7 +284,12 @@ void UConfigCatSubsystem::Initialize(FSubsystemCollectionBase& Collection) const UConfigCatSettings* ConfigCatSettings = GetDefault(); if (!ConfigCatSettings || ConfigCatSettings->SdkKey.IsEmpty()) { - UE_LOG(LogConfigCat, Warning, TEXT("Empty SdkKey detected. Please set your SdkKey in the Project Settings.")); + if(GEngine) + { + GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings.")); + } + + UE_LOG(LogConfigCat, Error, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings.")); return; } From 0d15e155ff38aabcbbbaa2e1e7dd084268eb5f64 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Sat, 31 Aug 2024 09:48:51 +0300 Subject: [PATCH 5/8] refactor error printing --- .../ConfigCat/Private/ConfigCatSubsystem.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index 27d0086..d73f313 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -27,6 +27,15 @@ using namespace configcat; namespace { + void PrintError(const FString& ErrorMessage) + { + if (GEngine) + { + GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("[ConfigCat] %s"), *ErrorMessage)); + } + UE_LOG(LogConfigCat, Error, TEXT("%s"), *ErrorMessage); + } + bool EnsureConfigCatClient(const std::shared_ptr& Client) { if (Client) @@ -34,12 +43,7 @@ namespace return true; } - UE_LOG(LogConfigCat, Error, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); - if(GEngine) - { - GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Trying to access the ConfigCatClient before initialization or after shutdown.")); - } - + PrintError(TEXT("Trying to access the client before initialization or after shutdown.")); return false; } @@ -284,12 +288,7 @@ void UConfigCatSubsystem::Initialize(FSubsystemCollectionBase& Collection) const UConfigCatSettings* ConfigCatSettings = GetDefault(); if (!ConfigCatSettings || ConfigCatSettings->SdkKey.IsEmpty()) { - if(GEngine) - { - GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings.")); - } - - UE_LOG(LogConfigCat, Error, TEXT("ConfigCat SdkKey missing. Please set your SdkKey in the Project Settings.")); + PrintError(TEXT("SdkKey missing. Please set your SdkKey in the Project Settings.")); return; } From 8bd7efdbd9266809b3cab373ce8e31eee52ee907 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Sat, 31 Aug 2024 09:50:20 +0300 Subject: [PATCH 6/8] added formatting corrections --- .../ConfigCat/Private/ConfigCatSubsystem.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index d73f313..bf42445 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -50,7 +50,7 @@ namespace template T GetValue(const std::shared_ptr& Client, FString Key, T DefaultValue, const UConfigCatUserWrapper* User) { - if(!EnsureConfigCatClient(Client)) + if (!EnsureConfigCatClient(Client)) { return DefaultValue; } @@ -63,7 +63,7 @@ namespace template UConfigCatEvaluationWrapper* GetEvaluationDetails(const std::shared_ptr& Client, FString Key, T DefaultValue, const UConfigCatUserWrapper* User) { - if(!EnsureConfigCatClient(Client)) + if (!EnsureConfigCatClient(Client)) { return {}; } @@ -107,7 +107,7 @@ FString UConfigCatSubsystem::GetStringValue(const FString& Key, const FString& D UConfigCatValueWrapper* UConfigCatSubsystem::GetConfigValue(const FString& Key, const UConfigCatUserWrapper* User) const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return {}; } @@ -141,7 +141,7 @@ UConfigCatEvaluationWrapper* UConfigCatSubsystem::GetStringValueDetails(const FS TArray UConfigCatSubsystem::GetAllKeys() const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return {}; } @@ -159,7 +159,7 @@ TArray UConfigCatSubsystem::GetAllKeys() const bool UConfigCatSubsystem::GetKeyAndValue(const FString& VariationId, FString& OutKey, UConfigCatValueWrapper*& OutValue) const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return false; } @@ -180,7 +180,7 @@ bool UConfigCatSubsystem::GetKeyAndValue(const FString& VariationId, FString& Ou TMap UConfigCatSubsystem::GetAllValues(const UConfigCatUserWrapper* User) const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return {}; } @@ -198,7 +198,7 @@ TMap UConfigCatSubsystem::GetAllValues(const U TArray UConfigCatSubsystem::GetAllValueDetails(const UConfigCatUserWrapper* User) const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return {}; } @@ -216,7 +216,7 @@ TArray UConfigCatSubsystem::GetAllValueDetails(con void UConfigCatSubsystem::ForceRefresh() { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return; } @@ -226,7 +226,7 @@ void UConfigCatSubsystem::ForceRefresh() void UConfigCatSubsystem::SetDefaultUser(const UConfigCatUserWrapper* User) { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return; } @@ -241,7 +241,7 @@ void UConfigCatSubsystem::SetDefaultUser(const UConfigCatUserWrapper* User) void UConfigCatSubsystem::ClearDefaultUser() { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return; } @@ -251,7 +251,7 @@ void UConfigCatSubsystem::ClearDefaultUser() void UConfigCatSubsystem::SetOnline() { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return; } @@ -261,7 +261,7 @@ void UConfigCatSubsystem::SetOnline() void UConfigCatSubsystem::SetOffline() { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return; } @@ -271,7 +271,7 @@ void UConfigCatSubsystem::SetOffline() bool UConfigCatSubsystem::IsOffline() const { - if(!EnsureConfigCatClient(ConfigCatClient)) + if (!EnsureConfigCatClient(ConfigCatClient)) { return true; } @@ -345,7 +345,7 @@ void UConfigCatSubsystem::Initialize(FSubsystemCollectionBase& Collection) ConfigCatClient = ConfigCatClient::get(SdkKey, &Options); #ifdef CONFIGCAT_HTTPTHREAD_WORKAROUND - if(ConfigCatSettings->PollingMode == EPollingMode::Auto) + if (ConfigCatSettings->PollingMode == EPollingMode::Auto) { ForceRefresh(); } From f4061ec23606c276fe32b91f7c86100a2f28c932 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Sat, 31 Aug 2024 10:04:17 +0300 Subject: [PATCH 7/8] added missing include --- Source/ConfigCat/Private/ConfigCatSubsystem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp index bf42445..930443a 100644 --- a/Source/ConfigCat/Private/ConfigCatSubsystem.cpp +++ b/Source/ConfigCat/Private/ConfigCatSubsystem.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "ConfigCat.h" #include "ConfigCatLog.h" From c391ecf84a87d20c7ac90024e7ec2cffb7dbfc0c Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Mon, 2 Sep 2024 16:25:25 +0300 Subject: [PATCH 8/8] version bump --- ConfigCat.uplugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigCat.uplugin b/ConfigCat.uplugin index 06cd9e3..452b0b5 100644 --- a/ConfigCat.uplugin +++ b/ConfigCat.uplugin @@ -1,6 +1,6 @@ { "FileVersion": 3, - "VersionName": "2.1.6", + "VersionName": "2.1.7", "EngineVersion": "5.4", "FriendlyName": "ConfigCat", "Description": "ConfigCat is a hosted service for feature flag and configuration management. It lets you decouple feature releases from code deployments.",