@atlaskit/smart-card 26.24.0 → 26.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/extractors/block/index.js +1 -1
  3. package/dist/cjs/extractors/common/actions/extractActions.js +3 -31
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +10 -15
  5. package/dist/cjs/state/hooks/use-invoke/utils.js +23 -0
  6. package/dist/cjs/state/hooks/use-invoke-client-action/index.js +20 -14
  7. package/dist/cjs/utils/analytics/analytics.js +28 -7
  8. package/dist/cjs/utils/mocks.js +7 -2
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
  10. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -45
  11. package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
  12. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
  13. package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +32 -15
  14. package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
  15. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +2 -4
  16. package/dist/cjs/view/FlexibleCard/components/utils.js +9 -20
  17. package/dist/cjs/view/FlexibleCard/index.js +14 -1
  18. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
  19. package/dist/cjs/view/LinkUrl/index.js +1 -1
  20. package/dist/es2019/extractors/block/index.js +2 -2
  21. package/dist/es2019/extractors/common/actions/extractActions.js +2 -23
  22. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +10 -17
  23. package/dist/es2019/state/hooks/use-invoke/utils.js +13 -0
  24. package/dist/es2019/state/hooks/use-invoke-client-action/index.js +14 -8
  25. package/dist/es2019/utils/analytics/analytics.js +65 -32
  26. package/dist/es2019/utils/mocks.js +7 -2
  27. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
  28. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -42
  29. package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +15 -1
  30. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +18 -7
  31. package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +19 -1
  32. package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +15 -1
  33. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +1 -1
  34. package/dist/es2019/view/FlexibleCard/components/utils.js +3 -17
  35. package/dist/es2019/view/FlexibleCard/index.js +11 -1
  36. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
  37. package/dist/es2019/view/LinkUrl/index.js +1 -1
  38. package/dist/esm/extractors/block/index.js +2 -2
  39. package/dist/esm/extractors/common/actions/extractActions.js +2 -30
  40. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +11 -16
  41. package/dist/esm/state/hooks/use-invoke/utils.js +15 -0
  42. package/dist/esm/state/hooks/use-invoke-client-action/index.js +20 -14
  43. package/dist/esm/utils/analytics/analytics.js +23 -5
  44. package/dist/esm/utils/mocks.js +7 -2
  45. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
  46. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -46
  47. package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
  48. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
  49. package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +32 -15
  50. package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
  51. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +1 -3
  52. package/dist/esm/view/FlexibleCard/components/utils.js +9 -20
  53. package/dist/esm/view/FlexibleCard/index.js +14 -1
  54. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
  55. package/dist/esm/view/LinkUrl/index.js +1 -1
  56. package/dist/types/extractors/common/__mocks__/jsonld.d.ts +0 -1
  57. package/dist/types/extractors/common/actions/extractActions.d.ts +1 -1
  58. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +6 -5
  59. package/dist/types/state/flexible-ui-context/index.d.ts +3 -119
  60. package/dist/types/state/flexible-ui-context/types.d.ts +6 -0
  61. package/dist/types/state/hooks/use-invoke/utils.d.ts +4 -0
  62. package/dist/types/state/hooks/useSmartLink.d.ts +4 -3
  63. package/dist/types/utils/analytics/analytics.d.ts +4 -1
  64. package/dist/types/utils/analytics/types.d.ts +7 -3
  65. package/dist/types/utils/mocks.d.ts +4 -3
  66. package/dist/types/view/Card/index.d.ts +1 -1
  67. package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -63
  68. package/dist/types/view/FlexibleCard/types.d.ts +2 -3
  69. package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +0 -1
  70. package/dist/types-ts4.5/extractors/common/actions/extractActions.d.ts +1 -1
  71. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +6 -5
  72. package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +3 -119
  73. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +6 -0
  74. package/dist/types-ts4.5/state/hooks/use-invoke/utils.d.ts +4 -0
  75. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +4 -3
  76. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +4 -1
  77. package/dist/types-ts4.5/utils/analytics/types.d.ts +7 -3
  78. package/dist/types-ts4.5/utils/mocks.d.ts +4 -3
  79. package/dist/types-ts4.5/view/Card/index.d.ts +1 -1
  80. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +2 -63
  81. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -3
  82. package/package.json +2 -2
  83. package/report.api.md +14 -6
  84. package/tmp/api-report-tmp.d.ts +12 -6
@@ -1,19 +1,21 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  var _excluded = ["smartLinkActionType"],
6
6
  _excluded2 = ["smartLinkActionType"],
7
7
  _excluded3 = ["smartLinkActionType"],
8
8
  _excluded4 = ["display"];
9
+ var _SmartLinkActionTypeT, _SmartLinkActionTypeU;
9
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
12
  import { getMeasure } from '../performance';
13
+ import { SmartLinkActionType } from '@atlaskit/linking-types';
12
14
  export var ANALYTICS_CHANNEL = 'media';
13
15
  export var context = {
14
16
  componentName: 'smart-cards',
15
17
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "26.24.0"
18
+ packageVersion: "26.26.0"
17
19
  };
18
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
19
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -25,6 +27,8 @@ export var TrackQuickActionFailureReason = /*#__PURE__*/function (TrackQuickActi
25
27
  TrackQuickActionFailureReason["UnknownError"] = "UnknownError";
26
28
  return TrackQuickActionFailureReason;
27
29
  }({});
30
+ export var SmartLinkActionTypeTrackingEventMapper = (_SmartLinkActionTypeT = {}, _defineProperty(_SmartLinkActionTypeT, SmartLinkActionType.FollowEntityAction, 'Follow'), _defineProperty(_SmartLinkActionTypeT, SmartLinkActionType.StatusUpdateAction, 'StatusUpdate'), _defineProperty(_SmartLinkActionTypeT, SmartLinkActionType.UnfollowEntityAction, 'Unfollow'), _SmartLinkActionTypeT);
31
+ export var SmartLinkActionTypeUiEventMapper = (_SmartLinkActionTypeU = {}, _defineProperty(_SmartLinkActionTypeU, SmartLinkActionType.FollowEntityAction, 'smartLinkFollowButton'), _defineProperty(_SmartLinkActionTypeU, SmartLinkActionType.UnfollowEntityAction, 'smartLinkFollowButton'), _SmartLinkActionTypeU);
28
32
  var uiActionSubjectIds = {
29
33
  DownloadAction: 'downloadDocument',
30
34
  PreviewAction: 'invokePreviewScreen',
@@ -234,6 +238,7 @@ export var trackAppAccountAuthStarted = function trackAppAccountAuthStarted(_ref
234
238
  };
235
239
  };
236
240
  export var trackSmartLinkQuickActionStarted = function trackSmartLinkQuickActionStarted(_ref8) {
241
+ var _SmartLinkActionTypeT2;
237
242
  var smartLinkActionType = _ref8.smartLinkActionType,
238
243
  attributes = _objectWithoutProperties(_ref8, _excluded);
239
244
  return {
@@ -241,11 +246,12 @@ export var trackSmartLinkQuickActionStarted = function trackSmartLinkQuickAction
241
246
  actionSubject: 'smartLinkQuickAction',
242
247
  eventType: 'track',
243
248
  attributes: _objectSpread(_objectSpread(_objectSpread({}, context), attributes), {}, {
244
- smartLinkActionType: smartLinkActionType
249
+ smartLinkActionType: (_SmartLinkActionTypeT2 = SmartLinkActionTypeTrackingEventMapper[smartLinkActionType]) !== null && _SmartLinkActionTypeT2 !== void 0 ? _SmartLinkActionTypeT2 : smartLinkActionType
245
250
  })
246
251
  };
247
252
  };
248
253
  export var trackSmartLinkQuickActionSuccess = function trackSmartLinkQuickActionSuccess(_ref9) {
254
+ var _SmartLinkActionTypeT3;
249
255
  var smartLinkActionType = _ref9.smartLinkActionType,
250
256
  attributes = _objectWithoutProperties(_ref9, _excluded2);
251
257
  return {
@@ -253,11 +259,12 @@ export var trackSmartLinkQuickActionSuccess = function trackSmartLinkQuickAction
253
259
  actionSubject: 'smartLinkQuickAction',
254
260
  eventType: 'track',
255
261
  attributes: _objectSpread(_objectSpread(_objectSpread({}, context), attributes), {}, {
256
- smartLinkActionType: smartLinkActionType
262
+ smartLinkActionType: (_SmartLinkActionTypeT3 = SmartLinkActionTypeTrackingEventMapper[smartLinkActionType]) !== null && _SmartLinkActionTypeT3 !== void 0 ? _SmartLinkActionTypeT3 : smartLinkActionType
257
263
  })
258
264
  };
259
265
  };
260
266
  export var trackSmartLinkQuickActionFailed = function trackSmartLinkQuickActionFailed(_ref10) {
267
+ var _SmartLinkActionTypeT4;
261
268
  var smartLinkActionType = _ref10.smartLinkActionType,
262
269
  attributes = _objectWithoutProperties(_ref10, _excluded3);
263
270
  return {
@@ -265,7 +272,7 @@ export var trackSmartLinkQuickActionFailed = function trackSmartLinkQuickActionF
265
272
  actionSubject: 'smartLinkQuickAction',
266
273
  eventType: 'track',
267
274
  attributes: _objectSpread(_objectSpread(_objectSpread({}, context), attributes), {}, {
268
- smartLinkActionType: smartLinkActionType
275
+ smartLinkActionType: (_SmartLinkActionTypeT4 = SmartLinkActionTypeTrackingEventMapper[smartLinkActionType]) !== null && _SmartLinkActionTypeT4 !== void 0 ? _SmartLinkActionTypeT4 : smartLinkActionType
269
276
  })
270
277
  };
271
278
  };
@@ -663,4 +670,15 @@ export var uiSmartLinkStatusOpenPreviewButtonClicked = function uiSmartLinkStatu
663
670
  eventType: 'ui',
664
671
  attributes: _objectSpread({}, context)
665
672
  };
673
+ };
674
+ export var uiServerActionClicked = function uiServerActionClicked(_ref26) {
675
+ var _SmartLinkActionTypeU2;
676
+ var smartLinkActionType = _ref26.smartLinkActionType;
677
+ return {
678
+ action: 'clicked',
679
+ actionSubject: 'button',
680
+ actionSubjectId: (_SmartLinkActionTypeU2 = SmartLinkActionTypeUiEventMapper[smartLinkActionType]) !== null && _SmartLinkActionTypeU2 !== void 0 ? _SmartLinkActionTypeU2 : smartLinkActionType,
681
+ eventType: 'ui',
682
+ attributes: _objectSpread({}, context)
683
+ };
666
684
  };
@@ -295,13 +295,18 @@ export var mockAnalytics = {
295
295
  buttonClickedEvent: function buttonClickedEvent() {},
296
296
  modalClosedEvent: function modalClosedEvent() {},
297
297
  renderSuccessEvent: function renderSuccessEvent() {},
298
- renderFailedEvent: function renderFailedEvent() {}
298
+ renderFailedEvent: function renderFailedEvent() {},
299
+ smartLinkServerActionClickedEvent: function smartLinkServerActionClickedEvent() {}
299
300
  },
300
301
  operational: {
301
302
  invokeSucceededEvent: function invokeSucceededEvent() {},
302
303
  invokeFailedEvent: function invokeFailedEvent() {}
303
304
  },
304
- track: {},
305
+ track: {
306
+ smartLinkQuickActionFailed: function smartLinkQuickActionFailed() {},
307
+ smartLinkQuickActionStarted: function smartLinkQuickActionStarted() {},
308
+ smartLinkQuickActionSuccess: function smartLinkQuickActionSuccess() {}
309
+ },
305
310
  screen: {
306
311
  modalViewedEvent: function modalViewedEvent() {}
307
312
  }
@@ -32,6 +32,7 @@ var FlexibleErroredView = function FlexibleErroredView(_ref) {
32
32
  return onAuthorize ? [RetryAction(onAuthorize)] : [];
33
33
  }, [onAuthorize]);
34
34
  return /*#__PURE__*/React.createElement(FlexibleCard, {
35
+ appearance: "block",
35
36
  cardState: cardState,
36
37
  onAuthorize: onAuthorize,
37
38
  onClick: onClick,
@@ -5,8 +5,7 @@ import FlexibleCard from '../../../FlexibleCard';
5
5
  import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
6
6
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
7
7
  import { metadataBlockCss, footerBlockCss } from './styled';
8
- import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
9
- import uuid from 'uuid';
8
+ import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
10
9
  import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
11
10
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
11
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
@@ -36,11 +35,6 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
36
35
  useEffect(function () {
37
36
  setIsPreviewBlockErrored(false);
38
37
  }, [url, cardState]);
39
- var _useState3 = useState(function () {
40
- return id ? id : uuid();
41
- }),
42
- _useState4 = _slicedToArray(_useState3, 1),
43
- analyticsId = _useState4[0];
44
38
  var _ref2 = getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? getSimulatedBetterMetadata(cardState.details) : getSimulatedMetadata(cardState.details),
45
39
  titleMetadata = _ref2.titleMetadata,
46
40
  topMetadata = _ref2.topMetadata,
@@ -87,49 +81,13 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
87
81
  }, {
88
82
  actions: [{
89
83
  name: ActionName.PreviewAction,
90
- hideIcon: true,
91
- onClick: function onClick() {
92
- analytics.ui.actionClickedEvent({
93
- id: analyticsId,
94
- actionType: 'PreviewAction',
95
- display: CardDisplay.Block
96
- });
97
- analytics.operational.invokeSucceededEvent({
98
- id: analyticsId,
99
- actionType: 'PreviewAction',
100
- display: CardDisplay.Block
101
- });
102
- }
84
+ hideIcon: true
103
85
  }, {
104
86
  name: ActionName.ViewAction,
105
- hideIcon: true,
106
- onClick: function onClick() {
107
- analytics.ui.actionClickedEvent({
108
- id: analyticsId,
109
- actionType: 'ViewAction',
110
- display: CardDisplay.Block
111
- });
112
- analytics.operational.invokeSucceededEvent({
113
- id: analyticsId,
114
- actionType: 'ViewAction',
115
- display: CardDisplay.Block
116
- });
117
- }
87
+ hideIcon: true
118
88
  }, {
119
89
  name: ActionName.DownloadAction,
120
- hideIcon: true,
121
- onClick: function onClick() {
122
- analytics.ui.actionClickedEvent({
123
- id: analyticsId,
124
- actionType: 'DownloadAction',
125
- display: CardDisplay.Block
126
- });
127
- analytics.operational.invokeSucceededEvent({
128
- id: analyticsId,
129
- actionType: 'DownloadAction',
130
- display: CardDisplay.Block
131
- });
132
- }
90
+ hideIcon: true
133
91
  }]
134
92
  })));
135
93
  };
@@ -1,10 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
7
  import React from 'react';
6
8
  import Action from '../index';
7
9
  import { downloadUrl as download } from '../../../../../../utils';
10
+ import { ActionName } from '../../../../../../constants';
11
+ import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
12
+ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
8
13
  var DownloadAction = function DownloadAction(props) {
9
14
  var appearance = props.appearance,
10
15
  asDropDownItem = props.asDropDownItem,
@@ -12,10 +17,37 @@ var DownloadAction = function DownloadAction(props) {
12
17
  _onClick = props.onClick,
13
18
  testId = props.testId,
14
19
  url = props.url;
20
+ var analytics = useFlexibleUiAnalyticsContext();
21
+ var invoke = useInvokeClientAction({
22
+ analytics: analytics
23
+ });
15
24
  if (downloadUrl && url) {
16
25
  var action = _objectSpread(_objectSpread({}, props), {}, {
17
26
  onClick: function onClick() {
18
- download(downloadUrl);
27
+ invoke({
28
+ actionType: ActionName.DownloadAction,
29
+ actionFn: function () {
30
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
32
+ while (1) switch (_context.prev = _context.next) {
33
+ case 0:
34
+ return _context.abrupt("return", download(downloadUrl));
35
+ case 1:
36
+ case "end":
37
+ return _context.stop();
38
+ }
39
+ }, _callee);
40
+ }));
41
+ function actionFn() {
42
+ return _actionFn.apply(this, arguments);
43
+ }
44
+ return actionFn;
45
+ }(),
46
+ // These values have already been set in analytics context.
47
+ // We only pass these here for ufo experience.
48
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
49
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
50
+ });
19
51
  if (_onClick) {
20
52
  _onClick();
21
53
  }
@@ -1,14 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
7
  import React from 'react';
6
8
  import Action from '../index';
7
9
  import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
8
- import { useSmartLinkAnalytics } from '../../../../../../state';
9
10
  import { FormattedMessage } from 'react-intl-next';
10
11
  import { messages } from '../../../../../../messages';
11
12
  import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
13
+ import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
14
+ import { ActionName } from '../../../../../../constants';
12
15
  var PreviewAction = function PreviewAction(props) {
13
16
  var appearance = props.appearance,
14
17
  asDropDownItem = props.asDropDownItem,
@@ -21,23 +24,46 @@ var PreviewAction = function PreviewAction(props) {
21
24
  providerName = props.providerName,
22
25
  downloadUrl = props.downloadUrl,
23
26
  isSupportTheming = props.isSupportTheming;
24
- var defaultAnalytics = useSmartLinkAnalytics(url, function () {});
25
- var analytics = useFlexibleUiAnalyticsContext() || defaultAnalytics;
27
+ var analytics = useFlexibleUiAnalyticsContext();
28
+ var invoke = useInvokeClientAction({
29
+ analytics: analytics
30
+ });
26
31
  if (src && url) {
27
- var embedModal = function embedModal() {
28
- return openEmbedModalWithFlexibleUiIcon({
29
- title: title,
30
- providerName: providerName,
31
- downloadUrl: downloadUrl,
32
- isSupportTheming: isSupportTheming,
33
- analytics: analytics,
34
- linkIcon: linkIcon,
35
- src: src
36
- });
37
- };
32
+ var actionFn = /*#__PURE__*/function () {
33
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
34
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon({
38
+ download: downloadUrl,
39
+ title: title,
40
+ providerName: providerName,
41
+ isSupportTheming: isSupportTheming,
42
+ analytics: analytics,
43
+ linkIcon: linkIcon,
44
+ src: src,
45
+ url: url
46
+ }));
47
+ case 1:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }, _callee);
52
+ }));
53
+ return function actionFn() {
54
+ return _ref.apply(this, arguments);
55
+ };
56
+ }();
38
57
  var action = _objectSpread(_objectSpread({}, props), {}, {
39
58
  onClick: function onClick() {
40
- embedModal();
59
+ invoke({
60
+ actionType: ActionName.PreviewAction,
61
+ actionFn: actionFn,
62
+ // These values have already been set in analytics context.
63
+ // We only pass these here for ufo experience.
64
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
65
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
66
+ });
41
67
  if (_onClick) {
42
68
  _onClick();
43
69
  }
@@ -6,9 +6,11 @@ var _excluded = ["action", "onClick"];
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useCallback, useState } from 'react';
8
8
  import useInvoke from '../../../../../../state/hooks/use-invoke';
9
+ import { getInvokeFailureReason } from '../../../../../../state/hooks/use-invoke/utils';
9
10
  import useResolve from '../../../../../../state/hooks/use-resolve';
10
11
  import createInvokeRequest from '../../../../../../utils/actions/create-invoke-request';
11
12
  import Action from '../index';
13
+ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
12
14
  var ServerAction = function ServerAction(_ref) {
13
15
  var action = _ref.action,
14
16
  onClick = _ref.onClick,
@@ -17,46 +19,61 @@ var ServerAction = function ServerAction(_ref) {
17
19
  _useState2 = _slicedToArray(_useState, 2),
18
20
  isLoading = _useState2[0],
19
21
  setIsLoading = _useState2[1];
22
+ var analytics = useFlexibleUiAnalyticsContext();
20
23
  var invoke = useInvoke();
21
24
  var reload = useResolve();
22
25
  var handleClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
23
- var request;
26
+ var _action$action, smartLinkActionType, request;
24
27
  return _regeneratorRuntime.wrap(function _callee$(_context) {
25
28
  while (1) switch (_context.prev = _context.next) {
26
29
  case 0:
27
30
  if (!action) {
28
- _context.next = 16;
31
+ _context.next = 21;
29
32
  break;
30
33
  }
31
- _context.prev = 1;
34
+ smartLinkActionType = (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.actionType;
35
+ _context.prev = 2;
32
36
  setIsLoading(true);
37
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkServerActionClickedEvent({
38
+ smartLinkActionType: smartLinkActionType
39
+ });
40
+ analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionStarted({
41
+ smartLinkActionType: smartLinkActionType
42
+ });
33
43
  request = createInvokeRequest(action);
34
- _context.next = 6;
44
+ _context.next = 9;
35
45
  return invoke(request);
36
- case 6:
46
+ case 9:
47
+ analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionSuccess({
48
+ smartLinkActionType: smartLinkActionType
49
+ });
37
50
  if (!(action.reload && action.reload.url)) {
38
- _context.next = 9;
51
+ _context.next = 13;
39
52
  break;
40
53
  }
41
- _context.next = 9;
54
+ _context.next = 13;
42
55
  return reload(action.reload.url, true, undefined, action.reload.id);
43
- case 9:
56
+ case 13:
44
57
  setIsLoading(false);
45
58
  if (onClick) {
46
59
  onClick();
47
60
  }
48
- _context.next = 16;
61
+ _context.next = 21;
49
62
  break;
50
- case 13:
51
- _context.prev = 13;
52
- _context.t0 = _context["catch"](1);
63
+ case 17:
64
+ _context.prev = 17;
65
+ _context.t0 = _context["catch"](2);
53
66
  setIsLoading(false);
54
- case 16:
67
+ analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionFailed({
68
+ smartLinkActionType: smartLinkActionType,
69
+ reason: getInvokeFailureReason(_context.t0)
70
+ });
71
+ case 21:
55
72
  case "end":
56
73
  return _context.stop();
57
74
  }
58
- }, _callee, null, [[1, 13]]);
59
- })), [action, invoke, onClick, reload]);
75
+ }, _callee, null, [[2, 17]]);
76
+ })), [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, reload]);
60
77
  return /*#__PURE__*/React.createElement(Action, _extends({}, props, {
61
78
  isLoading: isLoading,
62
79
  onClick: handleClick
@@ -1,10 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
7
  import React from 'react';
6
8
  import Action from '../index';
7
9
  import { openUrl } from '../../../../../../utils';
10
+ import { ActionName } from '../../../../../../constants';
11
+ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
12
+ import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
8
13
  var ViewAction = function ViewAction(props) {
9
14
  var appearance = props.appearance,
10
15
  asDropDownItem = props.asDropDownItem,
@@ -12,10 +17,37 @@ var ViewAction = function ViewAction(props) {
12
17
  _onClick = props.onClick,
13
18
  viewUrl = props.viewUrl,
14
19
  url = props.url;
20
+ var analytics = useFlexibleUiAnalyticsContext();
21
+ var invoke = useInvokeClientAction({
22
+ analytics: analytics
23
+ });
15
24
  if (viewUrl && url) {
16
25
  var action = _objectSpread(_objectSpread({}, props), {}, {
17
26
  onClick: function onClick() {
18
- openUrl(viewUrl);
27
+ invoke({
28
+ actionType: ActionName.ViewAction,
29
+ actionFn: function () {
30
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
32
+ while (1) switch (_context.prev = _context.next) {
33
+ case 0:
34
+ return _context.abrupt("return", openUrl(viewUrl));
35
+ case 1:
36
+ case "end":
37
+ return _context.stop();
38
+ }
39
+ }, _callee);
40
+ }));
41
+ function actionFn() {
42
+ return _actionFn.apply(this, arguments);
43
+ }
44
+ return actionFn;
45
+ }(),
46
+ // These values have already been set in analytics context.
47
+ // We only pass these here for ufo experience.
48
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
49
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
50
+ });
19
51
  if (_onClick) {
20
52
  _onClick();
21
53
  }
@@ -16,6 +16,7 @@ import extractLozengeActionItems from '../../../../../../extractors/action/extra
16
16
  import createStatusUpdateRequest from '../../../../../../utils/actions/create-status-update-request';
17
17
  import useResolve from '../../../../../../state/hooks/use-resolve';
18
18
  import { LozengeActionErrorMessages } from './lozenge-action-error/types';
19
+ import { isInvokeCustomError } from '../../../../../../state/hooks/use-invoke/utils';
19
20
  import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
20
21
  import { TrackQuickActionType } from '../../../../../../utils/analytics/analytics';
21
22
  import { permissionLoadErrorAnalyticsPayload, unknownLoadErrorAnalyticsPayload, unknownUpdateErrorAnalyticsPayload, validationUpdateErrorAnalyticsPayload } from './lozenge-action-analytics';
@@ -26,9 +27,6 @@ var validateItems = function validateItems() {
26
27
  return item.text !== text;
27
28
  });
28
29
  };
29
- var isInvokeCustomError = function isInvokeCustomError(err) {
30
- return err.message !== undefined && err.errorCode !== undefined;
31
- };
32
30
  var LozengeAction = function LozengeAction(_ref) {
33
31
  var _action$update;
34
32
  var action = _ref.action,
@@ -1,7 +1,11 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
  import _extends from "@babel/runtime/helpers/extends";
3
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ var _excluded = ["linkIcon"];
4
6
  var _sizeToButtonSpacing, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
9
  import React from 'react';
6
10
  import { css } from '@emotion/react';
7
11
  import { FormattedMessage } from 'react-intl-next';
@@ -98,34 +102,19 @@ export var hasWhiteSpace = function hasWhiteSpace(str) {
98
102
  return str.search(/\s/) >= 0;
99
103
  };
100
104
  export var openEmbedModalWithFlexibleUiIcon = function openEmbedModalWithFlexibleUiIcon(_ref) {
101
- var analytics = _ref.analytics,
102
- downloadUrl = _ref.downloadUrl,
103
- linkIcon = _ref.linkIcon,
104
- onClose = _ref.onClose,
105
- providerName = _ref.providerName,
106
- src = _ref.src,
107
- title = _ref.title,
108
- url = _ref.url,
109
- isSupportTheming = _ref.isSupportTheming;
105
+ var linkIcon = _ref.linkIcon,
106
+ props = _objectWithoutProperties(_ref, _excluded);
110
107
  var icon = {
111
108
  icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
112
109
  size: SmartLinkSize.Large
113
110
  })),
114
111
  isFlexibleUi: true
115
112
  };
116
- return openEmbedModal({
117
- analytics: analytics,
118
- download: downloadUrl,
113
+ return openEmbedModal(_objectSpread(_objectSpread({}, props), {}, {
119
114
  icon: icon,
120
115
  // Flex should not send origin as block card. It should be able to support
121
116
  // its internal parent components like hover card, block card and
122
117
  // itself as a standalone. To be investigated and fix in EDM-7520.
123
- origin: 'smartLinkCard',
124
- providerName: providerName,
125
- onClose: onClose,
126
- src: src,
127
- title: title,
128
- url: url,
129
- isSupportTheming: isSupportTheming
130
- });
118
+ origin: 'smartLinkCard'
119
+ }));
131
120
  };
@@ -1,4 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
5
  import React, { useEffect, useMemo } from 'react';
3
6
  import { SmartLinkStatus } from '../../constants';
4
7
  import Container from './components/container';
@@ -12,7 +15,10 @@ import { getContextByStatus, getRetryOptions } from './utils';
12
15
  * @see Container
13
16
  */
14
17
  var FlexibleCard = function FlexibleCard(_ref) {
18
+ var _details$meta2;
15
19
  var analytics = _ref.analytics,
20
+ _ref$appearance = _ref.appearance,
21
+ appearance = _ref$appearance === void 0 ? 'flexible' : _ref$appearance,
16
22
  cardState = _ref.cardState,
17
23
  children = _ref.children,
18
24
  id = _ref.id,
@@ -43,6 +49,13 @@ var FlexibleCard = function FlexibleCard(_ref) {
43
49
  var retry = getRetryOptions(url, status, details, onAuthorize);
44
50
  var _ref2 = context || {},
45
51
  title = _ref2.title;
52
+ var analyticsContext = useMemo(function () {
53
+ var _details$meta;
54
+ return analytics ? _objectSpread(_objectSpread({}, analytics), {}, {
55
+ display: appearance,
56
+ extensionKey: details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.key
57
+ }) : undefined;
58
+ }, [analytics, appearance, details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key]);
46
59
  useEffect(function () {
47
60
  switch (status) {
48
61
  case SmartLinkStatus.Resolved:
@@ -68,7 +81,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
68
81
  }
69
82
  }, [onError, onResolve, status, title, url]);
70
83
  return /*#__PURE__*/React.createElement(FlexibleUiAnalyticsContext.Provider, {
71
- value: analytics
84
+ value: analyticsContext
72
85
  }, /*#__PURE__*/React.createElement(FlexibleUiOptionContext.Provider, {
73
86
  value: ui
74
87
  }, /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
@@ -137,6 +137,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
137
137
  subtitle: subtitle
138
138
  };
139
139
  var flexibleCardProps = {
140
+ appearance: CardDisplay.HoverCardPreview,
140
141
  cardState: cardState,
141
142
  onClick: onClick,
142
143
  onResolve: onResolve,
@@ -11,7 +11,7 @@ import LinkWarningModal from './LinkWarningModal';
11
11
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
12
  var PACKAGE_DATA = {
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "26.24.0",
14
+ packageVersion: "26.26.0",
15
15
  componentName: 'linkUrl'
16
16
  };
17
17
  var Link = withLinkClickedEvent('a');
@@ -27,7 +27,6 @@ export declare const TEST_CURRENT_DOCUMENT: JsonLd.Data.Document;
27
27
  export declare const TEST_DOWNLOAD_ACTION: JsonLd.Data.BaseData['schema:potentialAction'];
28
28
  export declare const TEST_UNDEFINED_LINK: JsonLd.Data.UndefinedLinkDocument;
29
29
  export declare const TEST_ASSIGN_ACTION: JsonLd.Data.BaseData['schema:potentialAction'];
30
- export declare const TEST_NO_ID_ACTION: JsonLd.Data.BaseData['schema:potentialAction'];
31
30
  export declare const TEST_VIEW_ACTION: JsonLd.Data.BaseData['schema:potentialAction'];
32
31
  export declare const TEST_FOLLOW_ACTION: JsonLd.Primitives.UpdateAction;
33
32
  export declare const TEST_UNFOLLOW_ACTION: JsonLd.Primitives.UpdateAction;
@@ -2,4 +2,4 @@ import { JsonLd } from 'json-ld-types';
2
2
  import { InvokeHandler } from '../../../model/invoke-handler';
3
3
  import { ActionProps } from '../../../view/BlockCard/components/Action';
4
4
  export declare const getActionsFromJsonLd: (jsonLd: JsonLd.Data.BaseData) => JsonLd.Primitives.Action[];
5
- export declare function extractActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler): ActionProps[];
5
+ export declare function extractClientActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler): ActionProps[];