@atlaskit/react-ufo 3.12.2 → 3.12.3

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#155959](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/155959)
8
+ [`eeaa8485061ce`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eeaa8485061ce) -
9
+ Add further error handling to CPU monitoring logic
10
+
3
11
  ## 3.12.2
4
12
 
5
13
  ### Patch Changes
@@ -23,49 +23,54 @@ function removeOldBufferRecords(filter) {
23
23
  });
24
24
  }
25
25
  function createPressureStateReport(start, end) {
26
- // To differentiate between the API not available, vs no PressureRecords added
27
- if (!('PressureObserver' in globalThis)) {
26
+ try {
27
+ // To differentiate between the API not available, vs no PressureRecords added
28
+ if (!('PressureObserver' in globalThis)) {
29
+ return null;
30
+ }
31
+ var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
32
+ var time = _ref2.time,
33
+ state = _ref2.state;
34
+ if (time >= start && time <= end) {
35
+ pressureReport[state] += 1;
36
+ }
37
+ return pressureReport;
38
+ }, {
39
+ nominal: 0,
40
+ fair: 0,
41
+ serious: 0,
42
+ critical: 0
43
+ });
44
+ var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
45
+ return total + count;
46
+ }) || 1;
47
+ removeOldBufferRecords(end);
48
+ return {
49
+ count: pressureStateCount,
50
+ percentage: {
51
+ nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
52
+ fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
53
+ serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
54
+ critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
55
+ }
56
+ };
57
+ } catch (_unused) {
28
58
  return null;
29
59
  }
30
- var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
31
- var time = _ref2.time,
32
- state = _ref2.state;
33
- if (time >= start && time <= end) {
34
- pressureReport[state] += 1;
35
- }
36
- return pressureReport;
37
- }, {
38
- nominal: 0,
39
- fair: 0,
40
- serious: 0,
41
- critical: 0
42
- });
43
- var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
44
- return total + count;
45
- }) || 1;
46
- removeOldBufferRecords(end);
47
- return {
48
- count: pressureStateCount,
49
- percentage: {
50
- nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
51
- fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
52
- serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
53
- critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
54
- }
55
- };
56
60
  }
57
61
  function initialisePressureObserver() {
58
62
  try {
59
63
  if ('PressureObserver' in globalThis) {
64
+ var _pressureObserver$obs;
60
65
  pressureObserver = new PressureObserver(function (records) {
61
66
  if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
62
67
  var _pressureRecordBuffer;
63
68
  (_pressureRecordBuffer = pressureRecordBuffer).push.apply(_pressureRecordBuffer, (0, _toConsumableArray2.default)(records));
64
69
  }
65
70
  });
66
- pressureObserver.observe('cpu', {
71
+ (_pressureObserver$obs = pressureObserver.observe('cpu', {
67
72
  sampleInterval: 100
68
- });
73
+ })) === null || _pressureObserver$obs === void 0 || _pressureObserver$obs.catch();
69
74
  }
70
75
  } catch (err) {
71
76
  /* do nothing, this is a best efforts metric */
@@ -10,47 +10,52 @@ export function removeOldBufferRecords(filter) {
10
10
  }) => time > filter);
11
11
  }
12
12
  export function createPressureStateReport(start, end) {
13
- // To differentiate between the API not available, vs no PressureRecords added
14
- if (!('PressureObserver' in globalThis)) {
13
+ try {
14
+ // To differentiate between the API not available, vs no PressureRecords added
15
+ if (!('PressureObserver' in globalThis)) {
16
+ return null;
17
+ }
18
+ const pressureStateCount = pressureRecordBuffer.reduce((pressureReport, {
19
+ time,
20
+ state
21
+ }) => {
22
+ if (time >= start && time <= end) {
23
+ pressureReport[state] += 1;
24
+ }
25
+ return pressureReport;
26
+ }, {
27
+ nominal: 0,
28
+ fair: 0,
29
+ serious: 0,
30
+ critical: 0
31
+ });
32
+ const pressureStateTotal = Object.values(pressureStateCount).reduce((total, count) => total + count) || 1;
33
+ removeOldBufferRecords(end);
34
+ return {
35
+ count: pressureStateCount,
36
+ percentage: {
37
+ nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
38
+ fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
39
+ serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
40
+ critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
41
+ }
42
+ };
43
+ } catch {
15
44
  return null;
16
45
  }
17
- const pressureStateCount = pressureRecordBuffer.reduce((pressureReport, {
18
- time,
19
- state
20
- }) => {
21
- if (time >= start && time <= end) {
22
- pressureReport[state] += 1;
23
- }
24
- return pressureReport;
25
- }, {
26
- nominal: 0,
27
- fair: 0,
28
- serious: 0,
29
- critical: 0
30
- });
31
- const pressureStateTotal = Object.values(pressureStateCount).reduce((total, count) => total + count) || 1;
32
- removeOldBufferRecords(end);
33
- return {
34
- count: pressureStateCount,
35
- percentage: {
36
- nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
37
- fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
38
- serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
39
- critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
40
- }
41
- };
42
46
  }
43
47
  export function initialisePressureObserver() {
44
48
  try {
45
49
  if ('PressureObserver' in globalThis) {
50
+ var _pressureObserver$obs;
46
51
  pressureObserver = new PressureObserver(records => {
47
52
  if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
48
53
  pressureRecordBuffer.push(...records);
49
54
  }
50
55
  });
51
- pressureObserver.observe('cpu', {
56
+ (_pressureObserver$obs = pressureObserver.observe('cpu', {
52
57
  sampleInterval: 100
53
- });
58
+ })) === null || _pressureObserver$obs === void 0 ? void 0 : _pressureObserver$obs.catch();
54
59
  }
55
60
  } catch (err) {
56
61
  /* do nothing, this is a best efforts metric */
@@ -12,49 +12,54 @@ export function removeOldBufferRecords(filter) {
12
12
  });
13
13
  }
14
14
  export function createPressureStateReport(start, end) {
15
- // To differentiate between the API not available, vs no PressureRecords added
16
- if (!('PressureObserver' in globalThis)) {
15
+ try {
16
+ // To differentiate between the API not available, vs no PressureRecords added
17
+ if (!('PressureObserver' in globalThis)) {
18
+ return null;
19
+ }
20
+ var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
21
+ var time = _ref2.time,
22
+ state = _ref2.state;
23
+ if (time >= start && time <= end) {
24
+ pressureReport[state] += 1;
25
+ }
26
+ return pressureReport;
27
+ }, {
28
+ nominal: 0,
29
+ fair: 0,
30
+ serious: 0,
31
+ critical: 0
32
+ });
33
+ var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
34
+ return total + count;
35
+ }) || 1;
36
+ removeOldBufferRecords(end);
37
+ return {
38
+ count: pressureStateCount,
39
+ percentage: {
40
+ nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
41
+ fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
42
+ serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
43
+ critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
44
+ }
45
+ };
46
+ } catch (_unused) {
17
47
  return null;
18
48
  }
19
- var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
20
- var time = _ref2.time,
21
- state = _ref2.state;
22
- if (time >= start && time <= end) {
23
- pressureReport[state] += 1;
24
- }
25
- return pressureReport;
26
- }, {
27
- nominal: 0,
28
- fair: 0,
29
- serious: 0,
30
- critical: 0
31
- });
32
- var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
33
- return total + count;
34
- }) || 1;
35
- removeOldBufferRecords(end);
36
- return {
37
- count: pressureStateCount,
38
- percentage: {
39
- nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
40
- fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
41
- serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
42
- critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
43
- }
44
- };
45
49
  }
46
50
  export function initialisePressureObserver() {
47
51
  try {
48
52
  if ('PressureObserver' in globalThis) {
53
+ var _pressureObserver$obs;
49
54
  pressureObserver = new PressureObserver(function (records) {
50
55
  if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
51
56
  var _pressureRecordBuffer;
52
57
  (_pressureRecordBuffer = pressureRecordBuffer).push.apply(_pressureRecordBuffer, _toConsumableArray(records));
53
58
  }
54
59
  });
55
- pressureObserver.observe('cpu', {
60
+ (_pressureObserver$obs = pressureObserver.observe('cpu', {
56
61
  sampleInterval: 100
57
- });
62
+ })) === null || _pressureObserver$obs === void 0 || _pressureObserver$obs.catch();
58
63
  }
59
64
  } catch (err) {
60
65
  /* do nothing, this is a best efforts metric */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "3.12.2",
3
+ "version": "3.12.3",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",