From ba4e2c36a634d17394ea4fe7ee5942f6b8b0e3af Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:29:16 +0900 Subject: [PATCH] empty string issue --- CHANGELOG.md | 1 + cypress/e2e/health_check.cy.js | 2 +- modules/CountlyClass.js | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00506b..13381ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 23.12.6 * Mitigated an issue where error tracking could prevent SDK initialization in async mode +* Improved Health Check reporting ## 23.12.5 diff --git a/cypress/e2e/health_check.cy.js b/cypress/e2e/health_check.cy.js index 131bb7d..0d2fc4e 100644 --- a/cypress/e2e/health_check.cy.js +++ b/cypress/e2e/health_check.cy.js @@ -21,7 +21,7 @@ describe("Health Check tests ", () => { // Test the 'hc' parameter const hcParam = url.searchParams.get("hc"); const hcParamObj = JSON.parse(hcParam); - expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "\"\"" }); + expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "" }); // Test the 'metrics' parameter const metricsParam = url.searchParams.get("metrics"); diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index 15de017..42dd91d 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -4754,12 +4754,16 @@ class CountlyClass { function sendInstantHCRequest() { // 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 + if (curbedMessage !== "") { + curbedMessage = JSON.stringify(curbedMessage); + } // prepare hc object var hc = { el: self.hcErrorCount, wl: self.hcWarningCount, sc: self.hcStatusCode, - em: JSON.stringify(curbedMessage) + em: curbedMessage }; // prepare request var request = {