@atlaskit/smart-card 44.23.2 → 44.23.4

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 (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/extractors/action/extract-invoke-view-action.js +11 -1
  3. package/dist/cjs/extractors/flexible/actions/index.js +5 -2
  4. package/dist/cjs/extractors/flexible/extract-state.js +8 -5
  5. package/dist/cjs/extractors/flexible/index.js +6 -3
  6. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +17 -2
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/utils/click-helpers.js +30 -1
  9. package/dist/cjs/view/CardWithUrl/component.js +106 -42
  10. package/dist/cjs/view/FlexibleCard/index.js +12 -2
  11. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +24 -1
  12. package/dist/cjs/view/LinkUrl/index.js +1 -1
  13. package/dist/es2019/extractors/action/extract-invoke-view-action.js +10 -1
  14. package/dist/es2019/extractors/flexible/actions/index.js +5 -1
  15. package/dist/es2019/extractors/flexible/extract-state.js +8 -4
  16. package/dist/es2019/extractors/flexible/index.js +6 -2
  17. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +13 -2
  18. package/dist/es2019/utils/analytics/analytics.js +1 -1
  19. package/dist/es2019/utils/click-helpers.js +29 -0
  20. package/dist/es2019/view/CardWithUrl/component.js +108 -43
  21. package/dist/es2019/view/FlexibleCard/index.js +10 -3
  22. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +24 -1
  23. package/dist/es2019/view/LinkUrl/index.js +1 -1
  24. package/dist/esm/extractors/action/extract-invoke-view-action.js +11 -1
  25. package/dist/esm/extractors/flexible/actions/index.js +5 -2
  26. package/dist/esm/extractors/flexible/extract-state.js +8 -5
  27. package/dist/esm/extractors/flexible/index.js +6 -3
  28. package/dist/esm/state/hooks-external/useSmartLinkActions.js +17 -2
  29. package/dist/esm/utils/analytics/analytics.js +1 -1
  30. package/dist/esm/utils/click-helpers.js +29 -0
  31. package/dist/esm/view/CardWithUrl/component.js +107 -43
  32. package/dist/esm/view/FlexibleCard/index.js +13 -3
  33. package/dist/esm/view/HoverCard/components/HoverCardContent.js +24 -1
  34. package/dist/esm/view/LinkUrl/index.js +1 -1
  35. package/dist/types/extractors/action/extract-invoke-preview-action.d.ts +2 -1
  36. package/dist/types/extractors/action/extract-invoke-view-action.d.ts +5 -2
  37. package/dist/types/extractors/action/types.d.ts +1 -0
  38. package/dist/types/extractors/flexible/actions/index.d.ts +3 -1
  39. package/dist/types/extractors/flexible/extract-state.d.ts +2 -1
  40. package/dist/types/extractors/flexible/index.d.ts +1 -1
  41. package/dist/types/utils/click-helpers.d.ts +20 -0
  42. package/dist/types/view/FlexibleCard/types.d.ts +2 -0
  43. package/dist/types-ts4.5/extractors/action/extract-invoke-preview-action.d.ts +2 -1
  44. package/dist/types-ts4.5/extractors/action/extract-invoke-view-action.d.ts +5 -2
  45. package/dist/types-ts4.5/extractors/action/types.d.ts +1 -0
  46. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +3 -1
  47. package/dist/types-ts4.5/extractors/flexible/extract-state.d.ts +2 -1
  48. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  49. package/dist/types-ts4.5/utils/click-helpers.d.ts +20 -0
  50. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -0
  51. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 44.23.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`36b77f485aef1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/36b77f485aef1) -
8
+ Append url with cross-product analytics params on go to link via embed modal and action hook
9
+ - Updated dependencies
10
+
11
+ ## 44.23.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [`6cb1e43229040`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6cb1e43229040) -
16
+ Append url with cross-product analytics params on link click
17
+
3
18
  ## 44.23.2
4
19
 
5
20
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.extractInvokeViewAction = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _linkExtractors = require("@atlaskit/link-extractors");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _constants = require("../../constants");
12
13
  var _helpers = require("../../state/helpers");
13
14
  var _utils = require("../../utils");
@@ -16,6 +17,7 @@ var _extractActions = require("../common/actions/extractActions");
16
17
  var extractInvokeViewAction = exports.extractInvokeViewAction = function extractInvokeViewAction(_ref, force) {
17
18
  var actionOptions = _ref.actionOptions,
18
19
  appearance = _ref.appearance,
20
+ transformUrl = _ref.transformUrl,
19
21
  id = _ref.id,
20
22
  response = _ref.response;
21
23
  if (!(0, _canShowAction.canShowAction)(_constants.CardAction.ViewAction, actionOptions)) {
@@ -33,11 +35,19 @@ var extractInvokeViewAction = exports.extractInvokeViewAction = function extract
33
35
  return {
34
36
  actionFn: function () {
35
37
  var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
38
+ var _transformUrl, destinationUrl;
36
39
  return _regenerator.default.wrap(function (_context) {
37
40
  while (1) switch (_context.prev = _context.next) {
38
41
  case 0:
39
- return _context.abrupt("return", (0, _utils.openUrl)(url));
42
+ if (!(0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
43
+ _context.next = 1;
44
+ break;
45
+ }
46
+ destinationUrl = (_transformUrl = transformUrl === null || transformUrl === void 0 ? void 0 : transformUrl(url)) !== null && _transformUrl !== void 0 ? _transformUrl : url;
47
+ return _context.abrupt("return", (0, _utils.openUrl)(destinationUrl));
40
48
  case 1:
49
+ return _context.abrupt("return", (0, _utils.openUrl)(url));
50
+ case 2:
41
51
  case "end":
42
52
  return _context.stop();
43
53
  }
@@ -28,6 +28,7 @@ var extractFlexibleCardActions = exports.extractFlexibleCardActions = function e
28
28
  product = _ref.product,
29
29
  response = _ref.response,
30
30
  rovoConfig = _ref.rovoConfig,
31
+ transformUrl = _ref.transformUrl,
31
32
  url = _ref.url,
32
33
  isPreviewPanelAvailable = _ref.isPreviewPanelAvailable,
33
34
  openPreviewPanel = _ref.openPreviewPanel;
@@ -41,7 +42,7 @@ var extractFlexibleCardActions = exports.extractFlexibleCardActions = function e
41
42
  appearance: appearance,
42
43
  id: id,
43
44
  response: response
44
- })), _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewClientAction)({
45
+ })), _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewClientAction)(_objectSpread({
45
46
  actionOptions: actionOptions,
46
47
  appearance: appearance,
47
48
  fireEvent: fireEvent,
@@ -50,7 +51,9 @@ var extractFlexibleCardActions = exports.extractFlexibleCardActions = function e
50
51
  response: response,
51
52
  isPreviewPanelAvailable: isPreviewPanelAvailable,
52
53
  openPreviewPanel: openPreviewPanel
53
- })), _constants.ActionName.AutomationAction, (0, _extractAutomationAction.extractAutomationAction)(response)), _constants.InternalActionName.AISummaryAction, (0, _extractAiSummaryAction.extractAISummaryAction)(response, url, actionOptions, aiSummaryConfig)), (0, _platformFeatureFlags.fg)('platform_sl_3p_auth_rovo_action_kill_switch') ? (0, _defineProperty2.default)({}, _constants.ActionName.RovoChatAction, (0, _extractRovoChatAction.default)({
54
+ }, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? {
55
+ transformUrl: transformUrl
56
+ } : undefined))), _constants.ActionName.AutomationAction, (0, _extractAutomationAction.extractAutomationAction)(response)), _constants.InternalActionName.AISummaryAction, (0, _extractAiSummaryAction.extractAISummaryAction)(response, url, actionOptions, aiSummaryConfig)), (0, _platformFeatureFlags.fg)('platform_sl_3p_auth_rovo_action_kill_switch') ? (0, _defineProperty2.default)({}, _constants.ActionName.RovoChatAction, (0, _extractRovoChatAction.default)({
54
57
  actionOptions: actionOptions,
55
58
  appearance: appearance,
56
59
  id: id,
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _linkExtractors = require("@atlaskit/link-extractors");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _constants = require("../../constants");
11
12
  var _helpers = require("../../state/helpers");
12
13
  var _canShowAction = require("../../utils/actions/can-show-action");
@@ -28,7 +29,7 @@ var toInvokeRequest = function toInvokeRequest(extensionKey, resourceIdentifiers
28
29
  details: details
29
30
  };
30
31
  };
31
- var extractAction = function extractAction(response, id, actionOptions, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel) {
32
+ var extractAction = function extractAction(response, id, actionOptions, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel, transformUrl) {
32
33
  var _action$dataRetrieval, _extractInvokePreview, _action$dataUpdateAct;
33
34
  var extensionKey = (0, _helpers.getExtensionKey)(response);
34
35
  var data = response === null || response === void 0 ? void 0 : response.data;
@@ -44,7 +45,7 @@ var extractAction = function extractAction(response, id, actionOptions, appearan
44
45
  }
45
46
  var read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
46
47
  var url = (0, _linkExtractors.extractLink)(data);
47
- var invokePreviewAction = response ? (_extractInvokePreview = (0, _extractInvokePreviewAction.extractInvokePreviewAction)({
48
+ var invokePreviewAction = response ? (_extractInvokePreview = (0, _extractInvokePreviewAction.extractInvokePreviewAction)(_objectSpread({
48
49
  actionOptions: actionOptions,
49
50
  appearance: appearance,
50
51
  fireEvent: fireEvent,
@@ -56,7 +57,9 @@ var extractAction = function extractAction(response, id, actionOptions, appearan
56
57
  response: response,
57
58
  isPreviewPanelAvailable: isPreviewPanelAvailable,
58
59
  openPreviewPanel: openPreviewPanel
59
- })) === null || _extractInvokePreview === void 0 ? void 0 : _extractInvokePreview.invokeAction : undefined;
60
+ }, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? {
61
+ transformUrl: transformUrl
62
+ } : undefined))) === null || _extractInvokePreview === void 0 ? void 0 : _extractInvokePreview.invokeAction : undefined;
60
63
  var details = {
61
64
  id: id,
62
65
  url: url,
@@ -68,7 +71,7 @@ var extractAction = function extractAction(response, id, actionOptions, appearan
68
71
  update: update
69
72
  } : undefined;
70
73
  };
71
- var extractState = function extractState(response, actionOptions, id, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel) {
74
+ var extractState = function extractState(response, actionOptions, id, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel, transformUrl) {
72
75
  if (!response || !response.data) {
73
76
  return;
74
77
  }
@@ -79,7 +82,7 @@ var extractState = function extractState(response, actionOptions, id, appearance
79
82
  if (!(0, _canShowAction.canShowAction)(_constants.CardAction.ChangeStatusAction, actionOptions)) {
80
83
  return lozenge;
81
84
  }
82
- var action = extractAction(response, id, actionOptions, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel);
85
+ var action = extractAction(response, id, actionOptions, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? transformUrl : undefined);
83
86
  return _objectSpread(_objectSpread({}, lozenge), {}, {
84
87
  action: action
85
88
  });
@@ -20,7 +20,7 @@ var _icon = require("./icon");
20
20
  var _extractProviderIcon = require("./icon/extract-provider-icon");
21
21
  var _latestCommit = require("./latest-commit");
22
22
  var _utils = require("./utils");
23
- var _excluded = ["appearance", "fireEvent", "id", "onClick", "onAuxClick", "onContextMenu", "origin", "product", "resolve", "rovoConfig", "actionOptions", "response", "status", "aiSummaryConfig", "isPreviewPanelAvailable", "openPreviewPanel"];
23
+ var _excluded = ["appearance", "fireEvent", "id", "onClick", "onAuxClick", "onContextMenu", "origin", "product", "resolve", "rovoConfig", "actionOptions", "response", "status", "aiSummaryConfig", "isPreviewPanelAvailable", "openPreviewPanel", "transformUrl"];
24
24
  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; }
25
25
  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; }
26
26
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
@@ -41,6 +41,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
41
41
  aiSummaryConfig = _ref.aiSummaryConfig,
42
42
  isPreviewPanelAvailable = _ref.isPreviewPanelAvailable,
43
43
  openPreviewPanel = _ref.openPreviewPanel,
44
+ transformUrl = _ref.transformUrl,
44
45
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
45
46
  if (!response) {
46
47
  return undefined;
@@ -65,7 +66,9 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
65
66
  // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
66
67
  isPreviewPanelAvailable: isPreviewPanelAvailable,
67
68
  openPreviewPanel: openPreviewPanel
68
- })),
69
+ }, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? {
70
+ transformUrl: transformUrl
71
+ } : undefined)),
69
72
  appliedToComponentsCount: (0, _utils.extractAppliedToComponentsCount)(data),
70
73
  assignedToGroup: (0, _utils.extractPersonAssignedToAsArray)(data),
71
74
  attachmentCount: (0, _utils.extractAttachmentCount)(data),
@@ -97,7 +100,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
97
100
  snippet: (0, _extractSummary.extractSmartLinkSummary)(response) || undefined,
98
101
  // Explicitly set here to remove an empty string
99
102
  sourceBranch: (0, _utils.extractSourceBranch)(data),
100
- state: (0, _extractState.default)(response, actionOptions, id, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel),
103
+ state: (0, _extractState.default)(response, actionOptions, id, appearance, origin, fireEvent, resolve, isPreviewPanelAvailable, openPreviewPanel, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? transformUrl : undefined),
101
104
  subscriberCount: (0, _utils.extractSubscriberCount)(data),
102
105
  subTasksProgress: (0, _utils.extractSubTasksProgress)(data),
103
106
  storyPoints: (0, _utils.extractStoryPoints)(data),
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = require("react");
10
10
  var _uuid = _interopRequireDefault(require("uuid"));
11
11
  var _linkProvider = require("@atlaskit/link-provider");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
14
15
  var _extractInvokeDownloadAction = require("../../extractors/action/extract-invoke-download-action");
@@ -18,6 +19,7 @@ var _messages = require("../../messages");
18
19
  var _toAction = require("../../utils/actions/to-action");
19
20
  var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
20
21
  var _useResolve = _interopRequireDefault(require("../hooks/use-resolve"));
22
+ var _useSmartLinkCrossProductUrlWrapper = require("../hooks/use-smart-link-cross-product-url-wrapper");
21
23
  var _store = require("../store");
22
24
  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
25
  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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
@@ -41,6 +43,9 @@ function useSmartLinkActions(_ref) {
41
43
  fireEvent: fireEvent
42
44
  });
43
45
  var resolve = (0, _useResolve.default)();
46
+ var appendCrossProductAnalyticsParams = (0, _useSmartLinkCrossProductUrlWrapper.useSmartLinkCrossProductUrlWrapperGated)({
47
+ details: linkState.details
48
+ });
44
49
  if ((0, _expValEquals.expValEquals)('platform_hover_card_preview_panel', 'cohort', 'test') && prefetch && !linkState.details) {
45
50
  resolve(url);
46
51
  }
@@ -56,7 +61,12 @@ function useSmartLinkActions(_ref) {
56
61
  if (downloadActionProps) {
57
62
  actions.push((0, _toAction.toAction)(downloadActionProps, invokeClientAction, _messages.messages.download, 'download-content'));
58
63
  }
59
- var viewActionProps = (0, _extractInvokeViewAction.extractInvokeViewAction)(invokeParam);
64
+ var viewActionProps = (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? (0, _extractInvokeViewAction.extractInvokeViewAction)(_objectSpread(_objectSpread({}, invokeParam), {}, {
65
+ transformUrl: function transformUrl() {
66
+ var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
67
+ return appendCrossProductAnalyticsParams(destinationUrl);
68
+ }
69
+ })) : (0, _extractInvokeViewAction.extractInvokeViewAction)(invokeParam);
60
70
  if (viewActionProps) {
61
71
  actions.push((0, _toAction.toAction)(viewActionProps, invokeClientAction, _messages.messages.view, 'view-content'));
62
72
  }
@@ -65,7 +75,12 @@ function useSmartLinkActions(_ref) {
65
75
  origin: origin,
66
76
  isPreviewPanelAvailable: isPreviewPanelAvailable,
67
77
  openPreviewPanel: openPreviewPanel
68
- }));
78
+ }, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? {
79
+ transformUrl: function transformUrl() {
80
+ var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
81
+ return appendCrossProductAnalyticsParams(destinationUrl);
82
+ }
83
+ } : undefined));
69
84
  if (previewActionProps) {
70
85
  actions.push((0, _toAction.toAction)(previewActionProps.invokeAction, invokeClientAction, _messages.messages.preview_improved, 'preview-content'));
71
86
  }
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
11
11
  var context = exports.context = {
12
12
  componentName: 'smart-cards',
13
13
  packageName: "@atlaskit/smart-card" || '',
14
- packageVersion: "44.23.1" || ''
14
+ packageVersion: "44.23.3" || ''
15
15
  };
16
16
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
17
17
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isAuxClick = void 0;
6
+ exports.isAuxClick = exports.getAnchorAttributesFromEvent = void 0;
7
7
  /**
8
8
  * Returns true for genuine middle-clicks (button === 1).
9
9
  * Filters out Windows right-clicks, which fire onAuxClick with button === 2
@@ -11,4 +11,33 @@ exports.isAuxClick = void 0;
11
11
  */
12
12
  var isAuxClick = exports.isAuxClick = function isAuxClick(e) {
13
13
  return e.button === 1;
14
+ };
15
+
16
+ /**
17
+ * Extracts `href` and `target` from the anchor element that is the event's `currentTarget`.
18
+ *
19
+ * Smart Link click handlers are attached to multiple card renderers (InlineCard, BlockCard,
20
+ * EmbedCard, FlexibleCard). When the handler needs to manually open a link — for example,
21
+ * when native anchor navigation has been prevented — it uses this helper to read the
22
+ * anchor's resolved URL and intended target from the event rather than re-deriving them.
23
+ *
24
+ * Returns `{ href: undefined, target: '_self' }` when `currentTarget` is not an anchor
25
+ * element (e.g. a button or wrapper div), so callers can safely fall back to a default target.
26
+ *
27
+ * @param event - A React mouse or keyboard event whose `currentTarget` may be an anchor.
28
+ * @returns The resolved absolute `href` and `target` attribute of the anchor, or safe
29
+ * defaults if `currentTarget` is not an anchor.
30
+ */
31
+ var getAnchorAttributesFromEvent = exports.getAnchorAttributesFromEvent = function getAnchorAttributesFromEvent(event) {
32
+ var currentTarget = event.currentTarget;
33
+ if (!(currentTarget instanceof HTMLAnchorElement)) {
34
+ return {
35
+ href: undefined,
36
+ target: '_self'
37
+ };
38
+ }
39
+ return {
40
+ href: currentTarget.href,
41
+ target: currentTarget.target || '_self'
42
+ };
14
43
  };
@@ -93,7 +93,7 @@ function Component(_ref) {
93
93
  var services = (0, _helpers.getServices)(state.details);
94
94
  var thirdPartyARI = (0, _helpers.getThirdPartyARI)(state.details);
95
95
  var firstPartyIdentifier = (0, _helpers.getFirstPartyIdentifier)();
96
- var wrapUrlWithCrossProductAnalytics = (0, _useSmartLinkCrossProductUrlWrapper.useSmartLinkCrossProductUrlWrapperGated)({
96
+ var appendCrossProductAnalyticsParams = (0, _useSmartLinkCrossProductUrlWrapper.useSmartLinkCrossProductUrlWrapperGated)({
97
97
  details: state.details
98
98
  });
99
99
  var actionOptions = (0, _combineActionOptions.combineActionOptions)({
@@ -127,56 +127,120 @@ function Component(_ref) {
127
127
  var isDisablePreviewPanel = disablePreviewPanel && (0, _experiments.editorExperiment)('platform_editor_preview_panel_linking_exp', true, {
128
128
  exposure: true
129
129
  });
130
+ if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
131
+ var _appendCrossProductAn;
132
+ // FIXME: InlineCard, BlockCard and EmbedCard call event.preventDefault() internally
133
+ // before the event bubbles up to this handler. This forces us to snapshot
134
+ // event.defaultPrevented before calling onClick to detect whether the consumer
135
+ // specifically prevented navigation. Ideally those components should not call
136
+ // preventDefault so this workaround can be removed.
137
+ var isEventDefaultPrevented = event.defaultPrevented;
138
+ var canOpenPreviewPanel = !isModifierKeyPressed && ari && name && openPreviewPanel && (isPreviewPanelAvailable === null || isPreviewPanelAvailable === void 0 ? void 0 : isPreviewPanelAvailable({
139
+ ari: ari
140
+ })) && !isDisablePreviewPanel;
130
141
 
131
- // If preview panel is available and the user clicked on the link,
132
- // delegate the click to the preview panel handler
133
- if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
134
- ari: ari
135
- }) && !isDisablePreviewPanel) {
136
- var _extractSmartLinkEmbe;
137
- event.preventDefault();
138
- event.stopPropagation();
139
- openPreviewPanel({
140
- url: url,
141
- ari: ari,
142
- name: name,
143
- iconUrl: (0, _helpers.getObjectIconUrl)(state.details),
144
- panelData: {
145
- embedUrl: (0, _expValEquals.expValEquals)('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe = (0, _linkExtractors.extractSmartLinkEmbed)(state.details)) === null || _extractSmartLinkEmbe === void 0 ? void 0 : _extractSmartLinkEmbe.src : undefined
146
- }
147
- });
148
- (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
149
- attributes: {
150
- clickOutcome: 'previewPanel'
151
- }
152
- });
153
- return;
154
- } else if (!onClick && !isFlexibleUi) {
155
- var clickUrl = (0, _helpers.getClickUrl)(url, state.details);
142
+ // Preview panel takes priority over link navigation when available.
143
+ if (canOpenPreviewPanel) {
144
+ var _extractSmartLinkEmbe;
145
+ event.preventDefault();
146
+ event.stopPropagation();
147
+ openPreviewPanel({
148
+ url: url,
149
+ ari: ari,
150
+ name: name,
151
+ iconUrl: (0, _helpers.getObjectIconUrl)(state.details),
152
+ panelData: {
153
+ embedUrl: (0, _expValEquals.expValEquals)('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe = (0, _linkExtractors.extractSmartLinkEmbed)(state.details)) === null || _extractSmartLinkEmbe === void 0 ? void 0 : _extractSmartLinkEmbe.src : undefined
154
+ }
155
+ });
156
+ (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
157
+ attributes: {
158
+ clickOutcome: 'previewPanel'
159
+ }
160
+ });
161
+ return;
162
+ }
156
163
 
157
- // Ctrl+left click on mac typically doesn't trigger onClick
158
- // The event could have potentially had `e.preventDefault()` called on it by now
159
- // event by smart card internally
160
- // If it has been called then only then can `isSpecialEvent` be true.
161
- var target = (0, _utils.isSpecialEvent)(event) ? '_blank' : '_self';
162
- if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
163
- var wrappedUrl = wrapUrlWithCrossProductAnalytics(clickUrl);
164
- window.open(wrappedUrl, target);
165
- } else {
166
- window.open(clickUrl, target);
164
+ // For FlexibleCard, read target from the clicked anchor element (e.g. _blank for links
165
+ // rendered with explicit target). For classic cards, default to _self
166
+ var _getAnchorAttributesF = (0, _clickHelpers.getAnchorAttributesFromEvent)(event),
167
+ anchorTarget = _getAnchorAttributesF.target;
168
+ var target = (0, _utils.isSpecialEvent)(event) ? '_blank' : isFlexibleUi ? anchorTarget : '_self';
169
+
170
+ // FIXME: preferredUrl should be rendered in the DOM anchor href instead of derived at click time
171
+ var preferredUrl = (0, _helpers.getClickUrl)(url, state.details);
172
+ var destinationUrl = (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
173
+
174
+ // FIXME: Consumer that handle click even themselves via callback won't have the decorated URL
175
+ onClick === null || onClick === void 0 || onClick(event);
176
+
177
+ // Check if the event is prevented via onClick callback
178
+ var consumerPreventedNavigation = event.defaultPrevented && !isEventDefaultPrevented;
179
+
180
+ // Classic cards (InlineCard, BlockCard, EmbedCard) rely on their own anchor navigation
181
+ // when onClick is provided, so this handler should not open the link for them.
182
+ // FlexibleCard's anchor is prevented from native navigation, so this handler always
183
+ // opens the link for FlexibleCard unless the consumer's onClick called preventDefault.
184
+ var shouldOpenLink = isFlexibleUi || !onClick;
185
+ var doOpenLink = shouldOpenLink && !consumerPreventedNavigation;
186
+ if (doOpenLink) {
187
+ event.preventDefault();
188
+ window.open(destinationUrl, target);
167
189
  }
168
- (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
190
+
191
+ // Only set clickOutcome when this handler actually opened the link.
192
+ // If a parent onClick handled navigation, fire a generic click event instead.
193
+ (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, doOpenLink ? {
169
194
  attributes: {
170
195
  clickOutcome: target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
171
196
  }
172
- });
197
+ } : undefined);
173
198
  } else {
174
- if (onClick) {
175
- onClick(event);
199
+ // If preview panel is available and the user clicked on the link,
200
+ // delegate the click to the preview panel handler
201
+ if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
202
+ ari: ari
203
+ }) && !isDisablePreviewPanel) {
204
+ var _extractSmartLinkEmbe2;
205
+ event.preventDefault();
206
+ event.stopPropagation();
207
+ openPreviewPanel({
208
+ url: url,
209
+ ari: ari,
210
+ name: name,
211
+ iconUrl: (0, _helpers.getObjectIconUrl)(state.details),
212
+ panelData: {
213
+ embedUrl: (0, _expValEquals.expValEquals)('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe2 = (0, _linkExtractors.extractSmartLinkEmbed)(state.details)) === null || _extractSmartLinkEmbe2 === void 0 ? void 0 : _extractSmartLinkEmbe2.src : undefined
214
+ }
215
+ });
216
+ (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
217
+ attributes: {
218
+ clickOutcome: 'previewPanel'
219
+ }
220
+ });
221
+ return;
222
+ } else if (!onClick && !isFlexibleUi) {
223
+ var clickUrl = (0, _helpers.getClickUrl)(url, state.details);
224
+
225
+ // Ctrl+left click on mac typically doesn't trigger onClick
226
+ // The event could have potentially had `e.preventDefault()` called on it by now
227
+ // event by smart card internally
228
+ // If it has been called then only then can `isSpecialEvent` be true.
229
+ var _target = (0, _utils.isSpecialEvent)(event) ? '_blank' : '_self';
230
+ window.open(clickUrl, _target);
231
+ (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
232
+ attributes: {
233
+ clickOutcome: _target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
234
+ }
235
+ });
236
+ } else {
237
+ if (onClick) {
238
+ onClick(event);
239
+ }
240
+ (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
176
241
  }
177
- (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
178
242
  }
179
- }, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, wrapUrlWithCrossProductAnalytics, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
243
+ }, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, appendCrossProductAnalyticsParams, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
180
244
 
181
245
  // Exposure fires once per eligible mount; click-time reads use no-exposure variant.
182
246
  (0, _react.useEffect)(function () {
@@ -19,6 +19,7 @@ var _flexibleUiContext = require("../../state/flexible-ui-context");
19
19
  var _useAiSummaryConfig = require("../../state/hooks/use-ai-summary-config");
20
20
  var _useResolve = _interopRequireDefault(require("../../state/hooks/use-resolve"));
21
21
  var _useRovoConfig = _interopRequireDefault(require("../../state/hooks/use-rovo-config"));
22
+ var _useSmartLinkCrossProductUrlWrapper = require("../../state/hooks/use-smart-link-cross-product-url-wrapper");
22
23
  var _container = _interopRequireDefault(require("./components/container"));
23
24
  var _utils = require("./utils");
24
25
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -68,6 +69,14 @@ var FlexibleCard = function FlexibleCard(_ref) {
68
69
  var cardType = cardState.status,
69
70
  details = cardState.details;
70
71
  var status = cardType;
72
+ var appendCrossProductAnalyticsParams = (0, _useSmartLinkCrossProductUrlWrapper.useSmartLinkCrossProductUrlWrapperGated)({
73
+ details: details
74
+ });
75
+ var transformUrlCallback = (0, _react.useCallback)(function () {
76
+ var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
77
+ return appendCrossProductAnalyticsParams(destinationUrl);
78
+ }, [appendCrossProductAnalyticsParams, url]);
79
+ var transformUrl = (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? transformUrlCallback : undefined;
71
80
 
72
81
  // if we have placeholder state it means we can internally use it
73
82
  // as temporary resolved data until the actual data comes back as one of the final statuses
@@ -97,9 +106,10 @@ var FlexibleCard = function FlexibleCard(_ref) {
97
106
  status: placeholderCardState ? placeHolderStatus : status,
98
107
  url: url,
99
108
  isPreviewPanelAvailable: isPreviewPanelAvailable,
100
- openPreviewPanel: openPreviewPanel
109
+ openPreviewPanel: openPreviewPanel,
110
+ transformUrl: transformUrl
101
111
  }));
102
- }, [aiSummaryConfig, appearance, actionOptions, details, id, isPreviewPanelAvailable, onAuthorize, onClick, onAuxClick, onContextMenu, openPreviewPanel, origin, placeholderCardState, placeHolderStatus, product, renderers, resolve, rovoConfig, status, url, fireEvent]);
112
+ }, [aiSummaryConfig, appearance, actionOptions, details, id, isPreviewPanelAvailable, onAuthorize, onClick, onAuxClick, onContextMenu, openPreviewPanel, origin, placeholderCardState, placeHolderStatus, product, renderers, resolve, rovoConfig, status, transformUrl, url, fireEvent]);
103
113
  var flexibleCardContext = (0, _react.useMemo)(function () {
104
114
  return {
105
115
  data: context,
@@ -20,10 +20,12 @@ var _constants = require("../../../constants");
20
20
  var _extractRovoChatAction = _interopRequireDefault(require("../../../extractors/flexible/actions/extract-rovo-chat-action"));
21
21
  var _helpers = require("../../../state/helpers");
22
22
  var _useRovoConfig2 = _interopRequireDefault(require("../../../state/hooks/use-rovo-config"));
23
+ var _useSmartLinkCrossProductUrlWrapper = require("../../../state/hooks/use-smart-link-cross-product-url-wrapper");
23
24
  var _store = require("../../../state/store");
24
25
  var _utils = require("../../../utils");
25
26
  var _aiSummary = require("../../../utils/ai-summary");
26
27
  var _click = require("../../../utils/analytics/click");
28
+ var _clickHelpers = require("../../../utils/click-helpers");
27
29
  var _styled = require("../styled");
28
30
  var _utils2 = require("../utils");
29
31
  var _ContentContainer = _interopRequireDefault(require("./ContentContainer"));
@@ -95,6 +97,9 @@ var HoverCardContent = function HoverCardContent(_ref4) {
95
97
  product = _useSmartLinkContext.product;
96
98
  var isAISummaryEnabled = (0, _aiSummary.getIsAISummaryEnabled)(isAdminHubAIEnabled, cardState.details);
97
99
  var services = (0, _helpers.getServices)(linkState.details);
100
+ var appendCrossProductAnalyticsParams = (0, _useSmartLinkCrossProductUrlWrapper.useSmartLinkCrossProductUrlWrapperGated)({
101
+ details: linkState.details
102
+ });
98
103
  var statusRef = (0, _react.useRef)(linkStatus);
99
104
  var fireEventRef = (0, _react.useRef)(fireEvent);
100
105
  var definitionIdRef = (0, _react.useRef)(definitionId);
@@ -136,6 +141,24 @@ var HoverCardContent = function HoverCardContent(_ref4) {
136
141
  };
137
142
  }, []);
138
143
  var onClick = (0, _react.useCallback)(function (event) {
144
+ if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
145
+ // Prevent the anchor's native navigation so we can open the destination URL
146
+ // with cross-product analytics query parameters appended.
147
+ // The href is read from the anchor element at click time rather than at render
148
+ // time because the URL for the anchor may be different from original URL.
149
+ // The component may use the URL from the resolved response which can be a redirect URL
150
+ // or other preferred URL based on link extractor.
151
+ // The cross-product params are client-only and cannot be rendered
152
+ // server-side. Falls back to the original `url` prop if the event target is
153
+ // not an anchor element.
154
+ event.preventDefault();
155
+ var _getAnchorAttributesF = (0, _clickHelpers.getAnchorAttributesFromEvent)(event),
156
+ _getAnchorAttributesF2 = _getAnchorAttributesF.href,
157
+ href = _getAnchorAttributesF2 === void 0 ? url : _getAnchorAttributesF2,
158
+ target = _getAnchorAttributesF.target;
159
+ var destinationUrl = appendCrossProductAnalyticsParams(href);
160
+ window.open(destinationUrl, target);
161
+ }
139
162
  var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
140
163
  fireEvent('ui.smartLink.clicked.titleGoToLink', {
141
164
  id: id,
@@ -144,7 +167,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
144
167
  definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
145
168
  });
146
169
  (0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
147
- }, [createAnalyticsEvent, id, fireEvent, definitionId]);
170
+ }, [createAnalyticsEvent, appendCrossProductAnalyticsParams, id, fireEvent, definitionId, url]);
148
171
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
149
172
  var _getMetadata = (0, _utils2.getMetadata)(extensionKey, data),
150
173
  subtitle = _getMetadata.subtitle;
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
19
19
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
20
20
  var PACKAGE_DATA = {
21
21
  packageName: "@atlaskit/smart-card",
22
- packageVersion: "44.23.1",
22
+ packageVersion: "44.23.3",
23
23
  componentName: 'linkUrl'
24
24
  };
25
25
  var LinkUrl = function LinkUrl(_ref) {
@@ -1,4 +1,5 @@
1
1
  import { extractLink } from '@atlaskit/link-extractors';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { CardAction } from '../../constants';
3
4
  import { getDefinitionId, getExtensionKey, getResourceType } from '../../state/helpers';
4
5
  import { openUrl } from '../../utils';
@@ -7,6 +8,7 @@ import { getActionsFromJsonLd } from '../common/actions/extractActions';
7
8
  export const extractInvokeViewAction = ({
8
9
  actionOptions,
9
10
  appearance,
11
+ transformUrl,
10
12
  id,
11
13
  response
12
14
  }, force) => {
@@ -21,7 +23,14 @@ export const extractInvokeViewAction = ({
21
23
  const viewActionExists = getActionsFromJsonLd(data).find(action => action['@type'] === 'ViewAction');
22
24
  if (url && (viewActionExists || force)) {
23
25
  return {
24
- actionFn: async () => openUrl(url),
26
+ actionFn: async () => {
27
+ if (fg('platform_smartlink_xpc_url_wrapping')) {
28
+ var _transformUrl;
29
+ const destinationUrl = (_transformUrl = transformUrl === null || transformUrl === void 0 ? void 0 : transformUrl(url)) !== null && _transformUrl !== void 0 ? _transformUrl : url;
30
+ return openUrl(destinationUrl);
31
+ }
32
+ return openUrl(url);
33
+ },
25
34
  actionSubjectId: 'shortcutGoToLink',
26
35
  actionType: 'ViewAction',
27
36
  definitionId: getDefinitionId(response),
@@ -18,6 +18,7 @@ export const extractFlexibleCardActions = ({
18
18
  product,
19
19
  response,
20
20
  rovoConfig,
21
+ transformUrl,
21
22
  url,
22
23
  isPreviewPanelAvailable,
23
24
  openPreviewPanel
@@ -44,7 +45,10 @@ export const extractFlexibleCardActions = ({
44
45
  origin,
45
46
  response,
46
47
  isPreviewPanelAvailable,
47
- openPreviewPanel
48
+ openPreviewPanel,
49
+ ...(fg('platform_smartlink_xpc_url_wrapping') ? {
50
+ transformUrl
51
+ } : undefined)
48
52
  }),
49
53
  [ActionName.AutomationAction]: extractAutomationAction(response),
50
54
  [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig),