Skip to content

Commit 6c82149

Browse files
authored
Merge pull request #35 from Countly/server_config
Server config
2 parents 387159d + 7cd41d2 commit 6c82149

File tree

7 files changed

+862
-258
lines changed

7 files changed

+862
-258
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 25.4.0
2+
3+
* ! 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.
4+
5+
* Mitigated an issue about orientation detection in Safari
6+
7+
* Improved init time Content Zone logic
8+
* Improved error handler to include script loading issues
9+
10+
* Added `refreshContentZone` method to Content interface for refreshing Content Zone requests
11+
* Added `behavior_settings` init time method for providing server configuration during first initialization
12+
13+
* `max_logs` config option value will not be used anymore (use `max_breadcrumb_count` instead)
14+
115
## 25.1.0
216

317
* Mitigated an issue where content resizing did not work in certain orientations.

cypress/e2e/device_id_init_scenarios.cy.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,19 @@ function checkRequestsForT(queue, expectedInternalType) {
115115
expect(queue[i].t).to.eq(expectedInternalType);
116116
}
117117
}
118-
function checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, temp) {
118+
function checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, temp, afterOffline) {
119119
var directReqs = Countly._internals.testingGetRequests(); // get direct requests
120120
cy.log("Requests: " + JSON.stringify(directReqs));
121121

122-
expect(directReqs.length).to.eq(temp ? 0 : 2);
122+
expect(directReqs.length).to.eq(temp ? 0 : afterOffline?4:3);
123123
for (var i = 0; i < directReqs.length; i++) {
124-
expect(directReqs[i].params.device_id).to.eq(afterInitDeviceId);
125-
expect(directReqs[i].params.t).to.eq(afterInitDeviceIdType);
124+
if (afterOffline && directReqs[i].functionName == "server_config" && i == directReqs.length - 1) {
125+
expect(directReqs[i].params.device_id).to.be.oneOf(["id_2", "storedID", "newID"]);
126+
expect(directReqs[i].params.t).to.eq(DeviceIdTypeInternalEnumsTest.DEVELOPER_SUPPLIED);
127+
} else {
128+
expect(directReqs[i].params.device_id).to.eq(afterInitDeviceId);
129+
expect(directReqs[i].params.t).to.eq(afterInitDeviceIdType);
130+
}
126131
}
127132
}
128133
function checkEachStoredReqForIDandT(afterInitDeviceId, afterInitDeviceIdType) {
@@ -253,7 +258,7 @@ function changeIDTests(afterInitDeviceId, afterInitDeviceIdType, afterOffline) {
253258
// wait for things to resolve
254259
cy.wait(550).then(() => {
255260
// direct requests would have the old device id (hc and session)
256-
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType);
261+
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, false, true);
257262

258263
// after ID events
259264
checkStoredReqQueueAfterIDChange(changedID2, changedIDType2, afterOffline? 3 : 2); // no end and begin session in offline mode => device id change scenario
@@ -459,7 +464,7 @@ describe("Device Id tests during first init", ()=>{
459464
// wait for things to resolve
460465
cy.wait(550).then(() => {
461466
// direct requests would have the old device id (hc and session)
462-
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType);
467+
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, false, true);
463468

464469
// after ID events
465470
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true); // no end and begin session in offline mode => device id change scenario
@@ -535,7 +540,7 @@ describe("Device Id tests during first init", ()=>{
535540
// wait for things to resolve
536541
cy.wait(550).then(() => {
537542
// direct requests would have the old device id (hc and session)
538-
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType);
543+
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, false, true);
539544

540545
// after ID events
541546
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true);
@@ -687,7 +692,7 @@ describe("Device Id tests during first init", ()=>{
687692
// wait for things to resolve
688693
cy.wait(550).then(() => {
689694
// direct requests would have the old device id (hc and session)
690-
checkEachDirectReqForIDandT(afterInitDeviceId, DeviceIdTypeInternalEnumsTest.URL_PROVIDED);
695+
checkEachDirectReqForIDandT(afterInitDeviceId, DeviceIdTypeInternalEnumsTest.URL_PROVIDED, false, true);
691696

692697
// after ID events
693698
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true);
@@ -1756,7 +1761,7 @@ describe("Device Id tests during first init", ()=>{
17561761
// wait for things to resolve
17571762
cy.wait(550).then(() => {
17581763
// direct requests would have the old device id (hc and session)
1759-
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType);
1764+
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, false, true);
17601765

17611766
// after ID events
17621767
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true); // no end and begin session in offline mode => device id change scenario
@@ -1832,7 +1837,7 @@ describe("Device Id tests during first init", ()=>{
18321837
// wait for things to resolve
18331838
cy.wait(550).then(() => {
18341839
// direct requests would have the old device id (hc and session)
1835-
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType);
1840+
checkEachDirectReqForIDandT(afterInitDeviceId, afterInitDeviceIdType, false, true);
18361841

18371842
// after ID events
18381843
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true);
@@ -1984,7 +1989,7 @@ describe("Device Id tests during first init", ()=>{
19841989
// wait for things to resolve
19851990
cy.wait(550).then(() => {
19861991
// direct requests would have the old device id (hc and session)
1987-
checkEachDirectReqForIDandT(afterInitDeviceId, DeviceIdTypeInternalEnumsTest.URL_PROVIDED);
1992+
checkEachDirectReqForIDandT(afterInitDeviceId, DeviceIdTypeInternalEnumsTest.URL_PROVIDED, false, true);
19881993

19891994
// after ID events
19901995
checkStoredReqQueueAfterIDChange(changedID, changedIDType, true);

cypress/e2e/integration.cy.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,14 @@ function initMain() {
1616
describe("Integration test", () => {
1717
it("int, no consent, no offline_mode", () => {
1818
initMain();
19-
const idType = Countly.get_device_id_type();
20-
const id = Countly.get_device_id();
21-
const consentStatus = Countly.check_any_consent();
22-
Countly.remove_consent();
23-
Countly.disable_offline_mode();
24-
Countly.add_event({ key: "test", count: 1, sum: 1, dur: 1, segmentation: { test: "test" } });
25-
Countly.start_event("test");
26-
Countly.cancel_event("gobbledygook");
27-
Countly.end_event("test");
28-
Countly.report_conversion("camp_id", "camp_user_id");
29-
Countly.recordDirectAttribution("camp_id", "camp_user_id");
30-
Countly.user_details({ name: "name" });
31-
Countly.userData.set("set", "set");
32-
Countly.userData.save();
33-
Countly.report_trace({ name: "name", stz: 1, type: "type" });
34-
Countly.log_error({ error: "error", stack: "stack" });
35-
Countly.add_log("error");
36-
Countly.fetch_remote_config();
37-
Countly.enrollUserToAb();
38-
const remote = Countly.get_remote_config();
39-
Countly.track_sessions();
40-
Countly.track_pageview();
41-
Countly.track_errors();
42-
Countly.track_clicks();
43-
Countly.track_scrolls();
44-
Countly.track_links();
45-
Countly.track_forms();
46-
Countly.collect_from_forms();
47-
Countly.collect_from_facebook();
48-
Countly.opt_in();
49-
// TODO: widgets
50-
// TODO: make better
19+
var consentStatus = Countly.check_any_consent();
20+
var remote = Countly.get_remote_config();
21+
var id = Countly.get_device_id();
22+
var idType = Countly.get_device_id_type();
23+
hp.integrationMethods();
5124
cy.fetch_local_request_queue().then((rq) => {
5225
cy.log(rq);
53-
hp.testNormalFlow(rq, "/__cypress/iframes/cypress%5Ce2e%5Cintegration.cy.js", hp.appKey);
26+
hp.testNormalFlowInt(rq, "/__cypress/iframes/cypress%5Ce2e%5Cintegration.cy.js", hp.appKey);
5427
expect(consentStatus).to.equal(true); // no consent necessary
5528
expect(remote).to.eql({}); // deepEqual
5629
expect(rq[0].device_id).to.equal(id);

cypress/e2e/remaining_requests.cy.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ describe("Remaining requests tests ", () => {
2828
expect(JSON.parse(queues.requestQ[2]["events"])[0].key).to.equal("[CLY]_orientation");
2929

3030
var requests = Countly._internals.testingGetRequests();
31-
expect(requests.length).to.equal(2);
31+
expect(requests.length).to.equal(3);
3232
expect(requests[0].params["rr"]).to.equal(undefined);
33-
expect(requests[1].params["rr"]).to.equal(3);
34-
expect(requests[1].params["av"]).to.equal(av);
33+
expect(requests[1].params["rr"]).to.equal(undefined);
34+
expect(requests[2].params["rr"]).to.equal(3);
35+
expect(requests[2].params["av"]).to.equal(av);
3536
});
3637
});
3738
});

0 commit comments

Comments
 (0)