Skip to content

Commit cf3e3d6

Browse files
authored
Merge pull request #537 from Countly/content
Content addition
2 parents 99be37d + a431a77 commit cf3e3d6

File tree

11 files changed

+2239
-2058
lines changed

11 files changed

+2239
-2058
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 24.11.1
2+
- Deprecated `initializeRatingWidgets` method, use `feedback.showRating` instead.
3+
- Deprecated `enableRatingWidgets` method, use `feedback.showRating` instead.
4+
- Added an interface `content` for Content feature methods:
5+
- `enterContentZone`, to start Content checks (Experimental!)
6+
- `exitContentZone`, to stop Content checks (Experimental!)
7+
18
## 24.11.0
29
- Mitigated an issue where SDK could try to send old stored offline mode data during init if `clear_stored_id` was true
310
- Mitigated an issue where the SDK could stayed on offline mode after the first init with `offline_mode` set to true

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 = "24.11.0";
18+
const SDK_VERSION = "24.11.1";
1919

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

cypress/e2e/sessions.cy.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const dummyQueue = [
3030
describe("Session tests ", () => {
3131
it("Checks if session start, extension and ending works with a dummy queue", () => {
3232
hp.haltAndClearStorage(() => {
33-
// initialize countly
33+
// initialize countly
3434
initMain();
3535
// begin session
3636
Countly.begin_session();
@@ -50,7 +50,7 @@ describe("Session tests ", () => {
5050
});
5151
it("Checks if session start, extension and ending works", () => {
5252
hp.haltAndClearStorage(() => {
53-
// initialize countly
53+
// initialize countly
5454
initMain();
5555
// begin session
5656
Countly.begin_session();
@@ -97,9 +97,7 @@ describe("Browser session tests, auto", () => {
9797
describe("Browser session tests, manual 1", () => {
9898
it("Single sessions test with manual sessions", () => {
9999
cy.visit("./cypress/fixtures/session_test_manual_1.html?use_session_cookie=true");
100-
cy.contains("Start").click().wait(waitTime);
101-
cy.contains("Event").click().wait(300);
102-
cy.contains("End").click().wait(300);
100+
cy.wait(waitTime + 1000);
103101
cy.visit("./cypress/fixtures/base.html");
104102
cy.fetch_local_request_queue(app_key).then((rq) => {
105103
cy.log(rq);
@@ -109,10 +107,10 @@ describe("Browser session tests, manual 1", () => {
109107
cy.check_session(rq[0], undefined, undefined, app_key);
110108
// third object of the queue should be about session extension, also input the expected duration
111109
cy.check_session(rq[2], 5, undefined, app_key);
112-
// fourth object of the queue should be about event sent
113-
cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false);
114110
// fifth object of the queue should be about session extension, also input the expected duration
115-
cy.check_session(rq[4], 1, undefined, app_key);
111+
cy.check_session(rq[3], 1, undefined, app_key);
112+
// fourth object of the queue should be about event sent
113+
cy.check_event(JSON.parse(rq[4].events)[0], eventObj, undefined, false);
116114
});
117115
});
118116
});
@@ -160,12 +158,7 @@ describe("Browser session tests, auto, no cookie", () => {
160158
describe("Browser session tests, manual 1, no cookie", () => {
161159
it("Single bounce test with manual sessions with no cookies", () => {
162160
cy.visit("./cypress/fixtures/session_test_manual_1.html");
163-
cy.contains("Start").click();
164-
cy.wait(waitTime);
165-
cy.contains("Event").click();
166-
cy.wait(300);
167-
cy.contains("End").click();
168-
cy.wait(300);
161+
cy.wait(waitTime + 1000);
169162
cy.visit("./cypress/fixtures/base.html");
170163
cy.fetch_local_request_queue(app_key).then((rq) => {
171164
cy.log(rq);
@@ -175,10 +168,10 @@ describe("Browser session tests, manual 1, no cookie", () => {
175168
cy.check_session(rq[0], undefined, undefined, app_key);
176169
// third object of the queue should be about session extension, also input the expected duration
177170
cy.check_session(rq[2], 5, undefined, app_key);
178-
// fourth object of the queue should be about event sent
179-
cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false);
180171
// fifth object of the queue should be about session extension, also input the expected duration
181-
cy.check_session(rq[4], 1, true, app_key);
172+
cy.check_session(rq[3], 1, true, app_key);
173+
// fourth object of the queue should be about event sent
174+
cy.check_event(JSON.parse(rq[4].events)[0], eventObj, undefined, false);
182175
});
183176
});
184177
});
@@ -205,7 +198,7 @@ describe("Browser session tests, manual 2, no cookie", () => {
205198
describe("Check request related functions", () => {
206199
it("Check if prepareRequest forms a proper request object", () => {
207200
hp.haltAndClearStorage(() => {
208-
// initialize countly
201+
// initialize countly
209202
initMain();
210203
let reqObject = {};
211204
Countly._internals.prepareRequest(reqObject);
@@ -215,7 +208,7 @@ describe("Check request related functions", () => {
215208
});
216209
it("Check if prepareRequest forms a proper request object from a bad one ", () => {
217210
hp.haltAndClearStorage(() => {
218-
// initialize countly
211+
// initialize countly
219212
initMain();
220213
let reqObject = { app_key: null, device_id: null };
221214
Countly._internals.prepareRequest(reqObject);
@@ -225,7 +218,7 @@ describe("Check request related functions", () => {
225218
});
226219
it("Check if prepareRequest forms a proper request object and not erase an extra value ", () => {
227220
hp.haltAndClearStorage(() => {
228-
// initialize countly
221+
// initialize countly
229222
initMain();
230223
let reqObject = { extraKey: "value" };
231224
Countly._internals.prepareRequest(reqObject);

cypress/fixtures/session_test_manual_1.html

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,29 @@
2222
const confObj = queryExtractor(window.location.search);
2323

2424
//initializing countly with params
25-
Countly.init({
26-
app_key: "YOUR_APP_KEY",
27-
url: "https://your.domain.count.ly",
28-
device_id: "manual_1",
29-
session_update: 5,
30-
test_mode: true,
31-
use_session_cookie: confObj.use_session_cookie || false,
32-
debug:true
33-
})
25+
Countly.init({
26+
app_key: "YOUR_APP_KEY",
27+
url: "https://your.domain.count.ly",
28+
device_id: "manual_1",
29+
session_update: 5,
30+
test_mode: true,
31+
use_session_cookie: confObj.use_session_cookie || false,
32+
debug: true
33+
})
34+
Countly.begin_session();
35+
setTimeout(() => {
36+
Countly.add_event({
37+
key: "buttonClick",
38+
"segmentation": {
39+
"id": "id"
40+
}
41+
});
42+
Countly.end_session(undefined, true);
43+
}, 7000);
44+
45+
3446
</script>
3547
</head>
3648
<body>
37-
<script type='text/javascript' >
38-
function clickEvent(){
39-
window.Countly.add_event({
40-
key: "buttonClick",
41-
"segmentation": {
42-
"id": "id"
43-
}
44-
});
45-
}
46-
function start(){
47-
Countly.begin_session();
48-
}
49-
function end(){
50-
Countly.end_session(undefined, true);
51-
}
52-
</script>
53-
<button type="button" onclick="clickEvent()">Event</button>
54-
<button type="button" onclick="start()">Start</button>
55-
<button type="button" onclick="end()">End</button>
56-
<button type="button" onclick="windowClose()">Close</button>
5749
</body>
58-
</html>
50+
</html>

examples/example_opt_out.html

Lines changed: 0 additions & 82 deletions
This file was deleted.

examples/example_rating_widgets.html

Lines changed: 0 additions & 63 deletions
This file was deleted.

lib/countly.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,22 @@ declare module "countly-sdk-web" {
483483
showRating(nameIDorTag?: string): void;
484484
}
485485

486+
/**
487+
* Content interface with convenience methods for content zones:
488+
* - enterContentZone() - enters a content zone
489+
* - exitContentZone() - exits a content zone
490+
*/
491+
const content: Content;
492+
interface Content {
493+
/**
494+
* Enters content zone and checks and displays available content regularly
495+
*/
496+
enterContentZone(): void;
497+
/**
498+
* Exits content zone
499+
*/
500+
exitContentZone(): void;
501+
}
486502
/**
487503
* This function retrieves all associated widget information (IDs, type, name etc in an array/list of objects) of your app
488504
* @param {Function} callback - Callback function with two parameters, 1st for returned list, 2nd for error

0 commit comments

Comments
 (0)