diff --git a/CHANGELOG.md b/CHANGELOG.md
index b9b91e1..35c3787 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 23.12.3
+
+* Added bot detection for workers
+* Added the ability to clear stored device IDs in the workers
+
## 23.12.2
* Added Google Lighthouse to bot detection
diff --git a/cypress/e2e/user_agent.cy.js b/cypress/e2e/user_agent.cy.js
index 244ac1a..5f6a9b9 100644
--- a/cypress/e2e/user_agent.cy.js
+++ b/cypress/e2e/user_agent.cy.js
@@ -58,6 +58,8 @@ describe("User Agent tests ", () => {
expect(Countly._internals.userAgentSearchBotDetection("123")).to.equal(false);
expect(Countly._internals.userAgentSearchBotDetection("Googlebot")).to.equal(true);
expect(Countly._internals.userAgentSearchBotDetection("Google")).to.equal(false);
+ expect(Countly._internals.userAgentSearchBotDetection("HeadlessChrome")).to.equal(true);
+ expect(Countly._internals.userAgentSearchBotDetection("Chrome-Lighthouse")).to.equal(true);
});
});
});
diff --git a/examples/example_web_worker.html b/examples/example_web_worker.html
index 7d49769..887c34b 100644
--- a/examples/example_web_worker.html
+++ b/examples/example_web_worker.html
@@ -16,7 +16,7 @@
diff --git a/examples/worker.js b/examples/worker.js
index 49dcef5..1d71d66 100644
--- a/examples/worker.js
+++ b/examples/worker.js
@@ -5,6 +5,7 @@ Countly.init({
app_key: "YOUR_APP_KEY",
url: "https://your.domain.count.ly",
debug: true,
+ clear_stored_id: true, // Resets the stored device ID on init
storage: {
getItem: (key) => {
return STORAGE[key];
diff --git a/modules/Constants.js b/modules/Constants.js
index 7574470..f8514b2 100644
--- a/modules/Constants.js
+++ b/modules/Constants.js
@@ -104,7 +104,7 @@ var healthCheckCounterEnum = Object.freeze({
errorMessage: "cly_hc_error_message",
});
-var SDK_VERSION = "23.12.2";
+var SDK_VERSION = "23.12.3";
var SDK_NAME = "javascript_native_web";
// 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)
diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js
index decfa0c..9b9a9ca 100644
--- a/modules/CountlyClass.js
+++ b/modules/CountlyClass.js
@@ -107,7 +107,7 @@ class CountlyClass {
this.getSearchQuery = getConfig("getSearchQuery", ob, Countly.getSearchQuery);
this.DeviceIdType = Countly.DeviceIdType; // it is Countly device Id type Enums for clients to use
this.namespace = getConfig("namespace", ob, "");
- this.clearStoredId = !isBrowser ? undefined : getConfig("clear_stored_id", ob, false);
+ this.clearStoredId = getConfig("clear_stored_id", ob, false);
this.app_key = getConfig("app_key", ob, null);
this.onload = getConfig("onload", ob, []);
this.utm = getConfig("utm", ob, { source: true, medium: true, campaign: true, term: true, content: true });
@@ -124,7 +124,7 @@ class CountlyClass {
this.country_code = getConfig("country_code", ob, null);
this.city = getConfig("city", ob, null);
this.ip_address = getConfig("ip_address", ob, null);
- this.ignore_bots = !isBrowser ? undefined : getConfig("ignore_bots", ob, true);
+ this.ignore_bots = getConfig("ignore_bots", ob, true);
this.force_post = getConfig("force_post", ob, false);
this.remote_config = getConfig("remote_config", ob, false);
this.ignore_visitor = getConfig("ignore_visitor", ob, false);
@@ -197,9 +197,9 @@ class CountlyClass {
}
// then clear the storage so that a new device ID is set again later
log(logLevelEnums.INFO, "initialize, Clearing the device ID storage");
- localStorage.removeItem(this.app_key + "/cly_id");
- localStorage.removeItem(this.app_key + "/cly_id_type");
- localStorage.removeItem(this.app_key + "/cly_session");
+ removeValueFromStorage("cly_id");
+ removeValueFromStorage("cly_id_type");
+ removeValueFromStorage("cly_session");
}
checkIgnore();
@@ -3425,11 +3425,14 @@ class CountlyClass {
* Check if user or visit should be ignored
*/
function checkIgnore() {
+ log(logLevelEnums.INFO, "checkIgnore, Checking if user or visit should be ignored");
if (self.ignore_prefetch && isBrowser && typeof document.visibilityState !== "undefined" && document.visibilityState === "prerender") {
self.ignore_visitor = true;
+ log(logLevelEnums.DEBUG, "checkIgnore, Ignoring visit due to prerendering");
}
if (self.ignore_bots && userAgentSearchBotDetection()) {
self.ignore_visitor = true;
+ log(logLevelEnums.DEBUG, "checkIgnore, Ignoring visit due to bot");
}
}
diff --git a/package.json b/package.json
index f4caacf..4ec9deb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "countly-sdk-js",
- "version": "23.12.2",
+ "version": "23.12.3",
"description": "Countly JavaScript SDK",
"type": "module",
"main": "Countly.js",