@openreplay/tracker 18.0.10 → 18.0.11
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/dist/cjs/entry.js +53 -14
- package/dist/cjs/entry.js.map +1 -1
- package/dist/cjs/index.js +53 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/lib/entry.js +53 -14
- package/dist/lib/entry.js.map +1 -1
- package/dist/lib/index.js +53 -14
- package/dist/lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/index.js
CHANGED
|
@@ -1469,6 +1469,7 @@ const perf = IN_BROWSER && 'performance' in window && 'memory' in performance //
|
|
|
1469
1469
|
: { memory: {} };
|
|
1470
1470
|
const deviceMemory = IN_BROWSER ? (navigator.deviceMemory || 0) * 1024 : 0;
|
|
1471
1471
|
const jsHeapSizeLimit = perf.memory.jsHeapSizeLimit || 0;
|
|
1472
|
+
const PAUSED = -1;
|
|
1472
1473
|
function Performance (app, opts) {
|
|
1473
1474
|
const options = Object.assign({
|
|
1474
1475
|
capturePerformance: true,
|
|
@@ -1476,35 +1477,73 @@ function Performance (app, opts) {
|
|
|
1476
1477
|
if (!options.capturePerformance) {
|
|
1477
1478
|
return;
|
|
1478
1479
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1480
|
+
// Capture references up front so a third party that later replaces the global
|
|
1481
|
+
// (Sentry's browserApiErrors, polyfills, zones, ...) can't change which
|
|
1482
|
+
// implementation we drive the loop with mid-session.
|
|
1483
|
+
const raf = IN_BROWSER && typeof window.requestAnimationFrame === 'function'
|
|
1484
|
+
? window.requestAnimationFrame.bind(window)
|
|
1485
|
+
: null;
|
|
1486
|
+
const caf = IN_BROWSER && typeof window.cancelAnimationFrame === 'function'
|
|
1487
|
+
? window.cancelAnimationFrame.bind(window)
|
|
1488
|
+
: null;
|
|
1489
|
+
let running = false;
|
|
1490
|
+
let frames = 0;
|
|
1491
|
+
let ticks = 0;
|
|
1492
|
+
let rafHandle = null;
|
|
1493
|
+
let inFrame = false;
|
|
1494
|
+
const onFrame = () => {
|
|
1495
|
+
rafHandle = null;
|
|
1496
|
+
if (!running || frames === PAUSED) {
|
|
1483
1497
|
return;
|
|
1484
1498
|
}
|
|
1485
1499
|
frames++;
|
|
1486
|
-
|
|
1500
|
+
if (inFrame) {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
scheduleFrame();
|
|
1504
|
+
};
|
|
1505
|
+
const scheduleFrame = () => {
|
|
1506
|
+
if (!raf || rafHandle !== null) {
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
inFrame = true;
|
|
1510
|
+
rafHandle = raf(onFrame);
|
|
1511
|
+
inFrame = false;
|
|
1512
|
+
};
|
|
1513
|
+
const stopLoop = () => {
|
|
1514
|
+
if (rafHandle !== null && caf) {
|
|
1515
|
+
caf(rafHandle);
|
|
1516
|
+
}
|
|
1517
|
+
rafHandle = null;
|
|
1487
1518
|
};
|
|
1488
1519
|
app.ticker.attach(() => {
|
|
1489
|
-
if (
|
|
1520
|
+
if (!running || ticks === PAUSED) {
|
|
1490
1521
|
return;
|
|
1491
1522
|
}
|
|
1492
1523
|
ticks++;
|
|
1493
1524
|
}, 0, false);
|
|
1494
1525
|
const sendPerformanceTrack = () => {
|
|
1495
|
-
if (
|
|
1526
|
+
if (!running) {
|
|
1496
1527
|
return;
|
|
1497
1528
|
}
|
|
1498
1529
|
app.send(PerformanceTrack(frames, ticks, perf.memory.totalJSHeapSize || 0, perf.memory.usedJSHeapSize || 0));
|
|
1499
|
-
|
|
1530
|
+
if (document.hidden) {
|
|
1531
|
+
frames = ticks = PAUSED;
|
|
1532
|
+
}
|
|
1533
|
+
else {
|
|
1534
|
+
frames = ticks = 0;
|
|
1535
|
+
scheduleFrame();
|
|
1536
|
+
}
|
|
1500
1537
|
};
|
|
1501
1538
|
app.attachStartCallback(() => {
|
|
1502
|
-
|
|
1539
|
+
running = true;
|
|
1540
|
+
frames = ticks = PAUSED;
|
|
1503
1541
|
sendPerformanceTrack();
|
|
1504
|
-
nextFrame();
|
|
1505
1542
|
});
|
|
1506
1543
|
app.attachStopCallback(() => {
|
|
1507
|
-
|
|
1544
|
+
running = false;
|
|
1545
|
+
frames = ticks = 0;
|
|
1546
|
+
stopLoop();
|
|
1508
1547
|
});
|
|
1509
1548
|
app.ticker.attach(sendPerformanceTrack, 165, false);
|
|
1510
1549
|
if (document.hidden !== undefined) {
|
|
@@ -4009,7 +4048,7 @@ class App {
|
|
|
4009
4048
|
this.stopCallbacks = [];
|
|
4010
4049
|
this.commitCallbacks = [];
|
|
4011
4050
|
this.activityState = ActivityState.NotActive;
|
|
4012
|
-
this.version = '18.0.
|
|
4051
|
+
this.version = '18.0.11'; // TODO: version compatability check inside each plugin.
|
|
4013
4052
|
this.socketMode = false;
|
|
4014
4053
|
this.compressionThreshold = 24 * 1000;
|
|
4015
4054
|
this.bc = null;
|
|
@@ -9008,7 +9047,7 @@ class ConstantProperties {
|
|
|
9008
9047
|
user_id: this.user_id,
|
|
9009
9048
|
distinct_id: this.deviceId,
|
|
9010
9049
|
sdk_edition: 'web',
|
|
9011
|
-
sdk_version: '18.0.
|
|
9050
|
+
sdk_version: '18.0.11',
|
|
9012
9051
|
timezone: getUTCOffsetString(),
|
|
9013
9052
|
search_engine: this.searchEngine,
|
|
9014
9053
|
};
|
|
@@ -9710,7 +9749,7 @@ class API {
|
|
|
9710
9749
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9711
9750
|
const doNotTrack = this.checkDoNotTrack();
|
|
9712
9751
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9713
|
-
trackerVersion: '18.0.
|
|
9752
|
+
trackerVersion: '18.0.11',
|
|
9714
9753
|
projectKey: this.options.projectKey,
|
|
9715
9754
|
doNotTrack,
|
|
9716
9755
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|