Skip to content

Commit

Permalink
release (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
turtledreams committed Jul 28, 2023
1 parent c626f92 commit 0fbb172
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 162 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## X.X.X
## 23.6.0
- Added a new flag, 'loadAPMScriptsAsync', which can load the APM related scripts automatically for Async implementations
- Adding SDK health check requests after init
- Adding remaining request queue size information to every request
Expand Down
46 changes: 26 additions & 20 deletions cypress/integration/remaining_requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,32 @@ describe("Remaining requests tests ", () => {
hp.haltAndClearStorage(() => {
initMain(false);

// Create a session and end it
Countly.begin_session();
Countly.end_session(undefined, true);

// We expect 3 requests: begin_session, end_session, orientation
hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "begin_session", (requestParams) => {
expect(requestParams.get("begin_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("3");
});
hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "end_session", (requestParams) => {
expect(requestParams.get("end_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("2");
// We will expect 4 requests: health check, begin_session, end_session, orientation
hp.interceptAndCheckRequests(undefined, undefined, undefined, "?hc=*", "hc", (requestParams) => {
expect(requestParams.get("hc")).to.equal(JSON.stringify({ el: 0, wl: 0, sc: -1, em: "\"\"" }));
expect(requestParams.get("rr")).to.equal(null);
});
hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "orientation", (requestParams) => {
expect(JSON.parse(requestParams.get("events"))[0].key).to.equal("[CLY]_orientation");
expect(requestParams.get("rr")).to.equal("1");
});
cy.wait(100).then(() => {
cy.fetch_local_request_queue().then((rq) => {
expect(rq.length).to.equal(0);
cy.wait(1000).then(() => {
// Create a session
Countly.begin_session();
hp.interceptAndCheckRequests(undefined, undefined, undefined, "?begin_session=*", "begin_session", (requestParams) => {
expect(requestParams.get("begin_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("3");
});
// End the session
Countly.end_session(undefined, true);
hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "end_session", (requestParams) => {
expect(requestParams.get("end_session")).to.equal("1");
expect(requestParams.get("rr")).to.equal("2");
});
hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "orientation", (requestParams) => {
expect(JSON.parse(requestParams.get("events"))[0].key).to.equal("[CLY]_orientation");
expect(requestParams.get("rr")).to.equal("1");
});
cy.wait(100).then(() => {
cy.fetch_local_request_queue().then((rq) => {
expect(rq.length).to.equal(0);
});
});
});
});
Expand All @@ -48,7 +54,7 @@ describe("Remaining requests tests ", () => {
Countly.begin_session();
Countly.end_session(undefined, true);
cy.fetch_local_request_queue().then((rq) => {
// We expect 3 requests in queue: begin_session, end_session, orientation
// We expect 3 requests in queue: begin_session, end_session, orientation. health check was not in the queue
expect(rq.length).to.equal(3);
expect(rq[0].rr).to.equal(3);
expect(rq[1].rr).to.equal(undefined);
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ var waitFunction = function(startTime, waitTime, waitIncrement, continueCallback
*/
function interceptAndCheckRequests(requestType, requestUrl, endPoint, requestParams, alias, callback) {
requestType = requestType || "GET";
requestUrl = requestUrl || "https://try.count.ly";
requestUrl = requestUrl || "https://try.count.ly"; // TODO: might be needed in the future but not yet
endPoint = endPoint || "/i";
requestParams = requestParams || "?**";
alias = alias || "getXhr";

cy.intercept(requestType, requestUrl + endPoint + requestParams).as(alias);
cy.intercept(requestType, endPoint + requestParams).as(alias);
cy.wait("@" + alias).then((xhr) => {
const url = new URL(xhr.request.url);
const searchParams = url.searchParams;
Expand Down
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"countly-sdk-web": "^23.2.2"
"countly-sdk-web": "^23.6.0"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
6 changes: 3 additions & 3 deletions lib/countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
*/
Countly.onload = Countly.onload || [];

var SDK_VERSION = "23.2.2";
var SDK_VERSION = "23.6.0";
var SDK_NAME = "javascript_native_web";

var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
Expand Down Expand Up @@ -666,6 +666,8 @@
}
}, 1);
document.documentElement.setAttribute("data-countly-useragent", currentUserAgentString());
// send instant health check request
HealthCheck.sendInstantHCRequest();
};

/**
Expand Down Expand Up @@ -4610,8 +4612,6 @@

// initialize Countly Class
this.initialize();
// send instant health check request
HealthCheck.sendInstantHCRequest();
};

/**
Expand Down
Loading

0 comments on commit 0fbb172

Please sign in to comment.