Skip to content

Commit 44ca467

Browse files
committed
Major 25.1 changes
1 parent 809fcfe commit 44ca467

File tree

6 files changed

+243
-204
lines changed

6 files changed

+243
-204
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 25.1.0
2+
3+
- Improved orientation reporting precision.
4+
- Reduced log verbosity.
5+
- Added a new init time config option `crash_filter_callback` for filtering crashes.
6+
7+
- Mitigated an issue where content resizing did not work in certain orientations.
8+
19
## 24.11.4
210

311
- Mitigated an issue where `content` and `feedback` interface methods would not have worked if async methods were used when multi instancing the SDK.

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.4";
18+
const SDK_VERSION = "25.1.0";
1919

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

lib/countly.js

+90-60
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.4";
212+
var SDK_VERSION = "25.1.0";
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)
@@ -901,6 +901,7 @@
901901
var _contentZoneTimer = /*#__PURE__*/new WeakMap();
902902
var _contentZoneTimerInterval = /*#__PURE__*/new WeakMap();
903903
var _contentIframeID = /*#__PURE__*/new WeakMap();
904+
var _crashFilterCallback = /*#__PURE__*/new WeakMap();
904905
var _initialize = /*#__PURE__*/new WeakMap();
905906
var _updateConsent = /*#__PURE__*/new WeakMap();
906907
var _add_cly_events = /*#__PURE__*/new WeakMap();
@@ -1017,6 +1018,7 @@
10171018
_classPrivateFieldInitSpec(this, _contentZoneTimer, void 0);
10181019
_classPrivateFieldInitSpec(this, _contentZoneTimerInterval, void 0);
10191020
_classPrivateFieldInitSpec(this, _contentIframeID, void 0);
1021+
_classPrivateFieldInitSpec(this, _crashFilterCallback, void 0);
10201022
/**
10211023
* Initialize the Countly
10221024
* @param {Object} ob - config object
@@ -1074,6 +1076,7 @@
10741076
_this.hcStatusCode = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.statusCode) || -1;
10751077
_this.hcErrorMessage = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.errorMessage) || "";
10761078
_classPrivateFieldSet2(_contentZoneTimerInterval, _this, getConfig("content_zone_timer_interval", ob, null));
1079+
_classPrivateFieldSet2(_crashFilterCallback, _this, getConfig("crash_filter_callback", ob, null));
10771080
if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
10781081
_classPrivateFieldSet2(_contentTimeInterval, _this, Math.max(_classPrivateFieldGet2(_contentZoneTimerInterval, _this), 15) * 1000);
10791082
}
@@ -1831,8 +1834,12 @@
18311834
if (_this.enableOrientationTracking) {
18321835
// report orientation
18331836
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
1837+
var orientationTimeout;
18341838
add_event_listener(window, "resize", function () {
1835-
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
1839+
clearTimeout(orientationTimeout);
1840+
orientationTimeout = setTimeout(function () {
1841+
_classPrivateFieldGet2(_report_orientation, _this).call(_this);
1842+
}, 200);
18361843
});
18371844
}
18381845
_classPrivateFieldSet2(_lastBeat, _this, getTimestamp());
@@ -4298,10 +4305,21 @@
42984305

42994306
// send userAgent string with the crash object incase it gets removed by a gateway
43004307
var req = {};
4301-
req.crash = JSON.stringify(obj);
43024308
req.metrics = JSON.stringify({
43034309
_ua: metrics._ua
43044310
});
4311+
if (_classPrivateFieldGet2(_crashFilterCallback, _this) && typeof _classPrivateFieldGet2(_crashFilterCallback, _this) === "function") {
4312+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "recordError, Applying crash filter to:[" + JSON.stringify(obj) + "]");
4313+
obj = _classPrivateFieldGet2(_crashFilterCallback, _this).call(_this, obj);
4314+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "recordError, Filtered crash object:[" + JSON.stringify(obj) + "]");
4315+
}
4316+
if (!obj) {
4317+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "recordError, Crash object was filtered out");
4318+
return;
4319+
}
4320+
4321+
// error should be re-truncated incase it was modified by the filter
4322+
req.crash = JSON.stringify(obj);
43054323
_classPrivateFieldGet2(_toRequestQueue, _this).call(_this, req);
43064324
}
43074325
});
@@ -4429,6 +4447,8 @@
44294447
try {
44304448
var iframe = document.createElement("iframe");
44314449
iframe.id = _classPrivateFieldGet2(_contentIframeID, _this);
4450+
// always https in the future
4451+
// response.html = response.html.replace(/http:\/\//g, "https://");
44324452
iframe.src = response.html;
44334453
iframe.style.position = "absolute";
44344454
var dimensionToUse = response.geo.p;
@@ -4490,7 +4510,7 @@
44904510
if (resize_me) {
44914511
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "interpretContentMessage, Resizing iframe");
44924512
var resInfo = _classPrivateFieldGet2(_getResolution, _this).call(_this, true);
4493-
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) {
4513+
if (!resize_me.l || !resize_me.p) {
44944514
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "interpretContentMessage, Invalid resize object");
44954515
return;
44964516
}
@@ -5319,7 +5339,7 @@
53195339
try {
53205340
var parsedResponse = JSON.parse(str);
53215341
// check if parsed response is a JSON object or JSON array, if not it is not valid
5322-
if (Object.prototype.toString.call(parsedResponse) !== "[object Object]" && !Array.isArray(parsedResponse)) {
5342+
if (Object.prototype.toString.call(parsedResponse) !== "[object Object]" && !Array.isArray(parsedResponse) && parsedResponse !== "No content block found!") {
53235343
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "Http response is not JSON Object nor JSON Array");
53245344
return false;
53255345
}
@@ -5489,21 +5509,22 @@
54895509
if (useLocalStorage === undefined) {
54905510
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
54915511
}
5512+
try {
5513+
// Get value
5514+
if (useLocalStorage) {
5515+
// Native support
5516+
data = localStorage.getItem(key);
5517+
} else if (_this.storage !== "localstorage") {
5518+
// Use cookie
5519+
data = _classPrivateFieldGet2(_readCookie, _this).call(_this, key);
5520+
}
54925521

5493-
// Get value
5494-
if (useLocalStorage) {
5495-
// Native support
5496-
data = localStorage.getItem(key);
5497-
} else if (_this.storage !== "localstorage") {
5498-
// Use cookie
5499-
data = _classPrivateFieldGet2(_readCookie, _this).call(_this, key);
5500-
}
5501-
5502-
// 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.
5503-
if (key.endsWith("cly_id")) {
5504-
return data;
5505-
}
5506-
return _this.deserialize(data);
5522+
// 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.
5523+
if (key.endsWith("cly_id")) {
5524+
return data;
5525+
}
5526+
return _this.deserialize(data);
5527+
} catch (error) { }
55075528
});
55085529
/**
55095530
* Storage function that acts as setter, can be used for setting data into local storage or as cookies
@@ -5527,26 +5548,30 @@
55275548
key = stripTrailingSlash(_this.namespace) + "/" + key;
55285549
}
55295550
}
5530-
if (typeof value !== "undefined" && value !== null) {
5531-
// use dev provided storage if available
5532-
if (_typeof(_this.storage) === "object" && typeof _this.storage.setItem === "function") {
5533-
_this.storage.setItem(key, value);
5534-
return;
5535-
}
5551+
try {
5552+
if (typeof value !== "undefined" && value !== null) {
5553+
// use dev provided storage if available
5554+
if (_typeof(_this.storage) === "object" && typeof _this.storage.setItem === "function") {
5555+
_this.storage.setItem(key, value);
5556+
return;
5557+
}
55365558

5537-
// developer set values takes priority
5538-
if (useLocalStorage === undefined) {
5539-
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
5540-
}
5541-
value = _this.serialize(value);
5542-
// Set the store
5543-
if (useLocalStorage) {
5544-
// Native support
5545-
localStorage.setItem(key, value);
5546-
} else if (_this.storage !== "localstorage") {
5547-
// Use Cookie
5548-
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, value, 30);
5559+
// developer set values takes priority
5560+
if (useLocalStorage === undefined) {
5561+
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
5562+
}
5563+
value = _this.serialize(value);
5564+
// Set the store
5565+
if (useLocalStorage) {
5566+
// Native support
5567+
localStorage.setItem(key, value);
5568+
} else if (_this.storage !== "localstorage") {
5569+
// Use Cookie
5570+
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, value, 30);
5571+
}
55495572
}
5573+
} catch (error) {
5574+
// silent fail
55505575
}
55515576
});
55525577
/**
@@ -5570,23 +5595,26 @@
55705595
key = stripTrailingSlash(_this.namespace) + "/" + key;
55715596
}
55725597
}
5598+
try {
5599+
// use dev provided storage if available
5600+
if (_typeof(_this.storage) === "object" && typeof _this.storage.removeItem === "function") {
5601+
_this.storage.removeItem(key);
5602+
return;
5603+
}
55735604

5574-
// use dev provided storage if available
5575-
if (_typeof(_this.storage) === "object" && typeof _this.storage.removeItem === "function") {
5576-
_this.storage.removeItem(key);
5577-
return;
5578-
}
5579-
5580-
// developer set values takes priority
5581-
if (useLocalStorage === undefined) {
5582-
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
5583-
}
5584-
if (useLocalStorage) {
5585-
// Native support
5586-
localStorage.removeItem(key);
5587-
} else if (_this.storage !== "localstorage") {
5588-
// Use cookie
5589-
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, "", -1);
5605+
// developer set values takes priority
5606+
if (useLocalStorage === undefined) {
5607+
useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
5608+
}
5609+
if (useLocalStorage) {
5610+
// Native support
5611+
localStorage.removeItem(key);
5612+
} else if (_this.storage !== "localstorage") {
5613+
// Use cookie
5614+
_classPrivateFieldGet2(_createCookie, _this).call(_this, key, "", -1);
5615+
}
5616+
} catch (error) {
5617+
// silent fail
55905618
}
55915619
});
55925620
/**
@@ -5871,6 +5899,7 @@
58715899
_classPrivateFieldSet2(_inContentZone, this, false);
58725900
_classPrivateFieldSet2(_contentZoneTimer, this, null);
58735901
_classPrivateFieldSet2(_contentIframeID, this, "cly-content-iframe");
5902+
_classPrivateFieldSet2(_crashFilterCallback, this, null);
58745903
try {
58755904
localStorage.setItem("cly_testLocal", true);
58765905
// clean up test
@@ -5972,9 +6001,13 @@
59726001
* @return {string} serialized value
59736002
* */
59746003
Countly.serialize = function (value) {
5975-
// Convert object values to JSON
5976-
if (_typeof(value) === "object") {
5977-
value = JSON.stringify(value);
6004+
try {
6005+
// Convert object values to JSON
6006+
if (_typeof(value) === "object") {
6007+
value = JSON.stringify(value);
6008+
}
6009+
} catch (error) {
6010+
// silent fail
59786011
}
59796012
return value;
59806013
};
@@ -5993,10 +6026,7 @@
59936026
try {
59946027
data = JSON.parse(data);
59956028
} catch (e) {
5996-
if (checkIfLoggingIsOn()) {
5997-
// eslint-disable-next-line no-console
5998-
console.warn("[WARNING] [Countly] deserialize, Could not parse the file:[" + data + "], error: " + e);
5999-
}
6029+
// silent fail
60006030
}
60016031
return data;
60026032
};

0 commit comments

Comments
 (0)