Skip to content

Commit

Permalink
Merge pull request #538 from Countly/content-fixes
Browse files Browse the repository at this point in the history
24.11.2 release
  • Loading branch information
turtledreams authored Dec 9, 2024
2 parents cf3e3d6 + 91a87c0 commit a81d981
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 215 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 24.11.2
- 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
- Deprecated `initializeRatingWidgets` method, use `feedback.showRating` instead.
- Deprecated `enableRatingWidgets` method, use `feedback.showRating` instead.
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/bridged_utils.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function initMain(name, version) {
}

const SDK_NAME = "javascript_native_web";
const SDK_VERSION = "24.11.1";
const SDK_VERSION = "24.11.2";

// tests
describe("Bridged SDK Utilities Tests", () => {
Expand Down
67 changes: 44 additions & 23 deletions lib/countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
statusCode: "cly_hc_status_code",
errorMessage: "cly_hc_error_message"
});
var SDK_VERSION = "24.11.1";
var SDK_VERSION = "24.11.2";
var SDK_NAME = "javascript_native_web";

// 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)
Expand Down Expand Up @@ -899,6 +899,7 @@
var _contentEndPoint = /*#__PURE__*/new WeakMap();
var _inContentZone = /*#__PURE__*/new WeakMap();
var _contentZoneTimer = /*#__PURE__*/new WeakMap();
var _contentZoneTimerInterval = /*#__PURE__*/new WeakMap();
var _contentIframeID = /*#__PURE__*/new WeakMap();
var _initialize = /*#__PURE__*/new WeakMap();
var _updateConsent = /*#__PURE__*/new WeakMap();
Expand Down Expand Up @@ -1014,6 +1015,7 @@
_classPrivateFieldInitSpec(this, _contentEndPoint, void 0);
_classPrivateFieldInitSpec(this, _inContentZone, void 0);
_classPrivateFieldInitSpec(this, _contentZoneTimer, void 0);
_classPrivateFieldInitSpec(this, _contentZoneTimerInterval, void 0);
_classPrivateFieldInitSpec(this, _contentIframeID, void 0);
/**
* Initialize the Countly
Expand Down Expand Up @@ -1071,6 +1073,10 @@
_this.hcWarningCount = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.warningCount) || 0;
_this.hcStatusCode = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.statusCode) || -1;
_this.hcErrorMessage = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.errorMessage) || "";
_classPrivateFieldSet2(_contentZoneTimerInterval, _this, getConfig("content_zone_timer_interval", ob, null));
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
_classPrivateFieldSet2(_contentTimeInterval, _this, Math.max(_classPrivateFieldGet2(_contentZoneTimerInterval, _this), 15) * 1000);
}
if (_classPrivateFieldGet2(_maxCrashLogs, _this) && !_this.maxBreadcrumbCount) {
_this.maxBreadcrumbCount = _classPrivateFieldGet2(_maxCrashLogs, _this);
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.WARNING, "initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!");
Expand Down Expand Up @@ -1257,6 +1263,9 @@
if (_classPrivateFieldGet2(_remoteConfigs, _this)) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, stored remote configs:[" + JSON.stringify(_classPrivateFieldGet2(_remoteConfigs, _this)) + "]");
}
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, content_zone_timer_interval:[" + _classPrivateFieldGet2(_contentZoneTimerInterval, _this) + "]");
}
// functions, if provided, would be printed as true without revealing their content
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, 'getViewName' callback override provided:[" + (_this.getViewName !== Countly.getViewName) + "]");
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "initialize, 'getSearchQuery' callback override provided:[" + (_this.getSearchQuery !== Countly.getSearchQuery) + "]");
Expand Down Expand Up @@ -4327,15 +4336,17 @@
});
_classPrivateFieldInitSpec(this, _prepareContentRequest, function () {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "prepareContentRequest, forming content request");
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this);
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, 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;
var lWidthPHeight = Math.max(resInfo.width, resInfo.height);
var lHeightPWidth = Math.min(resInfo.width, resInfo.height);
resToSend.l.w = lWidthPHeight;
resToSend.l.h = lHeightPWidth;
resToSend.p.w = lHeightPWidth;
resToSend.p.h = lWidthPHeight;
var local = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage;
var language = local.split('-')[0];
var params = {
Expand Down Expand Up @@ -4374,10 +4385,15 @@
iframe.id = _classPrivateFieldGet2(_contentIframeID, _this);
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;
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, true);
if (resInfo.width >= resInfo.height) {
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);
Expand Down Expand Up @@ -4859,38 +4875,43 @@
});
/**
* 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}
*/
_classPrivateFieldInitSpec(this, _getResolution, function (getAvailable) {
_classPrivateFieldInitSpec(this, _getResolution, function (getViewPort) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "Getting the resolution of the device");
if (!isBrowser || !screen) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "No screen available");
return null;
}
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) {
var viewportWidth = window.innerWidth;
var viewportHeight = window.innerHeight;
var layoutWidth = document.documentElement.clientWidth;
var layoutHeight = document.documentElement.clientHeight;
var visibleWidth = Math.min(viewportWidth, layoutWidth);
var visibleHeight = Math.min(viewportHeight, layoutHeight);
width = visibleWidth ? parseInt(visibleWidth) : width;
height = visibleHeight ? parseInt(visibleHeight) : height;
}
if (width === 0 || height === 0) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "Screen width or height is non existent");
return null;
}
var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS && window.devicePixelRatio) {
_classPrivateFieldGet2(_log, _this).call(_this, 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) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "Screen is in landscape mode, adjusting resolution");
var temp = width;
width = height;
height = temp;
}
return {
width: width,
Expand Down
Loading

0 comments on commit a81d981

Please sign in to comment.