Skip to content

Commit

Permalink
Merge pull request #532 from Countly/staging
Browse files Browse the repository at this point in the history
Staging 24.11.0
  • Loading branch information
turtledreams authored Nov 12, 2024
2 parents d361ae0 + 99be37d commit 84d49ef
Show file tree
Hide file tree
Showing 53 changed files with 2,052 additions and 1,309 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ node_modules
.github
.gitignore
CHANGELOG.md
cypress.json
cypress.config.js
generateDocs.sh
jsdoc_conf.json
LICENSE
LICENSE
cypress/
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build-and-test:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x, 20.x]

runs-on: ubuntu-latest

Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 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
- Mitigated an issue where the SDK could stayed on offline mode after the first init with `offline_mode` set to true
- Mitigated an issue where old Rating widget stickers were not cleared when a new one was presented

- Improved view tracking logic
- Default request method is now set to "POST"
- Healtchecks won't be sent in offline mode anymore
- Added a new interface 'feedback' which includes convenience methods to show feedback widgets:
- showNPS([String nameIDorTag]) - for displaying the first available NPS widget or one with the given name, Tag or ID value
- showSurvey([String nameIDorTag]) - for displaying the first available Survey widget or one with the given name, Tag or ID value
- showRating([String nameIDorTag]) - for displaying the first available Rating widget or one with the given name, Tag or ID value

## 24.4.1
- Added types for the SDK
- Added a new method `set_id(newDeviceId)` for managing device ID changes according to the device ID Type
Expand Down
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
userAgent: "abcd",
});
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable require-jsdoc */
var Countly = require("../../lib/countly");
// import * as Countly from "../../dist/countly_umd.js";
var hp = require("../support/helper.js");
var hp = require("../support/helper");

function initMain(clear) {
Countly.init({
Expand Down Expand Up @@ -62,22 +60,22 @@ describe("Test Countly.q related methods and processes", () => {
// Check that the .q is empty
expect(Countly.q.length).to.equal(0);

cy.fetch_local_request_queue().then((rq_2) => {
cy.fetch_local_request_queue().then((rq) => {
// Check that nothing sent to request queue
expect(rq_2.length).to.equal(0);
expect(rq.length).to.equal(0);
cy.fetch_local_event_queue().then((eq) => {
// Check that events are now in event queue
expect(eq.length).to.equal(4);

// Send events from event queue to request queue
Countly._internals.sendEventsForced();
cy.fetch_local_event_queue().then((eq_2) => {
cy.fetch_local_event_queue().then((eq) => {
// Check that event queue is empty
expect(eq_2.length).to.equal(0);
cy.fetch_local_request_queue().then((rq_3) => {
expect(eq.length).to.equal(0);
cy.fetch_local_request_queue().then((rq) => {
// Check that events are now in request queue
expect(rq_3.length).to.equal(1);
const eventsArray = JSON.parse(rq_3[0].events);
expect(rq.length).to.equal(1);
const eventsArray = JSON.parse(rq[0].events);
expect(eventsArray[0].key).to.equal("event_1");
expect(eventsArray[1].key).to.equal("event_2");
expect(eventsArray[2].key).to.equal("event_3");
Expand Down Expand Up @@ -125,16 +123,16 @@ describe("Test Countly.q related methods and processes", () => {
// Check that event queue has new device ID's orientation event
expect(eq.length).to.equal(1);
expect(eq[0].key).to.equal("[CLY]_orientation");
cy.fetch_local_request_queue().then((rq_2) => {
cy.fetch_local_request_queue().then((rq) => {
// Check that events are now in request queue (second request is begin session for new device ID)
expect(rq_2.length).to.equal(2);
const eventsArray = JSON.parse(rq_2[0].events);
expect(rq.length).to.equal(2);
const eventsArray = JSON.parse(rq[0].events);
expect(eventsArray[0].key).to.equal("event_1");
expect(eventsArray[1].key).to.equal("event_2");
expect(eventsArray[2].key).to.equal("event_3");
expect(eventsArray[3].key).to.equal("event_4");
// check begin session
expect(rq_2[1].begin_session).to.equal(1);
expect(rq[1].begin_session).to.equal(1);
});
});
});
Expand Down Expand Up @@ -175,16 +173,16 @@ describe("Test Countly.q related methods and processes", () => {
cy.fetch_local_event_queue().then((eq) => {
// Check that event queue is empty
expect(eq.length).to.equal(0);
cy.fetch_local_request_queue().then((rq_2) => {
cy.fetch_local_request_queue().then((rq) => {
// Check that events are now in request queue (second request is user details)
expect(rq_2.length).to.equal(2);
const eventsArray = JSON.parse(rq_2[0].events);
expect(rq.length).to.equal(2);
const eventsArray = JSON.parse(rq[0].events);
expect(eventsArray[0].key).to.equal("event_1");
expect(eventsArray[1].key).to.equal("event_2");
expect(eventsArray[2].key).to.equal("event_3");
expect(eventsArray[3].key).to.equal("event_4");
// check user details
const user_details = JSON.parse(rq_2[1].user_details);
const user_details = JSON.parse(rq[1].user_details);
expect(user_details.name).to.equal("test_user");
});
});
Expand Down Expand Up @@ -227,16 +225,16 @@ describe("Test Countly.q related methods and processes", () => {
cy.fetch_local_event_queue().then((eq) => {
// Check that event queue is empty
expect(eq.length).to.equal(0);
cy.fetch_local_request_queue().then((rq_2) => {
cy.fetch_local_request_queue().then((rq) => {
// Check that events are now in request queue (second request is user details)
expect(rq_2.length).to.equal(2);
const eventsArray = JSON.parse(rq_2[0].events);
expect(rq.length).to.equal(2);
const eventsArray = JSON.parse(rq[0].events);
expect(eventsArray[0].key).to.equal("event_1");
expect(eventsArray[1].key).to.equal("event_2");
expect(eventsArray[2].key).to.equal("event_3");
expect(eventsArray[3].key).to.equal("event_4");
// check user data
const user_details = JSON.parse(rq_2[1].user_details);
const user_details = JSON.parse(rq[1].user_details);
expect(user_details.custom.name).to.equal("test_user");
});
});
Expand Down Expand Up @@ -267,15 +265,15 @@ describe("Test Countly.q related methods and processes", () => {
expect(Countly.q.length).to.equal(4);
// Wait for heartBeat to process the .q
cy.wait(1500).then(() => {
// Check that the .q is empty
// Check that the .q is empty
expect(Countly.q.length).to.equal(0);
cy.fetch_local_event_queue().then((eq_2) => {
// Check that event queue is empty as all must be in request queue
expect(eq_2.length).to.equal(0);
cy.fetch_local_request_queue().then((rq_2) => {
// Check that events are now in request queue
expect(rq_2.length).to.equal(1);
const eventsArray = JSON.parse(rq_2[0].events);
cy.fetch_local_event_queue().then((eq) => {
// Check that event queue is empty as all must be in request queue
expect(eq.length).to.equal(0);
cy.fetch_local_request_queue().then((rq) => {
// Check that events are now in request queue
expect(rq.length).to.equal(1);
const eventsArray = JSON.parse(rq[0].events);
expect(eventsArray[0].key).to.equal("event_1");
expect(eventsArray[1].key).to.equal("event_2");
expect(eventsArray[2].key).to.equal("event_3");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable require-jsdoc */
var Countly = require("../../lib/countly");
// import * as Countly from "../../dist/countly_umd.js";
var hp = require("../support/helper.js");

function initMain(name, version) {
Expand All @@ -16,13 +15,13 @@ function initMain(name, version) {
}

const SDK_NAME = "javascript_native_web";
const SDK_VERSION = "24.4.1";
const SDK_VERSION = "24.11.0";

// tests
describe("Bridged SDK Utilities Tests", () => {
it("Check if we can override sdk name and version successful", () => {
hp.haltAndClearStorage(() => {
initMain("javascript_gtm_web", "24.0.0");
initMain('javascript_gtm_web', '24.0.0');
hp.events();
cy.fetch_local_request_queue().then((eq) => {
expect(eq).to.have.length(1);
Expand All @@ -33,7 +32,7 @@ describe("Bridged SDK Utilities Tests", () => {
});
it("Check if SDK uses default values if SDK name and version was not overriden", () => {
hp.haltAndClearStorage(() => {
initMain(undefined, undefined);
initMain(undefined, undefined);
hp.events();
cy.fetch_local_request_queue().then((eq) => {
expect(eq).to.have.length(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable require-jsdoc */
var Countly = require("../../lib/countly");
var hp = require("../support/helper");
// import * as Countly from "../../dist/countly_umd.js";
var hp = require("../support/helper.js");

function initMain(consent) {
Countly.init({
app_key: "YOUR_APP_KEY",
url: "https://your.domain.countly",
url: "https://your.domain.count.ly",
require_consent: consent,
device_id: "György Ligeti",
test_mode: true,
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/crashes.js → cypress/e2e/crashes.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var hp = require("../support/helper");
function initMain() {
Countly.init({
app_key: "YOUR_APP_KEY",
url: "https://your.domain.countly",
url: "https://your.domain.count.ly",
test_mode: true
});
}
Expand All @@ -26,7 +26,7 @@ describe("Crashes tests ", () => {
catch (err) {
Countly.log_error(err);
}
cy.wait(3000).then(() => {
cy.wait(1000).then(() => {
cy.fetch_local_request_queue().then((rq) => {
cy.check_crash(rq[0], hp.appKey);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var hp = require("../support/helper");
function initMain(deviceId, offline, searchQuery, clear, rq, eq) {
Countly.init({
app_key: "YOUR_APP_KEY",
url: "https://your.domain.countly",
url: "https://your.domain.count.ly",
device_id: deviceId,
test_mode: rq,
test_mode_eq: eq,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Countly = require("../../lib/countly");
var hp = require("../support/helper");
var hp = require("../support/helper.js");

// ========================================
// Device ID change tests
Expand All @@ -14,7 +14,7 @@ var hp = require("../support/helper");
function initMain(offline) {
Countly.init({
app_key: "YOUR_APP_KEY",
url: "https://your.domain.countly",
url: "https://your.domain.count.ly",
test_mode: true,
debug: true,
offline_mode: offline
Expand Down Expand Up @@ -220,7 +220,7 @@ describe("Device ID change tests ", ()=>{
});

describe("Set ID change tests ", () => {
it("set_id should be non merge as there was dev provided id", () => {
it('set_id should be non merge as there was dev provided id', () => {
hp.haltAndClearStorage(() => {
Countly.init({
app_key: "YOUR_APP_KEY",
Expand All @@ -239,16 +239,16 @@ describe("Set ID change tests ", () => {
cy.fetch_local_request_queue().then((eq2) => {
expect(eq2.length).to.equal(3); // no merge request
expect(eq2[0].device_id).to.equal("old ID");
expect(eq2[0].events).to.contains("\"key\":\"1\"");
expect(eq2[0].events).to.contains('"key\":\"1\"');
expect(eq2[1].device_id).to.equal("new ID");
expect(eq2[1].begin_session).to.equal(1);
expect(eq2[2].device_id).to.equal("new ID");
expect(eq2[2].events).to.contains("\"key\":\"2\"");
expect(eq2[2].events).to.contains('"key\":\"2\"');
});
});
});
});
it("set_id should be merge as there was sdk generated id", () => {
it('set_id should be merge as there was sdk generated id', () => {
hp.haltAndClearStorage(() => {
initMain(false); // init normally
Countly.add_event(eventObj("1")); // record an event.
Expand All @@ -264,13 +264,14 @@ describe("Set ID change tests ", () => {
cy.log(eq2);
expect(eq2.length).to.equal(3); // merge request
expect(eq2[0].device_id).to.equal(generatedID);
expect(eq2[0].events).to.contains("\"key\":\"1\"");
expect(eq2[0].events).to.contains('"key\":\"1\"');
expect(eq2[1].device_id).to.equal("new ID");
expect(eq2[1].old_device_id).to.equal(generatedID);
expect(eq2[2].device_id).to.equal("new ID");
expect(eq2[2].events).to.contains("\"key\":\"2\"");
expect(eq2[2].events).to.contains('"key\":\"2\"');
});
});
});
});

});
Loading

0 comments on commit 84d49ef

Please sign in to comment.