@atlaskit/smart-card 32.7.8 → 32.7.10

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 (71) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/analytics.spec.yaml +31 -5
  3. package/dist/cjs/extractors/action/extract-invoke-preview-action.js +7 -6
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +5 -1
  5. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +2 -7
  6. package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +99 -6
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/CardWithUrl/component.js +2 -3
  9. package/dist/cjs/view/CardWithUrl/loader.js +15 -6
  10. package/dist/cjs/view/EmbedModal/components/analytics/index.js +88 -32
  11. package/dist/cjs/view/FlexibleCard/components/container/index.js +2 -1
  12. package/dist/cjs/view/FlexibleCard/index.js +2 -1
  13. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -2
  14. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +0 -1
  15. package/dist/cjs/view/HoverCard/index.js +15 -8
  16. package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +4 -1
  17. package/dist/cjs/view/InlineCard/index.js +3 -1
  18. package/dist/cjs/view/LinkUrl/index.js +1 -1
  19. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +8 -7
  20. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -1
  21. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +0 -3
  22. package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +97 -2
  23. package/dist/es2019/utils/analytics/analytics.js +1 -1
  24. package/dist/es2019/view/CardWithUrl/component.js +2 -3
  25. package/dist/es2019/view/CardWithUrl/loader.js +10 -2
  26. package/dist/es2019/view/EmbedModal/components/analytics/index.js +88 -32
  27. package/dist/es2019/view/FlexibleCard/components/container/index.js +2 -1
  28. package/dist/es2019/view/FlexibleCard/index.js +2 -1
  29. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -1
  30. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +0 -1
  31. package/dist/es2019/view/HoverCard/index.js +10 -2
  32. package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +3 -1
  33. package/dist/es2019/view/InlineCard/index.js +3 -1
  34. package/dist/es2019/view/LinkUrl/index.js +1 -1
  35. package/dist/esm/extractors/action/extract-invoke-preview-action.js +8 -7
  36. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +5 -1
  37. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +2 -7
  38. package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +95 -5
  39. package/dist/esm/utils/analytics/analytics.js +1 -1
  40. package/dist/esm/view/CardWithUrl/component.js +2 -3
  41. package/dist/esm/view/CardWithUrl/loader.js +15 -6
  42. package/dist/esm/view/EmbedModal/components/analytics/index.js +88 -32
  43. package/dist/esm/view/FlexibleCard/components/container/index.js +2 -1
  44. package/dist/esm/view/FlexibleCard/index.js +2 -1
  45. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -1
  46. package/dist/esm/view/HoverCard/components/views/resolved/index.js +0 -1
  47. package/dist/esm/view/HoverCard/index.js +14 -4
  48. package/dist/esm/view/InlineCard/UnauthorisedView/index.js +4 -1
  49. package/dist/esm/view/InlineCard/index.js +3 -1
  50. package/dist/esm/view/LinkUrl/index.js +1 -1
  51. package/dist/types/common/analytics/generated/analytics.types.d.ts +16 -2
  52. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  53. package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  54. package/dist/types/view/Card/types.d.ts +1 -0
  55. package/dist/types/view/CardWithUrl/types.d.ts +3 -0
  56. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -0
  57. package/dist/types/view/FlexibleCard/types.d.ts +1 -0
  58. package/dist/types/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  59. package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +7 -2
  60. package/dist/types/view/InlineCard/types.d.ts +3 -0
  61. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +16 -2
  62. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  63. package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  64. package/dist/types-ts4.5/view/Card/types.d.ts +1 -0
  65. package/dist/types-ts4.5/view/CardWithUrl/types.d.ts +3 -0
  66. package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +1 -0
  67. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +1 -0
  68. package/dist/types-ts4.5/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  69. package/dist/types-ts4.5/view/InlineCard/UnauthorisedView/index.d.ts +7 -2
  70. package/dist/types-ts4.5/view/InlineCard/types.d.ts +3 -0
  71. package/package.json +4 -1
@@ -17,7 +17,7 @@ import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAna
17
17
  import CustomPopupContainer from '../components/CustomPopupContainer';
18
18
  import HoverCardContent from '../components/HoverCardContent';
19
19
  import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
20
- const HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
20
+ export const HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
21
21
  const FADE_IN_DELAY = 500;
22
22
  const FADE_OUT_DELAY = 300;
23
23
  const RESOLVE_DELAY = 100;
@@ -40,7 +40,6 @@ const HoverCardResolvedView = ({
40
40
  display: CardDisplay.HoverCardPreview
41
41
  });
42
42
  fireEvent('ui.smartLink.renderSuccess', {
43
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
44
43
  display: CardDisplay.HoverCardPreview
45
44
  });
46
45
  } else {
@@ -15,7 +15,8 @@ import { CardDisplay } from '../../constants';
15
15
  import { useSmartLinkAnalytics } from '../../state';
16
16
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
17
17
  import { SmartLinkModalProvider } from '../../state/modal';
18
- import { HoverCardComponent } from './components/HoverCardComponent';
18
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
19
+ import { HOVER_CARD_SOURCE, HoverCardComponent } from './components/HoverCardComponent';
19
20
  const HoverCardWithErrorBoundary = props => {
20
21
  const {
21
22
  fireEvent
@@ -26,12 +27,19 @@ const HoverCardWithErrorBoundary = props => {
26
27
  children
27
28
  } = props;
28
29
  const analytics = useSmartLinkAnalytics(url, id);
30
+ const analyticsContext = useSmartLinkAnalyticsContext({
31
+ display: CardDisplay.HoverCardPreview,
32
+ id,
33
+ source: HOVER_CARD_SOURCE,
34
+ url
35
+ });
29
36
  const onError = useCallback((error, info) => {
30
37
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
31
38
  startUfoExperience('smart-link-rendered', id || 'NULL');
32
39
  failUfoExperience('smart-link-rendered', id || 'NULL');
33
40
  failUfoExperience('smart-link-authenticated', id || 'NULL');
34
41
  fireEvent('ui.smartLink.renderFailed', {
42
+ ...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
35
43
  display: CardDisplay.HoverCardPreview,
36
44
  id: id !== null && id !== void 0 ? id : null,
37
45
  error: error,
@@ -45,7 +53,7 @@ const HoverCardWithErrorBoundary = props => {
45
53
  errorInfo: info
46
54
  });
47
55
  }
48
- }, [analytics.ui, id, fireEvent]);
56
+ }, [analytics.ui, analyticsContext, id, fireEvent]);
49
57
  return jsx(ErrorBoundary, {
50
58
  fallback: children,
51
59
  onError: onError
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import Button from '@atlaskit/button';
5
5
  import LockIcon from '@atlaskit/icon/glyph/lock-filled';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { N500, R400 } from '@atlaskit/theme/colors';
7
8
  import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
8
9
  import { messages } from '../../../messages';
@@ -26,6 +27,7 @@ export const InlineCardUnauthorizedView = ({
26
27
  isSelected,
27
28
  testId = 'inline-card-unauthorized-view',
28
29
  showAuthTooltip = false,
30
+ showHoverPreview = false,
29
31
  truncateInline,
30
32
  context
31
33
  }) => {
@@ -66,7 +68,7 @@ export const InlineCardUnauthorizedView = ({
66
68
  onClick: onClick,
67
69
  titleColor: `var(--ds-text-subtle, ${N500})`
68
70
  }), renderActionButton());
69
- if (onAuthorise && showAuthTooltip) {
71
+ if (onAuthorise && (fg('platform_deprecate-showauthtooltip-smart-card') ? showHoverPreview : showAuthTooltip)) {
70
72
  return /*#__PURE__*/React.createElement(HoverCard, {
71
73
  url: url,
72
74
  id: id
@@ -3,6 +3,7 @@ import React, { useEffect } from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
4
  import { extractProvider } from '@atlaskit/link-extractors';
5
5
  import { useFeatureFlag } from '@atlaskit/link-provider';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { SmartLinkStatus } from '../../constants';
7
8
  import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
8
9
  import { extractInlineProps } from '../../extractors/inline';
@@ -110,7 +111,8 @@ export const InlineCard = ({
110
111
  onClick: handleFrameClick,
111
112
  onAuthorise: handleAuthorize,
112
113
  testId: testIdWithStatus,
113
- showAuthTooltip: showAuthTooltip,
114
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
115
+ showHoverPreview: showHoverPreview,
114
116
  id: id,
115
117
  analytics: analytics,
116
118
  extensionKey: extensionKey,
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
10
10
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
11
11
  const PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "32.7.8",
13
+ packageVersion: "32.7.10",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  const Anchor = withLinkClickedEvent('a');
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { extractLink, extractPreview as extractPreviewData, extractProvider, extractTitle } from '@atlaskit/link-extractors';
4
4
  import { ActionName, CardAction } from '../../index';
5
- import { getDefinitionId, getExtensionKey, getResourceType } from '../../state/helpers';
5
+ import { getExtensionKey } from '../../state/helpers';
6
6
  import { canShowAction } from '../../utils/actions/can-show-action';
7
7
  import { openEmbedModal } from '../../view/EmbedModal/utils';
8
8
  import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
@@ -27,6 +27,7 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
27
27
  var src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
28
28
  if (src) {
29
29
  var url = extractLink(data);
30
+ var extensionKey = getExtensionKey(response);
30
31
  return {
31
32
  actionFn: function () {
32
33
  var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -36,7 +37,10 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
36
37
  case 0:
37
38
  return _context.abrupt("return", openEmbedModal({
38
39
  fireEvent: fireEvent,
40
+ extensionKey: extensionKey,
41
+ id: id,
39
42
  invokeDownloadAction: extractInvokeDownloadAction(param),
43
+ invokeViewAction: extractInvokeViewAction(param, true),
40
44
  isSupportTheming: extractIsSupportTheming(meta),
41
45
  isTrusted: extractIsTrusted(meta),
42
46
  linkIcon: extractLinkIcon(response),
@@ -45,8 +49,7 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
45
49
  origin: origin,
46
50
  src: src,
47
51
  title: extractTitle(data),
48
- url: url,
49
- invokeViewAction: extractInvokeViewAction(param, true)
52
+ url: url
50
53
  }));
51
54
  case 1:
52
55
  case "end":
@@ -61,11 +64,9 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
61
64
  }(),
62
65
  actionSubjectId: 'invokePreviewScreen',
63
66
  actionType: ActionName.PreviewAction,
64
- definitionId: getDefinitionId(response),
65
67
  display: display,
66
- extensionKey: getExtensionKey(response),
67
- id: id,
68
- resourceType: getResourceType(response)
68
+ extensionKey: extensionKey,
69
+ id: id
69
70
  };
70
71
  }
71
72
  };
@@ -68,6 +68,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
68
68
  * This fires an event that represents when a user
69
69
  * click a button.
70
70
  * @param data A partial analytics event payload
71
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
71
72
  */
72
73
  buttonClickedEvent: function buttonClickedEvent(data) {
73
74
  return dispatchAnalytics(applyCommonAttributes({
@@ -113,6 +114,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
113
114
  /**
114
115
  * This fires an event that represents when a user close a modal.
115
116
  * @param data A partial analytics event payload
117
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
116
118
  */
117
119
  modalClosedEvent: function modalClosedEvent(data) {
118
120
  return dispatchAnalytics(applyCommonAttributes({
@@ -131,6 +133,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
131
133
  * @param definitionId The definitionId of the Smart Link resolver invoked.
132
134
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
133
135
  * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
136
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
134
137
  */
135
138
  renderSuccessEvent: function renderSuccessEvent(_ref2) {
136
139
  var display = _ref2.display,
@@ -172,6 +175,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
172
175
  * @param id The unique ID for this Smart Link.
173
176
  * @param error: An error representing why the Smart Link render failed.
174
177
  * @param errorInfo: Additional details about the error including the stack trace.
178
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
175
179
  */
176
180
  renderFailedEvent: function renderFailedEvent(_ref3) {
177
181
  var display = _ref3.display,
@@ -277,7 +281,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
277
281
  return {
278
282
  /**
279
283
  * This fires an event that represents when a user view a modal.
280
- * @param data A partial analytics event payload
284
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
281
285
  */
282
286
  modalViewedEvent: function modalViewedEvent(data) {
283
287
  return dispatchAnalytics(applyCommonAttributes({
@@ -1,10 +1,5 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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; }
4
1
  import React from 'react';
5
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
- import { context } from './analytics';
8
3
  /**
9
4
  * Provides an analytics context to supply attributes to events based on a URL
10
5
  */
@@ -17,11 +12,11 @@ export var LinkAnalyticsContext = function LinkAnalyticsContext(_ref) {
17
12
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
18
13
  data: {
19
14
  source: source,
20
- attributes: _objectSpread(_objectSpread({}, fg('platform-smart-card-migrate-embed-modal-analytics') ? context : {}), {}, {
15
+ attributes: {
21
16
  displayCategory: displayCategory,
22
17
  display: display,
23
18
  id: id
24
- })
19
+ }
25
20
  }
26
21
  }, children);
27
22
  };
@@ -1,20 +1,102 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
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; }
5
+ import React, { useMemo } from 'react';
3
6
  import { AnalyticsContext } from '@atlaskit/analytics-next';
4
7
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
8
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
9
+ import { getUrl } from '@atlaskit/linking-common';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
5
11
  import { useSmartCardState as useSmartLinkState } from '../../state/store';
12
+ import { context } from './analytics';
6
13
  import { LinkAnalyticsContext } from './LinkAnalyticsContext';
14
+ var getExtendedResolvedAttributes = function getExtendedResolvedAttributes(linkDetails, details, linkStatus) {
15
+ var _details$meta$definit, _details$meta, _details$meta$resourc, _details$meta2;
16
+ return _objectSpread({
17
+ definitionId: (_details$meta$definit = details === null || details === void 0 || (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId) !== null && _details$meta$definit !== void 0 ? _details$meta$definit : null,
18
+ resourceType: (_details$meta$resourc = details === null || details === void 0 || (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.resourceType) !== null && _details$meta$resourc !== void 0 ? _details$meta$resourc : null
19
+ }, getResolvedAttributes(linkDetails, details, linkStatus));
20
+ };
21
+ var getSmartLinkAnalyticsContext = function getSmartLinkAnalyticsContext(_ref) {
22
+ var display = _ref.display,
23
+ id = _ref.id,
24
+ response = _ref.response,
25
+ source = _ref.source,
26
+ status = _ref.status,
27
+ url = _ref.url;
28
+ var resolvedAttributes = getExtendedResolvedAttributes({
29
+ url: url
30
+ }, response, status);
31
+ return {
32
+ source: source,
33
+ attributes: _objectSpread(_objectSpread({}, context), {}, {
34
+ display: display,
35
+ id: id
36
+ }, resolvedAttributes)
37
+ };
38
+ };
39
+ /**
40
+ * Provides an analytics context data to supply attributes to events based on a URL
41
+ * and the link state in the store
42
+ */
43
+ export var useSmartLinkAnalyticsContext = function useSmartLinkAnalyticsContext(_ref2) {
44
+ var display = _ref2.display,
45
+ id = _ref2.id,
46
+ source = _ref2.source,
47
+ url = _ref2.url;
48
+ var _useSmartLinkContext = useSmartLinkContext(),
49
+ store = _useSmartLinkContext.store;
50
+ var state = store ? getUrl(store, url) : undefined;
51
+ return useMemo(function () {
52
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? getSmartLinkAnalyticsContext({
53
+ display: display,
54
+ id: id,
55
+ response: state === null || state === void 0 ? void 0 : state.details,
56
+ source: source,
57
+ status: state === null || state === void 0 ? void 0 : state.status,
58
+ url: url
59
+ }) : {};
60
+ }, [display, id, source, state === null || state === void 0 ? void 0 : state.details, state === null || state === void 0 ? void 0 : state.status, url]);
61
+ };
62
+
7
63
  /**
8
64
  * Provides an analytics context to supply attributes to events based on a URL
9
65
  * and the link state in the store
10
66
  */
11
- export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props) {
12
- var children = props.children,
13
- url = props.url,
14
- display = props.display;
67
+ var ExtendedSmartLinkAnalyticsContext = function ExtendedSmartLinkAnalyticsContext(_ref3) {
68
+ var children = _ref3.children,
69
+ display = _ref3.display,
70
+ id = _ref3.id,
71
+ source = _ref3.source,
72
+ url = _ref3.url;
15
73
  var _useSmartLinkState = useSmartLinkState(url),
16
74
  details = _useSmartLinkState.details,
17
75
  status = _useSmartLinkState.status;
76
+ var data = getSmartLinkAnalyticsContext({
77
+ display: display,
78
+ id: id,
79
+ response: details,
80
+ source: source,
81
+ status: status,
82
+ url: url
83
+ });
84
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
85
+ data: data
86
+ }, children);
87
+ };
88
+
89
+ /**
90
+ * Provides an analytics context to supply attributes to events based on a URL
91
+ * and the link state in the store
92
+ */
93
+ var LegacySmartLinkAnalyticsContext = function LegacySmartLinkAnalyticsContext(props) {
94
+ var children = props.children,
95
+ url = props.url,
96
+ display = props.display;
97
+ var _useSmartLinkState2 = useSmartLinkState(url),
98
+ details = _useSmartLinkState2.details,
99
+ status = _useSmartLinkState2.status;
18
100
  var attributes = getResolvedAttributes({
19
101
  url: url
20
102
  }, details, status);
@@ -25,4 +107,12 @@ export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props)
25
107
  attributes: attributes
26
108
  }
27
109
  }, children));
110
+ };
111
+
112
+ /**
113
+ * Provides an analytics context to supply attributes to events based on a URL
114
+ * and the link state in the store
115
+ */
116
+ export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props) {
117
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? /*#__PURE__*/React.createElement(ExtendedSmartLinkAnalyticsContext, props) : /*#__PURE__*/React.createElement(LegacySmartLinkAnalyticsContext, props);
28
118
  };
@@ -8,7 +8,7 @@ export var ANALYTICS_CHANNEL = 'media';
8
8
  export var context = {
9
9
  componentName: 'smart-cards',
10
10
  packageName: "@atlaskit/smart-card",
11
- packageVersion: "32.7.8"
11
+ packageVersion: "32.7.10"
12
12
  };
13
13
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
14
14
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -153,7 +153,6 @@ function Component(_ref) {
153
153
  display: isFlexibleUi ? 'flexible' : appearance
154
154
  });
155
155
  fireEvent('ui.smartLink.renderSuccess', {
156
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
157
156
  display: isFlexibleUi ? 'flexible' : appearance
158
157
  });
159
158
  } else {
@@ -205,7 +204,7 @@ function Component(_ref) {
205
204
  ui: ui,
206
205
  showHoverPreview: showHoverPreview,
207
206
  hoverPreviewOptions: hoverPreviewOptions,
208
- showAuthTooltip: showAuthTooltip,
207
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
209
208
  actionOptions: actionOptions,
210
209
  url: url,
211
210
  testId: testId,
@@ -237,7 +236,7 @@ function Component(_ref) {
237
236
  inlinePreloaderStyle: inlinePreloaderStyle,
238
237
  showHoverPreview: showHoverPreview,
239
238
  hoverPreviewOptions: hoverPreviewOptions,
240
- showAuthTooltip: showAuthTooltip,
239
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
241
240
  actionOptions: actionOptions,
242
241
  removeTextHighlightingFromTitle: removeTextHighlightingFromTitle,
243
242
  resolvingPlaceholder: resolvingPlaceholder,
@@ -1,4 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
3
6
  import { ErrorBoundary } from 'react-error-boundary';
4
7
  import { di } from 'react-magnetic-di';
@@ -8,6 +11,7 @@ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analyti
8
11
  import { useSmartLinkAnalytics } from '../../state';
9
12
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
10
13
  import { importWithRetry } from '../../utils';
14
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
11
15
  import { isFlexibleUiCard } from '../../utils/flexible';
12
16
  import { clearMarks, clearMeasures } from '../../utils/performance';
13
17
  import { LoadingCardLink } from './component-lazy/LoadingCardLink';
@@ -59,6 +63,11 @@ export function CardWithURLRenderer(props) {
59
63
  truncateInline = props.truncateInline;
60
64
  var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
61
65
  var isFlexibleUi = isFlexibleUiCard(children);
66
+ var analyticsContext = useSmartLinkAnalyticsContext({
67
+ display: isFlexibleUi ? 'flexible' : appearance,
68
+ id: id,
69
+ url: url !== null && url !== void 0 ? url : ''
70
+ });
62
71
  var errorHandler = useCallback(function (error, info) {
63
72
  var componentStack = info.componentStack;
64
73
  var errorInfo = {
@@ -70,23 +79,23 @@ export function CardWithURLRenderer(props) {
70
79
  // to the reliability of the smart-card front-end components.
71
80
  // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
72
81
  if (error.name === 'ChunkLoadError') {
73
- fireEvent('operational.smartLink.chunkLoadFailed', {
82
+ fireEvent('operational.smartLink.chunkLoadFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
74
83
  display: appearance,
75
84
  error: error,
76
85
  errorInfo: errorInfo,
77
86
  definitionId: null
78
- });
87
+ }));
79
88
  } else if (error.name !== 'APIError') {
80
89
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
81
90
  startUfoExperience('smart-link-rendered', id || 'NULL');
82
91
  failUfoExperience('smart-link-rendered', id || 'NULL');
83
92
  failUfoExperience('smart-link-authenticated', id || 'NULL');
84
- fireEvent('ui.smartLink.renderFailed', {
93
+ fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
85
94
  display: isFlexibleUi ? 'flexible' : appearance,
86
95
  id: id !== null && id !== void 0 ? id : null,
87
96
  error: error,
88
97
  errorInfo: errorInfo
89
- });
98
+ }));
90
99
  } else {
91
100
  analytics.ui.renderFailedEvent({
92
101
  display: isFlexibleUi ? 'flexible' : appearance,
@@ -101,7 +110,7 @@ export function CardWithURLRenderer(props) {
101
110
  url: url !== null && url !== void 0 ? url : '',
102
111
  err: error
103
112
  });
104
- }, [analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
113
+ }, [analytics.ui, analyticsContext, appearance, id, onError, url, isFlexibleUi, fireEvent]);
105
114
  if (!url) {
106
115
  throw new Error('@atlaskit/smart-card: url property is missing.');
107
116
  }
@@ -133,7 +142,7 @@ export function CardWithURLRenderer(props) {
133
142
  ui: ui,
134
143
  showHoverPreview: showHoverPreview,
135
144
  hoverPreviewOptions: hoverPreviewOptions,
136
- showAuthTooltip: showAuthTooltip,
145
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
137
146
  placeholder: placeholder,
138
147
  removeTextHighlightingFromTitle: removeTextHighlightingFromTitle,
139
148
  resolvingPlaceholder: resolvingPlaceholder,
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { CardDisplay } from '../../../../constants';
5
+ import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../../../state/analytics';
4
6
  import { EmbedModalSize } from '../../types';
5
7
  var getResizeFrom = function getResizeFrom(size) {
6
8
  return size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
@@ -8,63 +10,117 @@ var getResizeFrom = function getResizeFrom(size) {
8
10
  var withAnalytics = function withAnalytics(Component) {
9
11
  return function (props) {
10
12
  var analytics = props.analytics,
13
+ fireEvent = props.fireEvent,
14
+ extensionKey = props.extensionKey,
15
+ id = props.id,
11
16
  onClose = props.onClose,
12
17
  onOpen = props.onOpen,
13
18
  onOpenFailed = props.onOpenFailed,
14
19
  onResize = props.onResize,
15
20
  origin = props.origin;
16
21
  var handleOnOpen = useCallback(function (context) {
17
- analytics === null || analytics === void 0 || analytics.screen.modalViewedEvent({
18
- name: 'embedPreviewModal',
19
- attributes: {
20
- origin: origin,
22
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
23
+ fireEvent === null || fireEvent === void 0 || fireEvent('screen.embedPreviewModal.viewed', {
24
+ origin: origin !== null && origin !== void 0 ? origin : null,
21
25
  size: context.size
22
- }
23
- });
24
- analytics === null || analytics === void 0 || analytics.ui.renderSuccessEvent({
25
- status: 'resolved',
26
- display: CardDisplay.EmbedPreview
27
- });
26
+ });
27
+ } else {
28
+ analytics === null || analytics === void 0 || analytics.screen.modalViewedEvent({
29
+ name: 'embedPreviewModal',
30
+ attributes: {
31
+ origin: origin,
32
+ size: context.size
33
+ }
34
+ });
35
+ }
36
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
37
+ succeedUfoExperience('smart-link-rendered', id || 'NULL', {
38
+ extensionKey: extensionKey,
39
+ display: CardDisplay.EmbedPreview
40
+ });
41
+
42
+ // UFO will disregard this if authentication experience has not yet been started
43
+ succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
44
+ display: CardDisplay.EmbedPreview
45
+ });
46
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.smartLink.renderSuccess', {
47
+ display: CardDisplay.EmbedPreview
48
+ });
49
+ } else {
50
+ analytics === null || analytics === void 0 || analytics.ui.renderSuccessEvent({
51
+ status: 'resolved',
52
+ display: CardDisplay.EmbedPreview
53
+ });
54
+ }
28
55
  if (onOpen) {
29
56
  onOpen(context);
30
57
  }
31
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpen, origin]);
58
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, extensionKey, id, onOpen, origin]);
32
59
  var handleOnOpenFailed = useCallback(function (error, errorInfo) {
33
- analytics === null || analytics === void 0 || analytics.ui.renderFailedEvent({
34
- display: CardDisplay.EmbedPreview,
35
- error: error,
36
- errorInfo: errorInfo
37
- });
60
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
61
+ startUfoExperience('smart-link-rendered', id || 'NULL');
62
+ failUfoExperience('smart-link-rendered', id || 'NULL');
63
+ failUfoExperience('smart-link-authenticated', id || 'NULL');
64
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.smartLink.renderFailed', {
65
+ display: CardDisplay.EmbedPreview,
66
+ error: error,
67
+ errorInfo: errorInfo,
68
+ id: id !== null && id !== void 0 ? id : null
69
+ });
70
+ } else {
71
+ analytics === null || analytics === void 0 || analytics.ui.renderFailedEvent({
72
+ display: CardDisplay.EmbedPreview,
73
+ error: error,
74
+ errorInfo: errorInfo
75
+ });
76
+ }
38
77
  if (onOpenFailed) {
39
78
  onOpenFailed(error, errorInfo);
40
79
  }
41
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpenFailed]);
80
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, id, onOpenFailed]);
42
81
  var handleOnClose = useCallback(function (context) {
43
- analytics === null || analytics === void 0 || analytics.ui.modalClosedEvent({
44
- actionSubjectId: 'embedPreview',
45
- attributes: {
46
- origin: origin,
47
- previewTime: context.duration,
82
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
83
+ var _context$duration;
84
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.modal.closed.embedPreview', {
85
+ origin: origin !== null && origin !== void 0 ? origin : null,
86
+ previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
48
87
  size: context.size
49
- }
50
- });
88
+ });
89
+ } else {
90
+ analytics === null || analytics === void 0 || analytics.ui.modalClosedEvent({
91
+ actionSubjectId: 'embedPreview',
92
+ attributes: {
93
+ origin: origin,
94
+ previewTime: context.duration,
95
+ size: context.size
96
+ }
97
+ });
98
+ }
51
99
  if (onClose) {
52
100
  onClose(context);
53
101
  }
54
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onClose, origin]);
102
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onClose, origin]);
55
103
  var handleOnResize = useCallback(function (context) {
56
- analytics === null || analytics === void 0 || analytics.ui.buttonClickedEvent({
57
- actionSubjectId: 'embedPreviewResize',
58
- attributes: {
104
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
105
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.button.clicked.embedPreviewResize', {
59
106
  newSize: context.size,
60
- origin: origin,
107
+ origin: origin !== null && origin !== void 0 ? origin : null,
61
108
  previousSize: getResizeFrom(context.size)
62
- }
63
- });
109
+ });
110
+ } else {
111
+ analytics === null || analytics === void 0 || analytics.ui.buttonClickedEvent({
112
+ actionSubjectId: 'embedPreviewResize',
113
+ attributes: {
114
+ newSize: context.size,
115
+ origin: origin,
116
+ previousSize: getResizeFrom(context.size)
117
+ }
118
+ });
119
+ }
64
120
  if (onResize) {
65
121
  onResize(context);
66
122
  }
67
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onResize, origin]);
123
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onResize, origin]);
68
124
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
69
125
  onClose: handleOnClose,
70
126
  onOpen: handleOnOpen,
@@ -9,6 +9,7 @@ import React, { useContext } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { di } from 'react-magnetic-di';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { N40 } from '@atlaskit/theme/colors';
13
14
  import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
14
15
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
@@ -193,7 +194,7 @@ var Container = function Container(_ref3) {
193
194
  var canShowHoverPreview = showHoverPreview && status === 'resolved';
194
195
  // `retry` object contains action that can be performed on
195
196
  // unresolved link (unauthorized, forbidden, not found, etc.)
196
- var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
197
+ var canShowAuthTooltip = (fg('platform_deprecate-showauthtooltip-smart-card') ? showHoverPreview : showAuthTooltip) && status === 'unauthorized' && retry !== undefined;
197
198
  var container = jsx("div", {
198
199
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
199
200
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),