@atlaskit/media-card 73.2.0 → 73.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 73.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`7d8e24c4dcd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d8e24c4dcd) - Log reliability of Media Card SSR
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 73.2.0
4
14
 
5
15
  ### Minor Changes
@@ -10,22 +10,22 @@ var _analytics = require("../../utils/analytics");
10
10
  var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
11
11
  exports.relevantFeatureFlagNames = relevantFeatureFlagNames;
12
12
 
13
- var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
13
+ var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability, error) {
14
14
  var fireEvent = function fireEvent(payload) {
15
15
  return (0, _analytics.fireMediaCardEvent)(payload, createAnalyticsEvent);
16
16
  };
17
17
 
18
18
  switch (status) {
19
19
  case 'complete':
20
- fireEvent((0, _analytics.getRenderSucceededEventPayload)(fileAttributes, performanceAttributes));
20
+ fireEvent((0, _analytics.getRenderSucceededEventPayload)(fileAttributes, performanceAttributes, ssrReliability));
21
21
  break;
22
22
 
23
23
  case 'failed-processing':
24
- fireEvent((0, _analytics.getRenderFailedFileStatusPayload)(fileAttributes, performanceAttributes));
24
+ fireEvent((0, _analytics.getRenderFailedFileStatusPayload)(fileAttributes, performanceAttributes, ssrReliability));
25
25
  break;
26
26
 
27
27
  case 'error':
28
- error && fireEvent((0, _analytics.getRenderErrorEventPayload)(fileAttributes, performanceAttributes, error));
28
+ error && fireEvent((0, _analytics.getRenderErrorEventPayload)(fileAttributes, performanceAttributes, error, ssrReliability));
29
29
  break;
30
30
  }
31
31
  };
@@ -102,6 +102,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
102
102
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasBeenMounted", false);
103
103
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPreAnchorRef", /*#__PURE__*/(0, _react.createRef)());
104
104
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPostAnchorRef", /*#__PURE__*/(0, _react.createRef)());
105
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "ssrReliability", {
106
+ server: {
107
+ status: 'unknown'
108
+ },
109
+ client: {
110
+ status: 'unknown'
111
+ }
112
+ });
105
113
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeElapsedTillCommenced", performance.now());
106
114
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getImageURLParams", function (_ref) {
107
115
  var collection = _ref.collectionName;
@@ -270,7 +278,29 @@ var CardBase = /*#__PURE__*/function (_Component) {
270
278
  }
271
279
  };
272
280
  });
281
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "logSSRImageError", function (cardPreview) {
282
+ if (cardPreview) {
283
+ var failedSSRObject = _objectSpread({
284
+ status: 'fail'
285
+ }, (0, _analytics.extractErrorInfo)(new _errors.ImageLoadError(cardPreview.source)));
286
+
287
+ if ((0, _getCardPreview.isSSRClientPreview)(cardPreview)) {
288
+ _this.ssrReliability.client = failedSSRObject;
289
+ }
290
+ /*
291
+ If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
292
+ */
293
+
294
+
295
+ if ((0, _getCardPreview.isSSRDataPreview)(cardPreview)) {
296
+ _this.ssrReliability.server = failedSSRObject;
297
+ _this.ssrReliability.client = failedSSRObject;
298
+ }
299
+ }
300
+ });
273
301
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageError", function (cardPreview) {
302
+ _this.logSSRImageError(cardPreview);
303
+
274
304
  var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this error
275
305
 
276
306
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
@@ -292,10 +322,6 @@ var CardBase = /*#__PURE__*/function (_Component) {
292
322
  _this.fireLocalPreviewErrorEvent(error);
293
323
  }
294
324
 
295
- if (isSSR) {// TODO: set SSR-client reliability 'failed'.
296
- // https://product-fabric.atlassian.net/browse/MEX-770
297
- }
298
-
299
325
  var _this$props5 = _this.props,
300
326
  identifier = _this$props5.identifier,
301
327
  _this$props5$dimensio = _this$props5.dimensions,
@@ -311,6 +337,27 @@ var CardBase = /*#__PURE__*/function (_Component) {
311
337
  }
312
338
  });
313
339
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageLoad", function (cardPreview) {
340
+ if (cardPreview) {
341
+ if ((0, _getCardPreview.isSSRClientPreview)(cardPreview) && _this.ssrReliability.client.status === 'unknown') {
342
+ _this.ssrReliability.client = {
343
+ status: 'success'
344
+ };
345
+ }
346
+ /*
347
+ If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
348
+ */
349
+
350
+
351
+ if ((0, _getCardPreview.isSSRDataPreview)(cardPreview) && _this.ssrReliability.server.status === 'unknown') {
352
+ _this.ssrReliability.server = {
353
+ status: 'success'
354
+ };
355
+ _this.ssrReliability.client = {
356
+ status: 'success'
357
+ };
358
+ }
359
+ }
360
+
314
361
  var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this callback
315
362
 
316
363
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
@@ -575,20 +622,19 @@ var CardBase = /*#__PURE__*/function (_Component) {
575
622
  })) : card;
576
623
  });
577
624
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "storeSSRData", function () {
625
+ var _this$ssrReliability$;
626
+
578
627
  var _this$props10 = _this.props,
579
628
  ssr = _this$props10.ssr,
580
629
  identifier = _this$props10.identifier;
581
- var _this$state3 = _this.state,
582
- _this$state3$cardPrev = _this$state3.cardPreview;
583
- _this$state3$cardPrev = _this$state3$cardPrev === void 0 ? {} : _this$state3$cardPrev;
584
- var dataURI = _this$state3$cardPrev.dataURI,
585
- error = _this$state3.error;
586
- var ssrDataError = !!error ? (0, _analytics.extractErrorInfo)(error) : undefined;
630
+ var _this$state$cardPrevi = _this.state.cardPreview;
631
+ _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
632
+ var dataURI = _this$state$cardPrevi.dataURI;
587
633
  return (0, _mediaClient2.isFileIdentifier)(identifier) && ssr === 'server' && /*#__PURE__*/_react.default.createElement(_globalScope.StoreSSRDataScript, {
588
634
  identifier: identifier,
589
635
  dataURI: dataURI,
590
636
  dimensions: _this.requestedDimensions,
591
- error: ssrDataError
637
+ error: ((_this$ssrReliability$ = _this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? _this.ssrReliability.server : undefined
592
638
  });
593
639
  });
594
640
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardInViewport", function () {
@@ -642,19 +688,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
642
688
  _cardPreview = (0, _getCardPreview.getCardPreviewFromCache)(id, _dimensions);
643
689
 
644
690
  if (!_cardPreview && _ssr) {
645
- var _this$ssrData;
691
+ var _this$ssrData, _this$ssrData2;
646
692
 
647
693
  _this.ssrData = (0, _globalScope.getSSRData)(_identifier);
648
694
 
649
- if (_ssr === 'server' || !((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.dataURI)) {
695
+ if ((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
696
+ _this.ssrReliability.server = _objectSpread({
697
+ status: 'fail'
698
+ }, _this.ssrData.error);
699
+ }
700
+
701
+ if (!((_this$ssrData2 = _this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
650
702
  try {
651
703
  _cardPreview = (0, _getCardPreview.getSSRCardPreview)(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
652
704
  } catch (e) {
653
- // TODO: handle error in client MEX-770
654
- // If we fail building the dataURI in server, we store the error in the state
655
- // to be later stored in global scope and logged in client.
656
- // We don't set the status = error to fall back to the spinner icon
657
- _error = _ssr === 'server' ? e : undefined;
705
+ _this.ssrReliability[_ssr] = _objectSpread({
706
+ status: 'fail'
707
+ }, (0, _analytics.extractErrorInfo)(e));
658
708
  }
659
709
  } else {
660
710
  _cardPreview = {
@@ -699,9 +749,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
699
749
  key: "componentDidMount",
700
750
  value: function componentDidMount() {
701
751
  this.hasBeenMounted = true;
702
- var _this$state4 = this.state,
703
- isCardVisible = _this$state4.isCardVisible,
704
- cardPreview = _this$state4.cardPreview;
752
+ var _this$state3 = this.state,
753
+ isCardVisible = _this$state3.isCardVisible,
754
+ cardPreview = _this$state3.cardPreview;
705
755
  var _this$props12 = this.props,
706
756
  identifier = _this$props12.identifier,
707
757
  ssr = _this$props12.ssr,
@@ -712,7 +762,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
712
762
  }
713
763
 
714
764
  if (isCardVisible && !!ssr && !!cardPreview && (0, _mediaClient2.isFileIdentifier)(identifier)) {
715
- var _this$ssrData2;
765
+ var _this$ssrData3;
716
766
 
717
767
  if ((0, _getCardPreview.isSSRClientPreview)(cardPreview)) {
718
768
  // Since the SSR preview brings the token in the query params,
@@ -720,7 +770,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
720
770
  this.setCacheSSRPreview(identifier);
721
771
  }
722
772
 
723
- if ((0, _getCardPreview.isSSRDataPreview)(cardPreview) && (0, _dimensionComparer.isBigger)((_this$ssrData2 = this.ssrData) === null || _this$ssrData2 === void 0 ? void 0 : _this$ssrData2.dimensions, dimensions)) {
773
+ if ((0, _getCardPreview.isSSRDataPreview)(cardPreview) && (0, _dimensionComparer.isBigger)((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
724
774
  // If dimensions from Server have changed and are bigger,
725
775
  // we need to refetch
726
776
  this.refetchSSRPreview(identifier);
@@ -747,14 +797,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
747
797
  featureFlags = _this$props13.featureFlags,
748
798
  useInlinePlayer = _this$props13.useInlinePlayer,
749
799
  disableOverlay = _this$props13.disableOverlay;
750
- var _this$state5 = this.state,
751
- isCardVisible = _this$state5.isCardVisible,
752
- cardPreview = _this$state5.cardPreview,
753
- status = _this$state5.status,
754
- fileState = _this$state5.fileState,
755
- isBannedLocalPreview = _this$state5.isBannedLocalPreview,
756
- previewDidRender = _this$state5.previewDidRender,
757
- isPlayingFile = _this$state5.isPlayingFile;
800
+ var _this$state4 = this.state,
801
+ isCardVisible = _this$state4.isCardVisible,
802
+ cardPreview = _this$state4.cardPreview,
803
+ status = _this$state4.status,
804
+ fileState = _this$state4.fileState,
805
+ isBannedLocalPreview = _this$state4.isBannedLocalPreview,
806
+ previewDidRender = _this$state4.previewDidRender,
807
+ isPlayingFile = _this$state4.isPlayingFile;
758
808
  var isDifferent = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
759
809
  var turnedVisible = !prevIsCardVisible && isCardVisible;
760
810
  var isNewMediaClient = prevMediaClient !== mediaClient;
@@ -881,25 +931,25 @@ var CardBase = /*#__PURE__*/function (_Component) {
881
931
  }, {
882
932
  key: "metadata",
883
933
  get: function get() {
884
- var _this$state6;
934
+ var _this$state5;
885
935
 
886
- return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
936
+ return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : _this$state5.fileState);
887
937
  }
888
938
  }, {
889
939
  key: "fileAttributes",
890
940
  get: function get() {
891
- var _this$state7, _this$state7$fileStat;
941
+ var _this$state6, _this$state6$fileStat;
892
942
 
893
- return (0, _analytics.getFileAttributes)(this.metadata, (_this$state7 = this.state) === null || _this$state7 === void 0 ? void 0 : (_this$state7$fileStat = _this$state7.fileState) === null || _this$state7$fileStat === void 0 ? void 0 : _this$state7$fileStat.status);
943
+ return (0, _analytics.getFileAttributes)(this.metadata, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : (_this$state6$fileStat = _this$state6.fileState) === null || _this$state6$fileStat === void 0 ? void 0 : _this$state6$fileStat.status);
894
944
  }
895
945
  }, {
896
946
  key: "fireOperationalEvent",
897
947
  value: function fireOperationalEvent() {
898
- var _this$state8 = this.state,
899
- status = _this$state8.status,
900
- error = _this$state8.error;
948
+ var _this$state7 = this.state,
949
+ status = _this$state7.status,
950
+ error = _this$state7.error;
901
951
  var createAnalyticsEvent = this.props.createAnalyticsEvent;
902
- createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
952
+ createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error);
903
953
  }
904
954
  }, {
905
955
  key: "fireCommencedEvent",
@@ -943,9 +993,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
943
993
  }, {
944
994
  key: "render",
945
995
  value: function render() {
946
- var _this$state9 = this.state,
947
- isPlayingFile = _this$state9.isPlayingFile,
948
- mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
996
+ var _this$state8 = this.state,
997
+ isPlayingFile = _this$state8.isPlayingFile,
998
+ mediaViewerSelectedItem = _this$state8.mediaViewerSelectedItem;
949
999
 
950
1000
  var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
951
1001
 
@@ -64,7 +64,7 @@ var getRenderCommencedEventPayload = function getRenderCommencedEventPayload(fil
64
64
 
65
65
  exports.getRenderCommencedEventPayload = getRenderCommencedEventPayload;
66
66
 
67
- var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes) {
67
+ var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability) {
68
68
  return {
69
69
  eventType: 'operational',
70
70
  action: 'succeeded',
@@ -72,7 +72,8 @@ var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fil
72
72
  attributes: {
73
73
  fileAttributes: fileAttributes,
74
74
  performanceAttributes: performanceAttributes,
75
- status: 'success'
75
+ status: 'success',
76
+ ssrReliability: ssrReliability
76
77
  }
77
78
  };
78
79
  };
@@ -147,7 +148,7 @@ var extractErrorInfo = function extractErrorInfo(error) {
147
148
 
148
149
  exports.extractErrorInfo = extractErrorInfo;
149
150
 
150
- var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error) {
151
+ var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability) {
151
152
  return {
152
153
  eventType: 'operational',
153
154
  action: 'failed',
@@ -157,14 +158,15 @@ var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttribu
157
158
  performanceAttributes: performanceAttributes,
158
159
  status: 'fail'
159
160
  }, extractErrorInfo(error)), {}, {
160
- request: getRenderErrorRequestMetadata(error)
161
+ request: getRenderErrorRequestMetadata(error),
162
+ ssrReliability: ssrReliability
161
163
  })
162
164
  };
163
165
  };
164
166
 
165
167
  exports.getRenderErrorEventPayload = getRenderErrorEventPayload;
166
168
 
167
- var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
169
+ var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability) {
168
170
  return {
169
171
  eventType: 'operational',
170
172
  action: 'failed',
@@ -173,7 +175,8 @@ var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload
173
175
  fileAttributes: fileAttributes,
174
176
  performanceAttributes: performanceAttributes,
175
177
  status: 'fail',
176
- failReason: 'failed-processing'
178
+ failReason: 'failed-processing',
179
+ ssrReliability: ssrReliability
177
180
  }
178
181
  };
179
182
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.2.0",
3
+ "version": "73.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,19 +1,19 @@
1
1
  import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
2
2
  export const relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
3
- export const fireOperationalEvent = (createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) => {
3
+ export const fireOperationalEvent = (createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability, error) => {
4
4
  const fireEvent = payload => fireMediaCardEvent(payload, createAnalyticsEvent);
5
5
 
6
6
  switch (status) {
7
7
  case 'complete':
8
- fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes));
8
+ fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability));
9
9
  break;
10
10
 
11
11
  case 'failed-processing':
12
- fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes));
12
+ fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability));
13
13
  break;
14
14
 
15
15
  case 'error':
16
- error && fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error));
16
+ error && fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability));
17
17
  break;
18
18
  }
19
19
  };
@@ -36,6 +36,15 @@ export class CardBase extends Component {
36
36
 
37
37
  _defineProperty(this, "viewportPostAnchorRef", /*#__PURE__*/createRef());
38
38
 
39
+ _defineProperty(this, "ssrReliability", {
40
+ server: {
41
+ status: 'unknown'
42
+ },
43
+ client: {
44
+ status: 'unknown'
45
+ }
46
+ });
47
+
39
48
  _defineProperty(this, "timeElapsedTillCommenced", performance.now());
40
49
 
41
50
  _defineProperty(this, "getImageURLParams", ({
@@ -165,7 +174,30 @@ export class CardBase extends Component {
165
174
  };
166
175
  });
167
176
 
177
+ _defineProperty(this, "logSSRImageError", cardPreview => {
178
+ if (cardPreview) {
179
+ const failedSSRObject = {
180
+ status: 'fail',
181
+ ...extractErrorInfo(new ImageLoadError(cardPreview.source))
182
+ };
183
+
184
+ if (isSSRClientPreview(cardPreview)) {
185
+ this.ssrReliability.client = failedSSRObject;
186
+ }
187
+ /*
188
+ If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
189
+ */
190
+
191
+
192
+ if (isSSRDataPreview(cardPreview)) {
193
+ this.ssrReliability.server = failedSSRObject;
194
+ this.ssrReliability.client = failedSSRObject;
195
+ }
196
+ }
197
+ });
198
+
168
199
  _defineProperty(this, "onImageError", cardPreview => {
200
+ this.logSSRImageError(cardPreview);
169
201
  const {
170
202
  cardPreview: currentPreview
171
203
  } = this.state; // If the dataURI has been replaced, we can dismiss this error
@@ -188,10 +220,6 @@ export class CardBase extends Component {
188
220
  this.fireLocalPreviewErrorEvent(error);
189
221
  }
190
222
 
191
- if (isSSR) {// TODO: set SSR-client reliability 'failed'.
192
- // https://product-fabric.atlassian.net/browse/MEX-770
193
- }
194
-
195
223
  const {
196
224
  identifier,
197
225
  dimensions = {}
@@ -207,6 +235,27 @@ export class CardBase extends Component {
207
235
  });
208
236
 
209
237
  _defineProperty(this, "onImageLoad", cardPreview => {
238
+ if (cardPreview) {
239
+ if (isSSRClientPreview(cardPreview) && this.ssrReliability.client.status === 'unknown') {
240
+ this.ssrReliability.client = {
241
+ status: 'success'
242
+ };
243
+ }
244
+ /*
245
+ If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
246
+ */
247
+
248
+
249
+ if (isSSRDataPreview(cardPreview) && this.ssrReliability.server.status === 'unknown') {
250
+ this.ssrReliability.server = {
251
+ status: 'success'
252
+ };
253
+ this.ssrReliability.client = {
254
+ status: 'success'
255
+ };
256
+ }
257
+ }
258
+
210
259
  const {
211
260
  cardPreview: currentPreview
212
261
  } = this.state; // If the dataURI has been replaced, we can dismiss this callback
@@ -503,6 +552,8 @@ export class CardBase extends Component {
503
552
  });
504
553
 
505
554
  _defineProperty(this, "storeSSRData", () => {
555
+ var _this$ssrReliability$;
556
+
506
557
  const {
507
558
  ssr,
508
559
  identifier
@@ -510,15 +561,13 @@ export class CardBase extends Component {
510
561
  const {
511
562
  cardPreview: {
512
563
  dataURI
513
- } = {},
514
- error
564
+ } = {}
515
565
  } = this.state;
516
- const ssrDataError = !!error ? extractErrorInfo(error) : undefined;
517
566
  return isFileIdentifier(identifier) && ssr === 'server' && /*#__PURE__*/React.createElement(StoreSSRDataScript, {
518
567
  identifier: identifier,
519
568
  dataURI: dataURI,
520
569
  dimensions: this.requestedDimensions,
521
- error: ssrDataError
570
+ error: ((_this$ssrReliability$ = this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? this.ssrReliability.server : undefined
522
571
  });
523
572
  });
524
573
 
@@ -582,19 +631,25 @@ export class CardBase extends Component {
582
631
  _cardPreview = getCardPreviewFromCache(id, _dimensions);
583
632
 
584
633
  if (!_cardPreview && _ssr) {
585
- var _this$ssrData;
634
+ var _this$ssrData, _this$ssrData2;
586
635
 
587
636
  this.ssrData = getSSRData(_identifier);
588
637
 
589
- if (_ssr === 'server' || !((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.dataURI)) {
638
+ if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
639
+ this.ssrReliability.server = {
640
+ status: 'fail',
641
+ ...this.ssrData.error
642
+ };
643
+ }
644
+
645
+ if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
590
646
  try {
591
647
  _cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, this.getImageURLParams(_identifier), this.getMediaBlobUrlAttrs(_identifier));
592
648
  } catch (e) {
593
- // TODO: handle error in client MEX-770
594
- // If we fail building the dataURI in server, we store the error in the state
595
- // to be later stored in global scope and logged in client.
596
- // We don't set the status = error to fall back to the spinner icon
597
- _error = _ssr === 'server' ? e : undefined;
649
+ this.ssrReliability[_ssr] = {
650
+ status: 'fail',
651
+ ...extractErrorInfo(e)
652
+ };
598
653
  }
599
654
  } else {
600
655
  _cardPreview = {
@@ -652,7 +707,7 @@ export class CardBase extends Component {
652
707
  }
653
708
 
654
709
  if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
655
- var _this$ssrData2;
710
+ var _this$ssrData3;
656
711
 
657
712
  if (isSSRClientPreview(cardPreview)) {
658
713
  // Since the SSR preview brings the token in the query params,
@@ -660,7 +715,7 @@ export class CardBase extends Component {
660
715
  this.setCacheSSRPreview(identifier);
661
716
  }
662
717
 
663
- if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData2 = this.ssrData) === null || _this$ssrData2 === void 0 ? void 0 : _this$ssrData2.dimensions, dimensions)) {
718
+ if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
664
719
  // If dimensions from Server have changed and are bigger,
665
720
  // we need to refetch
666
721
  this.refetchSSRPreview(identifier);
@@ -847,7 +902,7 @@ export class CardBase extends Component {
847
902
  const {
848
903
  createAnalyticsEvent
849
904
  } = this.props;
850
- createAnalyticsEvent && fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
905
+ createAnalyticsEvent && fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error);
851
906
  }
852
907
 
853
908
  fireCommencedEvent() {
@@ -30,14 +30,15 @@ export const getRenderCommencedEventPayload = (fileAttributes, performanceAttrib
30
30
  }
31
31
  };
32
32
  };
33
- export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes) => ({
33
+ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes, ssrReliability) => ({
34
34
  eventType: 'operational',
35
35
  action: 'succeeded',
36
36
  actionSubject: 'mediaCardRender',
37
37
  attributes: {
38
38
  fileAttributes,
39
39
  performanceAttributes,
40
- status: 'success'
40
+ status: 'success',
41
+ ssrReliability
41
42
  }
42
43
  });
43
44
  export const getRenderFailedExternalUriPayload = (fileAttributes, performanceAttributes) => ({
@@ -88,7 +89,7 @@ export const extractErrorInfo = error => {
88
89
  errorDetail: getRenderErrorErrorDetail(error)
89
90
  };
90
91
  };
91
- export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
92
+ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error, ssrReliability) => ({
92
93
  eventType: 'operational',
93
94
  action: 'failed',
94
95
  actionSubject: 'mediaCardRender',
@@ -97,10 +98,11 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
97
98
  performanceAttributes,
98
99
  status: 'fail',
99
100
  ...extractErrorInfo(error),
100
- request: getRenderErrorRequestMetadata(error)
101
+ request: getRenderErrorRequestMetadata(error),
102
+ ssrReliability
101
103
  }
102
104
  });
103
- export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes) => ({
105
+ export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes, ssrReliability) => ({
104
106
  eventType: 'operational',
105
107
  action: 'failed',
106
108
  actionSubject: 'mediaCardRender',
@@ -108,7 +110,8 @@ export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttr
108
110
  fileAttributes,
109
111
  performanceAttributes,
110
112
  status: 'fail',
111
- failReason: 'failed-processing'
113
+ failReason: 'failed-processing',
114
+ ssrReliability
112
115
  }
113
116
  });
114
117
  export const getCopiedFilePayload = fileId => ({
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.2.0",
3
+ "version": "73.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,21 +1,21 @@
1
1
  import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
2
2
  export var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
3
- export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
3
+ export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability, error) {
4
4
  var fireEvent = function fireEvent(payload) {
5
5
  return fireMediaCardEvent(payload, createAnalyticsEvent);
6
6
  };
7
7
 
8
8
  switch (status) {
9
9
  case 'complete':
10
- fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes));
10
+ fireEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability));
11
11
  break;
12
12
 
13
13
  case 'failed-processing':
14
- fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes));
14
+ fireEvent(getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability));
15
15
  break;
16
16
 
17
17
  case 'error':
18
- error && fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error));
18
+ error && fireEvent(getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability));
19
19
  break;
20
20
  }
21
21
  };
@@ -62,6 +62,15 @@ export var CardBase = /*#__PURE__*/function (_Component) {
62
62
 
63
63
  _defineProperty(_assertThisInitialized(_this), "viewportPostAnchorRef", /*#__PURE__*/createRef());
64
64
 
65
+ _defineProperty(_assertThisInitialized(_this), "ssrReliability", {
66
+ server: {
67
+ status: 'unknown'
68
+ },
69
+ client: {
70
+ status: 'unknown'
71
+ }
72
+ });
73
+
65
74
  _defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
66
75
 
67
76
  _defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
@@ -238,7 +247,30 @@ export var CardBase = /*#__PURE__*/function (_Component) {
238
247
  };
239
248
  });
240
249
 
250
+ _defineProperty(_assertThisInitialized(_this), "logSSRImageError", function (cardPreview) {
251
+ if (cardPreview) {
252
+ var failedSSRObject = _objectSpread({
253
+ status: 'fail'
254
+ }, extractErrorInfo(new ImageLoadError(cardPreview.source)));
255
+
256
+ if (isSSRClientPreview(cardPreview)) {
257
+ _this.ssrReliability.client = failedSSRObject;
258
+ }
259
+ /*
260
+ If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
261
+ */
262
+
263
+
264
+ if (isSSRDataPreview(cardPreview)) {
265
+ _this.ssrReliability.server = failedSSRObject;
266
+ _this.ssrReliability.client = failedSSRObject;
267
+ }
268
+ }
269
+ });
270
+
241
271
  _defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
272
+ _this.logSSRImageError(cardPreview);
273
+
242
274
  var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this error
243
275
 
244
276
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
@@ -260,10 +292,6 @@ export var CardBase = /*#__PURE__*/function (_Component) {
260
292
  _this.fireLocalPreviewErrorEvent(error);
261
293
  }
262
294
 
263
- if (isSSR) {// TODO: set SSR-client reliability 'failed'.
264
- // https://product-fabric.atlassian.net/browse/MEX-770
265
- }
266
-
267
295
  var _this$props5 = _this.props,
268
296
  identifier = _this$props5.identifier,
269
297
  _this$props5$dimensio = _this$props5.dimensions,
@@ -280,6 +308,27 @@ export var CardBase = /*#__PURE__*/function (_Component) {
280
308
  });
281
309
 
282
310
  _defineProperty(_assertThisInitialized(_this), "onImageLoad", function (cardPreview) {
311
+ if (cardPreview) {
312
+ if (isSSRClientPreview(cardPreview) && _this.ssrReliability.client.status === 'unknown') {
313
+ _this.ssrReliability.client = {
314
+ status: 'success'
315
+ };
316
+ }
317
+ /*
318
+ If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
319
+ */
320
+
321
+
322
+ if (isSSRDataPreview(cardPreview) && _this.ssrReliability.server.status === 'unknown') {
323
+ _this.ssrReliability.server = {
324
+ status: 'success'
325
+ };
326
+ _this.ssrReliability.client = {
327
+ status: 'success'
328
+ };
329
+ }
330
+ }
331
+
283
332
  var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this callback
284
333
 
285
334
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
@@ -556,20 +605,19 @@ export var CardBase = /*#__PURE__*/function (_Component) {
556
605
  });
557
606
 
558
607
  _defineProperty(_assertThisInitialized(_this), "storeSSRData", function () {
608
+ var _this$ssrReliability$;
609
+
559
610
  var _this$props10 = _this.props,
560
611
  ssr = _this$props10.ssr,
561
612
  identifier = _this$props10.identifier;
562
- var _this$state3 = _this.state,
563
- _this$state3$cardPrev = _this$state3.cardPreview;
564
- _this$state3$cardPrev = _this$state3$cardPrev === void 0 ? {} : _this$state3$cardPrev;
565
- var dataURI = _this$state3$cardPrev.dataURI,
566
- error = _this$state3.error;
567
- var ssrDataError = !!error ? extractErrorInfo(error) : undefined;
613
+ var _this$state$cardPrevi = _this.state.cardPreview;
614
+ _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
615
+ var dataURI = _this$state$cardPrevi.dataURI;
568
616
  return isFileIdentifier(identifier) && ssr === 'server' && /*#__PURE__*/React.createElement(StoreSSRDataScript, {
569
617
  identifier: identifier,
570
618
  dataURI: dataURI,
571
619
  dimensions: _this.requestedDimensions,
572
- error: ssrDataError
620
+ error: ((_this$ssrReliability$ = _this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? _this.ssrReliability.server : undefined
573
621
  });
574
622
  });
575
623
 
@@ -627,19 +675,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
627
675
  _cardPreview = getCardPreviewFromCache(id, _dimensions);
628
676
 
629
677
  if (!_cardPreview && _ssr) {
630
- var _this$ssrData;
678
+ var _this$ssrData, _this$ssrData2;
631
679
 
632
680
  _this.ssrData = getSSRData(_identifier);
633
681
 
634
- if (_ssr === 'server' || !((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.dataURI)) {
682
+ if ((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
683
+ _this.ssrReliability.server = _objectSpread({
684
+ status: 'fail'
685
+ }, _this.ssrData.error);
686
+ }
687
+
688
+ if (!((_this$ssrData2 = _this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
635
689
  try {
636
690
  _cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
637
691
  } catch (e) {
638
- // TODO: handle error in client MEX-770
639
- // If we fail building the dataURI in server, we store the error in the state
640
- // to be later stored in global scope and logged in client.
641
- // We don't set the status = error to fall back to the spinner icon
642
- _error = _ssr === 'server' ? e : undefined;
692
+ _this.ssrReliability[_ssr] = _objectSpread({
693
+ status: 'fail'
694
+ }, extractErrorInfo(e));
643
695
  }
644
696
  } else {
645
697
  _cardPreview = {
@@ -684,9 +736,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
684
736
  key: "componentDidMount",
685
737
  value: function componentDidMount() {
686
738
  this.hasBeenMounted = true;
687
- var _this$state4 = this.state,
688
- isCardVisible = _this$state4.isCardVisible,
689
- cardPreview = _this$state4.cardPreview;
739
+ var _this$state3 = this.state,
740
+ isCardVisible = _this$state3.isCardVisible,
741
+ cardPreview = _this$state3.cardPreview;
690
742
  var _this$props12 = this.props,
691
743
  identifier = _this$props12.identifier,
692
744
  ssr = _this$props12.ssr,
@@ -697,7 +749,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
697
749
  }
698
750
 
699
751
  if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
700
- var _this$ssrData2;
752
+ var _this$ssrData3;
701
753
 
702
754
  if (isSSRClientPreview(cardPreview)) {
703
755
  // Since the SSR preview brings the token in the query params,
@@ -705,7 +757,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
705
757
  this.setCacheSSRPreview(identifier);
706
758
  }
707
759
 
708
- if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData2 = this.ssrData) === null || _this$ssrData2 === void 0 ? void 0 : _this$ssrData2.dimensions, dimensions)) {
760
+ if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
709
761
  // If dimensions from Server have changed and are bigger,
710
762
  // we need to refetch
711
763
  this.refetchSSRPreview(identifier);
@@ -732,14 +784,14 @@ export var CardBase = /*#__PURE__*/function (_Component) {
732
784
  featureFlags = _this$props13.featureFlags,
733
785
  useInlinePlayer = _this$props13.useInlinePlayer,
734
786
  disableOverlay = _this$props13.disableOverlay;
735
- var _this$state5 = this.state,
736
- isCardVisible = _this$state5.isCardVisible,
737
- cardPreview = _this$state5.cardPreview,
738
- status = _this$state5.status,
739
- fileState = _this$state5.fileState,
740
- isBannedLocalPreview = _this$state5.isBannedLocalPreview,
741
- previewDidRender = _this$state5.previewDidRender,
742
- isPlayingFile = _this$state5.isPlayingFile;
787
+ var _this$state4 = this.state,
788
+ isCardVisible = _this$state4.isCardVisible,
789
+ cardPreview = _this$state4.cardPreview,
790
+ status = _this$state4.status,
791
+ fileState = _this$state4.fileState,
792
+ isBannedLocalPreview = _this$state4.isBannedLocalPreview,
793
+ previewDidRender = _this$state4.previewDidRender,
794
+ isPlayingFile = _this$state4.isPlayingFile;
743
795
  var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
744
796
  var turnedVisible = !prevIsCardVisible && isCardVisible;
745
797
  var isNewMediaClient = prevMediaClient !== mediaClient;
@@ -866,25 +918,25 @@ export var CardBase = /*#__PURE__*/function (_Component) {
866
918
  }, {
867
919
  key: "metadata",
868
920
  get: function get() {
869
- var _this$state6;
921
+ var _this$state5;
870
922
 
871
- return getFileDetails(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
923
+ return getFileDetails(this.props.identifier, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : _this$state5.fileState);
872
924
  }
873
925
  }, {
874
926
  key: "fileAttributes",
875
927
  get: function get() {
876
- var _this$state7, _this$state7$fileStat;
928
+ var _this$state6, _this$state6$fileStat;
877
929
 
878
- return getFileAttributes(this.metadata, (_this$state7 = this.state) === null || _this$state7 === void 0 ? void 0 : (_this$state7$fileStat = _this$state7.fileState) === null || _this$state7$fileStat === void 0 ? void 0 : _this$state7$fileStat.status);
930
+ return getFileAttributes(this.metadata, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : (_this$state6$fileStat = _this$state6.fileState) === null || _this$state6$fileStat === void 0 ? void 0 : _this$state6$fileStat.status);
879
931
  }
880
932
  }, {
881
933
  key: "fireOperationalEvent",
882
934
  value: function fireOperationalEvent() {
883
- var _this$state8 = this.state,
884
- status = _this$state8.status,
885
- error = _this$state8.error;
935
+ var _this$state7 = this.state,
936
+ status = _this$state7.status,
937
+ error = _this$state7.error;
886
938
  var createAnalyticsEvent = this.props.createAnalyticsEvent;
887
- createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
939
+ createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error);
888
940
  }
889
941
  }, {
890
942
  key: "fireCommencedEvent",
@@ -928,9 +980,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
928
980
  }, {
929
981
  key: "render",
930
982
  value: function render() {
931
- var _this$state9 = this.state,
932
- isPlayingFile = _this$state9.isPlayingFile,
933
- mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
983
+ var _this$state8 = this.state,
984
+ isPlayingFile = _this$state8.isPlayingFile,
985
+ mediaViewerSelectedItem = _this$state8.mediaViewerSelectedItem;
934
986
  var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
935
987
  return this.props.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
936
988
  locale: "en"
@@ -40,7 +40,7 @@ export var getRenderCommencedEventPayload = function getRenderCommencedEventPayl
40
40
  }
41
41
  };
42
42
  };
43
- export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes) {
43
+ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability) {
44
44
  return {
45
45
  eventType: 'operational',
46
46
  action: 'succeeded',
@@ -48,7 +48,8 @@ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayl
48
48
  attributes: {
49
49
  fileAttributes: fileAttributes,
50
50
  performanceAttributes: performanceAttributes,
51
- status: 'success'
51
+ status: 'success',
52
+ ssrReliability: ssrReliability
52
53
  }
53
54
  };
54
55
  };
@@ -102,7 +103,7 @@ export var extractErrorInfo = function extractErrorInfo(error) {
102
103
  errorDetail: getRenderErrorErrorDetail(error)
103
104
  };
104
105
  };
105
- export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error) {
106
+ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability) {
106
107
  return {
107
108
  eventType: 'operational',
108
109
  action: 'failed',
@@ -112,11 +113,12 @@ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(file
112
113
  performanceAttributes: performanceAttributes,
113
114
  status: 'fail'
114
115
  }, extractErrorInfo(error)), {}, {
115
- request: getRenderErrorRequestMetadata(error)
116
+ request: getRenderErrorRequestMetadata(error),
117
+ ssrReliability: ssrReliability
116
118
  })
117
119
  };
118
120
  };
119
- export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
121
+ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability) {
120
122
  return {
121
123
  eventType: 'operational',
122
124
  action: 'failed',
@@ -125,7 +127,8 @@ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatus
125
127
  fileAttributes: fileAttributes,
126
128
  performanceAttributes: performanceAttributes,
127
129
  status: 'fail',
128
- failReason: 'failed-processing'
130
+ failReason: 'failed-processing',
131
+ ssrReliability: ssrReliability
129
132
  }
130
133
  };
131
134
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.2.0",
3
+ "version": "73.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,4 @@
1
1
  /// <reference types="cypress" />
2
- /// <reference types="jquery" />
3
2
  import { InProductTestPageObject } from '@atlaskit/in-product-testing';
4
3
  export declare class MediaCardPageObject extends InProductTestPageObject {
5
4
  expectCardReady(numOfCards: number): Cypress.Chainable<JQuery<HTMLElement>>;
@@ -1,9 +1,10 @@
1
1
  import { FileAttributes, MediaFeatureFlags, PerformanceAttributes } from '@atlaskit/media-common';
2
2
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import { SSRStatus } from '../../utils/analytics';
3
4
  import { CardStatus } from '../..';
4
5
  import { MediaCardError } from './../../errors';
5
6
  export declare const relevantFeatureFlagNames: Array<keyof MediaFeatureFlags>;
6
- export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error?: MediaCardError | undefined) => void;
7
+ export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error?: MediaCardError | undefined) => void;
7
8
  export declare const fireCommencedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => void;
8
9
  export declare const fireCopiedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileId: string, cardRef: HTMLDivElement) => void;
9
10
  export declare const fireScreenEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes) => void;
@@ -9,6 +9,7 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
9
9
  private hasBeenMounted;
10
10
  private viewportPreAnchorRef;
11
11
  private viewportPostAnchorRef;
12
+ private ssrReliability;
12
13
  private timeElapsedTillCommenced;
13
14
  subscription?: Subscription;
14
15
  private ssrData?;
@@ -29,6 +30,7 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
29
30
  private get metadata();
30
31
  private get fileAttributes();
31
32
  private getPerformanceAttributes;
33
+ private logSSRImageError;
32
34
  private onImageError;
33
35
  private onImageLoad;
34
36
  private fireOperationalEvent;
@@ -9,12 +9,27 @@ export declare type MediaCardErrorInfo = {
9
9
  error: MediaClientErrorReason | 'nativeError';
10
10
  errorDetail: string;
11
11
  };
12
- export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & FailureAttributes & {
12
+ export declare type SSRStatusFail = MediaCardErrorInfo & {
13
+ status: 'fail';
14
+ };
15
+ declare type SSRStatusSuccess = SuccessAttributes;
16
+ declare type SSRStatusUnknown = {
17
+ status: 'unknown';
18
+ };
19
+ declare type SSRStatusAttributes = SSRStatusSuccess | SSRStatusFail | SSRStatusUnknown;
20
+ export declare type SSRStatus = {
21
+ server: SSRStatusAttributes;
22
+ client: SSRStatusAttributes;
23
+ };
24
+ export declare type WithSSRReliability = {
25
+ ssrReliability?: SSRStatus;
26
+ };
27
+ export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & FailureAttributes & {
13
28
  failReason: FailedErrorFailReason | 'failed-processing';
14
29
  error?: MediaClientErrorReason | 'nativeError';
15
30
  request?: RequestMetadata;
16
31
  }, 'failed', 'mediaCardRender'>;
17
- export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
32
+ export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
18
33
  export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes, 'commenced', 'mediaCardRender'>;
19
34
  export declare type CopiedFileEventPayload = UIEventPayload<{}, 'copied', string>;
20
35
  export declare type ClickedEventPayload = UIEventPayload<{
@@ -30,15 +45,16 @@ export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload
30
45
  export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: "failed-processing" | "uploading" | "processing" | "processed" | "error" | undefined) => FileAttributes;
31
46
  export declare const getRenderPreviewableCardPayload: (fileAttributes: FileAttributes) => RenderScreenEventPayload;
32
47
  export declare const getRenderCommencedEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderCommencedEventPayload;
33
- export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes?: PerformanceAttributes | undefined) => RenderSucceededEventPayload;
48
+ export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus) => RenderSucceededEventPayload;
34
49
  export declare const getRenderFailedExternalUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
35
50
  export declare const getRenderErrorFailReason: (error: MediaCardError) => FailedErrorFailReason;
36
51
  export declare const getRenderErrorErrorReason: (error: MediaCardError) => MediaClientErrorReason | 'nativeError';
37
52
  export declare const getRenderErrorErrorDetail: (error: MediaCardError) => string;
38
53
  export declare const getRenderErrorRequestMetadata: (error: MediaCardError) => RequestMetadata | undefined;
39
54
  export declare const extractErrorInfo: (error: MediaCardError) => MediaCardErrorInfo;
40
- export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError) => RenderFailedEventPayload;
41
- export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
55
+ export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError, ssrReliability: SSRStatus) => RenderFailedEventPayload;
56
+ export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus) => RenderFailedEventPayload;
42
57
  export declare const getCopiedFilePayload: (fileId: string) => CopiedFileEventPayload;
43
58
  export declare function fireMediaCardEvent(payload: MediaCardAnalyticsEventPayload, createAnalyticsEvent?: CreateUIAnalyticsEvent): void;
44
59
  export declare const createAndFireMediaCardEvent: (payload: MediaCardAnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
60
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.2.0",
3
+ "version": "73.3.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,13 +30,13 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/analytics-next": "^8.2.0",
32
32
  "@atlaskit/dropdown-menu": "^11.1.0",
33
- "@atlaskit/editor-shared-styles": "^1.6.0",
33
+ "@atlaskit/editor-shared-styles": "^2.0.0",
34
34
  "@atlaskit/icon": "^21.10.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/media-client": "^14.3.0",
37
- "@atlaskit/media-common": "^2.10.0",
38
- "@atlaskit/media-ui": "^19.0.0",
39
- "@atlaskit/media-viewer": "^46.0.0",
36
+ "@atlaskit/media-client": "^14.4.0",
37
+ "@atlaskit/media-common": "^2.11.0",
38
+ "@atlaskit/media-ui": "^20.0.0",
39
+ "@atlaskit/media-viewer": "^46.1.0",
40
40
  "@atlaskit/spinner": "^15.1.0",
41
41
  "@atlaskit/theme": "^12.1.0",
42
42
  "@atlaskit/tooltip": "^17.5.0",
@@ -57,13 +57,13 @@
57
57
  "devDependencies": {
58
58
  "@atlaskit/analytics-listeners": "^8.2.0",
59
59
  "@atlaskit/analytics-namespaced-context": "^6.4.0",
60
- "@atlaskit/button": "^16.1.0",
60
+ "@atlaskit/button": "^16.2.0",
61
61
  "@atlaskit/checkbox": "^12.3.0",
62
62
  "@atlaskit/docs": "*",
63
63
  "@atlaskit/inline-message": "^11.2.0",
64
64
  "@atlaskit/item": "^12.0.0",
65
65
  "@atlaskit/media-core": "^32.2.0",
66
- "@atlaskit/media-test-helpers": "^29.1.0",
66
+ "@atlaskit/media-test-helpers": "^29.2.0",
67
67
  "@atlaskit/radio": "^5.3.2",
68
68
  "@atlaskit/range": "^6.0.0",
69
69
  "@atlaskit/select": "^15.2.1",