|
66 | 66 | function _classPrivateFieldSet2(s, a, r) { |
67 | 67 | return s.set(_assertClassBrand(s, a), r), r; |
68 | 68 | } |
| 69 | + function _defineProperties(e, r) { |
| 70 | + for (var t = 0; t < r.length; t++) { |
| 71 | + var o = r[t]; |
| 72 | + o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); |
| 73 | + } |
| 74 | + } |
69 | 75 | function _createClass(e, r, t) { |
70 | | - return Object.defineProperty(e, "prototype", { |
| 76 | + return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { |
71 | 77 | writable: !1 |
72 | 78 | }), e; |
73 | 79 | } |
|
211 | 217 | backoffCount: "cly_hc_backoff_count", |
212 | 218 | consecutiveBackoffCount: "cly_hc_consecutive_backoff_count" |
213 | 219 | }); |
214 | | - var SDK_VERSION = "25.4.2"; |
| 220 | + var SDK_VERSION = "25.4.3"; |
215 | 221 | var SDK_NAME = "javascript_native_web"; |
216 | 222 |
|
217 | 223 | // 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) |
|
938 | 944 | var _lastRequestWasBackoff = /*#__PURE__*/new WeakMap(); |
939 | 945 | var _testModeTime = /*#__PURE__*/new WeakMap(); |
940 | 946 | var _requestTimeoutDuration = /*#__PURE__*/new WeakMap(); |
| 947 | + var _contentFilterCallback = /*#__PURE__*/new WeakMap(); |
941 | 948 | var _getAndSetServerConfig = /*#__PURE__*/new WeakMap(); |
942 | 949 | var _populateServerConfig = /*#__PURE__*/new WeakMap(); |
943 | 950 | var _initialize = /*#__PURE__*/new WeakMap(); |
|
1093 | 1100 | _classPrivateFieldInitSpec(this, _lastRequestWasBackoff, void 0); |
1094 | 1101 | _classPrivateFieldInitSpec(this, _testModeTime, void 0); |
1095 | 1102 | _classPrivateFieldInitSpec(this, _requestTimeoutDuration, void 0); |
| 1103 | + _classPrivateFieldInitSpec(this, _contentFilterCallback, void 0); |
1096 | 1104 | _classPrivateFieldInitSpec(this, _getAndSetServerConfig, function () { |
1097 | 1105 | if (_this.device_id === "[CLY]_temp_id") { |
1098 | 1106 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.INFO, "server_config, Device ID is temporary, not fetching server config"); |
|
4602 | 4610 | } |
4603 | 4611 | }); |
4604 | 4612 | _defineProperty(this, "content", { |
4605 | | - enterContentZone: function enterContentZone() { |
4606 | | - _classPrivateFieldGet2(_enterContentZoneInternal, _this).call(_this); |
| 4613 | + enterContentZone: function enterContentZone(filter_callback) { |
| 4614 | + _classPrivateFieldGet2(_enterContentZoneInternal, _this).call(_this, undefined, filter_callback); |
4607 | 4615 | }, |
4608 | 4616 | refreshContentZone: function refreshContentZone() { |
4609 | 4617 | _classPrivateFieldGet2(_refreshContentZoneInternal, _this).call(_this); |
|
4612 | 4620 | _classPrivateFieldGet2(_exitContentZoneInternal, _this).call(_this); |
4613 | 4621 | } |
4614 | 4622 | }); |
4615 | | - _classPrivateFieldInitSpec(this, _enterContentZoneInternal, function (forced) { |
| 4623 | + _classPrivateFieldInitSpec(this, _enterContentZoneInternal, function (forced, filter_callback) { |
4616 | 4624 | if (!isBrowser) { |
4617 | 4625 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.WARNING, "content.enterContentZone, window object is not available. Not entering content zone."); |
4618 | 4626 | return; |
|
4621 | 4629 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "content.enterContentZone, Already in content zone"); |
4622 | 4630 | return; |
4623 | 4631 | } |
| 4632 | + if (filter_callback && typeof filter_callback == "function") { |
| 4633 | + _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "content.enterContentZone, Content filter callback is provided"); |
| 4634 | + _classPrivateFieldSet2(_contentFilterCallback, _this, filter_callback); |
| 4635 | + } |
4624 | 4636 | if (!_classPrivateFieldGet2(_initTimestamp, _this) || getMsTimestamp() - _classPrivateFieldGet2(_initTimestamp, _this) < 4000) { |
4625 | 4637 | // settimeout |
4626 | 4638 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "content.enterContentZone, Not enough time passed since initialization"); |
|
4711 | 4723 | _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "sendContentRequest, no html content or orientation to display"); |
4712 | 4724 | return; |
4713 | 4725 | } |
| 4726 | + |
| 4727 | + // Build query params |
| 4728 | + var queryParams = {}; |
| 4729 | + var qIndex = response.html.indexOf("?"); |
| 4730 | + if (qIndex !== -1) { |
| 4731 | + var search = response.html.slice(qIndex + 1); |
| 4732 | + new URLSearchParams(search).forEach(function (v, k) { |
| 4733 | + queryParams[k] = v; |
| 4734 | + }); |
| 4735 | + } |
| 4736 | + |
| 4737 | + // Filter check |
| 4738 | + if (_classPrivateFieldGet2(_contentFilterCallback, _this) && _classPrivateFieldGet2(_contentFilterCallback, _this).call(_this, queryParams) === false) { |
| 4739 | + _classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.VERBOSE, "sendContentRequest, Content was filtered out by the content filter"); |
| 4740 | + return; |
| 4741 | + } |
4714 | 4742 | _classPrivateFieldGet2(_displayContent, _this).call(_this, response); |
4715 | 4743 | clearInterval(_classPrivateFieldGet2(_contentZoneTimer, _this)); // prevent multiple content requests while one is on |
4716 | 4744 | window.addEventListener('message', function (event) { |
|
6487 | 6515 | _classPrivateFieldSet2(_SCBackoffRequestAge, this, 24); // 24 hours |
6488 | 6516 | _classPrivateFieldSet2(_SCBackoffDuration, this, 60); // 60 seconds |
6489 | 6517 | _classPrivateFieldSet2(_requestTimeoutDuration, this, 30000); // 30 seconds |
| 6518 | + _classPrivateFieldSet2(_contentFilterCallback, this, null); |
6490 | 6519 | this.app_key = getConfig("app_key", _ob, null); |
6491 | 6520 | this.url = stripTrailingSlash(getConfig("url", _ob, "")); |
6492 | 6521 | this.serialize = getConfig("serialize", _ob, Countly.serialize); |
|
0 commit comments