From 3e4f8e3be29fc372b33f4d49a3a4b94473c0fe08 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:53:30 +0900 Subject: [PATCH 1/5] Dimension fix --- CHANGELOG.md | 4 ++++ modules/CountlyClass.js | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926ea10..67040cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 24.11.2 + +* Mitigated an issue about content's positioning (Experimental!) + ## 24.11.1 * Deprecated `initializeRatingWidgets` method, use `feedback.showRating` instead. diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index b8b8616..feeb080 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -3679,7 +3679,7 @@ constructor(ob) { #prepareContentRequest = () => { this.#log(logLevelEnums.DEBUG, "prepareContentRequest, forming content request"); - const resInfo = this.#getResolution(); + const resInfo = this.#getResolution(true); var resToSend = {l : {}, p: {}}; resToSend.l.w = resInfo.width; resToSend.l.h = resInfo.height; @@ -4243,10 +4243,10 @@ constructor(ob) { /** * returns the resolution of the device - * @param {bool} getAvailable - get available resolution + * @param {bool} getViewPort - get viewport * @returns {object} resolution object: {width: 1920, height: 1080, orientation: 0} */ - #getResolution = (getAvailable) => { + #getResolution = (getViewPort) => { this.#log(logLevelEnums.DEBUG, "Getting the resolution of the device"); if (!isBrowser || !screen) { this.#log(logLevelEnums.DEBUG, "No screen available"); @@ -4256,9 +4256,16 @@ constructor(ob) { var width = (screen.width) ? parseInt(screen.width) : 0; var height = (screen.height) ? parseInt(screen.height) : 0; - if (getAvailable) { - width = (screen.availWidth) ? parseInt(screen.availWidth) : width; - height = (screen.availHeight) ? parseInt(screen.availHeight) : height; + if (getViewPort) { + const viewportWidth = window.innerWidth; + const viewportHeight = window.innerHeight; + const layoutWidth = document.documentElement.clientWidth; + const layoutHeight = document.documentElement.clientHeight; + const visibleWidth = Math.min(viewportWidth, layoutWidth); + const visibleHeight = Math.min(viewportHeight, layoutHeight); + + width = visibleWidth ? parseInt(visibleWidth) : width; + height = visibleHeight ? parseInt(visibleHeight) : height; } if (width === 0 || height === 0) { From f8968cdab0f464fdec7b5da8f9d5411ea03cbd4e Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:59:51 +0900 Subject: [PATCH 2/5] res --- modules/CountlyClass.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index feeb080..3116199 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -3728,10 +3728,14 @@ constructor(ob) { iframe.id = this.#contentIframeID; iframe.src = response.html; iframe.style.position = "absolute"; - iframe.style.left = response.geo.l.x + "px"; - iframe.style.top = response.geo.l.y + "px"; - iframe.style.width = response.geo.l.w + "px"; - iframe.style.height = response.geo.l.h + "px"; + var dimensionToUse = response.geo.p; + if (screen && screen.orientation.angle === 90) { + dimensionToUse = response.geo.l; + }; + iframe.style.left = dimensionToUse.x + "px"; + iframe.style.top = dimensionToUse.y + "px"; + iframe.style.width = dimensionToUse.w + "px"; + iframe.style.height = dimensionToUse.h + "px"; iframe.style.border = "none"; iframe.style.zIndex = "999999"; document.body.appendChild(iframe); @@ -4274,18 +4278,16 @@ constructor(ob) { } var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); if (iOS && window.devicePixelRatio) { + this.#log(logLevelEnums.VERBOSE, "Mobile Mac device detected, adjusting resolution"); // ios provides dips, need to multiply width = Math.round(width * window.devicePixelRatio); height = Math.round(height * window.devicePixelRatio); } - else { - if (Math.abs(screen.orientation.angle) === 90) { - // we have landscape orientation - // switch values for all except ios - var temp = width; - width = height; - height = temp; - } + if (Math.abs(screen.orientation.angle) === 90) { + this.#log(logLevelEnums.VERBOSE, "Screen is in landscape mode, adjusting resolution"); + var temp = width; + width = height; + height = temp; } return { width: width, height: height , orientation: screen.orientation.angle }; }; From 6ad48ec20a542516f38c635cd72f7e18ee1b3b16 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:25:57 +0900 Subject: [PATCH 3/5] precision --- modules/CountlyClass.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index 3116199..84d35b6 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -3681,10 +3681,12 @@ constructor(ob) { this.#log(logLevelEnums.DEBUG, "prepareContentRequest, forming content request"); const resInfo = this.#getResolution(true); var resToSend = {l : {}, p: {}}; - resToSend.l.w = resInfo.width; - resToSend.l.h = resInfo.height; - resToSend.p.w = resInfo.height; - resToSend.p.h = resInfo.width; + const lWidthPHeight = Math.max(resInfo.width, resInfo.height); + const lHeightPWidth = Math.min(resInfo.width, resInfo.height); + resToSend.l.w = lWidthPHeight; + resToSend.l.h = lHeightPWidth; + resToSend.p.w = lHeightPWidth; + resToSend.p.h = lWidthPHeight; const local = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage; const language = local.split('-')[0]; @@ -3729,7 +3731,8 @@ constructor(ob) { iframe.src = response.html; iframe.style.position = "absolute"; var dimensionToUse = response.geo.p; - if (screen && screen.orientation.angle === 90) { + const resInfo = this.#getResolution(true); + if (resInfo.width >= resInfo.height) { dimensionToUse = response.geo.l; }; iframe.style.left = dimensionToUse.x + "px"; From 0b0c4df5449576187767f55184598138f04661e6 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:18:38 +0900 Subject: [PATCH 4/5] timer --- modules/CountlyClass.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/CountlyClass.js b/modules/CountlyClass.js index 84d35b6..59db5f6 100644 --- a/modules/CountlyClass.js +++ b/modules/CountlyClass.js @@ -91,6 +91,7 @@ class CountlyClass { #contentEndPoint; #inContentZone; #contentZoneTimer; + #contentZoneTimerInterval; #contentIframeID; constructor(ob) { this.#self = this; @@ -216,6 +217,11 @@ constructor(ob) { this.hcWarningCount = this.#getValueFromStorage(healthCheckCounterEnum.warningCount) || 0; this.hcStatusCode = this.#getValueFromStorage(healthCheckCounterEnum.statusCode) || -1; this.hcErrorMessage = this.#getValueFromStorage(healthCheckCounterEnum.errorMessage) || ""; + this.#contentZoneTimerInterval = getConfig("content_zone_timer_interval", ob, null); + + if (this.#contentZoneTimerInterval) { + this.#contentTimeInterval = Math.max(this.#contentZoneTimerInterval, 15) * 1000; + } if (this.#maxCrashLogs && !this.maxBreadcrumbCount) { this.maxBreadcrumbCount = this.#maxCrashLogs; @@ -419,6 +425,9 @@ constructor(ob) { if (this.#remoteConfigs) { this.#log(logLevelEnums.DEBUG, "initialize, stored remote configs:[" + JSON.stringify(this.#remoteConfigs) + "]"); } + if (this.#contentZoneTimerInterval) { + this.#log(logLevelEnums.DEBUG, "initialize, content_zone_timer_interval:[" + this.#contentZoneTimerInterval + "]"); + } // functions, if provided, would be printed as true without revealing their content this.#log(logLevelEnums.DEBUG, "initialize, 'getViewName' callback override provided:[" + (this.getViewName !== Countly.getViewName) + "]"); this.#log(logLevelEnums.DEBUG, "initialize, 'getSearchQuery' callback override provided:[" + (this.getSearchQuery !== Countly.getSearchQuery) + "]"); From b434825bd80bb5b2c9e43f33b28eb50a4e736919 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:19:17 +0900 Subject: [PATCH 5/5] changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67040cb..4704dbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 24.11.2 -* Mitigated an issue about content's positioning (Experimental!) +* Added a new init method to set the interval of Content Zone's timer (Experimental!): + * `content_zone_timer_interval` to set the timer interval in `seconds` +* Mitigated an issue about Content's positioning (Experimental!) ## 24.11.1