Skip to content

Commit d929c1b

Browse files
authored
release ready (#463)
1 parent 5a07d96 commit d929c1b

File tree

9 files changed

+152
-138
lines changed

9 files changed

+152
-138
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 23.12.3
2+
- Added bot detection for workers
3+
- Added the ability to clear stored device IDs in the workers
4+
- Mitigated an issue where utm naming could have been affected if 'searchQuery' did not return '?'
5+
16
## 23.12.2
27
- Improved bot detection capabilities
38

cypress/integration/bridge_utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function initMain(name, version) {
1616
}
1717

1818
const SDK_NAME = "javascript_native_web";
19-
const SDK_VERSION = "23.12.2";
19+
const SDK_VERSION = "23.12.3";
2020

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

cypress/integration/user_agent.js

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ describe("User Agent tests ", () => {
5858
expect(Countly._internals.userAgentSearchBotDetection("123")).to.equal(false);
5959
expect(Countly._internals.userAgentSearchBotDetection("Googlebot")).to.equal(true);
6060
expect(Countly._internals.userAgentSearchBotDetection("Google")).to.equal(false);
61+
expect(Countly._internals.userAgentSearchBotDetection("HeadlessChrome")).to.equal(true);
62+
expect(Countly._internals.userAgentSearchBotDetection("Chrome-Lighthouse")).to.equal(true);
6163
});
6264
});
6365
});

cypress/integration/utm.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("UTM tests ", () => {
3838
});
3939
it("Checks if a single custom utm tag works", () => {
4040
hp.haltAndClearStorage(() => {
41-
initMulti("YOUR_APP_KEY", "?utm_aa=hehe", { aa: true, bb: true });
41+
initMulti("YOUR_APP_KEY", "utm_aa=hehe", { aa: true, bb: true });
4242
cy.fetch_local_request_queue().then((rq) => {
4343
cy.log(rq);
4444
const custom = JSON.parse(rq[0].user_details).custom;
@@ -50,7 +50,7 @@ describe("UTM tests ", () => {
5050
});
5151
it("Checks if custom utm tags works", () => {
5252
hp.haltAndClearStorage(() => {
53-
initMulti("YOUR_APP_KEY", "?utm_aa=hehe&utm_bb=hoho", { aa: true, bb: true });
53+
initMulti("YOUR_APP_KEY", "utm_aa=hehe&utm_bb=hoho", { aa: true, bb: true });
5454
cy.fetch_local_request_queue().then((rq) => {
5555
cy.log(rq);
5656
const custom = JSON.parse(rq[0].user_details).custom;
@@ -72,7 +72,7 @@ describe("UTM tests ", () => {
7272
initMulti("Countly_3", "?utm_source=hehe3", undefined);
7373

7474
// utm object not provided with inappropriate query
75-
initMulti("Countly_5", "?utm_ss=hehe5", undefined);
75+
initMulti("Countly_5", "utm_ss=hehe5", undefined);
7676

7777
// default (original) init with no custom tags and default query
7878
initMulti("YOUR_APP_KEY", "?utm_source=hehe", undefined);
@@ -116,7 +116,7 @@ describe("UTM tests ", () => {
116116
initMulti("Countly_multi_2", "?utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4&utm_sthelse=hehe5&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", { source: true, term: true, sthelse: true });
117117

118118
// empty init, garbage query + 1 default
119-
initMulti("Countly_multi_3", "?dasdashdjkhaslkjdhsakj=dasmndlask=asdkljska&&utm_source=hehe", undefined);
119+
initMulti("Countly_multi_3", "dasdashdjkhaslkjdhsakj=dasmndlask=asdkljska&&utm_source=hehe", undefined);
120120

121121
// full default utm obj + custom 1, full query + 1
122122
initMulti("Countly_multi_4", "?utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4&utm_next=hehe5", { source: true, medium: true, campaign: true, term: true, content: true, next: true });

cypress/integration/view_utm_referrer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe("View with utm and referrer tests ", () => {
4242
// we record 2 views and check if both have the same utm tag
4343
it("Checks if a single default utm tag is at view segmentation of both views", () => {
4444
hp.haltAndClearStorage(() => {
45-
init("YOUR_APP_KEY", "?utm_source=hehe", undefined);
45+
init("YOUR_APP_KEY", "utm_source=hehe", undefined);
4646
Countly.track_view(pageNameOne); // first view
4747
Countly.track_view(pageNameTwo); // second view
4848
// View event should have the utm tag

examples/worker.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Countly.init({
66
app_key: "YOUR_APP_KEY",
77
url: "https://your.domain.countly",
88
debug: true,
9+
clear_stored_id: true, // Resets the stored device ID on init
910
storage: {
1011
getItem: function (key) {
1112
return STORE[key];

lib/countly.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
statusCode: "cly_hc_status_code",
197197
errorMessage: "cly_hc_error_message"
198198
});
199-
var SDK_VERSION = "23.12.2";
199+
var SDK_VERSION = "23.12.3";
200200
var SDK_NAME = "javascript_native_web";
201201

202202
// Using this on document.referrer would return an array with 15 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
@@ -831,7 +831,7 @@
831831
this.getSearchQuery = getConfig("getSearchQuery", ob, Countly.getSearchQuery);
832832
this.DeviceIdType = Countly.DeviceIdType; // it is Countly device Id type Enums for clients to use
833833
this.namespace = getConfig("namespace", ob, "");
834-
this.clearStoredId = !isBrowser ? undefined : getConfig("clear_stored_id", ob, false);
834+
this.clearStoredId = getConfig("clear_stored_id", ob, false);
835835
this.app_key = getConfig("app_key", ob, null);
836836
this.onload = getConfig("onload", ob, []);
837837
this.utm = getConfig("utm", ob, {
@@ -854,7 +854,7 @@
854854
this.country_code = getConfig("country_code", ob, null);
855855
this.city = getConfig("city", ob, null);
856856
this.ip_address = getConfig("ip_address", ob, null);
857-
this.ignore_bots = !isBrowser ? undefined : getConfig("ignore_bots", ob, true);
857+
this.ignore_bots = getConfig("ignore_bots", ob, true);
858858
this.force_post = getConfig("force_post", ob, false);
859859
this.remote_config = getConfig("remote_config", ob, false);
860860
this.ignore_visitor = getConfig("ignore_visitor", ob, false);
@@ -918,9 +918,9 @@
918918
}
919919
// then clear the storage so that a new device ID is set again later
920920
log(logLevelEnums.INFO, "initialize, Clearing the device ID storage");
921-
localStorage.removeItem(this.app_key + "/cly_id");
922-
localStorage.removeItem(this.app_key + "/cly_id_type");
923-
localStorage.removeItem(this.app_key + "/cly_session");
921+
removeValueFromStorage("cly_id");
922+
removeValueFromStorage("cly_id_type");
923+
removeValueFromStorage("cly_session");
924924
}
925925
checkIgnore();
926926
if (isBrowser) {
@@ -1107,7 +1107,11 @@
11071107
var hasUTM = false;
11081108
var utms = {};
11091109
if (searchQuery) {
1110-
var parts = searchQuery.substring(1).split("&");
1110+
// remove the '?' character from the beginning if it exists
1111+
if (searchQuery.indexOf('?') === 0) {
1112+
searchQuery = searchQuery.substring(1);
1113+
}
1114+
var parts = searchQuery.split("&");
11111115
for (var i = 0; i < parts.length; i++) {
11121116
var nv = parts[i].split("=");
11131117
if (nv[0] === "cly_id") {
@@ -4003,11 +4007,14 @@
40034007
* Check if user or visit should be ignored
40044008
*/
40054009
function checkIgnore() {
4010+
log(logLevelEnums.INFO, "checkIgnore, Checking if user or visit should be ignored");
40064011
if (self.ignore_prefetch && isBrowser && typeof document.visibilityState !== "undefined" && document.visibilityState === "prerender") {
40074012
self.ignore_visitor = true;
4013+
log(logLevelEnums.DEBUG, "checkIgnore, Ignoring visit due to prerendering");
40084014
}
40094015
if (self.ignore_bots && userAgentSearchBotDetection()) {
40104016
self.ignore_visitor = true;
4017+
log(logLevelEnums.DEBUG, "checkIgnore, Ignoring visit due to bot");
40114018
}
40124019
}
40134020

0 commit comments

Comments
 (0)