Skip to content

Commit 1d56374

Browse files
authored
Merge pull request #562 from Countly/version-25.4
Version 25.4 Update
2 parents bc8353e + 63d4c3e commit 1d56374

File tree

9 files changed

+1166
-525
lines changed

9 files changed

+1166
-525
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
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+
- Improved the wrapper of Feedback Widgets
10+
11+
- Added `refreshContentZone` method to Content interface for refreshing Content Zone requests
12+
- Added `behavior_settings` init time method for providing server configuration during first initialization
13+
- Added `content_whitelist` init time method that lets you whitelist your other domains for displaying Content
14+
15+
- `max_logs` config option value will not be used anymore (use `max_breadcrumb_count` instead)
16+
117
## 25.1.0
218

319
- Improved orientation reporting precision.

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.1.0";
18+
const SDK_VERSION = "25.4.0";
1919

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

cypress/e2e/device_id_init_scenarios.cy.js

Lines changed: 88 additions & 83 deletions
Large diffs are not rendered by default.

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/sdk_behavior.cy.js

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
2+
var Countly = require("../../lib/countly");
3+
var hp = require("../support/helper.js");
4+
5+
function initMain(val) {
6+
Countly.init({
7+
app_key: "spp",
8+
url: "https://hey.some.ly",
9+
debug: true,
10+
behavior_settings: val
11+
});
12+
}
13+
14+
function sentReqList(size, expectedKeywords, nonexistingKeywords) {
15+
var directReqs = Countly._internals.testingGetRequests(); // get direct requests
16+
var functionNames = directReqs.map((item) => item.functionName);
17+
cy.log("Direct Requests: " + JSON.stringify(directReqs));
18+
19+
if (typeof size !== 'undefined') {
20+
expect(directReqs.length).to.eq(size);
21+
}
22+
if (expectedKeywords) {
23+
for (var i = 0; i < expectedKeywords.length; i++) {
24+
expect(functionNames.includes(expectedKeywords[i])).to.be.true;
25+
}
26+
}
27+
if (nonexistingKeywords) {
28+
for (var j = 0; j < nonexistingKeywords.length; j++) {
29+
expect(functionNames.includes(nonexistingKeywords[j])).to.be.false;
30+
}
31+
}
32+
}
33+
function queues(eqsize, rqsize, expectedKeywords, nonexistingKeywords) {
34+
var queues = Countly._internals.getLocalQueues(); // get local queues
35+
const allKeysE = queues.eventQ.flatMap(item => Object.keys(item));
36+
const allKeysQ = queues.requestQ.flatMap(item => Object.keys(item));
37+
const uniqueKeys = [...new Set(allKeysE), ...new Set(allKeysQ)];
38+
39+
const allValuesE = queues.eventQ.flatMap(item => Object.values(item));
40+
const allValuesQ = queues.requestQ.flatMap(item => Object.values(item));
41+
const uniqueValues = [...new Set(allValuesE), ...new Set(allValuesQ)];
42+
43+
cy.log("Unique Keys: " + JSON.stringify(uniqueKeys));
44+
cy.log("Queues: " + JSON.stringify(queues));
45+
46+
if (typeof eqsize !== 'undefined') {
47+
expect(queues.eventQ.length).to.eq(eqsize);
48+
}
49+
if (typeof rqsize !== 'undefined') {
50+
expect(queues.requestQ.length).to.eq(rqsize);
51+
}
52+
if (expectedKeywords) {
53+
for (var i = 0; i < expectedKeywords.length; i++) {
54+
expect(uniqueKeys.includes(expectedKeywords[i])).to.be.true;
55+
}
56+
}
57+
if (nonexistingKeywords) {
58+
for (var j = 0; j < nonexistingKeywords.length; j++) {
59+
expect(uniqueValues.includes(nonexistingKeywords[j])).to.be.false;
60+
}
61+
}
62+
}
63+
64+
const waitT = 2000;
65+
66+
describe("SDK Behavior test", () => {
67+
it("Basic initialization with default config", () => {
68+
hp.haltAndClearStorage(() => {
69+
initMain();
70+
cy.wait(waitT).then(() => {
71+
cy.fetch_local_request_queue().then((rq) => {
72+
cy.log("Request Queue: " + JSON.stringify(rq));
73+
sentReqList(2, ["server_config", "[healthCheck]"]);
74+
queues(0, 0);
75+
});
76+
});
77+
});
78+
});
79+
80+
it("Initialization with default config and integration methods", () => {
81+
hp.haltAndClearStorage(() => {
82+
initMain();
83+
hp.integrationMethods();
84+
cy.wait(waitT).then(() => {
85+
cy.fetch_local_request_queue().then((rq) => {
86+
cy.log("Request Queue: " + JSON.stringify(rq));
87+
sentReqList(9, ["server_config", "[healthCheck]", "enrollUserToAb", "fetch_remote_config_explicit", "send_request_queue", "get_available_feedback_widgets,"]);
88+
queues(0, 15);
89+
});
90+
});
91+
});
92+
});
93+
94+
it("Config with networking disabled", () => {
95+
hp.haltAndClearStorage(() => {
96+
var settings = {};
97+
settings.c = {
98+
networking: false
99+
};
100+
initMain(settings);
101+
hp.integrationMethods();
102+
cy.wait(waitT).then(() => {
103+
cy.fetch_local_request_queue().then((rq) => {
104+
cy.log("Request Queue: " + JSON.stringify(rq));
105+
sentReqList(1, ["server_config"]);
106+
queues(0, 15);
107+
});
108+
});
109+
});
110+
});
111+
112+
it("Config with tracking disabled", () => {
113+
hp.haltAndClearStorage(() => {
114+
var settings = {};
115+
settings.c = {
116+
tracking: false
117+
};
118+
initMain(settings);
119+
hp.integrationMethods();
120+
cy.wait(waitT).then(() => {
121+
cy.fetch_local_request_queue().then((rq) => {
122+
cy.log("Request Queue: " + JSON.stringify(rq));
123+
sentReqList(8, ["server_config", "[healthCheck]", "enrollUserToAb", "fetch_remote_config_explicit", "get_available_feedback_widgets,"]);
124+
queues(0, 0);
125+
});
126+
});
127+
});
128+
});
129+
130+
it("Config with both tracking and networking disabled", () => {
131+
hp.haltAndClearStorage(() => {
132+
var settings = {};
133+
settings.c = {
134+
tracking: false,
135+
networking: false
136+
};
137+
initMain(settings);
138+
hp.integrationMethods();
139+
cy.wait(waitT).then(() => {
140+
cy.fetch_local_request_queue().then((rq) => {
141+
cy.log("Request Queue: " + JSON.stringify(rq));
142+
sentReqList(1, ["server_config"]);
143+
queues(0, 0);
144+
});
145+
});
146+
});
147+
});
148+
149+
it("Config with consent required true", () => {
150+
hp.haltAndClearStorage(() => {
151+
var settings = {};
152+
settings.c = {
153+
cr: true
154+
};
155+
initMain(settings);
156+
hp.integrationMethods();
157+
cy.wait(waitT).then(() => {
158+
cy.fetch_local_request_queue().then((rq) => {
159+
cy.log("Request Queue: " + JSON.stringify(rq));
160+
sentReqList(4, ["server_config", "[healthCheck]", "enrollUserToAb", "send_request_queue"]); // device id change sent
161+
queues(0, 2, ["old_device_id", "consent"]);
162+
});
163+
});
164+
});
165+
});
166+
167+
it("Limited queue sizes with networking disabled", () => {
168+
hp.haltAndClearStorage(() => {
169+
var settings = {};
170+
settings.c = {
171+
rqs: 1,
172+
eqs: 1,
173+
networking: false,
174+
};
175+
initMain(settings);
176+
Countly.add_event({ key: "test_1" });
177+
Countly.add_event({ key: "test_2" });
178+
Countly.add_event({ key: "test_3" });
179+
Countly.add_event({ key: "test_4" });
180+
Countly.add_event({ key: "test_5" });
181+
cy.wait(3000).then(() => {
182+
cy.fetch_local_request_queue().then((rq) => {
183+
cy.log("Request Queue: " + JSON.stringify(rq));
184+
sentReqList(1, ["server_config"]);
185+
queues(0, 2, ["events"], ["test_1", "test_2", "test_3"]); // 1+1
186+
});
187+
});
188+
});
189+
});
190+
191+
it("Session update interval configuration", () => {
192+
hp.haltAndClearStorage(() => {
193+
var settings = {};
194+
settings.c = {
195+
sui: 1,
196+
};
197+
initMain(settings);
198+
Countly.track_sessions();
199+
cy.wait(4000).then(() => {
200+
cy.fetch_local_request_queue().then((rq) => {
201+
cy.log("Request Queue: " + JSON.stringify(rq));
202+
sentReqList(3, ["server_config", "[healthCheck]", "send_request_queue"]);
203+
queues(0, 4, ["session_duration", "begin_session"], ["session_end"]);
204+
});
205+
});
206+
});
207+
});
208+
209+
it("Disabled tracking types configuration", () => {
210+
hp.haltAndClearStorage(() => {
211+
var settings = {};
212+
settings.c = {
213+
st: false,
214+
crt: false,
215+
lt: false,
216+
vt: false,
217+
cet: false,
218+
};
219+
initMain(settings);
220+
Countly.track_sessions();
221+
Countly.add_event({ key: "test_1" });
222+
Countly.track_pageview();
223+
Countly.log_error({ message: "test" });
224+
cy.wait(4000).then(() => {
225+
cy.fetch_local_request_queue().then((rq) => {
226+
cy.log("Request Queue: " + JSON.stringify(rq));
227+
sentReqList(2, ["server_config", "[healthCheck]"]);
228+
queues(0, 0);
229+
});
230+
});
231+
});
232+
});
233+
});

0 commit comments

Comments
 (0)