Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4e23c46
add NoContent code
dorin-ga Mar 13, 2026
4079ca9
handle code 204 as success
dorin-ga Mar 13, 2026
f2aa42d
treat code 204 as valid response
dorin-ga Mar 13, 2026
1849945
allow 204 for sdk error event
dorin-ga Mar 16, 2026
7911d53
add response code constants
dorin-ga Mar 16, 2026
58c5ed8
print correct status code
dorin-ga Mar 16, 2026
2b08477
http interface
dorin-ga Mar 18, 2026
913e16c
default http implementation
dorin-ga Mar 18, 2026
d592130
use http impl
dorin-ga Mar 18, 2026
ec57ac4
changes to processRequestResponse
dorin-ga Mar 19, 2026
ae729b3
fix debug logs
dorin-ga Mar 19, 2026
bf5af41
add virtual dtor for http api
dorin-ga Mar 23, 2026
c26dcb1
add enum for sdk error
dorin-ga Mar 23, 2026
763df97
simplify code
dorin-ga Mar 23, 2026
0185451
sanity check for impl
dorin-ga Mar 23, 2026
d095251
return error is response code is invalid
dorin-ga Apr 1, 2026
e086082
missing return code
dorin-ga Apr 1, 2026
24090ca
fix: check response status before parsing JSON in init request
Gogoshika-ga Apr 2, 2026
997bb0a
Fix: Early-return an empty string_view when packet is empty.
Gogoshika-ga Apr 2, 2026
d544623
fix: use correct format specifier %ld for status code log
Gogoshika-ga Apr 2, 2026
b932426
move GAHttpWrapper to public include and allow registering a custom H…
Gogoshika-ga Apr 2, 2026
029ce47
add HTTP interface tests and README documentation
Gogoshika-ga Apr 2, 2026
b7af985
fix MSVC min macro conflict in GAUtilities
Gogoshika-ga Apr 2, 2026
1761269
update github actions to prevent node.js warnings
Gogoshika-ga Apr 2, 2026
ab2563b
rename GAHttpWrapper to GAHttpClient
Gogoshika-ga Apr 2, 2026
a3dc128
fix NOMINMAX for windows
Gogoshika-ga Apr 2, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
c_compiler: gcc

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand All @@ -79,7 +79,7 @@ jobs:
fi

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for tags and commits

Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,58 @@ void myLogHandler(const char* message, GALoggerMessageType type)
gameAnalytics_configureCustomLogHandler(myLogHandler);
```

### Custom HTTP client

By default, the SDK uses cURL for HTTP requests. If you need to use a different HTTP library (e.g. on consoles or custom platforms), you can provide your own implementation by subclassing `GAHttpClient`:

``` c++
#include "GameAnalytics/GAHttpClient.h"

class MyHttpClient : public gameanalytics::GAHttpClient
{
public:
void initialize() override
{
// Set up your HTTP library
}

void cleanup() override
{
// Tear down your HTTP library
}

Response sendRequest(
std::string const& url,
std::string const& auth,
std::vector<uint8_t> const& payloadData,
bool useGzip,
void* userData) override
{
Response response;

// Use your HTTP library to POST payloadData to url.
// Set the following headers:
// - auth (e.g. "Authorization: ...")
// - "Content-Type: application/json"
// - "Content-Encoding: gzip" (if useGzip is true)
//
// Fill in response.code with the HTTP status code.
// Fill in response.packet with the response body bytes.

return response;
}
};
```

Register it **before** calling `initialize()`:

``` c++
gameanalytics::GameAnalytics::configureHttpClient(std::make_unique<MyHttpClient>());
gameanalytics::GameAnalytics::initialize("<your game key>", "<your secret key>");
```

If `configureHttpClient` is not called, the built-in cURL implementation is used.

### Configuration

Example:
Expand Down
40 changes: 40 additions & 0 deletions include/GameAnalytics/GAHttpClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <string>
#include <string_view>
#include <vector>
#include <cstdint>

namespace gameanalytics
{
class GAHttpClient
{
public:

struct Response
{
long code = -1;
std::vector<uint8_t> packet;

inline std::string_view toString() const
{
if(packet.empty()) return {};
return std::string_view((const char*)packet.data(), packet.size());
}
};

virtual ~GAHttpClient() {};

virtual void initialize() = 0;

virtual void cleanup() = 0;

virtual Response sendRequest(
std::string const& url,
std::string const& auth,
std::vector<uint8_t> const& payloadData,
bool useGzip,
void* userData) = 0;
};

} // namespace gameanalytics
6 changes: 6 additions & 0 deletions include/GameAnalytics/GameAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#pragma once

#include "GameAnalytics/GATypes.h"
#include "GameAnalytics/GAHttpClient.h"

namespace gameanalytics
{

class GameAnalytics
{
public:
Expand Down Expand Up @@ -61,6 +63,10 @@ namespace gameanalytics

static void configureExternalUserId(std::string const& extId);

// Set a custom HTTP implementation. Must be called before initialize().
// If not called, the default cURL implementation is used.
static void configureHttpClient(std::unique_ptr<GAHttpClient> httpClient);

// initialize - starting SDK (need configuration before starting)
static void initialize(std::string const& gameKey, std::string const& gameSecret);

Expand Down
2 changes: 1 addition & 1 deletion source/gameanalytics/GAEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ namespace gameanalytics
responseEnum = http.sendEventsInArray(dataDict, payloadArray);
#endif

if (responseEnum == http::Ok)
if (responseEnum == http::Ok || responseEnum == http::NoContent)
{
// Delete events
store::GAStore::executeQuerySync(deleteSql);
Expand Down
Loading
Loading