Skip to content

Commit 9b47134

Browse files
authored
Merge pull request #141 from Countly/staging
Staging 23.2.2
2 parents 79038e0 + f725c1a commit 9b47134

File tree

14 files changed

+323
-43
lines changed

14 files changed

+323
-43
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release Notice
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# To check the github context
11+
- name: Dump Github context
12+
env:
13+
GITHUB_CONTEXT: ${{ toJSON(github) }}
14+
run: echo "$GITHUB_CONTEXT"
15+
- name: Send custom JSON data to Slack workflow
16+
id: slack
17+
uses: slackapi/[email protected]
18+
with:
19+
# This data can be any valid JSON from a previous step in the GitHub Action
20+
payload: |
21+
{
22+
"repository": "${{ github.repository }}",
23+
"tag_name": "${{ github.event.release.tag_name }}",
24+
"actor": "${{ github.actor }}",
25+
"body": ${{ toJSON(github.event.release.body) }},
26+
"html_url": "${{ github.event.release.html_url }}"
27+
}
28+
env:
29+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE }}
30+
- name: Send custom JSON data to Discord
31+
uses: sarisia/[email protected]
32+
with:
33+
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
34+
nodetail: true
35+
title: New ${{ github.repository }} version ${{ github.event.release.tag_name }} published by ${{ github.actor }}
36+
description: |
37+
Release URL: ${{ github.event.release.html_url }}
38+
Click [here](https://github.com/Countly/countly-server/blob/master/CHANGELOG.md) to view the change log.
39+
`${{ github.event.release.body }}`

.github/workflows/tests.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os:
17-
- ubuntu-20.04
18-
- macos-11.0
19-
- windows-2019
17+
- ubuntu-22.04
18+
- macos-15
19+
- windows-2022
2020

2121
include:
22-
- os: windows-2019
23-
cmake-generator: -G "Visual Studio 16 2019" -A x64
24-
cmake-install: "choco install -y cmake"
25-
dependencies: |
26-
choco install -y openssl
27-
choco install -y visualstudio2017-workload-vctools
28-
choco upgrade -y visualstudio2017-workload-vctools
29-
make: msbuild countly-tests.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release && .\Release\countly-tests.exe
30-
- os: macos-11.0
31-
cmake-install: "brew install cmake"
32-
dependencies: "brew install openssl"
22+
- os: windows-2022
23+
cmake-generator: -G "Visual Studio 17 2022" -A x64
24+
cmake-install: "" #Already installed on hosted runner
25+
dependencies: "" #Already installed on hosted runner
26+
make: msbuild countly-tests.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release && .\Release\countly-tests.exe
27+
- os: macos-15
28+
cmake-install: "" #Already installed on hosted runner
29+
dependencies: "" #Already installed on hosted runner
3330
make: make ./countly-tests && ./countly-tests
34-
- os: ubuntu-20.04
35-
cmake-install: "sudo apt-get update && sudo apt-get install -y cmake"
36-
dependencies: "sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev"
31+
- os: ubuntu-22.04
32+
cmake-install: "" #Already installed on hosted runner
33+
dependencies: |
34+
sudo apt-get update && sudo apt-get install -y \
35+
libcurl4-openssl-dev \
36+
libssl-dev
3737
make: make ./countly-tests && ./countly-tests
3838

3939
steps:
@@ -52,11 +52,13 @@ jobs:
5252
run: ${{ matrix.dependencies }}
5353

5454
- name: Set up MSVC
55-
if: matrix.os == 'windows-2019'
55+
if: matrix.os == 'windows-2022'
5656
uses: microsoft/setup-msbuild@v1
5757

5858
- name: Build and run tests
5959
run: |
6060
cmake -DCOUNTLY_BUILD_TESTS=1 -B build . ${{ matrix.cmake-generator }}
6161
cd build
6262
${{ matrix.make }}
63+
env:
64+
CMAKE_POLICY_VERSION_MINIMUM: 3.31

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 23.2.2
2+
- Mitigated a mutex issue that can happen during update loop.
3+
4+
## 23.2.1
5+
- Added manual session control via "Countly::enableManualSessionControl". When enabled, automatic session calls are ignored, while manual calls remain usable for finer control.
6+
- Added "checkRQSize" function to return the current number of requests in the queue.
7+
18
## 23.2.0
29
- Request queue processing now is limited to 100 requests at a time
310
- Added 'setEventsToRQThreshold' method that sets the number of events after which all events will be sent to the RQ. Default value is set to 100.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f3268a85b0034b68aa4fc47c9dce596c)](https://www.codacy.com/gh/Countly/countly-sdk-cpp/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Countly/countly-sdk-cpp&utm_campaign=Badge_Grade)
1+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f3268a85b0034b68aa4fc47c9dce596c)](https://app.codacy.com/gh/Countly/countly-sdk-cpp/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
22

33
# Countly C++ SDK
44

examples/example_integration.cpp

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,115 @@ void printLog(LogLevel level, const string &msg) {
3030
cout << lvl << msg << endl;
3131
}
3232

33+
// // Callback function to write response data
34+
// static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
35+
// ((std::string*)userp)->append((char*)contents, size * nmemb);
36+
// return size * nmemb;
37+
// }
38+
39+
// // Custom HTTP client for macOS
40+
// HTTPResponse customClient(bool use_post, const std::string &path, const std::string &data) {
41+
// HTTPResponse response;
42+
// response.success = false;
43+
// cout << "Making real HTTP request to: " << path << endl;
44+
45+
// CURL *curl;
46+
// CURLcode res;
47+
// std::string readBuffer;
48+
49+
// curl = curl_easy_init();
50+
// if(curl) {
51+
// // Set URL
52+
// curl_easy_setopt(curl, CURLOPT_URL, path.c_str());
53+
54+
// // Set callback function to write data
55+
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
56+
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
57+
58+
// // Set timeout
59+
// curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L);
60+
61+
// // Follow redirects
62+
// curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
63+
64+
// // SSL verification (set to 0 for testing, 1 for production)
65+
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
66+
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
67+
68+
// // Set User-Agent
69+
// curl_easy_setopt(curl, CURLOPT_USERAGENT, "Countly-SDK-CPP/1.0");
70+
71+
// if (use_post) {
72+
// // Set POST method
73+
// curl_easy_setopt(curl, CURLOPT_POST, 1L);
74+
75+
// if (!data.empty()) {
76+
// // Set POST data
77+
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
78+
// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, data.length());
79+
// }
80+
81+
// // Set content type for POST
82+
// struct curl_slist *headers = NULL;
83+
// headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
84+
// curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
85+
// } else {
86+
// // For GET requests, append data as query parameters
87+
// if (!data.empty()) {
88+
// std::string fullUrl = path;
89+
// fullUrl += (path.find('?') != std::string::npos) ? "&" : "?";
90+
// fullUrl += data;
91+
// curl_easy_setopt(curl, CURLOPT_URL, fullUrl.c_str());
92+
// }
93+
// }
94+
95+
// // Perform the request
96+
// res = curl_easy_perform(curl);
97+
98+
// if(res != CURLE_OK) {
99+
// cout << "curl_easy_perform() failed: " << curl_easy_strerror(res) << endl;
100+
// } else {
101+
// // Get response code
102+
// long response_code;
103+
// curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
104+
105+
// cout << "HTTP Response Code: " << response_code << endl;
106+
// cout << "Raw response: " << readBuffer << endl;
107+
108+
// // Check if HTTP request was successful (2xx status codes)
109+
// if (response_code >= 200 && response_code < 300) {
110+
// // Check if response contains { result: 'Success' } or {"result":"Success"}
111+
// if (readBuffer.find("\"result\"") != std::string::npos &&
112+
// (readBuffer.find("\"Success\"") != std::string::npos ||
113+
// readBuffer.find("'Success'") != std::string::npos)) {
114+
// response.success = true;
115+
// cout << "Success response detected!" << endl;
116+
// } else {
117+
// cout << "Response does not indicate success" << endl;
118+
// }
119+
120+
// // Parse as JSON
121+
// try {
122+
// response.data = nlohmann::json::parse(readBuffer);
123+
// } catch (const std::exception& e) {
124+
// cout << "Failed to parse JSON response: " << e.what() << endl;
125+
// response.data = nlohmann::json::object();
126+
// }
127+
// } else {
128+
// cout << "HTTP request failed with code: " << response_code << endl;
129+
// }
130+
// }
131+
132+
// // Cleanup
133+
// curl_easy_cleanup(curl);
134+
// } else {
135+
// cout << "Failed to initialize curl" << endl;
136+
// }
137+
138+
// cout << "Request completed. Success: " << (response.success ? "true" : "false") << endl;
139+
// return response;
140+
// }
141+
33142
int main() {
34143
cout << "Sample App" << endl;
35144
Countly &ct = Countly::getInstance();
@@ -38,7 +147,10 @@ int main() {
38147
// Please refer to the documentation for more information:
39148
// https://support.count.ly/hc/en-us/articles/4416163384857-C-
40149

41-
ct.alwaysUsePost(true);
150+
// Custom HTTP client
151+
// HTTPClientFunction clientPtr = customClient;
152+
// ct.setHTTPClient(clientPtr);
153+
// ct.alwaysUsePost(true);
42154
ct.setLogger(printLog);
43155
ct.SetPath("databaseFileName.db"); // this will be only built into account if the correct configurations are set
44156
ct.setDeviceID("test-device-id");
@@ -47,7 +159,14 @@ int main() {
47159
ct.SetMetrics("Windows 10", "10.22", "Mac", "800x600", "Carrier", "1.0");
48160

49161
// start the SDK (initialize the SDK)
50-
ct.start("YOUR_APP_KEY", "https://try.count.ly", 443, true);
162+
string _appKey = "YOUR_APP_KEY";
163+
string _serverUrl = "https://your.server.ly";
164+
165+
if(_appKey.compare("YOUR_APP_KEY") == 0 || _serverUrl.compare("https://your.server.ly") == 0) {
166+
cerr << "Please do not use default set of app key and server url" << endl;
167+
}
168+
169+
ct.start(_appKey, _serverUrl, 443, true);
51170

52171
ct.setAutomaticSessionUpdateInterval(5);// The value is set so low just for internal validation.
53172
ct.setMaxRQProcessingBatchSize(2); // in most cases not needed to be set. The value is set so low just for internal validation

include/countly.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Countly : public cly::CountlyDelegates {
5656

5757
void setSha256(cly::SHA256Function fun);
5858

59+
void enableManualSessionControl();
60+
5961
void setHTTPClient(HTTPClientFunction fun);
6062

6163
void setMetrics(const std::string &os, const std::string &os_version, const std::string &device, const std::string &resolution, const std::string &carrier, const std::string &app_version);
@@ -105,6 +107,11 @@ class Countly : public cly::CountlyDelegates {
105107
*/
106108
int checkEQSize();
107109

110+
/*
111+
* Checks and returns the size of the request queue in memory or persistent storage.
112+
*/
113+
int checkRQSize();
114+
108115
/**
109116
* Checks and returns the size of the event queue in persistent storage.
110117
*/
@@ -319,6 +326,7 @@ class Countly : public cly::CountlyDelegates {
319326
std::chrono::system_clock::duration getSessionDuration();
320327

321328
void updateLoop();
329+
void packEvents();
322330
bool began_session = false;
323331
bool is_being_disposed = false;
324332
bool is_sdk_initialized = false;

include/countly/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <string>
1414

1515
#define COUNTLY_SDK_NAME "cpp-native-unknown"
16-
#define COUNTLY_SDK_VERSION "23.2.0"
16+
#define COUNTLY_SDK_VERSION "23.2.2"
1717
#define COUNTLY_POST_THRESHOLD 2000
1818
#define COUNTLY_KEEPALIVE_INTERVAL 3000
1919
#define COUNTLY_MAX_EVENTS_DEFAULT 200

include/countly/countly_configuration.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ struct CountlyConfiguration {
6868

6969
SHA256Function sha256_function = nullptr;
7070

71+
bool manualSessionControl = false;
72+
7173
HTTPClientFunction http_client_function = nullptr;
7274

7375
nlohmann::json metrics;

include/countly/request_module.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class RequestModule {
3535
*/
3636
void clearRequestQueue();
3737

38+
long long RQSize();
39+
3840
private:
3941
class RequestModuleImpl;
4042
std::unique_ptr<RequestModuleImpl> impl;

0 commit comments

Comments
 (0)