Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #22

Merged
merged 8 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
node_modules/
dist/
rollup.config.js
Countly.d.ts
src/
instrumented/
coverage/
.nyc_output/
```
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 24.11.1

* Deprecated `initializeRatingWidgets` method, use `feedback.showRating` instead.
* Deprecated `enableRatingWidgets` method, use `feedback.showRating` instead.
* Added an interface `content` for Content feature methods:
* `enterContentZone`, to start Content checks (Experimental!)
* `exitContentZone`, to stop Content checks (Experimental!)

## 24.11.0

* Mitigated an issue where SDK could try to send old stored offline mode data during init if `clear_stored_id` was true
Expand Down
2 changes: 1 addition & 1 deletion Countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ if (isBrowser) {
var key = parts.pop();
var appKey = parts.pop();
if (Countly.i && Countly.i[appKey]) {
Countly.i[appKey].onStorageChange(key, e.newValue);
Countly.i[appKey]._internals.onStorageChange(key, e.newValue);
}
});
}
Expand Down
11 changes: 10 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { defineConfig } from "cypress";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
const codeCoverageTask = require('@cypress/code-coverage/task');
codeCoverageTask(on, config);

// Include any other plugin code...

// IMPORTANT: Return the config object with any changed environment variables
return config;
},
},
userAgent: "abcd",
Expand Down
47 changes: 14 additions & 33 deletions cypress/e2e/remaining_requests.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,22 @@ describe("Remaining requests tests ", () => {
it("Checks the requests for rr", () => {
hp.haltAndClearStorage(() => {
initMain(false);
Countly.begin_session();
Countly.end_session(undefined, true);

// We will expect 4 requests: health check, begin_session, end_session, orientation
hp.interceptAndCheckRequests("POST", undefined, undefined, "?hc=*", "hc", (requestParams) => {
const params = JSON.parse(requestParams.get("hc"));
assert.isTrue(typeof params.el === "number");
assert.isTrue(typeof params.wl === "number");
assert.isTrue(typeof params.sc === "number");
assert.isTrue(typeof params.em === "string");
expect(requestParams.get("rr")).to.equal(null);
});
cy.wait(1000).then(() => {
// Create a session
Countly.begin_session();
hp.interceptAndCheckRequests("POST", undefined, undefined, "?begin_session=*", "begin_session", (requestParams) => {
expect(requestParams.get("begin_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("3");
expect(requestParams.get("av")).to.equal(av);
});
// End the session
Countly.end_session(undefined, true);
hp.interceptAndCheckRequests("POST", undefined, undefined, "?end_session=*", "end", (requestParams) => {
expect(requestParams.get("end_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("2");
expect(requestParams.get("av")).to.equal(av);
});
hp.interceptAndCheckRequests("POST", undefined, undefined, undefined, "orientation", (requestParams) => {
expect(JSON.parse(requestParams.get("events"))[0].key).to.equal("[CLY]_orientation");
expect(requestParams.get("rr")).to.equal("1");
expect(requestParams.get("av")).to.equal(av);
});
cy.wait(100).then(() => {
cy.fetch_local_request_queue().then((rq) => {
expect(rq.length).to.equal(0);
});
});
var queues = Countly._internals.getLocalQueues();
expect(queues.eventQ.length).to.equal(0);
expect(queues.requestQ.length).to.equal(3);
expect(queues.requestQ[0]["begin_session"]).to.equal(1);
expect(queues.requestQ[1]["end_session"]).to.equal(1);
expect(JSON.parse(queues.requestQ[2]["events"])[0].key).to.equal("[CLY]_orientation");

var requests = Countly._internals.testingGetRequests();
expect(requests.length).to.equal(2);
expect(requests[0].params["rr"]).to.equal(undefined);
expect(requests[1].params["rr"]).to.equal(3);
expect(requests[1].params["av"]).to.equal(av);
});
});
});
Expand Down
23 changes: 8 additions & 15 deletions cypress/e2e/sessions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ describe("Browser session tests, auto", () => {
describe("Browser session tests, manual 1", () => {
it("Single sessions test with manual sessions", () => {
cy.visit("./cypress/fixtures/session_test_manual_1.html?use_session_cookie=true");
cy.contains("Start").click().wait(waitTime);
cy.contains("Event").click().wait(300);
cy.contains("End").click().wait(300);
cy.wait(waitTime + 1000);
cy.visit("./cypress/fixtures/base.html");
cy.fetch_local_request_queue(app_key).then((rq) => {
cy.log(rq);
Expand All @@ -109,10 +107,10 @@ describe("Browser session tests, manual 1", () => {
cy.check_session(rq[0], undefined, undefined, app_key);
// third object of the queue should be about session extension, also input the expected duration
cy.check_session(rq[2], 5, undefined, app_key);
// fourth object of the queue should be about event sent
cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false);
// fifth object of the queue should be about session extension, also input the expected duration
cy.check_session(rq[4], 1, undefined, app_key);
cy.check_session(rq[3], 1, undefined, app_key);
// fourth object of the queue should be about event sent
cy.check_event(JSON.parse(rq[4].events)[0], eventObj, undefined, false);
});
});
});
Expand Down Expand Up @@ -160,12 +158,7 @@ describe("Browser session tests, auto, no cookie", () => {
describe("Browser session tests, manual 1, no cookie", () => {
it("Single bounce test with manual sessions with no cookies", () => {
cy.visit("./cypress/fixtures/session_test_manual_1.html");
cy.contains("Start").click();
cy.wait(waitTime);
cy.contains("Event").click();
cy.wait(300);
cy.contains("End").click();
cy.wait(300);
cy.wait(waitTime + 1000);
cy.visit("./cypress/fixtures/base.html");
cy.fetch_local_request_queue(app_key).then((rq) => {
cy.log(rq);
Expand All @@ -175,10 +168,10 @@ describe("Browser session tests, manual 1, no cookie", () => {
cy.check_session(rq[0], undefined, undefined, app_key);
// third object of the queue should be about session extension, also input the expected duration
cy.check_session(rq[2], 5, undefined, app_key);
// fourth object of the queue should be about event sent
cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false);
// fifth object of the queue should be about session extension, also input the expected duration
cy.check_session(rq[4], 1, true, app_key);
cy.check_session(rq[3], 1, true, app_key);
// fourth object of the queue should be about event sent
cy.check_event(JSON.parse(rq[4].events)[0], eventObj, undefined, false);
});
});
});
Expand Down
7 changes: 4 additions & 3 deletions cypress/e2e/web_worker_queues.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ describe("Web Worker Local Queue Tests", () => {
requestQueue = e.data.requestQ; // Array of requests
eventQueue = e.data.eventQ; // Array of events
myWorker.terminate(); // terminate worker

};
cy.wait(3000).then(() => {
// verify event queue
expect(eventQueue.length).to.equal(2);
cy.check_event(eventQueue[0], { key: "key" }, undefined, false);
cy.check_view_event(eventQueue[1], "home_page", undefined, false);

// verify request queue
expect(requestQueue.length).to.equal(2);
cy.check_session(requestQueue[0], undefined, false, false, true);
cy.check_session(requestQueue[1], 0, false, false, false);
};
});
});
});
32 changes: 12 additions & 20 deletions cypress/fixtures/session_test_manual_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,20 @@
use_session_cookie: confObj.use_session_cookie || false,
debug:true
})
Countly.begin_session();
setTimeout(() => {
Countly.add_event({
key: "buttonClick",
"segmentation": {
"id": "id"
}
});
Countly.end_session(undefined, true);
}, 7000);


</script>
</head>
<body>
<script type='text/javascript' >
function clickEvent(){
window.Countly.add_event({
key: "buttonClick",
"segmentation": {
"id": "id"
}
});
}
function start(){
Countly.begin_session();
}
function end(){
Countly.end_session(undefined, true);
}
</script>
<button type="button" onclick="clickEvent()">Event</button>
<button type="button" onclick="start()">Start</button>
<button type="button" onclick="end()">End</button>
<button type="button" onclick="windowClose()">Close</button>
</body>
</html>
1 change: 1 addition & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import './commands'
import '@cypress/code-coverage/support'

// Alternatively you can use CommonJS syntax:
// require('./commands')
5 changes: 5 additions & 0 deletions examples/example_async.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
//provide countly initialization parameters
Countly.app_key = "YOUR_APP_KEY";
Countly.url = "https://your.server.ly"; //your server goes here
Countly.debug = true;
Countly.loadAPMScriptsAsync = true;

if(Countly.app_key === "YOUR_APP_KEY" || Countly.url === "https://your.server.ly"){
console.warn("Please do not use default set of app key and server url")
Expand All @@ -23,6 +25,9 @@
//track sessions automatically
Countly.q.push(['track_sessions']);

//track performance automatically
Countly.q.push(["track_performance"]);

//track sessions automatically
Countly.q.push(['track_pageview']);

Expand Down
84 changes: 0 additions & 84 deletions examples/example_opt_out.html

This file was deleted.

Loading