Skip to content

Commit

Permalink
initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
turtledreams committed Oct 19, 2024
1 parent cf5c572 commit 7aaf344
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 24.4.2

* Healtchecks won't be sent in offline mode
* Improved view tracking logic

## 24.4.1

* Added a new method `set_id(newDeviceId)` for managing device id changes according to the device ID Type.
Expand Down
20 changes: 15 additions & 5 deletions modules/CountlyClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CountlyClass {
var freshUTMTags = null;
var sdkName = getConfig("sdk_name", ob, SDK_NAME);
var sdkVersion = getConfig("sdk_version", ob, SDK_VERSION);
var shouldSendHC = false;

try {
localStorage.setItem("cly_testLocal", true);
Expand Down Expand Up @@ -344,7 +345,7 @@ class CountlyClass {
if (offlineMode) {
log(logLevelEnums.DEBUG, "initialize, offline_mode:[" + offlineMode + "], user info won't be send to the servers");
}
if (offlineMode) {
if (remoteConfigs) {
log(logLevelEnums.DEBUG, "initialize, stored remote configs:[" + JSON.stringify(remoteConfigs) + "]");
}
// functions, if provided, would be printed as true without revealing their content
Expand Down Expand Up @@ -898,6 +899,10 @@ class CountlyClass {
if (needResync) {
setValueInStorage("cly_queue", requestQueue, true);
}
if (shouldSendHC) {
HealthCheck.sendInstantHCRequest();
shouldSendHC = false;
}
};

/**
Expand Down Expand Up @@ -1971,9 +1976,6 @@ class CountlyClass {
}
}
}
lastView = page;
lastViewTime = getTimestamp();
log(logLevelEnums.VERBOSE, "track_pageview, last view is assigned:[" + lastView + "], current view ID is:[" + currentViewId + "], previous view ID is:[" + previousViewId + "]");
var segments = {
name: page,
visit: 1,
Expand Down Expand Up @@ -2044,6 +2046,9 @@ class CountlyClass {
key: internalEventKeyEnums.VIEW,
segmentation: segments
}, currentViewId);
lastView = page;
lastViewTime = getTimestamp();
log(logLevelEnums.VERBOSE, "track_pageview, last view is assigned:[" + lastView + "]");
}
else {
lastParams.track_pageview = arguments;
Expand Down Expand Up @@ -4072,7 +4077,7 @@ class CountlyClass {
var xhr = new XMLHttpRequest();
params = params || {};
prepareParams(params, self.salt).then(saltedData => {
var method = "GET";
var method = "POST";
if (self.force_post || saltedData.length >= 2000) {
method = "POST";
}
Expand Down Expand Up @@ -4779,6 +4784,11 @@ class CountlyClass {
* Countly health check request sender
*/
function sendInstantHCRequest() {
if (offlineMode) {
log(logLevelEnums.DEBUG, "sendInstantHCRequest, Offline mode is active. Not sending health check request.");
shouldSendHC = true;
return;
}
// truncate error message to 1000 characters
var curbedMessage = truncateSingleValue(self.hcErrorMessage, 1000, "healthCheck", log);
// due to some server issues we pass empty string as is
Expand Down

0 comments on commit 7aaf344

Please sign in to comment.