Skip to content

Commit d0ce873

Browse files
authored
5.0.0 release prep (#30)
* rename remote configs members * split remote configs in game and annotation cfgs * add 5.0.0 release notes
1 parent d76234d commit d0ce873

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 5.0.0
4+
5+
### Added
6+
7+
- **Remote Configs With JSON**: Remote Configs now support JSON values, allowing for more complex configurations.
8+
- **Playtime Metrics API**: Introduced new API to get total playtime and playtime in the current session.
9+
310
## 4.1.0
411

512
### Added

source/gameanalytics/GACommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace gameanalytics
8585
class GAState;
8686
}
8787

88-
constexpr const char* GA_VERSION_STR = "cpp 4.1.0";
88+
constexpr const char* GA_VERSION_STR = "cpp 5.0.0";
8989

9090
constexpr int MAX_CUSTOM_FIELDS_COUNT = 50;
9191
constexpr int MAX_CUSTOM_FIELDS_KEY_LENGTH = 64;

source/gameanalytics/GAState.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace gameanalytics
411411
out["user_id"] = getUserId();
412412

413413
// remote configs configurations
414-
if(getInstance()._configurations.is_object() && !getInstance()._configurations.empty())
414+
if(getInstance()._trackingRemoteConfigsJson.is_array() && !getInstance()._trackingRemoteConfigsJson.empty())
415415
{
416416
out["configurations_v3"] = getInstance().getRemoteConfigAnnotations();
417417
}
@@ -895,7 +895,7 @@ namespace gameanalytics
895895

896896
json contents;
897897

898-
for(auto& obj : getInstance()._configurations)
898+
for(auto& obj : getInstance()._gameRemoteConfigsJson)
899899
{
900900
if(obj.contains("key") && obj.contains("value"))
901901
{
@@ -910,10 +910,34 @@ namespace gameanalytics
910910
return contents.dump(JSON_PRINT_INDENT);
911911
}
912912

913+
void GAState::buildRemoteConfigsJsons(const json& remoteCfgs)
914+
{
915+
_gameRemoteConfigsJson = json::array();
916+
_trackingRemoteConfigsJson = json::array();
917+
918+
for (const auto& configuration : remoteCfgs)
919+
{
920+
_gameRemoteConfigsJson.push_back({
921+
{"key", configuration["key"]},
922+
{"value", configuration["value"]}
923+
});
924+
925+
_trackingRemoteConfigsJson.push_back({
926+
{"key", configuration["key"]},
927+
{"id", configuration["id"]},
928+
{"vsn", configuration["vsn"]}
929+
});
930+
}
931+
932+
logging::GALogger::d("Remote configs: %s", _gameRemoteConfigsJson.dump(JSON_PRINT_INDENT).c_str());
933+
logging::GALogger::d("Remote configs for tracking: %s", _trackingRemoteConfigsJson.dump(JSON_PRINT_INDENT).c_str());
934+
logging::GALogger::i("Remote configs ready with %zu configurations", _gameRemoteConfigsJson.size());
935+
}
936+
913937
void GAState::populateConfigurations(json& sdkConfig)
914938
{
915-
std::lock_guard<std::recursive_mutex> guard(_mtx);
916-
_configurations = {};
939+
940+
json _tempRemoteConfigsJson = {};
917941

918942
try
919943
{
@@ -933,16 +957,18 @@ namespace gameanalytics
933957

934958
if (!key.empty() && configuration.contains("value") && client_ts_adjusted > start_ts && client_ts_adjusted < end_ts)
935959
{
936-
_configurations[key] = configuration;
960+
_tempRemoteConfigsJson[key] = configuration;
937961
logging::GALogger::d("configuration added: %s", configuration.dump(JSON_PRINT_INDENT).c_str());
938962
}
939963
}
940964
}
941965
}
942966

967+
buildRemoteConfigsJsons(_tempRemoteConfigsJson);
968+
943969
_remoteConfigsIsReady = true;
944970

945-
std::string const configStr = _configurations.dump();
971+
std::string const configStr = _gameRemoteConfigsJson.dump();
946972
for (auto& listener : _remoteConfigsListeners)
947973
{
948974
listener->onRemoteConfigsUpdated(configStr);
@@ -1160,18 +1186,7 @@ namespace gameanalytics
11601186

11611187
json GAState::getRemoteConfigAnnotations()
11621188
{
1163-
json configs;
1164-
for(json& obj : _configurations)
1165-
{
1166-
json cfg;
1167-
cfg["vsn"] = utilities::getOptionalValue<int>(obj, "vsn", 0);
1168-
cfg["key"] = utilities::getOptionalValue<std::string>(obj, "key", "");
1169-
cfg["id"] = utilities::getOptionalValue<std::string>(obj, "id", "");
1170-
1171-
configs.push_back(cfg);
1172-
}
1173-
1174-
return configs;
1189+
return _trackingRemoteConfigsJson;
11751190
}
11761191
}
11771192
}

source/gameanalytics/GAState.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ namespace gameanalytics
150150
inline static T getRemoteConfigsValue(std::string const& key, T const& defaultValue)
151151
{
152152
std::lock_guard<std::recursive_mutex> lg(getInstance()._mtx);
153-
if(getInstance()._configurations.contains(key))
153+
if(getInstance()._gameRemoteConfigsJson.contains(key))
154154
{
155-
json& config = getInstance()._configurations[key];
155+
json& config = getInstance()._gameRemoteConfigsJson[key];
156156
T value = utilities::getOptionalValue<T>(config, "value", defaultValue);
157157
return value;
158158
}
@@ -210,6 +210,8 @@ namespace gameanalytics
210210

211211
void addErrorEvent(EGAErrorSeverity severity, std::string const& message);
212212

213+
void buildRemoteConfigsJsons(const json& remoteCfgs);
214+
213215
threading::GAThreading _gaThread;
214216
events::GAEvents _gaEvents;
215217
device::GADevice _gaDevice;
@@ -271,7 +273,9 @@ namespace gameanalytics
271273

272274
bool _enableIdTracking = true;
273275

274-
json _configurations;
276+
json _gameRemoteConfigsJson;
277+
json _trackingRemoteConfigsJson;
278+
275279
bool _remoteConfigsIsReady;
276280
std::vector<std::shared_ptr<IRemoteConfigsListener>> _remoteConfigsListeners;
277281
std::recursive_mutex _mtx;

0 commit comments

Comments
 (0)