From 47866078a01aca5e5859d174e0f3cec219c10ccf Mon Sep 17 00:00:00 2001 From: Dorin Date: Thu, 27 Feb 2025 11:24:57 +0200 Subject: [PATCH 01/51] using default argument instead of duplicated function --- include/GameAnalytics/GameAnalytics.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index 87845d61..a5b135c7 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -102,15 +102,13 @@ namespace gameanalytics static void startSession(); static void endSession(); - static std::string getRemoteConfigsValueAsString(std::string const& key); - static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue); + static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue = ""); static bool isRemoteConfigsReady(); static void addRemoteConfigsListener(const std::shared_ptr &listener); static void removeRemoteConfigsListener(const std::shared_ptr &listener); static std::string getRemoteConfigsContentAsString(); - static std::string getRemoteConfigsContentAsJson(); static std::string getABTestingId(); static std::string getABTestingVariantId(); From cec686ec6765f60f877b2344df8586cd154c5bc1 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 13:20:19 +0200 Subject: [PATCH 02/51] Update Main.cpp --- sample/Main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sample/Main.cpp b/sample/Main.cpp index 212589c1..3ed96837 100644 --- a/sample/Main.cpp +++ b/sample/Main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "GameAnalytics/GameAnalytics.h" From bcde102271de332029541c66a0791d23c8531b02 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 15:57:02 +0200 Subject: [PATCH 03/51] set ubuntu-24.04 and clang version to 16 --- .github/workflows/cmake.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 28938db9..21ddadb9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,17 +31,17 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-24.04, windows-latest, macOS-latest] build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-latest + - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-latest + - os: ubuntu-24.04 c_compiler: clang cpp_compiler: clang++ - os: macOS-latest @@ -52,7 +52,7 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-latest + - os: ubuntu-24.04 c_compiler: cl - os: macOS-latest c_compiler: cl @@ -71,6 +71,12 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Set Clang 16 as default + if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' + run: | + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 + - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type From 5c6d7e7f72d83a7f14f1cf25f38a44b1a7914bc2 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 15:59:41 +0200 Subject: [PATCH 04/51] Update cmake.yml --- .github/workflows/cmake.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 21ddadb9..ee3bd697 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -74,8 +74,8 @@ jobs: - name: Set Clang 16 as default if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' run: | - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 + sudo update-alternatives --set clang /usr/bin/clang-16 + sudo update-alternatives --set clang++ /usr/bin/clang++-16 - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. From 5586240ce7b3e2fd406861122b74e0dbdbacfe5e Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 16:12:13 +0200 Subject: [PATCH 05/51] Update cmake.yml --- .github/workflows/cmake.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ee3bd697..9119f059 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -71,11 +71,16 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: Set Clang 16 as default - if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' + - name: Set Clang 16 as Default run: | + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 sudo update-alternatives --set clang /usr/bin/clang-16 sudo update-alternatives --set clang++ /usr/bin/clang++-16 + + # Verify the change + clang --version + clang++ --version - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. From 2f751e4dc3a40cc94b6afcf861cca9cc8f9b402a Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 16:14:47 +0200 Subject: [PATCH 06/51] Update cmake.yml --- .github/workflows/cmake.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9119f059..327ba432 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -72,6 +72,7 @@ jobs: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - name: Set Clang 16 as Default + if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' run: | sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 From b79e828f26883096cbf425924b1b43da32717536 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:00:38 +0200 Subject: [PATCH 07/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3627bdd8..b698d227 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,7 +198,7 @@ elseif(LINUX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17") if(CLANG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") endif() endif() From 2f2c2ebf2d769032a4d361c93030a714d154db4a Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:07:54 +0200 Subject: [PATCH 08/51] Update cmake.yml --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 327ba432..25eed345 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -95,7 +95,7 @@ jobs: - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} VERBOSE=1 - name: Test working-directory: ${{ steps.strings.outputs.build-output-dir }} From ebbf72f3546ebdac0166c1daba1a0b42f79422a7 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:08:32 +0200 Subject: [PATCH 09/51] Update cmake.yml --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 25eed345..8190e0e5 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -95,7 +95,7 @@ jobs: - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} VERBOSE=1 + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --verbose - name: Test working-directory: ${{ steps.strings.outputs.build-output-dir }} From 9a6867a32767f04da439f4b92e85e3d6a4df36f3 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:12:06 +0200 Subject: [PATCH 10/51] Update CMakeLists.txt --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b698d227..70053a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,7 +209,9 @@ endif() add_library(GameAnalytics ${LIB_TYPE} ${CPP_SOURCES}) target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS}) - +message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") +message(STATUS "CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") # --------------------------- Google Test Setup --------------------------- # # Set Project Name From fc62e197c4916ef32c61a5beaefb14a8891ebd78 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:14:07 +0200 Subject: [PATCH 11/51] Update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70053a90..2b5e4233 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,6 +198,7 @@ elseif(LINUX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17") if(CLANG) + message(STATUS "Using Linux Clang with libstdc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") endif() From 122584058606b51aa4d621fbbb3800bb9e21cde0 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:16:49 +0200 Subject: [PATCH 12/51] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b5e4233..59ab5877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,8 +198,8 @@ elseif(LINUX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17") if(CLANG) - message(STATUS "Using Linux Clang with libstdc++") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") + message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() From 691a618769cc71729da9085f3bb75cf47d745d8c Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:17:59 +0200 Subject: [PATCH 13/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59ab5877..868c6b1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,7 @@ elseif(APPLE) elseif(LINUX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17") - if(CLANG) + if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() From bd08d61622cff983bd90d2ffedbd2e624e6fbb38 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:21:20 +0200 Subject: [PATCH 14/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 868c6b1b..4d5115be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -nostdinc++") endif() endif() From 792a871ead9bf49d0b20471176dacdf89dbbad16 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:22:37 +0200 Subject: [PATCH 15/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d5115be..e3ffd119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -nostdinc++") + # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() From df964bda08eaf78172bbe77fbd9dca3e6a0358ec Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:23:29 +0200 Subject: [PATCH 16/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ffd119..81962bf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") endif() endif() From 876f32b72b4c8168dfa7c854ab11523e0d5e47d0 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:28:08 +0200 Subject: [PATCH 17/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81962bf9..868c6b1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() From e1b552ecef3a374bf60c7946528a6f3383cc50bc Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:33:34 +0200 Subject: [PATCH 18/51] Update guid.cpp --- source/dependencies/crossguid/guid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dependencies/crossguid/guid.cpp b/source/dependencies/crossguid/guid.cpp index f3bfe58b..6faa8241 100644 --- a/source/dependencies/crossguid/guid.cpp +++ b/source/dependencies/crossguid/guid.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include "guid.h" #ifdef GUID_LIBUUID From cf493e70bc2314254dedf981af303e56af9bc1cf Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:36:16 +0200 Subject: [PATCH 19/51] Update guid.cpp --- source/dependencies/crossguid/guid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dependencies/crossguid/guid.cpp b/source/dependencies/crossguid/guid.cpp index 6faa8241..f3bfe58b 100644 --- a/source/dependencies/crossguid/guid.cpp +++ b/source/dependencies/crossguid/guid.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include "guid.h" #ifdef GUID_LIBUUID From ebca0f4fbf99a064c888763ed2a94f31f3abbbf2 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Thu, 13 Mar 2025 19:41:34 +0200 Subject: [PATCH 20/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 868c6b1b..6691b43f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -lc++abi") endif() endif() From 6d771f5786eb53e0acd88fea972fa04b1e9aa842 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 11:11:08 +0200 Subject: [PATCH 21/51] try and fix libc++ compatibility issues for linux --- .github/workflows/cmake.yml | 2 ++ CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8190e0e5..be1a878e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -82,6 +82,8 @@ jobs: # Verify the change clang --version clang++ --version + clang++ -v -E -x c++ /dev/null + clang++ -v -stdlib=libc++ - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. diff --git a/CMakeLists.txt b/CMakeLists.txt index 6691b43f..ee6655c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,8 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -lc++abi") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi") endif() endif() From 0d8ecb4bb872c9d53311b235fc61d32c01c1c3fc Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 11:17:08 +0200 Subject: [PATCH 22/51] Update cmake.yml --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index be1a878e..52441e2c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -82,8 +82,8 @@ jobs: # Verify the change clang --version clang++ --version + echo "Checking clang headers..." clang++ -v -E -x c++ /dev/null - clang++ -v -stdlib=libc++ - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. From 409966ec22edf45b1c8bdd59b310b5d3271212e2 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 11:36:16 +0200 Subject: [PATCH 23/51] Update cmake.yml --- .github/workflows/cmake.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 52441e2c..be8fb862 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,17 +31,17 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-24.04, windows-latest, macOS-latest] + os: [ubuntu-22.04, windows-latest, macOS-latest] build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-24.04 + - os: ubuntu-22.04 c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-24.04 + - os: ubuntu-22.04 c_compiler: clang cpp_compiler: clang++ - os: macOS-latest @@ -52,7 +52,7 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-24.04 + - os: ubuntu-22.04 c_compiler: cl - os: macOS-latest c_compiler: cl @@ -78,8 +78,10 @@ jobs: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 sudo update-alternatives --set clang /usr/bin/clang-16 sudo update-alternatives --set clang++ /usr/bin/clang++-16 - - # Verify the change + + - name: Check Clang Settings + if: matrix.os == 'ubuntu-22.04' && matrix.c_compiler == 'clang' + run: | clang --version clang++ --version echo "Checking clang headers..." From 4e00501b15c86eb1501e6cf7a716249e6c5c1c17 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 11:39:14 +0200 Subject: [PATCH 24/51] Update GALinux.cpp --- source/gameanalytics/Platform/GALinux.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameanalytics/Platform/GALinux.cpp b/source/gameanalytics/Platform/GALinux.cpp index 20154394..d5ec8064 100644 --- a/source/gameanalytics/Platform/GALinux.cpp +++ b/source/gameanalytics/Platform/GALinux.cpp @@ -4,6 +4,7 @@ #include "GAState.h" +#include #include #include #include From 884ae5d132731c3cbc1369cd44706b3739033b4e Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 12:36:05 +0200 Subject: [PATCH 25/51] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6655c7..2bedea27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,7 @@ if(${GA_BUILD_SAMPLE}) endif() add_library(GameAnalytics ${LIB_TYPE} ${CPP_SOURCES}) -target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS}) +target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS} -lc) message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") message(STATUS "CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") @@ -240,7 +240,7 @@ add_executable(${UT_PROJECT_NAME} ${TEST_SRC_FILES}) ######################################## # Standard linking to gtest and gmock components ######################################## -target_link_libraries(${UT_PROJECT_NAME} gtest gtest_main gmock_main) +target_link_libraries(${UT_PROJECT_NAME} gtest gtest_main gmock_main -lc) ######################################## # Linking to GA SDK From 2cd685c2f27fa88c82646ad78d3c0a823a0a3117 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 12:39:32 +0200 Subject: [PATCH 26/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6655c7..0236eb83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc -lc++abi") endif() endif() From c1dbc7d4f9740f63f4ba5e3482003479a5896076 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 12:57:44 +0200 Subject: [PATCH 27/51] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f298d238..d95c2397 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -D_FILE_OFFSET_BITS=64") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc -lc++abi") endif() From 2da61b039f1bebddc5f962ac099a92f2f30272d0 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 12:59:51 +0200 Subject: [PATCH 28/51] Update cmake.yml --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index be8fb862..2e7ec3c4 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -86,6 +86,8 @@ jobs: clang++ --version echo "Checking clang headers..." clang++ -v -E -x c++ /dev/null + echo "check lld..." + ldd --version - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. From 02e23647f6d2aa4ebea49776be7db3f99684e637 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 15:33:51 +0200 Subject: [PATCH 29/51] use with older ubuntu 20.04 --- .github/workflows/cmake.yml | 18 +++++------------- CMakeLists.txt | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2e7ec3c4..f1f93185 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,17 +31,17 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-22.04, windows-latest, macOS-latest] + os: [ubuntu-20.04, windows-latest, macOS-latest] build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-22.04 + - os: ubuntu-20.04 c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-22.04 + - os: ubuntu-20.04 c_compiler: clang cpp_compiler: clang++ - os: macOS-latest @@ -52,7 +52,7 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-22.04 + - os: ubuntu-20.04 c_compiler: cl - os: macOS-latest c_compiler: cl @@ -71,16 +71,8 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: Set Clang 16 as Default - if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' - run: | - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 - sudo update-alternatives --set clang /usr/bin/clang-16 - sudo update-alternatives --set clang++ /usr/bin/clang++-16 - - name: Check Clang Settings - if: matrix.os == 'ubuntu-22.04' && matrix.c_compiler == 'clang' + if: matrix.os == 'ubuntu-20.04' && matrix.c_compiler == 'clang' run: | clang --version clang++ --version diff --git a/CMakeLists.txt b/CMakeLists.txt index d95c2397..4b027450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,7 @@ if(${GA_BUILD_SAMPLE}) endif() add_library(GameAnalytics ${LIB_TYPE} ${CPP_SOURCES}) -target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS} -lc) +target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS}) message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") message(STATUS "CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") @@ -240,7 +240,7 @@ add_executable(${UT_PROJECT_NAME} ${TEST_SRC_FILES}) ######################################## # Standard linking to gtest and gmock components ######################################## -target_link_libraries(${UT_PROJECT_NAME} gtest gtest_main gmock_main -lc) +target_link_libraries(${UT_PROJECT_NAME} gtest gtest_main gmock_main) ######################################## # Linking to GA SDK From 2cca217f73e2fd344df1adf416f9df4af5016a2a Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 15:40:39 +0200 Subject: [PATCH 30/51] Update cmake.yml --- .github/workflows/cmake.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f1f93185..a7a673a3 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -71,6 +71,11 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Install Clang and Libraries + run: | + sudo apt-get update + sudo apt-get install -y clang libc++-dev libc++abi-dev + - name: Check Clang Settings if: matrix.os == 'ubuntu-20.04' && matrix.c_compiler == 'clang' run: | From 733ef2a94c0adffd140ef7b9897b48db8a013b29 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 15:44:16 +0200 Subject: [PATCH 31/51] Update cmake.yml --- .github/workflows/cmake.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a7a673a3..a28e7393 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,17 +31,17 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-20.04, windows-latest, macOS-latest] + os: [ubuntu-24.04, windows-latest, macOS-latest] build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-20.04 + - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-20.04 + - os: ubuntu-24.04 c_compiler: clang cpp_compiler: clang++ - os: macOS-latest @@ -52,7 +52,7 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-20.04 + - os: ubuntu-24.04 c_compiler: cl - os: macOS-latest c_compiler: cl @@ -72,12 +72,13 @@ jobs: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - name: Install Clang and Libraries + if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' run: | sudo apt-get update sudo apt-get install -y clang libc++-dev libc++abi-dev - name: Check Clang Settings - if: matrix.os == 'ubuntu-20.04' && matrix.c_compiler == 'clang' + if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' run: | clang --version clang++ --version From 2a4ad72d0c3ced5dc449491ea883d828d577f5f1 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 16:10:39 +0200 Subject: [PATCH 32/51] Update cmake.yml Update CMakeLists.txt Update cmake.yml fix linux compilation issue --- .github/workflows/cmake.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a28e7393..15681e38 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -77,6 +77,14 @@ jobs: sudo apt-get update sudo apt-get install -y clang libc++-dev libc++abi-dev + - name: Set Clang 16 as Default + if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' + run: | + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 + sudo update-alternatives --set clang /usr/bin/clang-16 + sudo update-alternatives --set clang++ /usr/bin/clang++-16 + - name: Check Clang Settings if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' run: | From 72a65adb594d1be58fa5ed82b62613a475b179e3 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 14 Mar 2025 16:36:14 +0200 Subject: [PATCH 33/51] Update cmake.yml --- .github/workflows/cmake.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a28e7393..f03da2e9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,17 +31,17 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-24.04, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-latest] build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-24.04 + - os: ubuntu-latest c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-24.04 + - os: ubuntu-latest c_compiler: clang cpp_compiler: clang++ - os: macOS-latest @@ -52,7 +52,7 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-24.04 + - os: ubuntu-latest c_compiler: cl - os: macOS-latest c_compiler: cl @@ -72,13 +72,13 @@ jobs: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - name: Install Clang and Libraries - if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' + if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang' run: | sudo apt-get update sudo apt-get install -y clang libc++-dev libc++abi-dev - name: Check Clang Settings - if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' + if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang' run: | clang --version clang++ --version From 43f2de434f3635019b903d47307849d6f5108e55 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Wed, 26 Mar 2025 15:07:45 +0200 Subject: [PATCH 34/51] Update CMakeLists.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b027450..868c6b1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,8 +199,7 @@ elseif(LINUX) if (CMAKE_CXX_COMPILER MATCHES "clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -D_FILE_OFFSET_BITS=64") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc -lc++abi") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() From 3a572cf147e15945da3583d7aab4778b146c7ca9 Mon Sep 17 00:00:00 2001 From: Dorin Date: Wed, 26 Mar 2025 15:17:13 +0200 Subject: [PATCH 35/51] expose identifiers --- include/GameAnalytics/GameAnalytics.h | 3 +++ source/gameanalytics/GAState.cpp | 7 ++++++- source/gameanalytics/GAState.h | 3 ++- source/gameanalytics/GameAnalytics.cpp | 12 +++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index a5b135c7..622d30d0 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -110,6 +110,9 @@ namespace gameanalytics static std::string getRemoteConfigsContentAsString(); + static std::string getUserId(); + static std::string getExternalUserId(); + static std::string getABTestingId(); static std::string getABTestingVariantId(); diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index 515655a4..2b8c1745 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -66,6 +66,11 @@ namespace gameanalytics return getInstance()._identifier; } + std::string GAState::getExternalUserId() + { + return getInstance()._externalUserId; + } + bool GAState::isInitialized() { return getInstance()._initialized; @@ -402,7 +407,7 @@ namespace gameanalytics out["event_uuid"] = utilities::GAUtilities::generateUUID(); // User identifier - out["user_id"] = getInstance().getIdentifier(); + out["user_id"] = getUserId(); // remote configs configurations if(getInstance()._configurations.is_object() && !getInstance()._configurations.empty()) diff --git a/source/gameanalytics/GAState.h b/source/gameanalytics/GAState.h index 490bd3a1..020438ea 100644 --- a/source/gameanalytics/GAState.h +++ b/source/gameanalytics/GAState.h @@ -141,6 +141,8 @@ namespace gameanalytics static std::string getRemoteConfigsContentAsString(); static std::string getAbId(); static std::string getAbVariantId(); + static std::string getUserId(); + static std::string getExternalUserId(); static json getValidatedCustomFields(); static json getValidatedCustomFields(const json& withEventFields); @@ -164,7 +166,6 @@ namespace gameanalytics addErrorEvent(severity, msg); } - std::string getIdentifier(); void setDefaultUserId(std::string const& id); json& getSdkConfig(); void cacheIdentifier(); diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index dfa373ca..60ec105b 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -475,7 +475,7 @@ namespace gameanalytics { // Send to events json fieldsJson = utilities::parseFields(fields); - events::GAEvents::addProgressionEvent(progressionStatus, progression01, progression02, progression03, score, false, fieldsJson, mergeFields); + events::GAEvents::addProgressionEvent(progressionStatus, progression01, progression02, progression03, score, true, fieldsJson, mergeFields); } catch(const json::exception& e) { @@ -763,6 +763,16 @@ namespace gameanalytics return state::GAState::getRemoteConfigsContentAsString(); } + std::string GameAnalytics::getUserId() + { + return state::GAState::getUserId(); + } + + std::string GameAnalytics::getExternalUserId() + { + return state::GAState::getExternalUserId(); + } + std::string GameAnalytics::getABTestingId() { return state::GAState::getAbId(); From 4eb45a451888a9eef85c706a72523777709ca20d Mon Sep 17 00:00:00 2001 From: Dorin Date: Wed, 26 Mar 2025 15:27:49 +0200 Subject: [PATCH 36/51] renamed getUserId --- source/gameanalytics/GAState.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index 2b8c1745..13fd7a90 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -61,7 +61,7 @@ namespace gameanalytics getInstance().cacheIdentifier(); } - std::string GAState::getIdentifier() + std::string GAState::getUserId() { return getInstance()._identifier; } From dc8672185288d8d9a7b810353e2a73a5f45736df Mon Sep 17 00:00:00 2001 From: Dorin Date: Thu, 22 May 2025 12:49:54 +0300 Subject: [PATCH 37/51] added gpu model --- source/gameanalytics/GADevice.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameanalytics/GADevice.h b/source/gameanalytics/GADevice.h index 7ab1e825..eca493db 100644 --- a/source/gameanalytics/GADevice.h +++ b/source/gameanalytics/GADevice.h @@ -78,6 +78,7 @@ namespace gameanalytics std::string _osVersion; std::string _deviceModel; std::string _deviceManufacturer; + std::string _gpu; std::string _writablepath; bool _writablepathStatus{false}; From b57c30549442675cdec3eb9623e75b7e99fd4fbc Mon Sep 17 00:00:00 2001 From: Dorin Date: Thu, 22 May 2025 12:51:05 +0300 Subject: [PATCH 38/51] playtime support --- include/GameAnalytics/GameAnalytics.h | 3 ++ source/gameanalytics/GAEvents.cpp | 3 +- source/gameanalytics/GAState.cpp | 41 +++++++++++++++++++++------ source/gameanalytics/GAState.h | 18 ++++++++++-- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index 622d30d0..5a72cdd3 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -116,6 +116,9 @@ namespace gameanalytics static std::string getABTestingId(); static std::string getABTestingVariantId(); + static int64_t getElapsedSessionTime(); + static int64_t getElapsedTimeFromAllSessions(); + // game state changes // will affect how session is started / ended static void onResume(); diff --git a/source/gameanalytics/GAEvents.cpp b/source/gameanalytics/GAEvents.cpp index 9cbc710d..64d58ecd 100644 --- a/source/gameanalytics/GAEvents.cpp +++ b/source/gameanalytics/GAEvents.cpp @@ -116,7 +116,8 @@ namespace gameanalytics try { - int64_t sessionLength = state.calculateSessionLength(); + // get session length in seconds + int64_t sessionLength = state.calculateSessionLength(); if(sessionLength < 0ll) { diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index 13fd7a90..e1dc80ee 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -57,7 +57,7 @@ namespace gameanalytics return; } - getInstance()._userId = id; + getInstance()._customUserId = id; getInstance().cacheIdentifier(); } @@ -383,6 +383,7 @@ namespace gameanalytics logging::GALogger::i("Ending session."); if (GAState::isEnabled() && GAState::sessionIsStarted()) { + getInstance().updateTotalSessionTime(); events::GAEvents::addHealthEvent(); events::GAEvents::addSessionEndEvent(); getInstance()._sessionStart = 0; @@ -505,9 +506,9 @@ namespace gameanalytics void GAState::cacheIdentifier() { - if(!_userId.empty()) + if(!_customUserId.empty()) { - _identifier = _userId; + _identifier = _customUserId; } else { @@ -515,7 +516,6 @@ namespace gameanalytics } logging::GALogger::d("identifier, {clean:%s}", _identifier.c_str()); - } std::string setStateFromCache(json& dict, std::string const& key, std::string const& value) @@ -535,6 +535,11 @@ namespace gameanalytics return ""; } + int64_t GAState::getTotalSessionLength() const + { + return _totalElapsedSessionTime + calculateSessionLength(); + } + void GAState::ensurePersistedStates() { try @@ -555,6 +560,9 @@ namespace gameanalytics } } } + + std::string s = state_dict.dump(); + _gaLogger.d("state_dict: %s", s.c_str()); // insert into GAState instance std::string defaultId = utilities::getOptionalValue(state_dict, "default_user_id"); @@ -575,6 +583,20 @@ namespace gameanalytics _currentCustomDimension01 = setStateFromCache(state_dict, "dimension01", _currentCustomDimension01); _currentCustomDimension02 = setStateFromCache(state_dict, "dimension02", _currentCustomDimension02); _currentCustomDimension03 = setStateFromCache(state_dict, "dimension03", _currentCustomDimension03); + + try + { + std::string cachedSessionTime = utilities::getOptionalValue(state_dict, "total_session_time", "0"); + + _totalElapsedSessionTime = std::stoull(cachedSessionTime); + + } + catch(const std::exception& e) + { + _gaLogger.w("Failed to read total_session_time from cache!"); + _totalElapsedSessionTime = 0; + } + // get cached init call values if (state_dict.contains("sdk_config_cached") && state_dict["sdk_config_cached"].is_string()) @@ -856,11 +878,6 @@ namespace gameanalytics return getInstance()._remoteConfigsIsReady; } - int64_t GAState::calculateSessionLength() const - { - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - _startTimepoint).count(); - } - void GAState::addRemoteConfigsListener(const std::shared_ptr& listener) { if(std::find(getInstance()._remoteConfigsListeners.begin(), getInstance()._remoteConfigsListeners.end(), listener) == getInstance()._remoteConfigsListeners.end()) @@ -1043,6 +1060,12 @@ namespace gameanalytics return utilities::GAUtilities::timeIntervalSince1970(); } + void GAState::updateTotalSessionTime() + { + int64_t totalSessionTime = getTotalSessionLength(); + _gaStore.setState("total_session_time", std::to_string(totalSessionTime)); + } + std::string GAState::getBuild() { return getInstance()._build; diff --git a/source/gameanalytics/GAState.h b/source/gameanalytics/GAState.h index 020438ea..6ff1d7f0 100644 --- a/source/gameanalytics/GAState.h +++ b/source/gameanalytics/GAState.h @@ -147,7 +147,15 @@ namespace gameanalytics static json getValidatedCustomFields(); static json getValidatedCustomFields(const json& withEventFields); - int64_t calculateSessionLength() const; + int64_t getTotalSessionLength() const; + + template + inline int64_t calculateSessionLength() const + { + return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - _startTimepoint).count(); + } + + void populateConfigurations(json& sdkConfig); private: @@ -174,8 +182,11 @@ namespace gameanalytics void validateAndFixCurrentDimensions(); std::string getBuild(); + void updateTotalSessionTime(); + int64_t calculateServerTimeOffset(int64_t serverTs); - void populateConfigurations(json& sdkConfig); + + std::chrono::milliseconds getCurrentSessionLength() const; void validateAndCleanCustomFields(const json& fields, json& out); @@ -192,7 +203,7 @@ namespace gameanalytics store::GAStore _gaStore; http::GAHTTPApi _gaHttp; - std::string _userId; + std::string _customUserId; std::string _identifier; bool _initialized = false; @@ -202,6 +213,7 @@ namespace gameanalytics int64_t _sessionNum = 0; int64_t _transactionNum = 0; + int64_t _totalElapsedSessionTime = 0; std::chrono::high_resolution_clock::time_point _startTimepoint; std::string _sessionId; From 22beea33a899b7d9de3dd4fb38b4b1c9d68077b6 Mon Sep 17 00:00:00 2001 From: Dorin Date: Thu, 22 May 2025 12:51:46 +0300 Subject: [PATCH 39/51] playtime support --- source/gameanalytics/GameAnalytics.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index 60ec105b..0b187dfd 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -988,4 +988,14 @@ namespace gameanalytics } } + int64_t GameAnalytics::getElapsedTimeFromAllSessions() + { + return state::GAState::getInstance().getTotalSessionLength(); + } + + int64_t GameAnalytics::getElapsedSessionTime() + { + return state::GAState::getInstance().calculateSessionLength(); + } + } // namespace gameanalytics From 9a88dce98127916960097e6a41e7c910c2de6cb0 Mon Sep 17 00:00:00 2001 From: Dorin Date: Thu, 22 May 2025 13:00:44 +0300 Subject: [PATCH 40/51] removed redudant function declaration --- source/gameanalytics/GAState.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/gameanalytics/GAState.h b/source/gameanalytics/GAState.h index 6ff1d7f0..df375099 100644 --- a/source/gameanalytics/GAState.h +++ b/source/gameanalytics/GAState.h @@ -186,8 +186,6 @@ namespace gameanalytics int64_t calculateServerTimeOffset(int64_t serverTs); - std::chrono::milliseconds getCurrentSessionLength() const; - void validateAndCleanCustomFields(const json& fields, json& out); void setConfigsHash(std::string const& configsHash); From 89048793f13d441a3bec940211767661f26f1705 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 14:29:55 +0300 Subject: [PATCH 41/51] remote configs v3 --- source/gameanalytics/GAHTTPApi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameanalytics/GAHTTPApi.cpp b/source/gameanalytics/GAHTTPApi.cpp index 394a340c..16e5bbe3 100644 --- a/source/gameanalytics/GAHTTPApi.cpp +++ b/source/gameanalytics/GAHTTPApi.cpp @@ -56,7 +56,7 @@ namespace gameanalytics std::string gameKey = state::GAState::getGameKey(); // Generate URL - std::string url = remoteConfigsBaseUrl + "/" + initializeUrlPath + "?game_key=" + gameKey + "&interval_seconds=0&configs_hash=" + configsHash; + std::string url = remoteConfigsBaseUrl + "/" + initializeUrlPath + "?game_key=" + gameKey + "&interval_seconds=0&configs_hash=" + configsHash + "&config_vsn_supported=3"; logging::GALogger::d("Sending 'init' URL: %s", url.c_str()); From bea39258b11967865fd687e3f7aab8bc6b35232e Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 14:31:02 +0300 Subject: [PATCH 42/51] remote configs v3 support --- source/gameanalytics/GAState.cpp | 54 +++++++++++++++++++++----------- source/gameanalytics/GAState.h | 24 +++++++++++--- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index e1dc80ee..01a4c912 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -413,7 +413,7 @@ namespace gameanalytics // remote configs configurations if(getInstance()._configurations.is_object() && !getInstance()._configurations.empty()) { - out["configurations"] = getInstance()._configurations; + out["configurations_v3"] = getInstance().getRemoteConfigAnnotations(); } out["sdk_version"] = device::GADevice::getRelevantSdkVersion(); @@ -865,14 +865,6 @@ namespace gameanalytics return getInstance()._sessionStart != 0; } - std::string GAState::getRemoteConfigsStringValue(std::string const& key, std::string const& defaultValue) - { - std::lock_guard lg(getInstance()._mtx); - std::string const value = utilities::getOptionalValue(getInstance()._configurations, key, defaultValue); - - return value; - } - bool GAState::isRemoteConfigsReady() { return getInstance()._remoteConfigsIsReady; @@ -900,12 +892,28 @@ namespace gameanalytics std::string GAState::getRemoteConfigsContentAsString() { std::lock_guard lg(getInstance()._mtx); - return getInstance()._configurations.dump(JSON_PRINT_INDENT); + + json contents; + + for(auto& obj : getInstance()._configurations) + { + if(obj.contains("key") && obj.contains("value")) + { + std::string key = utilities::getOptionalValue(obj, "key", ""); + if(!key.empty()) + { + contents[key] = obj["value"]; + } + } + } + + return contents.dump(JSON_PRINT_INDENT); } void GAState::populateConfigurations(json& sdkConfig) { std::lock_guard guard(_mtx); + _configurations = {}; try { @@ -918,21 +926,15 @@ namespace gameanalytics if (!configuration.empty()) { std::string key = utilities::getOptionalValue(configuration, "key", ""); - int64_t start_ts = utilities::getOptionalValue(configuration, "start_ts", std::numeric_limits::min()); - int64_t end_ts = utilities::getOptionalValue(configuration, "end_ts", std::numeric_limits::max()); int64_t client_ts_adjusted = getClientTsAdjusted(); if (!key.empty() && configuration.contains("value") && client_ts_adjusted > start_ts && client_ts_adjusted < end_ts) { - json& value = configuration["value"]; - if (value.is_string() || value.is_number()) - { - _configurations[key] = value; - logging::GALogger::d("configuration added: %s", configuration.dump(JSON_PRINT_INDENT).c_str()); - } + _configurations[key] = configuration; + logging::GALogger::d("configuration added: %s", configuration.dump(JSON_PRINT_INDENT).c_str()); } } } @@ -1155,5 +1157,21 @@ namespace gameanalytics return cleanedFields; } + + json GAState::getRemoteConfigAnnotations() + { + json configs; + for(json& obj : _configurations) + { + json cfg; + cfg["vsn"] = utilities::getOptionalValue(obj, "vsn", 0); + cfg["key"] = utilities::getOptionalValue(obj, "key", ""); + cfg["id"] = utilities::getOptionalValue(obj, "id", ""); + + configs.push_back(cfg); + } + + return configs; + } } } diff --git a/source/gameanalytics/GAState.h b/source/gameanalytics/GAState.h index df375099..b2da9593 100644 --- a/source/gameanalytics/GAState.h +++ b/source/gameanalytics/GAState.h @@ -134,7 +134,6 @@ namespace gameanalytics static void setEnabledEventSubmission(bool flag); static bool isEventSubmissionEnabled(); static bool sessionIsStarted(); - static std::string getRemoteConfigsStringValue(std::string const& key, std::string const& defaultValue); static bool isRemoteConfigsReady(); static void addRemoteConfigsListener(const std::shared_ptr& listener); static void removeRemoteConfigsListener(const std::shared_ptr& listener); @@ -147,16 +146,33 @@ namespace gameanalytics static json getValidatedCustomFields(); static json getValidatedCustomFields(const json& withEventFields); - int64_t getTotalSessionLength() const; + template + inline static T getRemoteConfigsValue(std::string const& key, T const& defaultValue) + { + std::lock_guard lg(getInstance()._mtx); + if(getInstance()._configurations.contains(key)) + { + json& config = getInstance()._configurations[key]; + T value = utilities::getOptionalValue(config, "value", defaultValue); + return value; + } + + return defaultValue; + } template inline int64_t calculateSessionLength() const { - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - _startTimepoint).count(); + auto len = std::chrono::high_resolution_clock::now() - _startTimepoint; + return std::chrono::duration_cast(len).count(); } + int64_t getTotalSessionLength() const; + void populateConfigurations(json& sdkConfig); + json getRemoteConfigAnnotations(); + private: GAState(); @@ -184,7 +200,7 @@ namespace gameanalytics void updateTotalSessionTime(); - int64_t calculateServerTimeOffset(int64_t serverTs); + int64_t calculateServerTimeOffset(int64_t serverTs); void validateAndCleanCustomFields(const json& fields, json& out); From f4f36eb096b6960a8cfcc58bc05cabc797587812 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 14:33:39 +0300 Subject: [PATCH 43/51] do not drop fps values outside range --- source/gameanalytics/GAHealth.cpp | 8 +++----- source/gameanalytics/GAHealth.h | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/gameanalytics/GAHealth.cpp b/source/gameanalytics/GAHealth.cpp index 6edab39e..a8a93e09 100644 --- a/source/gameanalytics/GAHealth.cpp +++ b/source/gameanalytics/GAHealth.cpp @@ -24,10 +24,9 @@ namespace gameanalytics void GAHealth::doFpsReading(float fps) { int fpsBucket = std::round(fps); - if(fpsBucket >= 0 && fpsBucket < MAX_FPS_COUNT) - { - _fpsReadings[fpsBucket]++; - } + fpsBucket = std::clamp(fpsBucket, 0, MAX_FPS_VALUE); + + _fpsReadings[fpsBucket]++; } int GAHealth::getMemoryPercent(int64_t memory) @@ -169,7 +168,6 @@ namespace gameanalytics } } ); - } } } diff --git a/source/gameanalytics/GAHealth.h b/source/gameanalytics/GAHealth.h index 94361c19..014c2ed3 100644 --- a/source/gameanalytics/GAHealth.h +++ b/source/gameanalytics/GAHealth.h @@ -29,7 +29,8 @@ namespace gameanalytics protected: - static constexpr size_t MAX_FPS_COUNT = 120 + 1; + static constexpr int MAX_FPS_VALUE = 120; + static constexpr size_t MAX_FPS_COUNT = MAX_FPS_VALUE + 1; static constexpr size_t MAX_MEMORY_COUNT = 100 + 1; static constexpr std::chrono::milliseconds MEMORY_TRACK_FREQ {5000}; From 796c6c94b43e7a5627254d26a5fff3908c93c605 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 14:41:12 +0300 Subject: [PATCH 44/51] features for remote configs v3 --- include/GameAnalytics/GameAnalytics.h | 11 ++++ source/gameanalytics/GameAnalytics.cpp | 84 ++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 6 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index 5a72cdd3..34bf1090 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -102,7 +102,17 @@ namespace gameanalytics static void startSession(); static void endSession(); + /* + template + static T getRemoteConfigsValue(std::string const& key, T const& defaultValue); + */ + static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue = ""); + static int64_t getRemoteConfigsValueAsInt(std::string const& key, int64_t defaultValue = 0); + static uint64_t getRemoteConfigsValueAsUInt(std::string const& key, uint64_t defaultValue = 0); + static bool getRemoteConfigsValueAsBool(std::string const& key, bool defaultValue = false); + static double getRemoteConfigsValueAsFloat(std::string const& key, double defaultValue = 0.0); + static std::string getRemoteConfigsValueAsJson(std::string const& key); static bool isRemoteConfigsReady(); static void addRemoteConfigsListener(const std::shared_ptr &listener); @@ -134,4 +144,5 @@ namespace gameanalytics static bool isSdkReady(bool needsInitialized, bool warn); static bool isSdkReady(bool needsInitialized, bool warn, std::string const& message); }; + } // namespace gameanalytics diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index 0b187dfd..dbc4e388 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -740,7 +740,78 @@ namespace gameanalytics std::string GameAnalytics::getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue) { - return state::GAState::getRemoteConfigsStringValue(key, defaultValue); + return state::GAState::getRemoteConfigsValue(key, defaultValue); + } + + int64_t GameAnalytics::getRemoteConfigsValueAsInt(std::string const& key, int64_t defaultValue) + { + try + { + std::string s = getRemoteConfigsValueAsString(key); + if(!s.empty()) + { + return std::stoll(s); + } + } + catch(std::exception& e) + { + (void)e; + } + + return defaultValue; + } + + uint64_t GameAnalytics::getRemoteConfigsValueAsUInt(std::string const& key, uint64_t defaultValue) + { + try + { + std::string s = getRemoteConfigsValueAsString(key); + if(!s.empty()) + { + return std::stoull(s); + } + } + catch(std::exception& e) + { + (void)e; + } + + return defaultValue; + } + + double GameAnalytics::getRemoteConfigsValueAsFloat(std::string const& key, double defaultValue) + { + try + { + std::string s = getRemoteConfigsValueAsString(key); + if(!s.empty()) + { + return std::stod(s); + } + } + catch(std::exception& e) + { + (void)e; + } + + return defaultValue; + } + + bool GameAnalytics::getRemoteConfigsValueAsBool(std::string const& key, bool defaultValue) + { + std::string s = getRemoteConfigsValueAsString(key, "false"); + return utilities::toLowerCase(s) == "true"; + } + + std::string GameAnalytics::getRemoteConfigsValueAsJson(std::string const& key) + { + std::string jsonString = getRemoteConfigsValueAsString(key); + if(!json::accept(jsonString)) + { + return ""; + } + + return jsonString; } bool GameAnalytics::isRemoteConfigsReady() @@ -874,8 +945,9 @@ namespace gameanalytics std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } - catch (const std::exception&) + catch (const std::exception& e) { + logging::GALogger::e(e.what()); } } @@ -906,7 +978,7 @@ namespace gameanalytics { if (warn) { - logging::GALogger::w("%sDatastore not initialized", m.c_str()); + logging::GALogger::w("%s; Datastore not initialized", m.c_str()); } return false; } @@ -915,7 +987,7 @@ namespace gameanalytics { if (warn) { - logging::GALogger::w("%sSDK is not initialized", m.c_str()); + logging::GALogger::w("%s; SDK is not initialized", m.c_str()); } return false; } @@ -924,7 +996,7 @@ namespace gameanalytics { if (warn) { - logging::GALogger::w("%s;SDK is disabled", m.c_str()); + logging::GALogger::w("%s; SDK is disabled", m.c_str()); } return false; } @@ -934,7 +1006,7 @@ namespace gameanalytics { if (warn) { - logging::GALogger::w("%s;Session has not started yet", m.c_str()); + logging::GALogger::w("%s; Session has not started yet", m.c_str()); } return false; } From 6d1e591c1fb5980dcf9a43fcf0a07d9e2b4a3449 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 14:48:28 +0300 Subject: [PATCH 45/51] track gpu model --- source/gameanalytics/GAHealth.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameanalytics/GAHealth.cpp b/source/gameanalytics/GAHealth.cpp index a8a93e09..1f301d3b 100644 --- a/source/gameanalytics/GAHealth.cpp +++ b/source/gameanalytics/GAHealth.cpp @@ -64,6 +64,7 @@ namespace gameanalytics { utilities::addIfNotEmpty(out, "cpu_model", _cpuModel); utilities::addIfNotEmpty(out, "hardware", _hardware); + utilities::addIfNotEmpty(out, "gpu_model", _gpuModel); if(_numCores > 0) { From 01b4543d56e7e2a894f47d873cb9f7a2b172b4b5 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 6 Jun 2025 15:00:28 +0300 Subject: [PATCH 46/51] fixed gpu model retrieval for windows --- source/gameanalytics/Platform/GAWin32.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/gameanalytics/Platform/GAWin32.cpp b/source/gameanalytics/Platform/GAWin32.cpp index f63d8320..aaa8e2e0 100644 --- a/source/gameanalytics/Platform/GAWin32.cpp +++ b/source/gameanalytics/Platform/GAWin32.cpp @@ -233,16 +233,18 @@ std::string GAPlatformWin32::getGpuModel() const DISPLAY_DEVICE device; ZeroMemory(&device, sizeof(DISPLAY_DEVICE)); - if(EnumDisplayDevices(NULL, 0, &device, 0)) + device.cb = sizeof(DISPLAY_DEVICE); + + if(EnumDisplayDevices(NULL, 0, &device, EDD_GET_DEVICE_INTERFACE_NAME)) { #ifdef UNICODE - return utilities::GAUtilities::ws2s(device.DeviceName); + return utilities::GAUtilities::ws2s(device.DeviceString); #else - return device.DeviceName; + return device.DeviceString; #endif } - return UNKNOWN_VALUE; + return ""; } int GAPlatformWin32::getNumCpuCores() const From d76234dfcf8fcea56e1e587bd5a266f47da517a0 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Mon, 23 Jun 2025 08:22:23 +0300 Subject: [PATCH 47/51] Fix zlib issues (#28) * create internal compression component * use the new miniz code * Update README.md --- README.md | 2 +- .../miniz/{miniz.c => GA_Zip.cpp} | 22 ++++++------------- source/gameanalytics/GAUtilities.cpp | 4 +++- 3 files changed, 11 insertions(+), 17 deletions(-) rename source/dependencies/miniz/{miniz.c => GA_Zip.cpp} (99%) diff --git a/README.md b/README.md index 04a2cb97..fddbfb38 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Example: Example: ``` c++ - gameanalytics::GameAnalytics::initialize("", "", ""); ``` ### Send events diff --git a/source/dependencies/miniz/miniz.c b/source/dependencies/miniz/GA_Zip.cpp similarity index 99% rename from source/dependencies/miniz/miniz.c rename to source/dependencies/miniz/GA_Zip.cpp index 2b787fbf..31f5841f 100644 --- a/source/dependencies/miniz/miniz.c +++ b/source/dependencies/miniz/GA_Zip.cpp @@ -219,9 +219,9 @@ #define MINIZ_HAS_64BIT_REGISTERS 1 #endif -#ifdef __cplusplus -extern "C" { -#endif +namespace gameanalytics { +namespace utilities { +namespace zip { // ------------------- zlib-style API Definitions. @@ -919,10 +919,6 @@ mz_uint32 tdefl_get_adler32(tdefl_compressor *d); mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); #endif // #ifndef MINIZ_NO_ZLIB_APIS -#ifdef __cplusplus -} -#endif - #endif // MINIZ_HEADER_INCLUDED // ------------------- 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]; #define MZ_FORCEINLINE inline #endif -#ifdef __cplusplus - extern "C" { -#endif - // ------------------- zlib-style API's 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 #endif // #ifndef MINIZ_NO_ARCHIVE_APIS -#ifdef __cplusplus -} -#endif - #endif // MINIZ_HEADER_FILE_ONLY +} // namespace zip +} // namespace utilities +} // namespace gameanalytics + /* This is free and unencumbered software released into the public domain. diff --git a/source/gameanalytics/GAUtilities.cpp b/source/gameanalytics/GAUtilities.cpp index bbb1807c..2f98626e 100644 --- a/source/gameanalytics/GAUtilities.cpp +++ b/source/gameanalytics/GAUtilities.cpp @@ -20,12 +20,14 @@ // From crypto #define MINIZ_HEADER_FILE_ONLY -#include "miniz.c" +#include "GA_Zip.cpp" namespace gameanalytics { namespace utilities { + using namespace zip; + std::string printArray(StringVector const& v, std::string const& delim) { if(v.empty()) From d0ce87328f0c5aa6753599bff89807a2e7829c42 Mon Sep 17 00:00:00 2001 From: Andrei Dabija Date: Fri, 22 Aug 2025 12:00:55 +0300 Subject: [PATCH 48/51] 5.0.0 release prep (#30) * rename remote configs members * split remote configs in game and annotation cfgs * add 5.0.0 release notes --- CHANGELOG.md | 7 +++++ source/gameanalytics/GACommon.h | 2 +- source/gameanalytics/GAState.cpp | 51 +++++++++++++++++++++----------- source/gameanalytics/GAState.h | 10 +++++-- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4329e0f3..27975727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 5.0.0 + +### Added + +- **Remote Configs With JSON**: Remote Configs now support JSON values, allowing for more complex configurations. +- **Playtime Metrics API**: Introduced new API to get total playtime and playtime in the current session. + ## 4.1.0 ### Added diff --git a/source/gameanalytics/GACommon.h b/source/gameanalytics/GACommon.h index e761edb8..37f533c6 100644 --- a/source/gameanalytics/GACommon.h +++ b/source/gameanalytics/GACommon.h @@ -85,7 +85,7 @@ namespace gameanalytics class GAState; } - constexpr const char* GA_VERSION_STR = "cpp 4.1.0"; + constexpr const char* GA_VERSION_STR = "cpp 5.0.0"; constexpr int MAX_CUSTOM_FIELDS_COUNT = 50; constexpr int MAX_CUSTOM_FIELDS_KEY_LENGTH = 64; diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index 01a4c912..ae3ba089 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -411,7 +411,7 @@ namespace gameanalytics out["user_id"] = getUserId(); // remote configs configurations - if(getInstance()._configurations.is_object() && !getInstance()._configurations.empty()) + if(getInstance()._trackingRemoteConfigsJson.is_array() && !getInstance()._trackingRemoteConfigsJson.empty()) { out["configurations_v3"] = getInstance().getRemoteConfigAnnotations(); } @@ -895,7 +895,7 @@ namespace gameanalytics json contents; - for(auto& obj : getInstance()._configurations) + for(auto& obj : getInstance()._gameRemoteConfigsJson) { if(obj.contains("key") && obj.contains("value")) { @@ -910,10 +910,34 @@ namespace gameanalytics return contents.dump(JSON_PRINT_INDENT); } + void GAState::buildRemoteConfigsJsons(const json& remoteCfgs) + { + _gameRemoteConfigsJson = json::array(); + _trackingRemoteConfigsJson = json::array(); + + for (const auto& configuration : remoteCfgs) + { + _gameRemoteConfigsJson.push_back({ + {"key", configuration["key"]}, + {"value", configuration["value"]} + }); + + _trackingRemoteConfigsJson.push_back({ + {"key", configuration["key"]}, + {"id", configuration["id"]}, + {"vsn", configuration["vsn"]} + }); + } + + logging::GALogger::d("Remote configs: %s", _gameRemoteConfigsJson.dump(JSON_PRINT_INDENT).c_str()); + logging::GALogger::d("Remote configs for tracking: %s", _trackingRemoteConfigsJson.dump(JSON_PRINT_INDENT).c_str()); + logging::GALogger::i("Remote configs ready with %zu configurations", _gameRemoteConfigsJson.size()); + } + void GAState::populateConfigurations(json& sdkConfig) { - std::lock_guard guard(_mtx); - _configurations = {}; + + json _tempRemoteConfigsJson = {}; try { @@ -933,16 +957,18 @@ namespace gameanalytics if (!key.empty() && configuration.contains("value") && client_ts_adjusted > start_ts && client_ts_adjusted < end_ts) { - _configurations[key] = configuration; + _tempRemoteConfigsJson[key] = configuration; logging::GALogger::d("configuration added: %s", configuration.dump(JSON_PRINT_INDENT).c_str()); } } } } + buildRemoteConfigsJsons(_tempRemoteConfigsJson); + _remoteConfigsIsReady = true; - std::string const configStr = _configurations.dump(); + std::string const configStr = _gameRemoteConfigsJson.dump(); for (auto& listener : _remoteConfigsListeners) { listener->onRemoteConfigsUpdated(configStr); @@ -1160,18 +1186,7 @@ namespace gameanalytics json GAState::getRemoteConfigAnnotations() { - json configs; - for(json& obj : _configurations) - { - json cfg; - cfg["vsn"] = utilities::getOptionalValue(obj, "vsn", 0); - cfg["key"] = utilities::getOptionalValue(obj, "key", ""); - cfg["id"] = utilities::getOptionalValue(obj, "id", ""); - - configs.push_back(cfg); - } - - return configs; + return _trackingRemoteConfigsJson; } } } diff --git a/source/gameanalytics/GAState.h b/source/gameanalytics/GAState.h index b2da9593..346a0b86 100644 --- a/source/gameanalytics/GAState.h +++ b/source/gameanalytics/GAState.h @@ -150,9 +150,9 @@ namespace gameanalytics inline static T getRemoteConfigsValue(std::string const& key, T const& defaultValue) { std::lock_guard lg(getInstance()._mtx); - if(getInstance()._configurations.contains(key)) + if(getInstance()._gameRemoteConfigsJson.contains(key)) { - json& config = getInstance()._configurations[key]; + json& config = getInstance()._gameRemoteConfigsJson[key]; T value = utilities::getOptionalValue(config, "value", defaultValue); return value; } @@ -210,6 +210,8 @@ namespace gameanalytics void addErrorEvent(EGAErrorSeverity severity, std::string const& message); + void buildRemoteConfigsJsons(const json& remoteCfgs); + threading::GAThreading _gaThread; events::GAEvents _gaEvents; device::GADevice _gaDevice; @@ -271,7 +273,9 @@ namespace gameanalytics bool _enableIdTracking = true; - json _configurations; + json _gameRemoteConfigsJson; + json _trackingRemoteConfigsJson; + bool _remoteConfigsIsReady; std::vector> _remoteConfigsListeners; std::recursive_mutex _mtx; From f7c058f25f71cd9e342b3d0e1f392c6d2addd046 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 22 Aug 2025 14:31:56 +0300 Subject: [PATCH 49/51] use default arguments instead of duplicated functions --- include/GameAnalytics/GameAnalytics.h | 6 ++---- source/gameanalytics/GameAnalytics.cpp | 12 ------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index 34bf1090..eab66a41 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -138,11 +138,9 @@ namespace gameanalytics static bool isThreadEnding(); private: - static bool _endThread; - static bool isSdkReady(bool needsInitialized); - static bool isSdkReady(bool needsInitialized, bool warn); - static bool isSdkReady(bool needsInitialized, bool warn, std::string const& message); + static bool _endThread; + static bool isSdkReady(bool needsInitialized, bool warn = true, std::string const& message = ""); }; } // namespace gameanalytics diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index dbc4e388..d00655e8 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -956,18 +956,6 @@ namespace gameanalytics return _endThread || threading::GAThreading::isThreadFinished(); } - // --------------PRIVATE HELPERS -------------- // - - bool GameAnalytics::isSdkReady(bool needsInitialized) - { - return isSdkReady(needsInitialized, true); - } - - bool GameAnalytics::isSdkReady(bool needsInitialized, bool warn) - { - return isSdkReady(needsInitialized, warn, ""); - } - bool GameAnalytics::isSdkReady(bool needsInitialized, bool warn, std::string const& message) { constexpr std::size_t maxMsgLen = 64u; From 855d73171cf8416ffb8b687beb3e18df0cadfd1c Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 22 Aug 2025 14:32:53 +0300 Subject: [PATCH 50/51] remove redudndant functions --- include/GameAnalytics/GameAnalytics.h | 4 --- source/gameanalytics/GameAnalytics.cpp | 42 -------------------------- 2 files changed, 46 deletions(-) diff --git a/include/GameAnalytics/GameAnalytics.h b/include/GameAnalytics/GameAnalytics.h index eab66a41..ee0620eb 100644 --- a/include/GameAnalytics/GameAnalytics.h +++ b/include/GameAnalytics/GameAnalytics.h @@ -108,10 +108,6 @@ namespace gameanalytics */ static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue = ""); - static int64_t getRemoteConfigsValueAsInt(std::string const& key, int64_t defaultValue = 0); - static uint64_t getRemoteConfigsValueAsUInt(std::string const& key, uint64_t defaultValue = 0); - static bool getRemoteConfigsValueAsBool(std::string const& key, bool defaultValue = false); - static double getRemoteConfigsValueAsFloat(std::string const& key, double defaultValue = 0.0); static std::string getRemoteConfigsValueAsJson(std::string const& key); static bool isRemoteConfigsReady(); diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index d00655e8..e47d9d72 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -761,48 +761,6 @@ namespace gameanalytics return defaultValue; } - uint64_t GameAnalytics::getRemoteConfigsValueAsUInt(std::string const& key, uint64_t defaultValue) - { - try - { - std::string s = getRemoteConfigsValueAsString(key); - if(!s.empty()) - { - return std::stoull(s); - } - } - catch(std::exception& e) - { - (void)e; - } - - return defaultValue; - } - - double GameAnalytics::getRemoteConfigsValueAsFloat(std::string const& key, double defaultValue) - { - try - { - std::string s = getRemoteConfigsValueAsString(key); - if(!s.empty()) - { - return std::stod(s); - } - } - catch(std::exception& e) - { - (void)e; - } - - return defaultValue; - } - - bool GameAnalytics::getRemoteConfigsValueAsBool(std::string const& key, bool defaultValue) - { - std::string s = getRemoteConfigsValueAsString(key, "false"); - return utilities::toLowerCase(s) == "true"; - } - std::string GameAnalytics::getRemoteConfigsValueAsJson(std::string const& key) { std::string jsonString = getRemoteConfigsValueAsString(key); From 7f03bd09091cb1f77c0ddd305fa0c2a085749286 Mon Sep 17 00:00:00 2001 From: Dorin Date: Fri, 22 Aug 2025 14:53:45 +0300 Subject: [PATCH 51/51] remove old function --- source/gameanalytics/GameAnalytics.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/source/gameanalytics/GameAnalytics.cpp b/source/gameanalytics/GameAnalytics.cpp index e47d9d72..76a8604f 100644 --- a/source/gameanalytics/GameAnalytics.cpp +++ b/source/gameanalytics/GameAnalytics.cpp @@ -743,24 +743,6 @@ namespace gameanalytics return state::GAState::getRemoteConfigsValue(key, defaultValue); } - int64_t GameAnalytics::getRemoteConfigsValueAsInt(std::string const& key, int64_t defaultValue) - { - try - { - std::string s = getRemoteConfigsValueAsString(key); - if(!s.empty()) - { - return std::stoll(s); - } - } - catch(std::exception& e) - { - (void)e; - } - - return defaultValue; - } - std::string GameAnalytics::getRemoteConfigsValueAsJson(std::string const& key) { std::string jsonString = getRemoteConfigsValueAsString(key);