Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging 25.1.0 #553

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 25.1.0

- Improved orientation reporting precision.
- Reduced log verbosity.
- Added a new init time config option `crash_filter_callback` for filtering crashes.

- Mitigated an issue where content resizing did not work in certain orientations.

## 24.11.4

- Mitigated an issue where `content` and `feedback` interface methods would not have worked if async methods were used when multi instancing the SDK.
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.4";
const SDK_VERSION = "25.1.0";

// tests
describe("Bridged SDK Utilities Tests", () => {
Expand Down
150 changes: 90 additions & 60 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.4";
var SDK_VERSION = "25.1.0";
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 @@ -901,6 +901,7 @@
var _contentZoneTimer = /*#__PURE__*/new WeakMap();
var _contentZoneTimerInterval = /*#__PURE__*/new WeakMap();
var _contentIframeID = /*#__PURE__*/new WeakMap();
var _crashFilterCallback = /*#__PURE__*/new WeakMap();
var _initialize = /*#__PURE__*/new WeakMap();
var _updateConsent = /*#__PURE__*/new WeakMap();
var _add_cly_events = /*#__PURE__*/new WeakMap();
Expand Down Expand Up @@ -1017,6 +1018,7 @@
_classPrivateFieldInitSpec(this, _contentZoneTimer, void 0);
_classPrivateFieldInitSpec(this, _contentZoneTimerInterval, void 0);
_classPrivateFieldInitSpec(this, _contentIframeID, void 0);
_classPrivateFieldInitSpec(this, _crashFilterCallback, void 0);
/**
* Initialize the Countly
* @param {Object} ob - config object
Expand Down Expand Up @@ -1074,6 +1076,7 @@
_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));
_classPrivateFieldSet2(_crashFilterCallback, _this, getConfig("crash_filter_callback", ob, null));
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
_classPrivateFieldSet2(_contentTimeInterval, _this, Math.max(_classPrivateFieldGet2(_contentZoneTimerInterval, _this), 15) * 1000);
}
Expand Down Expand Up @@ -1831,8 +1834,12 @@
if (_this.enableOrientationTracking) {
// report orientation
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
var orientationTimeout;
add_event_listener(window, "resize", function () {
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
clearTimeout(orientationTimeout);
orientationTimeout = setTimeout(function () {
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
}, 200);
});
}
_classPrivateFieldSet2(_lastBeat, _this, getTimestamp());
Expand Down Expand Up @@ -4298,10 +4305,21 @@

// send userAgent string with the crash object incase it gets removed by a gateway
var req = {};
req.crash = JSON.stringify(obj);
req.metrics = JSON.stringify({
_ua: metrics._ua
});
if (_classPrivateFieldGet2(_crashFilterCallback, _this) && typeof _classPrivateFieldGet2(_crashFilterCallback, _this) === "function") {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "recordError, Applying crash filter to:[" + JSON.stringify(obj) + "]");
obj = _classPrivateFieldGet2(_crashFilterCallback, _this).call(_this, obj);
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "recordError, Filtered crash object:[" + JSON.stringify(obj) + "]");
}
if (!obj) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "recordError, Crash object was filtered out");
return;
}

// error should be re-truncated incase it was modified by the filter
req.crash = JSON.stringify(obj);
_classPrivateFieldGet2(_toRequestQueue, _this).call(_this, req);
}
});
Expand Down Expand Up @@ -4429,6 +4447,8 @@
try {
var iframe = document.createElement("iframe");
iframe.id = _classPrivateFieldGet2(_contentIframeID, _this);
// always https in the future
// response.html = response.html.replace(/http:\/\//g, "https://");
iframe.src = response.html;
iframe.style.position = "absolute";
var dimensionToUse = response.geo.p;
Expand Down Expand Up @@ -4490,7 +4510,7 @@
if (resize_me) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "interpretContentMessage, Resizing iframe");
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, true);
if (!resize_me.l || !resize_me.p || !resize_me.l.x || !resize_me.l.y || !resize_me.l.w || !resize_me.l.h || !resize_me.p.x || !resize_me.p.y || !resize_me.p.w || !resize_me.p.h) {
if (!resize_me.l || !resize_me.p) {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "interpretContentMessage, Invalid resize object");
return;
}
Expand Down Expand Up @@ -5319,7 +5339,7 @@
try {
var parsedResponse = JSON.parse(str);
// check if parsed response is a JSON object or JSON array, if not it is not valid
if (Object.prototype.toString.call(parsedResponse) !== "[object Object]" && !Array.isArray(parsedResponse)) {
if (Object.prototype.toString.call(parsedResponse) !== "[object Object]" && !Array.isArray(parsedResponse) && parsedResponse !== "No content block found!") {
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "Http response is not JSON Object nor JSON Array");
return false;
}
Expand Down Expand Up @@ -5489,21 +5509,22 @@
if (useLocalStorage === undefined) {
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
}
try {
// Get value
if (useLocalStorage) {
// Native support
data = localStorage.getItem(key);
} else if (_this.storage !== "localstorage") {
// Use cookie
data = _classPrivateFieldGet2(_readCookie, _this).call(_this, key);
}

// Get value
if (useLocalStorage) {
// Native support
data = localStorage.getItem(key);
} else if (_this.storage !== "localstorage") {
// Use cookie
data = _classPrivateFieldGet2(_readCookie, _this).call(_this, key);
}

// we return early without parsing if we are trying to get the device ID. This way we are keeping it as a string incase it was numerical.
if (key.endsWith("cly_id")) {
return data;
}
return _this.deserialize(data);
// we return early without parsing if we are trying to get the device ID. This way we are keeping it as a string incase it was numerical.
if (key.endsWith("cly_id")) {
return data;
}
return _this.deserialize(data);
} catch (error) { }
});
/**
* Storage function that acts as setter, can be used for setting data into local storage or as cookies
Expand All @@ -5527,26 +5548,30 @@
key = stripTrailingSlash(_this.namespace) + "/" + key;
}
}
if (typeof value !== "undefined" && value !== null) {
// use dev provided storage if available
if (_typeof(_this.storage) === "object" && typeof _this.storage.setItem === "function") {
_this.storage.setItem(key, value);
return;
}
try {
if (typeof value !== "undefined" && value !== null) {
// use dev provided storage if available
if (_typeof(_this.storage) === "object" && typeof _this.storage.setItem === "function") {
_this.storage.setItem(key, value);
return;
}

// developer set values takes priority
if (useLocalStorage === undefined) {
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
}
value = _this.serialize(value);
// Set the store
if (useLocalStorage) {
// Native support
localStorage.setItem(key, value);
} else if (_this.storage !== "localstorage") {
// Use Cookie
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, value, 30);
// developer set values takes priority
if (useLocalStorage === undefined) {
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
}
value = _this.serialize(value);
// Set the store
if (useLocalStorage) {
// Native support
localStorage.setItem(key, value);
} else if (_this.storage !== "localstorage") {
// Use Cookie
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, value, 30);
}
}
} catch (error) {
// silent fail
}
});
/**
Expand All @@ -5570,23 +5595,26 @@
key = stripTrailingSlash(_this.namespace) + "/" + key;
}
}
try {
// use dev provided storage if available
if (_typeof(_this.storage) === "object" && typeof _this.storage.removeItem === "function") {
_this.storage.removeItem(key);
return;
}

// use dev provided storage if available
if (_typeof(_this.storage) === "object" && typeof _this.storage.removeItem === "function") {
_this.storage.removeItem(key);
return;
}

// developer set values takes priority
if (useLocalStorage === undefined) {
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
}
if (useLocalStorage) {
// Native support
localStorage.removeItem(key);
} else if (_this.storage !== "localstorage") {
// Use cookie
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, "", -1);
// developer set values takes priority
if (useLocalStorage === undefined) {
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
}
if (useLocalStorage) {
// Native support
localStorage.removeItem(key);
} else if (_this.storage !== "localstorage") {
// Use cookie
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, "", -1);
}
} catch (error) {
// silent fail
}
});
/**
Expand Down Expand Up @@ -5871,6 +5899,7 @@
_classPrivateFieldSet2(_inContentZone, this, false);
_classPrivateFieldSet2(_contentZoneTimer, this, null);
_classPrivateFieldSet2(_contentIframeID, this, "cly-content-iframe");
_classPrivateFieldSet2(_crashFilterCallback, this, null);
try {
localStorage.setItem("cly_testLocal", true);
// clean up test
Expand Down Expand Up @@ -5972,9 +6001,13 @@
* @return {string} serialized value
* */
Countly.serialize = function (value) {
// Convert object values to JSON
if (_typeof(value) === "object") {
value = JSON.stringify(value);
try {
// Convert object values to JSON
if (_typeof(value) === "object") {
value = JSON.stringify(value);
}
} catch (error) {
// silent fail
}
return value;
};
Expand All @@ -5993,10 +6026,7 @@
try {
data = JSON.parse(data);
} catch (e) {
if (checkIfLoggingIsOn()) {
// eslint-disable-next-line no-console
console.warn("[WARNING] [Countly] deserialize, Could not parse the file:[" + data + "], error: " + e);
}
// silent fail
}
return data;
};
Expand Down
Loading
Loading