Skip to content

Commit a81d981

Browse files
authored
Merge pull request #538 from Countly/content-fixes
24.11.2 release
2 parents cf3e3d6 + 91a87c0 commit a81d981

File tree

6 files changed

+242
-215
lines changed

6 files changed

+242
-215
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 24.11.2
2+
- Added a new init method to set the interval of Content Zone's timer (Experimental!):
3+
- `content_zone_timer_interval` to set the timer interval in `seconds`
4+
- Mitigated an issue about Content's positioning (Experimental!)
5+
16
## 24.11.1
27
- Deprecated `initializeRatingWidgets` method, use `feedback.showRating` instead.
38
- Deprecated `enableRatingWidgets` method, use `feedback.showRating` instead.

cypress/e2e/bridged_utils.cy.js

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

1717
const SDK_NAME = "javascript_native_web";
18-
const SDK_VERSION = "24.11.1";
18+
const SDK_VERSION = "24.11.2";
1919

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

lib/countly.js

+44-23
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
statusCode: "cly_hc_status_code",
210210
errorMessage: "cly_hc_error_message"
211211
});
212-
var SDK_VERSION = "24.11.1";
212+
var SDK_VERSION = "24.11.2";
213213
var SDK_NAME = "javascript_native_web";
214214

215215
// Using this on document.referrer would return an array with 17 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)
@@ -899,6 +899,7 @@
899899
var _contentEndPoint = /*#__PURE__*/new WeakMap();
900900
var _inContentZone = /*#__PURE__*/new WeakMap();
901901
var _contentZoneTimer = /*#__PURE__*/new WeakMap();
902+
var _contentZoneTimerInterval = /*#__PURE__*/new WeakMap();
902903
var _contentIframeID = /*#__PURE__*/new WeakMap();
903904
var _initialize = /*#__PURE__*/new WeakMap();
904905
var _updateConsent = /*#__PURE__*/new WeakMap();
@@ -1014,6 +1015,7 @@
10141015
_classPrivateFieldInitSpec(this, _contentEndPoint, void 0);
10151016
_classPrivateFieldInitSpec(this, _inContentZone, void 0);
10161017
_classPrivateFieldInitSpec(this, _contentZoneTimer, void 0);
1018+
_classPrivateFieldInitSpec(this, _contentZoneTimerInterval, void 0);
10171019
_classPrivateFieldInitSpec(this, _contentIframeID, void 0);
10181020
/**
10191021
* Initialize the Countly
@@ -1071,6 +1073,10 @@
10711073
_this.hcWarningCount = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.warningCount) || 0;
10721074
_this.hcStatusCode = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.statusCode) || -1;
10731075
_this.hcErrorMessage = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.errorMessage) || "";
1076+
_classPrivateFieldSet2(_contentZoneTimerInterval, _this, getConfig("content_zone_timer_interval", ob, null));
1077+
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
1078+
_classPrivateFieldSet2(_contentTimeInterval, _this, Math.max(_classPrivateFieldGet2(_contentZoneTimerInterval, _this), 15) * 1000);
1079+
}
10741080
if (_classPrivateFieldGet2(_maxCrashLogs, _this) && !_this.maxBreadcrumbCount) {
10751081
_this.maxBreadcrumbCount = _classPrivateFieldGet2(_maxCrashLogs, _this);
10761082
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.WARNING, "initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!");
@@ -1257,6 +1263,9 @@
12571263
if (_classPrivateFieldGet2(_remoteConfigs, _this)) {
12581264
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, stored remote configs:[" + JSON.stringify(_classPrivateFieldGet2(_remoteConfigs, _this)) + "]");
12591265
}
1266+
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
1267+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, content_zone_timer_interval:[" + _classPrivateFieldGet2(_contentZoneTimerInterval, _this) + "]");
1268+
}
12601269
// functions, if provided, would be printed as true without revealing their content
12611270
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, 'getViewName' callback override provided:[" + (_this.getViewName !== Countly.getViewName) + "]");
12621271
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, 'getSearchQuery' callback override provided:[" + (_this.getSearchQuery !== Countly.getSearchQuery) + "]");
@@ -4327,15 +4336,17 @@
43274336
});
43284337
_classPrivateFieldInitSpec(this, _prepareContentRequest, function () {
43294338
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "prepareContentRequest, forming content request");
4330-
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this);
4339+
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, true);
43314340
var resToSend = {
43324341
l: {},
43334342
p: {}
43344343
};
4335-
resToSend.l.w = resInfo.width;
4336-
resToSend.l.h = resInfo.height;
4337-
resToSend.p.w = resInfo.height;
4338-
resToSend.p.h = resInfo.width;
4344+
var lWidthPHeight = Math.max(resInfo.width, resInfo.height);
4345+
var lHeightPWidth = Math.min(resInfo.width, resInfo.height);
4346+
resToSend.l.w = lWidthPHeight;
4347+
resToSend.l.h = lHeightPWidth;
4348+
resToSend.p.w = lHeightPWidth;
4349+
resToSend.p.h = lWidthPHeight;
43394350
var local = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage;
43404351
var language = local.split('-')[0];
43414352
var params = {
@@ -4374,10 +4385,15 @@
43744385
iframe.id = _classPrivateFieldGet2(_contentIframeID, _this);
43754386
iframe.src = response.html;
43764387
iframe.style.position = "absolute";
4377-
iframe.style.left = response.geo.l.x + "px";
4378-
iframe.style.top = response.geo.l.y + "px";
4379-
iframe.style.width = response.geo.l.w + "px";
4380-
iframe.style.height = response.geo.l.h + "px";
4388+
var dimensionToUse = response.geo.p;
4389+
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, true);
4390+
if (resInfo.width >= resInfo.height) {
4391+
dimensionToUse = response.geo.l;
4392+
}
4393+
iframe.style.left = dimensionToUse.x + "px";
4394+
iframe.style.top = dimensionToUse.y + "px";
4395+
iframe.style.width = dimensionToUse.w + "px";
4396+
iframe.style.height = dimensionToUse.h + "px";
43814397
iframe.style.border = "none";
43824398
iframe.style.zIndex = "999999";
43834399
document.body.appendChild(iframe);
@@ -4859,38 +4875,43 @@
48594875
});
48604876
/**
48614877
* returns the resolution of the device
4862-
* @param {bool} getAvailable - get available resolution
4878+
* @param {bool} getViewPort - get viewport
48634879
* @returns {object} resolution object: {width: 1920, height: 1080, orientation: 0}
48644880
*/
4865-
_classPrivateFieldInitSpec(this, _getResolution, function (getAvailable) {
4881+
_classPrivateFieldInitSpec(this, _getResolution, function (getViewPort) {
48664882
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "Getting the resolution of the device");
48674883
if (!isBrowser || !screen) {
48684884
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "No screen available");
48694885
return null;
48704886
}
48714887
var width = screen.width ? parseInt(screen.width) : 0;
48724888
var height = screen.height ? parseInt(screen.height) : 0;
4873-
if (getAvailable) {
4874-
width = screen.availWidth ? parseInt(screen.availWidth) : width;
4875-
height = screen.availHeight ? parseInt(screen.availHeight) : height;
4889+
if (getViewPort) {
4890+
var viewportWidth = window.innerWidth;
4891+
var viewportHeight = window.innerHeight;
4892+
var layoutWidth = document.documentElement.clientWidth;
4893+
var layoutHeight = document.documentElement.clientHeight;
4894+
var visibleWidth = Math.min(viewportWidth, layoutWidth);
4895+
var visibleHeight = Math.min(viewportHeight, layoutHeight);
4896+
width = visibleWidth ? parseInt(visibleWidth) : width;
4897+
height = visibleHeight ? parseInt(visibleHeight) : height;
48764898
}
48774899
if (width === 0 || height === 0) {
48784900
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "Screen width or height is non existent");
48794901
return null;
48804902
}
48814903
var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
48824904
if (iOS && window.devicePixelRatio) {
4905+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "Mobile Mac device detected, adjusting resolution");
48834906
// ios provides dips, need to multiply
48844907
width = Math.round(width * window.devicePixelRatio);
48854908
height = Math.round(height * window.devicePixelRatio);
4886-
} else {
4887-
if (Math.abs(screen.orientation.angle) === 90) {
4888-
// we have landscape orientation
4889-
// switch values for all except ios
4890-
var temp = width;
4891-
width = height;
4892-
height = temp;
4893-
}
4909+
}
4910+
if (Math.abs(screen.orientation.angle) === 90) {
4911+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "Screen is in landscape mode, adjusting resolution");
4912+
var temp = width;
4913+
width = height;
4914+
height = temp;
48944915
}
48954916
return {
48964917
width: width,

0 commit comments

Comments
 (0)