@atlaskit/media-card 74.3.1 → 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.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/card/card.js +27 -18
- package/dist/cjs/card/cardAnalytics.js +16 -5
- package/dist/cjs/card/cardLoader.js +12 -3
- package/dist/cjs/card/cardState.js +11 -13
- package/dist/cjs/card/media-card-analytics-error-boundary.js +129 -0
- package/dist/cjs/card/ui/unhandledErrorCard/index.js +114 -0
- package/dist/cjs/card/ui/unhandledErrorCard/types.js +5 -0
- package/dist/cjs/errors.js +12 -3
- package/dist/cjs/inline/loader.js +4 -4
- package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +113 -0
- package/dist/cjs/utils/analytics.js +41 -10
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/card/card.js +29 -17
- package/dist/es2019/card/cardAnalytics.js +9 -5
- package/dist/es2019/card/cardLoader.js +12 -3
- package/dist/es2019/card/cardState.js +12 -7
- package/dist/es2019/card/media-card-analytics-error-boundary.js +90 -0
- package/dist/es2019/card/ui/unhandledErrorCard/index.js +80 -0
- package/dist/es2019/card/ui/unhandledErrorCard/types.js +1 -0
- package/dist/es2019/errors.js +13 -2
- package/dist/es2019/inline/loader.js +4 -4
- package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +75 -0
- package/dist/es2019/utils/analytics.js +32 -9
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/card/card.js +28 -19
- package/dist/esm/card/cardAnalytics.js +12 -4
- package/dist/esm/card/cardLoader.js +12 -3
- package/dist/esm/card/cardState.js +12 -11
- package/dist/esm/card/media-card-analytics-error-boundary.js +115 -0
- package/dist/esm/card/ui/unhandledErrorCard/index.js +94 -0
- package/dist/esm/card/ui/unhandledErrorCard/types.js +1 -0
- package/dist/esm/errors.js +12 -3
- package/dist/esm/inline/loader.js +5 -5
- package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +99 -0
- package/dist/esm/utils/analytics.js +34 -9
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/card/card.d.ts +1 -1
- package/dist/types/card/cardAnalytics.d.ts +2 -1
- package/dist/types/card/cardState.d.ts +6 -1
- package/dist/types/card/getCardPreview/index.d.ts +1 -1
- package/dist/types/card/media-card-analytics-error-boundary.d.ts +14 -0
- package/dist/types/card/ui/unhandledErrorCard/index.d.ts +7 -0
- package/dist/types/card/ui/unhandledErrorCard/types.d.ts +6 -0
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/inline/mediaInlineAnalyticsErrorBoundary.d.ts +11 -0
- package/dist/types/types.d.ts +3 -0
- package/dist/types/utils/analytics.d.ts +26 -6
- package/example-helpers/styles.ts +13 -0
- package/package.json +10 -9
- package/report.api.md +2 -2
- package/dist/cjs/utils/media-card-analytics-error-boundary.js +0 -59
- package/dist/es2019/utils/media-card-analytics-error-boundary.js +0 -19
- package/dist/esm/utils/media-card-analytics-error-boundary.js +0 -46
- package/dist/types/utils/media-card-analytics-error-boundary.d.ts +0 -10
|
@@ -18,15 +18,15 @@ export default class MediaInlineCardLoader extends React.PureComponent {
|
|
|
18
18
|
|
|
19
19
|
if (!this.state.MediaInlineCard) {
|
|
20
20
|
try {
|
|
21
|
-
const [mediaClient, cardModule,
|
|
21
|
+
const [mediaClient, cardModule, mediaInlineErrorBoundaryModule] = await Promise.all([import(
|
|
22
22
|
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
23
23
|
'@atlaskit/media-client'), import(
|
|
24
24
|
/* webpackChunkName: "@atlaskit-internal_inline-media-card" */
|
|
25
25
|
'./mediaInlineCard'), import(
|
|
26
|
-
/* webpackChunkName: "@atlaskit-internal_media-
|
|
27
|
-
'
|
|
26
|
+
/* webpackChunkName: "@atlaskit-internal_media-inline-error-boundary" */
|
|
27
|
+
'./mediaInlineAnalyticsErrorBoundary')]);
|
|
28
28
|
MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
|
|
29
|
-
MediaInlineCardLoader.ErrorBoundary =
|
|
29
|
+
MediaInlineCardLoader.ErrorBoundary = mediaInlineErrorBoundaryModule.default;
|
|
30
30
|
|
|
31
31
|
if (this.isMounted) {
|
|
32
32
|
this.setState({
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
4
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import { fireMediaCardEvent } from '../utils/analytics';
|
|
6
|
+
|
|
7
|
+
class WrappedMediaInlineAnalyticsErrorBoundary extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "fireOperationalEvent", (error, info) => {
|
|
12
|
+
var _window, _window$navigator;
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
data = {},
|
|
16
|
+
createAnalyticsEvent
|
|
17
|
+
} = this.props;
|
|
18
|
+
const payload = {
|
|
19
|
+
eventType: 'operational',
|
|
20
|
+
action: 'failed',
|
|
21
|
+
actionSubject: 'mediaInlineRender',
|
|
22
|
+
attributes: {
|
|
23
|
+
browserInfo: (_window = window) !== null && _window !== void 0 && (_window$navigator = _window.navigator) !== null && _window$navigator !== void 0 && _window$navigator.userAgent ? window.navigator.userAgent : 'unknown',
|
|
24
|
+
error,
|
|
25
|
+
failReason: 'unexpected-error',
|
|
26
|
+
info,
|
|
27
|
+
...data
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
fireMediaCardEvent(payload, createAnalyticsEvent);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.state = {
|
|
34
|
+
hasError: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
componentDidCatch(error, info) {
|
|
39
|
+
try {
|
|
40
|
+
this.fireOperationalEvent(error, info);
|
|
41
|
+
this.setState({
|
|
42
|
+
hasError: true
|
|
43
|
+
});
|
|
44
|
+
} catch (e) {}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
hasError
|
|
50
|
+
} = this.state;
|
|
51
|
+
const {
|
|
52
|
+
children
|
|
53
|
+
} = this.props;
|
|
54
|
+
|
|
55
|
+
if (hasError) {
|
|
56
|
+
// TODO refactor error boundary for inline card https://product-fabric.atlassian.net/browse/MEX-2140
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return children;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_defineProperty(WrappedMediaInlineAnalyticsErrorBoundary, "displayName", 'MediaInlineAnalyticsErrorBoundary');
|
|
66
|
+
|
|
67
|
+
const packageName = "@atlaskit/media-card";
|
|
68
|
+
const packageVersion = "74.4.0";
|
|
69
|
+
const MediaInlineAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
70
|
+
packageVersion,
|
|
71
|
+
packageName,
|
|
72
|
+
componentName: 'mediaInlineCard',
|
|
73
|
+
component: 'mediaInlineCard'
|
|
74
|
+
})(withAnalyticsEvents()(WrappedMediaInlineAnalyticsErrorBoundary));
|
|
75
|
+
export default MediaInlineAnalyticsErrorBoundary;
|
|
@@ -9,7 +9,6 @@ const relevantFlags = {
|
|
|
9
9
|
observedWidth: true,
|
|
10
10
|
mediaInline: false,
|
|
11
11
|
folderUploads: false,
|
|
12
|
-
mediaUploadApiV2: true,
|
|
13
12
|
memoryCacheLogging: true
|
|
14
13
|
};
|
|
15
14
|
export const LOGGED_FEATURE_FLAGS = filterFeatureFlagNames(relevantFlags);
|
|
@@ -45,7 +44,7 @@ export const getRenderCommencedEventPayload = (fileAttributes, performanceAttrib
|
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
|
-
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes, ssrReliability, traceContext) => ({
|
|
47
|
+
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext) => ({
|
|
49
48
|
eventType: 'operational',
|
|
50
49
|
action: 'succeeded',
|
|
51
50
|
actionSubject: 'mediaCardRender',
|
|
@@ -54,7 +53,8 @@ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttrib
|
|
|
54
53
|
performanceAttributes,
|
|
55
54
|
status: 'success',
|
|
56
55
|
ssrReliability,
|
|
57
|
-
traceContext
|
|
56
|
+
traceContext,
|
|
57
|
+
metadataTraceContext
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
export const getCacheHitEventPayload = cardPreviewAttributes => ({
|
|
@@ -109,19 +109,27 @@ export const getRenderErrorErrorDetail = error => {
|
|
|
109
109
|
return error.message;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
+
export const getErrorTraceContext = error => {
|
|
113
|
+
if (isMediaCardError(error) && !!error.secondaryError && isRequestError(error.secondaryError)) {
|
|
114
|
+
var _error$secondaryError;
|
|
115
|
+
|
|
116
|
+
return (_error$secondaryError = error.secondaryError.metadata) === null || _error$secondaryError === void 0 ? void 0 : _error$secondaryError.traceContext;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
112
119
|
export const getRenderErrorRequestMetadata = error => {
|
|
113
120
|
if (isMediaCardError(error) && !!error.secondaryError && isRequestError(error.secondaryError)) {
|
|
114
121
|
return error.secondaryError.metadata;
|
|
115
122
|
}
|
|
116
123
|
};
|
|
117
|
-
export const extractErrorInfo = error => {
|
|
124
|
+
export const extractErrorInfo = (error, metadataTraceContext) => {
|
|
118
125
|
return {
|
|
119
126
|
failReason: getRenderErrorFailReason(error),
|
|
120
127
|
error: getRenderErrorErrorReason(error),
|
|
121
|
-
errorDetail: getRenderErrorErrorDetail(error)
|
|
128
|
+
errorDetail: getRenderErrorErrorDetail(error),
|
|
129
|
+
metadataTraceContext: metadataTraceContext !== null && metadataTraceContext !== void 0 ? metadataTraceContext : getErrorTraceContext(error)
|
|
122
130
|
};
|
|
123
131
|
};
|
|
124
|
-
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error, ssrReliability, traceContext) => ({
|
|
132
|
+
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error, ssrReliability, traceContext, metadataTraceContext) => ({
|
|
125
133
|
eventType: 'operational',
|
|
126
134
|
action: 'failed',
|
|
127
135
|
actionSubject: 'mediaCardRender',
|
|
@@ -129,13 +137,27 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
129
137
|
fileAttributes,
|
|
130
138
|
performanceAttributes,
|
|
131
139
|
status: 'fail',
|
|
132
|
-
...extractErrorInfo(error),
|
|
140
|
+
...extractErrorInfo(error, metadataTraceContext),
|
|
133
141
|
request: getRenderErrorRequestMetadata(error),
|
|
134
142
|
ssrReliability,
|
|
135
143
|
traceContext
|
|
136
144
|
}
|
|
137
145
|
});
|
|
138
|
-
export const
|
|
146
|
+
export const getErrorEventPayload = (cardStatus, fileAttributes, error, ssrReliability, traceContext, metadataTraceContext) => ({
|
|
147
|
+
eventType: 'operational',
|
|
148
|
+
action: 'nonCriticalFail',
|
|
149
|
+
actionSubject: 'mediaCardRender',
|
|
150
|
+
attributes: {
|
|
151
|
+
fileAttributes,
|
|
152
|
+
status: 'fail',
|
|
153
|
+
...extractErrorInfo(error, metadataTraceContext),
|
|
154
|
+
request: getRenderErrorRequestMetadata(error),
|
|
155
|
+
ssrReliability,
|
|
156
|
+
traceContext,
|
|
157
|
+
cardStatus
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext) => ({
|
|
139
161
|
eventType: 'operational',
|
|
140
162
|
action: 'failed',
|
|
141
163
|
actionSubject: 'mediaCardRender',
|
|
@@ -145,7 +167,8 @@ export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttr
|
|
|
145
167
|
status: 'fail',
|
|
146
168
|
failReason: 'failed-processing',
|
|
147
169
|
ssrReliability,
|
|
148
|
-
traceContext
|
|
170
|
+
traceContext,
|
|
171
|
+
metadataTraceContext
|
|
149
172
|
}
|
|
150
173
|
});
|
|
151
174
|
export const getCopiedFilePayload = fileId => ({
|
|
@@ -3,7 +3,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata, LOGGED_FEATURE_FLAG_KE
|
|
|
3
3
|
import { MediaCardError } from '../errors';
|
|
4
4
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
5
5
|
const packageName = "@atlaskit/media-card";
|
|
6
|
-
const packageVersion = "74.
|
|
6
|
+
const packageVersion = "74.4.0";
|
|
7
7
|
let concurrentExperience;
|
|
8
8
|
|
|
9
9
|
const getExperience = id => {
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/card/card.js
CHANGED
|
@@ -34,7 +34,7 @@ import { getFileDetails } from '../utils/metadata';
|
|
|
34
34
|
import { InlinePlayerLazy } from './inlinePlayerLazy';
|
|
35
35
|
import { getFileAttributes, extractErrorInfo, LOGGED_FEATURE_FLAGS } from '../utils/analytics';
|
|
36
36
|
import { isLocalPreviewError, MediaCardError, ensureMediaCardError, ImageLoadError } from '../errors';
|
|
37
|
-
import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, fireCopiedEvent, fireScreenEvent } from './cardAnalytics';
|
|
37
|
+
import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, fireCopiedEvent, fireScreenEvent, fireNonCriticalErrorEvent } from './cardAnalytics';
|
|
38
38
|
import getDocument from '../utils/document';
|
|
39
39
|
import { StoreSSRDataScript, getSSRData } from '../utils/globalScope';
|
|
40
40
|
import { getCardStateFromFileState, createStateUpdater } from './cardState';
|
|
@@ -44,7 +44,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
|
|
|
44
44
|
import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
|
|
45
45
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
46
46
|
var packageName = "@atlaskit/media-card";
|
|
47
|
-
var packageVersion = "74.
|
|
47
|
+
var packageVersion = "74.4.0";
|
|
48
48
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
49
49
|
_inherits(CardBase, _Component);
|
|
50
50
|
|
|
@@ -83,7 +83,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
83
83
|
_defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
|
|
84
84
|
|
|
85
85
|
_defineProperty(_assertThisInitialized(_this), "traceContext", {
|
|
86
|
-
traceId: getRandomHex(
|
|
86
|
+
traceId: getRandomHex(8)
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
_defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
|
|
@@ -133,7 +133,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
133
133
|
mediaClient: mediaClient,
|
|
134
134
|
id: id,
|
|
135
135
|
dimensions: dimensions,
|
|
136
|
-
onLocalPreviewError: _this.
|
|
136
|
+
onLocalPreviewError: _this.fireNonCriticalErrorEvent,
|
|
137
137
|
filePreview: isBannedLocalPreview ? undefined : getFilePreviewFromFileState(fileState),
|
|
138
138
|
isRemotePreviewReady: isImageRepresentationReady(fileState),
|
|
139
139
|
imageUrlParams: _this.getImageURLParams(identifier),
|
|
@@ -158,7 +158,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
158
158
|
|
|
159
159
|
_defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
|
|
160
160
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
|
|
161
|
-
var _this$props4, mediaClient, _this$props4$dimensio, dimensions, cardPreview;
|
|
161
|
+
var _this$props4, mediaClient, _this$props4$dimensio, dimensions, cardPreview, wrappedError;
|
|
162
162
|
|
|
163
163
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
164
164
|
while (1) {
|
|
@@ -176,14 +176,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
176
176
|
cardPreview: cardPreview
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
_context.next =
|
|
179
|
+
_context.next = 12;
|
|
180
180
|
break;
|
|
181
181
|
|
|
182
182
|
case 8:
|
|
183
183
|
_context.prev = 8;
|
|
184
184
|
_context.t0 = _context["catch"](1);
|
|
185
|
+
wrappedError = ensureMediaCardError('remote-preview-fetch-ssr', _context.t0, true);
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
_this.fireNonCriticalErrorEvent(wrappedError);
|
|
188
|
+
|
|
189
|
+
case 12:
|
|
187
190
|
case "end":
|
|
188
191
|
return _context.stop();
|
|
189
192
|
}
|
|
@@ -227,6 +230,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
227
230
|
// If it's any other error we set status 'error'
|
|
228
231
|
|
|
229
232
|
if (isLocalPreviewError(wrappedError)) {
|
|
233
|
+
// This error should already been logged inside the getCardPreview. No need to log it here.
|
|
230
234
|
_this.safeSetState({
|
|
231
235
|
isBannedLocalPreview: true
|
|
232
236
|
});
|
|
@@ -306,7 +310,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
306
310
|
if (isLocal) {
|
|
307
311
|
updateState.isBannedLocalPreview = true;
|
|
308
312
|
|
|
309
|
-
_this.
|
|
313
|
+
_this.fireNonCriticalErrorEvent(error);
|
|
310
314
|
}
|
|
311
315
|
|
|
312
316
|
var _this$props5 = _this.props,
|
|
@@ -368,18 +372,22 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
368
372
|
createAnalyticsEvent && fireScreenEvent(createAnalyticsEvent, _this.fileAttributes);
|
|
369
373
|
});
|
|
370
374
|
|
|
371
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
372
|
-
|
|
375
|
+
_defineProperty(_assertThisInitialized(_this), "fireNonCriticalErrorEvent", function (error) {
|
|
376
|
+
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
377
|
+
var fileState = _this.state.fileState;
|
|
378
|
+
createAnalyticsEvent && fireNonCriticalErrorEvent(createAnalyticsEvent, _this.state.status, _this.fileAttributes, _this.ssrReliability, error, _this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
|
|
373
379
|
});
|
|
374
380
|
|
|
375
|
-
_defineProperty(_assertThisInitialized(_this), "safeSetState", function (
|
|
381
|
+
_defineProperty(_assertThisInitialized(_this), "safeSetState", function (newState) {
|
|
376
382
|
if (_this.hasBeenMounted) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
+
/**
|
|
384
|
+
* createStateUpdater helper returns a callback to be passed to setState.
|
|
385
|
+
* It decides wether to update the 'status' depending on the current state vs the input state.
|
|
386
|
+
* From docs: "Both state and props received by the updater function are guaranteed to be up-to-date."
|
|
387
|
+
* If the input state brings an error and it won't be updating the state, the error will be logged as non-critical inside the helper.
|
|
388
|
+
* If the error persists int the state, it means it is a critical error and should be logged as a failed event for Card
|
|
389
|
+
*/
|
|
390
|
+
_this.setState(createStateUpdater(newState, _this.fireNonCriticalErrorEvent));
|
|
383
391
|
}
|
|
384
392
|
});
|
|
385
393
|
|
|
@@ -978,9 +986,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
978
986
|
value: function fireOperationalEvent() {
|
|
979
987
|
var _this$state7 = this.state,
|
|
980
988
|
status = _this$state7.status,
|
|
981
|
-
error = _this$state7.error
|
|
989
|
+
error = _this$state7.error,
|
|
990
|
+
fileState = _this$state7.fileState;
|
|
982
991
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
983
|
-
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error, this.traceContext);
|
|
992
|
+
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error, this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
|
|
984
993
|
completeUfoExperience(this.internalOccurrenceKey, status, this.fileAttributes, this.fileStateFlags, this.ssrReliability, error);
|
|
985
994
|
}
|
|
986
995
|
}, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../utils/analytics';
|
|
1
|
+
import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload, getErrorEventPayload } from '../utils/analytics';
|
|
2
2
|
import { MediaCardError } from '../errors';
|
|
3
3
|
export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability) {
|
|
4
4
|
var error = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new MediaCardError('missing-error-data');
|
|
5
5
|
var traceContext = arguments.length > 6 ? arguments[6] : undefined;
|
|
6
|
+
var metadataTraceContext = arguments.length > 7 ? arguments[7] : undefined;
|
|
6
7
|
|
|
7
8
|
var fireEvent = function fireEvent(payload) {
|
|
8
9
|
return fireMediaCardEvent(payload, createAnalyticsEvent);
|
|
@@ -10,15 +11,15 @@ export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsE
|
|
|
10
11
|
|
|
11
12
|
switch (status) {
|
|
12
13
|
case 'complete':
|
|
13
|
-
fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext));
|
|
14
|
+
fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext));
|
|
14
15
|
break;
|
|
15
16
|
|
|
16
17
|
case 'failed-processing':
|
|
17
|
-
fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext));
|
|
18
|
+
fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability, traceContext, metadataTraceContext));
|
|
18
19
|
break;
|
|
19
20
|
|
|
20
21
|
case 'error':
|
|
21
|
-
fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability, traceContext));
|
|
22
|
+
fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability, traceContext, metadataTraceContext));
|
|
22
23
|
break;
|
|
23
24
|
}
|
|
24
25
|
};
|
|
@@ -38,4 +39,11 @@ export var fireCopiedEvent = function fireCopiedEvent(createAnalyticsEvent, file
|
|
|
38
39
|
};
|
|
39
40
|
export var fireScreenEvent = function fireScreenEvent(createAnalyticsEvent, fileAttributes) {
|
|
40
41
|
fireMediaCardEvent(getRenderPreviewableCardPayload(fileAttributes), createAnalyticsEvent);
|
|
42
|
+
};
|
|
43
|
+
export var fireNonCriticalErrorEvent = function fireNonCriticalErrorEvent(createAnalyticsEvent, cardStatus, fileAttributes, ssrReliability) {
|
|
44
|
+
var error = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new MediaCardError('missing-error-data');
|
|
45
|
+
var traceContext = arguments.length > 5 ? arguments[5] : undefined;
|
|
46
|
+
var metadataTraceContext = arguments.length > 6 ? arguments[6] : undefined;
|
|
47
|
+
var errorPayload = getErrorEventPayload(cardStatus, fileAttributes, error, ssrReliability, traceContext, metadataTraceContext);
|
|
48
|
+
fireMediaCardEvent(errorPayload, createAnalyticsEvent);
|
|
41
49
|
};
|
|
@@ -26,7 +26,7 @@ var MediaCardErrorBoundary = Loadable({
|
|
|
26
26
|
loader: function loader() {
|
|
27
27
|
return import(
|
|
28
28
|
/* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
|
|
29
|
-
'
|
|
29
|
+
'./media-card-analytics-error-boundary').then(function (mod) {
|
|
30
30
|
return mod.default;
|
|
31
31
|
});
|
|
32
32
|
},
|
|
@@ -52,12 +52,21 @@ var MediaCardWithMediaClient = Loadable({
|
|
|
52
52
|
|
|
53
53
|
var CardWithMediaClient = function CardWithMediaClient(props) {
|
|
54
54
|
var withMediaClient = props.withMediaClient,
|
|
55
|
-
|
|
55
|
+
dimensions = props.dimensions,
|
|
56
|
+
featureFlags = props.featureFlags,
|
|
57
|
+
onClick = props.onClick;
|
|
56
58
|
var memoizedFeatureFlags = useMemoizeFeatureFlags(featureFlags);
|
|
57
59
|
var Card = React.useMemo(function () {
|
|
58
60
|
return withMediaClient(MediaCard, memoizedFeatureFlags);
|
|
59
61
|
}, [withMediaClient, memoizedFeatureFlags]);
|
|
60
|
-
return
|
|
62
|
+
return (
|
|
63
|
+
/*#__PURE__*/
|
|
64
|
+
// onClick is passed into MediaCardErrorBoundary so MediaGroup items can get the toolbar menu in Editor
|
|
65
|
+
React.createElement(MediaCardErrorBoundary, {
|
|
66
|
+
dimensions: dimensions,
|
|
67
|
+
onClick: onClick
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Card, props))
|
|
69
|
+
);
|
|
61
70
|
};
|
|
62
71
|
|
|
63
72
|
var CardLoader = function CardLoader(props) {
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
1
|
import { isErrorFileState } from '@atlaskit/media-client';
|
|
8
2
|
import { MediaCardError } from '../errors';
|
|
9
3
|
import { getCardStatus, isFinalCardStatus } from './getCardStatus';
|
|
10
4
|
import { extractFilePreviewStatus } from './getCardPreview';
|
|
11
|
-
|
|
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
|
+
|
|
10
|
+
export var createStateUpdater = function createStateUpdater(newState, fireErrorEvent) {
|
|
12
11
|
return function (prevState) {
|
|
13
|
-
// Only override if previous status is non-final
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// Only override if previous status is non-final or new status is 'complete'
|
|
13
|
+
if (!!newState.status && isFinalCardStatus(prevState.status) && newState.status !== 'complete') {
|
|
14
|
+
// Log the error if the new state is not going to store it.
|
|
15
|
+
// i.e. this is a non critical error
|
|
16
|
+
!!newState.error && fireErrorEvent(newState.error);
|
|
16
17
|
return prevState;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
return
|
|
20
|
+
return newState;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
export var getCardStateFromFileState = function getCardStateFromFileState(fileState, isBannedLocalPreview, featureFlags) {
|
|
@@ -0,0 +1,115 @@
|
|
|
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 { UnhandledErrorCard } from './ui/unhandledErrorCard';
|
|
20
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
21
|
+
import { fireMediaCardEvent } from '../utils/analytics';
|
|
22
|
+
|
|
23
|
+
var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
24
|
+
_inherits(WrappedMediaCardAnalyticsErrorBoundary, _React$Component);
|
|
25
|
+
|
|
26
|
+
var _super = _createSuper(WrappedMediaCardAnalyticsErrorBoundary);
|
|
27
|
+
|
|
28
|
+
function WrappedMediaCardAnalyticsErrorBoundary(props) {
|
|
29
|
+
var _this;
|
|
30
|
+
|
|
31
|
+
_classCallCheck(this, WrappedMediaCardAnalyticsErrorBoundary);
|
|
32
|
+
|
|
33
|
+
_this = _super.call(this, props);
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "fireOperationalEvent", function (error, info) {
|
|
36
|
+
var _window, _window$navigator;
|
|
37
|
+
|
|
38
|
+
var _this$props = _this.props,
|
|
39
|
+
_this$props$data = _this$props.data,
|
|
40
|
+
data = _this$props$data === void 0 ? {} : _this$props$data,
|
|
41
|
+
createAnalyticsEvent = _this$props.createAnalyticsEvent;
|
|
42
|
+
var payload = {
|
|
43
|
+
eventType: 'operational',
|
|
44
|
+
action: 'failed',
|
|
45
|
+
actionSubject: 'mediaCardRender',
|
|
46
|
+
attributes: _objectSpread({
|
|
47
|
+
browserInfo: (_window = window) !== null && _window !== void 0 && (_window$navigator = _window.navigator) !== null && _window$navigator !== void 0 && _window$navigator.userAgent ? window.navigator.userAgent : 'unknown',
|
|
48
|
+
error: error,
|
|
49
|
+
info: info,
|
|
50
|
+
failReason: 'unexpected-error'
|
|
51
|
+
}, data)
|
|
52
|
+
};
|
|
53
|
+
fireMediaCardEvent(payload, createAnalyticsEvent);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "handleOnClick", function (event) {
|
|
57
|
+
try {
|
|
58
|
+
var _this$props$onClick, _this$props2;
|
|
59
|
+
|
|
60
|
+
(_this$props$onClick = (_this$props2 = _this.props).onClick) === null || _this$props$onClick === void 0 ? void 0 : _this$props$onClick.call(_this$props2, {
|
|
61
|
+
event: event
|
|
62
|
+
});
|
|
63
|
+
} catch (e) {}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
_this.state = {
|
|
67
|
+
hasError: false
|
|
68
|
+
};
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_createClass(WrappedMediaCardAnalyticsErrorBoundary, [{
|
|
73
|
+
key: "componentDidCatch",
|
|
74
|
+
value: function componentDidCatch(error, info) {
|
|
75
|
+
try {
|
|
76
|
+
this.fireOperationalEvent(error, info);
|
|
77
|
+
} catch (e) {}
|
|
78
|
+
|
|
79
|
+
this.setState({
|
|
80
|
+
hasError: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "render",
|
|
85
|
+
value: function render() {
|
|
86
|
+
var hasError = this.state.hasError;
|
|
87
|
+
var _this$props3 = this.props,
|
|
88
|
+
dimensions = _this$props3.dimensions,
|
|
89
|
+
children = _this$props3.children;
|
|
90
|
+
|
|
91
|
+
if (hasError) {
|
|
92
|
+
return /*#__PURE__*/React.createElement(UnhandledErrorCard, {
|
|
93
|
+
dimensions: dimensions,
|
|
94
|
+
onClick: this.handleOnClick
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return children;
|
|
99
|
+
}
|
|
100
|
+
}]);
|
|
101
|
+
|
|
102
|
+
return WrappedMediaCardAnalyticsErrorBoundary;
|
|
103
|
+
}(React.Component);
|
|
104
|
+
|
|
105
|
+
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
106
|
+
|
|
107
|
+
var packageName = "@atlaskit/media-card";
|
|
108
|
+
var packageVersion = "74.4.0";
|
|
109
|
+
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
110
|
+
packageVersion: packageVersion,
|
|
111
|
+
packageName: packageName,
|
|
112
|
+
componentName: 'mediaCard',
|
|
113
|
+
component: 'mediaCard'
|
|
114
|
+
})(withAnalyticsEvents()(WrappedMediaCardAnalyticsErrorBoundary));
|
|
115
|
+
export default MediaCardAnalyticsErrorBoundary;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
7
|
+
|
|
8
|
+
var _templateObject;
|
|
9
|
+
|
|
10
|
+
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); }; }
|
|
11
|
+
|
|
12
|
+
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; } }
|
|
13
|
+
|
|
14
|
+
/** @jsx jsx */
|
|
15
|
+
import { Component } from 'react';
|
|
16
|
+
import { css, jsx } from '@emotion/react';
|
|
17
|
+
import { token } from '@atlaskit/tokens';
|
|
18
|
+
import WarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
19
|
+
import { N20, N800, Y500 } from '@atlaskit/theme/colors';
|
|
20
|
+
import { fontSize } from '@atlaskit/theme/constants';
|
|
21
|
+
import { center, borderRadius } from '@atlaskit/media-ui';
|
|
22
|
+
import { defaultImageCardDimensions } from '../../../utils';
|
|
23
|
+
|
|
24
|
+
var isPercentage = function isPercentage(value) {
|
|
25
|
+
return /^\d+(\.\d+)?%$/.test(value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var shouldShowText = function shouldShowText(_ref) {
|
|
29
|
+
var width = _ref.width,
|
|
30
|
+
height = _ref.height;
|
|
31
|
+
|
|
32
|
+
if (isPercentage(width) || isPercentage(height)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return parseInt(width, 10) >= 240 && parseInt(height, 10) >= 90;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var normalizeDimension = function normalizeDimension(value, defaultValue) {
|
|
40
|
+
var sValue = value.toString();
|
|
41
|
+
return isPercentage(sValue) ? sValue : isNaN(parseInt(sValue, 10)) ? defaultValue + 'px' : parseInt(sValue, 10) + 'px';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var getConvertedDimension = function getConvertedDimension(dimensions) {
|
|
45
|
+
var _dimensions$width = dimensions.width,
|
|
46
|
+
width = _dimensions$width === void 0 ? defaultImageCardDimensions.width : _dimensions$width,
|
|
47
|
+
_dimensions$height = dimensions.height,
|
|
48
|
+
height = _dimensions$height === void 0 ? defaultImageCardDimensions.height : _dimensions$height;
|
|
49
|
+
return {
|
|
50
|
+
width: normalizeDimension(width, defaultImageCardDimensions.width),
|
|
51
|
+
height: normalizeDimension(height, defaultImageCardDimensions.height)
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var wrapperStyles = function wrapperStyles() {
|
|
56
|
+
var dimensions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultImageCardDimensions;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n ", ";\n background: ", ";\n color: ", ";\n max-height: 100%;\n max-width: 100%;\n ", ";\n display: flex;\n flex-direction: column;\n\n p {\n font-size: ", "px;\n text-align: center;\n display: ", ";\n }\n "])), center, borderRadius, token('color.background.neutral', N20), token('color.text.subtle', N800), getConvertedDimension(dimensions), fontSize(), shouldShowText(getConvertedDimension(dimensions)) ? 'block' : 'none');
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export var UnhandledErrorCard = /*#__PURE__*/function (_Component) {
|
|
66
|
+
_inherits(UnhandledErrorCard, _Component);
|
|
67
|
+
|
|
68
|
+
var _super = _createSuper(UnhandledErrorCard);
|
|
69
|
+
|
|
70
|
+
function UnhandledErrorCard() {
|
|
71
|
+
_classCallCheck(this, UnhandledErrorCard);
|
|
72
|
+
|
|
73
|
+
return _super.apply(this, arguments);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_createClass(UnhandledErrorCard, [{
|
|
77
|
+
key: "render",
|
|
78
|
+
value: function render() {
|
|
79
|
+
var _this$props = this.props,
|
|
80
|
+
dimensions = _this$props.dimensions,
|
|
81
|
+
onClick = _this$props.onClick;
|
|
82
|
+
return jsx("div", {
|
|
83
|
+
css: wrapperStyles(dimensions),
|
|
84
|
+
onClick: onClick
|
|
85
|
+
}, jsx(WarningIcon, {
|
|
86
|
+
label: "Error",
|
|
87
|
+
primaryColor: token('color.icon.warning', Y500),
|
|
88
|
+
size: "medium"
|
|
89
|
+
}), jsx("p", null, "We couldn't load this content"));
|
|
90
|
+
}
|
|
91
|
+
}]);
|
|
92
|
+
|
|
93
|
+
return UnhandledErrorCard;
|
|
94
|
+
}(Component);
|