@@ -413,7 +413,7 @@ namespace gameanalytics
413413 // remote configs configurations
414414 if (getInstance ()._configurations .is_object () && !getInstance ()._configurations .empty ())
415415 {
416- out[" configurations " ] = getInstance ()._configurations ;
416+ out[" configurations_v3 " ] = getInstance ().getRemoteConfigAnnotations () ;
417417 }
418418
419419 out[" sdk_version" ] = device::GADevice::getRelevantSdkVersion ();
@@ -865,14 +865,6 @@ namespace gameanalytics
865865 return getInstance ()._sessionStart != 0 ;
866866 }
867867
868- std::string GAState::getRemoteConfigsStringValue (std::string const & key, std::string const & defaultValue)
869- {
870- std::lock_guard<std::recursive_mutex> lg (getInstance ()._mtx );
871- std::string const value = utilities::getOptionalValue (getInstance ()._configurations , key, defaultValue);
872-
873- return value;
874- }
875-
876868 bool GAState::isRemoteConfigsReady ()
877869 {
878870 return getInstance ()._remoteConfigsIsReady ;
@@ -900,12 +892,28 @@ namespace gameanalytics
900892 std::string GAState::getRemoteConfigsContentAsString ()
901893 {
902894 std::lock_guard<std::recursive_mutex> lg (getInstance ()._mtx );
903- return getInstance ()._configurations .dump (JSON_PRINT_INDENT);
895+
896+ json contents;
897+
898+ for (auto & obj : getInstance ()._configurations )
899+ {
900+ if (obj.contains (" key" ) && obj.contains (" value" ))
901+ {
902+ std::string key = utilities::getOptionalValue<std::string>(obj, " key" , " " );
903+ if (!key.empty ())
904+ {
905+ contents[key] = obj[" value" ];
906+ }
907+ }
908+ }
909+
910+ return contents.dump (JSON_PRINT_INDENT);
904911 }
905912
906913 void GAState::populateConfigurations (json& sdkConfig)
907914 {
908915 std::lock_guard<std::recursive_mutex> guard (_mtx);
916+ _configurations = {};
909917
910918 try
911919 {
@@ -918,21 +926,15 @@ namespace gameanalytics
918926 if (!configuration.empty ())
919927 {
920928 std::string key = utilities::getOptionalValue<std::string>(configuration, " key" , " " );
921-
922929 int64_t start_ts = utilities::getOptionalValue<int64_t >(configuration, " start_ts" , std::numeric_limits<int64_t >::min ());
923-
924930 int64_t end_ts = utilities::getOptionalValue<int64_t >(configuration, " end_ts" , std::numeric_limits<int64_t >::max ());
925931
926932 int64_t client_ts_adjusted = getClientTsAdjusted ();
927933
928934 if (!key.empty () && configuration.contains (" value" ) && client_ts_adjusted > start_ts && client_ts_adjusted < end_ts)
929935 {
930- json& value = configuration[" value" ];
931- if (value.is_string () || value.is_number ())
932- {
933- _configurations[key] = value;
934- logging::GALogger::d (" configuration added: %s" , configuration.dump (JSON_PRINT_INDENT).c_str ());
935- }
936+ _configurations[key] = configuration;
937+ logging::GALogger::d (" configuration added: %s" , configuration.dump (JSON_PRINT_INDENT).c_str ());
936938 }
937939 }
938940 }
@@ -1155,5 +1157,21 @@ namespace gameanalytics
11551157
11561158 return cleanedFields;
11571159 }
1160+
1161+ json GAState::getRemoteConfigAnnotations ()
1162+ {
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;
1175+ }
11581176 }
11591177}
0 commit comments