@atlaskit/react-ufo 4.13.1 → 4.14.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`55c867098e0ab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55c867098e0ab) -
8
+ Added battery info and webdriver
9
+
3
10
  ## 4.13.1
4
11
 
5
12
  ### Patch Changes
@@ -35,6 +35,7 @@ var ssr = _interopRequireWildcard(require("../ssr"));
35
35
  var _utils = require("./common/utils");
36
36
  var _criticalMetricsPayload = require("./critical-metrics-payload");
37
37
  var _addPerformanceMeasures = require("./utils/add-performance-measures");
38
+ var _getBatteryInfo = require("./utils/get-battery-info");
38
39
  var _getBrowserMetadata = require("./utils/get-browser-metadata");
39
40
  var _getInteractionStatus = _interopRequireDefault(require("./utils/get-interaction-status"));
40
41
  var _getMoreAccuratePageVisibilityUpToTtai = require("./utils/get-more-accurate-page-visibility-up-to-ttai");
@@ -397,7 +398,7 @@ function createInteractionMetricsPayload(_x, _x2, _x3, _x4, _x5) {
397
398
  function _createInteractionMetricsPayload() {
398
399
  _createInteractionMetricsPayload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction, interactionId, experimental, criticalPayloadCount, vcMetrics) {
399
400
  var _window$location, _config$additionalPay;
400
- var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, getReactHydrationStats, payload;
401
+ var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, batteryInfo, getReactHydrationStats, payload;
401
402
  return _regenerator.default.wrap(function _callee$(_context) {
402
403
  while (1) switch (_context.prev = _context.next) {
403
404
  case 0:
@@ -510,15 +511,17 @@ function _createInteractionMetricsPayload() {
510
511
  _context.t2 = _context.t1;
511
512
  _context.t3 = experimental ? (0, _createExperimentalInteractionMetricsPayload.getExperimentalVCMetrics)(interaction) : Promise.resolve(undefined);
512
513
  _context.t4 = (0, _getPaintMetrics.getPaintMetricsToLegacyFormat)(type, end);
513
- _context.t5 = [_context.t2, _context.t3, _context.t4];
514
- _context.next = 34;
515
- return _context.t0.all.call(_context.t0, _context.t5);
516
- case 34:
514
+ _context.t5 = (0, _getBatteryInfo.getBatteryInfoToLegacyFormat)();
515
+ _context.t6 = [_context.t2, _context.t3, _context.t4, _context.t5];
516
+ _context.next = 35;
517
+ return _context.t0.all.call(_context.t0, _context.t6);
518
+ case 35:
517
519
  _yield$Promise$all = _context.sent;
518
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 3);
520
+ _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 4);
519
521
  finalVCMetrics = _yield$Promise$all2[0];
520
522
  experimentalMetrics = _yield$Promise$all2[1];
521
523
  paintMetrics = _yield$Promise$all2[2];
524
+ batteryInfo = _yield$Promise$all2[3];
522
525
  if (!experimental) {
523
526
  (0, _addPerformanceMeasures.addPerformanceMeasures)(interaction.start, (0, _toConsumableArray2.default)((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || []));
524
527
  }
@@ -537,7 +540,7 @@ function _createInteractionMetricsPayload() {
537
540
  source: 'measured',
538
541
  tags: ['observability'],
539
542
  attributes: {
540
- properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
543
+ properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
541
544
  // basic
542
545
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
543
546
  'event:product': config.product,
@@ -556,7 +559,7 @@ function _createInteractionMetricsPayload() {
556
559
  }, criticalPayloadCount !== undefined ? {
557
560
  'ufo:multipayload': true,
558
561
  'ufo:criticalPayloadCount': criticalPayloadCount
559
- } : {}), (0, _getBrowserMetadata.getBrowserMetadataToLegacyFormat)()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), (0, _getNavigationMetrics.getNavigationMetricsToLegacyFormat)(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
562
+ } : {}), (0, _getBrowserMetadata.getBrowserMetadataToLegacyFormat)()), batteryInfo), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), (0, _getNavigationMetrics.getNavigationMetricsToLegacyFormat)(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
560
563
  interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
561
564
  namePrefix: config.namePrefix || '',
562
565
  segmentPrefix: config.segmentPrefix || '',
@@ -603,7 +606,7 @@ function _createInteractionMetricsPayload() {
603
606
  }
604
607
  payload.attributes.properties['event:sizeInKb'] = (0, _getPayloadSize.default)(payload.attributes.properties);
605
608
  return _context.abrupt("return", payload);
606
- case 45:
609
+ case 47:
607
610
  case "end":
608
611
  return _context.stop();
609
612
  }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = getBatteryInfo;
8
+ exports.getBatteryInfoToLegacyFormat = getBatteryInfoToLegacyFormat;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ // Type definitions for battery info
13
+ // Main function returns compact nested format
14
+ function getBatteryInfo() {
15
+ return _getBatteryInfo.apply(this, arguments);
16
+ } // Helper function to get battery info in legacy colon format for backward compatibility
17
+ function _getBatteryInfo() {
18
+ _getBatteryInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
19
+ var battery;
20
+ return _regenerator.default.wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ if ((0, _platformFeatureFlags.fg)('react_ufo_battery_info')) {
24
+ _context.next = 2;
25
+ break;
26
+ }
27
+ return _context.abrupt("return", {});
28
+ case 2:
29
+ if (!(typeof navigator === 'undefined')) {
30
+ _context.next = 4;
31
+ break;
32
+ }
33
+ return _context.abrupt("return", {});
34
+ case 4:
35
+ _context.prev = 4;
36
+ if (!('getBattery' in navigator)) {
37
+ _context.next = 11;
38
+ break;
39
+ }
40
+ _context.next = 8;
41
+ return navigator.getBattery();
42
+ case 8:
43
+ battery = _context.sent;
44
+ if (!(battery && typeof battery.level === 'number' && typeof battery.charging === 'boolean')) {
45
+ _context.next = 11;
46
+ break;
47
+ }
48
+ return _context.abrupt("return", {
49
+ level: Math.round(battery.level * 100) / 100,
50
+ // Round to 0.01
51
+ charging: battery.charging
52
+ });
53
+ case 11:
54
+ _context.next = 15;
55
+ break;
56
+ case 13:
57
+ _context.prev = 13;
58
+ _context.t0 = _context["catch"](4);
59
+ case 15:
60
+ return _context.abrupt("return", {});
61
+ case 16:
62
+ case "end":
63
+ return _context.stop();
64
+ }
65
+ }, _callee, null, [[4, 13]]);
66
+ }));
67
+ return _getBatteryInfo.apply(this, arguments);
68
+ }
69
+ function getBatteryInfoToLegacyFormat() {
70
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
71
+ }
72
+ function _getBatteryInfoToLegacyFormat() {
73
+ _getBatteryInfoToLegacyFormat = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
74
+ var battery, legacyFormat;
75
+ return _regenerator.default.wrap(function _callee2$(_context2) {
76
+ while (1) switch (_context2.prev = _context2.next) {
77
+ case 0:
78
+ _context2.next = 2;
79
+ return getBatteryInfo();
80
+ case 2:
81
+ battery = _context2.sent;
82
+ legacyFormat = {};
83
+ if (battery.level !== undefined) {
84
+ legacyFormat['event:battery:level'] = battery.level;
85
+ }
86
+ if (battery.charging !== undefined) {
87
+ legacyFormat['event:battery:charging'] = battery.charging;
88
+ }
89
+ return _context2.abrupt("return", legacyFormat);
90
+ case 7:
91
+ case "end":
92
+ return _context2.stop();
93
+ }
94
+ }, _callee2);
95
+ }));
96
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
97
+ }
@@ -22,6 +22,7 @@ import * as ssr from '../ssr';
22
22
  import { buildSegmentTree, getOldSegmentsLabelStack, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
23
23
  import { createCriticalMetricsPayloads } from './critical-metrics-payload';
24
24
  import { addPerformanceMeasures } from './utils/add-performance-measures';
25
+ import { getBatteryInfoToLegacyFormat } from './utils/get-battery-info';
25
26
  import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
26
27
  import getInteractionStatus from './utils/get-interaction-status';
27
28
  import { getMoreAccuratePageVisibilityUpToTTAI } from './utils/get-more-accurate-page-visibility-up-to-ttai';
@@ -499,7 +500,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
499
500
  }
500
501
  const newUFOName = sanitizeUfoName(ufoName);
501
502
  const resourceTimings = getResourceTimings(start, end);
502
- const [finalVCMetrics, experimentalMetrics, paintMetrics] = await Promise.all([vcMetrics || (await getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined), getPaintMetricsToLegacyFormat(type, end)]);
503
+ const [finalVCMetrics, experimentalMetrics, paintMetrics, batteryInfo] = await Promise.all([vcMetrics || (await getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined), getPaintMetricsToLegacyFormat(type, end), getBatteryInfoToLegacyFormat()]);
503
504
  if (!experimental) {
504
505
  addPerformanceMeasures(interaction.start, [...((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || [])]);
505
506
  }
@@ -540,6 +541,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
540
541
  } : {}),
541
542
  // root
542
543
  ...getBrowserMetadataToLegacyFormat(),
544
+ ...batteryInfo,
543
545
  ...getSSRProperties(type),
544
546
  ...getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime),
545
547
  ...getPPSMetrics(interaction),
@@ -0,0 +1,42 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+
3
+ // Type definitions for battery info
4
+
5
+ // Main function returns compact nested format
6
+ export default async function getBatteryInfo() {
7
+ if (!fg('react_ufo_battery_info')) {
8
+ return {};
9
+ }
10
+ if (typeof navigator === 'undefined') {
11
+ return {};
12
+ }
13
+ try {
14
+ // Try modern getBattery() API first
15
+ if ('getBattery' in navigator) {
16
+ const battery = await navigator.getBattery();
17
+ if (battery && typeof battery.level === 'number' && typeof battery.charging === 'boolean') {
18
+ return {
19
+ level: Math.round(battery.level * 100) / 100,
20
+ // Round to 0.01
21
+ charging: battery.charging
22
+ };
23
+ }
24
+ }
25
+ } catch (error) {
26
+ // Silently ignore errors - battery info is optional
27
+ }
28
+ return {};
29
+ }
30
+
31
+ // Helper function to get battery info in legacy colon format for backward compatibility
32
+ export async function getBatteryInfoToLegacyFormat() {
33
+ const battery = await getBatteryInfo();
34
+ const legacyFormat = {};
35
+ if (battery.level !== undefined) {
36
+ legacyFormat['event:battery:level'] = battery.level;
37
+ }
38
+ if (battery.charging !== undefined) {
39
+ legacyFormat['event:battery:charging'] = battery.charging;
40
+ }
41
+ return legacyFormat;
42
+ }
@@ -31,6 +31,7 @@ import * as ssr from '../ssr';
31
31
  import { buildSegmentTree, getOldSegmentsLabelStack, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
32
32
  import { createCriticalMetricsPayloads } from './critical-metrics-payload';
33
33
  import { addPerformanceMeasures } from './utils/add-performance-measures';
34
+ import { getBatteryInfoToLegacyFormat } from './utils/get-battery-info';
34
35
  import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
35
36
  import getInteractionStatus from './utils/get-interaction-status';
36
37
  import { getMoreAccuratePageVisibilityUpToTTAI } from './utils/get-more-accurate-page-visibility-up-to-ttai';
@@ -389,7 +390,7 @@ function createInteractionMetricsPayload(_x, _x2, _x3, _x4, _x5) {
389
390
  function _createInteractionMetricsPayload() {
390
391
  _createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction, interactionId, experimental, criticalPayloadCount, vcMetrics) {
391
392
  var _window$location, _config$additionalPay;
392
- var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, getReactHydrationStats, payload;
393
+ var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, responsiveness, unknownElementName, unknownElementHierarchy, hydration, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, finalVCMetrics, experimentalMetrics, paintMetrics, batteryInfo, getReactHydrationStats, payload;
393
394
  return _regeneratorRuntime.wrap(function _callee$(_context) {
394
395
  while (1) switch (_context.prev = _context.next) {
395
396
  case 0:
@@ -502,15 +503,17 @@ function _createInteractionMetricsPayload() {
502
503
  _context.t2 = _context.t1;
503
504
  _context.t3 = experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined);
504
505
  _context.t4 = getPaintMetricsToLegacyFormat(type, end);
505
- _context.t5 = [_context.t2, _context.t3, _context.t4];
506
- _context.next = 34;
507
- return _context.t0.all.call(_context.t0, _context.t5);
508
- case 34:
506
+ _context.t5 = getBatteryInfoToLegacyFormat();
507
+ _context.t6 = [_context.t2, _context.t3, _context.t4, _context.t5];
508
+ _context.next = 35;
509
+ return _context.t0.all.call(_context.t0, _context.t6);
510
+ case 35:
509
511
  _yield$Promise$all = _context.sent;
510
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
512
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 4);
511
513
  finalVCMetrics = _yield$Promise$all2[0];
512
514
  experimentalMetrics = _yield$Promise$all2[1];
513
515
  paintMetrics = _yield$Promise$all2[2];
516
+ batteryInfo = _yield$Promise$all2[3];
514
517
  if (!experimental) {
515
518
  addPerformanceMeasures(interaction.start, _toConsumableArray((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || []));
516
519
  }
@@ -529,7 +532,7 @@ function _createInteractionMetricsPayload() {
529
532
  source: 'measured',
530
533
  tags: ['observability'],
531
534
  attributes: {
532
- properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
535
+ properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
533
536
  // basic
534
537
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
535
538
  'event:product': config.product,
@@ -548,7 +551,7 @@ function _createInteractionMetricsPayload() {
548
551
  }, criticalPayloadCount !== undefined ? {
549
552
  'ufo:multipayload': true,
550
553
  'ufo:criticalPayloadCount': criticalPayloadCount
551
- } : {}), getBrowserMetadataToLegacyFormat()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), getNavigationMetricsToLegacyFormat(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
554
+ } : {}), getBrowserMetadataToLegacyFormat()), batteryInfo), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), getNavigationMetricsToLegacyFormat(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
552
555
  interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
553
556
  namePrefix: config.namePrefix || '',
554
557
  segmentPrefix: config.segmentPrefix || '',
@@ -595,7 +598,7 @@ function _createInteractionMetricsPayload() {
595
598
  }
596
599
  payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
597
600
  return _context.abrupt("return", payload);
598
- case 45:
601
+ case 47:
599
602
  case "end":
600
603
  return _context.stop();
601
604
  }
@@ -0,0 +1,93 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+
5
+ // Type definitions for battery info
6
+
7
+ // Main function returns compact nested format
8
+ export default function getBatteryInfo() {
9
+ return _getBatteryInfo.apply(this, arguments);
10
+ }
11
+
12
+ // Helper function to get battery info in legacy colon format for backward compatibility
13
+ function _getBatteryInfo() {
14
+ _getBatteryInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
+ var battery;
16
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17
+ while (1) switch (_context.prev = _context.next) {
18
+ case 0:
19
+ if (fg('react_ufo_battery_info')) {
20
+ _context.next = 2;
21
+ break;
22
+ }
23
+ return _context.abrupt("return", {});
24
+ case 2:
25
+ if (!(typeof navigator === 'undefined')) {
26
+ _context.next = 4;
27
+ break;
28
+ }
29
+ return _context.abrupt("return", {});
30
+ case 4:
31
+ _context.prev = 4;
32
+ if (!('getBattery' in navigator)) {
33
+ _context.next = 11;
34
+ break;
35
+ }
36
+ _context.next = 8;
37
+ return navigator.getBattery();
38
+ case 8:
39
+ battery = _context.sent;
40
+ if (!(battery && typeof battery.level === 'number' && typeof battery.charging === 'boolean')) {
41
+ _context.next = 11;
42
+ break;
43
+ }
44
+ return _context.abrupt("return", {
45
+ level: Math.round(battery.level * 100) / 100,
46
+ // Round to 0.01
47
+ charging: battery.charging
48
+ });
49
+ case 11:
50
+ _context.next = 15;
51
+ break;
52
+ case 13:
53
+ _context.prev = 13;
54
+ _context.t0 = _context["catch"](4);
55
+ case 15:
56
+ return _context.abrupt("return", {});
57
+ case 16:
58
+ case "end":
59
+ return _context.stop();
60
+ }
61
+ }, _callee, null, [[4, 13]]);
62
+ }));
63
+ return _getBatteryInfo.apply(this, arguments);
64
+ }
65
+ export function getBatteryInfoToLegacyFormat() {
66
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
67
+ }
68
+ function _getBatteryInfoToLegacyFormat() {
69
+ _getBatteryInfoToLegacyFormat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
70
+ var battery, legacyFormat;
71
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
72
+ while (1) switch (_context2.prev = _context2.next) {
73
+ case 0:
74
+ _context2.next = 2;
75
+ return getBatteryInfo();
76
+ case 2:
77
+ battery = _context2.sent;
78
+ legacyFormat = {};
79
+ if (battery.level !== undefined) {
80
+ legacyFormat['event:battery:level'] = battery.level;
81
+ }
82
+ if (battery.charging !== undefined) {
83
+ legacyFormat['event:battery:charging'] = battery.charging;
84
+ }
85
+ return _context2.abrupt("return", legacyFormat);
86
+ case 7:
87
+ case "end":
88
+ return _context2.stop();
89
+ }
90
+ }, _callee2);
91
+ }));
92
+ return _getBatteryInfoToLegacyFormat.apply(this, arguments);
93
+ }