countly-sdk-web
Advanced tools
Comparing version 23.6.1 to 23.6.2
@@ -0,1 +1,6 @@ | ||
## 23.6.2 | ||
- Adding app version information to every request | ||
- Mitigated an issue where if a long numerical device ID was changed while SDK was running at multiple tabs, it was parsed | ||
## 23.6.1 | ||
@@ -2,0 +7,0 @@ - Mitigated an issue where numerical device IDs were parsed at the initialization |
@@ -306,2 +306,9 @@ /* eslint-disable require-jsdoc */ | ||
}); | ||
it("Start with a long numerical device ID", () => { | ||
hp.haltAndClearStorage(() => { | ||
localStorage.setItem("YOUR_APP_KEY/cly_id", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); | ||
initMain(undefined, false, undefined, false, true, true); | ||
expect(Countly.get_device_id()).to.equal("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); | ||
}); | ||
}); | ||
}); |
@@ -9,2 +9,3 @@ /* eslint-disable require-jsdoc */ | ||
url: "https://try.count.ly", | ||
app_version: "1.0", | ||
// would prevent requests from being sent to the server if true | ||
@@ -14,3 +15,3 @@ test_mode: shouldStopRequests | ||
} | ||
const av = "1.0"; | ||
describe("Remaining requests tests ", () => { | ||
@@ -32,2 +33,3 @@ it("Checks the requests for rr", () => { | ||
expect(requestParams.get("rr")).to.equal("3"); | ||
expect(requestParams.get("av")).to.equal(av); | ||
}); | ||
@@ -39,2 +41,3 @@ // End the session | ||
expect(requestParams.get("rr")).to.equal("2"); | ||
expect(requestParams.get("av")).to.equal(av); | ||
}); | ||
@@ -44,2 +47,3 @@ hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "orientation", (requestParams) => { | ||
expect(requestParams.get("rr")).to.equal("1"); | ||
expect(requestParams.get("av")).to.equal(av); | ||
}); | ||
@@ -46,0 +50,0 @@ cy.wait(100).then(() => { |
@@ -215,2 +215,3 @@ /* eslint-disable require-jsdoc */ | ||
}); | ||
document.cookie = ""; // clear cookies | ||
} |
@@ -15,16 +15,3 @@ /* eslint-disable cypress/no-unnecessary-waiting */ | ||
const userDetailObj = { | ||
name: "Barturiana Sosinsiava", | ||
username: "bar2rawwen", | ||
email: "test@test.com", | ||
organization: "Dukely", | ||
phone: "+123456789", | ||
picture: "https://ps.timg.com/profile_images/52237/011_n_400x400.jpg", | ||
gender: "Non-binary", | ||
byear: 1987, // birth year | ||
custom: { | ||
"key1 segment": "value1 segment", | ||
"key2 segment": "value2 segment" | ||
} | ||
}; | ||
const userDetailObj = hp.userDetailObj; | ||
@@ -31,0 +18,0 @@ // an event object to use |
@@ -17,34 +17,2 @@ /* eslint-disable require-jsdoc */ | ||
} | ||
function validateDefaultUtmTags(aq, source, medium, campaign, term, content) { | ||
if (typeof source === "string") { | ||
expect(aq.utm_source).to.eq(source); | ||
} | ||
else { | ||
expect(aq.utm_source).to.not.exist; | ||
} | ||
if (typeof medium === "string") { | ||
expect(aq.utm_medium).to.eq(medium); | ||
} | ||
else { | ||
expect(aq.utm_medium).to.not.exist; | ||
} | ||
if (typeof campaign === "string") { | ||
expect(aq.utm_campaign).to.eq(campaign); | ||
} | ||
else { | ||
expect(aq.utm_campaign).to.not.exist; | ||
} | ||
if (typeof term === "string") { | ||
expect(aq.utm_term).to.eq(term); | ||
} | ||
else { | ||
expect(aq.utm_term).to.not.exist; | ||
} | ||
if (typeof content === "string") { | ||
expect(aq.utm_content).to.eq(content); | ||
} | ||
else { | ||
expect(aq.utm_content).to.not.exist; | ||
} | ||
} | ||
@@ -58,3 +26,3 @@ describe("UTM tests ", () => { | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
}); | ||
@@ -69,3 +37,3 @@ }); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
hp.validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
}); | ||
@@ -80,3 +48,3 @@ }); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
hp.validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
expect(custom.utm_aa).to.eq("hehe"); | ||
@@ -93,3 +61,3 @@ expect(custom.utm_bb).to.eq(""); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
hp.validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
expect(custom.utm_aa).to.eq("hehe"); | ||
@@ -120,3 +88,3 @@ expect(custom.utm_bb).to.eq("hoho"); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
}); | ||
@@ -127,3 +95,3 @@ | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
hp.validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
expect(custom.utm_ss).to.eq("hehe2"); | ||
@@ -134,3 +102,3 @@ }); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe3", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe3", "", "", "", ""); | ||
}); | ||
@@ -170,3 +138,3 @@ // check if no utm tag in request queue if the query is wrong | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
}); | ||
@@ -177,3 +145,3 @@ | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
hp.validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
}); | ||
@@ -184,3 +152,3 @@ | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", undefined, undefined, "hehe3", undefined); | ||
hp.validateDefaultUtmTags(custom, "hehe", undefined, undefined, "hehe3", undefined); | ||
expect(custom.utm_sthelse).to.eq("hehe5"); | ||
@@ -192,3 +160,3 @@ }); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
}); | ||
@@ -199,3 +167,3 @@ | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
hp.validateDefaultUtmTags(custom, "hehe", "hehe1", "hehe2", "hehe3", "hehe4"); | ||
expect(custom.utm_next).to.eq("hehe5"); | ||
@@ -227,3 +195,3 @@ }); | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
hp.validateDefaultUtmTags(custom, "hehe", "", "", "", ""); | ||
}); | ||
@@ -244,3 +212,3 @@ | ||
const custom = JSON.parse(rq[0].user_details).custom; | ||
validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
hp.validateDefaultUtmTags(custom, undefined, undefined, undefined, undefined, undefined); | ||
expect(custom.utm_sauce).to.eq("hehe"); | ||
@@ -247,0 +215,0 @@ expect(custom.utm_pan).to.eq("hehe2"); |
@@ -82,3 +82,3 @@ import "./index"; | ||
else if (!isSessionEnd) { | ||
expect(queueObject.session_duration).to.be.within(duration, duration + 1); | ||
expect(queueObject.session_duration).to.be.within(duration, duration + 2); | ||
} | ||
@@ -189,6 +189,6 @@ else { | ||
*/ | ||
Cypress.Commands.add("check_user_details", (detailsObject, userDetails, limits) => { | ||
Cypress.Commands.add("check_user_details", (detailsObject, userDetails, limits, appKey) => { | ||
const obj = detailsObject; | ||
cy.check_commons(obj); | ||
cy.check_request_commons(obj); | ||
cy.check_request_commons(obj, appKey); | ||
const queue = JSON.parse(obj.user_details); | ||
@@ -360,3 +360,3 @@ if (limits !== undefined) { | ||
appKey = appKey || hp.appKey; | ||
cy.getLocalStorage(`${hp.appKey}/cly_event`).then((e) => { | ||
cy.getLocalStorage(`${appKey}/cly_event`).then((e) => { | ||
if (e === undefined) { | ||
@@ -381,3 +381,3 @@ expect.fail("event queue inside the local storage should not be undefined"); | ||
appKey = appKey || hp.appKey; | ||
cy.getLocalStorage(`${hp.appKey}/${key}`).then((e) => { | ||
cy.getLocalStorage(`${appKey}/${key}`).then((e) => { | ||
return JSON.parse(e); | ||
@@ -384,0 +384,0 @@ }); |
@@ -24,2 +24,21 @@ var Countly = require("../../lib/countly"); | ||
/** | ||
* user details object for user details tests (used in user_details.js and storage_change.js) | ||
* @type {Object} | ||
*/ | ||
const userDetailObj = { | ||
name: "Barturiana Sosinsiava", | ||
username: "bar2rawwen", | ||
email: "test@test.com", | ||
organization: "Dukely", | ||
phone: "+123456789", | ||
picture: "https://ps.timg.com/profile_images/52237/011_n_400x400.jpg", | ||
gender: "Non-binary", | ||
byear: 1987, | ||
custom: { | ||
"key1 segment": "value1 segment", | ||
"key2 segment": "value2 segment" | ||
} | ||
}; | ||
/** | ||
* get timestamp | ||
@@ -210,2 +229,46 @@ * @returns {number} -timestamp | ||
/** | ||
* Validates utm tags in the request queue/given object | ||
* You can pass undefined if you want to check if utm tags do not exist | ||
* | ||
* @param {*} aq - object to check | ||
* @param {*} source - utm_source | ||
* @param {*} medium - utm_medium | ||
* @param {*} campaign - utm_campaign | ||
* @param {*} term - utm_term | ||
* @param {*} content - utm_content | ||
*/ | ||
function validateDefaultUtmTags(aq, source, medium, campaign, term, content) { | ||
if (typeof source === "string") { | ||
expect(aq.utm_source).to.eq(source); | ||
} | ||
else { | ||
expect(aq.utm_source).to.not.exist; | ||
} | ||
if (typeof medium === "string") { | ||
expect(aq.utm_medium).to.eq(medium); | ||
} | ||
else { | ||
expect(aq.utm_medium).to.not.exist; | ||
} | ||
if (typeof campaign === "string") { | ||
expect(aq.utm_campaign).to.eq(campaign); | ||
} | ||
else { | ||
expect(aq.utm_campaign).to.not.exist; | ||
} | ||
if (typeof term === "string") { | ||
expect(aq.utm_term).to.eq(term); | ||
} | ||
else { | ||
expect(aq.utm_term).to.not.exist; | ||
} | ||
if (typeof content === "string") { | ||
expect(aq.utm_content).to.eq(content); | ||
} | ||
else { | ||
expect(aq.utm_content).to.not.exist; | ||
} | ||
} | ||
module.exports = { | ||
@@ -222,3 +285,5 @@ haltAndClearStorage, | ||
testNormalFlow, | ||
interceptAndCheckRequests | ||
interceptAndCheckRequests, | ||
validateDefaultUtmTags, | ||
userDetailObj | ||
}; |
@@ -20,1 +20,18 @@ /* eslint-disable no-unused-vars */ | ||
} | ||
/** | ||
* Sets a value to local storage and triggers a storage event | ||
* @param {*} key - storage key | ||
* @param {*} value - storage value | ||
*/ | ||
function triggerStorageChange(key, value) { | ||
localStorage.setItem(key, value); | ||
const storageEvent = new StorageEvent("storage", { | ||
key: key, | ||
newValue: value | ||
}); | ||
window.dispatchEvent(storageEvent); | ||
} | ||
export { queryExtractor, triggerStorageChange }; |
@@ -6,3 +6,3 @@ { | ||
"dependencies": { | ||
"countly-sdk-web": "^23.6.1" | ||
"countly-sdk-web": "^23.6.2" | ||
}, | ||
@@ -9,0 +9,0 @@ "devDependencies": { |
@@ -14,3 +14,3 @@ { | ||
"@babel/preset-env": "7.21.4", | ||
"@babel/core": "7.21.4", | ||
"@babel/core": "7.23.2", | ||
"babel-loader": "8.2.5", | ||
@@ -21,2 +21,2 @@ "babel-plugin-syntax-dynamic-import": "6.18.0", | ||
} | ||
} | ||
} |
{ | ||
"name": "countly-sdk-web", | ||
"version": "23.6.1", | ||
"version": "23.6.2", | ||
"description": "Countly Web SDK", | ||
@@ -5,0 +5,0 @@ "main": "lib/countly.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2028622
140
13420