|
209 | 209 | statusCode: "cly_hc_status_code",
|
210 | 210 | errorMessage: "cly_hc_error_message"
|
211 | 211 | });
|
212 |
| - var SDK_VERSION = "24.11.4"; |
| 212 | + var SDK_VERSION = "25.1.0"; |
213 | 213 | var SDK_NAME = "javascript_native_web";
|
214 | 214 |
|
215 | 215 | // 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 | 901 | var _contentZoneTimer = /*#__PURE__*/new WeakMap();
|
902 | 902 | var _contentZoneTimerInterval = /*#__PURE__*/new WeakMap();
|
903 | 903 | var _contentIframeID = /*#__PURE__*/new WeakMap();
|
| 904 | + var _crashFilterCallback = /*#__PURE__*/new WeakMap(); |
904 | 905 | var _initialize = /*#__PURE__*/new WeakMap();
|
905 | 906 | var _updateConsent = /*#__PURE__*/new WeakMap();
|
906 | 907 | var _add_cly_events = /*#__PURE__*/new WeakMap();
|
|
1017 | 1018 | _classPrivateFieldInitSpec(this, _contentZoneTimer, void 0);
|
1018 | 1019 | _classPrivateFieldInitSpec(this, _contentZoneTimerInterval, void 0);
|
1019 | 1020 | _classPrivateFieldInitSpec(this, _contentIframeID, void 0);
|
| 1021 | + _classPrivateFieldInitSpec(this, _crashFilterCallback, void 0); |
1020 | 1022 | /**
|
1021 | 1023 | * Initialize the Countly
|
1022 | 1024 | * @param {Object} ob - config object
|
|
1074 | 1076 | _this.hcStatusCode = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.statusCode) || -1;
|
1075 | 1077 | _this.hcErrorMessage = _classPrivateFieldGet2(_getValueFromStorage, _this).call(_this, healthCheckCounterEnum.errorMessage) || "";
|
1076 | 1078 | _classPrivateFieldSet2(_contentZoneTimerInterval, _this, getConfig("content_zone_timer_interval", ob, null));
|
| 1079 | + _classPrivateFieldSet2(_crashFilterCallback, _this, getConfig("crash_filter_callback", ob, null)); |
1077 | 1080 | if (_classPrivateFieldGet2(_contentZoneTimerInterval, _this)) {
|
1078 | 1081 | _classPrivateFieldSet2(_contentTimeInterval, _this, Math.max(_classPrivateFieldGet2(_contentZoneTimerInterval, _this), 15) * 1000);
|
1079 | 1082 | }
|
|
1831 | 1834 | if (_this.enableOrientationTracking) {
|
1832 | 1835 | // report orientation
|
1833 | 1836 | _classPrivateFieldGet2(_report_orientation, _this).call(_this);
|
| 1837 | + var orientationTimeout; |
1834 | 1838 | 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); |
1836 | 1843 | });
|
1837 | 1844 | }
|
1838 | 1845 | _classPrivateFieldSet2(_lastBeat, _this, getTimestamp());
|
|
4298 | 4305 |
|
4299 | 4306 | // send userAgent string with the crash object incase it gets removed by a gateway
|
4300 | 4307 | var req = {};
|
4301 |
| - req.crash = JSON.stringify(obj); |
4302 | 4308 | req.metrics = JSON.stringify({
|
4303 | 4309 | _ua: metrics._ua
|
4304 | 4310 | });
|
| 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); |
4305 | 4323 | _classPrivateFieldGet2(_toRequestQueue, _this).call(_this, req);
|
4306 | 4324 | }
|
4307 | 4325 | });
|
|
4429 | 4447 | try {
|
4430 | 4448 | var iframe = document.createElement("iframe");
|
4431 | 4449 | iframe.id = _classPrivateFieldGet2(_contentIframeID, _this);
|
| 4450 | + // always https in the future |
| 4451 | + // response.html = response.html.replace(/http:\/\//g, "https://"); |
4432 | 4452 | iframe.src = response.html;
|
4433 | 4453 | iframe.style.position = "absolute";
|
4434 | 4454 | var dimensionToUse = response.geo.p;
|
|
4490 | 4510 | if (resize_me) {
|
4491 | 4511 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "interpretContentMessage, Resizing iframe");
|
4492 | 4512 | 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) { |
4494 | 4514 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "interpretContentMessage, Invalid resize object");
|
4495 | 4515 | return;
|
4496 | 4516 | }
|
|
5319 | 5339 | try {
|
5320 | 5340 | var parsedResponse = JSON.parse(str);
|
5321 | 5341 | // 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!") { |
5323 | 5343 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.ERROR, "Http response is not JSON Object nor JSON Array");
|
5324 | 5344 | return false;
|
5325 | 5345 | }
|
|
5489 | 5509 | if (useLocalStorage === undefined) {
|
5490 | 5510 | useLocalStorage = _classPrivateFieldGet2(_lsSupport, _this);
|
5491 | 5511 | }
|
| 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 | + } |
5492 | 5521 |
|
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) { } |
5507 | 5528 | });
|
5508 | 5529 | /**
|
5509 | 5530 | * Storage function that acts as setter, can be used for setting data into local storage or as cookies
|
|
5527 | 5548 | key = stripTrailingSlash(_this.namespace) + "/" + key;
|
5528 | 5549 | }
|
5529 | 5550 | }
|
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 | + } |
5536 | 5558 |
|
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 | + } |
5549 | 5572 | }
|
| 5573 | + } catch (error) { |
| 5574 | + // silent fail |
5550 | 5575 | }
|
5551 | 5576 | });
|
5552 | 5577 | /**
|
|
5570 | 5595 | key = stripTrailingSlash(_this.namespace) + "/" + key;
|
5571 | 5596 | }
|
5572 | 5597 | }
|
| 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 | + } |
5573 | 5604 |
|
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 |
5590 | 5618 | }
|
5591 | 5619 | });
|
5592 | 5620 | /**
|
|
5871 | 5899 | _classPrivateFieldSet2(_inContentZone, this, false);
|
5872 | 5900 | _classPrivateFieldSet2(_contentZoneTimer, this, null);
|
5873 | 5901 | _classPrivateFieldSet2(_contentIframeID, this, "cly-content-iframe");
|
| 5902 | + _classPrivateFieldSet2(_crashFilterCallback, this, null); |
5874 | 5903 | try {
|
5875 | 5904 | localStorage.setItem("cly_testLocal", true);
|
5876 | 5905 | // clean up test
|
|
5972 | 6001 | * @return {string} serialized value
|
5973 | 6002 | * */
|
5974 | 6003 | 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 |
5978 | 6011 | }
|
5979 | 6012 | return value;
|
5980 | 6013 | };
|
|
5993 | 6026 | try {
|
5994 | 6027 | data = JSON.parse(data);
|
5995 | 6028 | } 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 |
6000 | 6030 | }
|
6001 | 6031 | return data;
|
6002 | 6032 | };
|
|
0 commit comments