Skip to content

Commit ed8cb72

Browse files
authored
Merge pull request #570 from Countly/backoff-addition
Backoff addition
2 parents e5c7bdb + 66c152a commit ed8cb72

File tree

10 files changed

+1202
-250
lines changed

10 files changed

+1202
-250
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 25.4.1
2+
3+
- Added automatic backoff mechanism which delays sending requests if server seems busy
4+
- Added `disable_sdk_behavior_settings_updates` init method for disabling Server Configuration sync requests
5+
- Added `disable_backoff_mechanism` init method for disabling backoff mechanism
6+
- Added timezone support for server
7+
18
## 25.4.0
29

310
- ! Minor Breaking Change ! SDK now has Server Configuration feature and it is enabled by default. Changes made on SDK Manager > SDK Configuration on your server will affect SDK behavior directly.

cypress.config.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,71 @@ const { defineConfig } = require('cypress')
22
module.exports = defineConfig({
33
e2e: {
44
setupNodeEvents(on, config) {
5-
// implement node event listeners here
5+
6+
// Include any other plugin code...
7+
const http = require('http');
8+
let server = null;
9+
let responseDelay = 0;
10+
let requests = [];
11+
12+
on('task', {
13+
startServer() {
14+
return new Promise((resolve) => {
15+
requests = [];
16+
server = http.createServer((req, res) => {
17+
res.setHeader('Access-Control-Allow-Origin', '*');
18+
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
19+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
20+
21+
if (req.method === 'OPTIONS') {
22+
res.writeHead(204);
23+
return res.end();
24+
}
25+
26+
let body = '';
27+
req.on('data', chunk => { body += chunk; });
28+
req.on('end', () => {
29+
requests.push({ method: req.method, url: req.url, headers: req.headers, body });
30+
setTimeout(() => {
31+
res.writeHead(200, { 'Content-Type': 'application/json' });
32+
res.end(JSON.stringify({ result: 'Success' }));
33+
}, responseDelay);
34+
});
35+
});
36+
server.listen(9000, () => {
37+
console.log('Test server running on http://localhost:9000');
38+
resolve(null);
39+
});
40+
});
41+
},
42+
stopServer() {
43+
return new Promise((resolve) => {
44+
if (server) {
45+
server.close(() => {
46+
requests = [];
47+
console.log('Test server stopped');
48+
resolve(null);
49+
});
50+
} else {
51+
resolve(null);
52+
}
53+
});
54+
},
55+
setResponseDelay(ms) {
56+
responseDelay = ms;
57+
return null;
58+
},
59+
getRequests() {
60+
return requests;
61+
},
62+
clearRequests() {
63+
requests = [];
64+
return null;
65+
},
66+
});
67+
68+
// IMPORTANT: Return the config object with any changed environment variables
69+
return config;
670
},
771
},
872
userAgent: "abcd",

cypress/e2e/bridged_utils.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function initMain(name, version) {
1515
}
1616

1717
const SDK_NAME = "javascript_native_web";
18-
const SDK_VERSION = "25.4.0";
18+
const SDK_VERSION = "25.4.1";
1919

2020
// tests
2121
describe("Bridged SDK Utilities Tests", () => {

cypress/e2e/health_check.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("Health Check tests", () => {
2121

2222
const hcParam = params.get("hc");
2323
const hcParamObj = JSON.parse(decodeURIComponent(hcParam));
24-
expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "" });
24+
expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "", bom: 0, cbom: 0 });
2525

2626
const metricsParam = params.get("metrics");
2727
expect(metricsParam).to.equal("{\"_app_version\":\"0.0\",\"_ua\":\"abcd\"}");

0 commit comments

Comments
 (0)