@@ -411,7 +411,7 @@ namespace gameanalytics
411411 out[" user_id" ] = getUserId ();
412412
413413 // remote configs configurations
414- if (getInstance ()._gameRemoteConfigsJson . is_object () && !getInstance ()._gameRemoteConfigsJson .empty ())
414+ if (getInstance ()._trackingRemoteConfigsJson . is_array () && !getInstance ()._trackingRemoteConfigsJson .empty ())
415415 {
416416 out[" configurations_v3" ] = getInstance ().getRemoteConfigAnnotations ();
417417 }
@@ -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- _gameRemoteConfigsJson = {};
939+
940+ json _tempRemoteConfigsJson = {};
917941
918942 try
919943 {
@@ -933,13 +957,15 @@ namespace gameanalytics
933957
934958 if (!key.empty () && configuration.contains (" value" ) && client_ts_adjusted > start_ts && client_ts_adjusted < end_ts)
935959 {
936- _gameRemoteConfigsJson [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
945971 std::string const configStr = _gameRemoteConfigsJson.dump ();
@@ -1160,18 +1186,7 @@ namespace gameanalytics
11601186
11611187 json GAState::getRemoteConfigAnnotations ()
11621188 {
1163- json configs;
1164- for (json& obj : _gameRemoteConfigsJson)
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}
0 commit comments