@atlaskit/media-card 79.12.0 → 79.13.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 (38) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/externalImageCard.js +17 -12
  4. package/dist/cjs/card/fileCard.js +34 -12
  5. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  6. package/dist/cjs/card/ui/titleBox/failedTitleBox.js +0 -2
  7. package/dist/cjs/inline/loader.js +1 -1
  8. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  9. package/dist/cjs/utils/globalScope/globalScope.js +2 -1
  10. package/dist/cjs/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  11. package/dist/cjs/utils/ufoExperiences.js +454 -68
  12. package/dist/es2019/card/card.js +1 -1
  13. package/dist/es2019/card/externalImageCard.js +16 -13
  14. package/dist/es2019/card/fileCard.js +33 -13
  15. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  16. package/dist/es2019/card/ui/titleBox/failedTitleBox.js +0 -2
  17. package/dist/es2019/inline/loader.js +1 -1
  18. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  19. package/dist/es2019/utils/globalScope/globalScope.js +1 -0
  20. package/dist/es2019/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  21. package/dist/es2019/utils/ufoExperiences.js +449 -72
  22. package/dist/esm/card/card.js +1 -1
  23. package/dist/esm/card/externalImageCard.js +18 -13
  24. package/dist/esm/card/fileCard.js +35 -13
  25. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  26. package/dist/esm/card/ui/titleBox/failedTitleBox.js +0 -2
  27. package/dist/esm/inline/loader.js +1 -1
  28. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  29. package/dist/esm/utils/globalScope/globalScope.js +1 -0
  30. package/dist/esm/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  31. package/dist/esm/utils/ufoExperiences.js +454 -68
  32. package/dist/types/utils/globalScope/globalScope.d.ts +2 -0
  33. package/dist/types/utils/mediaPerformanceObserver/durationMetrics.d.ts +1 -0
  34. package/dist/types/utils/ufoExperiences.d.ts +88 -5
  35. package/dist/types-ts4.5/utils/globalScope/globalScope.d.ts +2 -0
  36. package/dist/types-ts4.5/utils/mediaPerformanceObserver/durationMetrics.d.ts +1 -0
  37. package/dist/types-ts4.5/utils/ufoExperiences.d.ts +88 -5
  38. package/package.json +6 -6
@@ -11,7 +11,7 @@ import { generateUniqueId } from '../utils/generateUniqueId';
11
11
  import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
12
12
  import { getMediaCardCursor } from '../utils/getMediaCardCursor';
13
13
  import { getFileDetails } from '../utils/metadata';
14
- import { abortUfoExperience, completeUfoExperience, shouldPerformanceBeSampled, startUfoExperience } from '../utils/ufoExperiences';
14
+ import { shouldPerformanceBeSampled, useMediaCardUfoExperience } from '../utils/ufoExperiences';
15
15
  import { useCurrentValueRef } from '../utils/useCurrentValueRef';
16
16
  import { usePrevious } from '../utils/usePrevious';
17
17
  import { ViewportDetector } from '../utils/viewportDetector';
@@ -181,7 +181,13 @@ export const FileCard = ({
181
181
  skipRemote: !isCardVisible,
182
182
  source: 'mediaCard'
183
183
  });
184
- const shouldSendPerformanceEventRef = useRef(shouldPerformanceBeSampled());
184
+ const shouldSendPerformanceEvent = useMemo(() => shouldPerformanceBeSampled(), []);
185
+
186
+ // UFO experience hook - creates a unique experience instance per card
187
+ const ufoExperience = useMediaCardUfoExperience({
188
+ instanceId: internalOccurrenceKey,
189
+ enabled: shouldSendPerformanceEvent
190
+ });
185
191
  const [error, setError] = useState();
186
192
 
187
193
  // CXP-2723 TODO: TEMPORARY VARIABLES
@@ -258,6 +264,7 @@ export const FileCard = ({
258
264
  //----------------------------------------------------------------//
259
265
 
260
266
  const fireOperationalEventRef = useCurrentValueRef(() => {
267
+ var _ssrReliability$serve, _ssrReliability$clien;
261
268
  const timeElapsedTillEvent = performanceNow();
262
269
  const durationSinceCommenced = timeElapsedTillEvent - timeElapsedTillCommenced;
263
270
  const performanceAttributes = {
@@ -267,7 +274,19 @@ export const FileCard = ({
267
274
  }
268
275
  };
269
276
  createAnalyticsEvent && fireOperationalEvent(createAnalyticsEvent, finalStatus, fileAttributes, performanceAttributes, ssrReliability, finalError, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
270
- shouldSendPerformanceEventRef.current && completeUfoExperience(internalOccurrenceKey, finalStatus, fileAttributes, fileStateFlagsRef.current, ssrReliability, finalError);
277
+
278
+ // Determine SSR preview info for UFO timing strategy
279
+ // wasSSRAttempted is only true when SSR was used AND preview is non-lazy
280
+ // because lazy SSR defers loading, so it behaves like CSR for timing purposes
281
+ const isSSRNonLazy = !!ssr && (preview === null || preview === void 0 ? void 0 : preview.lazy) !== true;
282
+ const wasSSRSuccessful = isSSRNonLazy && (((_ssrReliability$serve = ssrReliability.server) === null || _ssrReliability$serve === void 0 ? void 0 : _ssrReliability$serve.status) === 'success' || ((_ssrReliability$clien = ssrReliability.client) === null || _ssrReliability$clien === void 0 ? void 0 : _ssrReliability$clien.status) === 'success');
283
+ const ssrPreviewInfo = {
284
+ dataUri: preview === null || preview === void 0 ? void 0 : preview.dataURI,
285
+ srcset: preview === null || preview === void 0 ? void 0 : preview.srcSet,
286
+ wasSSRAttempted: isSSRNonLazy,
287
+ wasSSRSuccessful
288
+ };
289
+ ufoExperience.complete(finalStatus, fileAttributes, fileStateFlagsRef.current, ssrReliability, finalError, ssrPreviewInfo);
271
290
  });
272
291
  const fireNonCriticalErrorEventRef = useCurrentValueRef(error => {
273
292
  createAnalyticsEvent && fireNonCriticalErrorEvent(createAnalyticsEvent, finalStatus, fileAttributes, ssrReliability, error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
@@ -278,19 +297,20 @@ export const FileCard = ({
278
297
  }
279
298
  }, [nonCriticalError, fireNonCriticalErrorEventRef]);
280
299
  const startUfoExperienceRef = useCurrentValueRef(() => {
281
- if (shouldSendPerformanceEventRef.current) {
282
- startUfoExperience(internalOccurrenceKey);
283
- }
300
+ // For non-lazy SSR previews, use interaction start time as the experience start time
301
+ // because the image loading started at interaction start, not at mount time
302
+ const isSSRNonLazy = !!ssr && (preview === null || preview === void 0 ? void 0 : preview.lazy) !== true;
303
+ ufoExperience.start({
304
+ useInteractionTime: isSSRNonLazy
305
+ });
284
306
  });
285
307
  const fireAbortedEventRef = useCurrentValueRef(() => {
286
308
  // UFO won't abort if it's already in a final state (succeeded, failed, aborted, etc)
287
- if (shouldSendPerformanceEventRef.current) {
288
- abortUfoExperience(internalOccurrenceKey, {
289
- fileAttributes,
290
- fileStateFlags: fileStateFlagsRef === null || fileStateFlagsRef === void 0 ? void 0 : fileStateFlagsRef.current,
291
- ssrReliability: ssrReliability
292
- });
293
- }
309
+ ufoExperience.abort({
310
+ fileAttributes,
311
+ fileStateFlags: fileStateFlagsRef === null || fileStateFlagsRef === void 0 ? void 0 : fileStateFlagsRef.current,
312
+ ssrReliability: ssrReliability
313
+ });
294
314
  });
295
315
 
296
316
  //----------------------------------------------------------------//
@@ -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 = "0.0.0-development";
69
+ const packageVersion = "79.13.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({
@@ -16,8 +16,6 @@ export const FailedTitleBox = ({
16
16
  breakpoint: breakpoint
17
17
  }, /*#__PURE__*/React.createElement(ErrorMessageWrapper, null, /*#__PURE__*/React.createElement(EditorWarningIcon, {
18
18
  label: 'Warning',
19
- LEGACY_size: 'small',
20
- LEGACY_margin: `0 ${"var(--ds-space-negative-025, -2px)"}`,
21
19
  color: `var(--ds-text-danger, ${R300})`,
22
20
  size: "small"
23
21
  }), /*#__PURE__*/React.createElement("span", {
@@ -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: "0.0.0-development",
40
+ packageName: "79.13.0",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -57,9 +57,7 @@ const ErrorBoundaryComponent = ({
57
57
  React.createElement("span", {
58
58
  style: style
59
59
  }, /*#__PURE__*/React.createElement(WarningIcon, {
60
- LEGACY_margin: `0 ${"var(--ds-space-negative-050, -4px)"} 0 0`,
61
60
  label: "error",
62
- LEGACY_size: "small",
63
61
  color: `var(--ds-icon-danger, ${R300})`,
64
62
  size: "small"
65
63
  }), message)
@@ -7,6 +7,7 @@ import { printFunctionCall, printScript } from '../printScript';
7
7
 
8
8
  export const GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
9
9
  export const GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
10
+ export const GLOBAL_MEDIA_PERFORMANCE_ENTRIES = 'performanceEntries';
10
11
  export function getMediaGlobalScope(globalScope = window) {
11
12
  // Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
12
13
  const namespace = '__MEDIA_INTERNAL';
@@ -81,6 +81,7 @@ export const createMediaDurationMetrics = (entry, interactionStartTime) => {
81
81
  totalDuration: entry.duration,
82
82
  initiatorType: entry.initiatorType,
83
83
  // value can be 'fetch' or 'img'
84
+ endedAt: entry.responseEnd - interactionStartTime,
84
85
  responseEnd: entry.responseEnd,
85
86
  browserCacheHit: entry.transferSize === 0,
86
87
  nextHopProtocol: entry.nextHopProtocol,