@atlaskit/media-card 78.7.0 → 78.8.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  4. package/dist/cjs/inline/loader.js +1 -1
  5. package/dist/cjs/utils/mediaPerformanceObserver/durationMetrics.js +98 -0
  6. package/dist/cjs/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +15 -86
  7. package/dist/cjs/utils/mediaPerformanceObserver/types.js +1 -0
  8. package/dist/cjs/utils/mediaPerformanceObserver/ufo.js +26 -0
  9. package/dist/cjs/utils/ufoExperiences.js +1 -1
  10. package/dist/es2019/card/card.js +1 -1
  11. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  12. package/dist/es2019/inline/loader.js +1 -1
  13. package/dist/es2019/utils/mediaPerformanceObserver/durationMetrics.js +93 -0
  14. package/dist/es2019/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +9 -86
  15. package/dist/es2019/utils/mediaPerformanceObserver/types.js +0 -0
  16. package/dist/es2019/utils/mediaPerformanceObserver/ufo.js +16 -0
  17. package/dist/es2019/utils/ufoExperiences.js +1 -1
  18. package/dist/esm/card/card.js +1 -1
  19. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  20. package/dist/esm/inline/loader.js +1 -1
  21. package/dist/esm/utils/mediaPerformanceObserver/durationMetrics.js +92 -0
  22. package/dist/esm/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +14 -86
  23. package/dist/esm/utils/mediaPerformanceObserver/types.js +0 -0
  24. package/dist/esm/utils/mediaPerformanceObserver/ufo.js +19 -0
  25. package/dist/esm/utils/ufoExperiences.js +1 -1
  26. package/dist/types/utils/mediaPerformanceObserver/durationMetrics.d.ts +75 -0
  27. package/dist/types/utils/mediaPerformanceObserver/types.d.ts +8 -0
  28. package/dist/types/utils/mediaPerformanceObserver/ufo.d.ts +2 -0
  29. package/dist/types-ts4.5/utils/mediaPerformanceObserver/durationMetrics.d.ts +75 -0
  30. package/dist/types-ts4.5/utils/mediaPerformanceObserver/types.d.ts +8 -0
  31. package/dist/types-ts4.5/utils/mediaPerformanceObserver/ufo.d.ts +2 -0
  32. package/package.json +8 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 78.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#155735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155735)
8
+ [`e5a96535fa143`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e5a96535fa143) -
9
+ Media Card sends custom network metrics using React UFO
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 78.7.1
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 78.7.0
4
22
 
5
23
  ### Minor Changes
@@ -21,7 +21,7 @@ var _excluded = ["identifier"];
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
23
  var packageName = "@atlaskit/media-card";
24
- var packageVersion = "78.7.0";
24
+ var packageVersion = "78.8.0";
25
25
  var CardBase = exports.CardBase = function CardBase(_ref) {
26
26
  var identifier = _ref.identifier,
27
27
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
90
90
  }(_react.default.Component);
91
91
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
92
92
  var packageName = "@atlaskit/media-card";
93
- var packageVersion = "78.7.0";
93
+ var packageVersion = "78.8.0";
94
94
 
95
95
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
96
96
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
119
119
  ErrorBoundary = _this$state.ErrorBoundary;
120
120
  var analyticsContext = {
121
121
  packageVersion: "@atlaskit/media-card",
122
- packageName: "78.7.0",
122
+ packageName: "78.8.0",
123
123
  componentName: 'mediaInlineCard',
124
124
  component: 'mediaInlineCard'
125
125
  };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createUfoDurationMetrics = exports.createMediaDurationMetrics = void 0;
7
+ var getStartedAt = function getStartedAt(entry, navigationTime) {
8
+ return entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0);
9
+ };
10
+ var createMediaDurationMetrics = exports.createMediaDurationMetrics = function createMediaDurationMetrics(entry, navigationTime) {
11
+ var _entry$serverTiming$f, _entry$serverTiming$f2;
12
+ return {
13
+ startedAt: getStartedAt(entry, navigationTime),
14
+ /**
15
+ * Performance resource timing data regarding the loading of an
16
+ * application's resources as described in
17
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
18
+ */
19
+ transferSize: entry.transferSize,
20
+ decodedBodySize: entry.decodedBodySize,
21
+ totalDuration: entry.duration,
22
+ initiatorType: entry.initiatorType,
23
+ // value can be 'fetch' or 'img'
24
+ responseEnd: entry.responseEnd,
25
+ tcpHandshakeTime: entry.connectEnd - entry.connectStart,
26
+ dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
27
+ redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
28
+ tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
29
+ timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
30
+ browserCacheHit: entry.transferSize === 0,
31
+ nextHopProtocol: entry.nextHopProtocol,
32
+ /**
33
+ * `interimRequestTime` represents the entire time the browser took to
34
+ * request the resource from the server. This includes the interim response time
35
+ * (for example, 100 Continue or 103 Early Hints).
36
+ *
37
+ * i.e. It is the time taken for the request to be sent
38
+ * + the waiting time for the server to send a response
39
+ *
40
+ * Please, note that this value
41
+ * is distinctly different from the aforementioned document.
42
+ */
43
+ interimRequestTime: entry.responseStart - entry.requestStart,
44
+ /**
45
+ * `requestInvocationTime` represents the actual time the browser took to request
46
+ * the resource from the server (i.e. it does not include the interim reponse
47
+ * time).
48
+ * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
49
+ * available in Chrome, but not in FireFox or Safari. This value will be undefined
50
+ * when `firstInterimResponseStart` is unavailable.
51
+ */
52
+ requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
53
+ /**
54
+ * `contentDownloadTime` represents the time taken for the browser to receive
55
+ * the resource from the server. This may be cut short if the transport
56
+ * connection is closed.
57
+ */
58
+ contentDownloadTime: entry.responseEnd - entry.responseStart,
59
+ /**
60
+ * The user agent string for the current browser
61
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
62
+ */
63
+ userAgent: window.navigator.userAgent,
64
+ /**
65
+ * Performance resource timing data sent by the server. This includes:
66
+ *
67
+ * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
68
+ *
69
+ * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
70
+ * how long the it took the CDN to respond to the frontend.
71
+ *
72
+ * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
73
+ * time the Media backend took to respond to the CDN, in the case that the CDN
74
+ * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
75
+ */
76
+ cdnCacheHit: entry.serverTiming.find(function (_ref) {
77
+ var name = _ref.name;
78
+ return name === 'cdn-cache-hit';
79
+ }) ? true : false,
80
+ cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(function (_ref2) {
81
+ var name = _ref2.name;
82
+ return name === 'cdn-downstream-fbl';
83
+ })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
84
+ cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(function (_ref3) {
85
+ var name = _ref3.name;
86
+ return name === 'cdn-upstream-fbl';
87
+ })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
88
+ };
89
+ };
90
+ var createUfoDurationMetrics = exports.createUfoDurationMetrics = function createUfoDurationMetrics(entry, navigationTime) {
91
+ return {
92
+ resourceTiming: {
93
+ start: getStartedAt(entry, navigationTime),
94
+ end: entry.responseEnd
95
+ }
96
+ /* More metrics to add here */
97
+ };
98
+ };
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.startResourceObserver = exports.setAnalyticsContext = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _analytics = require("@atlaskit/media-common/analytics");
8
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _durationMetrics = require("./durationMetrics");
12
+ var _ufo = require("./ufo");
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
15
  var MEDIA_CARD_PERF_STATE_KEY = '__mediaCardPerfState_asflkajsdflja';
10
16
  var urlRegex = /https:\/\/(?:media\.(?:dev|staging|prod)\.atl-paas\.net|api\.media\.atlassian\.com|media-cdn(?:\.stg\.|\.)atlassian\.com)\/file\/([^/]+)\/image.*[?&]source=mediaCard/;
11
17
  var clientIdParamRegex = /[?&]clientId=([^&]+)/;
12
18
  var ssrParamRegex = /[?&]token=([^&]+)/;
13
-
14
- /**
15
- * `ExperimentalPerformanceResourceTiming` type accounts for the experimental value `firstInterimResponseStart`
16
- * which is present in Chrome, but not present in FireFox or Safari.
17
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/firstInterimResponseStart
18
- */
19
-
20
19
  var createAndGetResourceObserver = function createAndGetResourceObserver() {
21
20
  return new PerformanceObserver(function (list) {
22
21
  list.getEntries().forEach(function (baseEntry) {
@@ -26,100 +25,30 @@ var createAndGetResourceObserver = function createAndGetResourceObserver() {
26
25
  var matchClientId = entry.name.match(clientIdParamRegex);
27
26
  var matchSSR = entry.name.match(ssrParamRegex);
28
27
  if (matchFileId && (_window$MEDIA_CARD_PE = window[MEDIA_CARD_PERF_STATE_KEY]) !== null && _window$MEDIA_CARD_PE !== void 0 && _window$MEDIA_CARD_PE.mediaCardCreateAnalyticsEvent) {
29
- var _entry$serverTiming$f, _entry$serverTiming$f2;
30
28
  var fileId = matchFileId[1];
31
29
  var clientId = matchClientId === null || matchClientId === void 0 ? void 0 : matchClientId[1];
32
30
  var ssr = matchSSR ? 'server' : undefined;
33
31
  var navigationTime = performance.getEntriesByType('navigation')[0];
32
+ var mediaDurationMetrics = (0, _durationMetrics.createMediaDurationMetrics)(entry, navigationTime);
34
33
  var event = window[MEDIA_CARD_PERF_STATE_KEY].mediaCardCreateAnalyticsEvent({
35
34
  eventType: 'operational',
36
35
  action: 'succeeded',
37
36
  actionSubject: 'mediaCardPerfObserver',
38
- attributes: {
37
+ attributes: _objectSpread({
39
38
  ssr: ssr,
40
39
  fileId: fileId,
41
40
  mediaClientId: clientId,
42
- startedAt: entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0),
43
41
  featureFlags: {
44
42
  'media-cdn-single-host': (0, _platformFeatureFlags.fg)('platform.media-cdn-single-host')
45
- },
46
- /**
47
- * Performance resource timing data regarding the loading of an
48
- * application's resources as described in
49
- * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
50
- */
51
- transferSize: entry.transferSize,
52
- decodedBodySize: entry.decodedBodySize,
53
- totalDuration: entry.duration,
54
- initiatorType: entry.initiatorType,
55
- // value can be 'fetch' or 'img'
56
- responseEnd: entry.responseEnd,
57
- tcpHandshakeTime: entry.connectEnd - entry.connectStart,
58
- dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
59
- redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
60
- tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
61
- timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
62
- browserCacheHit: entry.transferSize === 0,
63
- nextHopProtocol: entry.nextHopProtocol,
64
- /**
65
- * `interimRequestTime` represents the entire time the browser took to
66
- * request the resource from the server. This includes the interim response time
67
- * (for example, 100 Continue or 103 Early Hints).
68
- *
69
- * i.e. It is the time taken for the request to be sent
70
- * + the waiting time for the server to send a response
71
- *
72
- * Please, note that this value
73
- * is distinctly different from the aforementioned document.
74
- */
75
- interimRequestTime: entry.responseStart - entry.requestStart,
76
- /**
77
- * `requestInvocationTime` represents the actual time the browser took to request
78
- * the resource from the server (i.e. it does not include the interim reponse
79
- * time).
80
- * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
81
- * available in Chrome, but not in FireFox or Safari. This value will be undefined
82
- * when `firstInterimResponseStart` is unavailable.
83
- */
84
- requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
85
- /**
86
- * `contentDownloadTime` represents the time taken for the browser to receive
87
- * the resource from the server. This may be cut short if the transport
88
- * connection is closed.
89
- */
90
- contentDownloadTime: entry.responseEnd - entry.responseStart,
91
- /**
92
- * The user agent string for the current browser
93
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
94
- */
95
- userAgent: window.navigator.userAgent,
96
- /**
97
- * Performance resource timing data sent by the server. This includes:
98
- *
99
- * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
100
- *
101
- * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
102
- * how long the it took the CDN to respond to the frontend.
103
- *
104
- * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
105
- * time the Media backend took to respond to the CDN, in the case that the CDN
106
- * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
107
- */
108
- cdnCacheHit: entry.serverTiming.find(function (_ref) {
109
- var name = _ref.name;
110
- return name === 'cdn-cache-hit';
111
- }) ? true : false,
112
- cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(function (_ref2) {
113
- var name = _ref2.name;
114
- return name === 'cdn-downstream-fbl';
115
- })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
116
- cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(function (_ref3) {
117
- var name = _ref3.name;
118
- return name === 'cdn-upstream-fbl';
119
- })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
120
- }
43
+ }
44
+ }, mediaDurationMetrics)
121
45
  });
122
46
  event.fire(_analytics.ANALYTICS_MEDIA_CHANNEL);
47
+ if ((0, _platformFeatureFlags.fg)('platform_media_card_ufo_network_metrics')) {
48
+ var ufoDurationMetrics = (0, _durationMetrics.createUfoDurationMetrics)(entry, navigationTime);
49
+ var endpointName = 'image';
50
+ (0, _ufo.sendUfoDurationMetrics)(ufoDurationMetrics, endpointName);
51
+ }
123
52
  }
124
53
  });
125
54
  });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.sendUfoDurationMetrics = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _interactionMetrics = require("@atlaskit/react-ufo/interaction-metrics");
10
+ var mediaLabelStack = [{
11
+ name: 'media'
12
+ }];
13
+ var sendUfoDurationMetrics = exports.sendUfoDurationMetrics = function sendUfoDurationMetrics(ufoDurationMetrics, endpoint) {
14
+ var labelStack = [].concat(mediaLabelStack, [{
15
+ name: endpoint
16
+ }]);
17
+ Object.entries(ufoDurationMetrics).map(function (_ref) {
18
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
19
+ name = _ref2[0],
20
+ _ref2$ = _ref2[1],
21
+ start = _ref2$.start,
22
+ end = _ref2$.end,
23
+ size = _ref2$.size;
24
+ (0, _interactionMetrics.addCustomSpans)(name, start, end, size, labelStack);
25
+ });
26
+ };
@@ -15,7 +15,7 @@ var _mediaClient = require("@atlaskit/media-client");
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var packageName = "@atlaskit/media-card";
18
- var packageVersion = "78.7.0";
18
+ var packageVersion = "78.8.0";
19
19
  var concurrentExperience;
20
20
  var getExperience = function getExperience(id) {
21
21
  if (!concurrentExperience) {
@@ -9,7 +9,7 @@ import { startResourceObserver, setAnalyticsContext } from '../utils/mediaPerfor
9
9
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  const packageName = "@atlaskit/media-card";
12
- const packageVersion = "78.7.0";
12
+ const packageVersion = "78.8.0";
13
13
  export const CardBase = ({
14
14
  identifier,
15
15
  ...otherProps
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "78.7.0";
69
+ const packageVersion = "78.8.0";
70
70
 
71
71
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
72
72
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "78.7.0",
40
+ packageName: "78.8.0",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -0,0 +1,93 @@
1
+ const getStartedAt = (entry, navigationTime) => entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0);
2
+ export const createMediaDurationMetrics = (entry, navigationTime) => {
3
+ var _entry$serverTiming$f, _entry$serverTiming$f2;
4
+ return {
5
+ startedAt: getStartedAt(entry, navigationTime),
6
+ /**
7
+ * Performance resource timing data regarding the loading of an
8
+ * application's resources as described in
9
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
10
+ */
11
+ transferSize: entry.transferSize,
12
+ decodedBodySize: entry.decodedBodySize,
13
+ totalDuration: entry.duration,
14
+ initiatorType: entry.initiatorType,
15
+ // value can be 'fetch' or 'img'
16
+ responseEnd: entry.responseEnd,
17
+ tcpHandshakeTime: entry.connectEnd - entry.connectStart,
18
+ dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
19
+ redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
20
+ tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
21
+ timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
22
+ browserCacheHit: entry.transferSize === 0,
23
+ nextHopProtocol: entry.nextHopProtocol,
24
+ /**
25
+ * `interimRequestTime` represents the entire time the browser took to
26
+ * request the resource from the server. This includes the interim response time
27
+ * (for example, 100 Continue or 103 Early Hints).
28
+ *
29
+ * i.e. It is the time taken for the request to be sent
30
+ * + the waiting time for the server to send a response
31
+ *
32
+ * Please, note that this value
33
+ * is distinctly different from the aforementioned document.
34
+ */
35
+ interimRequestTime: entry.responseStart - entry.requestStart,
36
+ /**
37
+ * `requestInvocationTime` represents the actual time the browser took to request
38
+ * the resource from the server (i.e. it does not include the interim reponse
39
+ * time).
40
+ * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
41
+ * available in Chrome, but not in FireFox or Safari. This value will be undefined
42
+ * when `firstInterimResponseStart` is unavailable.
43
+ */
44
+ requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
45
+ /**
46
+ * `contentDownloadTime` represents the time taken for the browser to receive
47
+ * the resource from the server. This may be cut short if the transport
48
+ * connection is closed.
49
+ */
50
+ contentDownloadTime: entry.responseEnd - entry.responseStart,
51
+ /**
52
+ * The user agent string for the current browser
53
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
54
+ */
55
+ userAgent: window.navigator.userAgent,
56
+ /**
57
+ * Performance resource timing data sent by the server. This includes:
58
+ *
59
+ * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
60
+ *
61
+ * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
62
+ * how long the it took the CDN to respond to the frontend.
63
+ *
64
+ * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
65
+ * time the Media backend took to respond to the CDN, in the case that the CDN
66
+ * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
67
+ */
68
+ cdnCacheHit: entry.serverTiming.find(({
69
+ name
70
+ }) => {
71
+ return name === 'cdn-cache-hit';
72
+ }) ? true : false,
73
+ cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(({
74
+ name
75
+ }) => {
76
+ return name === 'cdn-downstream-fbl';
77
+ })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
78
+ cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(({
79
+ name
80
+ }) => {
81
+ return name === 'cdn-upstream-fbl';
82
+ })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
83
+ };
84
+ };
85
+ export const createUfoDurationMetrics = (entry, navigationTime) => {
86
+ return {
87
+ resourceTiming: {
88
+ start: getStartedAt(entry, navigationTime),
89
+ end: entry.responseEnd
90
+ }
91
+ /* More metrics to add here */
92
+ };
93
+ };
@@ -1,16 +1,11 @@
1
1
  import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common/analytics';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { createMediaDurationMetrics, createUfoDurationMetrics } from './durationMetrics';
4
+ import { sendUfoDurationMetrics } from './ufo';
3
5
  const MEDIA_CARD_PERF_STATE_KEY = '__mediaCardPerfState_asflkajsdflja';
4
6
  const urlRegex = /https:\/\/(?:media\.(?:dev|staging|prod)\.atl-paas\.net|api\.media\.atlassian\.com|media-cdn(?:\.stg\.|\.)atlassian\.com)\/file\/([^/]+)\/image.*[?&]source=mediaCard/;
5
7
  const clientIdParamRegex = /[?&]clientId=([^&]+)/;
6
8
  const ssrParamRegex = /[?&]token=([^&]+)/;
7
-
8
- /**
9
- * `ExperimentalPerformanceResourceTiming` type accounts for the experimental value `firstInterimResponseStart`
10
- * which is present in Chrome, but not present in FireFox or Safari.
11
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/firstInterimResponseStart
12
- */
13
-
14
9
  const createAndGetResourceObserver = () => {
15
10
  return new PerformanceObserver(list => {
16
11
  list.getEntries().forEach(baseEntry => {
@@ -20,11 +15,11 @@ const createAndGetResourceObserver = () => {
20
15
  const matchClientId = entry.name.match(clientIdParamRegex);
21
16
  const matchSSR = entry.name.match(ssrParamRegex);
22
17
  if (matchFileId && (_window$MEDIA_CARD_PE = window[MEDIA_CARD_PERF_STATE_KEY]) !== null && _window$MEDIA_CARD_PE !== void 0 && _window$MEDIA_CARD_PE.mediaCardCreateAnalyticsEvent) {
23
- var _entry$serverTiming$f, _entry$serverTiming$f2;
24
18
  const fileId = matchFileId[1];
25
19
  const clientId = matchClientId === null || matchClientId === void 0 ? void 0 : matchClientId[1];
26
20
  const ssr = matchSSR ? 'server' : undefined;
27
21
  const navigationTime = performance.getEntriesByType('navigation')[0];
22
+ const mediaDurationMetrics = createMediaDurationMetrics(entry, navigationTime);
28
23
  const event = window[MEDIA_CARD_PERF_STATE_KEY].mediaCardCreateAnalyticsEvent({
29
24
  eventType: 'operational',
30
25
  action: 'succeeded',
@@ -33,90 +28,18 @@ const createAndGetResourceObserver = () => {
33
28
  ssr,
34
29
  fileId: fileId,
35
30
  mediaClientId: clientId,
36
- startedAt: entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0),
37
31
  featureFlags: {
38
32
  'media-cdn-single-host': fg('platform.media-cdn-single-host')
39
33
  },
40
- /**
41
- * Performance resource timing data regarding the loading of an
42
- * application's resources as described in
43
- * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
44
- */
45
- transferSize: entry.transferSize,
46
- decodedBodySize: entry.decodedBodySize,
47
- totalDuration: entry.duration,
48
- initiatorType: entry.initiatorType,
49
- // value can be 'fetch' or 'img'
50
- responseEnd: entry.responseEnd,
51
- tcpHandshakeTime: entry.connectEnd - entry.connectStart,
52
- dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
53
- redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
54
- tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
55
- timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
56
- browserCacheHit: entry.transferSize === 0,
57
- nextHopProtocol: entry.nextHopProtocol,
58
- /**
59
- * `interimRequestTime` represents the entire time the browser took to
60
- * request the resource from the server. This includes the interim response time
61
- * (for example, 100 Continue or 103 Early Hints).
62
- *
63
- * i.e. It is the time taken for the request to be sent
64
- * + the waiting time for the server to send a response
65
- *
66
- * Please, note that this value
67
- * is distinctly different from the aforementioned document.
68
- */
69
- interimRequestTime: entry.responseStart - entry.requestStart,
70
- /**
71
- * `requestInvocationTime` represents the actual time the browser took to request
72
- * the resource from the server (i.e. it does not include the interim reponse
73
- * time).
74
- * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
75
- * available in Chrome, but not in FireFox or Safari. This value will be undefined
76
- * when `firstInterimResponseStart` is unavailable.
77
- */
78
- requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
79
- /**
80
- * `contentDownloadTime` represents the time taken for the browser to receive
81
- * the resource from the server. This may be cut short if the transport
82
- * connection is closed.
83
- */
84
- contentDownloadTime: entry.responseEnd - entry.responseStart,
85
- /**
86
- * The user agent string for the current browser
87
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
88
- */
89
- userAgent: window.navigator.userAgent,
90
- /**
91
- * Performance resource timing data sent by the server. This includes:
92
- *
93
- * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
94
- *
95
- * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
96
- * how long the it took the CDN to respond to the frontend.
97
- *
98
- * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
99
- * time the Media backend took to respond to the CDN, in the case that the CDN
100
- * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
101
- */
102
- cdnCacheHit: entry.serverTiming.find(({
103
- name
104
- }) => {
105
- return name === 'cdn-cache-hit';
106
- }) ? true : false,
107
- cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(({
108
- name
109
- }) => {
110
- return name === 'cdn-downstream-fbl';
111
- })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
112
- cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(({
113
- name
114
- }) => {
115
- return name === 'cdn-upstream-fbl';
116
- })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
34
+ ...mediaDurationMetrics
117
35
  }
118
36
  });
119
37
  event.fire(ANALYTICS_MEDIA_CHANNEL);
38
+ if (fg('platform_media_card_ufo_network_metrics')) {
39
+ const ufoDurationMetrics = createUfoDurationMetrics(entry, navigationTime);
40
+ const endpointName = 'image';
41
+ sendUfoDurationMetrics(ufoDurationMetrics, endpointName);
42
+ }
120
43
  }
121
44
  });
122
45
  });
@@ -0,0 +1,16 @@
1
+ import { addCustomSpans } from '@atlaskit/react-ufo/interaction-metrics';
2
+ const mediaLabelStack = [{
3
+ name: 'media'
4
+ }];
5
+ export const sendUfoDurationMetrics = (ufoDurationMetrics, endpoint) => {
6
+ const labelStack = [...mediaLabelStack, {
7
+ name: endpoint
8
+ }];
9
+ Object.entries(ufoDurationMetrics).map(([name, {
10
+ start,
11
+ end,
12
+ size
13
+ }]) => {
14
+ addCustomSpans(name, start, end, size, labelStack);
15
+ });
16
+ };
@@ -5,7 +5,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
5
5
  import { MediaCardError } from '../errors';
6
6
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
7
7
  const packageName = "@atlaskit/media-card";
8
- const packageVersion = "78.7.0";
8
+ const packageVersion = "78.8.0";
9
9
  let concurrentExperience;
10
10
  const getExperience = id => {
11
11
  if (!concurrentExperience) {
@@ -11,7 +11,7 @@ import { startResourceObserver, setAnalyticsContext } from '../utils/mediaPerfor
11
11
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
13
  var packageName = "@atlaskit/media-card";
14
- var packageVersion = "78.7.0";
14
+ var packageVersion = "78.8.0";
15
15
  export var CardBase = function CardBase(_ref) {
16
16
  var identifier = _ref.identifier,
17
17
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
83
83
  }(React.Component);
84
84
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
85
85
  var packageName = "@atlaskit/media-card";
86
- var packageVersion = "78.7.0";
86
+ var packageVersion = "78.8.0";
87
87
 
88
88
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
89
89
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
103
103
  ErrorBoundary = _this$state.ErrorBoundary;
104
104
  var analyticsContext = {
105
105
  packageVersion: "@atlaskit/media-card",
106
- packageName: "78.7.0",
106
+ packageName: "78.8.0",
107
107
  componentName: 'mediaInlineCard',
108
108
  component: 'mediaInlineCard'
109
109
  };
@@ -0,0 +1,92 @@
1
+ var getStartedAt = function getStartedAt(entry, navigationTime) {
2
+ return entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0);
3
+ };
4
+ export var createMediaDurationMetrics = function createMediaDurationMetrics(entry, navigationTime) {
5
+ var _entry$serverTiming$f, _entry$serverTiming$f2;
6
+ return {
7
+ startedAt: getStartedAt(entry, navigationTime),
8
+ /**
9
+ * Performance resource timing data regarding the loading of an
10
+ * application's resources as described in
11
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
12
+ */
13
+ transferSize: entry.transferSize,
14
+ decodedBodySize: entry.decodedBodySize,
15
+ totalDuration: entry.duration,
16
+ initiatorType: entry.initiatorType,
17
+ // value can be 'fetch' or 'img'
18
+ responseEnd: entry.responseEnd,
19
+ tcpHandshakeTime: entry.connectEnd - entry.connectStart,
20
+ dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
21
+ redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
22
+ tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
23
+ timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
24
+ browserCacheHit: entry.transferSize === 0,
25
+ nextHopProtocol: entry.nextHopProtocol,
26
+ /**
27
+ * `interimRequestTime` represents the entire time the browser took to
28
+ * request the resource from the server. This includes the interim response time
29
+ * (for example, 100 Continue or 103 Early Hints).
30
+ *
31
+ * i.e. It is the time taken for the request to be sent
32
+ * + the waiting time for the server to send a response
33
+ *
34
+ * Please, note that this value
35
+ * is distinctly different from the aforementioned document.
36
+ */
37
+ interimRequestTime: entry.responseStart - entry.requestStart,
38
+ /**
39
+ * `requestInvocationTime` represents the actual time the browser took to request
40
+ * the resource from the server (i.e. it does not include the interim reponse
41
+ * time).
42
+ * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
43
+ * available in Chrome, but not in FireFox or Safari. This value will be undefined
44
+ * when `firstInterimResponseStart` is unavailable.
45
+ */
46
+ requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
47
+ /**
48
+ * `contentDownloadTime` represents the time taken for the browser to receive
49
+ * the resource from the server. This may be cut short if the transport
50
+ * connection is closed.
51
+ */
52
+ contentDownloadTime: entry.responseEnd - entry.responseStart,
53
+ /**
54
+ * The user agent string for the current browser
55
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
56
+ */
57
+ userAgent: window.navigator.userAgent,
58
+ /**
59
+ * Performance resource timing data sent by the server. This includes:
60
+ *
61
+ * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
62
+ *
63
+ * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
64
+ * how long the it took the CDN to respond to the frontend.
65
+ *
66
+ * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
67
+ * time the Media backend took to respond to the CDN, in the case that the CDN
68
+ * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
69
+ */
70
+ cdnCacheHit: entry.serverTiming.find(function (_ref) {
71
+ var name = _ref.name;
72
+ return name === 'cdn-cache-hit';
73
+ }) ? true : false,
74
+ cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(function (_ref2) {
75
+ var name = _ref2.name;
76
+ return name === 'cdn-downstream-fbl';
77
+ })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
78
+ cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(function (_ref3) {
79
+ var name = _ref3.name;
80
+ return name === 'cdn-upstream-fbl';
81
+ })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
82
+ };
83
+ };
84
+ export var createUfoDurationMetrics = function createUfoDurationMetrics(entry, navigationTime) {
85
+ return {
86
+ resourceTiming: {
87
+ start: getStartedAt(entry, navigationTime),
88
+ end: entry.responseEnd
89
+ }
90
+ /* More metrics to add here */
91
+ };
92
+ };
@@ -1,16 +1,14 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common/analytics';
2
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { createMediaDurationMetrics, createUfoDurationMetrics } from './durationMetrics';
7
+ import { sendUfoDurationMetrics } from './ufo';
3
8
  var MEDIA_CARD_PERF_STATE_KEY = '__mediaCardPerfState_asflkajsdflja';
4
9
  var urlRegex = /https:\/\/(?:media\.(?:dev|staging|prod)\.atl-paas\.net|api\.media\.atlassian\.com|media-cdn(?:\.stg\.|\.)atlassian\.com)\/file\/([^/]+)\/image.*[?&]source=mediaCard/;
5
10
  var clientIdParamRegex = /[?&]clientId=([^&]+)/;
6
11
  var ssrParamRegex = /[?&]token=([^&]+)/;
7
-
8
- /**
9
- * `ExperimentalPerformanceResourceTiming` type accounts for the experimental value `firstInterimResponseStart`
10
- * which is present in Chrome, but not present in FireFox or Safari.
11
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/firstInterimResponseStart
12
- */
13
-
14
12
  var createAndGetResourceObserver = function createAndGetResourceObserver() {
15
13
  return new PerformanceObserver(function (list) {
16
14
  list.getEntries().forEach(function (baseEntry) {
@@ -20,100 +18,30 @@ var createAndGetResourceObserver = function createAndGetResourceObserver() {
20
18
  var matchClientId = entry.name.match(clientIdParamRegex);
21
19
  var matchSSR = entry.name.match(ssrParamRegex);
22
20
  if (matchFileId && (_window$MEDIA_CARD_PE = window[MEDIA_CARD_PERF_STATE_KEY]) !== null && _window$MEDIA_CARD_PE !== void 0 && _window$MEDIA_CARD_PE.mediaCardCreateAnalyticsEvent) {
23
- var _entry$serverTiming$f, _entry$serverTiming$f2;
24
21
  var fileId = matchFileId[1];
25
22
  var clientId = matchClientId === null || matchClientId === void 0 ? void 0 : matchClientId[1];
26
23
  var ssr = matchSSR ? 'server' : undefined;
27
24
  var navigationTime = performance.getEntriesByType('navigation')[0];
25
+ var mediaDurationMetrics = createMediaDurationMetrics(entry, navigationTime);
28
26
  var event = window[MEDIA_CARD_PERF_STATE_KEY].mediaCardCreateAnalyticsEvent({
29
27
  eventType: 'operational',
30
28
  action: 'succeeded',
31
29
  actionSubject: 'mediaCardPerfObserver',
32
- attributes: {
30
+ attributes: _objectSpread({
33
31
  ssr: ssr,
34
32
  fileId: fileId,
35
33
  mediaClientId: clientId,
36
- startedAt: entry.startTime - ((navigationTime === null || navigationTime === void 0 ? void 0 : navigationTime.domContentLoadedEventEnd) || 0),
37
34
  featureFlags: {
38
35
  'media-cdn-single-host': fg('platform.media-cdn-single-host')
39
- },
40
- /**
41
- * Performance resource timing data regarding the loading of an
42
- * application's resources as described in
43
- * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
44
- */
45
- transferSize: entry.transferSize,
46
- decodedBodySize: entry.decodedBodySize,
47
- totalDuration: entry.duration,
48
- initiatorType: entry.initiatorType,
49
- // value can be 'fetch' or 'img'
50
- responseEnd: entry.responseEnd,
51
- tcpHandshakeTime: entry.connectEnd - entry.connectStart,
52
- dnsLookupTime: entry.domainLookupEnd - entry.domainLookupStart,
53
- redirectTimeTaken: entry.redirectEnd - entry.redirectStart,
54
- tlsConnectNegotiationTime: entry.requestStart - entry.secureConnectionStart,
55
- timeTakenToFetchWithoutRedirect: entry.responseEnd - entry.fetchStart,
56
- browserCacheHit: entry.transferSize === 0,
57
- nextHopProtocol: entry.nextHopProtocol,
58
- /**
59
- * `interimRequestTime` represents the entire time the browser took to
60
- * request the resource from the server. This includes the interim response time
61
- * (for example, 100 Continue or 103 Early Hints).
62
- *
63
- * i.e. It is the time taken for the request to be sent
64
- * + the waiting time for the server to send a response
65
- *
66
- * Please, note that this value
67
- * is distinctly different from the aforementioned document.
68
- */
69
- interimRequestTime: entry.responseStart - entry.requestStart,
70
- /**
71
- * `requestInvocationTime` represents the actual time the browser took to request
72
- * the resource from the server (i.e. it does not include the interim reponse
73
- * time).
74
- * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
75
- * available in Chrome, but not in FireFox or Safari. This value will be undefined
76
- * when `firstInterimResponseStart` is unavailable.
77
- */
78
- requestInvocationTime: entry.firstInterimResponseStart ? entry.firstInterimResponseStart - entry.requestStart : undefined,
79
- /**
80
- * `contentDownloadTime` represents the time taken for the browser to receive
81
- * the resource from the server. This may be cut short if the transport
82
- * connection is closed.
83
- */
84
- contentDownloadTime: entry.responseEnd - entry.responseStart,
85
- /**
86
- * The user agent string for the current browser
87
- * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
88
- */
89
- userAgent: window.navigator.userAgent,
90
- /**
91
- * Performance resource timing data sent by the server. This includes:
92
- *
93
- * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
94
- *
95
- * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
96
- * how long the it took the CDN to respond to the frontend.
97
- *
98
- * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
99
- * time the Media backend took to respond to the CDN, in the case that the CDN
100
- * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
101
- */
102
- cdnCacheHit: entry.serverTiming.find(function (_ref) {
103
- var name = _ref.name;
104
- return name === 'cdn-cache-hit';
105
- }) ? true : false,
106
- cdnDownstreamFBL: (_entry$serverTiming$f = entry.serverTiming.find(function (_ref2) {
107
- var name = _ref2.name;
108
- return name === 'cdn-downstream-fbl';
109
- })) === null || _entry$serverTiming$f === void 0 ? void 0 : _entry$serverTiming$f.duration,
110
- cdnUpstreamFBL: (_entry$serverTiming$f2 = entry.serverTiming.find(function (_ref3) {
111
- var name = _ref3.name;
112
- return name === 'cdn-upstream-fbl';
113
- })) === null || _entry$serverTiming$f2 === void 0 ? void 0 : _entry$serverTiming$f2.duration
114
- }
36
+ }
37
+ }, mediaDurationMetrics)
115
38
  });
116
39
  event.fire(ANALYTICS_MEDIA_CHANNEL);
40
+ if (fg('platform_media_card_ufo_network_metrics')) {
41
+ var ufoDurationMetrics = createUfoDurationMetrics(entry, navigationTime);
42
+ var endpointName = 'image';
43
+ sendUfoDurationMetrics(ufoDurationMetrics, endpointName);
44
+ }
117
45
  }
118
46
  });
119
47
  });
@@ -0,0 +1,19 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { addCustomSpans } from '@atlaskit/react-ufo/interaction-metrics';
3
+ var mediaLabelStack = [{
4
+ name: 'media'
5
+ }];
6
+ export var sendUfoDurationMetrics = function sendUfoDurationMetrics(ufoDurationMetrics, endpoint) {
7
+ var labelStack = [].concat(mediaLabelStack, [{
8
+ name: endpoint
9
+ }]);
10
+ Object.entries(ufoDurationMetrics).map(function (_ref) {
11
+ var _ref2 = _slicedToArray(_ref, 2),
12
+ name = _ref2[0],
13
+ _ref2$ = _ref2[1],
14
+ start = _ref2$.start,
15
+ end = _ref2$.end,
16
+ size = _ref2$.size;
17
+ addCustomSpans(name, start, end, size, labelStack);
18
+ });
19
+ };
@@ -8,7 +8,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
8
8
  import { MediaCardError } from '../errors';
9
9
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
10
10
  var packageName = "@atlaskit/media-card";
11
- var packageVersion = "78.7.0";
11
+ var packageVersion = "78.8.0";
12
12
  var concurrentExperience;
13
13
  var getExperience = function getExperience(id) {
14
14
  if (!concurrentExperience) {
@@ -0,0 +1,75 @@
1
+ import { type ExperimentalPerformanceResourceTiming } from './types';
2
+ export type MediaDurationMetrics = ReturnType<typeof createMediaDurationMetrics>;
3
+ export type UfoDurationMetrics = Record<string, {
4
+ start: number;
5
+ end?: number;
6
+ size?: number;
7
+ }>;
8
+ export declare const createMediaDurationMetrics: (entry: ExperimentalPerformanceResourceTiming, navigationTime: PerformanceNavigationTiming | undefined) => {
9
+ startedAt: number;
10
+ /**
11
+ * Performance resource timing data regarding the loading of an
12
+ * application's resources as described in
13
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
14
+ */
15
+ transferSize: number;
16
+ decodedBodySize: number;
17
+ totalDuration: number;
18
+ initiatorType: string;
19
+ responseEnd: number;
20
+ tcpHandshakeTime: number;
21
+ dnsLookupTime: number;
22
+ redirectTimeTaken: number;
23
+ tlsConnectNegotiationTime: number;
24
+ timeTakenToFetchWithoutRedirect: number;
25
+ browserCacheHit: boolean;
26
+ nextHopProtocol: string;
27
+ /**
28
+ * `interimRequestTime` represents the entire time the browser took to
29
+ * request the resource from the server. This includes the interim response time
30
+ * (for example, 100 Continue or 103 Early Hints).
31
+ *
32
+ * i.e. It is the time taken for the request to be sent
33
+ * + the waiting time for the server to send a response
34
+ *
35
+ * Please, note that this value
36
+ * is distinctly different from the aforementioned document.
37
+ */
38
+ interimRequestTime: number;
39
+ /**
40
+ * `requestInvocationTime` represents the actual time the browser took to request
41
+ * the resource from the server (i.e. it does not include the interim reponse
42
+ * time).
43
+ * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
44
+ * available in Chrome, but not in FireFox or Safari. This value will be undefined
45
+ * when `firstInterimResponseStart` is unavailable.
46
+ */
47
+ requestInvocationTime: number | undefined;
48
+ /**
49
+ * `contentDownloadTime` represents the time taken for the browser to receive
50
+ * the resource from the server. This may be cut short if the transport
51
+ * connection is closed.
52
+ */
53
+ contentDownloadTime: number;
54
+ /**
55
+ * The user agent string for the current browser
56
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
57
+ */
58
+ userAgent: string;
59
+ /**
60
+ * Performance resource timing data sent by the server. This includes:
61
+ *
62
+ * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
63
+ *
64
+ * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
65
+ * how long the it took the CDN to respond to the frontend.
66
+ *
67
+ * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
68
+ * time the Media backend took to respond to the CDN, in the case that the CDN
69
+ * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
70
+ */
71
+ cdnCacheHit: boolean;
72
+ cdnDownstreamFBL: number | undefined;
73
+ cdnUpstreamFBL: number | undefined;
74
+ };
75
+ export declare const createUfoDurationMetrics: (entry: ExperimentalPerformanceResourceTiming, navigationTime: PerformanceNavigationTiming | undefined) => UfoDurationMetrics;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `ExperimentalPerformanceResourceTiming` type accounts for the experimental value `firstInterimResponseStart`
3
+ * which is present in Chrome, but not present in FireFox or Safari.
4
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/firstInterimResponseStart
5
+ */
6
+ export interface ExperimentalPerformanceResourceTiming extends PerformanceResourceTiming {
7
+ firstInterimResponseStart?: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { type UfoDurationMetrics } from './durationMetrics';
2
+ export declare const sendUfoDurationMetrics: (ufoDurationMetrics: UfoDurationMetrics, endpoint: 'image' | 'items') => void;
@@ -0,0 +1,75 @@
1
+ import { type ExperimentalPerformanceResourceTiming } from './types';
2
+ export type MediaDurationMetrics = ReturnType<typeof createMediaDurationMetrics>;
3
+ export type UfoDurationMetrics = Record<string, {
4
+ start: number;
5
+ end?: number;
6
+ size?: number;
7
+ }>;
8
+ export declare const createMediaDurationMetrics: (entry: ExperimentalPerformanceResourceTiming, navigationTime: PerformanceNavigationTiming | undefined) => {
9
+ startedAt: number;
10
+ /**
11
+ * Performance resource timing data regarding the loading of an
12
+ * application's resources as described in
13
+ * https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
14
+ */
15
+ transferSize: number;
16
+ decodedBodySize: number;
17
+ totalDuration: number;
18
+ initiatorType: string;
19
+ responseEnd: number;
20
+ tcpHandshakeTime: number;
21
+ dnsLookupTime: number;
22
+ redirectTimeTaken: number;
23
+ tlsConnectNegotiationTime: number;
24
+ timeTakenToFetchWithoutRedirect: number;
25
+ browserCacheHit: boolean;
26
+ nextHopProtocol: string;
27
+ /**
28
+ * `interimRequestTime` represents the entire time the browser took to
29
+ * request the resource from the server. This includes the interim response time
30
+ * (for example, 100 Continue or 103 Early Hints).
31
+ *
32
+ * i.e. It is the time taken for the request to be sent
33
+ * + the waiting time for the server to send a response
34
+ *
35
+ * Please, note that this value
36
+ * is distinctly different from the aforementioned document.
37
+ */
38
+ interimRequestTime: number;
39
+ /**
40
+ * `requestInvocationTime` represents the actual time the browser took to request
41
+ * the resource from the server (i.e. it does not include the interim reponse
42
+ * time).
43
+ * NOTE: it relies on an experimental feature (`firstInterimResponseStart`) that is
44
+ * available in Chrome, but not in FireFox or Safari. This value will be undefined
45
+ * when `firstInterimResponseStart` is unavailable.
46
+ */
47
+ requestInvocationTime: number | undefined;
48
+ /**
49
+ * `contentDownloadTime` represents the time taken for the browser to receive
50
+ * the resource from the server. This may be cut short if the transport
51
+ * connection is closed.
52
+ */
53
+ contentDownloadTime: number;
54
+ /**
55
+ * The user agent string for the current browser
56
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
57
+ */
58
+ userAgent: string;
59
+ /**
60
+ * Performance resource timing data sent by the server. This includes:
61
+ *
62
+ * `cdnCacheHit` is a boolean determining whether the CDN cache was hit or missed.
63
+ *
64
+ * `cdnDownstreamFBL` is the 'CDN Downstream First Byte Latency'. It represents
65
+ * how long the it took the CDN to respond to the frontend.
66
+ *
67
+ * `cdnUpstreamFBL` is the 'CDN Upstream First Byte Latency'. It represents the
68
+ * time the Media backend took to respond to the CDN, in the case that the CDN
69
+ * cache was a miss. Notably, this timing is a subset of the `cdnDownstreamFBL` timing.
70
+ */
71
+ cdnCacheHit: boolean;
72
+ cdnDownstreamFBL: number | undefined;
73
+ cdnUpstreamFBL: number | undefined;
74
+ };
75
+ export declare const createUfoDurationMetrics: (entry: ExperimentalPerformanceResourceTiming, navigationTime: PerformanceNavigationTiming | undefined) => UfoDurationMetrics;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `ExperimentalPerformanceResourceTiming` type accounts for the experimental value `firstInterimResponseStart`
3
+ * which is present in Chrome, but not present in FireFox or Safari.
4
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/firstInterimResponseStart
5
+ */
6
+ export interface ExperimentalPerformanceResourceTiming extends PerformanceResourceTiming {
7
+ firstInterimResponseStart?: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { type UfoDurationMetrics } from './durationMetrics';
2
+ export declare const sendUfoDurationMetrics: (ufoDurationMetrics: UfoDurationMetrics, endpoint: 'image' | 'items') => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "78.7.0",
3
+ "version": "78.8.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,9 +36,9 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@atlaskit/analytics-next": "^10.1.0",
39
- "@atlaskit/dropdown-menu": "^12.20.0",
39
+ "@atlaskit/dropdown-menu": "^12.21.0",
40
40
  "@atlaskit/editor-shared-styles": "^3.0.0",
41
- "@atlaskit/icon": "^22.22.0",
41
+ "@atlaskit/icon": "^22.24.0",
42
42
  "@atlaskit/media-client": "^28.0.0",
43
43
  "@atlaskit/media-client-react": "^2.2.0",
44
44
  "@atlaskit/media-common": "^11.6.0",
@@ -48,8 +48,9 @@
48
48
  "@atlaskit/media-viewer": "^49.2.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.3.0",
50
50
  "@atlaskit/primitives": "^12.2.0",
51
+ "@atlaskit/react-ufo": "^1.1.0",
51
52
  "@atlaskit/spinner": "^16.3.0",
52
- "@atlaskit/theme": "^13.1.0",
53
+ "@atlaskit/theme": "^14.0.0",
53
54
  "@atlaskit/tokens": "^2.0.0",
54
55
  "@atlaskit/tooltip": "^18.8.0",
55
56
  "@atlaskit/ufo": "^0.3.0",
@@ -111,6 +112,9 @@
111
112
  },
112
113
  "platform-visual-refresh-icons": {
113
114
  "type": "boolean"
115
+ },
116
+ "platform_media_card_ufo_network_metrics": {
117
+ "type": "boolean"
114
118
  }
115
119
  },
116
120
  "techstack": {