@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
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.HoverCardComponent = void 0;
8
+ exports.HoverCardComponent = exports.HOVER_CARD_SOURCE = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
@@ -29,7 +29,7 @@ var _excluded = ["aria-haspopup", "aria-expanded"];
29
29
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
30
30
  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); }
31
31
  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; }
32
- var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
32
+ var HOVER_CARD_SOURCE = exports.HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
33
33
  var FADE_IN_DELAY = 500;
34
34
  var FADE_OUT_DELAY = 300;
35
35
  var RESOLVE_DELAY = 100;
@@ -52,7 +52,6 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
52
52
  display: _constants.CardDisplay.HoverCardPreview
53
53
  });
54
54
  fireEvent('ui.smartLink.renderSuccess', {
55
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
56
55
  display: _constants.CardDisplay.HoverCardPreview
57
56
  });
58
57
  } else {
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.StandaloneHoverCard = exports.HoverCard = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _react = require("react");
8
10
  var _react2 = require("@emotion/react");
9
11
  var _reactErrorBoundary = require("react-error-boundary");
@@ -15,14 +17,13 @@ var _constants = require("../../constants");
15
17
  var _state = require("../../state");
16
18
  var _analytics = require("../../state/analytics");
17
19
  var _modal = require("../../state/modal");
20
+ var _SmartLinkAnalyticsContext = require("../../utils/analytics/SmartLinkAnalyticsContext");
18
21
  var _HoverCardComponent = require("./components/HoverCardComponent");
19
- /**
22
+ 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; }
23
+ 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; } /**
20
24
  * @jsxRuntime classic
21
25
  * @jsx jsx
22
- */
23
-
24
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
-
26
+ */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
27
  var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
27
28
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
28
29
  fireEvent = _useAnalyticsEvents.fireEvent;
@@ -30,17 +31,23 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
30
31
  id = props.id,
31
32
  children = props.children;
32
33
  var analytics = (0, _state.useSmartLinkAnalytics)(url, id);
34
+ var analyticsContext = (0, _SmartLinkAnalyticsContext.useSmartLinkAnalyticsContext)({
35
+ display: _constants.CardDisplay.HoverCardPreview,
36
+ id: id,
37
+ source: _HoverCardComponent.HOVER_CARD_SOURCE,
38
+ url: url
39
+ });
33
40
  var onError = (0, _react.useCallback)(function (error, info) {
34
41
  if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
35
42
  (0, _analytics.startUfoExperience)('smart-link-rendered', id || 'NULL');
36
43
  (0, _analytics.failUfoExperience)('smart-link-rendered', id || 'NULL');
37
44
  (0, _analytics.failUfoExperience)('smart-link-authenticated', id || 'NULL');
38
- fireEvent('ui.smartLink.renderFailed', {
45
+ fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
39
46
  display: _constants.CardDisplay.HoverCardPreview,
40
47
  id: id !== null && id !== void 0 ? id : null,
41
48
  error: error,
42
49
  errorInfo: info
43
- });
50
+ }));
44
51
  } else {
45
52
  analytics.ui.renderFailedEvent({
46
53
  display: _constants.CardDisplay.HoverCardPreview,
@@ -49,7 +56,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
49
56
  errorInfo: info
50
57
  });
51
58
  }
52
- }, [analytics.ui, id, fireEvent]);
59
+ }, [analytics.ui, analyticsContext, id, fireEvent]);
53
60
  return (0, _react2.jsx)(_reactErrorBoundary.ErrorBoundary, {
54
61
  fallback: children,
55
62
  onError: onError
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _button = _interopRequireDefault(require("@atlaskit/button"));
12
12
  var _lockFilled = _interopRequireDefault(require("@atlaskit/icon/glyph/lock-filled"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _colors = require("@atlaskit/theme/colors");
14
15
  var _useAnalyticsEvents2 = require("../../../common/analytics/generated/use-analytics-events");
15
16
  var _messages = require("../../../messages");
@@ -35,6 +36,8 @@ var InlineCardUnauthorizedView = exports.InlineCardUnauthorizedView = function I
35
36
  testId = _ref$testId === void 0 ? 'inline-card-unauthorized-view' : _ref$testId,
36
37
  _ref$showAuthTooltip = _ref.showAuthTooltip,
37
38
  showAuthTooltip = _ref$showAuthTooltip === void 0 ? false : _ref$showAuthTooltip,
39
+ _ref$showHoverPreview = _ref.showHoverPreview,
40
+ showHoverPreview = _ref$showHoverPreview === void 0 ? false : _ref$showHoverPreview,
38
41
  truncateInline = _ref.truncateInline,
39
42
  context = _ref.context;
40
43
  var frameRef = _react.default.useRef(null);
@@ -73,7 +76,7 @@ var InlineCardUnauthorizedView = exports.InlineCardUnauthorizedView = function I
73
76
  onClick: onClick,
74
77
  titleColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")")
75
78
  }), renderActionButton());
76
- if (onAuthorise && showAuthTooltip) {
79
+ if (onAuthorise && ((0, _platformFeatureFlags.fg)('platform_deprecate-showauthtooltip-smart-card') ? showHoverPreview : showAuthTooltip)) {
77
80
  return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
78
81
  url: url,
79
82
  id: id
@@ -41,6 +41,7 @@ var _react = _interopRequireWildcard(require("react"));
41
41
  var _analyticsNext = require("@atlaskit/analytics-next");
42
42
  var _linkExtractors = require("@atlaskit/link-extractors");
43
43
  var _linkProvider = require("@atlaskit/link-provider");
44
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
44
45
  var _constants = require("../../constants");
45
46
  var _extractAccessContext = require("../../extractors/common/context/extractAccessContext");
46
47
  var _inline = require("../../extractors/inline");
@@ -145,7 +146,8 @@ var InlineCard = exports.InlineCard = function InlineCard(_ref) {
145
146
  onClick: handleFrameClick,
146
147
  onAuthorise: handleAuthorize,
147
148
  testId: testIdWithStatus,
148
- showAuthTooltip: showAuthTooltip,
149
+ showAuthTooltip: (0, _platformFeatureFlags.fg)('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
150
+ showHoverPreview: showHoverPreview,
149
151
  id: id,
150
152
  analytics: analytics,
151
153
  extensionKey: extensionKey,
@@ -20,7 +20,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
20
20
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
21
21
  var PACKAGE_DATA = {
22
22
  packageName: "@atlaskit/smart-card",
23
- packageVersion: "32.7.8",
23
+ packageVersion: "32.7.10",
24
24
  componentName: 'linkUrl'
25
25
  };
26
26
  var Anchor = (0, _click.withLinkClickedEvent)('a');
@@ -1,6 +1,6 @@
1
1
  import { extractLink, extractPreview as extractPreviewData, extractProvider, extractTitle } from '@atlaskit/link-extractors';
2
2
  import { ActionName, CardAction } from '../../index';
3
- import { getDefinitionId, getExtensionKey, getResourceType } from '../../state/helpers';
3
+ import { getExtensionKey } from '../../state/helpers';
4
4
  import { canShowAction } from '../../utils/actions/can-show-action';
5
5
  import { openEmbedModal } from '../../view/EmbedModal/utils';
6
6
  import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
@@ -27,12 +27,16 @@ export const extractInvokePreviewAction = param => {
27
27
  const src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
28
28
  if (src) {
29
29
  const url = extractLink(data);
30
+ const extensionKey = getExtensionKey(response);
30
31
  return {
31
32
  actionFn: async () => {
32
33
  var _extractProvider;
33
34
  return openEmbedModal({
34
35
  fireEvent,
36
+ extensionKey,
37
+ id,
35
38
  invokeDownloadAction: extractInvokeDownloadAction(param),
39
+ invokeViewAction: extractInvokeViewAction(param, true),
36
40
  isSupportTheming: extractIsSupportTheming(meta),
37
41
  isTrusted: extractIsTrusted(meta),
38
42
  linkIcon: extractLinkIcon(response),
@@ -41,17 +45,14 @@ export const extractInvokePreviewAction = param => {
41
45
  origin,
42
46
  src,
43
47
  title: extractTitle(data),
44
- url,
45
- invokeViewAction: extractInvokeViewAction(param, true)
48
+ url
46
49
  });
47
50
  },
48
51
  actionSubjectId: 'invokePreviewScreen',
49
52
  actionType: ActionName.PreviewAction,
50
- definitionId: getDefinitionId(response),
51
53
  display,
52
- extensionKey: getExtensionKey(response),
53
- id,
54
- resourceType: getResourceType(response)
54
+ extensionKey,
55
+ id
55
56
  };
56
57
  }
57
58
  };
@@ -60,6 +60,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
60
60
  * This fires an event that represents when a user
61
61
  * click a button.
62
62
  * @param data A partial analytics event payload
63
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
63
64
  */
64
65
  buttonClickedEvent: data => dispatchAnalytics(applyCommonAttributes({
65
66
  action: 'clicked',
@@ -107,6 +108,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
107
108
  /**
108
109
  * This fires an event that represents when a user close a modal.
109
110
  * @param data A partial analytics event payload
111
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
110
112
  */
111
113
  modalClosedEvent: data => dispatchAnalytics(applyCommonAttributes({
112
114
  action: 'closed',
@@ -126,6 +128,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
126
128
  * @param definitionId The definitionId of the Smart Link resolver invoked.
127
129
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
128
130
  * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
131
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
129
132
  */
130
133
  renderSuccessEvent: ({
131
134
  display,
@@ -167,6 +170,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
167
170
  * @param id The unique ID for this Smart Link.
168
171
  * @param error: An error representing why the Smart Link render failed.
169
172
  * @param errorInfo: Additional details about the error including the stack trace.
173
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
170
174
  */
171
175
  renderFailedEvent: ({
172
176
  display,
@@ -271,7 +275,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
271
275
  const screen = useMemo(() => ({
272
276
  /**
273
277
  * This fires an event that represents when a user view a modal.
274
- * @param data A partial analytics event payload
278
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
275
279
  */
276
280
  modalViewedEvent: data => dispatchAnalytics(applyCommonAttributes({
277
281
  action: 'viewed',
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
- import { context } from './analytics';
5
3
  /**
6
4
  * Provides an analytics context to supply attributes to events based on a URL
7
5
  */
@@ -16,7 +14,6 @@ export const LinkAnalyticsContext = ({
16
14
  data: {
17
15
  source,
18
16
  attributes: {
19
- ...(fg('platform-smart-card-migrate-embed-modal-analytics') ? context : {}),
20
17
  displayCategory,
21
18
  display,
22
19
  id
@@ -1,14 +1,101 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useMemo } from 'react';
3
3
  import { AnalyticsContext } from '@atlaskit/analytics-next';
4
4
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
5
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
6
+ import { getUrl } from '@atlaskit/linking-common';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
5
8
  import { useSmartCardState as useSmartLinkState } from '../../state/store';
9
+ import { context } from './analytics';
6
10
  import { LinkAnalyticsContext } from './LinkAnalyticsContext';
11
+ const getExtendedResolvedAttributes = (linkDetails, details, linkStatus) => {
12
+ var _details$meta$definit, _details$meta, _details$meta$resourc, _details$meta2;
13
+ return {
14
+ definitionId: (_details$meta$definit = details === null || details === void 0 ? 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,
15
+ resourceType: (_details$meta$resourc = details === null || details === void 0 ? 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,
16
+ ...getResolvedAttributes(linkDetails, details, linkStatus)
17
+ };
18
+ };
19
+ const getSmartLinkAnalyticsContext = ({
20
+ display,
21
+ id,
22
+ response,
23
+ source,
24
+ status,
25
+ url
26
+ }) => {
27
+ const resolvedAttributes = getExtendedResolvedAttributes({
28
+ url
29
+ }, response, status);
30
+ return {
31
+ source,
32
+ attributes: {
33
+ ...context,
34
+ display,
35
+ id,
36
+ ...resolvedAttributes
37
+ }
38
+ };
39
+ };
40
+ /**
41
+ * Provides an analytics context data to supply attributes to events based on a URL
42
+ * and the link state in the store
43
+ */
44
+ export const useSmartLinkAnalyticsContext = ({
45
+ display,
46
+ id,
47
+ source,
48
+ url
49
+ }) => {
50
+ const {
51
+ store
52
+ } = useSmartLinkContext();
53
+ const state = store ? getUrl(store, url) : undefined;
54
+ return useMemo(() => {
55
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? getSmartLinkAnalyticsContext({
56
+ display,
57
+ id,
58
+ response: state === null || state === void 0 ? void 0 : state.details,
59
+ source,
60
+ status: state === null || state === void 0 ? void 0 : state.status,
61
+ url
62
+ }) : {};
63
+ }, [display, id, source, state === null || state === void 0 ? void 0 : state.details, state === null || state === void 0 ? void 0 : state.status, url]);
64
+ };
65
+
7
66
  /**
8
67
  * Provides an analytics context to supply attributes to events based on a URL
9
68
  * and the link state in the store
10
69
  */
11
- export const SmartLinkAnalyticsContext = props => {
70
+ const ExtendedSmartLinkAnalyticsContext = ({
71
+ children,
72
+ display,
73
+ id,
74
+ source,
75
+ url
76
+ }) => {
77
+ const {
78
+ details,
79
+ status
80
+ } = useSmartLinkState(url);
81
+ const data = getSmartLinkAnalyticsContext({
82
+ display,
83
+ id,
84
+ response: details,
85
+ source,
86
+ status,
87
+ url
88
+ });
89
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
90
+ data: data
91
+ }, children);
92
+ };
93
+
94
+ /**
95
+ * Provides an analytics context to supply attributes to events based on a URL
96
+ * and the link state in the store
97
+ */
98
+ const LegacySmartLinkAnalyticsContext = props => {
12
99
  const {
13
100
  children,
14
101
  url,
@@ -28,4 +115,12 @@ export const SmartLinkAnalyticsContext = props => {
28
115
  attributes
29
116
  }
30
117
  }, children));
118
+ };
119
+
120
+ /**
121
+ * Provides an analytics context to supply attributes to events based on a URL
122
+ * and the link state in the store
123
+ */
124
+ export const SmartLinkAnalyticsContext = props => {
125
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? /*#__PURE__*/React.createElement(ExtendedSmartLinkAnalyticsContext, props) : /*#__PURE__*/React.createElement(LegacySmartLinkAnalyticsContext, props);
31
126
  };
@@ -3,7 +3,7 @@ export const ANALYTICS_CHANNEL = 'media';
3
3
  export const context = {
4
4
  componentName: 'smart-cards',
5
5
  packageName: "@atlaskit/smart-card",
6
- packageVersion: "32.7.8"
6
+ packageVersion: "32.7.10"
7
7
  };
8
8
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
9
9
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -151,7 +151,6 @@ function Component({
151
151
  display: isFlexibleUi ? 'flexible' : appearance
152
152
  });
153
153
  fireEvent('ui.smartLink.renderSuccess', {
154
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
155
154
  display: isFlexibleUi ? 'flexible' : appearance
156
155
  });
157
156
  } else {
@@ -203,7 +202,7 @@ function Component({
203
202
  ui: ui,
204
203
  showHoverPreview: showHoverPreview,
205
204
  hoverPreviewOptions: hoverPreviewOptions,
206
- showAuthTooltip: showAuthTooltip,
205
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
207
206
  actionOptions: actionOptions,
208
207
  url: url,
209
208
  testId: testId,
@@ -235,7 +234,7 @@ function Component({
235
234
  inlinePreloaderStyle: inlinePreloaderStyle,
236
235
  showHoverPreview: showHoverPreview,
237
236
  hoverPreviewOptions: hoverPreviewOptions,
238
- showAuthTooltip: showAuthTooltip,
237
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
239
238
  actionOptions: actionOptions,
240
239
  removeTextHighlightingFromTitle: removeTextHighlightingFromTitle,
241
240
  resolvingPlaceholder: resolvingPlaceholder,
@@ -7,6 +7,7 @@ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analyti
7
7
  import { useSmartLinkAnalytics } from '../../state';
8
8
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
9
9
  import { importWithRetry } from '../../utils';
10
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
10
11
  import { isFlexibleUiCard } from '../../utils/flexible';
11
12
  import { clearMarks, clearMeasures } from '../../utils/performance';
12
13
  import { LoadingCardLink } from './component-lazy/LoadingCardLink';
@@ -53,6 +54,11 @@ export function CardWithURLRenderer(props) {
53
54
  } = props;
54
55
  const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
55
56
  const isFlexibleUi = isFlexibleUiCard(children);
57
+ const analyticsContext = useSmartLinkAnalyticsContext({
58
+ display: isFlexibleUi ? 'flexible' : appearance,
59
+ id,
60
+ url: url !== null && url !== void 0 ? url : ''
61
+ });
56
62
  const errorHandler = useCallback((error, info) => {
57
63
  const {
58
64
  componentStack
@@ -67,6 +73,7 @@ export function CardWithURLRenderer(props) {
67
73
  // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
68
74
  if (error.name === 'ChunkLoadError') {
69
75
  fireEvent('operational.smartLink.chunkLoadFailed', {
76
+ ...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
70
77
  display: appearance,
71
78
  error: error,
72
79
  errorInfo: errorInfo,
@@ -78,6 +85,7 @@ export function CardWithURLRenderer(props) {
78
85
  failUfoExperience('smart-link-rendered', id || 'NULL');
79
86
  failUfoExperience('smart-link-authenticated', id || 'NULL');
80
87
  fireEvent('ui.smartLink.renderFailed', {
88
+ ...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
81
89
  display: isFlexibleUi ? 'flexible' : appearance,
82
90
  id: id !== null && id !== void 0 ? id : null,
83
91
  error: error,
@@ -97,7 +105,7 @@ export function CardWithURLRenderer(props) {
97
105
  url: url !== null && url !== void 0 ? url : '',
98
106
  err: error
99
107
  });
100
- }, [analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
108
+ }, [analytics.ui, analyticsContext, appearance, id, onError, url, isFlexibleUi, fireEvent]);
101
109
  if (!url) {
102
110
  throw new Error('@atlaskit/smart-card: url property is missing.');
103
111
  }
@@ -125,7 +133,7 @@ export function CardWithURLRenderer(props) {
125
133
  ui,
126
134
  showHoverPreview,
127
135
  hoverPreviewOptions,
128
- showAuthTooltip,
136
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
129
137
  placeholder,
130
138
  removeTextHighlightingFromTitle,
131
139
  resolvingPlaceholder,
@@ -1,11 +1,16 @@
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
  const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
6
8
  const withAnalytics = Component => props => {
7
9
  const {
8
10
  analytics,
11
+ fireEvent,
12
+ extensionKey,
13
+ id,
9
14
  onClose,
10
15
  onOpen,
11
16
  onOpenFailed,
@@ -13,57 +18,108 @@ const withAnalytics = Component => props => {
13
18
  origin
14
19
  } = props;
15
20
  const handleOnOpen = useCallback(context => {
16
- analytics === null || analytics === void 0 ? void 0 : analytics.screen.modalViewedEvent({
17
- name: 'embedPreviewModal',
18
- attributes: {
19
- origin,
21
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
22
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('screen.embedPreviewModal.viewed', {
23
+ origin: origin !== null && origin !== void 0 ? origin : null,
20
24
  size: context.size
21
- }
22
- });
23
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
24
- status: 'resolved',
25
- display: CardDisplay.EmbedPreview
26
- });
25
+ });
26
+ } else {
27
+ analytics === null || analytics === void 0 ? void 0 : analytics.screen.modalViewedEvent({
28
+ name: 'embedPreviewModal',
29
+ attributes: {
30
+ origin,
31
+ size: context.size
32
+ }
33
+ });
34
+ }
35
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
36
+ succeedUfoExperience('smart-link-rendered', id || 'NULL', {
37
+ extensionKey,
38
+ display: CardDisplay.EmbedPreview
39
+ });
40
+
41
+ // UFO will disregard this if authentication experience has not yet been started
42
+ succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
43
+ display: CardDisplay.EmbedPreview
44
+ });
45
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderSuccess', {
46
+ display: CardDisplay.EmbedPreview
47
+ });
48
+ } else {
49
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
50
+ status: 'resolved',
51
+ display: CardDisplay.EmbedPreview
52
+ });
53
+ }
27
54
  if (onOpen) {
28
55
  onOpen(context);
29
56
  }
30
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpen, origin]);
57
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, extensionKey, id, onOpen, origin]);
31
58
  const handleOnOpenFailed = useCallback((error, errorInfo) => {
32
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
33
- display: CardDisplay.EmbedPreview,
34
- error,
35
- errorInfo
36
- });
59
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
60
+ startUfoExperience('smart-link-rendered', id || 'NULL');
61
+ failUfoExperience('smart-link-rendered', id || 'NULL');
62
+ failUfoExperience('smart-link-authenticated', id || 'NULL');
63
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderFailed', {
64
+ display: CardDisplay.EmbedPreview,
65
+ error: error,
66
+ errorInfo: errorInfo,
67
+ id: id !== null && id !== void 0 ? id : null
68
+ });
69
+ } else {
70
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
71
+ display: CardDisplay.EmbedPreview,
72
+ error,
73
+ errorInfo
74
+ });
75
+ }
37
76
  if (onOpenFailed) {
38
77
  onOpenFailed(error, errorInfo);
39
78
  }
40
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpenFailed]);
79
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, id, onOpenFailed]);
41
80
  const handleOnClose = useCallback(context => {
42
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
43
- actionSubjectId: 'embedPreview',
44
- attributes: {
45
- origin,
46
- previewTime: context.duration,
81
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
82
+ var _context$duration;
83
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.modal.closed.embedPreview', {
84
+ origin: origin !== null && origin !== void 0 ? origin : null,
85
+ previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
47
86
  size: context.size
48
- }
49
- });
87
+ });
88
+ } else {
89
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
90
+ actionSubjectId: 'embedPreview',
91
+ attributes: {
92
+ origin,
93
+ previewTime: context.duration,
94
+ size: context.size
95
+ }
96
+ });
97
+ }
50
98
  if (onClose) {
51
99
  onClose(context);
52
100
  }
53
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onClose, origin]);
101
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onClose, origin]);
54
102
  const handleOnResize = useCallback(context => {
55
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
56
- actionSubjectId: 'embedPreviewResize',
57
- attributes: {
103
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
104
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.button.clicked.embedPreviewResize', {
58
105
  newSize: context.size,
59
- origin,
106
+ origin: origin !== null && origin !== void 0 ? origin : null,
60
107
  previousSize: getResizeFrom(context.size)
61
- }
62
- });
108
+ });
109
+ } else {
110
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
111
+ actionSubjectId: 'embedPreviewResize',
112
+ attributes: {
113
+ newSize: context.size,
114
+ origin,
115
+ previousSize: getResizeFrom(context.size)
116
+ }
117
+ });
118
+ }
63
119
  if (onResize) {
64
120
  onResize(context);
65
121
  }
66
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onResize, origin]);
122
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onResize, origin]);
67
123
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
68
124
  onClose: handleOnClose,
69
125
  onOpen: handleOnOpen,
@@ -7,6 +7,7 @@ import React, { useContext } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { di } from 'react-magnetic-di';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { N40 } from '@atlaskit/theme/colors';
11
12
  import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
12
13
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
@@ -204,7 +205,7 @@ const Container = ({
204
205
  const canShowHoverPreview = showHoverPreview && status === 'resolved';
205
206
  // `retry` object contains action that can be performed on
206
207
  // unresolved link (unauthorized, forbidden, not found, etc.)
207
- const canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
208
+ const canShowAuthTooltip = (fg('platform_deprecate-showauthtooltip-smart-card') ? showHoverPreview : showAuthTooltip) && status === 'unauthorized' && retry !== undefined;
208
209
  const container = jsx("div", {
209
210
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
210
211
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect, useMemo } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
4
5
  import { SmartLinkStatus } from '../../constants';
5
6
  import { FlexibleUiAnalyticsContext, FlexibleUiContext, FlexibleUiOptionContext } from '../../state/flexible-ui-context';
@@ -108,7 +109,7 @@ const FlexibleCard = ({
108
109
  showHoverPreview: showHoverPreview,
109
110
  hoverPreviewOptions: hoverPreviewOptions,
110
111
  actionOptions: actionOptions,
111
- showAuthTooltip: showAuthTooltip,
112
+ showAuthTooltip: fg('platform_deprecate-showauthtooltip-smart-card') ? undefined : showAuthTooltip,
112
113
  status: status
113
114
  }), children))));
114
115
  };