Skip to content

Commit 134c11d

Browse files
authored
Release v5.0.0 (#27)
version 5.0.0
1 parent b6c8168 commit 134c11d

File tree

15 files changed

+193
-88
lines changed

15 files changed

+193
-88
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.1
411

512
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Example:
123123
Example:
124124

125125
``` c++
126-
gameanalytics::GameAnalytics::initialize("<your game key>", "<your secret key");
126+
gameanalytics::GameAnalytics::initialize("<your game key>", "<your secret key>");
127127
```
128128
129129
### Send events

include/GameAnalytics/GameAnalytics.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ namespace gameanalytics
103103
static void endSession();
104104

105105
static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue = "");
106+
static std::string getRemoteConfigsValueAsJson(std::string const& key);
107+
106108

107109
static bool isRemoteConfigsReady();
108110
static void addRemoteConfigsListener(const std::shared_ptr<IRemoteConfigsListener> &listener);
@@ -116,6 +118,9 @@ namespace gameanalytics
116118
static std::string getABTestingId();
117119
static std::string getABTestingVariantId();
118120

121+
static int64_t getElapsedSessionTime();
122+
static int64_t getElapsedTimeFromAllSessions();
123+
119124
// game state changes
120125
// will affect how session is started / ended
121126
static void onResume();
@@ -125,10 +130,9 @@ namespace gameanalytics
125130
static bool isThreadEnding();
126131

127132
private:
128-
static bool _endThread;
129133

130-
static bool isSdkReady(bool needsInitialized);
131-
static bool isSdkReady(bool needsInitialized, bool warn);
132-
static bool isSdkReady(bool needsInitialized, bool warn, std::string const& message);
134+
static bool _endThread;
135+
static bool isSdkReady(bool needsInitialized, bool warn = true, std::string const& message = "");
133136
};
137+
134138
} // namespace gameanalytics
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@
219219
#define MINIZ_HAS_64BIT_REGISTERS 1
220220
#endif
221221

222-
#ifdef __cplusplus
223-
extern "C" {
224-
#endif
222+
namespace gameanalytics {
223+
namespace utilities {
224+
namespace zip {
225225

226226
// ------------------- zlib-style API Definitions.
227227

@@ -919,10 +919,6 @@ mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
919919
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
920920
#endif // #ifndef MINIZ_NO_ZLIB_APIS
921921

922-
#ifdef __cplusplus
923-
}
924-
#endif
925-
926922
#endif // MINIZ_HEADER_INCLUDED
927923

928924
// ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.)
@@ -968,10 +964,6 @@ typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1];
968964
#define MZ_FORCEINLINE inline
969965
#endif
970966

971-
#ifdef __cplusplus
972-
extern "C" {
973-
#endif
974-
975967
// ------------------- zlib-style API's
976968

977969
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
@@ -4882,12 +4874,12 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char
48824874

48834875
#endif // #ifndef MINIZ_NO_ARCHIVE_APIS
48844876

4885-
#ifdef __cplusplus
4886-
}
4887-
#endif
4888-
48894877
#endif // MINIZ_HEADER_FILE_ONLY
48904878

4879+
} // namespace zip
4880+
} // namespace utilities
4881+
} // namespace gameanalytics
4882+
48914883
/*
48924884
This is free and unencumbered software released into the public domain.
48934885

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.1";
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/GADevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace gameanalytics
7878
std::string _osVersion;
7979
std::string _deviceModel;
8080
std::string _deviceManufacturer;
81+
std::string _gpu;
8182

8283
std::string _writablepath;
8384
bool _writablepathStatus{false};

source/gameanalytics/GAEvents.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ namespace gameanalytics
116116

117117
try
118118
{
119-
int64_t sessionLength = state.calculateSessionLength();
119+
// get session length in seconds
120+
int64_t sessionLength = state.calculateSessionLength<std::chrono::seconds>();
120121

121122
if(sessionLength < 0ll)
122123
{

source/gameanalytics/GAHTTPApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace gameanalytics
5656
std::string gameKey = state::GAState::getGameKey();
5757

5858
// Generate URL
59-
std::string url = remoteConfigsBaseUrl + "/" + initializeUrlPath + "?game_key=" + gameKey + "&interval_seconds=0&configs_hash=" + configsHash;
59+
std::string url = remoteConfigsBaseUrl + "/" + initializeUrlPath + "?game_key=" + gameKey + "&interval_seconds=0&configs_hash=" + configsHash + "&config_vsn_supported=3";
6060

6161
logging::GALogger::d("Sending 'init' URL: %s", url.c_str());
6262

source/gameanalytics/GAHealth.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ namespace gameanalytics
2424
void GAHealth::doFpsReading(float fps)
2525
{
2626
int fpsBucket = std::round(fps);
27-
if(fpsBucket >= 0 && fpsBucket < MAX_FPS_COUNT)
28-
{
29-
_fpsReadings[fpsBucket]++;
30-
}
27+
fpsBucket = std::clamp(fpsBucket, 0, MAX_FPS_VALUE);
28+
29+
_fpsReadings[fpsBucket]++;
3130
}
3231

3332
int GAHealth::getMemoryPercent(int64_t memory)
@@ -65,6 +64,7 @@ namespace gameanalytics
6564
{
6665
utilities::addIfNotEmpty(out, "cpu_model", _cpuModel);
6766
utilities::addIfNotEmpty(out, "hardware", _hardware);
67+
utilities::addIfNotEmpty(out, "gpu_model", _gpuModel);
6868

6969
if(_numCores > 0)
7070
{
@@ -169,7 +169,6 @@ namespace gameanalytics
169169
}
170170
}
171171
);
172-
173172
}
174173
}
175174
}

source/gameanalytics/GAHealth.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace gameanalytics
2929

3030
protected:
3131

32-
static constexpr size_t MAX_FPS_COUNT = 120 + 1;
32+
static constexpr int MAX_FPS_VALUE = 120;
33+
static constexpr size_t MAX_FPS_COUNT = MAX_FPS_VALUE + 1;
3334
static constexpr size_t MAX_MEMORY_COUNT = 100 + 1;
3435

3536
static constexpr std::chrono::milliseconds MEMORY_TRACK_FREQ {5000};

0 commit comments

Comments
 (0)