countly-sdk-web 23.12.6 → 24.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/cypress/integration/bridge_utils.js +1 -1
- package/cypress/integration/health_check.js +1 -1
- package/cypress/integration/salt.js +87 -0
- package/cypress/support/helper.js +43 -1
- package/examples/create_examples.py +1 -1
- package/examples/style/style.css +0 -1
- package/lib/countly.js +130 -89
- package/lib/countly.min.js +134 -134
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 24.4.0
|
|
2
|
+
! Minor breaking change ! For implementations using `salt` the browser compatability is tied to SubtleCrypto's `digest` method support
|
|
3
|
+
|
|
4
|
+
- Added the `salt` init config flag to add checksums to requests (for secure contexts only)
|
|
5
|
+
- Improved Health Check feature stability
|
|
6
|
+
- Added support for Feedback Widget terms and conditions
|
|
7
|
+
|
|
1
8
|
## 23.12.6
|
|
2
9
|
- Mitigated an issue where error tracking could prevent SDK initialization in async mode
|
|
3
10
|
|
|
@@ -21,7 +21,7 @@ describe("Health Check tests ", () => {
|
|
|
21
21
|
// Test the 'hc' parameter
|
|
22
22
|
const hcParam = url.searchParams.get("hc");
|
|
23
23
|
const hcParamObj = JSON.parse(hcParam);
|
|
24
|
-
expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "
|
|
24
|
+
expect(hcParamObj).to.eql({ el: 0, wl: 0, sc: -1, em: "" });
|
|
25
25
|
|
|
26
26
|
// Test the 'metrics' parameter
|
|
27
27
|
const metricsParam = url.searchParams.get("metrics");
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
2
|
+
/* eslint-disable require-jsdoc */
|
|
3
|
+
var Countly = require("../../lib/countly");
|
|
4
|
+
// import * as Countly from "../../dist/countly_umd.js";
|
|
5
|
+
var hp = require("../support/helper.js");
|
|
6
|
+
const crypto = require("crypto");
|
|
7
|
+
|
|
8
|
+
function initMain(salt) {
|
|
9
|
+
Countly.init({
|
|
10
|
+
app_key: "YOUR_APP_KEY",
|
|
11
|
+
url: "https://your.domain.count.ly",
|
|
12
|
+
debug: true,
|
|
13
|
+
salt: salt
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const salt = "salt";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Tests for salt consists of:
|
|
20
|
+
* 1. Init without salt
|
|
21
|
+
* Create events and intercept the SDK requests. Request params should be normal and there should be no checksum
|
|
22
|
+
* 2. Init with salt
|
|
23
|
+
* Create events and intercept the SDK requests. Request params should be normal and there should be a checksum with length 64
|
|
24
|
+
* 3. Node and Web Crypto comparison
|
|
25
|
+
* Compare the checksums calculated by node crypto api and SDK's web crypto api for the same data. Should be equal
|
|
26
|
+
*/
|
|
27
|
+
describe("Salt Tests", () => {
|
|
28
|
+
it("Init without salt", () => {
|
|
29
|
+
hp.haltAndClearStorage(() => {
|
|
30
|
+
initMain(null);
|
|
31
|
+
var rqArray = [];
|
|
32
|
+
hp.events();
|
|
33
|
+
cy.intercept("GET", "**/i?**", (req) => {
|
|
34
|
+
const { url } = req;
|
|
35
|
+
rqArray.push(url.split("?")[1]); // get the query string
|
|
36
|
+
});
|
|
37
|
+
cy.wait(1000).then(() => {
|
|
38
|
+
cy.log(rqArray).then(() => {
|
|
39
|
+
for (const rq of rqArray) {
|
|
40
|
+
const paramsObject = hp.turnSearchStringToObject(rq);
|
|
41
|
+
hp.check_commons(paramsObject);
|
|
42
|
+
expect(paramsObject.checksum256).to.be.not.ok;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it("Init with salt", () => {
|
|
49
|
+
hp.haltAndClearStorage(() => {
|
|
50
|
+
initMain(salt);
|
|
51
|
+
var rqArray = [];
|
|
52
|
+
hp.events();
|
|
53
|
+
cy.intercept("GET", "**/i?**", (req) => {
|
|
54
|
+
const { url } = req;
|
|
55
|
+
rqArray.push(url.split("?")[1]);
|
|
56
|
+
});
|
|
57
|
+
cy.wait(1000).then(() => {
|
|
58
|
+
cy.log(rqArray).then(() => {
|
|
59
|
+
for (const rq of rqArray) {
|
|
60
|
+
const paramsObject = hp.turnSearchStringToObject(rq);
|
|
61
|
+
hp.check_commons(paramsObject);
|
|
62
|
+
expect(paramsObject.checksum256).to.be.ok;
|
|
63
|
+
expect(paramsObject.checksum256.length).to.equal(64);
|
|
64
|
+
// TODO: directly check the checksum with the node crypto api. Will need some extra decoding logic
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
it("Node and Web Crypto comparison", () => {
|
|
71
|
+
const hash = sha256("text" + salt); // node crypto api
|
|
72
|
+
Countly._internals.calculateChecksum("text", salt).then((hash2) => { // SDK uses web crypto api
|
|
73
|
+
expect(hash2).to.equal(hash);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Calculate sha256 hash of given data
|
|
80
|
+
* @param {*} data - data to hash
|
|
81
|
+
* @returns {string} - sha256 hash
|
|
82
|
+
*/
|
|
83
|
+
function sha256(data) {
|
|
84
|
+
const hash = crypto.createHash("sha256");
|
|
85
|
+
hash.update(data);
|
|
86
|
+
return hash.digest("hex");
|
|
87
|
+
}
|
|
@@ -272,6 +272,46 @@ function validateDefaultUtmTags(aq, source, medium, campaign, term, content) {
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Check common params for all requests
|
|
277
|
+
* @param {Object} paramsObject - object from search string
|
|
278
|
+
*/
|
|
279
|
+
function check_commons(paramsObject) {
|
|
280
|
+
expect(paramsObject.timestamp).to.be.ok;
|
|
281
|
+
expect(paramsObject.timestamp.toString().length).to.equal(13);
|
|
282
|
+
expect(paramsObject.hour).to.be.within(0, 23);
|
|
283
|
+
expect(paramsObject.dow).to.be.within(0, 7);
|
|
284
|
+
expect(paramsObject.app_key).to.equal(appKey);
|
|
285
|
+
expect(paramsObject.device_id).to.be.ok;
|
|
286
|
+
expect(paramsObject.sdk_name).to.equal("javascript_native_web");
|
|
287
|
+
expect(paramsObject.sdk_version).to.be.ok;
|
|
288
|
+
expect(paramsObject.t).to.be.within(0, 3);
|
|
289
|
+
expect(paramsObject.av).to.equal(0); // av is 0 as we parsed parsable things
|
|
290
|
+
if (!paramsObject.hc) { // hc is direct request
|
|
291
|
+
expect(paramsObject.rr).to.be.above(-1);
|
|
292
|
+
}
|
|
293
|
+
expect(paramsObject.metrics._ua).to.be.ok;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Turn search string into object with values parsed
|
|
298
|
+
* @param {String} searchString - search string
|
|
299
|
+
* @returns {object} - object from search string
|
|
300
|
+
*/
|
|
301
|
+
function turnSearchStringToObject(searchString) {
|
|
302
|
+
const searchParams = new URLSearchParams(searchString);
|
|
303
|
+
const paramsObject = {};
|
|
304
|
+
for (const [key, value] of searchParams.entries()) {
|
|
305
|
+
try {
|
|
306
|
+
paramsObject[key] = JSON.parse(decodeURIComponent(value)); // try to parse value
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
paramsObject[key] = decodeURIComponent(value);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return paramsObject;
|
|
313
|
+
}
|
|
314
|
+
|
|
275
315
|
module.exports = {
|
|
276
316
|
haltAndClearStorage,
|
|
277
317
|
sWait,
|
|
@@ -285,5 +325,7 @@ module.exports = {
|
|
|
285
325
|
testNormalFlow,
|
|
286
326
|
interceptAndCheckRequests,
|
|
287
327
|
validateDefaultUtmTags,
|
|
288
|
-
userDetailObj
|
|
328
|
+
userDetailObj,
|
|
329
|
+
check_commons,
|
|
330
|
+
turnSearchStringToObject
|
|
289
331
|
};
|
|
@@ -23,7 +23,7 @@ def setup_react_example():
|
|
|
23
23
|
|
|
24
24
|
def setup_angular_example():
|
|
25
25
|
print("Creating Angular example...")
|
|
26
|
-
os.system("npx @angular/cli new angular-example --defaults")
|
|
26
|
+
os.system("npx @angular/cli@next new angular-example --defaults")
|
|
27
27
|
|
|
28
28
|
# Copy contents of Angular folder over to Angular example
|
|
29
29
|
shutil.copytree("Angular", "angular-example/src", dirs_exist_ok=True)
|
package/examples/style/style.css
CHANGED
package/lib/countly.js
CHANGED
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
statusCode: "cly_hc_status_code",
|
|
197
197
|
errorMessage: "cly_hc_error_message"
|
|
198
198
|
});
|
|
199
|
-
var SDK_VERSION = "
|
|
199
|
+
var SDK_VERSION = "24.4.0";
|
|
200
200
|
var SDK_NAME = "javascript_native_web";
|
|
201
201
|
|
|
202
202
|
// 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)
|
|
@@ -349,14 +349,22 @@
|
|
|
349
349
|
* Convert JSON object to URL encoded query parameter string
|
|
350
350
|
* @memberof Countly._internals
|
|
351
351
|
* @param {Object} params - object with query parameters
|
|
352
|
+
* @param {String} salt - salt to be used for checksum calculation
|
|
352
353
|
* @returns {String} URL encode query string
|
|
353
354
|
*/
|
|
354
|
-
function prepareParams(params) {
|
|
355
|
+
function prepareParams(params, salt) {
|
|
355
356
|
var str = [];
|
|
356
357
|
for (var i in params) {
|
|
357
358
|
str.push(i + "=" + encodeURIComponent(params[i]));
|
|
358
359
|
}
|
|
359
|
-
|
|
360
|
+
var data = str.join("&");
|
|
361
|
+
if (salt) {
|
|
362
|
+
return calculateChecksum(data, salt).then(function (checksum) {
|
|
363
|
+
data += "&checksum256=" + checksum;
|
|
364
|
+
return data;
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
return Promise.resolve(data);
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
/**
|
|
@@ -470,6 +478,27 @@
|
|
|
470
478
|
return newStr;
|
|
471
479
|
}
|
|
472
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Calculates the checksum of the data with the given salt
|
|
483
|
+
* Uses SHA-256 algorithm with web crypto API
|
|
484
|
+
* Implementation based on https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
|
485
|
+
* TODO: Turn to async function when we drop support for older browsers
|
|
486
|
+
* @param {string} data - data to be used for checksum calculation (concatenated query parameters)
|
|
487
|
+
* @param {string} salt - salt to be used for checksum calculation
|
|
488
|
+
* @returns {string} checksum in hex format
|
|
489
|
+
*/
|
|
490
|
+
function calculateChecksum(data, salt) {
|
|
491
|
+
var msgUint8 = new TextEncoder().encode(data + salt); // encode as (utf-8) Uint8Array
|
|
492
|
+
return crypto.subtle.digest("SHA-256", msgUint8).then(function (hashBuffer) {
|
|
493
|
+
// hash the message
|
|
494
|
+
var hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
|
|
495
|
+
var hashHex = hashArray.map(function (b) {
|
|
496
|
+
return b.toString(16).padStart(2, "0");
|
|
497
|
+
}).join(""); // convert bytes to hex string
|
|
498
|
+
return hashHex;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
473
502
|
/**
|
|
474
503
|
* Polyfill to get closest parent matching nodeName
|
|
475
504
|
* @param {HTMLElement} el - element from which to search
|
|
@@ -914,6 +943,7 @@
|
|
|
914
943
|
this.maxStackTraceLinesPerThread = getConfig("max_stack_trace_lines_per_thread", ob, configurationDefaultValues.MAX_STACKTRACE_LINES_PER_THREAD);
|
|
915
944
|
this.maxStackTraceLineLength = getConfig("max_stack_trace_line_length", ob, configurationDefaultValues.MAX_STACKTRACE_LINE_LENGTH);
|
|
916
945
|
this.heatmapWhitelist = getConfig("heatmap_whitelist", ob, []);
|
|
946
|
+
self.salt = getConfig("salt", ob, null);
|
|
917
947
|
self.hcErrorCount = getValueFromStorage(healthCheckCounterEnum.errorCount) || 0;
|
|
918
948
|
self.hcWarningCount = getValueFromStorage(healthCheckCounterEnum.warningCount) || 0;
|
|
919
949
|
self.hcStatusCode = getValueFromStorage(healthCheckCounterEnum.statusCode) || -1;
|
|
@@ -1037,6 +1067,7 @@
|
|
|
1037
1067
|
if (ignoreReferrers) {
|
|
1038
1068
|
log(logLevelEnums.DEBUG, "initialize, referrers to ignore :[" + JSON.stringify(ignoreReferrers) + "]");
|
|
1039
1069
|
}
|
|
1070
|
+
log(logLevelEnums.DEBUG, "initialize, salt given:[" + !!self.salt + "]");
|
|
1040
1071
|
} catch (e) {
|
|
1041
1072
|
log(logLevelEnums.ERROR, "initialize, Could not stringify some config object values");
|
|
1042
1073
|
}
|
|
@@ -1369,6 +1400,7 @@
|
|
|
1369
1400
|
self.track_domains = undefined;
|
|
1370
1401
|
self.storage = undefined;
|
|
1371
1402
|
self.enableOrientationTracking = undefined;
|
|
1403
|
+
self.salt = undefined;
|
|
1372
1404
|
self.maxKeyLength = undefined;
|
|
1373
1405
|
self.maxValueSize = undefined;
|
|
1374
1406
|
self.maxSegmentationValues = undefined;
|
|
@@ -3723,11 +3755,12 @@
|
|
|
3723
3755
|
url += "&platform=" + this.platform;
|
|
3724
3756
|
url += "&app_version=" + this.app_version;
|
|
3725
3757
|
url += "&sdk_version=" + sdkVersion;
|
|
3758
|
+
var customObjectToSendWithTheWidget = {};
|
|
3759
|
+
customObjectToSendWithTheWidget.tc = 1; // indicates SDK supports opening links from the widget in a new tab
|
|
3726
3760
|
if (feedbackWidgetSegmentation) {
|
|
3727
|
-
var customObjectToSendWithTheWidget = {};
|
|
3728
3761
|
customObjectToSendWithTheWidget.sg = feedbackWidgetSegmentation;
|
|
3729
|
-
url += "&custom=" + JSON.stringify(customObjectToSendWithTheWidget);
|
|
3730
3762
|
}
|
|
3763
|
+
url += "&custom=" + JSON.stringify(customObjectToSendWithTheWidget);
|
|
3731
3764
|
// Origin is passed to the popup so that it passes it back in the postMessage event
|
|
3732
3765
|
// Only web SDK passes origin and web
|
|
3733
3766
|
url += "&origin=" + passedOrigin;
|
|
@@ -4646,53 +4679,54 @@
|
|
|
4646
4679
|
log(logLevelEnums.DEBUG, "Sending XML HTTP request");
|
|
4647
4680
|
var xhr = new XMLHttpRequest();
|
|
4648
4681
|
params = params || {};
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
}
|
|
4676
|
-
if (isResponseValidated) {
|
|
4677
|
-
if (typeof callback === "function") {
|
|
4678
|
-
callback(false, params, this.responseText);
|
|
4679
|
-
}
|
|
4680
|
-
} else {
|
|
4681
|
-
log(logLevelEnums.ERROR, functionName + " Invalid response from server");
|
|
4682
|
-
if (functionName === "send_request_queue") {
|
|
4683
|
-
HealthCheck.saveRequestCounters(this.status, this.responseText);
|
|
4682
|
+
prepareParams(params, self.salt).then(function (saltedData) {
|
|
4683
|
+
var method = "GET";
|
|
4684
|
+
if (self.force_post || saltedData.length >= 2000) {
|
|
4685
|
+
method = "POST";
|
|
4686
|
+
}
|
|
4687
|
+
if (method === "GET") {
|
|
4688
|
+
xhr.open("GET", url + "?" + saltedData, true);
|
|
4689
|
+
} else {
|
|
4690
|
+
xhr.open("POST", url, true);
|
|
4691
|
+
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
4692
|
+
}
|
|
4693
|
+
for (var header in self.headers) {
|
|
4694
|
+
xhr.setRequestHeader(header, self.headers[header]);
|
|
4695
|
+
}
|
|
4696
|
+
// fallback on error
|
|
4697
|
+
xhr.onreadystatechange = function () {
|
|
4698
|
+
if (this.readyState === 4) {
|
|
4699
|
+
log(logLevelEnums.DEBUG, functionName + " HTTP request completed with status code: [" + this.status + "] and response: [" + this.responseText + "]");
|
|
4700
|
+
// response validation function will be selected to also accept JSON arrays if useBroadResponseValidator is true
|
|
4701
|
+
var isResponseValidated;
|
|
4702
|
+
if (useBroadResponseValidator) {
|
|
4703
|
+
// JSON array/object both can pass
|
|
4704
|
+
isResponseValidated = isResponseValidBroad(this.status, this.responseText);
|
|
4705
|
+
} else {
|
|
4706
|
+
// only JSON object can pass
|
|
4707
|
+
isResponseValidated = isResponseValid(this.status, this.responseText);
|
|
4684
4708
|
}
|
|
4685
|
-
if (
|
|
4686
|
-
|
|
4709
|
+
if (isResponseValidated) {
|
|
4710
|
+
if (typeof callback === "function") {
|
|
4711
|
+
callback(false, params, this.responseText);
|
|
4712
|
+
}
|
|
4713
|
+
} else {
|
|
4714
|
+
log(logLevelEnums.ERROR, functionName + " Invalid response from server");
|
|
4715
|
+
if (functionName === "send_request_queue") {
|
|
4716
|
+
HealthCheck.saveRequestCounters(this.status, this.responseText);
|
|
4717
|
+
}
|
|
4718
|
+
if (typeof callback === "function") {
|
|
4719
|
+
callback(true, params, this.status, this.responseText);
|
|
4720
|
+
}
|
|
4687
4721
|
}
|
|
4688
4722
|
}
|
|
4723
|
+
};
|
|
4724
|
+
if (method === "GET") {
|
|
4725
|
+
xhr.send();
|
|
4726
|
+
} else {
|
|
4727
|
+
xhr.send(saltedData);
|
|
4689
4728
|
}
|
|
4690
|
-
};
|
|
4691
|
-
if (method === "GET") {
|
|
4692
|
-
xhr.send();
|
|
4693
|
-
} else {
|
|
4694
|
-
xhr.send(data);
|
|
4695
|
-
}
|
|
4729
|
+
});
|
|
4696
4730
|
} catch (e) {
|
|
4697
4731
|
// fallback
|
|
4698
4732
|
log(logLevelEnums.ERROR, functionName + " Something went wrong while making an XML HTTP request: " + e);
|
|
@@ -4724,52 +4758,54 @@
|
|
|
4724
4758
|
};
|
|
4725
4759
|
var body = null;
|
|
4726
4760
|
params = params || {};
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
url += "?" + prepareParams(params);
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4734
|
-
// Add custom headers
|
|
4735
|
-
for (var header in self.headers) {
|
|
4736
|
-
headers[header] = self.headers[header];
|
|
4737
|
-
}
|
|
4738
|
-
|
|
4739
|
-
// Make the fetch request
|
|
4740
|
-
fetch(url, {
|
|
4741
|
-
method: method,
|
|
4742
|
-
headers: headers,
|
|
4743
|
-
body: body
|
|
4744
|
-
}).then(function (res) {
|
|
4745
|
-
response = res;
|
|
4746
|
-
return response.text();
|
|
4747
|
-
}).then(function (data) {
|
|
4748
|
-
log(logLevelEnums.DEBUG, functionName + " Fetch request completed wit status code: [" + response.status + "] and response: [" + data + "]");
|
|
4749
|
-
var isResponseValidated;
|
|
4750
|
-
if (useBroadResponseValidator) {
|
|
4751
|
-
isResponseValidated = isResponseValidBroad(response.status, data);
|
|
4761
|
+
prepareParams(params, self.salt).then(function (saltedData) {
|
|
4762
|
+
if (self.force_post || saltedData.length >= 2000) {
|
|
4763
|
+
method = "POST";
|
|
4764
|
+
body = saltedData;
|
|
4752
4765
|
} else {
|
|
4753
|
-
|
|
4766
|
+
url += "?" + saltedData;
|
|
4754
4767
|
}
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4768
|
+
|
|
4769
|
+
// Add custom headers
|
|
4770
|
+
for (var header in self.headers) {
|
|
4771
|
+
headers[header] = self.headers[header];
|
|
4772
|
+
}
|
|
4773
|
+
|
|
4774
|
+
// Make the fetch request
|
|
4775
|
+
fetch(url, {
|
|
4776
|
+
method: method,
|
|
4777
|
+
headers: headers,
|
|
4778
|
+
body: body
|
|
4779
|
+
}).then(function (res) {
|
|
4780
|
+
response = res;
|
|
4781
|
+
return response.text();
|
|
4782
|
+
}).then(function (data) {
|
|
4783
|
+
log(logLevelEnums.DEBUG, functionName + " Fetch request completed wit status code: [" + response.status + "] and response: [" + data + "]");
|
|
4784
|
+
var isResponseValidated;
|
|
4785
|
+
if (useBroadResponseValidator) {
|
|
4786
|
+
isResponseValidated = isResponseValidBroad(response.status, data);
|
|
4787
|
+
} else {
|
|
4788
|
+
isResponseValidated = isResponseValid(response.status, data);
|
|
4758
4789
|
}
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4790
|
+
if (isResponseValidated) {
|
|
4791
|
+
if (typeof callback === "function") {
|
|
4792
|
+
callback(false, params, data);
|
|
4793
|
+
}
|
|
4794
|
+
} else {
|
|
4795
|
+
log(logLevelEnums.ERROR, functionName + " Invalid response from server");
|
|
4796
|
+
if (functionName === "send_request_queue") {
|
|
4797
|
+
HealthCheck.saveRequestCounters(response.status, data);
|
|
4798
|
+
}
|
|
4799
|
+
if (typeof callback === "function") {
|
|
4800
|
+
callback(true, params, response.status, data);
|
|
4801
|
+
}
|
|
4763
4802
|
}
|
|
4803
|
+
})["catch"](function (error) {
|
|
4804
|
+
log(logLevelEnums.ERROR, functionName + " Failed Fetch request: " + error);
|
|
4764
4805
|
if (typeof callback === "function") {
|
|
4765
|
-
callback(true, params
|
|
4806
|
+
callback(true, params);
|
|
4766
4807
|
}
|
|
4767
|
-
}
|
|
4768
|
-
})["catch"](function (error) {
|
|
4769
|
-
log(logLevelEnums.ERROR, functionName + " Failed Fetch request: " + error);
|
|
4770
|
-
if (typeof callback === "function") {
|
|
4771
|
-
callback(true, params);
|
|
4772
|
-
}
|
|
4808
|
+
});
|
|
4773
4809
|
});
|
|
4774
4810
|
} catch (e) {
|
|
4775
4811
|
// fallback
|
|
@@ -5214,6 +5250,7 @@
|
|
|
5214
5250
|
isResponseValidBroad: isResponseValidBroad,
|
|
5215
5251
|
secureRandom: secureRandom,
|
|
5216
5252
|
log: log,
|
|
5253
|
+
calculateChecksum: calculateChecksum,
|
|
5217
5254
|
checkIfLoggingIsOn: checkIfLoggingIsOn,
|
|
5218
5255
|
getMetrics: getMetrics,
|
|
5219
5256
|
getUA: getUA,
|
|
@@ -5334,12 +5371,16 @@
|
|
|
5334
5371
|
function sendInstantHCRequest() {
|
|
5335
5372
|
// truncate error message to 1000 characters
|
|
5336
5373
|
var curbedMessage = truncateSingleValue(self.hcErrorMessage, 1000, "healthCheck", log);
|
|
5374
|
+
// due to some server issues we pass empty string as is
|
|
5375
|
+
if (curbedMessage !== "") {
|
|
5376
|
+
curbedMessage = JSON.stringify(curbedMessage);
|
|
5377
|
+
}
|
|
5337
5378
|
// prepare hc object
|
|
5338
5379
|
var hc = {
|
|
5339
5380
|
el: self.hcErrorCount,
|
|
5340
5381
|
wl: self.hcWarningCount,
|
|
5341
5382
|
sc: self.hcStatusCode,
|
|
5342
|
-
em:
|
|
5383
|
+
em: curbedMessage
|
|
5343
5384
|
};
|
|
5344
5385
|
// prepare request
|
|
5345
5386
|
var request = {
|
package/lib/countly.min.js
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
function zb(l,k){for(var q=0;q<k.length;q++){var
|
|
3
|
-
0;q<l.options.length;q++)l.options[q].selected&&k.push(l.options[q].value);return k.join(", ")}function
|
|
4
|
-
|
|
5
|
-
k[
|
|
6
|
-
typeof l?
|
|
7
|
-
":"+k.version}).join(),l+=navigator.userAgentData.mobile?" mobi ":" ",l+=navigator.userAgentData.platform);return l}function
|
|
8
|
-
k="tablet":q.test(l)&&(k="phone");return k}function
|
|
9
|
-
if(l)return k.test(l);l=k.test(ua());k=k.test(kb());return l||k}function lb(l){"undefined"===typeof l.pageY&&"number"===typeof l.clientX&&document.documentElement&&(l.pageX=l.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.pageY=l.clientY+document.body.scrollTop+document.documentElement.scrollTop);return l}function
|
|
10
|
-
l.documentElement.clientHeight))}function mb(){var l=document;return Math.max(Math.max(l.body.scrollWidth,l.documentElement.scrollWidth),Math.max(l.body.offsetWidth,l.documentElement.offsetWidth),Math.max(l.body.clientWidth,l.documentElement.clientWidth))}function
|
|
11
|
-
l.setAttribute(k,q);l.setAttribute(
|
|
1
|
+
(function(ma,L){"object"===typeof exports&&"undefined"!==typeof module?L(exports):"function"===typeof define&&define.amd?define(["exports"],L):(ma="undefined"!==typeof globalThis?globalThis:ma||self,L(ma.Countly=ma.Countly||{}))})(this,function(ma){function L(l){"@babel/helpers - typeof";return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(k){return typeof k}:function(k){return k&&"function"==typeof Symbol&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},L(l)}
|
|
2
|
+
function zb(l,k){for(var q=0;q<k.length;q++){var t=k[q];t.enumerable=t.enumerable||!1;t.configurable=!0;"value"in t&&(t.writable=!0);Object.defineProperty(l,Wb(t.key),t)}}function Wb(l){a:if("object"===typeof l&&null!==l){var k=l[Symbol.toPrimitive];if(void 0!==k){l=k.call(l,"string");if("object"!==typeof l)break a;throw new TypeError("@@toPrimitive must return a primitive value.");}l=String(l)}return"symbol"===typeof l?l:String(l)}function Ab(l){var k=[];if("undefined"!==typeof l.options)for(var q=
|
|
3
|
+
0;q<l.options.length;q++)l.options[q].selected&&k.push(l.options[q].value);return k.join(", ")}function fb(){var l=Bb("xxxxxxxx","[x]");var k=Date.now().toString();return l+k}function gb(){return Bb("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx","[xy]")}function Bb(l,k){var q=(new Date).getTime();return l.replace(new RegExp(k,"g"),function(t){var C=(q+16*Math.random())%16|0;return("x"===t?C:C&3|8).toString(16)})}function F(){return Math.floor((new Date).getTime()/1E3)}function hb(){var l=(new Date).getTime();
|
|
4
|
+
Pa>=l?Pa++:Pa=l;return Pa}function u(l,k,q){if(k&&Object.keys(k).length){if("undefined"!==typeof k[l])return k[l]}else if("undefined"!==typeof p[l])return p[l];return q}function ib(l,k,q){for(var t in p.i)p.i[t].tracking_crashes&&p.i[t].recordError(l,k,q)}function jb(l,k){var q=[],t;for(t in l)q.push(t+"="+encodeURIComponent(l[t]));var C=q.join("&");return k?Cb(C,k).then(function(O){return C+="&checksum256="+O}):Promise.resolve(C)}function ta(l){return"string"===typeof l&&"/"===l.substring(l.length-
|
|
5
|
+
1)?l.substring(0,l.length-1):l}function za(l,k){for(var q={},t,C=0,O=k.length;C<O;C++)t=k[C],"undefined"!==typeof l[t]&&(q[t]=l[t]);return q}function ba(l,k,q,t,C,O){var Q={};if(l){if(Object.keys(l).length>t){var W={},Aa=0,na;for(na in l)Aa<t&&(W[na]=l[na],Aa++);l=W}for(var Ba in l)t=z(Ba,k,C,O),W=z(l[Ba],q,C,O),Q[t]=W}return Q}function z(l,k,q,t){var C=l;"number"===typeof l&&(l=l.toString());"string"===typeof l&&l.length>k&&(C=l.substring(0,k),t(c.DEBUG,q+", Key: [ "+l+" ] is longer than accepted length. It will be truncated."));
|
|
6
|
+
return C}function Cb(l,k){l=(new TextEncoder).encode(l+k);return crypto.subtle.digest("SHA-256",l).then(function(q){return Array.from(new Uint8Array(q)).map(function(t){return t.toString(16).padStart(2,"0")}).join("")})}function A(l,k,q){x&&(null===l||"undefined"===typeof l?Ca()&&console.warn("[WARNING] [Countly] add_event_listener, Can't bind ["+k+"] event to nonexisting element"):"undefined"!==typeof l.addEventListener?l.addEventListener(k,q,!1):l.attachEvent("on"+k,q))}function Qa(l){return l?
|
|
7
|
+
"undefined"!==typeof l.target?l.target:l.srcElement:window.event.srcElement}function ua(l){if(l)return l;(l=navigator.userAgent)||(l=kb());return l}function kb(l){if(l)return l;l="";navigator.userAgentData&&(l=navigator.userAgentData.brands.map(function(k){return k.brand+":"+k.version}).join(),l+=navigator.userAgentData.mobile?" mobi ":" ",l+=navigator.userAgentData.platform);return l}function Db(l){if(!l){if(navigator.userAgentData&&navigator.userAgentData.mobile)return"phone";l=ua()}l=l.toLowerCase();
|
|
8
|
+
var k="desktop",q=/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/;/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(l)?k="tablet":q.test(l)&&(k="phone");return k}function Eb(l){var k=/(CountlySiteBot|nuhk|Googlebot|GoogleSecurityScanner|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver|bingbot|Google Web Preview|Mediapartners-Google|AdsBot-Google|Baiduspider|Ezooms|YahooSeeker|AltaVista|AVSearch|Mercator|Scooter|InfoSeek|Ultraseek|Lycos|Wget|YandexBot|Yandex|YaDirectFetcher|SiteBot|Exabot|AhrefsBot|MJ12bot|TurnitinBot|magpie-crawler|Nutch Crawler|CMS Crawler|rogerbot|Domnutch|ssearch_bot|XoviBot|netseer|digincore|fr-crawler|wesee|AliasIO|contxbot|PingdomBot|BingPreview|HeadlessChrome|Lighthouse)/;
|
|
9
|
+
if(l)return k.test(l);l=k.test(ua());k=k.test(kb());return l||k}function lb(l){"undefined"===typeof l.pageY&&"number"===typeof l.clientX&&document.documentElement&&(l.pageX=l.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.pageY=l.clientY+document.body.scrollTop+document.documentElement.scrollTop);return l}function Ra(){var l=document;return Math.max(Math.max(l.body.scrollHeight,l.documentElement.scrollHeight),Math.max(l.body.offsetHeight,l.documentElement.offsetHeight),Math.max(l.body.clientHeight,
|
|
10
|
+
l.documentElement.clientHeight))}function mb(){var l=document;return Math.max(Math.max(l.body.scrollWidth,l.documentElement.scrollWidth),Math.max(l.body.offsetWidth,l.documentElement.offsetWidth),Math.max(l.body.clientWidth,l.documentElement.clientWidth))}function Fb(){var l=document;return Math.min(Math.min(l.body.clientHeight,l.documentElement.clientHeight),Math.min(l.body.offsetHeight,l.documentElement.offsetHeight),window.innerHeight)}function Gb(l,k,q,t,C,O){l=document.createElement(l);var Q;
|
|
11
|
+
l.setAttribute(k,q);l.setAttribute(t,C);k=function(){Q||O();Q=!0};O&&(l.onreadystatechange=k,l.onload=k);document.getElementsByTagName("head")[0].appendChild(l)}function Hb(l,k){Gb("script","type","text/javascript","src",l,k)}function Sa(l,k){Gb("link","rel","stylesheet","href",l,k)}function Ib(){if(x){var l=document.getElementById("cly-loader");if(!l){var k=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=
|
|
12
12
|
"#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}":q.appendChild(document.createTextNode("#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}"));
|
|
13
|
-
k.appendChild(q);l=document.createElement("div");l.setAttribute("id","cly-loader");document.body.onload=function(){if(p.showLoaderProtection)
|
|
14
|
-
var l=document.getElementById("cly-loader");l&&(l.style.display="none")}}function
|
|
15
|
-
50;if(
|
|
16
|
-
CLY_BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/countly_boomerang.js"},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(g.method="fetch_remote_config");0===e&&(g.oi=0);1===e&&(g.oi=1);"function"===typeof m&&(n=m);f.check_consent("sessions")&&(g.metrics=JSON.stringify(
|
|
20
|
-
n(r,
|
|
21
|
-
function
|
|
13
|
+
k.appendChild(q);l=document.createElement("div");l.setAttribute("id","cly-loader");document.body.onload=function(){if(p.showLoaderProtection)Ca()&&console.warn("[WARNING] [Countly] showloader, Loader is already on");else try{document.body.appendChild(l)}catch(t){Ca()&&console.error("[ERROR] [Countly] showLoader, Body is not loaded for loader to append: "+t)}}}l.style.display="block"}}function Ca(){return p&&p.debug&&"undefined"!==typeof console?!0:!1}function Jb(){if(x){p.showLoaderProtection=!0;
|
|
14
|
+
var l=document.getElementById("cly-loader");l&&(l.style.display="none")}}function Xb(l){var k=document.createElement("script"),q=document.createElement("script");k.async=!0;q.async=!0;k.src=p.customSourceBoomerang||Kb.BOOMERANG_SRC;q.src=p.customSourceCountlyBoomerang||Kb.CLY_BOOMERANG_SRC;document.getElementsByTagName("head")[0].appendChild(k);document.getElementsByTagName("head")[0].appendChild(q);var t=!1,C=!1;k.onload=function(){t=!0};q.onload=function(){C=!0};var O=0,Q=setInterval(function(){O+=
|
|
15
|
+
50;if(t&&C||1500<=O){if(p.debug){var W="BoomerangJS loaded:["+t+"], countly_boomerang loaded:["+C+"].";t&&C?console.log("[DEBUG] "+W):console.warn("[WARNING] "+W+" Initializing without APM.")}p.init(l);clearInterval(Q)}},50)}var M={NPS:"[CLY]_nps",SURVEY:"[CLY]_survey",STAR_RATING:"[CLY]_star_rating",VIEW:"[CLY]_view",ORIENTATION:"[CLY]_orientation",ACTION:"[CLY]_action"},Yb=Object.values(M),c={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "},Kb={BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/boomerang.min.js",
|
|
16
|
+
CLY_BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/countly_boomerang.js"},U=Object.freeze({errorCount:"cly_hc_error_count",warningCount:"cly_hc_warning_count",statusCode:"cly_hc_status_code",errorMessage:"cly_hc_error_message"}),Lb=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,x="undefined"!==typeof window,p=globalThis.Countly||{},
|
|
17
|
+
Pa=0,Ub=function(l,k,q){k&&zb(l.prototype,k);q&&zb(l,q);Object.defineProperty(l,"prototype",{writable:!1});return l}(function q(k){function t(a,d){if(f.ignore_visitor)b(c.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);Yb.includes(a.key)||(a.key=z(a.key,f.maxKeyLength,"add_cly_event",b));a.segmentation=ba(a.segmentation,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"add_cly_event",b);a=za(a,["key","count","sum","dur","segmentation"]);a.timestamp=
|
|
18
|
+
hb();var e=new Date;a.hour=e.getHours();a.dow=e.getDay();a.id=d||fb();a.key===M.VIEW?a.pvid=Da||"":a.cvid=ia||"";I.push(a);w("cly_event",I);b(c.INFO,"With event ID: ["+a.id+"], successfully adding the last event:",a)}else b(c.ERROR,"Adding event failed. Event must have a key property")}function C(a,d,e,h,m){b(c.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var g={method:"rc",av:f.app_version};a&&(g.keys=JSON.stringify(a));d&&(g.omit_keys=JSON.stringify(d));var n;"legacy"===h&&
|
|
19
|
+
(g.method="fetch_remote_config");0===e&&(g.oi=0);1===e&&(g.oi=1);"function"===typeof m&&(n=m);f.check_consent("sessions")&&(g.metrics=JSON.stringify(Ta()));f.check_consent("remote-config")?(Ea(g),ca("fetch_remote_config_explicit",f.url+Ua,g,function(r,v,G){if(!r){try{var N=JSON.parse(G);if(g.keys||g.omit_keys)for(var J in N)S[J]=N[J];else S=N;w("cly_remote_configs",S)}catch(Fa){b(c.ERROR,"fetch_remote_config_explicit, Had an issue while parsing the response: "+Fa)}n&&(b(c.INFO,"fetch_remote_config_explicit, Callback function is provided"),
|
|
20
|
+
n(r,S))}},!0)):(b(c.ERROR,"fetch_remote_config_explicit, Remote config requires explicit consent"),n&&n(Error("Remote config requires explicit consent"),S))}function O(){b(c.INFO,"checkIgnore, Checking if user or visit should be ignored");f.ignore_prefetch&&x&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to prerendering"));f.ignore_bots&&Eb()&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to bot"))}
|
|
21
|
+
function Q(){0<I.length&&(b(c.DEBUG,"Flushing events"),P({events:JSON.stringify(I)}),I=[],w("cly_event",I))}function W(a,d){if(x)if(document.getElementById("countly-feedback-sticker-"+a._id))b(c.ERROR,"Widget with same ID exists");else try{var e=document.createElement("div");e.className="countly-iframe-wrapper";e.id="countly-iframe-wrapper-"+a._id;var h=document.createElement("span");h.className="countly-feedback-close-icon";h.id="countly-feedback-close-icon-"+a._id;h.innerText="x";var m=document.createElement("iframe");
|
|
22
22
|
m.name="countly-feedback-iframe";m.id="countly-feedback-iframe";m.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version="+oa;document.body.appendChild(e);e.appendChild(h);e.appendChild(m);A(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(d){var g=document.createElementNS("http://www.w3.org/2000/svg",
|
|
23
23
|
"svg");g.id="feedback-sticker-svg";g.setAttribute("aria-hidden","true");g.setAttribute("data-prefix","far");g.setAttribute("data-icon","grin");g.setAttribute("class","svg-inline--fa fa-grin fa-w-16");g.setAttribute("role","img");g.setAttribute("xmlns","http://www.w3.org/2000/svg");g.setAttribute("viewBox","0 0 496 512");var n=document.createElementNS("http://www.w3.org/2000/svg","path");n.id="smileyPathInStickerSvg";n.setAttribute("fill","white");n.setAttribute("d","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z");
|
|
24
|
-
var r=document.createElement("span");r.innerText=a.trigger_button_text;var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function
|
|
28
|
-
b(c.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(
|
|
29
|
-
f.hcWarningCount))}0<
|
|
24
|
+
var r=document.createElement("span");r.innerText=a.trigger_button_text;var v=document.createElement("div");v.style.color=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;v.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;v.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;v.id="countly-feedback-sticker-"+a._id;g.appendChild(n);v.appendChild(g);v.appendChild(r);document.body.appendChild(v);var G=document.getElementById("smileyPathInStickerSvg");
|
|
25
|
+
G&&(G.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);A(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(N){b(c.ERROR,"Somethings went wrong while element injecting process: "+
|
|
26
|
+
N)}else b(c.WARNING,"processWidget, window object is not available. Not processing widget.")}function Aa(){var a;if("undefined"!==typeof f.onload&&0<f.onload.length){for(a=0;a<f.onload.length;a++)if("function"===typeof f.onload[a])f.onload[a](f);f.onload=[]}}function na(){if(Y){var a={name:Y};f.check_consent("views")&&(t({key:M.VIEW,dur:pa?F()-Ga:Ha,segmentation:a},ia),Y=null)}}function Ba(){if(ja){var a=y("cly_session");if(!a||parseInt(a)<=F())X=!1,f.begin_session(!Ia);w("cly_session",F()+60*Ja)}}
|
|
27
|
+
function Ea(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name=va;a.sdk_version=oa;a.t=D;a.av=f.app_version;var d=Mb();if(a.metrics){var e=JSON.parse(a.metrics);e._ua||(e._ua=d,a.metrics=JSON.stringify(e))}else a.metrics=JSON.stringify({_ua:d});f.check_consent("location")?(f.country_code&&(a.country_code=f.country_code),f.city&&(a.city=f.city),null!==f.ip_address&&(a.ip_address=f.ip_address)):a.location="";a.timestamp=hb();d=new Date;a.hour=d.getHours();a.dow=d.getDay()}function P(a){f.ignore_visitor?
|
|
28
|
+
b(c.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(Ea(a),H.length>Va&&H.shift(),H.push(a),w("cly_queue",H,!0)):b(c.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}function Wa(){Aa();if(f.ignore_visitor)Xa=!1,b(c.WARNING,"User opt_out, no heartbeat");else{Xa=!0;Ya&&"undefined"!==typeof p.q&&0<p.q.length&&wa();if(X&&Ia&&pa){var a=F();a-ka>Za&&(f.session_duration(a-ka),ka=a,0<f.hcErrorCount&&w(U.errorCount,f.hcErrorCount),0<f.hcWarningCount&&w(U.warningCount,
|
|
29
|
+
f.hcWarningCount))}0<I.length&&!f.test_mode_eq&&(I.length<=Ka?(P({events:JSON.stringify(I)}),I=[]):(a=I.splice(0,Ka),P({events:JSON.stringify(a)})),w("cly_event",I));!K&&0<H.length&&$a&&F()>nb&&($a=!1,a=H[0],a.rr=H.length,b(c.DEBUG,"Processing request",a),w("cly_queue",H,!0),f.test_mode||ca("send_request_queue",f.url+ob,a,function(d,e){d?nb=F()+ab:H.shift();w("cly_queue",H,!0);$a=!0},!1));setTimeout(Wa,bb)}}function wa(){if("undefined"===typeof p||"undefined"===typeof p.i)b(c.DEBUG,"Countly is not finished initialization yet, will process the queue after initialization is done");
|
|
30
30
|
else{var a=p.q;p.q=[];for(var d=0;d<a.length;d++){var e=a[d];b(c.DEBUG,"Processing queued calls:"+e);if("function"===typeof e)e();else if(Array.isArray(e)&&0<e.length){var h=f,m=0;try{p.i[e[m]]&&(h=p.i[e[m]],m++)}catch(n){b(c.DEBUG,"No instance found for the provided key while processing async queue");p.q.push(e);continue}if("function"===typeof h[e[m]])h[e[m]].apply(h,e.slice(m+1));else if(0===e[m].indexOf("userData.")){var g=e[m].replace("userData.","");"function"===typeof h.userData[g]&&h.userData[g].apply(h,
|
|
31
|
-
e.slice(m+1))}else"function"===typeof p[e[m]]&&p[e[m]].apply(p,e.slice(m+1))}}}}function pb(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):
|
|
31
|
+
e.slice(m+1))}else"function"===typeof p[e[m]]&&p[e[m]].apply(p,e.slice(m+1))}}}}function pb(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):gb()}function Mb(){return f.metrics._ua||ua()}function Ta(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||ua();if(x&&screen.width){var d=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==d&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&
|
|
32
32
|
window.devicePixelRatio)d=Math.round(d*window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var h=d;d=e;e=h}a._resolution=a._resolution||""+d+"x"+e}}x&&window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);d=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof d&&(a._locale=a._locale||d);qb()&&(a._store=a._store||document.referrer);b(c.DEBUG,"Got metrics",a);return a}
|
|
33
|
-
function qb(a){if(!x)return!1;a=a||document.referrer;var d=!1;if("undefined"===typeof a||0===a.length)b(c.DEBUG,"Invalid referrer:["+a+"], ignoring.");else{var e=
|
|
34
|
-
a+"], ignoring.");else b(c.DEBUG,"Referrer is corrupt:["+a+"], ignoring.")}return d}function b(a,d){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===L(arguments[2])&&(arguments[2]=JSON.stringify(arguments[2]));
|
|
35
|
-
console.log(e):console.debug(e)}}function
|
|
36
|
-
a+" HTTP request completed with status code: ["+this.status+"] and response: ["+this.responseText+"]"),(m?rb(this.status,this.responseText):sb(this.status,this.responseText))?"function"===typeof h&&h(!1,e,this.responseText):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(this.status,this.responseText),"function"===typeof h&&h(!0,e,this.status,this.responseText)))};"GET"===r?g.send():g.send(n)}catch(
|
|
37
|
-
|
|
38
|
-
sb(g.status,
|
|
39
|
-
|
|
40
|
-
!1)}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function
|
|
41
|
-
a=
|
|
33
|
+
function qb(a){if(!x)return!1;a=a||document.referrer;var d=!1;if("undefined"===typeof a||0===a.length)b(c.DEBUG,"Invalid referrer:["+a+"], ignoring.");else{var e=Lb.exec(a);if(e)if(e[11])if(e[11]===window.location.hostname)b(c.DEBUG,"Referrer is current host:["+a+"], ignoring.");else if(da&&da.length)for(d=!0,e=0;e<da.length;e++){if(0<=a.indexOf(da[e])){b(c.DEBUG,"Referrer in ignore list:["+a+"], ignoring.");d=!1;break}}else b(c.DEBUG,"Valid referrer:["+a+"]"),d=!0;else b(c.DEBUG,"No path found in referrer:["+
|
|
34
|
+
a+"], ignoring.");else b(c.DEBUG,"Referrer is corrupt:["+a+"], ignoring.")}return d}function b(a,d){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===L(arguments[2])&&(arguments[2]=JSON.stringify(arguments[2]));Ya||(d="["+f.app_key+"] "+d);a||(a=c.DEBUG);for(var e="",h=2;h<arguments.length;h++)e+=arguments[h];e=a+"[Countly] "+d+e;a===c.ERROR?(console.error(e),qa.incrementErrorCount()):a===c.WARNING?(console.warn(e),qa.incrementWarningCount()):a===c.INFO?console.info(e):a===c.VERBOSE?
|
|
35
|
+
console.log(e):console.debug(e)}}function ca(a,d,e,h,m){x?Nb(a,d,e,h,m):Ob(a,d,e,h,m)}function Nb(a,d,e,h,m){m=m||!1;try{b(c.DEBUG,"Sending XML HTTP request");var g=new XMLHttpRequest;e=e||{};jb(e,f.salt).then(function(n){var r="GET";if(f.force_post||2E3<=n.length)r="POST";"GET"===r?g.open("GET",d+"?"+n,!0):(g.open("POST",d,!0),g.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var v in f.headers)g.setRequestHeader(v,f.headers[v]);g.onreadystatechange=function(){4===this.readyState&&
|
|
36
|
+
(b(c.DEBUG,a+" HTTP request completed with status code: ["+this.status+"] and response: ["+this.responseText+"]"),(m?rb(this.status,this.responseText):sb(this.status,this.responseText))?"function"===typeof h&&h(!1,e,this.responseText):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(this.status,this.responseText),"function"===typeof h&&h(!0,e,this.status,this.responseText)))};"GET"===r?g.send():g.send(n)})}catch(n){b(c.ERROR,a+" Something went wrong while making an XML HTTP request: "+
|
|
37
|
+
n),"function"===typeof h&&h(!0,e)}}function Ob(a,d,e,h,m){m=m||!1;var g;try{b(c.DEBUG,"Sending Fetch request");var n="GET",r={"Content-type":"application/x-www-form-urlencoded"},v=null;e=e||{};jb(e,f.salt).then(function(G){f.force_post||2E3<=G.length?(n="POST",v=G):d+="?"+G;for(var N in f.headers)r[N]=f.headers[N];fetch(d,{method:n,headers:r,body:v}).then(function(J){g=J;return g.text()}).then(function(J){b(c.DEBUG,a+" Fetch request completed wit status code: ["+g.status+"] and response: ["+J+"]");
|
|
38
|
+
(m?rb(g.status,J):sb(g.status,J))?"function"===typeof h&&h(!1,e,J):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(g.status,J),"function"===typeof h&&h(!0,e,g.status,J))})["catch"](function(J){b(c.ERROR,a+" Failed Fetch request: "+J);"function"===typeof h&&h(!0,e)})})}catch(G){b(c.ERROR,a+" Something went wrong with the Fetch request attempt: "+G),"function"===typeof h&&h(!0,e)}}function sb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+
|
|
39
|
+
a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"!==Object.prototype.toString.call(e)?(b(c.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function rb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(b(c.ERROR,"Http response is not JSON Object nor JSON Array"),
|
|
40
|
+
!1)}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function Pb(){x?La=Math.max(La,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop):b(c.WARNING,"processScroll, window object is not available. Not processing scroll.")}function tb(){if(!x)b(c.WARNING,"processScrollView, window object is not available. Not processing scroll view.");else if(Ma){Ma=!1;var a=Ra(),d=mb(),e=Fb();f.check_consent("scrolls")&&(a={type:"scroll",y:La+e,width:d,height:a,view:f.getViewUrl()},
|
|
41
|
+
a=ba(a,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processScrollView",b),f.track_domains&&(a.domain=window.location.hostname),t({key:M.ACTION,segmentation:a}))}}function Qb(a){w("cly_token",a)}function Rb(a,d,e){var h=new Date;h.setTime(h.getTime()+864E5*e);e="; expires="+h.toGMTString();document.cookie=a+"="+d+e+"; path=/"}function y(a,d,e){if("none"===f.storage||"object"!==L(f.storage)&&!x)b(c.DEBUG,"Storage is disabled. Value with key: ["+a+"] won't be retrieved");else{e||(a=f.app_key+
|
|
42
42
|
"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a));if("object"===L(f.storage)&&"function"===typeof f.storage.getItem){var h=f.storage.getItem(a);return a.endsWith("cly_id")?h:f.deserialize(h)}void 0===d&&(d=ra);if(d)h=localStorage.getItem(a);else if("localstorage"!==f.storage)a:{d=a+"=";e=document.cookie.split(";");h=0;for(var m=e.length;h<m;h++){for(var g=e[h];" "===g.charAt(0);)g=g.substring(1,g.length);if(0===g.indexOf(d)){h=g.substring(d.length,g.length);break a}}h=null}return a.endsWith("cly_id")?
|
|
43
|
-
h:f.deserialize(h)}}function w(a,d,e,h){"none"===f.storage||"object"!==L(f.storage)&&!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be stored"):(h||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"undefined"!==typeof d&&null!==d&&("object"===L(f.storage)&&"function"===typeof f.storage.setItem?f.storage.setItem(a,d):(void 0===e&&(e=ra),d=f.serialize(d),e?localStorage.setItem(a,d):"localstorage"!==f.storage&&
|
|
44
|
-
!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be removed"):(e||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"object"===L(f.storage)&&"function"===typeof f.storage.removeItem?f.storage.removeItem(a):(void 0===d&&(d=ra),d?localStorage.removeItem(a):"localstorage"!==f.storage&&
|
|
45
|
-
!1,!0));w("cly_session",y(f.namespace+"cly_session",!1,!0));var a=y(f.namespace+"cly_queue",!1,!0);Array.isArray(a)&&(a=a.filter(function(d){return d.app_key===f.app_key}),w("cly_queue",a));y(f.namespace+"cly_cmp_id",!1,!0)&&(w("cly_cmp_id",y(f.namespace+"cly_cmp_id",!1,!0)),w("cly_cmp_uid",y(f.namespace+"cly_cmp_uid",!1,!0)));y(f.namespace+"cly_ignore",!1,!0)&&w("cly_ignore",y(f.namespace+"cly_ignore",!1,!0));
|
|
46
|
-
!1,!0);
|
|
47
|
-
k,!0),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
k,!0);this.force_post=
|
|
51
|
-
|
|
52
|
-
xa||this.maxBreadcrumbCount||(this.maxBreadcrumbCount=100);"cookie"===this.storage&&(ra=!1);this.rcAutoOptinAb||this.useExplicitRcApi||(b(c.WARNING,"initialize, Auto opting is disabled, switching to explicit RC API"),this.useExplicitRcApi=!0);Array.isArray(
|
|
53
|
-
!g&&(this.device_id=y("cly_id"),b(c.DEBUG,"initialize, temporarily using the previous device ID to flush existing events"),D=y("cly_id_type"),D||(b(c.DEBUG,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"),D=0),
|
|
54
|
-
""))}catch(r){b(c.ERROR,"initialize, Could not parse name: "+window.name+", error: "+r)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(r){b(c.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+r)}if((this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&
|
|
55
|
-
y("cly_old_token")&&(
|
|
56
|
-
else{"javascript_native_web"===va&&"
|
|
57
|
-
|
|
58
|
-
this.country_code+"], city:["+this.city+"], ip_address:["+this.ip_address+"]");""!==this.namespace&&b(c.DEBUG,"initialize, namespace given:["+this.namespace+"]");this.clearStoredId&&b(c.DEBUG,"initialize, clearStoredId flag set to:["+this.clearStoredId+"]");this.ignore_prefetch&&b(c.DEBUG,"initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :["+this.ignore_prefetch+"]");this.test_mode&&b(c.WARNING,"initialize, test_mode:["+
|
|
59
|
-
this.test_mode_eq&&b(c.WARNING,"initialize, test_mode_eq:["+this.test_mode_eq+"], event queue won't be processed");this.heatmapWhitelist&&b(c.DEBUG,"initialize, heatmap whitelist:["+JSON.stringify(this.heatmapWhitelist)+"], these domains will be whitelisted");"default"!==this.storage&&b(c.DEBUG,"initialize, storage is set to:["+this.storage+"]");this.ignore_bots&&b(c.DEBUG,"initialize, ignore traffic from bots :["+this.ignore_bots+"]");this.force_post&&
|
|
60
|
-
this.force_post+"]");this.remote_config&&b(c.DEBUG,"initialize, remote_config callback provided:["+!!this.remote_config+"]");"boolean"===typeof this.rcAutoOptinAb&&b(c.DEBUG,"initialize, automatic RC optin is enabled:["+this.rcAutoOptinAb+"]");this.useExplicitRcApi||b(c.WARNING,"initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag");this.track_domains&&b(c.DEBUG,"initialize, tracking domain info:["+
|
|
61
|
-
b(c.DEBUG,"initialize, enableOrientationTracking:["+this.enableOrientationTracking+"]");
|
|
62
|
-
p.getSearchQuery)+"]");128!==this.maxKeyLength&&b(c.DEBUG,"initialize, maxKeyLength set to:["+this.maxKeyLength+"] characters");256!==this.maxValueSize&&b(c.DEBUG,"initialize, maxValueSize set to:["+this.maxValueSize+"] characters");100!==this.maxSegmentationValues&&b(c.DEBUG,"initialize, maxSegmentationValues set to:["+this.maxSegmentationValues+"] key/value pairs");100!==this.maxBreadcrumbCount&&b(c.DEBUG,"initialize, maxBreadcrumbCount for custom logs set to:["+this.maxBreadcrumbCount+
|
|
63
|
-
30!==this.maxStackTraceLinesPerThread&&b(c.DEBUG,"initialize, maxStackTraceLinesPerThread set to:["+this.maxStackTraceLinesPerThread+"] lines");200!==this.maxStackTraceLineLength&&b(c.DEBUG,"initialize, maxStackTraceLineLength set to:["+this.maxStackTraceLineLength+"] characters");500!==
|
|
64
|
-
20!==
|
|
65
|
-
|
|
66
|
-
y("cly_id")&&!g?(this.device_id=y("cly_id"),b(c.INFO,"initialize, Set the stored device ID"),D=y("cly_id_type"),D||(b(c.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),D=0)):null!==a?(b(c.INFO,"initialize, Device ID set by URL"),this.device_id=a,D=3):h?(b(c.INFO,"initialize, Device ID set by developer"),this.device_id=h,k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==
|
|
67
|
-
K&&g?b(c.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):K&&!g?b(c.INFO,"initialize, Temp ID set, entering offline mode"):(K=!0,b(c.INFO,"initialize, Temp ID set, enabling offline mode"))):(b(c.INFO,"initialize, Generating the device ID"),this.device_id=
|
|
68
|
-
n,e[n]),
|
|
69
|
-
|
|
43
|
+
h:f.deserialize(h)}}function w(a,d,e,h){"none"===f.storage||"object"!==L(f.storage)&&!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be stored"):(h||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"undefined"!==typeof d&&null!==d&&("object"===L(f.storage)&&"function"===typeof f.storage.setItem?f.storage.setItem(a,d):(void 0===e&&(e=ra),d=f.serialize(d),e?localStorage.setItem(a,d):"localstorage"!==f.storage&&Rb(a,d,30))))}function T(a,d,e){"none"===f.storage||"object"!==L(f.storage)&&
|
|
44
|
+
!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be removed"):(e||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"object"===L(f.storage)&&"function"===typeof f.storage.removeItem?f.storage.removeItem(a):(void 0===d&&(d=ra),d?localStorage.removeItem(a):"localstorage"!==f.storage&&Rb(a,"",-1)))}function Zb(){if(y(f.namespace+"cly_id",!1,!0)){w("cly_id",y(f.namespace+"cly_id",!1,!0));w("cly_id_type",y(f.namespace+"cly_id_type",!1,!0));w("cly_event",y(f.namespace+"cly_event",
|
|
45
|
+
!1,!0));w("cly_session",y(f.namespace+"cly_session",!1,!0));var a=y(f.namespace+"cly_queue",!1,!0);Array.isArray(a)&&(a=a.filter(function(d){return d.app_key===f.app_key}),w("cly_queue",a));y(f.namespace+"cly_cmp_id",!1,!0)&&(w("cly_cmp_id",y(f.namespace+"cly_cmp_id",!1,!0)),w("cly_cmp_uid",y(f.namespace+"cly_cmp_uid",!1,!0)));y(f.namespace+"cly_ignore",!1,!0)&&w("cly_ignore",y(f.namespace+"cly_ignore",!1,!0));T("cly_id",!1,!0);T("cly_id_type",!1,!0);T("cly_event",!1,!0);T("cly_session",!1,!0);T("cly_queue",
|
|
46
|
+
!1,!0);T("cly_cmp_id",!1,!0);T("cly_cmp_uid",!1,!0);T("cly_ignore",!1,!0)}}if(!(this instanceof q))throw new TypeError("Cannot call a class as a function");var f=this,Ya=!p.i,X=!1,ob="/i",Ua="/o/sdk",bb=u("interval",k,500),Va=u("queue_size",k,1E3),H=[],I=[],S={},sa=[],ea={},da=u("ignore_referrers",k,[]),ub=null,Ia=!0,ka,vb=0,Y=null,Ga=0,Ha=0,nb=0,ab=u("fail_timeout",k,60),Na=u("inactivity_time",k,20),Oa=0,Za=u("session_update",k,60),Ka=u("max_events",k,100),xa=u("max_logs",k,null),ja=u("use_session_cookie",
|
|
47
|
+
k,!0),Ja=u("session_cookie_timeout",k,30),$a=!0,Xa=!1,K=u("offline_mode",k,!1),fa={},pa=!0,Sb=F(),ra=!0,ya=null,D=1,Ma=!1,La=0,wb=!1,ia=null,Da=null,la=null,va=u("sdk_name",k,"javascript_native_web"),oa=u("sdk_version",k,"24.4.0");try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(a){b(c.ERROR,"Local storage test failed, Halting local storage support: "+a),ra=!1}for(var E={},xb=0;xb<p.features.length;xb++)E[p.features[xb]]={};this.initialize=function(){this.serialize=
|
|
48
|
+
u("serialize",k,p.serialize);this.deserialize=u("deserialize",k,p.deserialize);this.getViewName=u("getViewName",k,p.getViewName);this.getViewUrl=u("getViewUrl",k,p.getViewUrl);this.getSearchQuery=u("getSearchQuery",k,p.getSearchQuery);this.DeviceIdType=p.DeviceIdType;this.namespace=u("namespace",k,"");this.clearStoredId=u("clear_stored_id",k,!1);this.app_key=u("app_key",k,null);this.onload=u("onload",k,[]);this.utm=u("utm",k,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});this.ignore_prefetch=
|
|
49
|
+
u("ignore_prefetch",k,!0);this.rcAutoOptinAb=u("rc_automatic_optin_for_ab",k,!0);this.useExplicitRcApi=u("use_explicit_rc_api",k,!1);this.debug=u("debug",k,!1);this.test_mode=u("test_mode",k,!1);this.test_mode_eq=u("test_mode_eq",k,!1);this.metrics=u("metrics",k,{});this.headers=u("headers",k,{});this.url=ta(u("url",k,""));this.app_version=u("app_version",k,"0.0");this.country_code=u("country_code",k,null);this.city=u("city",k,null);this.ip_address=u("ip_address",k,null);this.ignore_bots=u("ignore_bots",
|
|
50
|
+
k,!0);this.force_post=u("force_post",k,!1);this.remote_config=u("remote_config",k,!1);this.ignore_visitor=u("ignore_visitor",k,!1);this.require_consent=u("require_consent",k,!1);this.track_domains=x?u("track_domains",k,!0):void 0;this.storage=u("storage",k,"default");this.enableOrientationTracking=x?u("enable_orientation_tracking",k,!0):void 0;this.maxKeyLength=u("max_key_length",k,128);this.maxValueSize=u("max_value_size",k,256);this.maxSegmentationValues=u("max_segmentation_values",k,100);this.maxBreadcrumbCount=
|
|
51
|
+
u("max_breadcrumb_count",k,null);this.maxStackTraceLinesPerThread=u("max_stack_trace_lines_per_thread",k,30);this.maxStackTraceLineLength=u("max_stack_trace_line_length",k,200);this.heatmapWhitelist=u("heatmap_whitelist",k,[]);f.salt=u("salt",k,null);f.hcErrorCount=y(U.errorCount)||0;f.hcWarningCount=y(U.warningCount)||0;f.hcStatusCode=y(U.statusCode)||-1;f.hcErrorMessage=y(U.errorMessage)||"";xa&&!this.maxBreadcrumbCount?(this.maxBreadcrumbCount=xa,b(c.WARNING,"initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!")):
|
|
52
|
+
xa||this.maxBreadcrumbCount||(this.maxBreadcrumbCount=100);"cookie"===this.storage&&(ra=!1);this.rcAutoOptinAb||this.useExplicitRcApi||(b(c.WARNING,"initialize, Auto opting is disabled, switching to explicit RC API"),this.useExplicitRcApi=!0);Array.isArray(da)||(da=[]);""===this.url&&(b(c.ERROR,"initialize, Please provide server URL"),this.ignore_visitor=!0);y("cly_ignore")&&(this.ignore_visitor=!0);Zb();H=y("cly_queue")||[];I=y("cly_event")||[];S=y("cly_remote_configs")||{};this.clearStoredId&&(y("cly_id")&&
|
|
53
|
+
!g&&(this.device_id=y("cly_id"),b(c.DEBUG,"initialize, temporarily using the previous device ID to flush existing events"),D=y("cly_id_type"),D||(b(c.DEBUG,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"),D=0),Q(),this.device_id=void 0,D=1),b(c.INFO,"initialize, Clearing the device ID storage"),T("cly_id"),T("cly_id_type"),T("cly_session"));O();if(x)if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=JSON.parse(window.name.replace("cly:",
|
|
54
|
+
""))}catch(r){b(c.ERROR,"initialize, Could not parse name: "+window.name+", error: "+r)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(r){b(c.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+r)}if((this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&Ya)&&this.passed_data.token&&this.passed_data.purpose){this.passed_data.token!==
|
|
55
|
+
y("cly_old_token")&&(Qb(this.passed_data.token),w("cly_old_token",this.passed_data.token));var a=[];Array.isArray(this.heatmapWhitelist)?(this.heatmapWhitelist.push(this.url),a=this.heatmapWhitelist.map(function(r){return ta(r)})):a=[this.url];a.includes(this.passed_data.url)&&"heatmap"===this.passed_data.purpose&&(this.ignore_visitor=!0,Ib(),Hb(this.passed_data.url+"/views/heatmap.js",Jb))}if(this.ignore_visitor)b(c.WARNING,"initialize, ignore_visitor:["+this.ignore_visitor+"], this user will not be tracked");
|
|
56
|
+
else{"javascript_native_web"===va&&"24.4.0"===oa?b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"]"):b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"], default name:[javascript_native_web] and default version:[24.4.0]");b(c.DEBUG,"initialize, app_key:["+this.app_key+"], url:["+this.url+"]");b(c.DEBUG,"initialize, device_id:["+u("device_id",k,void 0)+"]");b(c.DEBUG,"initialize, require_consent is enabled:["+this.require_consent+"]");try{b(c.DEBUG,"initialize, metric override:["+JSON.stringify(this.metrics)+
|
|
57
|
+
"]"),b(c.DEBUG,"initialize, header override:["+JSON.stringify(this.headers)+"]"),b(c.DEBUG,"initialize, number of onload callbacks provided:["+this.onload.length+"]"),b(c.DEBUG,"initialize, utm tags:["+JSON.stringify(this.utm)+"]"),da&&b(c.DEBUG,"initialize, referrers to ignore :["+JSON.stringify(da)+"]"),b(c.DEBUG,"initialize, salt given:["+!!f.salt+"]")}catch(r){b(c.ERROR,"initialize, Could not stringify some config object values")}b(c.DEBUG,"initialize, app_version:["+this.app_version+"]");b(c.DEBUG,
|
|
58
|
+
"initialize, provided location info; country_code:["+this.country_code+"], city:["+this.city+"], ip_address:["+this.ip_address+"]");""!==this.namespace&&b(c.DEBUG,"initialize, namespace given:["+this.namespace+"]");this.clearStoredId&&b(c.DEBUG,"initialize, clearStoredId flag set to:["+this.clearStoredId+"]");this.ignore_prefetch&&b(c.DEBUG,"initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :["+this.ignore_prefetch+"]");this.test_mode&&b(c.WARNING,"initialize, test_mode:["+
|
|
59
|
+
this.test_mode+"], request queue won't be processed");this.test_mode_eq&&b(c.WARNING,"initialize, test_mode_eq:["+this.test_mode_eq+"], event queue won't be processed");this.heatmapWhitelist&&b(c.DEBUG,"initialize, heatmap whitelist:["+JSON.stringify(this.heatmapWhitelist)+"], these domains will be whitelisted");"default"!==this.storage&&b(c.DEBUG,"initialize, storage is set to:["+this.storage+"]");this.ignore_bots&&b(c.DEBUG,"initialize, ignore traffic from bots :["+this.ignore_bots+"]");this.force_post&&
|
|
60
|
+
b(c.DEBUG,"initialize, forced post method for all requests:["+this.force_post+"]");this.remote_config&&b(c.DEBUG,"initialize, remote_config callback provided:["+!!this.remote_config+"]");"boolean"===typeof this.rcAutoOptinAb&&b(c.DEBUG,"initialize, automatic RC optin is enabled:["+this.rcAutoOptinAb+"]");this.useExplicitRcApi||b(c.WARNING,"initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag");this.track_domains&&b(c.DEBUG,"initialize, tracking domain info:["+
|
|
61
|
+
this.track_domains+"]");this.enableOrientationTracking&&b(c.DEBUG,"initialize, enableOrientationTracking:["+this.enableOrientationTracking+"]");ja||b(c.WARNING,"initialize, use_session_cookie is enabled:["+ja+"]");K&&b(c.DEBUG,"initialize, offline_mode:["+K+"], user info won't be send to the servers");K&&b(c.DEBUG,"initialize, stored remote configs:["+JSON.stringify(S)+"]");b(c.DEBUG,"initialize, 'getViewName' callback override provided:["+(this.getViewName!==p.getViewName)+"]");b(c.DEBUG,"initialize, 'getSearchQuery' callback override provided:["+
|
|
62
|
+
(this.getSearchQuery!==p.getSearchQuery)+"]");128!==this.maxKeyLength&&b(c.DEBUG,"initialize, maxKeyLength set to:["+this.maxKeyLength+"] characters");256!==this.maxValueSize&&b(c.DEBUG,"initialize, maxValueSize set to:["+this.maxValueSize+"] characters");100!==this.maxSegmentationValues&&b(c.DEBUG,"initialize, maxSegmentationValues set to:["+this.maxSegmentationValues+"] key/value pairs");100!==this.maxBreadcrumbCount&&b(c.DEBUG,"initialize, maxBreadcrumbCount for custom logs set to:["+this.maxBreadcrumbCount+
|
|
63
|
+
"] entries");30!==this.maxStackTraceLinesPerThread&&b(c.DEBUG,"initialize, maxStackTraceLinesPerThread set to:["+this.maxStackTraceLinesPerThread+"] lines");200!==this.maxStackTraceLineLength&&b(c.DEBUG,"initialize, maxStackTraceLineLength set to:["+this.maxStackTraceLineLength+"] characters");500!==bb&&b(c.DEBUG,"initialize, interval for heartbeats set to:["+bb+"] milliseconds");1E3!==Va&&b(c.DEBUG,"initialize, queue_size set to:["+Va+"] items max");60!==ab&&b(c.DEBUG,"initialize, fail_timeout set to:["+
|
|
64
|
+
ab+"] seconds of wait time after a failed connection to server");20!==Na&&b(c.DEBUG,"initialize, inactivity_time set to:["+Na+"] minutes to consider a user as inactive after no observable action");60!==Za&&b(c.DEBUG,"initialize, session_update set to:["+Za+"] seconds to check if extending a session is needed while the user is active");100!==Ka&&b(c.DEBUG,"initialize, max_events set to:["+Ka+"] events to send in one batch");xa&&b(c.WARNING,"initialize, max_logs set to:["+xa+"] breadcrumbs to store for crash logs max, deprecated ");
|
|
65
|
+
30!==Ja&&b(c.DEBUG,"initialize, session_cookie_timeout set to:["+Ja+"] minutes to expire a cookies session");a=null;g=f.getSearchQuery();var d=!1,e={};if(g){0===g.indexOf("?")&&(g=g.substring(1));g=g.split("&");for(var h=0;h<g.length;h++){var m=g[h].split("=");"cly_id"===m[0]?w("cly_cmp_id",m[1]):"cly_uid"===m[0]?w("cly_cmp_uid",m[1]):"cly_device_id"===m[0]?a=m[1]:0===(m[0]+"").indexOf("utm_")&&this.utm[m[0].replace("utm_","")]&&(e[m[0].replace("utm_","")]=m[1],d=!0)}}var g="[CLY]_temp_id"===y("cly_id");
|
|
66
|
+
h=u("device_id",k,void 0);"number"===typeof h&&(h=h.toString());y("cly_id")&&!g?(this.device_id=y("cly_id"),b(c.INFO,"initialize, Set the stored device ID"),D=y("cly_id_type"),D||(b(c.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),D=0)):null!==a?(b(c.INFO,"initialize, Device ID set by URL"),this.device_id=a,D=3):h?(b(c.INFO,"initialize, Device ID set by developer"),this.device_id=h,k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==
|
|
67
|
+
p.device_id&&(D=0)):K||g?(this.device_id="[CLY]_temp_id",D=2,K&&g?b(c.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):K&&!g?b(c.INFO,"initialize, Temp ID set, entering offline mode"):(K=!0,b(c.INFO,"initialize, Temp ID set, enabling offline mode"))):(b(c.INFO,"initialize, Generating the device ID"),this.device_id=u("device_id",k,pb()),k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==p.device_id&&(D=0));w("cly_id",this.device_id);w("cly_id_type",D);if(d){la=
|
|
68
|
+
{};for(var n in this.utm)e[n]?(this.userData.set("utm_"+n,e[n]),la[n]=e[n]):this.userData.unset("utm_"+n);this.userData.save()}Aa();setTimeout(function(){p.noHeartBeat?b(c.WARNING,"initialize, Heartbeat disabled. This is for testing purposes only!"):Wa();f.remote_config&&f.fetch_remote_config(f.remote_config)},1);x&&document.documentElement.setAttribute("data-countly-useragent",ua());qa.sendInstantHCRequest();b(c.INFO,"initialize, Countly initialized")}};this.halt=function(){b(c.WARNING,"halt, Resetting Countly");
|
|
69
|
+
p.i=void 0;p.q=[];p.noHeartBeat=void 0;Ya=!p.i;X=!1;ob="/i";Ua="/o/sdk";bb=500;Va=1E3;H=[];I=[];S={};sa=[];ea={};da=[];ub=null;Ia=!0;vb=0;Y=null;nb=Ha=Ga=0;ab=60;Na=20;Oa=0;Za=60;Ka=100;xa=null;ja=!0;Ja=30;$a=!0;K=Xa=!1;fa={};pa=!0;Sb=F();ra=!0;ya=null;D=1;Ma=!1;La=0;wb=!1;la=Da=ia=null;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(d){b(c.ERROR,"halt, Local storage test failed, will fallback to cookies"),ra=!1}p.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
|
|
70
70
|
E={};for(var a=0;a<p.features.length;a++)E[p.features[a]]={};f.app_key=void 0;f.device_id=void 0;f.onload=void 0;f.utm=void 0;f.ignore_prefetch=void 0;f.debug=void 0;f.test_mode=void 0;f.test_mode_eq=void 0;f.metrics=void 0;f.headers=void 0;f.url=void 0;f.app_version=void 0;f.country_code=void 0;f.city=void 0;f.ip_address=void 0;f.ignore_bots=void 0;f.force_post=void 0;f.rcAutoOptinAb=void 0;f.useExplicitRcApi=void 0;f.remote_config=void 0;f.ignore_visitor=void 0;f.require_consent=void 0;f.track_domains=
|
|
71
|
-
void 0;f.storage=void 0;f.enableOrientationTracking=void 0;f.maxKeyLength=void 0;f.maxValueSize=void 0;f.maxSegmentationValues=void 0;f.maxBreadcrumbCount=void 0;f.maxStackTraceLinesPerThread=void 0;f.maxStackTraceLineLength=void 0};this.group_features=function(a){b(c.INFO,"group_features, Grouping features");if(a)for(var d in a)E[d]?b(c.WARNING,"group_features, Feature name ["+d+"] is already reserved"):"string"===typeof a[d]?E[d]={features:[a[d]]}:a[d]&&Array.isArray(a[d])&&a[d].length?
|
|
72
|
-
b(c.ERROR,"group_features, Incorrect feature list for ["+d+"] value: ["+a[d]+"]");else b(c.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){b(c.INFO,"check_consent, Checking if consent is given for specific feature:["+a+"]");if(!this.require_consent)return b(c.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(E[a])return!(!E[a]||!E[a].optin);b(c.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=
|
|
71
|
+
void 0;f.storage=void 0;f.enableOrientationTracking=void 0;f.salt=void 0;f.maxKeyLength=void 0;f.maxValueSize=void 0;f.maxSegmentationValues=void 0;f.maxBreadcrumbCount=void 0;f.maxStackTraceLinesPerThread=void 0;f.maxStackTraceLineLength=void 0};this.group_features=function(a){b(c.INFO,"group_features, Grouping features");if(a)for(var d in a)E[d]?b(c.WARNING,"group_features, Feature name ["+d+"] is already reserved"):"string"===typeof a[d]?E[d]={features:[a[d]]}:a[d]&&Array.isArray(a[d])&&a[d].length?
|
|
72
|
+
E[d]={features:a[d]}:b(c.ERROR,"group_features, Incorrect feature list for ["+d+"] value: ["+a[d]+"]");else b(c.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){b(c.INFO,"check_consent, Checking if consent is given for specific feature:["+a+"]");if(!this.require_consent)return b(c.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(E[a])return!(!E[a]||!E[a].optin);b(c.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=
|
|
73
73
|
function(){b(c.INFO,"check_device_id_type, Retrieving the current device id type.["+D+"]");switch(D){case 1:var a=f.DeviceIdType.SDK_GENERATED;break;case 3:case 0:a=f.DeviceIdType.DEVELOPER_SUPPLIED;break;case 2:a=f.DeviceIdType.TEMPORARY_ID;break;default:a=-1}return a};this.get_device_id=function(){b(c.INFO,"get_device_id, Retrieving the device id: ["+f.device_id+"]");return f.device_id};this.check_any_consent=function(){b(c.INFO,"check_any_consent, Checking if any consent is given");if(!this.require_consent)return b(c.INFO,
|
|
74
|
-
"check_any_consent, require_consent is off, no consent is necessary"),!0;for(var a in E)if(E[a]&&E[a].optin)return!0;b(c.INFO,"check_any_consent, No consents given");return!1};this.add_consent=function(a){b(c.INFO,"add_consent, Adding consent for ["+a+"]");if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add_consent(a[d]);else E[a]?E[a].features?(E[a].optin=!0,this.add_consent(E[a].features)):!0!==E[a].optin&&(E[a].optin=!0,
|
|
75
|
-
|
|
76
|
-
d):(E[a].optin=!1,d&&!1!==E[a].optin&&
|
|
77
|
-
!1);K=!0;this.device_id="[CLY]_temp_id";f.device_id=this.device_id;D=2};this.disable_offline_mode=function(a){if(K){b(c.INFO,"disable_offline_mode, Disabling offline mode");K=!1;a&&this.device_id!==a?(this.device_id=a,f.device_id=this.device_id,D=0,w("cly_id",this.device_id),w("cly_id_type",0),b(c.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=pb(),"[CLY]_temp_id"===this.device_id&&(this.device_id=
|
|
78
|
-
this.device_id),w("cly_id_type",1)));a=!1;if(0<H.length)for(var d=0;d<H.length;d++)"[CLY]_temp_id"===H[d].device_id&&(H[d].device_id=this.device_id,a=!0);a&&w("cly_queue",H,!0)}else b(c.WARNING,"disable_offline_mode, Countly was not in offline mode.")};this.begin_session=function(a,d){b(c.INFO,"begin_session, Starting the session. There was an ongoing session: ["+
|
|
79
|
-
if(this.check_consent("sessions")){if(!
|
|
80
|
-
w("cly_session",F()+60*
|
|
81
|
-
session_duration:a})):this.session_duration(a),
|
|
82
|
-
!1));var e=this.device_id;this.device_id=a;f.device_id=this.device_id;D=0;w("cly_id",this.device_id);w("cly_id_type",0);b(c.INFO,"change_id, Changing ID from:["+e+"] to ["+a+"]");d?
|
|
83
|
-
break;case M.STAR_RATING:d=this.check_consent("star-rating");break;case M.VIEW:d=this.check_consent("views");break;case M.ORIENTATION:d=this.check_consent("users");break;case M.ACTION:d=this.check_consent("clicks")||this.check_consent("scrolls");break;default:d=this.check_consent("events")}d&&
|
|
84
|
-
a+"] already started"):
|
|
85
|
-
a+"] was not found");return!1};this.end_event=function(a){a?(b(c.INFO,"end_event, Ending timed event"),"string"===typeof a&&(a=z(a,f.maxKeyLength,"end_event",b),a={key:a}),a.key?
|
|
86
|
-
function(a){b(c.INFO,"report_orientation, Reporting orientation");this.check_consent("users")&&
|
|
87
|
-
a+"] and the user ID: ["+d+"]");this.check_consent("attribution")&&(a=a||y("cly_cmp_id")||"cly_organic",(d=d||y("cly_cmp_uid"))?
|
|
88
|
-
b),a.organization=z(a.organization,f.maxValueSize,"user_details",b),a.phone=z(a.phone,f.maxValueSize,"user_details",b),a.picture=z(a.picture,4096,"user_details",b),a.gender=z(a.gender,f.maxValueSize,"user_details",b),a.byear=z(a.byear,f.maxValueSize,"user_details",b),a.custom=
|
|
89
|
-
d,e){f.check_consent("users")&&(
|
|
90
|
-
d+"] under the key: ["+a+"] ");a=z(a,f.maxKeyLength,"userData set_once",b);d=z(d,f.maxValueSize,"userData set_once",b);
|
|
91
|
-
b);d=z(d,f.maxValueSize,"userData increment_by",b);
|
|
92
|
-
"userData max",b);
|
|
93
|
-
d){b(c.INFO,"[userData] push_unique, Pushing a unique value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push_unique",b);d=z(d,f.maxValueSize,"userData push_unique",b);
|
|
94
|
-
(wa(),
|
|
95
|
-
f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"report_trace",b);d=
|
|
96
|
-
n="";"undefined"!==typeof e&&(n+=e+"\n");"undefined"!==typeof h&&(n+="at "+h);"undefined"!==typeof m&&(n+=":"+m);"undefined"!==typeof g&&(n+=":"+g);n+="\n";try{e=[];for(var
|
|
74
|
+
"check_any_consent, require_consent is off, no consent is necessary"),!0;for(var a in E)if(E[a]&&E[a].optin)return!0;b(c.INFO,"check_any_consent, No consents given");return!1};this.add_consent=function(a){b(c.INFO,"add_consent, Adding consent for ["+a+"]");if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add_consent(a[d]);else E[a]?E[a].features?(E[a].optin=!0,this.add_consent(E[a].features)):!0!==E[a].optin&&(E[a].optin=!0,Tb(),setTimeout(function(){"sessions"===a&&fa.begin_session?(f.begin_session.apply(f,
|
|
75
|
+
fa.begin_session),fa.begin_session=null):"views"===a&&fa.track_pageview&&(Y=null,f.track_pageview.apply(f,fa.track_pageview),fa.track_pageview=null)},1)):b(c.ERROR,"add_consent, No feature available for ["+a+"]")};this.remove_consent=function(a){b(c.INFO,"remove_consent, Removing consent for ["+a+"]");this.remove_consent_internal(a,!0)};this.remove_consent_internal=function(a,d){d=d||!1;if(Array.isArray(a))for(var e=0;e<a.length;e++)this.remove_consent_internal(a[e],d);else E[a]?E[a].features?this.remove_consent_internal(E[a].features,
|
|
76
|
+
d):(E[a].optin=!1,d&&!1!==E[a].optin&&Tb()):b(c.WARNING,"remove_consent, No feature available for ["+a+"]")};var cb,Tb=function(){cb&&(clearTimeout(cb),cb=null);cb=setTimeout(function(){for(var a={},d=0;d<p.features.length;d++)a[p.features[d]]=!0===E[p.features[d]].optin?!0:!1;P({consent:JSON.stringify(a)});b(c.DEBUG,"Consent update request has been sent to the queue.")},1E3)};this.enable_offline_mode=function(){b(c.INFO,"enable_offline_mode, Enabling offline mode");this.remove_consent_internal(p.features,
|
|
77
|
+
!1);K=!0;this.device_id="[CLY]_temp_id";f.device_id=this.device_id;D=2};this.disable_offline_mode=function(a){if(K){b(c.INFO,"disable_offline_mode, Disabling offline mode");K=!1;a&&this.device_id!==a?(this.device_id=a,f.device_id=this.device_id,D=0,w("cly_id",this.device_id),w("cly_id_type",0),b(c.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=pb(),"[CLY]_temp_id"===this.device_id&&(this.device_id=gb()),f.device_id=this.device_id,this.device_id!==y("cly_id")&&(w("cly_id",
|
|
78
|
+
this.device_id),w("cly_id_type",1)));a=!1;if(0<H.length)for(var d=0;d<H.length;d++)"[CLY]_temp_id"===H[d].device_id&&(H[d].device_id=this.device_id,a=!0);a&&w("cly_queue",H,!0)}else b(c.WARNING,"disable_offline_mode, Countly was not in offline mode.")};this.begin_session=function(a,d){b(c.INFO,"begin_session, Starting the session. There was an ongoing session: ["+X+"]");a&&b(c.INFO,"begin_session, Heartbeats are disabled");d&&b(c.INFO,"begin_session, Session starts irrespective of session cookie");
|
|
79
|
+
if(this.check_consent("sessions")){if(!X){this.enableOrientationTracking&&(this.report_orientation(),A(window,"resize",function(){f.report_orientation()}));ka=F();X=!0;Ia=!a;var e=y("cly_session");b(c.VERBOSE,"begin_session, Session state, forced: ["+d+"], useSessionCookie: ["+ja+"], seconds to expire: ["+(e-ka)+"], expired: ["+(parseInt(e)<=F())+"] ");if(d||!ja||!e||parseInt(e)<=F())b(c.INFO,"begin_session, Session started"),null===ya&&(ya=!0),e={begin_session:1},e.metrics=JSON.stringify(Ta()),P(e);
|
|
80
|
+
w("cly_session",F()+60*Ja)}}else fa.begin_session=arguments};this.session_duration=function(a){b(c.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&X&&(b(c.INFO,"session_duration, Session extended: ",a),P({session_duration:a}),Ba())};this.end_session=function(a,d){b(c.INFO,"end_session, Ending the current session. There was an on going session:["+X+"]");this.check_consent("sessions")&&X&&(a=a||F()-ka,na(),!ja||d?(b(c.INFO,"end_session, Session ended"),P({end_session:1,
|
|
81
|
+
session_duration:a})):this.session_duration(a),X=!1)};this.change_id=function(a,d){b(c.INFO,"change_id, Changing the ID");d&&b(c.INFO,"change_id, Will merge the IDs");if(!a||"string"!==typeof a||0===a.length)b(c.ERROR,"change_id, The provided ID: ["+a+"] is not a valid ID");else if(K)b(c.WARNING,"change_id, Offline mode was on, initiating disabling sequence instead."),this.disable_offline_mode(a);else if(this.device_id!=a){d||(wa(),Q(),this.end_session(null,!0),ea={},this.remove_consent_internal(p.features,
|
|
82
|
+
!1));var e=this.device_id;this.device_id=a;f.device_id=this.device_id;D=0;w("cly_id",this.device_id);w("cly_id_type",0);b(c.INFO,"change_id, Changing ID from:["+e+"] to ["+a+"]");d?P({old_device_id:e}):this.begin_session(!Ia,!0);this.remote_config&&(S={},w("cly_remote_configs",S),this.fetch_remote_config(this.remote_config))}};this.add_event=function(a){b(c.INFO,"add_event, Adding event: ",a);switch(a.key){case M.NPS:var d=this.check_consent("feedback");break;case M.SURVEY:d=this.check_consent("feedback");
|
|
83
|
+
break;case M.STAR_RATING:d=this.check_consent("star-rating");break;case M.VIEW:d=this.check_consent("views");break;case M.ORIENTATION:d=this.check_consent("users");break;case M.ACTION:d=this.check_consent("clicks")||this.check_consent("scrolls");break;default:d=this.check_consent("events")}d&&t(a)};this.start_event=function(a){a&&"string"===typeof a?(b(c.INFO,"start_event, Starting timed event with key: ["+a+"]"),a=z(a,f.maxKeyLength,"start_event",b),ea[a]?b(c.WARNING,"start_event, Timed event with key: ["+
|
|
84
|
+
a+"] already started"):ea[a]=F()):b(c.WARNING,"start_event, you have to provide a valid string key instead of: ["+a+"]")};this.cancel_event=function(a){if(!a||"string"!==typeof a)return b(c.WARNING,"cancel_event, you have to provide a valid string key instead of: ["+a+"]"),!1;b(c.INFO,"cancel_event, Canceling timed event with key: ["+a+"]");a=z(a,f.maxKeyLength,"cancel_event",b);if(ea[a])return delete ea[a],b(c.INFO,"cancel_event, Timed event with key: ["+a+"] is canceled"),!0;b(c.WARNING,"cancel_event, Timed event with key: ["+
|
|
85
|
+
a+"] was not found");return!1};this.end_event=function(a){a?(b(c.INFO,"end_event, Ending timed event"),"string"===typeof a&&(a=z(a,f.maxKeyLength,"end_event",b),a={key:a}),a.key?ea[a.key]?(a.dur=F()-ea[a.key],this.add_event(a),delete ea[a.key]):b(c.ERROR,"end_event, Timed event with key: ["+a.key+"] was not started"):b(c.ERROR,"end_event, Timed event must have a key property")):b(c.WARNING,"end_event, you have to provide a valid string key or event object instead of: ["+a+"]")};this.report_orientation=
|
|
86
|
+
function(a){b(c.INFO,"report_orientation, Reporting orientation");this.check_consent("users")&&t({key:M.ORIENTATION,segmentation:{mode:a||(window.innerWidth>window.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,d){b(c.WARNING,"report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,d)};this.recordDirectAttribution=function(a,d){b(c.INFO,"recordDirectAttribution, Recording the attribution for campaign ID: ["+
|
|
87
|
+
a+"] and the user ID: ["+d+"]");this.check_consent("attribution")&&(a=a||y("cly_cmp_id")||"cly_organic",(d=d||y("cly_cmp_uid"))?P({campaign_id:a,campaign_user:d}):P({campaign_id:a}))};this.user_details=function(a){b(c.INFO,"user_details, Trying to add user details: ",a);this.check_consent("users")&&(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),a.name=z(a.name,f.maxValueSize,"user_details",b),a.username=z(a.username,f.maxValueSize,"user_details",b),a.email=z(a.email,f.maxValueSize,"user_details",
|
|
88
|
+
b),a.organization=z(a.organization,f.maxValueSize,"user_details",b),a.phone=z(a.phone,f.maxValueSize,"user_details",b),a.picture=z(a.picture,4096,"user_details",b),a.gender=z(a.gender,f.maxValueSize,"user_details",b),a.byear=z(a.byear,f.maxValueSize,"user_details",b),a.custom=ba(a.custom,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"user_details",b),P({user_details:JSON.stringify(za(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var Z={},ha=function(a,
|
|
89
|
+
d,e){f.check_consent("users")&&(Z[a]||(Z[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(Z[a][e]||(Z[a][e]=[]),Z[a][e].push(d)):Z[a][e]=d)};this.userData={set:function(a,d){b(c.INFO,"[userData] set, Setting user's custom property value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData set",b);d=z(d,f.maxValueSize,"userData set",b);Z[a]=d},unset:function(a){b(c.INFO,"[userData] unset, Resetting user's custom property with key: ["+a+"] ");Z[a]=""},set_once:function(a,d){b(c.INFO,"[userData] set_once, Setting user's unique custom property value: ["+
|
|
90
|
+
d+"] under the key: ["+a+"] ");a=z(a,f.maxKeyLength,"userData set_once",b);d=z(d,f.maxValueSize,"userData set_once",b);ha(a,d,"$setOnce")},increment:function(a){b(c.INFO,"[userData] increment, Increasing user's custom property value under the key: ["+a+"] by one");a=z(a,f.maxKeyLength,"userData increment",b);ha(a,1,"$inc")},increment_by:function(a,d){b(c.INFO,"[userData] increment_by, Increasing user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData increment_by",
|
|
91
|
+
b);d=z(d,f.maxValueSize,"userData increment_by",b);ha(a,d,"$inc")},multiply:function(a,d){b(c.INFO,"[userData] multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData multiply",b);d=z(d,f.maxValueSize,"userData multiply",b);ha(a,d,"$mul")},max:function(a,d){b(c.INFO,"[userData] max, Saving user's maximum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData max",b);d=z(d,f.maxValueSize,
|
|
92
|
+
"userData max",b);ha(a,d,"$max")},min:function(a,d){b(c.INFO,"[userData] min, Saving user's minimum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData min",b);d=z(d,f.maxValueSize,"userData min",b);ha(a,d,"$min")},push:function(a,d){b(c.INFO,"[userData] push, Pushing a value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push",b);d=z(d,f.maxValueSize,"userData push",b);ha(a,d,"$push")},push_unique:function(a,
|
|
93
|
+
d){b(c.INFO,"[userData] push_unique, Pushing a unique value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push_unique",b);d=z(d,f.maxValueSize,"userData push_unique",b);ha(a,d,"$addToSet")},pull:function(a,d){b(c.INFO,"[userData] pull, Removing the value: ["+d+"] under the key: ["+a+"] from user's custom property array");ha(a,d,"$pull")},save:function(){b(c.INFO,"[userData] save, Saving changes to user's custom property");f.check_consent("users")&&
|
|
94
|
+
(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),P({user_details:JSON.stringify({custom:Z})}));Z={}}};this.report_trace=function(a){b(c.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var d="type name stz etz apm_metrics apm_attr".split(" "),e=0;e<d.length;e++)if("apm_attr"!==d[e]&&"undefined"===typeof a[d[e]]){b(c.WARNING,"report_trace, APM trace don't have the property: "+d[e]);return}a.name=z(a.name,f.maxKeyLength,"report_trace",b);a.app_metrics=ba(a.app_metrics,
|
|
95
|
+
f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"report_trace",b);d=za(a,d);d.timestamp=a.stz;a=new Date;d.hour=a.getHours();d.dow=a.getDay();P({apm:JSON.stringify(d)});b(c.INFO,"report_trace, Successfully adding APM trace: ",d)}};this.track_errors=function(a){x?(b(c.INFO,"track_errors, Started tracking errors"),p.i[this.app_key].tracking_crashes=!0,window.cly_crashes||(window.cly_crashes=!0,ub=a,window.onerror=function r(e,h,m,g,n){if(void 0!==n&&null!==n)ib(n,!1);else{g=g||window.event&&window.event.errorCharacter;
|
|
96
|
+
n="";"undefined"!==typeof e&&(n+=e+"\n");"undefined"!==typeof h&&(n+="at "+h);"undefined"!==typeof m&&(n+=":"+m);"undefined"!==typeof g&&(n+=":"+g);n+="\n";try{e=[];for(var v=r.caller;v;)e.push(v.name),v=v.caller;n+=e.join("\n")}catch(G){b(c.ERROR,"track_errors, Call stack generation experienced a problem: "+G)}ib(n,!1)}},window.addEventListener("unhandledrejection",function(e){ib(Error("Unhandled rejection (reason: "+(e.reason&&e.reason.stack?e.reason.stack:e.reason)+")."),!0)}))):b(c.WARNING,"track_errors, window object is not available. Not tracking errors.")};
|
|
97
97
|
this.log_error=function(a,d){b(c.INFO,"log_error, Logging errors");this.recordError(a,!0,d)};this.add_log=function(a){b(c.INFO,"add_log, Adding a new log of breadcrumbs: [ "+a+" ]");if(this.check_consent("crashes")){for(a=z(a,f.maxValueSize,"add_log",b);sa.length>=f.maxBreadcrumbCount;)sa.shift(),b(c.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one.");sa.push(a)}};this.fetch_remote_config=function(a,d,e){var h=null,m=null,g=null;a&&(e||"function"!==typeof a?Array.isArray(a)&&
|
|
98
|
-
(h=a):g=a);d&&(e||"function"!==typeof d?Array.isArray(d)&&(m=d):g=d);g||"function"!==typeof e||(g=e);this.useExplicitRcApi?(b(c.INFO,"fetch_remote_config, Fetching remote config"),
|
|
99
|
-
|
|
100
|
-
pa&&(pa=!1,vb=F()-
|
|
98
|
+
(h=a):g=a);d&&(e||"function"!==typeof d?Array.isArray(d)&&(m=d):g=d);g||"function"!==typeof e||(g=e);this.useExplicitRcApi?(b(c.INFO,"fetch_remote_config, Fetching remote config"),C(h,m,this.rcAutoOptinAb?1:0,null,g)):(b(c.WARNING,"fetch_remote_config, Fetching remote config, with legacy API"),C(h,m,null,"legacy",g))};this.enrollUserToAb=function(a){b(c.INFO,"enrollUserToAb, Providing AB test keys to opt in for");a&&Array.isArray(a)&&0!==a.length?(a={method:"ab",keys:JSON.stringify(a),av:f.app_version},
|
|
99
|
+
Ea(a),ca("enrollUserToAb",this.url+Ua,a,function(d,e,h){if(!d)try{var m=JSON.parse(h);b(c.DEBUG,"enrollUserToAb, Parsed the response's result: ["+m.result+"]")}catch(g){b(c.ERROR,"enrollUserToAb, Had an issue while parsing the response: "+g)}},!0)):b(c.ERROR,"enrollUserToAb, No keys provided")};this.get_remote_config=function(a){b(c.INFO,"get_remote_config, Getting remote config from storage");return"undefined"!==typeof a?S[a]:S};this.stop_time=function(){b(c.INFO,"stop_time, Stopping tracking duration");
|
|
100
|
+
pa&&(pa=!1,vb=F()-ka,Ha=F()-Ga)};this.start_time=function(){b(c.INFO,"start_time, Starting tracking duration");pa||(pa=!0,ka=F()-vb,Ga=F()-Ha,Ha=0,Ba())};this.track_sessions=function(){function a(){document[e]||!document.hasFocus()?f.stop_time():f.start_time()}function d(){Oa>=Na&&f.start_time();Oa=0}if(x){b(c.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();A(window,"beforeunload",function(){wa();Q();f.end_session()});var e="hidden";A(window,"focus",a);
|
|
101
101
|
A(window,"blur",a);A(window,"pageshow",a);A(window,"pagehide",a);"onfocusin"in document&&(A(window,"focusin",a),A(window,"focusout",a));e in document?document.addEventListener("visibilitychange",a):"mozHidden"in document?(e="mozHidden",document.addEventListener("mozvisibilitychange",a)):"webkitHidden"in document?(e="webkitHidden",document.addEventListener("webkitvisibilitychange",a)):"msHidden"in document&&(e="msHidden",document.addEventListener("msvisibilitychange",a));A(window,"mousemove",d);A(window,
|
|
102
|
-
"click",d);A(window,"keydown",d);A(window,"scroll",d);setInterval(function(){
|
|
103
|
-
|
|
104
|
-
"track_pageview, Problem with finding ignore list item: "+d[h]+", error: "+r)}
|
|
105
|
-
typeof document.referrer&&document.referrer.length&&(m=
|
|
106
|
-
"track_pageview",b);for(var n in e)"undefined"===typeof h[n]&&(h[n]=e[n])}this.check_consent("views")?
|
|
107
|
-
a+"]");a=a||document;var d=!0;A(a,"click",function(e){if(d){d=!1;lb(e);if("undefined"!==typeof e.pageX&&"undefined"!==typeof e.pageY){var h=
|
|
108
|
-
this.track_scrolls=function(a){x?(b(c.INFO,"track_scrolls, Starting to track scrolls"),a&&b(c.INFO,"track_scrolls, Tracking the specified children"),a=a||window,wb=
|
|
109
|
-
for(h="A";e;){if(e.nodeName.toUpperCase()===h)break a;e=e.parentElement}e=void 0}e&&(lb(d),f.check_consent("clicks")&&
|
|
110
|
-
"]"),a=a||document,A(a,"submit",function(h){h=
|
|
102
|
+
"click",d);A(window,"keydown",d);A(window,"scroll",d);setInterval(function(){Oa++;Oa>=Na&&f.stop_time()},6E4)}else b(c.WARNING,"track_sessions, window object is not available. Not tracking sessions.")};this.track_pageview=function(a,d,e){if(x||a)if(b(c.INFO,"track_pageview, Tracking page views"),b(c.VERBOSE,"track_pageview, last view is:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]"),Y&&wb&&(b(c.DEBUG,"track_pageview, Scroll registry triggered"),tb(),Ma=!0,La=0),na(),Da=ia,ia=
|
|
103
|
+
fb(),(a=z(a,f.maxKeyLength,"track_pageview",b))&&Array.isArray(a)&&(d=a,a=null),a||(a=this.getViewName()),void 0===a||""===a)b(c.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked.");else if(null===a)b(c.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(d&&d.length)for(var h=0;h<d.length;h++)try{if((new RegExp(d[h])).test(a)){b(c.INFO,"track_pageview, Ignoring the page: "+a);return}}catch(r){b(c.ERROR,
|
|
104
|
+
"track_pageview, Problem with finding ignore list item: "+d[h]+", error: "+r)}Y=a;Ga=F();b(c.VERBOSE,"track_pageview, last view is assigned:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]");h={name:a,visit:1,view:f.getViewUrl()};h=ba(h,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);this.track_domains&&(h.domain=window.location.hostname);if(ja)if(X)ya&&(ya=!1,h.start=1);else{var m=y("cly_session");if(!m||parseInt(m)<=F())ya=!1,h.start=1}else x&&"undefined"!==
|
|
105
|
+
typeof document.referrer&&document.referrer.length&&(m=Lb.exec(document.referrer))&&m[11]&&m[11]!==window.location.hostname&&(h.start=1);if(la&&Object.keys(la).length){b(c.INFO,"track_pageview, Adding fresh utm tags to segmentation:["+JSON.stringify(la)+"]");for(var g in la)"undefined"===typeof h["utm_"+g]&&(h["utm_"+g]=la[g])}x&&qb()&&(b(c.INFO,"track_pageview, Adding referrer to segmentation:["+document.referrer+"]"),h.referrer=document.referrer);if(e){e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,
|
|
106
|
+
"track_pageview",b);for(var n in e)"undefined"===typeof h[n]&&(h[n]=e[n])}this.check_consent("views")?t({key:M.VIEW,segmentation:h},ia):fa.track_pageview=arguments}else b(c.WARNING,"track_pageview, window object is not available. Not tracking page views is page is not provided.")};this.track_view=function(a,d,e){b(c.INFO,"track_view, Initiating tracking page views");this.track_pageview(a,d,e)};this.track_clicks=function(a){if(x){b(c.INFO,"track_clicks, Starting to track clicks");a&&b(c.INFO,"track_clicks, Tracking the specified children:["+
|
|
107
|
+
a+"]");a=a||document;var d=!0;A(a,"click",function(e){if(d){d=!1;lb(e);if("undefined"!==typeof e.pageX&&"undefined"!==typeof e.pageY){var h=Ra(),m=mb();f.check_consent("clicks")&&(e={type:"click",x:e.pageX,y:e.pageY,width:m,height:h,view:f.getViewUrl()},e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processClick",b),f.track_domains&&(e.domain=window.location.hostname),t({key:M.ACTION,segmentation:e}))}setTimeout(function(){d=!0},1E3)}})}else b(c.WARNING,"track_clicks, window object is not available. Not tracking clicks.")};
|
|
108
|
+
this.track_scrolls=function(a){x?(b(c.INFO,"track_scrolls, Starting to track scrolls"),a&&b(c.INFO,"track_scrolls, Tracking the specified children"),a=a||window,wb=Ma=!0,A(a,"scroll",Pb),A(a,"beforeunload",tb)):b(c.WARNING,"track_scrolls, window object is not available. Not tracking scrolls.")};this.track_links=function(a){x?(b(c.INFO,"track_links, Starting to track clicks to links"),a&&b(c.INFO,"track_links, Tracking the specified children"),a=a||document,A(a,"click",function(d){a:{var e=Qa(d);var h;
|
|
109
|
+
for(h="A";e;){if(e.nodeName.toUpperCase()===h)break a;e=e.parentElement}e=void 0}e&&(lb(d),f.check_consent("clicks")&&t({key:"linkClick",segmentation:{href:e.href,text:e.innerText,id:e.id,view:f.getViewUrl()}}))})):b(c.WARNING,"track_links, window object is not available. Not tracking links.")};this.track_forms=function(a,d){function e(h){return h.name||h.id||h.type||h.nodeName}x?(b(c.INFO,"track_forms, Starting to track form submissions. DOM object provided:["+!!a+"] Tracking hidden inputs :["+!!d+
|
|
110
|
+
"]"),a=a||document,A(a,"submit",function(h){h=Qa(h);var m={id:h.attributes.id&&h.attributes.id.nodeValue,name:h.attributes.name&&h.attributes.name.nodeValue,action:h.attributes.action&&h.attributes.action.nodeValue,method:h.attributes.method&&h.attributes.method.nodeValue,view:f.getViewUrl()},g;if("undefined"!==typeof h.elements){for(var n=0;n<h.elements.length;n++)(g=h.elements[n])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore")&&("undefined"===typeof m["input:"+e(g)]&&(m["input:"+
|
|
111
111
|
e(g)]=[]),"select"===g.nodeName.toLowerCase()?"undefined"!==typeof g.multiple?m["input:"+e(g)].push(Ab(g)):m["input:"+e(g)].push(g.options[g.selectedIndex].value):"input"===g.nodeName.toLowerCase()?"undefined"!==typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&m["input:"+e(g)].push(g.value):("hidden"!==g.type.toLowerCase()||d)&&m["input:"+e(g)].push(g.value):m["input:"+e(g)].push(g.value):"textarea"===g.nodeName.toLowerCase()?m["input:"+e(g)].push(g.value):
|
|
112
|
-
"undefined"!==typeof g.value&&m["input:"+e(g)].push(g.value));for(var r in m)m[r]&&"function"===typeof m[r].join&&(m[r]=m[r].join(", "))}f.check_consent("forms")&&
|
|
113
|
-
|
|
114
|
-
typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&(r=g.value):r=g.value:r=g.value:"textarea"===g.nodeName.toLowerCase()?r=g.value:"undefined"!==typeof g.value&&(r=g.value),g.className&&-1!==g.className.indexOf("cly_user_")){var
|
|
112
|
+
"undefined"!==typeof g.value&&m["input:"+e(g)].push(g.value));for(var r in m)m[r]&&"function"===typeof m[r].join&&(m[r]=m[r].join(", "))}f.check_consent("forms")&&t({key:"formSubmit",segmentation:m})})):b(c.WARNING,"track_forms, window object is not available. Not tracking forms.")};this.collect_from_forms=function(a,d){x?(b(c.INFO,"collect_from_forms, Starting to collect possible user data. DOM object provided:["+!!a+"] Submitting custom user property:["+!!d+"]"),a=a||document,A(a,"submit",function(e){e=
|
|
113
|
+
Qa(e);var h={},m=!1,g;if("undefined"!==typeof e.elements){var n={},r=a.getElementsByTagName("LABEL"),v;for(v=0;v<r.length;v++)r[v].htmlFor&&""!==r[v].htmlFor&&(n[r[v].htmlFor]=r[v].innerText||r[v].textContent||r[v].innerHTML);for(v=0;v<e.elements.length;v++)if((g=e.elements[v])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore"))if(r="","select"===g.nodeName.toLowerCase()?r="undefined"!==typeof g.multiple?Ab(g):g.options[g.selectedIndex].value:"input"===g.nodeName.toLowerCase()?"undefined"!==
|
|
114
|
+
typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&(r=g.value):r=g.value:r=g.value:"textarea"===g.nodeName.toLowerCase()?r=g.value:"undefined"!==typeof g.value&&(r=g.value),g.className&&-1!==g.className.indexOf("cly_user_")){var G=g.className.split(" ");for(g=0;g<G.length;g++)if(0===G[g].indexOf("cly_user_")){h[G[g].replace("cly_user_","")]=r;m=!0;break}}else if(g.type&&"email"===g.type.toLowerCase()||g.name&&-1!==g.name.toLowerCase().indexOf("email")||g.id&&
|
|
115
115
|
-1!==g.id.toLowerCase().indexOf("email")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("email")||/[^@\s]+@[^@\s]+\.[^@\s]+/.test(r))h.email||(h.email=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("username")||g.id&&-1!==g.id.toLowerCase().indexOf("username")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("username"))h.username||(h.username=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("tel")||-1!==g.name.toLowerCase().indexOf("phone")||-1!==g.name.toLowerCase().indexOf("number"))||
|
|
116
116
|
g.id&&(-1!==g.id.toLowerCase().indexOf("tel")||-1!==g.id.toLowerCase().indexOf("phone")||-1!==g.id.toLowerCase().indexOf("number"))||g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("tel")||-1!==n[g.id].toLowerCase().indexOf("phone")||-1!==n[g.id].toLowerCase().indexOf("number")))h.phone||(h.phone=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("org")||-1!==g.name.toLowerCase().indexOf("company"))||g.id&&(-1!==g.id.toLowerCase().indexOf("org")||-1!==g.id.toLowerCase().indexOf("company"))||
|
|
117
117
|
g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("org")||-1!==n[g.id].toLowerCase().indexOf("company")))h.organization||(h.organization=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("name")||g.id&&-1!==g.id.toLowerCase().indexOf("name")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("name"))h.name||(h.name=""),h.name+=r+" ",m=!0}m&&(b(c.INFO,"collect_from_forms, Gathered user data",h),d?f.user_details({custom:h}):f.user_details(h))})):b(c.WARNING,"collect_from_forms, window object is not available. Not collecting from forms.")};
|
|
118
118
|
this.collect_from_facebook=function(a){x?"undefined"!==typeof FB&&FB&&FB.api?(b(c.INFO,"collect_from_facebook, Starting to collect possible user data"),FB.api("/me",function(d){var e={};d.name&&(e.name=d.name);d.email&&(e.email=d.email);"male"===d.gender?e.gender="M":"female"===d.gender&&(e.gender="F");if(d.birthday){var h=d.birthday.split("/").pop();h&&4===h.length&&(e.byear=h)}d.work&&d.work[0]&&d.work[0].employer&&d.work[0].employer.name&&(e.organization=d.work[0].employer.name);if(a){e.custom=
|
|
119
119
|
{};for(var m in a){h=a[m].split(".");for(var g=d,n=0;n<h.length&&(g=g[h[n]],"undefined"!==typeof g);n++);"undefined"!==typeof g&&(e.custom[m]=g)}}f.user_details(e)})):b(c.ERROR,"collect_from_facebook, Facebook SDK is not available"):b(c.WARNING,"collect_from_facebook, window object is not available. Not collecting from Facebook.")};this.opt_out=function(){b(c.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;w("cly_ignore",!0)};this.opt_in=function(){b(c.INFO,"opt_in, Opting in the user");
|
|
120
|
-
w("cly_ignore",!1);this.ignore_visitor=!1;
|
|
121
|
-
{key:M.STAR_RATING,count:1,segmentation:{}};d.segmentation=
|
|
122
|
-
d.segmentation.rating=1);b(c.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",d);
|
|
120
|
+
w("cly_ignore",!1);this.ignore_visitor=!1;O();this.ignore_visitor||Xa||Wa()};this.report_feedback=function(a){b(c.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!");this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=function(a){b(c.INFO,"recordRatingWidgetWithID, Providing information about user with ID: [ "+a.widget_id+" ]");if(this.check_consent("star-rating"))if(a.widget_id)if(a.rating){var d=
|
|
121
|
+
{key:M.STAR_RATING,count:1,segmentation:{}};d.segmentation=za(a,"widget_id contactMe platform app_version rating email comment".split(" "));d.segmentation.app_version||(d.segmentation.app_version=this.metrics._app_version||this.app_version);5<d.segmentation.rating?(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating higher than 5. Changing it back to 5 now."),d.segmentation.rating=5):1>d.segmentation.rating&&(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating lower than 1. Changing it back to 1 now."),
|
|
122
|
+
d.segmentation.rating=1);b(c.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",d);t(d)}else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain rating property");else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain widget_id property")};this.reportFeedbackWidgetManually=function(a,d,e){if(this.check_consent("feedback"))if(a&&d)if(a._id)if(K)b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets can not be reported in offline mode");else{b(c.INFO,"reportFeedbackWidgetManually, Providing information about user with, provided result of the widget with ID: [ "+
|
|
123
123
|
a._id+" ] and type: ["+a.type+"]");var h=[];d=a.type;if("nps"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);10<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 10. Changing it back to 10 now."),e.rating=10):0>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 0. Changing it back to 0 now."),e.rating=0);h=["rating","comment"]}var m=
|
|
124
124
|
M.NPS}else if("survey"===d){if(e){if(1>Object.keys(e).length){b(c.ERROR,"reportFeedbackWidgetManually, Widget should have answers to be reported");return}h=Object.keys(e)}m=M.SURVEY}else if("rating"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);5<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 5. Changing it back to 5 now."),e.rating=5):1>e.rating&&(b(c.WARNING,
|
|
125
125
|
"reportFeedbackWidgetManually, You have entered a rating lower than 1. Changing it back to 1 now."),e.rating=1);h=["rating","comment","email","contactMe"]}m=M.STAR_RATING}else{b(c.ERROR,"reportFeedbackWidgetManually, Widget has an unacceptable type");return}a={key:m,count:1,segmentation:{widget_id:a._id,platform:this.platform,app_version:this.metrics._app_version||this.app_version}};if(null===e)a.segmentation.closed=1;else{m=a.segmentation;if(h){for(var g,n=0,r=h.length;n<r;n++)g=h[n],"undefined"!==
|
|
126
|
-
typeof e[g]&&(m[g]=e[g]);e=m}else e=void 0;a.segmentation=e}b(c.INFO,"reportFeedbackWidgetManually, Reporting "+d+": ",a);
|
|
127
|
-
this.presentRatingWidgetWithID(a)):b(c.WARNING,"show_feedback_popup, window object is not available. Not showing feedback popup.")};this.presentRatingWidgetWithID=function(a){x?(b(c.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+a+" ]"),this.check_consent("star-rating")&&(K?b(c.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):
|
|
128
|
-
e,h){if(!d)try{var m=JSON.parse(h);
|
|
129
|
-
this.initializeRatingWidgets=function(a){if(x){if(b(c.INFO,"initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ "+a+"]"),this.check_consent("star-rating")){a||(a=y("cly_fb_widgets"));for(var d=document.getElementsByClassName("countly-feedback-sticker");0<d.length;)d[0].remove();
|
|
130
|
-
g[e].is_active){var n=g[e].target_devices,r=
|
|
126
|
+
typeof e[g]&&(m[g]=e[g]);e=m}else e=void 0;a.segmentation=e}b(c.INFO,"reportFeedbackWidgetManually, Reporting "+d+": ",a);t(a)}else b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets must contain _id property");else b(c.ERROR,"reportFeedbackWidgetManually, Widget data and/or Widget object not provided. Aborting.")};this.show_feedback_popup=function(a){x?(b(c.WARNING,"show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"),
|
|
127
|
+
this.presentRatingWidgetWithID(a)):b(c.WARNING,"show_feedback_popup, window object is not available. Not showing feedback popup.")};this.presentRatingWidgetWithID=function(a){x?(b(c.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+a+" ]"),this.check_consent("star-rating")&&(K?b(c.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):ca("presentRatingWidgetWithID,",this.url+"/o/feedback/widget",{widget_id:a,av:f.app_version},function(d,
|
|
128
|
+
e,h){if(!d)try{var m=JSON.parse(h);W(m,!1)}catch(g){b(c.ERROR,"presentRatingWidgetWithID, JSON parse failed: "+g)}},!0))):b(c.WARNING,"presentRatingWidgetWithID, window object is not available. Not showing rating widget popup.")};this.initialize_feedback_popups=function(a){x?(b(c.WARNING,"initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"),this.initializeRatingWidgets(a)):b(c.WARNING,"initialize_feedback_popups, window object is not available. Not initializing feedback popups.")};
|
|
129
|
+
this.initializeRatingWidgets=function(a){if(x){if(b(c.INFO,"initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ "+a+"]"),this.check_consent("star-rating")){a||(a=y("cly_fb_widgets"));for(var d=document.getElementsByClassName("countly-feedback-sticker");0<d.length;)d[0].remove();ca("initializeRatingWidgets,",this.url+"/o/feedback/multiple-widgets-by-id",{widgets:JSON.stringify(a),av:f.app_version},function(e,h,m){if(!e)try{var g=JSON.parse(m);for(e=0;e<g.length;e++)if("true"===
|
|
130
|
+
g[e].is_active){var n=g[e].target_devices,r=Db();if(n[r])if("string"===typeof g[e].hide_sticker&&(g[e].hide_sticker="true"===g[e].hide_sticker),"all"!==g[e].target_page||g[e].hide_sticker){var v=g[e].target_pages;for(h=0;h<v.length;h++){var G=v[h].substr(0,v[h].length-1)===window.location.pathname.substr(0,v[h].length-1),N=v[h]===window.location.pathname;(v[h].includes("*")&&G||N)&&!g[e].hide_sticker&&W(g[e],!0)}}else W(g[e],!0)}}catch(J){b(c.ERROR,"initializeRatingWidgets, JSON parse error: "+J)}},
|
|
131
131
|
!0)}}else b(c.WARNING,"initializeRatingWidgets, window object is not available. Not initializing rating widgets.")};this.enable_feedback=function(a){x?(b(c.WARNING,"enable_feedback, Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"),this.enableRatingWidgets(a)):b(c.WARNING,"enable_feedback, window object is not available. Not enabling feedback.")};this.enableRatingWidgets=function(a){x?(b(c.INFO,"enableRatingWidgets, Enabling rating widget with params:",
|
|
132
|
-
a),this.check_consent("star-rating")&&(K?b(c.ERROR,"enableRatingWidgets, Cannot enable rating widgets in offline mode"):(w("cly_fb_widgets",a.popups||a.widgets),
|
|
133
|
-
b(c.WARNING,"enableRatingWidgets, window object is not available. Not enabling rating widgets.")};this.get_available_feedback_widgets=function(a){b(c.INFO,"get_available_feedback_widgets, Getting the feedback list, callback function is provided:["+!!a+"]");this.check_consent("feedback")?K?b(c.ERROR,"get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."):
|
|
132
|
+
a),this.check_consent("star-rating")&&(K?b(c.ERROR,"enableRatingWidgets, Cannot enable rating widgets in offline mode"):(w("cly_fb_widgets",a.popups||a.widgets),Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css"),a=a.popups||a.widgets,0<a.length?(document.body.insertAdjacentHTML("beforeend",'<div id="cfbg"></div>'),this.initializeRatingWidgets(a)):b(c.ERROR,"enableRatingWidgets, You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback")))):
|
|
133
|
+
b(c.WARNING,"enableRatingWidgets, window object is not available. Not enabling rating widgets.")};this.get_available_feedback_widgets=function(a){b(c.INFO,"get_available_feedback_widgets, Getting the feedback list, callback function is provided:["+!!a+"]");this.check_consent("feedback")?K?b(c.ERROR,"get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."):ca("get_available_feedback_widgets,",this.url+Ua,{method:"feedback",device_id:this.device_id,app_key:this.app_key,av:f.app_version},
|
|
134
134
|
function(d,e,h){if(d)a&&a(null,d);else try{var m=JSON.parse(h).result||[];a&&a(m,null)}catch(g){b(c.ERROR,"get_available_feedback_widgets, Error while parsing feedback widgets list: "+g),a&&a(null,g)}},!1):a&&a(null,Error("Consent for feedback not provided."))};this.getFeedbackWidgetData=function(a,d){if(a.type)if(b(c.INFO,"getFeedbackWidgetData, Retrieving data for: ["+JSON.stringify(a)+"], callback function is provided:["+!!d+"]"),this.check_consent("feedback"))if(K)b(c.ERROR,"getFeedbackWidgetData, Cannot enable feedback widgets in offline mode.");
|
|
135
|
-
else{var e=this.url,h={widget_id:a._id,shown:1,sdk_version:oa,sdk_name:va,platform:this.platform,app_version:this.app_version};if("nps"===a.type)e+="/o/surveys/nps/widget";else if("survey"===a.type)e+="/o/surveys/survey/widget";else if("rating"===a.type)e+="/o/surveys/rating/widget";else{b(c.ERROR,"getFeedbackWidgetData, Unknown type info: ["+a.type+"]");return}
|
|
136
|
-
|
|
137
|
-
var
|
|
135
|
+
else{var e=this.url,h={widget_id:a._id,shown:1,sdk_version:oa,sdk_name:va,platform:this.platform,app_version:this.app_version};if("nps"===a.type)e+="/o/surveys/nps/widget";else if("survey"===a.type)e+="/o/surveys/survey/widget";else if("rating"===a.type)e+="/o/surveys/rating/widget";else{b(c.ERROR,"getFeedbackWidgetData, Unknown type info: ["+a.type+"]");return}ca("getFeedbackWidgetData,",e,h,function(m,g,n){if(m)d&&d(null,m);else try{var r=JSON.parse(n);d&&d(r,null)}catch(v){b(c.ERROR,"getFeedbackWidgetData, Error while parsing feedback widgets list: "+
|
|
136
|
+
v),d&&d(null,v)}},!0)}else d&&d(null,Error("Consent for feedback not provided."));else b(c.ERROR,"getFeedbackWidgetData, Expected the provided widget object to have a type but got: ["+JSON.stringify(a)+"], aborting.")};this.present_feedback_widget=function(a,d,e,h){function m(B){document.getElementById("countly-surveys-wrapper-"+B._id).style.display="block";document.getElementById("csbg").style.display="block"}function g(B){if(!B.appearance.hideS){b(c.DEBUG,"present_feedback_widget, handling the sticker as it was not set to hidden");
|
|
137
|
+
var V=document.createElement("div");V.innerText=B.appearance.text;V.style.color=7>B.appearance.text_color.length?"#"+B.appearance.text_color:B.appearance.text_color;V.style.backgroundColor=7>B.appearance.bg_color.length?"#"+B.appearance.bg_color:B.appearance.bg_color;V.className="countly-feedback-sticker "+B.appearance.position+"-"+B.appearance.size;V.id="countly-feedback-sticker-"+B._id;document.body.appendChild(V);A(document.getElementById("countly-feedback-sticker-"+B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+
|
|
138
138
|
B._id).style.display="flex";document.getElementById("csbg").style.display="block"})}A(document.getElementById("countly-feedback-close-icon-"+B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+B._id).style.display="none";document.getElementById("csbg").style.display="none"})}if(x){if(b(c.INFO,"present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ "+d+" ] and className: [ "+e+" ]"),this.check_consent("feedback"))if(!a||"object"!==L(a)||
|
|
139
139
|
Array.isArray(a))b(c.ERROR,"present_feedback_widget, Please provide at least one feedback widget object.");else{b(c.INFO,"present_feedback_widget, Adding segmentation to feedback widgets:["+JSON.stringify(h)+"]");h&&"object"===L(h)&&0!==Object.keys(h).length||(b(c.DEBUG,"present_feedback_widget, Segmentation is not an object or empty"),h=null);try{var n=this.url;if("nps"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: nps."),n+="/feedback/nps";else if("survey"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: survey."),
|
|
140
|
-
n+="/feedback/survey";else if("rating"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: rating."),n+="/feedback/rating";else{b(c.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");return}var r=window.origin||window.location.origin;if("rating"===a.type){b(c.DEBUG,"present_feedback_widget, Loading css for rating widget.");var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"countly-"+
|
|
144
|
-
if("rating"===a.type){var yb=document.createElement("div");yb.className="countly-ratings-overlay";yb.id="countly-ratings-overlay-"+a._id;
|
|
145
|
-
{};try{
|
|
146
|
-
m(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||
|
|
147
|
-
document.body.scrollTop,document.documentElement.scrollTop),
|
|
140
|
+
n+="/feedback/survey";else if("rating"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: rating."),n+="/feedback/rating";else{b(c.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");return}var r=window.origin||window.location.origin;if("rating"===a.type){b(c.DEBUG,"present_feedback_widget, Loading css for rating widget.");var v="ratings";Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else b(c.DEBUG,"present_feedback_widget, Loading css for survey or nps."),
|
|
141
|
+
Sa(this.url+"/surveys/stylesheets/countly-surveys.css"),v="surveys";n+="?widget_id="+a._id;n+="&app_key="+this.app_key;n+="&device_id="+this.device_id;n+="&sdk_name="+va;n+="&platform="+this.platform;n+="&app_version="+this.app_version;n+="&sdk_version="+oa;var G={tc:1};h&&(G.sg=h);n+="&custom="+JSON.stringify(G);n+="&origin="+r;n+="&widget_v=web";var N=document.createElement("iframe");N.src=n;N.name="countly-"+v+"-iframe";N.id="countly-"+v+"-iframe";var J=!1;N.onload=function(){J&&(document.getElementById("countly-"+
|
|
142
|
+
v+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none");J=!0;b(c.DEBUG,"present_feedback_widget, Loaded iframe.")};for(var Fa=document.getElementById("csbg");Fa;)Fa.remove(),Fa=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var aa=document.getElementsByClassName("countly-"+v+"-wrapper");for(h=0;h<aa.length;h++)aa[h].remove(),b(c.DEBUG,"present_feedback_widget, Removed a wrapper.");aa=document.createElement("div");
|
|
143
|
+
aa.className="countly-"+v+"-wrapper";aa.id="countly-"+v+"-wrapper-"+a._id;"survey"===a.type&&(aa.className=aa.className+" "+a.appearance.position);var db=document.body;h=!1;d&&(document.getElementById(d)?(db=document.getElementById(d),h=!0):b(c.ERROR,"present_feedback_widget, Provided ID not found."));h||e&&(document.getElementsByClassName(e)[0]?db=document.getElementsByClassName(e)[0]:b(c.ERROR,"present_feedback_widget, Provided class not found."));db.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');
|
|
144
|
+
db.appendChild(aa);if("rating"===a.type){var yb=document.createElement("div");yb.className="countly-ratings-overlay";yb.id="countly-ratings-overlay-"+a._id;aa.appendChild(yb);b(c.DEBUG,"present_feedback_widget, appended the rating overlay to wrapper");A(document.getElementById("countly-ratings-overlay-"+a._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+a._id).style.display="none"})}aa.appendChild(N);b(c.DEBUG,"present_feedback_widget, Appended the iframe");A(window,"message",
|
|
145
|
+
function(B){var V={};try{V=JSON.parse(B.data),b(c.DEBUG,"present_feedback_widget, Parsed response message "+V)}catch($b){b(c.ERROR,"present_feedback_widget, Error while parsing message body "+$b)}V.close?(document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none"):b(c.DEBUG,"present_feedback_widget, Closing signal not sent yet")});if("survey"===a.type){var R=!1;switch(a.showPolicy){case "afterPageLoad":"complete"===document.readyState?
|
|
146
|
+
R||(R=!0,m(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||R||(R=!0,m(a))});break;case "afterConstantDelay":setTimeout(function(){R||(R=!0,m(a))},1E4);break;case "onAbandon":"complete"===document.readyState?A(document,"mouseleave",function(){R||(R=!0,m(a))}):A(document,"readystatechange",function(B){"complete"===B.target.readyState&&A(document,"mouseleave",function(){R||(R=!0,m(a))})});break;case "onScrollHalfwayDown":A(window,"scroll",function(){if(!R){var B=Math.max(window.scrollY,
|
|
147
|
+
document.body.scrollTop,document.documentElement.scrollTop),V=Ra();B>=V/2&&(R=!0,m(a))}});break;default:R||(R=!0,m(a))}}else if("nps"===a.type)document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="block",document.getElementById("csbg").style.display="block";else if("rating"===a.type){var eb=!1;"complete"===document.readyState?eb||(eb=!0,g(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||eb||(eb=!0,g(a))})}}catch(B){b(c.ERROR,"present_feedback_widget, Something went wrong while presenting the widget: "+
|
|
148
148
|
B)}}}else b(c.WARNING,"present_feedback_widget, window object is not available. Not presenting feedback widget.")};this.recordError=function(a,d,e){b(c.INFO,"recordError, Recording error");if(this.check_consent("crashes")&&a){e=e||ub;var h="";"object"===L(a)?"undefined"!==typeof a.stack?h=a.stack:("undefined"!==typeof a.name&&(h+=a.name+":"),"undefined"!==typeof a.message&&(h+=a.message+"\n"),"undefined"!==typeof a.fileName&&(h+="in "+a.fileName+"\n"),"undefined"!==typeof a.lineNumber&&(h+="on "+
|
|
149
|
-
a.lineNumber),"undefined"!==typeof a.columnNumber&&(h+=":"+a.columnNumber)):h=a+"";if(h.length>f.maxStackTraceLineLength*f.maxStackTraceLinesPerThread){b(c.DEBUG,"record_error, Error stack is too long will be truncated");a=h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;h<m;h++)a[h].length>f.maxStackTraceLineLength&&(a[h]=a[h].substring(0,f.maxStackTraceLineLength));h=a.join("\n")}d=!!d;a=
|
|
150
|
-
_error:h,_app_version:a._app_version,_run:F()-
|
|
151
|
-
b),h._custom=e);try{var g=document.createElement("canvas").getContext("experimental-webgl");h._opengl=g.getParameter(g.VERSION)}catch(n){b(c.ERROR,"Could not get the experimental-webgl context: "+n)}d={};d.crash=JSON.stringify(h);d.metrics=JSON.stringify({_ua:a._ua});
|
|
152
|
-
case "cly_event":
|
|
153
|
-
isResponseValid:sb,getInternalDeviceIdType:function(){return D},getMsTimestamp:
|
|
154
|
-
getToken:function(){var a=y("cly_token");
|
|
155
|
-
[]);
|
|
156
|
-
f.hcWarningCount);w(
|
|
157
|
-
p.q=p.q||[];p.onload=p.onload||[];p.CountlyClass=
|
|
158
|
-
p.getViewName=function(){return x?window.location.pathname:"web_worker"};p.getViewUrl=function(){return x?window.location.pathname:"web_worker"};p.getSearchQuery=function(){if(x)return window.location.search};p.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};x&&window.addEventListener("storage",function(k){var q=(k.key+"").split("/"),
|
|
149
|
+
a.lineNumber),"undefined"!==typeof a.columnNumber&&(h+=":"+a.columnNumber)):h=a+"";if(h.length>f.maxStackTraceLineLength*f.maxStackTraceLinesPerThread){b(c.DEBUG,"record_error, Error stack is too long will be truncated");a=h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;h<m;h++)a[h].length>f.maxStackTraceLineLength&&(a[h]=a[h].substring(0,f.maxStackTraceLineLength));h=a.join("\n")}d=!!d;a=Ta();h={_resolution:a._resolution,
|
|
150
|
+
_error:h,_app_version:a._app_version,_run:F()-Sb,_not_os_specific:!0,_javascript:!0};if(m=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)h._bat=Math.floor(100*m.level);"undefined"!==typeof navigator.onLine&&(h._online=!!navigator.onLine);x&&(h._background=!document.hasFocus());0<sa.length&&(h._logs=sa.join("\n"));sa=[];h._nonfatal=d;h._view=this.getViewName();"undefined"!==typeof e&&(e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"record_error",
|
|
151
|
+
b),h._custom=e);try{var g=document.createElement("canvas").getContext("experimental-webgl");h._opengl=g.getParameter(g.VERSION)}catch(n){b(c.ERROR,"Could not get the experimental-webgl context: "+n)}d={};d.crash=JSON.stringify(h);d.metrics=JSON.stringify({_ua:a._ua});P(d)}};this.onStorageChange=function(a,d){b(c.DEBUG,"onStorageChange, Applying storage changes for key:",a);b(c.DEBUG,"onStorageChange, Applying storage changes for value:",d);switch(a){case "cly_queue":H=f.deserialize(d||"[]");break;
|
|
152
|
+
case "cly_event":I=f.deserialize(d||"[]");break;case "cly_remote_configs":S=f.deserialize(d||"{}");break;case "cly_ignore":f.ignore_visitor=f.deserialize(d);break;case "cly_id":f.device_id=d;break;case "cly_id_type":D=f.deserialize(d)}};this._internals={store:w,getDocWidth:mb,getDocHeight:Ra,getViewportHeight:Fb,get_page_coord:lb,get_event_target:Qa,add_event_listener:A,createNewObjectFromProperties:za,truncateObject:ba,truncateSingleValue:z,stripTrailingSlash:ta,prepareParams:jb,sendXmlHttpRequest:Nb,
|
|
153
|
+
isResponseValid:sb,getInternalDeviceIdType:function(){return D},getMsTimestamp:hb,getTimestamp:F,isResponseValidBroad:rb,secureRandom:fb,log:b,calculateChecksum:Cb,checkIfLoggingIsOn:Ca,getMetrics:Ta,getUA:Mb,prepareRequest:Ea,generateUUID:gb,sendEventsForced:Q,isUUID:function(a){return/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-4[0-9a-fA-F]{3}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(a)},isReferrerUsable:qb,getId:pb,heartBeat:Wa,toRequestQueue:P,reportViewDuration:na,loadJS:Hb,loadCSS:Sa,getLastView:function(){return Y},
|
|
154
|
+
setToken:Qb,getToken:function(){var a=y("cly_token");T("cly_token");return a},showLoader:Ib,hideLoader:Jb,setValueInStorage:w,getValueFromStorage:y,removeValueFromStorage:T,add_cly_events:t,processScrollView:tb,processScroll:Pb,currentUserAgentString:ua,currentUserAgentDataString:kb,userAgentDeviceDetection:Db,userAgentSearchBotDetection:Eb,getRequestQueue:function(){return H},getEventQueue:function(){return I},sendFetchRequest:Ob,processAsyncQueue:wa,makeNetworkRequest:ca,clearQueue:function(){H=
|
|
155
|
+
[];w("cly_queue",[]);I=[];w("cly_event",[])},getLocalQueues:function(){return{eventQ:I,requestQ:H}}};var qa={sendInstantHCRequest:function(){var a=z(f.hcErrorMessage,1E3,"healthCheck",b);""!==a&&(a=JSON.stringify(a));a={hc:JSON.stringify({el:f.hcErrorCount,wl:f.hcWarningCount,sc:f.hcStatusCode,em:a}),metrics:JSON.stringify({_app_version:f.app_version})};Ea(a);ca("[healthCheck]",f.url+ob,a,function(d){d||qa.resetAndSaveCounters()},!0)},resetAndSaveCounters:function(){qa.resetCounters();w(U.errorCount,
|
|
156
|
+
f.hcErrorCount);w(U.warningCount,f.hcWarningCount);w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)},incrementErrorCount:function(){f.hcErrorCount++},incrementWarningCount:function(){f.hcWarningCount++},resetCounters:function(){f.hcErrorCount=0;f.hcWarningCount=0;f.hcStatusCode=-1;f.hcErrorMessage=""},saveRequestCounters:function(a,d){f.hcStatusCode=a;f.hcErrorMessage=d;w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)}};this.initialize()}),Vb=!0;p.features="apm attribution clicks crashes events feedback forms location remote-config scrolls sessions star-rating users views".split(" ");
|
|
157
|
+
p.q=p.q||[];p.onload=p.onload||[];p.CountlyClass=Ub;p.init=function(k){k=k||{};if(p.loadAPMScriptsAsync&&Vb)Vb=!1,Xb(k);else{var q=k.app_key||p.app_key;if(!p.i||!p.i[q]){k=new Ub(k);if(!p.i){p.i={};for(var t in k)p[t]=k[t]}p.i[q]=k}return p.i[q]}};p.serialize=function(k){"object"===L(k)&&(k=JSON.stringify(k));return k};p.deserialize=function(k){if(""===k)return k;try{k=JSON.parse(k)}catch(q){Ca()&&console.warn("[WARNING] [Countly] deserialize, Could not parse the file:["+k+"], error: "+q)}return k};
|
|
158
|
+
p.getViewName=function(){return x?window.location.pathname:"web_worker"};p.getViewUrl=function(){return x?window.location.pathname:"web_worker"};p.getSearchQuery=function(){if(x)return window.location.search};p.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};x&&window.addEventListener("storage",function(k){var q=(k.key+"").split("/"),t=q.pop();q=q.pop();if(p.i&&p.i[q])p.i[q].onStorageChange(t,k.newValue)});ma.default=p;Object.defineProperty(ma,"__esModule",{value:!0})});
|