Skip to content

[WIP] Playtime Support #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4786607
using default argument instead of duplicated function
dorin-ga Feb 27, 2025
cec686e
Update Main.cpp
Gogoshika-ga Mar 13, 2025
bcde102
set ubuntu-24.04 and clang version to 16
Gogoshika-ga Mar 13, 2025
5c6d7e7
Update cmake.yml
Gogoshika-ga Mar 13, 2025
5586240
Update cmake.yml
Gogoshika-ga Mar 13, 2025
2f751e4
Update cmake.yml
Gogoshika-ga Mar 13, 2025
b79e828
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
2f2c2eb
Update cmake.yml
Gogoshika-ga Mar 13, 2025
ebbf72f
Update cmake.yml
Gogoshika-ga Mar 13, 2025
9a6867a
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
fc62e19
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
1225840
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
691a618
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
bd08d61
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
792a871
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
df964bd
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
876f32b
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
e1b552e
Update guid.cpp
Gogoshika-ga Mar 13, 2025
cf493e7
Update guid.cpp
Gogoshika-ga Mar 13, 2025
ebca0f4
Update CMakeLists.txt
Gogoshika-ga Mar 13, 2025
6d771f5
try and fix libc++ compatibility issues for linux
Gogoshika-ga Mar 14, 2025
0d8ecb4
Update cmake.yml
Gogoshika-ga Mar 14, 2025
409966e
Update cmake.yml
Gogoshika-ga Mar 14, 2025
4e00501
Update GALinux.cpp
Gogoshika-ga Mar 14, 2025
884ae5d
Update CMakeLists.txt
Gogoshika-ga Mar 14, 2025
2cd685c
Update CMakeLists.txt
Gogoshika-ga Mar 14, 2025
ed36c73
Merge branch 'development' of https://github.com/GameAnalytics/gamean…
Gogoshika-ga Mar 14, 2025
c1dbc7d
Update CMakeLists.txt
Gogoshika-ga Mar 14, 2025
2da61b0
Update cmake.yml
Gogoshika-ga Mar 14, 2025
02e2364
use with older ubuntu 20.04
Gogoshika-ga Mar 14, 2025
2cca217
Update cmake.yml
Gogoshika-ga Mar 14, 2025
733ef2a
Update cmake.yml
Gogoshika-ga Mar 14, 2025
2a4ad72
Update cmake.yml
Gogoshika-ga Mar 14, 2025
72a65ad
Update cmake.yml
Gogoshika-ga Mar 14, 2025
fd84651
Merge branch 'development' of https://github.com/GameAnalytics/gamean…
Gogoshika-ga Mar 14, 2025
43f2de4
Update CMakeLists.txt
Gogoshika-ga Mar 26, 2025
3a572cf
expose identifiers
dorin-ga Mar 26, 2025
4eb45a4
renamed getUserId
dorin-ga Mar 26, 2025
dc86721
added gpu model
dorin-ga May 22, 2025
b57c305
playtime support
dorin-ga May 22, 2025
22beea3
playtime support
dorin-ga May 22, 2025
9a88dce
removed redudant function declaration
dorin-ga May 22, 2025
8904879
remote configs v3
dorin-ga Jun 6, 2025
bea3925
remote configs v3 support
dorin-ga Jun 6, 2025
f4f36eb
do not drop fps values outside range
dorin-ga Jun 6, 2025
796c6c9
features for remote configs v3
dorin-ga Jun 6, 2025
6d1e591
track gpu model
dorin-ga Jun 6, 2025
01b4543
fixed gpu model retrieval for windows
dorin-ga Jun 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ jobs:
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Install Clang and Libraries
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: 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-latest' && matrix.c_compiler == 'clang'
run: |
clang --version
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.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand All @@ -83,7 +107,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

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ 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()

Expand All @@ -209,7 +210,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
Expand Down
21 changes: 18 additions & 3 deletions include/GameAnalytics/GameAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,33 @@ 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);
/*
template<typename T>
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<IRemoteConfigsListener> &listener);
static void removeRemoteConfigsListener(const std::shared_ptr<IRemoteConfigsListener> &listener);

static std::string getRemoteConfigsContentAsString();
static std::string getRemoteConfigsContentAsJson();

static std::string getUserId();
static std::string getExternalUserId();

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();
Expand All @@ -130,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
1 change: 1 addition & 0 deletions sample/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <string>
#include <iostream>
#include <thread>
#include <chrono>

#include "GameAnalytics/GameAnalytics.h"

Expand Down
1 change: 1 addition & 0 deletions source/gameanalytics/GADevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace gameanalytics
std::string _osVersion;
std::string _deviceModel;
std::string _deviceManufacturer;
std::string _gpu;

std::string _writablepath;
bool _writablepathStatus{false};
Expand Down
3 changes: 2 additions & 1 deletion source/gameanalytics/GAEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ namespace gameanalytics

try
{
int64_t sessionLength = state.calculateSessionLength();
// get session length in seconds
int64_t sessionLength = state.calculateSessionLength<std::chrono::seconds>();

if(sessionLength < 0ll)
{
Expand Down
2 changes: 1 addition & 1 deletion source/gameanalytics/GAHTTPApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
9 changes: 4 additions & 5 deletions source/gameanalytics/GAHealth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -65,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)
{
Expand Down Expand Up @@ -169,7 +169,6 @@ namespace gameanalytics
}
}
);

}
}
}
3 changes: 2 additions & 1 deletion source/gameanalytics/GAHealth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading