clarity-js 0.7.48 → 0.7.50
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/build/clarity.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +84 -56
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +84 -56
- package/build/clarity.performance.js +1 -1
- package/package.json +1 -1
- package/src/core/version.ts +1 -1
- package/src/data/consent.ts +21 -0
- package/src/data/metadata.ts +11 -1
- package/src/data/upgrade.ts +1 -0
- package/src/data/upload.ts +4 -1
- package/src/interaction/encode.ts +1 -0
- package/src/interaction/pointer.ts +6 -1
- package/types/data.d.ts +14 -3
- package/types/interaction.d.ts +1 -0
package/build/clarity.js
CHANGED
|
@@ -40,6 +40,7 @@ var dimension = /*#__PURE__*/Object.freeze({
|
|
|
40
40
|
});
|
|
41
41
|
var metadata$1 = /*#__PURE__*/Object.freeze({
|
|
42
42
|
__proto__: null,
|
|
43
|
+
get callback () { return callback; },
|
|
43
44
|
get callbacks () { return callbacks; },
|
|
44
45
|
get clear () { return clear; },
|
|
45
46
|
get consent () { return consent; },
|
|
@@ -114,7 +115,7 @@ function process$7() {
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
var config$
|
|
118
|
+
var config$2 = {
|
|
118
119
|
projectId: null,
|
|
119
120
|
delay: 1 * 1000 /* Time.Second */,
|
|
120
121
|
lean: false,
|
|
@@ -164,7 +165,7 @@ function stop$F() {
|
|
|
164
165
|
startTime = 0;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
var version$1 = "0.7.
|
|
168
|
+
var version$1 = "0.7.50";
|
|
168
169
|
|
|
169
170
|
// tslint:disable: no-bitwise
|
|
170
171
|
function hash (input, precision) {
|
|
@@ -275,7 +276,7 @@ function url$1(input, electron) {
|
|
|
275
276
|
if (electron) {
|
|
276
277
|
return "".concat("https://" /* Data.Constant.HTTPS */).concat("Electron" /* Data.Constant.Electron */);
|
|
277
278
|
}
|
|
278
|
-
var drop = config$
|
|
279
|
+
var drop = config$2.drop;
|
|
279
280
|
if (drop && drop.length > 0 && input && input.indexOf("?") > 0) {
|
|
280
281
|
var _a = input.split("?"), path = _a[0], query = _a[1];
|
|
281
282
|
var swap_1 = "*na*" /* Data.Constant.Dropped */;
|
|
@@ -621,8 +622,8 @@ var summary = /*#__PURE__*/Object.freeze({
|
|
|
621
622
|
|
|
622
623
|
var data$f = null;
|
|
623
624
|
function start$D() {
|
|
624
|
-
if (!config$
|
|
625
|
-
config$
|
|
625
|
+
if (!config$2.lean && config$2.upgrade) {
|
|
626
|
+
config$2.upgrade("Config" /* Constant.Config */);
|
|
626
627
|
}
|
|
627
628
|
data$f = null;
|
|
628
629
|
}
|
|
@@ -632,14 +633,15 @@ function start$D() {
|
|
|
632
633
|
// and send all backed up layout events to the server.
|
|
633
634
|
function upgrade(key) {
|
|
634
635
|
// Upgrade only if Clarity was successfully activated on the page
|
|
635
|
-
if (active() && config$
|
|
636
|
-
config$
|
|
636
|
+
if (active() && config$2.lean) {
|
|
637
|
+
config$2.lean = false;
|
|
637
638
|
data$f = { key: key };
|
|
638
639
|
// Update metadata to track we have upgraded this session
|
|
640
|
+
callback();
|
|
639
641
|
save();
|
|
640
642
|
// Callback upgrade handler, if configured
|
|
641
|
-
if (config$
|
|
642
|
-
config$
|
|
643
|
+
if (config$2.upgrade) {
|
|
644
|
+
config$2.upgrade(key);
|
|
643
645
|
}
|
|
644
646
|
encode$1(3 /* Event.Upgrade */);
|
|
645
647
|
}
|
|
@@ -941,8 +943,8 @@ function start$A() {
|
|
|
941
943
|
}
|
|
942
944
|
function check$4(id, target, input) {
|
|
943
945
|
// Compute hash for fraud detection, if enabled. Hash is computed only if input meets the minimum length criteria
|
|
944
|
-
if (config$
|
|
945
|
-
data$d = { id: id, target: target, checksum: hash(input,
|
|
946
|
+
if (config$2.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
|
|
947
|
+
data$d = { id: id, target: target, checksum: hash(input, 28 /* Setting.ChecksumPrecision */) };
|
|
946
948
|
// Only encode this event if we haven't already reported this hash
|
|
947
949
|
if (history$5.indexOf(data$d.checksum) < 0) {
|
|
948
950
|
history$5.push(data$d.checksum);
|
|
@@ -1095,14 +1097,14 @@ function parse$1(root, init) {
|
|
|
1095
1097
|
try {
|
|
1096
1098
|
// Parse unmask configuration into separate query selectors and override tokens as part of initialization
|
|
1097
1099
|
if (init) {
|
|
1098
|
-
config$
|
|
1100
|
+
config$2.unmask.forEach(function (x) { return x.indexOf("!" /* Constant.Bang */) < 0 ? unmask.push(x) : override.push(x.substr(1)); });
|
|
1099
1101
|
}
|
|
1100
1102
|
// Since mutations may happen on leaf nodes too, e.g. text nodes, which may not support all selector APIs.
|
|
1101
1103
|
// We ensure that the root note supports querySelectorAll API before executing the code below to identify new regions.
|
|
1102
1104
|
if ("querySelectorAll" in root) {
|
|
1103
|
-
config$
|
|
1104
|
-
config$
|
|
1105
|
-
config$
|
|
1105
|
+
config$2.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
|
|
1106
|
+
config$2.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* Privacy.TextImage */); }); }); // Masked Elements
|
|
1107
|
+
config$2.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
|
|
1106
1108
|
unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* Privacy.None */); }); }); // Unmasked Elements
|
|
1107
1109
|
}
|
|
1108
1110
|
}
|
|
@@ -1129,7 +1131,7 @@ function add(node, parent, data, source) {
|
|
|
1129
1131
|
var parentValue = null;
|
|
1130
1132
|
var regionId = exists(node) ? id : null;
|
|
1131
1133
|
var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
|
|
1132
|
-
var privacyId = config$
|
|
1134
|
+
var privacyId = config$2.content ? 1 /* Privacy.Sensitive */ : 3 /* Privacy.TextImage */;
|
|
1133
1135
|
if (parentId >= 0 && values[parentId]) {
|
|
1134
1136
|
parentValue = values[parentId];
|
|
1135
1137
|
parentValue.children.push(id);
|
|
@@ -1528,7 +1530,7 @@ function state$a(timer) {
|
|
|
1528
1530
|
return 2 /* Task.Stop */;
|
|
1529
1531
|
}
|
|
1530
1532
|
function start$y(timer) {
|
|
1531
|
-
tracker[key(timer)] = { start: performance.now(), calls: 0, yield: config$
|
|
1533
|
+
tracker[key(timer)] = { start: performance.now(), calls: 0, yield: config$2.longTask };
|
|
1532
1534
|
}
|
|
1533
1535
|
function restart$2(timer) {
|
|
1534
1536
|
var id = key(timer);
|
|
@@ -1614,14 +1616,14 @@ function requestIdleCallbackPolyfill(callback, options) {
|
|
|
1614
1616
|
var currentTime = performance.now();
|
|
1615
1617
|
var elapsed = currentTime - startTime;
|
|
1616
1618
|
var duration = currentTime - event.data;
|
|
1617
|
-
if (duration > config$
|
|
1619
|
+
if (duration > config$2.longTask && elapsed < options.timeout) {
|
|
1618
1620
|
requestAnimationFrame(function () { outgoing.postMessage(currentTime); });
|
|
1619
1621
|
}
|
|
1620
1622
|
else {
|
|
1621
1623
|
var didTimeout_1 = elapsed > options.timeout;
|
|
1622
1624
|
callback({
|
|
1623
1625
|
didTimeout: didTimeout_1,
|
|
1624
|
-
timeRemaining: function () { return didTimeout_1 ? config$
|
|
1626
|
+
timeRemaining: function () { return didTimeout_1 ? config$2.longTask : Math.max(0, config$2.longTask - duration); }
|
|
1625
1627
|
});
|
|
1626
1628
|
}
|
|
1627
1629
|
};
|
|
@@ -1718,7 +1720,7 @@ function recompute$8(evt) {
|
|
|
1718
1720
|
var element = target(evt);
|
|
1719
1721
|
if (element) {
|
|
1720
1722
|
var value = element.value;
|
|
1721
|
-
var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$
|
|
1723
|
+
var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$2.fraud && "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.indexOf(element.type) === -1 ? hash(value, 28 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
|
|
1722
1724
|
state$9.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
|
|
1723
1725
|
schedule$1(encode$3.bind(this, 42 /* Event.Change */));
|
|
1724
1726
|
}
|
|
@@ -1981,9 +1983,13 @@ function touch(event, root, evt) {
|
|
|
1981
1983
|
var y = "clientY" in entry ? Math.round(entry["clientY"] + d.scrollTop) : null;
|
|
1982
1984
|
x = x && frame ? x + Math.round(frame.offsetLeft) : x;
|
|
1983
1985
|
y = y && frame ? y + Math.round(frame.offsetTop) : y;
|
|
1986
|
+
// identifier is 0-based, unique for each touch point and resets when all fingers are lifted
|
|
1987
|
+
// that is not a part of the spec, but it is how it is implemented in browsers
|
|
1988
|
+
// tested in Chromium-based browsers as well as Firefox
|
|
1989
|
+
var id = "identifier" in entry ? entry["identifier"] : undefined;
|
|
1984
1990
|
// Check for null values before processing this event
|
|
1985
1991
|
if (x !== null && y !== null) {
|
|
1986
|
-
handler$2({ time: t, event: event, data: { target: target(evt), x: x, y: y } });
|
|
1992
|
+
handler$2({ time: t, event: event, data: { target: target(evt), x: x, y: y, id: id } });
|
|
1987
1993
|
}
|
|
1988
1994
|
}
|
|
1989
1995
|
}
|
|
@@ -2501,7 +2507,7 @@ function process$2() {
|
|
|
2501
2507
|
return [3 /*break*/, 6];
|
|
2502
2508
|
}
|
|
2503
2509
|
target = mutation.target;
|
|
2504
|
-
type = config$
|
|
2510
|
+
type = config$2.throttleDom ? track$5(mutation, timer, instance, record.time) : mutation.type;
|
|
2505
2511
|
if (type && target && target.ownerDocument) {
|
|
2506
2512
|
parse$1(target.ownerDocument);
|
|
2507
2513
|
}
|
|
@@ -3361,7 +3367,7 @@ function encode$4 (type, timer, ts) {
|
|
|
3361
3367
|
if (type === 6 /* Event.Mutation */) {
|
|
3362
3368
|
activity(eventTime);
|
|
3363
3369
|
}
|
|
3364
|
-
queue(tokenize(tokens), !config$
|
|
3370
|
+
queue(tokenize(tokens), !config$2.lean);
|
|
3365
3371
|
_l.label = 11;
|
|
3366
3372
|
case 11: return [3 /*break*/, 12];
|
|
3367
3373
|
case 12: return [2 /*return*/];
|
|
@@ -3588,6 +3594,9 @@ function encode$3 (type, ts) {
|
|
|
3588
3594
|
tokens.push(pTarget.id);
|
|
3589
3595
|
tokens.push(entry.data.x);
|
|
3590
3596
|
tokens.push(entry.data.y);
|
|
3597
|
+
if (entry.data.id !== undefined) {
|
|
3598
|
+
tokens.push(entry.data.id);
|
|
3599
|
+
}
|
|
3591
3600
|
queue(tokens);
|
|
3592
3601
|
track$8(entry.event, entry.data.x, entry.data.y);
|
|
3593
3602
|
}
|
|
@@ -3878,7 +3887,7 @@ function upload(final) {
|
|
|
3878
3887
|
switch (_b.label) {
|
|
3879
3888
|
case 0:
|
|
3880
3889
|
timeout = null;
|
|
3881
|
-
sendPlaybackBytes = config$
|
|
3890
|
+
sendPlaybackBytes = config$2.lean === false && playbackBytes > 0 && (playbackBytes < 1048576 /* Setting.MaxFirstPayloadBytes */ || data$1.sequence > 0);
|
|
3882
3891
|
if (sendPlaybackBytes) {
|
|
3883
3892
|
max(1 /* Metric.Playback */, 1 /* BooleanFlag.True */);
|
|
3884
3893
|
}
|
|
@@ -3923,8 +3932,8 @@ function stringify(encoded) {
|
|
|
3923
3932
|
function send(payload, zipped, sequence, beacon) {
|
|
3924
3933
|
if (beacon === void 0) { beacon = false; }
|
|
3925
3934
|
// Upload data if a valid URL is defined in the config
|
|
3926
|
-
if (typeof config$
|
|
3927
|
-
var url_1 = config$
|
|
3935
|
+
if (typeof config$2.upload === "string" /* Constant.String */) {
|
|
3936
|
+
var url_1 = config$2.upload;
|
|
3928
3937
|
var dispatched = false;
|
|
3929
3938
|
// If it's the last payload, attempt to upload using sendBeacon first.
|
|
3930
3939
|
// The advantage to using sendBeacon is that browser can decide to upload asynchronously, improving chances of success
|
|
@@ -3973,8 +3982,8 @@ function send(payload, zipped, sequence, beacon) {
|
|
|
3973
3982
|
}
|
|
3974
3983
|
}
|
|
3975
3984
|
}
|
|
3976
|
-
else if (config$
|
|
3977
|
-
var callback = config$
|
|
3985
|
+
else if (config$2.upload) {
|
|
3986
|
+
var callback = config$2.upload;
|
|
3978
3987
|
callback(payload);
|
|
3979
3988
|
done(sequence);
|
|
3980
3989
|
}
|
|
@@ -3996,7 +4005,7 @@ function check$3(xhr, sequence) {
|
|
|
3996
4005
|
// 2: Safari will terminate pending XHR requests with status code 0 if the user navigates away from the page
|
|
3997
4006
|
// In any case, we switch the upload URL to fallback configuration (if available) before re-trying one more time
|
|
3998
4007
|
if (xhr.status === 0) {
|
|
3999
|
-
config$
|
|
4008
|
+
config$2.upload = config$2.fallback ? config$2.fallback : config$2.upload;
|
|
4000
4009
|
}
|
|
4001
4010
|
// In all other cases, re-attempt sending the same data
|
|
4002
4011
|
// For retry we always fallback to string payload, even though we may have attempted
|
|
@@ -4034,13 +4043,14 @@ function done(sequence) {
|
|
|
4034
4043
|
// If we everything went successfully, and it is the first sequence, save this session for future reference
|
|
4035
4044
|
if (sequence === 1) {
|
|
4036
4045
|
save();
|
|
4046
|
+
callback();
|
|
4037
4047
|
}
|
|
4038
4048
|
}
|
|
4039
4049
|
function delay() {
|
|
4040
4050
|
// Progressively increase delay as we continue to send more payloads from the client to the server
|
|
4041
4051
|
// If we are not uploading data to a server, and instead invoking UploadCallback, in that case keep returning configured value
|
|
4042
|
-
var gap = config$
|
|
4043
|
-
return typeof config$
|
|
4052
|
+
var gap = config$2.lean === false && discoverBytes > 0 ? 100 /* Setting.MinUploadDelay */ : data$1.sequence * config$2.delay;
|
|
4053
|
+
return typeof config$2.upload === "string" /* Constant.String */ ? Math.max(Math.min(gap, 30000 /* Setting.MaxUploadDelay */), 100 /* Setting.MinUploadDelay */) : config$2.delay;
|
|
4044
4054
|
}
|
|
4045
4055
|
function response(payload) {
|
|
4046
4056
|
var lines = payload && payload.length > 0 ? payload.split("\n") : [];
|
|
@@ -4058,8 +4068,8 @@ function response(payload) {
|
|
|
4058
4068
|
break;
|
|
4059
4069
|
case "ACTION" /* Constant.Action */:
|
|
4060
4070
|
// Invoke action callback, if configured and has a valid value
|
|
4061
|
-
if (config$
|
|
4062
|
-
config$
|
|
4071
|
+
if (config$2.action && parts.length > 1) {
|
|
4072
|
+
config$2.action(parts[1]);
|
|
4063
4073
|
}
|
|
4064
4074
|
break;
|
|
4065
4075
|
case "EXTRACT" /* Constant.Extract */:
|
|
@@ -4542,6 +4552,17 @@ function reset$3() {
|
|
|
4542
4552
|
updates = {};
|
|
4543
4553
|
}
|
|
4544
4554
|
|
|
4555
|
+
function config$1(track) {
|
|
4556
|
+
trackConsent(track ? 1 /* ConsentType.Implicit */ : 0 /* ConsentType.None */);
|
|
4557
|
+
}
|
|
4558
|
+
// When we get consent signal as false, we restart the service and track config as false.
|
|
4559
|
+
function consent$1() {
|
|
4560
|
+
trackConsent(2 /* ConsentType.General */);
|
|
4561
|
+
}
|
|
4562
|
+
function trackConsent(consent) {
|
|
4563
|
+
log(36 /* Dimension.Consent */, consent.toString());
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4545
4566
|
var data$2 = null;
|
|
4546
4567
|
var callbacks = [];
|
|
4547
4568
|
var electron = 0 /* BooleanFlag.False */;
|
|
@@ -4558,11 +4579,11 @@ function start$9() {
|
|
|
4558
4579
|
// Populate ids for this page
|
|
4559
4580
|
var s = session();
|
|
4560
4581
|
var u = user();
|
|
4561
|
-
var projectId = config$
|
|
4582
|
+
var projectId = config$2.projectId || hash(location.host);
|
|
4562
4583
|
data$2 = { projectId: projectId, userId: u.id, sessionId: s.session, pageNum: s.count };
|
|
4563
4584
|
// Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
|
|
4564
|
-
config$
|
|
4565
|
-
config$
|
|
4585
|
+
config$2.lean = config$2.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$2.lean;
|
|
4586
|
+
config$2.upload = config$2.track && typeof config$2.upload === "string" /* Constant.String */ && s.upload && s.upload.length > "https://" /* Constant.HTTPS */.length ? s.upload : config$2.upload;
|
|
4566
4587
|
// Log page metadata as dimensions
|
|
4567
4588
|
log(0 /* Dimension.UserAgent */, ua);
|
|
4568
4589
|
log(3 /* Dimension.PageTitle */, title);
|
|
@@ -4595,13 +4616,15 @@ function start$9() {
|
|
|
4595
4616
|
max(16 /* Metric.ColorDepth */, Math.round(screen.colorDepth));
|
|
4596
4617
|
}
|
|
4597
4618
|
// Read cookies specified in configuration
|
|
4598
|
-
for (var _i = 0, _d = config$
|
|
4619
|
+
for (var _i = 0, _d = config$2.cookies; _i < _d.length; _i++) {
|
|
4599
4620
|
var key = _d[_i];
|
|
4600
4621
|
var value = getCookie(key);
|
|
4601
4622
|
if (value) {
|
|
4602
4623
|
set(key, value);
|
|
4603
4624
|
}
|
|
4604
4625
|
}
|
|
4626
|
+
// Track consent config
|
|
4627
|
+
config$1(config$2.track);
|
|
4605
4628
|
// Track ids using a cookie if configuration allows it
|
|
4606
4629
|
track(u);
|
|
4607
4630
|
}
|
|
@@ -4629,14 +4652,14 @@ function stop$8() {
|
|
|
4629
4652
|
function metadata(cb, wait, recall) {
|
|
4630
4653
|
if (wait === void 0) { wait = true; }
|
|
4631
4654
|
if (recall === void 0) { recall = false; }
|
|
4632
|
-
var upgraded = config$
|
|
4655
|
+
var upgraded = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
|
|
4633
4656
|
var called = false;
|
|
4634
4657
|
// if caller hasn't specified that they want to skip waiting for upgrade but we've already upgraded, we need to
|
|
4635
4658
|
// directly execute the callback in addition to adding to our list as we only process callbacks at the moment
|
|
4636
4659
|
// we go through the upgrading flow.
|
|
4637
4660
|
if (data$2 && (upgraded || wait === false)) {
|
|
4638
4661
|
// Immediately invoke the callback if the caller explicitly doesn't want to wait for the upgrade confirmation
|
|
4639
|
-
cb(data$2, !config$
|
|
4662
|
+
cb(data$2, !config$2.lean);
|
|
4640
4663
|
called = true;
|
|
4641
4664
|
}
|
|
4642
4665
|
if (recall || !called) {
|
|
@@ -4649,7 +4672,7 @@ function id() {
|
|
|
4649
4672
|
function consent(status) {
|
|
4650
4673
|
if (status === void 0) { status = true; }
|
|
4651
4674
|
if (!status) {
|
|
4652
|
-
config$
|
|
4675
|
+
config$2.track = false;
|
|
4653
4676
|
setCookie("_clsk" /* Constant.SessionKey */, "" /* Constant.Empty */, -Number.MAX_VALUE);
|
|
4654
4677
|
setCookie("_clck" /* Constant.CookieKey */, "" /* Constant.Empty */, -Number.MAX_VALUE);
|
|
4655
4678
|
stop();
|
|
@@ -4657,8 +4680,10 @@ function consent(status) {
|
|
|
4657
4680
|
return;
|
|
4658
4681
|
}
|
|
4659
4682
|
if (active()) {
|
|
4660
|
-
config$
|
|
4683
|
+
config$2.track = true;
|
|
4661
4684
|
track(user(), 1 /* BooleanFlag.True */);
|
|
4685
|
+
save();
|
|
4686
|
+
consent$1();
|
|
4662
4687
|
}
|
|
4663
4688
|
}
|
|
4664
4689
|
function clear() {
|
|
@@ -4667,20 +4692,23 @@ function clear() {
|
|
|
4667
4692
|
}
|
|
4668
4693
|
function tab() {
|
|
4669
4694
|
var id = shortid();
|
|
4670
|
-
if (config$
|
|
4695
|
+
if (config$2.track && supported(window, "sessionStorage" /* Constant.SessionStorage */)) {
|
|
4671
4696
|
var value = sessionStorage.getItem("_cltk" /* Constant.TabKey */);
|
|
4672
4697
|
id = value ? value : id;
|
|
4673
4698
|
sessionStorage.setItem("_cltk" /* Constant.TabKey */, id);
|
|
4674
4699
|
}
|
|
4675
4700
|
return id;
|
|
4676
4701
|
}
|
|
4702
|
+
function callback() {
|
|
4703
|
+
var upgrade = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
|
|
4704
|
+
processCallback(upgrade);
|
|
4705
|
+
}
|
|
4677
4706
|
function save() {
|
|
4678
4707
|
if (!data$2)
|
|
4679
4708
|
return;
|
|
4680
4709
|
var ts = Math.round(Date.now());
|
|
4681
|
-
var upload = config$
|
|
4682
|
-
var upgrade = config$
|
|
4683
|
-
processCallback(upgrade);
|
|
4710
|
+
var upload = config$2.upload && typeof config$2.upload === "string" /* Constant.String */ ? config$2.upload.replace("https://" /* Constant.HTTPS */, "" /* Constant.Empty */) : "" /* Constant.Empty */;
|
|
4711
|
+
var upgrade = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
|
|
4684
4712
|
setCookie("_clsk" /* Constant.SessionKey */, [data$2.sessionId, ts, data$2.pageNum, upgrade, upload].join("|" /* Constant.Pipe */), 1 /* Setting.SessionExpire */);
|
|
4685
4713
|
}
|
|
4686
4714
|
function processCallback(upgrade) {
|
|
@@ -4688,7 +4716,7 @@ function processCallback(upgrade) {
|
|
|
4688
4716
|
for (var i = 0; i < callbacks.length; i++) {
|
|
4689
4717
|
var cb = callbacks[i];
|
|
4690
4718
|
if (cb.callback && !cb.called && (!cb.wait || upgrade)) {
|
|
4691
|
-
cb.callback(data$2, !config$
|
|
4719
|
+
cb.callback(data$2, !config$2.lean);
|
|
4692
4720
|
cb.called = true;
|
|
4693
4721
|
if (!cb.recall) {
|
|
4694
4722
|
callbacks.splice(i, 1);
|
|
@@ -4714,7 +4742,7 @@ function track(u, consent) {
|
|
|
4714
4742
|
// E.g. Math.ceil(1628735962643 / (24*60*60*1000)) => 18852 (days) => ejo in base36 (13 bytes => 3 bytes)
|
|
4715
4743
|
var end = Math.ceil((Date.now() + (365 /* Setting.Expire */ * 86400000 /* Time.Day */)) / 86400000 /* Time.Day */);
|
|
4716
4744
|
// If DOB is not set in the user object, use the date set in the config as a DOB
|
|
4717
|
-
var dob = u.dob === 0 ? (config$
|
|
4745
|
+
var dob = u.dob === 0 ? (config$2.dob === null ? 0 : config$2.dob) : u.dob;
|
|
4718
4746
|
// To avoid cookie churn, write user id cookie only once every day
|
|
4719
4747
|
if (u.expiry === null || Math.abs(end - u.expiry) >= 1 /* Setting.CookieInterval */ || u.consent !== consent || u.dob !== dob) {
|
|
4720
4748
|
var cookieParts = [data$2.userId, 2 /* Setting.CookieVersion */, end.toString(36), consent, dob];
|
|
@@ -4786,9 +4814,9 @@ function user() {
|
|
|
4786
4814
|
output.dob = num(parts[4]);
|
|
4787
4815
|
}
|
|
4788
4816
|
// Set track configuration to true for this user if we have explicit consent, regardless of project setting
|
|
4789
|
-
config$
|
|
4817
|
+
config$2.track = config$2.track || output.consent === 1 /* BooleanFlag.True */;
|
|
4790
4818
|
// Get user id from cookie only if we tracking is enabled, otherwise fallback to a random id
|
|
4791
|
-
output.id = config$
|
|
4819
|
+
output.id = config$2.track ? parts[0] : output.id;
|
|
4792
4820
|
}
|
|
4793
4821
|
return output;
|
|
4794
4822
|
}
|
|
@@ -4832,7 +4860,7 @@ function encodeCookieValue(value) {
|
|
|
4832
4860
|
function setCookie(key, value, time) {
|
|
4833
4861
|
// only write cookies if we are currently in a cookie writing mode (and they are supported)
|
|
4834
4862
|
// OR if we are trying to write an empty cookie (i.e. clear the cookie value out)
|
|
4835
|
-
if ((config$
|
|
4863
|
+
if ((config$2.track || value == "" /* Constant.Empty */) && ((navigator && navigator.cookieEnabled) || supported(document, "cookie" /* Constant.Cookie */))) {
|
|
4836
4864
|
// Some browsers automatically url encode cookie values if they are not url encoded.
|
|
4837
4865
|
// We therefore encode and decode cookie values ourselves.
|
|
4838
4866
|
var encodedValue = encodeCookieValue(value);
|
|
@@ -4919,7 +4947,7 @@ function reset$2() {
|
|
|
4919
4947
|
function report(e) {
|
|
4920
4948
|
// Do not report the same message twice for the same page
|
|
4921
4949
|
if (history$1 && history$1.indexOf(e.message) === -1) {
|
|
4922
|
-
var url = config$
|
|
4950
|
+
var url = config$2.report;
|
|
4923
4951
|
if (url && url.length > 0) {
|
|
4924
4952
|
var payload = { v: data$1.version, p: data$1.projectId, u: data$1.userId, s: data$1.sessionId, n: data$1.pageNum };
|
|
4925
4953
|
if (e.message) {
|
|
@@ -4951,7 +4979,7 @@ function measure (method) {
|
|
|
4951
4979
|
}
|
|
4952
4980
|
var duration = performance.now() - start;
|
|
4953
4981
|
sum(4 /* Metric.TotalCost */, duration);
|
|
4954
|
-
if (duration > config$
|
|
4982
|
+
if (duration > config$2.longTask) {
|
|
4955
4983
|
count$1(7 /* Metric.LongTaskCount */);
|
|
4956
4984
|
max(6 /* Metric.ThreadBlockedTime */, duration);
|
|
4957
4985
|
}
|
|
@@ -5081,8 +5109,8 @@ function config(override) {
|
|
|
5081
5109
|
return false;
|
|
5082
5110
|
}
|
|
5083
5111
|
for (var key in override) {
|
|
5084
|
-
if (key in config$
|
|
5085
|
-
config$
|
|
5112
|
+
if (key in config$2) {
|
|
5113
|
+
config$2[key] = override[key];
|
|
5086
5114
|
}
|
|
5087
5115
|
}
|
|
5088
5116
|
return true;
|
|
@@ -5159,7 +5187,7 @@ function start$3() {
|
|
|
5159
5187
|
start$x();
|
|
5160
5188
|
start$h();
|
|
5161
5189
|
start$z();
|
|
5162
|
-
if (config$
|
|
5190
|
+
if (config$2.delayDom) {
|
|
5163
5191
|
// Lazy load layout module as part of page load time performance improvements experiment
|
|
5164
5192
|
bind(window, 'load', function () {
|
|
5165
5193
|
start$k();
|
|
@@ -5312,7 +5340,7 @@ function process(entries) {
|
|
|
5312
5340
|
case "resource" /* Constant.Resource */:
|
|
5313
5341
|
var name_1 = entry.name;
|
|
5314
5342
|
log(4 /* Dimension.NetworkHosts */, host(name_1));
|
|
5315
|
-
if (name_1 === config$
|
|
5343
|
+
if (name_1 === config$2.upload || name_1 === config$2.fallback) {
|
|
5316
5344
|
max(28 /* Metric.UploadTime */, entry.duration);
|
|
5317
5345
|
}
|
|
5318
5346
|
break;
|