@atlaskit/media-card 74.3.2 → 74.4.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 (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/card/card.js +27 -18
  3. package/dist/cjs/card/cardAnalytics.js +16 -5
  4. package/dist/cjs/card/cardLoader.js +12 -3
  5. package/dist/cjs/card/cardState.js +11 -13
  6. package/dist/cjs/card/media-card-analytics-error-boundary.js +129 -0
  7. package/dist/cjs/card/ui/unhandledErrorCard/index.js +114 -0
  8. package/dist/cjs/card/ui/unhandledErrorCard/types.js +5 -0
  9. package/dist/cjs/errors.js +12 -3
  10. package/dist/cjs/inline/loader.js +4 -4
  11. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +113 -0
  12. package/dist/cjs/utils/analytics.js +41 -10
  13. package/dist/cjs/utils/ufoExperiences.js +1 -1
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/es2019/card/card.js +29 -17
  16. package/dist/es2019/card/cardAnalytics.js +9 -5
  17. package/dist/es2019/card/cardLoader.js +12 -3
  18. package/dist/es2019/card/cardState.js +12 -7
  19. package/dist/es2019/card/media-card-analytics-error-boundary.js +90 -0
  20. package/dist/es2019/card/ui/unhandledErrorCard/index.js +80 -0
  21. package/dist/es2019/card/ui/unhandledErrorCard/types.js +1 -0
  22. package/dist/es2019/errors.js +13 -2
  23. package/dist/es2019/inline/loader.js +4 -4
  24. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +75 -0
  25. package/dist/es2019/utils/analytics.js +32 -9
  26. package/dist/es2019/utils/ufoExperiences.js +1 -1
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/card/card.js +28 -19
  29. package/dist/esm/card/cardAnalytics.js +12 -4
  30. package/dist/esm/card/cardLoader.js +12 -3
  31. package/dist/esm/card/cardState.js +12 -11
  32. package/dist/esm/card/media-card-analytics-error-boundary.js +115 -0
  33. package/dist/esm/card/ui/unhandledErrorCard/index.js +94 -0
  34. package/dist/esm/card/ui/unhandledErrorCard/types.js +1 -0
  35. package/dist/esm/errors.js +12 -3
  36. package/dist/esm/inline/loader.js +5 -5
  37. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +99 -0
  38. package/dist/esm/utils/analytics.js +34 -9
  39. package/dist/esm/utils/ufoExperiences.js +1 -1
  40. package/dist/esm/version.json +1 -1
  41. package/dist/types/card/card.d.ts +1 -1
  42. package/dist/types/card/cardAnalytics.d.ts +2 -1
  43. package/dist/types/card/cardState.d.ts +6 -1
  44. package/dist/types/card/getCardPreview/index.d.ts +1 -1
  45. package/dist/types/card/media-card-analytics-error-boundary.d.ts +14 -0
  46. package/dist/types/card/ui/unhandledErrorCard/index.d.ts +7 -0
  47. package/dist/types/card/ui/unhandledErrorCard/types.d.ts +6 -0
  48. package/dist/types/errors.d.ts +2 -2
  49. package/dist/types/inline/mediaInlineAnalyticsErrorBoundary.d.ts +11 -0
  50. package/dist/types/types.d.ts +3 -0
  51. package/dist/types/utils/analytics.d.ts +26 -6
  52. package/example-helpers/styles.ts +13 -0
  53. package/package.json +9 -8
  54. package/report.api.md +2 -2
  55. package/dist/cjs/utils/media-card-analytics-error-boundary.js +0 -59
  56. package/dist/es2019/utils/media-card-analytics-error-boundary.js +0 -19
  57. package/dist/esm/utils/media-card-analytics-error-boundary.js +0 -46
  58. package/dist/types/utils/media-card-analytics-error-boundary.d.ts +0 -10
@@ -0,0 +1 @@
1
+ export {};
@@ -142,11 +142,20 @@ export var isUnsupportedLocalPreviewError = function isUnsupportedLocalPreviewEr
142
142
  };
143
143
  export function isImageLoadError(err) {
144
144
  return err instanceof ImageLoadError;
145
- } // In a try/catch statement, the error caught is the type of any.
145
+ } // In a try/catch statement, the error caught is the type of unknown.
146
146
  // We can use this helper to ensure that the error handled is the type of MediaCardError if unsure
147
+ // If updatePrimaryReason is true, if it's a MediaCardError already, it will update it's primary reason
147
148
 
148
- export var ensureMediaCardError = function ensureMediaCardError(primaryReason, error) {
149
- return isMediaCardError(error) ? error : new MediaCardError(primaryReason, error);
149
+ export var ensureMediaCardError = function ensureMediaCardError(primaryReason, error, updatePrimaryReason) {
150
+ if (isMediaCardError(error)) {
151
+ if (updatePrimaryReason && error.primaryReason !== primaryReason) {
152
+ return new MediaCardError(primaryReason, error.secondaryError);
153
+ }
154
+
155
+ return error;
156
+ }
157
+
158
+ return new MediaCardError(primaryReason, error);
150
159
  };
151
160
  export var isUploadError = function isUploadError(error) {
152
161
  return error && error.primaryReason === 'upload';
@@ -46,7 +46,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
46
46
  key: "componentDidMount",
47
47
  value: function () {
48
48
  var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
49
- var _yield$Promise$all, _yield$Promise$all2, mediaClient, cardModule, mediaCardErrorBoundaryModule;
49
+ var _yield$Promise$all, _yield$Promise$all2, mediaClient, cardModule, mediaInlineErrorBoundaryModule;
50
50
 
51
51
  return _regeneratorRuntime.wrap(function _callee$(_context) {
52
52
  while (1) {
@@ -66,17 +66,17 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
66
66
  '@atlaskit/media-client'), import(
67
67
  /* webpackChunkName: "@atlaskit-internal_inline-media-card" */
68
68
  './mediaInlineCard'), import(
69
- /* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
70
- '../utils/media-card-analytics-error-boundary')]);
69
+ /* webpackChunkName: "@atlaskit-internal_media-inline-error-boundary" */
70
+ './mediaInlineAnalyticsErrorBoundary')]);
71
71
 
72
72
  case 5:
73
73
  _yield$Promise$all = _context.sent;
74
74
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
75
75
  mediaClient = _yield$Promise$all2[0];
76
76
  cardModule = _yield$Promise$all2[1];
77
- mediaCardErrorBoundaryModule = _yield$Promise$all2[2];
77
+ mediaInlineErrorBoundaryModule = _yield$Promise$all2[2];
78
78
  MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
79
- MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
79
+ MediaInlineCardLoader.ErrorBoundary = mediaInlineErrorBoundaryModule.default;
80
80
 
81
81
  if (this.isMounted) {
82
82
  this.setState({
@@ -0,0 +1,99 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+
13
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
+
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+
17
+ import React from 'react';
18
+ import { withMediaAnalyticsContext } from '@atlaskit/media-common';
19
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
20
+ import { fireMediaCardEvent } from '../utils/analytics';
21
+
22
+ var WrappedMediaInlineAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Component) {
23
+ _inherits(WrappedMediaInlineAnalyticsErrorBoundary, _React$Component);
24
+
25
+ var _super = _createSuper(WrappedMediaInlineAnalyticsErrorBoundary);
26
+
27
+ function WrappedMediaInlineAnalyticsErrorBoundary(props) {
28
+ var _this;
29
+
30
+ _classCallCheck(this, WrappedMediaInlineAnalyticsErrorBoundary);
31
+
32
+ _this = _super.call(this, props);
33
+
34
+ _defineProperty(_assertThisInitialized(_this), "fireOperationalEvent", function (error, info) {
35
+ var _window, _window$navigator;
36
+
37
+ var _this$props = _this.props,
38
+ _this$props$data = _this$props.data,
39
+ data = _this$props$data === void 0 ? {} : _this$props$data,
40
+ createAnalyticsEvent = _this$props.createAnalyticsEvent;
41
+ var payload = {
42
+ eventType: 'operational',
43
+ action: 'failed',
44
+ actionSubject: 'mediaInlineRender',
45
+ attributes: _objectSpread({
46
+ browserInfo: (_window = window) !== null && _window !== void 0 && (_window$navigator = _window.navigator) !== null && _window$navigator !== void 0 && _window$navigator.userAgent ? window.navigator.userAgent : 'unknown',
47
+ error: error,
48
+ failReason: 'unexpected-error',
49
+ info: info
50
+ }, data)
51
+ };
52
+ fireMediaCardEvent(payload, createAnalyticsEvent);
53
+ });
54
+
55
+ _this.state = {
56
+ hasError: false
57
+ };
58
+ return _this;
59
+ }
60
+
61
+ _createClass(WrappedMediaInlineAnalyticsErrorBoundary, [{
62
+ key: "componentDidCatch",
63
+ value: function componentDidCatch(error, info) {
64
+ try {
65
+ this.fireOperationalEvent(error, info);
66
+ this.setState({
67
+ hasError: true
68
+ });
69
+ } catch (e) {}
70
+ }
71
+ }, {
72
+ key: "render",
73
+ value: function render() {
74
+ var hasError = this.state.hasError;
75
+ var children = this.props.children;
76
+
77
+ if (hasError) {
78
+ // TODO refactor error boundary for inline card https://product-fabric.atlassian.net/browse/MEX-2140
79
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
80
+ }
81
+
82
+ return children;
83
+ }
84
+ }]);
85
+
86
+ return WrappedMediaInlineAnalyticsErrorBoundary;
87
+ }(React.Component);
88
+
89
+ _defineProperty(WrappedMediaInlineAnalyticsErrorBoundary, "displayName", 'MediaInlineAnalyticsErrorBoundary');
90
+
91
+ var packageName = "@atlaskit/media-card";
92
+ var packageVersion = "74.4.0";
93
+ var MediaInlineAnalyticsErrorBoundary = withMediaAnalyticsContext({
94
+ packageVersion: packageVersion,
95
+ packageName: packageName,
96
+ componentName: 'mediaInlineCard',
97
+ component: 'mediaInlineCard'
98
+ })(withAnalyticsEvents()(WrappedMediaInlineAnalyticsErrorBoundary));
99
+ export default MediaInlineAnalyticsErrorBoundary;
@@ -15,7 +15,6 @@ var relevantFlags = {
15
15
  observedWidth: true,
16
16
  mediaInline: false,
17
17
  folderUploads: false,
18
- mediaUploadApiV2: true,
19
18
  memoryCacheLogging: true
20
19
  };
21
20
  export var LOGGED_FEATURE_FLAGS = filterFeatureFlagNames(relevantFlags);
@@ -55,7 +54,7 @@ export var getRenderCommencedEventPayload = function getRenderCommencedEventPayl
55
54
  }
56
55
  };
57
56
  };
58
- export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext) {
57
+ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext) {
59
58
  return {
60
59
  eventType: 'operational',
61
60
  action: 'succeeded',
@@ -65,7 +64,8 @@ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayl
65
64
  performanceAttributes: performanceAttributes,
66
65
  status: 'success',
67
66
  ssrReliability: ssrReliability,
68
- traceContext: traceContext
67
+ traceContext: traceContext,
68
+ metadataTraceContext: metadataTraceContext
69
69
  }
70
70
  };
71
71
  };
@@ -127,19 +127,27 @@ export var getRenderErrorErrorDetail = function getRenderErrorErrorDetail(error)
127
127
  return error.message;
128
128
  }
129
129
  };
130
+ export var getErrorTraceContext = function getErrorTraceContext(error) {
131
+ if (isMediaCardError(error) && !!error.secondaryError && isRequestError(error.secondaryError)) {
132
+ var _error$secondaryError;
133
+
134
+ return (_error$secondaryError = error.secondaryError.metadata) === null || _error$secondaryError === void 0 ? void 0 : _error$secondaryError.traceContext;
135
+ }
136
+ };
130
137
  export var getRenderErrorRequestMetadata = function getRenderErrorRequestMetadata(error) {
131
138
  if (isMediaCardError(error) && !!error.secondaryError && isRequestError(error.secondaryError)) {
132
139
  return error.secondaryError.metadata;
133
140
  }
134
141
  };
135
- export var extractErrorInfo = function extractErrorInfo(error) {
142
+ export var extractErrorInfo = function extractErrorInfo(error, metadataTraceContext) {
136
143
  return {
137
144
  failReason: getRenderErrorFailReason(error),
138
145
  error: getRenderErrorErrorReason(error),
139
- errorDetail: getRenderErrorErrorDetail(error)
146
+ errorDetail: getRenderErrorErrorDetail(error),
147
+ metadataTraceContext: metadataTraceContext !== null && metadataTraceContext !== void 0 ? metadataTraceContext : getErrorTraceContext(error)
140
148
  };
141
149
  };
142
- export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability, traceContext) {
150
+ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability, traceContext, metadataTraceContext) {
143
151
  return {
144
152
  eventType: 'operational',
145
153
  action: 'failed',
@@ -148,14 +156,30 @@ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(file
148
156
  fileAttributes: fileAttributes,
149
157
  performanceAttributes: performanceAttributes,
150
158
  status: 'fail'
151
- }, extractErrorInfo(error)), {}, {
159
+ }, extractErrorInfo(error, metadataTraceContext)), {}, {
152
160
  request: getRenderErrorRequestMetadata(error),
153
161
  ssrReliability: ssrReliability,
154
162
  traceContext: traceContext
155
163
  })
156
164
  };
157
165
  };
158
- export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext) {
166
+ export var getErrorEventPayload = function getErrorEventPayload(cardStatus, fileAttributes, error, ssrReliability, traceContext, metadataTraceContext) {
167
+ return {
168
+ eventType: 'operational',
169
+ action: 'nonCriticalFail',
170
+ actionSubject: 'mediaCardRender',
171
+ attributes: _objectSpread(_objectSpread({
172
+ fileAttributes: fileAttributes,
173
+ status: 'fail'
174
+ }, extractErrorInfo(error, metadataTraceContext)), {}, {
175
+ request: getRenderErrorRequestMetadata(error),
176
+ ssrReliability: ssrReliability,
177
+ traceContext: traceContext,
178
+ cardStatus: cardStatus
179
+ })
180
+ };
181
+ };
182
+ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext) {
159
183
  return {
160
184
  eventType: 'operational',
161
185
  action: 'failed',
@@ -166,7 +190,8 @@ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatus
166
190
  status: 'fail',
167
191
  failReason: 'failed-processing',
168
192
  ssrReliability: ssrReliability,
169
- traceContext: traceContext
193
+ traceContext: traceContext,
194
+ metadataTraceContext: metadataTraceContext
170
195
  }
171
196
  };
172
197
  };
@@ -9,7 +9,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata, LOGGED_FEATURE_FLAG_KE
9
9
  import { MediaCardError } from '../errors';
10
10
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
11
11
  var packageName = "@atlaskit/media-card";
12
- var packageVersion = "74.3.2";
12
+ var packageVersion = "74.4.0";
13
13
  var concurrentExperience;
14
14
 
15
15
  var getExperience = function getExperience(id) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "74.3.2",
3
+ "version": "74.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -39,7 +39,7 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
39
39
  private fireCommencedEvent;
40
40
  private fireCopiedEvent;
41
41
  private fireScreenEvent;
42
- private fireLocalPreviewErrorEvent;
42
+ private fireNonCriticalErrorEvent;
43
43
  private safeSetState;
44
44
  unsubscribe: () => void;
45
45
  get actions(): CardAction[];
@@ -3,7 +3,8 @@ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  import { SSRStatus } from '../utils/analytics';
4
4
  import { CardStatus } from '../types';
5
5
  import { MediaCardError } from '../errors';
6
- export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error: MediaCardError | undefined, traceContext: MediaTraceContext) => void;
6
+ export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error: MediaCardError | undefined, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => void;
7
7
  export declare const fireCommencedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, traceContext: MediaTraceContext) => void;
8
8
  export declare const fireCopiedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileId: string, cardRef: HTMLDivElement) => void;
9
9
  export declare const fireScreenEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes) => void;
10
+ export declare const fireNonCriticalErrorEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, cardStatus: CardStatus, fileAttributes: FileAttributes, ssrReliability: SSRStatus, error: MediaCardError | undefined, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => void;
@@ -1,5 +1,10 @@
1
1
  import { FileState } from '@atlaskit/media-client';
2
2
  import { MediaFeatureFlags } from '@atlaskit/media-common';
3
3
  import { CardState } from '../types';
4
- export declare const createStateUpdater: (newState: Partial<CardState>) => (prevState: CardState) => Pick<CardState, keyof CardState>;
4
+ import { MediaCardError } from '../errors';
5
+ /**
6
+ * From docs: "Both state and props received by the updater function are guaranteed to be up-to-date.
7
+ * The output of the updater is shallowly merged with state."
8
+ */
9
+ export declare const createStateUpdater: (newState: Partial<CardState>, fireErrorEvent: (error: MediaCardError) => void) => (prevState: CardState) => Partial<CardState>;
5
10
  export declare const getCardStateFromFileState: (fileState: FileState, isBannedLocalPreview: boolean, featureFlags?: MediaFeatureFlags | undefined) => Partial<CardState>;
@@ -19,7 +19,7 @@ export declare type CardPreviewParams = {
19
19
  id: string;
20
20
  dimensions?: CardDimensions;
21
21
  filePreview?: FilePreview | Promise<FilePreview>;
22
- onLocalPreviewError?: (error: MediaCardError) => void;
22
+ onLocalPreviewError: (error: MediaCardError) => void;
23
23
  isRemotePreviewReady: boolean;
24
24
  imageUrlParams: MediaStoreGetFileImageParams;
25
25
  mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
3
+ import { CardDimensions, CardOnClickCallback } from '../types';
4
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
5
+ export declare type MediaCardAnalyticsErrorBoundaryProps = {
6
+ dimensions?: CardDimensions;
7
+ data?: {
8
+ [k: string]: any;
9
+ };
10
+ onClick?: CardOnClickCallback;
11
+ featureFlags?: MediaFeatureFlags;
12
+ } & WithAnalyticsEventsProps;
13
+ declare const MediaCardAnalyticsErrorBoundary: React.ComponentType<MediaCardAnalyticsErrorBoundaryProps & WithAnalyticsEventsProps>;
14
+ export default MediaCardAnalyticsErrorBoundary;
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { Component } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import { UnhandledErrorCardProps } from './types';
5
+ export declare class UnhandledErrorCard extends Component<UnhandledErrorCardProps, {}> {
6
+ render(): jsx.JSX.Element;
7
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { CardDimensions } from '../../../types';
3
+ export interface UnhandledErrorCardProps {
4
+ dimensions?: CardDimensions;
5
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
6
+ }
@@ -5,7 +5,7 @@ import { CardPreview } from './types';
5
5
  */
6
6
  export declare type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
7
7
  export declare type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
8
- export declare type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready';
8
+ export declare type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
9
9
  export declare type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
10
10
  export declare type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
11
11
  export declare class MediaCardError extends Error {
@@ -37,5 +37,5 @@ export declare const isLocalPreviewError: (err: Error) => err is LocalPreviewErr
37
37
  export declare const isRemotePreviewError: (err: Error) => err is LocalPreviewError;
38
38
  export declare const isUnsupportedLocalPreviewError: (err: Error) => boolean;
39
39
  export declare function isImageLoadError(err: Error): err is ImageLoadError;
40
- export declare const ensureMediaCardError: (primaryReason: MediaCardErrorPrimaryReason, error: Error) => MediaCardError;
40
+ export declare const ensureMediaCardError: (primaryReason: MediaCardErrorPrimaryReason, error: Error, updatePrimaryReason?: boolean | undefined) => MediaCardError;
41
41
  export declare const isUploadError: (error?: MediaCardError | undefined) => boolean | undefined;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
3
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
4
+ export declare type MediaInlineAnalyticsErrorBoundaryProps = {
5
+ data?: {
6
+ [k: string]: any;
7
+ };
8
+ featureFlags?: MediaFeatureFlags;
9
+ } & WithAnalyticsEventsProps;
10
+ declare const MediaInlineAnalyticsErrorBoundary: React.ComponentType<MediaInlineAnalyticsErrorBoundaryProps & WithAnalyticsEventsProps>;
11
+ export default MediaInlineAnalyticsErrorBoundary;
@@ -75,6 +75,9 @@ export interface CardProps extends SharedCardProps, CardEventProps {
75
75
  readonly isLazy?: boolean;
76
76
  readonly useInlinePlayer?: boolean;
77
77
  readonly shouldOpenMediaViewer?: boolean;
78
+ /** Imported from MediaViewer. It includes data source like collection name,
79
+ * media file list.
80
+ */
78
81
  readonly mediaViewerDataSource?: MediaViewerDataSource;
79
82
  readonly contextId?: string;
80
83
  readonly shouldEnableDownloadButton?: boolean;
@@ -2,7 +2,7 @@ import { FileDetails, MediaClientErrorReason, RequestMetadata } from '@atlaskit/
2
2
  import { FileAttributes, PerformanceAttributes, OperationalEventPayload, UIEventPayload, WithFileAttributes, WithPerformanceAttributes, SuccessAttributes, FailureAttributes, ScreenEventPayload, ScreenAttributes, MediaTraceContext, WithTraceContext } from '@atlaskit/media-common';
3
3
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
4
  import { MediaCardError, MediaCardErrorPrimaryReason } from '../errors';
5
- import { CardPreviewSource, CardDimensions } from '../types';
5
+ import { CardPreviewSource, CardDimensions, CardStatus } from '../types';
6
6
  export declare type CardPreviewAttributes = {
7
7
  fileId: string;
8
8
  prevDimensions: CardDimensions | undefined;
@@ -21,6 +21,7 @@ export declare type MediaCardErrorInfo = {
21
21
  failReason: FailedErrorFailReason;
22
22
  error: MediaClientErrorReason | 'nativeError';
23
23
  errorDetail: string;
24
+ metadataTraceContext?: MediaTraceContext;
24
25
  };
25
26
  export declare type SSRStatusFail = MediaCardErrorInfo & {
26
27
  status: 'fail';
@@ -42,6 +43,23 @@ export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileA
42
43
  error?: MediaClientErrorReason | 'nativeError';
43
44
  request?: RequestMetadata;
44
45
  }, 'failed', 'mediaCardRender'>;
46
+ export declare type ErrorEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & WithTraceContext & FailureAttributes & {
47
+ cardStatus: CardStatus;
48
+ failReason: FailedErrorFailReason | 'failed-processing';
49
+ error?: MediaClientErrorReason | 'nativeError';
50
+ request?: RequestMetadata;
51
+ }, 'nonCriticalFail', 'mediaCardRender'>;
52
+ export declare type ErrorBoundaryErrorInfo = {
53
+ componentStack: string;
54
+ };
55
+ export declare type AnalyticsErrorBoundaryAttributes = {
56
+ error?: Error | string;
57
+ info?: ErrorBoundaryErrorInfo;
58
+ browserInfo: string;
59
+ failReason: string;
60
+ };
61
+ export declare type AnalyticsErrorBoundaryCardPayload = OperationalEventPayload<AnalyticsErrorBoundaryAttributes, 'failed', 'mediaCardRender'>;
62
+ export declare type AnalyticsErrorBoundaryInlinePayload = OperationalEventPayload<AnalyticsErrorBoundaryAttributes, 'failed', 'mediaInlineRender'>;
45
63
  export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & SuccessAttributes & WithTraceContext, 'succeeded', 'mediaCardRender'>;
46
64
  export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithTraceContext, 'commenced', 'mediaCardRender'>;
47
65
  export declare type CacheHitEventPayload = OperationalEventPayload<WithCardPreviewCacheAttributes, 'cache-hit', 'mediaCardCache'>;
@@ -56,21 +74,23 @@ export declare type RenderScreenEventPayload = Omit<ScreenEventPayload<ScreenAtt
56
74
  fileAttributes: FileAttributes;
57
75
  };
58
76
  };
59
- export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload | RenderScreenEventPayload | CacheHitEventPayload | RemoteSuccessEventPayload;
77
+ export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload | RenderScreenEventPayload | CacheHitEventPayload | RemoteSuccessEventPayload | ErrorEventPayload | AnalyticsErrorBoundaryCardPayload | AnalyticsErrorBoundaryInlinePayload;
60
78
  export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: import("@atlaskit/media-common").FileStatus | undefined) => FileAttributes;
61
79
  export declare const getRenderPreviewableCardPayload: (fileAttributes: FileAttributes) => RenderScreenEventPayload;
62
80
  export declare const getRenderCommencedEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, traceContext: MediaTraceContext) => RenderCommencedEventPayload;
63
- export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, traceContext: MediaTraceContext) => RenderSucceededEventPayload;
81
+ export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => RenderSucceededEventPayload;
64
82
  export declare const getCacheHitEventPayload: (cardPreviewAttributes: CardPreviewAttributes) => CacheHitEventPayload;
65
83
  export declare const getRemoteSuccessEventPayload: (cardPreviewAttributes: CardPreviewAttributes) => RemoteSuccessEventPayload;
66
84
  export declare const getRenderFailedExternalUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
67
85
  export declare const getRenderErrorFailReason: (error: MediaCardError) => FailedErrorFailReason;
68
86
  export declare const getRenderErrorErrorReason: (error: MediaCardError) => MediaClientErrorReason | 'nativeError';
69
87
  export declare const getRenderErrorErrorDetail: (error: MediaCardError) => string;
88
+ export declare const getErrorTraceContext: (error: MediaCardError) => MediaTraceContext | undefined;
70
89
  export declare const getRenderErrorRequestMetadata: (error: MediaCardError) => RequestMetadata | undefined;
71
- export declare const extractErrorInfo: (error: MediaCardError) => MediaCardErrorInfo;
72
- export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError, ssrReliability: SSRStatus, traceContext: MediaTraceContext) => RenderFailedEventPayload;
73
- export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, traceContext: MediaTraceContext) => RenderFailedEventPayload;
90
+ export declare const extractErrorInfo: (error: MediaCardError, metadataTraceContext?: MediaTraceContext | undefined) => MediaCardErrorInfo;
91
+ export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError, ssrReliability: SSRStatus, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => RenderFailedEventPayload;
92
+ export declare const getErrorEventPayload: (cardStatus: CardStatus, fileAttributes: FileAttributes, error: MediaCardError, ssrReliability: SSRStatus, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => ErrorEventPayload;
93
+ export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, traceContext: MediaTraceContext, metadataTraceContext?: MediaTraceContext | undefined) => RenderFailedEventPayload;
74
94
  export declare const getCopiedFilePayload: (fileId: string) => CopiedFileEventPayload;
75
95
  export declare function fireMediaCardEvent(payload: MediaCardAnalyticsEventPayload, createAnalyticsEvent?: CreateUIAnalyticsEvent): void;
76
96
  export declare const createAndFireMediaCardEvent: (payload: MediaCardAnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
@@ -84,6 +84,19 @@ export const externalIdentifierWrapperStyles = css`
84
84
  }
85
85
  `;
86
86
 
87
+ export const unhandledErrorCardWrapperStyles = css`
88
+ padding: 20px;
89
+
90
+ > div:first-child {
91
+ display: flex;
92
+ margin-bottom: 20px;
93
+ }
94
+
95
+ label {
96
+ margin-right: 20px;
97
+ }
98
+ `;
99
+
87
100
  export const inlineCardVideoWrapperItemStyles = css`
88
101
  padding: 10px;
89
102
  border: 1px solid ${token('color.border.bold', 'black')};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "74.3.2",
3
+ "version": "74.4.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,12 +30,12 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/analytics-next": "^8.2.0",
32
32
  "@atlaskit/dropdown-menu": "^11.5.0",
33
- "@atlaskit/editor-shared-styles": "^2.2.0",
33
+ "@atlaskit/editor-shared-styles": "^2.3.0",
34
34
  "@atlaskit/icon": "^21.11.0",
35
- "@atlaskit/media-client": "^19.0.0",
36
- "@atlaskit/media-common": "^2.17.0",
35
+ "@atlaskit/media-client": "^19.1.0",
36
+ "@atlaskit/media-common": "^2.18.0",
37
37
  "@atlaskit/media-ui": "^22.2.0",
38
- "@atlaskit/media-viewer": "^47.2.0",
38
+ "@atlaskit/media-viewer": "^47.3.0",
39
39
  "@atlaskit/spinner": "^15.3.0",
40
40
  "@atlaskit/theme": "^12.2.0",
41
41
  "@atlaskit/tokens": "^0.13.0",
@@ -61,11 +61,12 @@
61
61
  "@atlaskit/docs": "*",
62
62
  "@atlaskit/inline-message": "^11.4.0",
63
63
  "@atlaskit/media-core": "^34.0.0",
64
- "@atlaskit/media-picker": "^64.0.0",
65
- "@atlaskit/media-test-helpers": "^30.0.0",
64
+ "@atlaskit/media-picker": "^64.1.0",
65
+ "@atlaskit/media-test-helpers": "^30.1.0",
66
66
  "@atlaskit/radio": "^5.4.0",
67
67
  "@atlaskit/range": "^7.0.0",
68
- "@atlaskit/select": "^16.0.0",
68
+ "@atlaskit/section-message": "^6.3.0",
69
+ "@atlaskit/select": "^16.1.0",
69
70
  "@atlaskit/ssr": "*",
70
71
  "@atlaskit/toggle": "^12.5.0",
71
72
  "@atlaskit/visual-regression": "*",
package/report.api.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- API Report Version: 2.2 -->
1
+ <!-- API Report Version: 2.3 -->
2
2
 
3
3
  ## API Report File for "@atlaskit/media-card"
4
4
 
@@ -147,7 +147,6 @@ export interface CardProps extends SharedCardProps, CardEventProps {
147
147
  readonly isLazy?: boolean;
148
148
  // (undocumented)
149
149
  readonly mediaClient: MediaClient;
150
- // (undocumented)
151
150
  readonly mediaViewerDataSource?: MediaViewerDataSource;
152
151
  // (undocumented)
153
152
  readonly shouldEnableDownloadButton?: boolean;
@@ -333,6 +332,7 @@ export { NumericalCardDimensions };
333
332
  // @public (undocumented)
334
333
  type RemotePreviewPrimaryReason =
335
334
  | 'remote-preview-fetch'
335
+ | 'remote-preview-fetch-ssr'
336
336
  | 'remote-preview-not-ready';
337
337
 
338
338
  // @public (undocumented)
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
-
16
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
-
18
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
-
20
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
-
22
- var _react = _interopRequireDefault(require("react"));
23
-
24
- var _mediaCommon = require("@atlaskit/media-common");
25
-
26
- var _AnalyticsErrorBoundary = _interopRequireDefault(require("@atlaskit/analytics-next/AnalyticsErrorBoundary"));
27
-
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
29
-
30
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
-
32
- var MediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Component) {
33
- (0, _inherits2.default)(MediaCardAnalyticsErrorBoundary, _React$Component);
34
-
35
- var _super = _createSuper(MediaCardAnalyticsErrorBoundary);
36
-
37
- function MediaCardAnalyticsErrorBoundary() {
38
- (0, _classCallCheck2.default)(this, MediaCardAnalyticsErrorBoundary);
39
- return _super.apply(this, arguments);
40
- }
41
-
42
- (0, _createClass2.default)(MediaCardAnalyticsErrorBoundary, [{
43
- key: "render",
44
- value: function render() {
45
- var _this$props = this.props,
46
- _this$props$data = _this$props.data,
47
- data = _this$props$data === void 0 ? {} : _this$props$data,
48
- children = _this$props.children;
49
- return /*#__PURE__*/_react.default.createElement(_AnalyticsErrorBoundary.default, {
50
- channel: _mediaCommon.ANALYTICS_MEDIA_CHANNEL,
51
- data: data
52
- }, children);
53
- }
54
- }]);
55
- return MediaCardAnalyticsErrorBoundary;
56
- }(_react.default.Component);
57
-
58
- exports.default = MediaCardAnalyticsErrorBoundary;
59
- (0, _defineProperty2.default)(MediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
@@ -1,19 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
4
- import AnalyticsErrorBoundary from '@atlaskit/analytics-next/AnalyticsErrorBoundary';
5
- export default class MediaCardAnalyticsErrorBoundary extends React.Component {
6
- render() {
7
- const {
8
- data = {},
9
- children
10
- } = this.props;
11
- return /*#__PURE__*/React.createElement(AnalyticsErrorBoundary, {
12
- channel: ANALYTICS_MEDIA_CHANNEL,
13
- data: data
14
- }, children);
15
- }
16
-
17
- }
18
-
19
- _defineProperty(MediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');