@atlaskit/smart-card 32.7.0 → 32.7.1

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 (160) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/analytics.spec.yaml +63 -9
  3. package/dist/cjs/common/analytics/types.js +5 -0
  4. package/dist/cjs/extractors/action/extract-invoke-copy-link-action.js +53 -0
  5. package/dist/cjs/extractors/action/extract-invoke-download-action.js +57 -0
  6. package/dist/cjs/extractors/action/extract-invoke-preview-action.js +78 -0
  7. package/dist/cjs/extractors/action/extract-invoke-view-action.js +60 -0
  8. package/dist/cjs/extractors/action/extractDownloadActionProps.js +4 -0
  9. package/dist/cjs/extractors/action/extractPreviewActionProps.js +4 -0
  10. package/dist/cjs/extractors/action/extractViewActionProps.js +4 -0
  11. package/dist/cjs/extractors/action/types.js +5 -0
  12. package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +12 -1
  13. package/dist/cjs/extractors/flexible/actions/extract-download-action.js +12 -1
  14. package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +12 -1
  15. package/dist/cjs/extractors/flexible/actions/extract-view-action.js +3 -0
  16. package/dist/cjs/extractors/flexible/actions/index.js +40 -3
  17. package/dist/cjs/extractors/flexible/extract-state.js +19 -5
  18. package/dist/cjs/extractors/flexible/index.js +22 -8
  19. package/dist/cjs/state/hooks/use-invoke-client-action/index.js +56 -17
  20. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +22 -3
  21. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +7 -2
  22. package/dist/cjs/utils/analytics/analytics.js +1 -1
  23. package/dist/cjs/utils/mocks.js +4 -1
  24. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  25. package/dist/cjs/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  26. package/dist/cjs/view/CardWithUrl/component.js +1 -0
  27. package/dist/cjs/view/EmbedModal/index.js +72 -51
  28. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  29. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  30. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  31. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  32. package/dist/cjs/view/FlexibleCard/components/utils.js +4 -0
  33. package/dist/cjs/view/FlexibleCard/index.js +11 -1
  34. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
  35. package/dist/cjs/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/common/analytics/types.js +1 -0
  37. package/dist/es2019/extractors/action/extract-invoke-copy-link-action.js +29 -0
  38. package/dist/es2019/extractors/action/extract-invoke-download-action.js +31 -0
  39. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +57 -0
  40. package/dist/es2019/extractors/action/extract-invoke-view-action.js +34 -0
  41. package/dist/es2019/extractors/action/extractDownloadActionProps.js +5 -0
  42. package/dist/es2019/extractors/action/extractPreviewActionProps.js +5 -0
  43. package/dist/es2019/extractors/action/extractViewActionProps.js +5 -0
  44. package/dist/es2019/extractors/action/types.js +1 -0
  45. package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  46. package/dist/es2019/extractors/flexible/actions/extract-download-action.js +12 -0
  47. package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +12 -0
  48. package/dist/es2019/extractors/flexible/actions/extract-view-action.js +4 -0
  49. package/dist/es2019/extractors/flexible/actions/index.js +48 -3
  50. package/dist/es2019/extractors/flexible/extract-state.js +17 -5
  51. package/dist/es2019/extractors/flexible/index.js +17 -6
  52. package/dist/es2019/state/hooks/use-invoke-client-action/index.js +91 -43
  53. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +21 -3
  54. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +3 -0
  55. package/dist/es2019/utils/analytics/analytics.js +1 -1
  56. package/dist/es2019/utils/mocks.js +4 -1
  57. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  58. package/dist/es2019/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  59. package/dist/es2019/view/CardWithUrl/component.js +1 -0
  60. package/dist/es2019/view/EmbedModal/index.js +41 -20
  61. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +31 -16
  62. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +20 -12
  63. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +25 -17
  64. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +14 -7
  65. package/dist/es2019/view/FlexibleCard/components/utils.js +4 -0
  66. package/dist/es2019/view/FlexibleCard/index.js +12 -1
  67. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
  68. package/dist/es2019/view/LinkUrl/index.js +1 -1
  69. package/dist/esm/common/analytics/types.js +1 -0
  70. package/dist/esm/extractors/action/extract-invoke-copy-link-action.js +46 -0
  71. package/dist/esm/extractors/action/extract-invoke-download-action.js +50 -0
  72. package/dist/esm/extractors/action/extract-invoke-preview-action.js +71 -0
  73. package/dist/esm/extractors/action/extract-invoke-view-action.js +53 -0
  74. package/dist/esm/extractors/action/extractDownloadActionProps.js +5 -0
  75. package/dist/esm/extractors/action/extractPreviewActionProps.js +5 -0
  76. package/dist/esm/extractors/action/extractViewActionProps.js +5 -0
  77. package/dist/esm/extractors/action/types.js +1 -0
  78. package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  79. package/dist/esm/extractors/flexible/actions/extract-download-action.js +12 -0
  80. package/dist/esm/extractors/flexible/actions/extract-preview-action.js +12 -0
  81. package/dist/esm/extractors/flexible/actions/extract-view-action.js +4 -0
  82. package/dist/esm/extractors/flexible/actions/index.js +42 -5
  83. package/dist/esm/extractors/flexible/extract-state.js +19 -5
  84. package/dist/esm/extractors/flexible/index.js +19 -8
  85. package/dist/esm/state/hooks/use-invoke-client-action/index.js +56 -17
  86. package/dist/esm/state/hooks-external/useSmartLinkActions.js +22 -3
  87. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +7 -2
  88. package/dist/esm/utils/analytics/analytics.js +1 -1
  89. package/dist/esm/utils/mocks.js +4 -1
  90. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  91. package/dist/esm/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  92. package/dist/esm/view/CardWithUrl/component.js +1 -0
  93. package/dist/esm/view/EmbedModal/index.js +73 -52
  94. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  95. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  96. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  97. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  98. package/dist/esm/view/FlexibleCard/components/utils.js +4 -0
  99. package/dist/esm/view/FlexibleCard/index.js +11 -1
  100. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
  101. package/dist/esm/view/LinkUrl/index.js +1 -1
  102. package/dist/types/common/analytics/generated/analytics.types.d.ts +63 -2
  103. package/dist/types/common/analytics/types.d.ts +2 -0
  104. package/dist/types/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  105. package/dist/types/extractors/action/extract-invoke-download-action.d.ts +3 -0
  106. package/dist/types/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  107. package/dist/types/extractors/action/extract-invoke-view-action.d.ts +3 -0
  108. package/dist/types/extractors/action/extractDownloadActionProps.d.ts +4 -0
  109. package/dist/types/extractors/action/extractPreviewActionProps.d.ts +5 -1
  110. package/dist/types/extractors/action/extractViewActionProps.d.ts +4 -0
  111. package/dist/types/extractors/action/types.d.ts +9 -0
  112. package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  113. package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  114. package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  115. package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  116. package/dist/types/extractors/flexible/actions/index.d.ts +21 -4
  117. package/dist/types/extractors/flexible/extract-state.d.ts +5 -2
  118. package/dist/types/extractors/flexible/index.d.ts +1 -1
  119. package/dist/types/state/flexible-ui-context/types.d.ts +9 -3
  120. package/dist/types/state/hooks/use-invoke/types.d.ts +7 -1
  121. package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  122. package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  123. package/dist/types/state/hooks/use-resolve/index.d.ts +1 -0
  124. package/dist/types/view/EmbedModal/index.d.ts +4 -0
  125. package/dist/types/view/EmbedModal/types.d.ts +7 -0
  126. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  127. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  128. package/dist/types/view/FlexibleCard/components/utils.d.ts +3 -0
  129. package/dist/types/view/FlexibleCard/index.d.ts +1 -1
  130. package/dist/types/view/FlexibleCard/types.d.ts +12 -3
  131. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +63 -2
  132. package/dist/types-ts4.5/common/analytics/types.d.ts +2 -0
  133. package/dist/types-ts4.5/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  134. package/dist/types-ts4.5/extractors/action/extract-invoke-download-action.d.ts +3 -0
  135. package/dist/types-ts4.5/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  136. package/dist/types-ts4.5/extractors/action/extract-invoke-view-action.d.ts +3 -0
  137. package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +4 -0
  138. package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +5 -1
  139. package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +4 -0
  140. package/dist/types-ts4.5/extractors/action/types.d.ts +9 -0
  141. package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  142. package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  143. package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  144. package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  145. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +21 -4
  146. package/dist/types-ts4.5/extractors/flexible/extract-state.d.ts +5 -2
  147. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  148. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +9 -3
  149. package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +7 -1
  150. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  151. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  152. package/dist/types-ts4.5/state/hooks/use-resolve/index.d.ts +1 -0
  153. package/dist/types-ts4.5/view/EmbedModal/index.d.ts +8 -0
  154. package/dist/types-ts4.5/view/EmbedModal/types.d.ts +7 -0
  155. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  156. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  157. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +3 -0
  158. package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +1 -1
  159. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +12 -3
  160. package/package.json +4 -1
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
10
  var _linkExtractors = require("@atlaskit/link-extractors");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
12
  var _primitives = require("../common/primitives");
11
- var _actions = _interopRequireDefault(require("./actions"));
12
- var _extractViewAction = require("./actions/extract-view-action");
13
+ var _actions = _interopRequireWildcard(require("./actions"));
13
14
  var _collaboratorGroup = require("./collaboratorGroup");
14
15
  var _extractPreview = _interopRequireDefault(require("./extract-preview"));
15
16
  var _extractPriority = _interopRequireDefault(require("./extract-priority"));
@@ -18,11 +19,17 @@ var _icon = require("./icon");
18
19
  var _extractProviderIcon = _interopRequireDefault(require("./icon/extract-provider-icon"));
19
20
  var _latestCommit = require("./latest-commit");
20
21
  var _utils = require("./utils");
21
- var _excluded = ["id", "renderers", "actionOptions", "response", "aiSummaryConfig"];
22
+ var _excluded = ["appearance", "fireEvent", "id", "origin", "renderers", "resolve", "actionOptions", "response", "aiSummaryConfig"];
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
25
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
23
26
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
- var id = _ref.id,
27
+ var appearance = _ref.appearance,
28
+ fireEvent = _ref.fireEvent,
29
+ id = _ref.id,
30
+ origin = _ref.origin,
25
31
  renderers = _ref.renderers,
32
+ resolve = _ref.resolve,
26
33
  actionOptions = _ref.actionOptions,
27
34
  response = _ref.response,
28
35
  aiSummaryConfig = _ref.aiSummaryConfig,
@@ -33,8 +40,16 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
33
40
  var data = response.data;
34
41
  var url = (0, _linkExtractors.extractLink)(data);
35
42
  return {
36
- // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
37
- actions: (0, _actions.default)(response, props.url, actionOptions, id, aiSummaryConfig),
43
+ actions: (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? (0, _actions.extractFlexibleCardActions)({
44
+ actionOptions: actionOptions,
45
+ aiSummaryConfig: aiSummaryConfig,
46
+ appearance: appearance,
47
+ fireEvent: fireEvent,
48
+ id: id,
49
+ origin: origin,
50
+ response: response,
51
+ url: props.url // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
52
+ }) : (0, _actions.default)(response, props.url, actionOptions, id, aiSummaryConfig),
38
53
  assignedToGroup: (0, _utils.extractPersonAssignedToAsArray)(data),
39
54
  attachmentCount: (0, _utils.extractAttachmentCount)(data),
40
55
  authorGroup: (0, _linkExtractors.extractPersonCreatedBy)(data),
@@ -50,7 +65,6 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
50
65
  assignedTo: (0, _utils.extractAssignedTo)(data),
51
66
  createdOn: (0, _linkExtractors.extractDateCreated)(data),
52
67
  dueOn: (0, _utils.extractDueOn)(data),
53
- viewAction: (0, _extractViewAction.extractViewAction)(data, actionOptions),
54
68
  latestCommit: (0, _latestCommit.extractLatestCommit)(data),
55
69
  linkIcon: (0, _icon.extractLinkIcon)(response, renderers),
56
70
  location: (0, _utils.extractLocation)(data),
@@ -65,7 +79,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
65
79
  snippet: (0, _primitives.extractSummary)(data) || undefined,
66
80
  // Explicitly set here to remove an empty string
67
81
  sourceBranch: (0, _utils.extractSourceBranch)(data),
68
- state: (0, _extractState.default)(response, actionOptions, id),
82
+ state: (0, _extractState.default)(response, actionOptions, id, appearance, origin, fireEvent, resolve),
69
83
  subscriberCount: (0, _utils.extractSubscriberCount)(data),
70
84
  subTasksProgress: (0, _utils.extractSubTasksProgress)(data),
71
85
  storyPoints: (0, _utils.extractStoryPoints)(data),
@@ -10,6 +10,8 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _react = require("react");
12
12
  var _uuid = _interopRequireDefault(require("uuid"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
+ var _useAnalyticsEvents2 = require("../../../common/analytics/generated/use-analytics-events");
13
15
  var measure = _interopRequireWildcard(require("../../../utils/performance"));
14
16
  var _analytics = require("../../analytics");
15
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -20,14 +22,18 @@ var ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
20
22
  * Invoke client action such as preview, download and open link
21
23
  */
22
24
  var useInvokeClientAction = function useInvokeClientAction(_ref) {
23
- var analytics = _ref.analytics;
25
+ var analytics = _ref.analytics,
26
+ fireEventProp = _ref.fireEvent;
27
+ var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
28
+ defaultFireEvent = _useAnalyticsEvents.fireEvent;
29
+ var fireEvent = fireEventProp !== null && fireEventProp !== void 0 ? fireEventProp : defaultFireEvent;
24
30
  return (0, _react.useCallback)( /*#__PURE__*/function () {
25
31
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
26
- var actionType, actionFn, extensionKey, display, experienceId, markName, result, reason;
32
+ var actionSubjectId, actionType, actionFn, _ref2$definitionId, definitionId, extensionKey, display, id, _ref2$resourceType, resourceType, experienceId, markName, result, _measure$getMeasure$d, _measure$getMeasure, reason, _measure$getMeasure$d2, _measure$getMeasure2;
27
33
  return _regenerator.default.wrap(function _callee$(_context) {
28
34
  while (1) switch (_context.prev = _context.next) {
29
35
  case 0:
30
- actionType = _ref2.actionType, actionFn = _ref2.actionFn, extensionKey = _ref2.extensionKey, display = _ref2.display;
36
+ actionSubjectId = _ref2.actionSubjectId, actionType = _ref2.actionType, actionFn = _ref2.actionFn, _ref2$definitionId = _ref2.definitionId, definitionId = _ref2$definitionId === void 0 ? null : _ref2$definitionId, extensionKey = _ref2.extensionKey, display = _ref2.display, id = _ref2.id, _ref2$resourceType = _ref2.resourceType, resourceType = _ref2$resourceType === void 0 ? null : _ref2$resourceType;
31
37
  experienceId = (0, _uuid.default)(); // Begin performance instrumentation.
32
38
  markName = "".concat(experienceId, "-").concat(actionType);
33
39
  measure.mark(markName, 'pending');
@@ -41,10 +47,20 @@ var useInvokeClientAction = function useInvokeClientAction(_ref) {
41
47
  });
42
48
 
43
49
  // Begin analytics instrumentation.
44
- analytics === null || analytics === void 0 || analytics.ui.actionClickedEvent({
45
- actionType: actionType,
46
- display: display
47
- });
50
+ if (actionSubjectId && (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
51
+ fireEvent("ui.button.clicked.".concat(actionSubjectId), {
52
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
53
+ definitionId: definitionId,
54
+ display: display !== null && display !== void 0 ? display : null,
55
+ id: id !== null && id !== void 0 ? id : experienceId,
56
+ resourceType: resourceType
57
+ });
58
+ } else {
59
+ analytics === null || analytics === void 0 || analytics.ui.actionClickedEvent({
60
+ actionType: actionType,
61
+ display: display
62
+ });
63
+ }
48
64
 
49
65
  // Invoke action
50
66
  _context.next = 9;
@@ -53,10 +69,21 @@ var useInvokeClientAction = function useInvokeClientAction(_ref) {
53
69
  result = _context.sent;
54
70
  measure.mark(markName, 'resolved');
55
71
  (0, _analytics.succeedUfoExperience)(ACTION_EXPERIENCE_NAME, experienceId);
56
- analytics === null || analytics === void 0 || analytics.operational.invokeSucceededEvent({
57
- actionType: actionType,
58
- display: display
59
- });
72
+ if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
73
+ fireEvent('operational.smartLinkAction.resolved', {
74
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
75
+ definitionId: definitionId,
76
+ display: display !== null && display !== void 0 ? display : null,
77
+ duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(markName, 'resolved')) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null,
78
+ id: id !== null && id !== void 0 ? id : experienceId,
79
+ resourceType: resourceType
80
+ });
81
+ } else {
82
+ analytics === null || analytics === void 0 || analytics.operational.invokeSucceededEvent({
83
+ actionType: actionType,
84
+ display: display
85
+ });
86
+ }
60
87
  return _context.abrupt("return", result);
61
88
  case 16:
62
89
  _context.prev = 16;
@@ -64,11 +91,23 @@ var useInvokeClientAction = function useInvokeClientAction(_ref) {
64
91
  measure.mark(markName, 'errored');
65
92
  (0, _analytics.failUfoExperience)(ACTION_EXPERIENCE_NAME, experienceId);
66
93
  reason = typeof _context.t0 === 'string' ? _context.t0 : _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message;
67
- analytics === null || analytics === void 0 || analytics.operational.invokeFailedEvent({
68
- actionType: actionType,
69
- display: display,
70
- reason: reason
71
- });
94
+ if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
95
+ fireEvent('operational.smartLinkAction.unresolved', {
96
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
97
+ definitionId: definitionId,
98
+ display: display !== null && display !== void 0 ? display : null,
99
+ duration: (_measure$getMeasure$d2 = (_measure$getMeasure2 = measure.getMeasure(markName, 'errored')) === null || _measure$getMeasure2 === void 0 ? void 0 : _measure$getMeasure2.duration) !== null && _measure$getMeasure$d2 !== void 0 ? _measure$getMeasure$d2 : null,
100
+ id: id !== null && id !== void 0 ? id : experienceId,
101
+ reason: reason,
102
+ resourceType: resourceType
103
+ });
104
+ } else {
105
+ analytics === null || analytics === void 0 || analytics.operational.invokeFailedEvent({
106
+ actionType: actionType,
107
+ display: display,
108
+ reason: reason
109
+ });
110
+ }
72
111
  case 22:
73
112
  case "end":
74
113
  return _context.stop();
@@ -78,6 +117,6 @@ var useInvokeClientAction = function useInvokeClientAction(_ref) {
78
117
  return function (_x) {
79
118
  return _ref3.apply(this, arguments);
80
119
  };
81
- }(), [analytics === null || analytics === void 0 ? void 0 : analytics.operational, analytics === null || analytics === void 0 ? void 0 : analytics.ui]);
120
+ }(), [analytics === null || analytics === void 0 ? void 0 : analytics.operational, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent]);
82
121
  };
83
122
  var _default = exports.default = useInvokeClientAction;
@@ -5,8 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useSmartLinkActions = useSmartLinkActions;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
9
  var _react = require("react");
9
10
  var _uuid = _interopRequireDefault(require("uuid"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
13
+ var _extractInvokeDownloadAction = require("../../extractors/action/extract-invoke-download-action");
14
+ var _extractInvokePreviewAction = require("../../extractors/action/extract-invoke-preview-action");
15
+ var _extractInvokeViewAction = require("../../extractors/action/extract-invoke-view-action");
10
16
  var _extractDownloadActionProps = require("../../extractors/action/extractDownloadActionProps");
11
17
  var _extractPreviewActionProps = require("../../extractors/action/extractPreviewActionProps");
12
18
  var _extractViewActionProps = require("../../extractors/action/extractViewActionProps");
@@ -16,6 +22,8 @@ var _analytics = require("../analytics");
16
22
  var _helpers = require("../helpers");
17
23
  var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
18
24
  var _store = require("../store");
25
+ 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; }
26
+ 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) { (0, _defineProperty2.default)(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; }
19
27
  function useSmartLinkActions(_ref) {
20
28
  var url = _ref.url,
21
29
  appearance = _ref.appearance,
@@ -26,6 +34,8 @@ function useSmartLinkActions(_ref) {
26
34
  }, []);
27
35
  var linkState = (0, _store.useSmartCardState)(url);
28
36
  var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, id);
37
+ var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
38
+ fireEvent = _useAnalyticsEvents.fireEvent;
29
39
  var invokeClientAction = (0, _useInvokeClientAction.default)({
30
40
  analytics: linkAnalytics
31
41
  });
@@ -40,15 +50,24 @@ function useSmartLinkActions(_ref) {
40
50
  actionOptions: actionOptions
41
51
  };
42
52
  var actions = [];
43
- var downloadActionProps = (0, _extractDownloadActionProps.extractDownloadActionProps)(opts);
53
+ var invokeParam = {
54
+ actionOptions: actionOptions,
55
+ appearance: appearance,
56
+ id: id,
57
+ response: linkState.details
58
+ };
59
+ var downloadActionProps = (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? (0, _extractInvokeDownloadAction.extractInvokeDownloadAction)(invokeParam) : (0, _extractDownloadActionProps.extractDownloadActionProps)(opts);
44
60
  if (downloadActionProps) {
45
61
  actions.push((0, _toAction.toAction)(downloadActionProps, invokeClientAction, _messages.messages.download, 'download-content'));
46
62
  }
47
- var viewActionProps = (0, _extractViewActionProps.extractViewActionProps)(opts);
63
+ var viewActionProps = (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? (0, _extractInvokeViewAction.extractInvokeViewAction)(invokeParam) : (0, _extractViewActionProps.extractViewActionProps)(opts);
48
64
  if (viewActionProps) {
49
65
  actions.push((0, _toAction.toAction)(viewActionProps, invokeClientAction, _messages.messages.view, 'view-content'));
50
66
  }
51
- var previewActionProps = (0, _extractPreviewActionProps.extractPreviewActionProps)(opts);
67
+ var previewActionProps = (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? (0, _extractInvokePreviewAction.extractInvokePreviewAction)(_objectSpread(_objectSpread({}, invokeParam), {}, {
68
+ fireEvent: fireEvent,
69
+ origin: origin
70
+ })) : (0, _extractPreviewActionProps.extractPreviewActionProps)(opts);
52
71
  if (previewActionProps) {
53
72
  actions.push((0, _toAction.toAction)(previewActionProps, invokeClientAction, _messages.messages.preview_improved, 'preview-content'));
54
73
  }
@@ -5,8 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.LinkAnalyticsContext = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _analytics = require("./analytics");
13
+ 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; }
14
+ 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) { (0, _defineProperty2.default)(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; }
10
15
  /**
11
16
  * Provides an analytics context to supply attributes to events based on a URL
12
17
  */
@@ -19,11 +24,11 @@ var LinkAnalyticsContext = exports.LinkAnalyticsContext = function LinkAnalytics
19
24
  return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
20
25
  data: {
21
26
  source: source,
22
- attributes: {
27
+ attributes: _objectSpread(_objectSpread({}, (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? _analytics.context : {}), {}, {
23
28
  displayCategory: displayCategory,
24
29
  display: display,
25
30
  id: id
26
- }
31
+ })
27
32
  }
28
33
  }, children);
29
34
  };
@@ -17,7 +17,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
17
17
  var context = exports.context = {
18
18
  componentName: 'smart-cards',
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "32.7.0"
20
+ packageVersion: "32.7.1"
21
21
  };
22
22
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
23
23
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -35,7 +35,10 @@ var mockByUrl = exports.mockByUrl = function mockByUrl(url) {
35
35
  access: 'granted',
36
36
  auth: [],
37
37
  definitionId: 'd1',
38
- key: 'object-provider'
38
+ key: 'object-provider',
39
+ resourceType: 'object-resource',
40
+ subproduct: 'object-subproduct',
41
+ product: 'object-product'
39
42
  },
40
43
  data: {
41
44
  '@context': {
@@ -62,6 +62,7 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
62
62
  onClick: onClick,
63
63
  onError: onError,
64
64
  onResolve: onResolve,
65
+ origin: "smartLinkCard",
65
66
  actionOptions: actionOptions,
66
67
  testId: testId,
67
68
  ui: _utils.FlexibleCardUiOptions,
@@ -34,6 +34,7 @@ var UnresolvedView = function UnresolvedView(_ref) {
34
34
  onAuthorize: onAuthorize,
35
35
  onClick: onClick,
36
36
  onError: onError,
37
+ origin: "smartLinkCard",
37
38
  testId: testId,
38
39
  ui: _utils.FlexibleCardUiOptions,
39
40
  url: url
@@ -208,6 +208,7 @@ function Component(_ref) {
208
208
  cardState: cardState,
209
209
  onAuthorize: services.length && handleAuthorize || undefined,
210
210
  onClick: handleClickWrapper,
211
+ origin: "smartLinkCard",
211
212
  renderers: renderers,
212
213
  ui: ui,
213
214
  showHoverPreview: showHoverPreview,
@@ -7,14 +7,17 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
13
  var _react = _interopRequireWildcard(require("react"));
13
14
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
16
  var _tokens = require("@atlaskit/tokens");
15
17
  var _constants = require("../../constants");
16
18
  var _useInvokeClientAction = _interopRequireDefault(require("../../state/hooks/use-invoke-client-action"));
17
19
  var _utils = require("../../utils");
20
+ var _icon = _interopRequireDefault(require("../FlexibleCard/components/elements/icon"));
18
21
  var _analytics = _interopRequireDefault(require("./components/analytics"));
19
22
  var _embedContent = _interopRequireDefault(require("./components/embed-content"));
20
23
  var _errorBoundary = _interopRequireDefault(require("./components/error-boundary"));
@@ -32,12 +35,15 @@ var toWidth = function toWidth(size) {
32
35
  var EmbedModal = function EmbedModal(_ref) {
33
36
  var analytics = _ref.analytics,
34
37
  download = _ref.download,
38
+ invokeDownloadAction = _ref.invokeDownloadAction,
35
39
  extensionKey = _ref.extensionKey,
40
+ fireEvent = _ref.fireEvent,
36
41
  icon = _ref.icon,
37
42
  iframeName = _ref.iframeName,
38
43
  isSupportTheming = _ref.isSupportTheming,
39
44
  _ref$isTrusted = _ref.isTrusted,
40
45
  isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
46
+ linkIcon = _ref.linkIcon,
41
47
  onClose = _ref.onClose,
42
48
  onOpen = _ref.onOpen,
43
49
  onResize = _ref.onResize,
@@ -49,7 +55,8 @@ var EmbedModal = function EmbedModal(_ref) {
49
55
  _ref$testId = _ref.testId,
50
56
  testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
51
57
  title = _ref.title,
52
- url = _ref.url;
58
+ url = _ref.url,
59
+ invokeViewAction = _ref.invokeViewAction;
53
60
  var defaultWidth = toWidth(size);
54
61
  var _useState = (0, _react.useState)(showModal),
55
62
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -61,7 +68,8 @@ var EmbedModal = function EmbedModal(_ref) {
61
68
  setWidth = _useState4[1];
62
69
  var openAt = (0, _react.useRef)();
63
70
  var invoke = (0, _useInvokeClientAction.default)({
64
- analytics: analytics
71
+ analytics: analytics,
72
+ fireEvent: fireEvent
65
73
  });
66
74
  var handleOnOpenComplete = (0, _react.useCallback)(function () {
67
75
  openAt.current = Date.now();
@@ -95,53 +103,61 @@ var EmbedModal = function EmbedModal(_ref) {
95
103
  var themeState = (0, _tokens.useThemeObserver)();
96
104
  var previewUrl = src;
97
105
  var handleOnViewActionClick = (0, _react.useCallback)(function () {
98
- invoke({
99
- actionType: 'ViewAction',
100
- actionFn: function () {
101
- var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
102
- return _regenerator.default.wrap(function _callee$(_context) {
103
- while (1) switch (_context.prev = _context.next) {
104
- case 0:
105
- return _context.abrupt("return", (0, _utils.openUrl)(url));
106
- case 1:
107
- case "end":
108
- return _context.stop();
109
- }
110
- }, _callee);
111
- }));
112
- function actionFn() {
113
- return _actionFn.apply(this, arguments);
114
- }
115
- return actionFn;
116
- }(),
117
- display: _constants.CardDisplay.EmbedPreview,
118
- extensionKey: extensionKey
119
- });
120
- }, [extensionKey, invoke, url]);
106
+ if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
107
+ invokeViewAction && invoke(invokeViewAction);
108
+ } else {
109
+ invoke({
110
+ actionType: 'ViewAction',
111
+ actionFn: function () {
112
+ var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
113
+ return _regenerator.default.wrap(function _callee$(_context) {
114
+ while (1) switch (_context.prev = _context.next) {
115
+ case 0:
116
+ return _context.abrupt("return", (0, _utils.openUrl)(url));
117
+ case 1:
118
+ case "end":
119
+ return _context.stop();
120
+ }
121
+ }, _callee);
122
+ }));
123
+ function actionFn() {
124
+ return _actionFn.apply(this, arguments);
125
+ }
126
+ return actionFn;
127
+ }(),
128
+ display: _constants.CardDisplay.EmbedPreview,
129
+ extensionKey: extensionKey
130
+ });
131
+ }
132
+ }, [extensionKey, invoke, url, invokeViewAction]);
121
133
  var handleOnDownloadActionClick = (0, _react.useCallback)(function () {
122
- invoke({
123
- actionType: _constants.ActionName.DownloadAction,
124
- actionFn: function () {
125
- var _actionFn2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
126
- return _regenerator.default.wrap(function _callee2$(_context2) {
127
- while (1) switch (_context2.prev = _context2.next) {
128
- case 0:
129
- return _context2.abrupt("return", (0, _utils.downloadUrl)(download));
130
- case 1:
131
- case "end":
132
- return _context2.stop();
133
- }
134
- }, _callee2);
135
- }));
136
- function actionFn() {
137
- return _actionFn2.apply(this, arguments);
138
- }
139
- return actionFn;
140
- }(),
141
- display: _constants.CardDisplay.EmbedPreview,
142
- extensionKey: extensionKey
143
- });
144
- }, [download, extensionKey, invoke]);
134
+ if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
135
+ invokeDownloadAction && invoke(invokeDownloadAction);
136
+ } else {
137
+ invoke({
138
+ actionType: _constants.ActionName.DownloadAction,
139
+ actionFn: function () {
140
+ var _actionFn2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
141
+ return _regenerator.default.wrap(function _callee2$(_context2) {
142
+ while (1) switch (_context2.prev = _context2.next) {
143
+ case 0:
144
+ return _context2.abrupt("return", (0, _utils.downloadUrl)(download));
145
+ case 1:
146
+ case "end":
147
+ return _context2.stop();
148
+ }
149
+ }, _callee2);
150
+ }));
151
+ function actionFn() {
152
+ return _actionFn2.apply(this, arguments);
153
+ }
154
+ return actionFn;
155
+ }(),
156
+ display: _constants.CardDisplay.EmbedPreview,
157
+ extensionKey: extensionKey
158
+ });
159
+ }
160
+ }, [download, invokeDownloadAction, extensionKey, invoke]);
145
161
  if (previewUrl && isSupportTheming) {
146
162
  previewUrl = (0, _utils.getPreviewUrlWithTheme)(previewUrl, themeState);
147
163
  }
@@ -153,10 +169,15 @@ var EmbedModal = function EmbedModal(_ref) {
153
169
  testId: testId,
154
170
  width: width
155
171
  }, /*#__PURE__*/_react.default.createElement(_linkInfo.default, {
156
- icon: icon,
172
+ icon: (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? linkIcon ? {
173
+ icon: /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({}, linkIcon, {
174
+ size: _constants.SmartLinkSize.Large
175
+ })),
176
+ isFlexibleUi: true
177
+ } : undefined : icon,
157
178
  providerName: providerName,
158
- onViewButtonClick: url ? handleOnViewActionClick : undefined,
159
- onDownloadButtonClick: download ? handleOnDownloadActionClick : undefined,
179
+ onViewButtonClick: (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? invokeViewAction ? handleOnViewActionClick : undefined : url ? handleOnViewActionClick : undefined,
180
+ onDownloadButtonClick: (0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics') ? invokeDownloadAction ? handleOnDownloadActionClick : undefined : download ? handleOnDownloadActionClick : undefined,
160
181
  onResizeButtonClick: handleOnResizeClick,
161
182
  size: width,
162
183
  title: title,