@atlaskit/smart-card 32.7.7 → 32.7.9

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 (82) 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/actions/index.js +13 -38
  5. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +59 -306
  6. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +2 -7
  7. package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +99 -6
  8. package/dist/cjs/utils/analytics/analytics.js +27 -301
  9. package/dist/cjs/utils/analytics/index.js +0 -66
  10. package/dist/cjs/view/CardWithUrl/component.js +7 -23
  11. package/dist/cjs/view/CardWithUrl/loader.js +14 -5
  12. package/dist/cjs/view/EmbedModal/components/analytics/index.js +88 -32
  13. package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +4 -13
  14. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +4 -16
  15. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +1 -5
  16. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -2
  17. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +21 -53
  18. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +0 -1
  19. package/dist/cjs/view/HoverCard/index.js +15 -8
  20. package/dist/cjs/view/LinkUrl/index.js +1 -1
  21. package/dist/cjs/view/common/UnauthorisedViewContent.js +3 -9
  22. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +8 -7
  23. package/dist/es2019/state/actions/index.js +13 -38
  24. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +7 -239
  25. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +0 -3
  26. package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +97 -2
  27. package/dist/es2019/utils/analytics/analytics.js +2 -286
  28. package/dist/es2019/utils/analytics/index.js +1 -1
  29. package/dist/es2019/view/CardWithUrl/component.js +8 -24
  30. package/dist/es2019/view/CardWithUrl/loader.js +9 -1
  31. package/dist/es2019/view/EmbedModal/components/analytics/index.js +88 -32
  32. package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +4 -13
  33. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +4 -16
  34. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +1 -5
  35. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -1
  36. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +21 -53
  37. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +0 -1
  38. package/dist/es2019/view/HoverCard/index.js +10 -2
  39. package/dist/es2019/view/LinkUrl/index.js +1 -1
  40. package/dist/es2019/view/common/UnauthorisedViewContent.js +3 -9
  41. package/dist/esm/extractors/action/extract-invoke-preview-action.js +8 -7
  42. package/dist/esm/state/actions/index.js +13 -38
  43. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +60 -307
  44. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +2 -7
  45. package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +95 -5
  46. package/dist/esm/utils/analytics/analytics.js +26 -300
  47. package/dist/esm/utils/analytics/index.js +1 -1
  48. package/dist/esm/view/CardWithUrl/component.js +8 -24
  49. package/dist/esm/view/CardWithUrl/loader.js +14 -5
  50. package/dist/esm/view/EmbedModal/components/analytics/index.js +88 -32
  51. package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +4 -13
  52. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +4 -16
  53. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +1 -5
  54. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -1
  55. package/dist/esm/view/HoverCard/components/HoverCardContent.js +21 -53
  56. package/dist/esm/view/HoverCard/components/views/resolved/index.js +0 -1
  57. package/dist/esm/view/HoverCard/index.js +14 -4
  58. package/dist/esm/view/LinkUrl/index.js +1 -1
  59. package/dist/esm/view/common/UnauthorisedViewContent.js +3 -9
  60. package/dist/types/common/analytics/generated/analytics.types.d.ts +16 -2
  61. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +6 -102
  62. package/dist/types/state/hooks/useSmartLink.d.ts +0 -12
  63. package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  64. package/dist/types/utils/analytics/analytics.d.ts +1 -51
  65. package/dist/types/utils/analytics/index.d.ts +1 -1
  66. package/dist/types/utils/analytics/types.d.ts +0 -60
  67. package/dist/types/utils/mocks.d.ts +0 -12
  68. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -0
  69. package/dist/types/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  70. package/dist/types/view/common/UnauthorisedViewContent.d.ts +1 -1
  71. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +16 -2
  72. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +6 -102
  73. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +0 -12
  74. package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  75. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +1 -51
  76. package/dist/types-ts4.5/utils/analytics/index.d.ts +1 -1
  77. package/dist/types-ts4.5/utils/analytics/types.d.ts +0 -60
  78. package/dist/types-ts4.5/utils/mocks.d.ts +0 -12
  79. package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +1 -0
  80. package/dist/types-ts4.5/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  81. package/dist/types-ts4.5/view/common/UnauthorisedViewContent.d.ts +1 -1
  82. package/package.json +2 -5
@@ -5,9 +5,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
5
5
  var _excluded = ["action", "onClick", "onError"];
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useCallback, useState } from 'react';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
10
- import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
11
9
  import useInvoke from '../../../../../../state/hooks/use-invoke';
12
10
  import { getInvokeFailureReason } from '../../../../../../state/hooks/use-invoke/utils';
13
11
  import useResolve from '../../../../../../state/hooks/use-resolve';
@@ -22,7 +20,6 @@ var ServerAction = function ServerAction(_ref) {
22
20
  _useState2 = _slicedToArray(_useState, 2),
23
21
  isLoading = _useState2[0],
24
22
  setIsLoading = _useState2[1];
25
- var analytics = useFlexibleUiAnalyticsContext();
26
23
  var invoke = useInvoke();
27
24
  var reload = useResolve();
28
25
  var _useAnalyticsEvents = useAnalyticsEvents(),
@@ -39,16 +36,10 @@ var ServerAction = function ServerAction(_ref) {
39
36
  smartLinkActionType = (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.actionType;
40
37
  _context.prev = 2;
41
38
  setIsLoading(true);
42
- if (fg('platform_migrate-some-ui-events-smart-card')) {
43
- if (smartLinkActionType === 'FollowEntityAction' || smartLinkActionType === 'UnfollowEntityAction') {
44
- fireEvent('ui.button.clicked.smartLinkFollowButton', {});
45
- } else {
46
- fireEvent("ui.button.clicked.".concat(smartLinkActionType), {});
47
- }
39
+ if (smartLinkActionType === 'FollowEntityAction' || smartLinkActionType === 'UnfollowEntityAction') {
40
+ fireEvent('ui.button.clicked.smartLinkFollowButton', {});
48
41
  } else {
49
- analytics === null || analytics === void 0 || analytics.ui.smartLinkServerActionClickedEvent({
50
- smartLinkActionType: smartLinkActionType
51
- });
42
+ fireEvent("ui.button.clicked.".concat(smartLinkActionType), {});
52
43
  }
53
44
  fireEvent('track.smartLinkQuickAction.started', {
54
45
  smartLinkActionType: smartLinkActionType
@@ -87,7 +78,7 @@ var ServerAction = function ServerAction(_ref) {
87
78
  return _context.stop();
88
79
  }
89
80
  }, _callee, null, [[2, 17]]);
90
- })), [action, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, onErrorCallback, reload, fireEvent]);
81
+ })), [action, invoke, onClick, onErrorCallback, reload, fireEvent]);
91
82
  return /*#__PURE__*/React.createElement(Action, _extends({}, props, {
92
83
  isLoading: isLoading,
93
84
  onClick: handleClick
@@ -11,10 +11,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
11
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
12
  import { jsx } from '@emotion/react';
13
13
  import DropdownMenu from '@atlaskit/dropdown-menu';
14
- import { fg } from '@atlaskit/platform-feature-flags';
15
14
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
16
15
  import extractLozengeActionItems from '../../../../../../extractors/action/extract-lozenge-action-items';
17
- import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
18
16
  import useInvoke from '../../../../../../state/hooks/use-invoke';
19
17
  import { isInvokeCustomError } from '../../../../../../state/hooks/use-invoke/utils';
20
18
  import useResolve from '../../../../../../state/hooks/use-resolve';
@@ -69,8 +67,6 @@ var LozengeAction = function LozengeAction(_ref) {
69
67
  errorMessage = _useState12[0],
70
68
  setErrorMessage = _useState12[1];
71
69
  var reload = useResolve();
72
- //TODO EDM-6583 Replace usage of useFlexibleUiAnalyticsContext with linking platform analytics context from find team.
73
- var analytics = useFlexibleUiAnalyticsContext();
74
70
  var invoke = useInvoke();
75
71
  var _useAnalyticsEvents = useAnalyticsEvents(),
76
72
  fireEvent = _useAnalyticsEvents.fireEvent;
@@ -95,11 +91,7 @@ var LozengeAction = function LozengeAction(_ref) {
95
91
  _context.next = 24;
96
92
  break;
97
93
  }
98
- if (fg('platform_migrate-some-ui-events-smart-card')) {
99
- fireEvent('ui.button.clicked.smartLinkStatusLozenge', {});
100
- } else {
101
- analytics === null || analytics === void 0 || analytics.ui.smartLinkLozengeActionClickedEvent();
102
- }
94
+ fireEvent('ui.button.clicked.smartLinkStatusLozenge', {});
103
95
  fireEvent('track.smartLinkQuickAction.started', {
104
96
  smartLinkActionType: TrackQuickActionType.StatusUpdate
105
97
  });
@@ -146,7 +138,7 @@ var LozengeAction = function LozengeAction(_ref) {
146
138
  return function (_x) {
147
139
  return _ref3.apply(this, arguments);
148
140
  };
149
- }(), [action.read, analytics, invoke, isLoaded, text, fireEvent]);
141
+ }(), [action.read, invoke, isLoaded, text, fireEvent]);
150
142
  var trigger = useCallback(function (props) {
151
143
  return jsx(LozengeActionTrigger, _extends({}, props, {
152
144
  appearance: selected.appearance,
@@ -162,11 +154,7 @@ var LozengeAction = function LozengeAction(_ref) {
162
154
  while (1) switch (_context2.prev = _context2.next) {
163
155
  case 0:
164
156
  _context2.prev = 0;
165
- if (fg('platform_migrate-some-ui-events-smart-card')) {
166
- fireEvent('ui.button.clicked.smartLinkStatusListItem', {});
167
- } else {
168
- analytics === null || analytics === void 0 || analytics.ui.smartLinkLozengeActionListItemClickedEvent();
169
- }
157
+ fireEvent('ui.button.clicked.smartLinkStatusListItem', {});
170
158
  updateAction = action === null || action === void 0 ? void 0 : action.update;
171
159
  if (!(updateAction && id)) {
172
160
  _context2.next = 17;
@@ -217,7 +205,7 @@ var LozengeAction = function LozengeAction(_ref) {
217
205
  return function (_x2, _x3, _x4) {
218
206
  return _ref4.apply(this, arguments);
219
207
  };
220
- }(), [action === null || action === void 0 ? void 0 : action.update, analytics, invoke, linkId, reload, url, fireEvent]);
208
+ }(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url, fireEvent]);
221
209
  var dropdownItemGroup = useMemo(function () {
222
210
  if (errorMessage) {
223
211
  return jsx(LozengeActionError, {
@@ -43,11 +43,7 @@ var LozengeActionError = function LozengeActionError(_ref) {
43
43
  }, [reload, url]);
44
44
  var handlePreviewOpen = useCallback(function () {
45
45
  if (isPreviewAvailable) {
46
- if (fg('platform_migrate-some-ui-events-smart-card')) {
47
- fireEvent('ui.button.clicked.smartLinkStatusOpenPreview', {});
48
- } else {
49
- analytics === null || analytics === void 0 || analytics.ui.smartLinkLozengeActionErrorOpenPreviewClickedEvent();
50
- }
46
+ fireEvent('ui.button.clicked.smartLinkStatusOpenPreview', {});
51
47
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
52
48
  invokePreviewAction && invoke(invokePreviewAction);
53
49
  } else {
@@ -20,7 +20,7 @@ import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAna
20
20
  import CustomPopupContainer from '../components/CustomPopupContainer';
21
21
  import HoverCardContent from '../components/HoverCardContent';
22
22
  import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
23
- var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
23
+ export var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
24
24
  var FADE_IN_DELAY = 500;
25
25
  var FADE_OUT_DELAY = 300;
26
26
  var RESOLVE_DELAY = 100;
@@ -8,7 +8,6 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
8
8
  import { jsx } from '@emotion/react';
9
9
  import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
10
10
  import { useSmartLinkContext } from '@atlaskit/link-provider';
11
- import { fg } from '@atlaskit/platform-feature-flags';
12
11
  import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
13
12
  import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
14
13
  import { useSmartLinkAnalytics } from '../../../state/analytics';
@@ -57,17 +56,13 @@ var HoverCardContent = function HoverCardContent(_ref) {
57
56
  var isAISummaryEnabled = getIsAISummaryEnabled(isAdminHubAIEnabled, cardState.details);
58
57
  var services = getServices(linkState.details);
59
58
  var statusRef = useRef(linkStatus);
60
- var analyticsRef = useRef(analytics);
61
59
  var fireEventRef = useRef(fireEvent);
62
60
  var definitionIdRef = useRef(definitionId);
63
61
  useEffect(function () {
64
62
  /**
65
- * Must access current analytics object value via ref because its not stable
63
+ * Must access object value via ref because its not stable
66
64
  * and it can trigger useEffect to re-run below
67
65
  */
68
- if (analyticsRef.current !== analytics) {
69
- analyticsRef.current = analytics;
70
- }
71
66
  if (statusRef.current !== linkStatus) {
72
67
  statusRef.current = linkStatus;
73
68
  }
@@ -77,66 +72,39 @@ var HoverCardContent = function HoverCardContent(_ref) {
77
72
  if (definitionIdRef.current !== definitionId) {
78
73
  definitionIdRef.current = definitionId;
79
74
  }
80
- }, [analytics, linkStatus, fireEvent, definitionId]);
75
+ }, [linkStatus, fireEvent, definitionId]);
81
76
  useEffect(function () {
77
+ var _definitionIdRef$curr;
82
78
  var previewDisplay = 'card';
83
79
  var previewInvokeMethod = 'mouse_hover';
84
80
  var cardOpenTime = Date.now();
85
81
  var fireEventCurrent = fireEventRef.current;
86
- if (fg('platform_migrate-some-ui-events-smart-card')) {
87
- var _definitionIdRef$curr;
88
- fireEventCurrent('ui.hoverCard.viewed', {
89
- previewDisplay: previewDisplay,
90
- previewInvokeMethod: previewInvokeMethod,
91
- definitionId: (_definitionIdRef$curr = definitionIdRef.current) !== null && _definitionIdRef$curr !== void 0 ? _definitionIdRef$curr : null
92
- });
93
- } else {
94
- analyticsRef.current.ui.hoverCardViewedEvent({
82
+ fireEventCurrent('ui.hoverCard.viewed', {
83
+ previewDisplay: previewDisplay,
84
+ previewInvokeMethod: previewInvokeMethod,
85
+ definitionId: (_definitionIdRef$curr = definitionIdRef.current) !== null && _definitionIdRef$curr !== void 0 ? _definitionIdRef$curr : null
86
+ });
87
+ return function () {
88
+ var _definitionIdRef$curr2;
89
+ var hoverTime = Date.now() - cardOpenTime;
90
+ fireEventCurrent('ui.hoverCard.dismissed', {
95
91
  previewDisplay: previewDisplay,
96
92
  previewInvokeMethod: previewInvokeMethod,
97
- status: statusRef.current
93
+ hoverTime: hoverTime,
94
+ definitionId: (_definitionIdRef$curr2 = definitionIdRef.current) !== null && _definitionIdRef$curr2 !== void 0 ? _definitionIdRef$curr2 : null
98
95
  });
99
- }
100
- return function () {
101
- var hoverTime = Date.now() - cardOpenTime;
102
- if (fg('platform_migrate-some-ui-events-smart-card')) {
103
- var _definitionIdRef$curr2;
104
- fireEventCurrent('ui.hoverCard.dismissed', {
105
- previewDisplay: previewDisplay,
106
- previewInvokeMethod: previewInvokeMethod,
107
- hoverTime: hoverTime,
108
- definitionId: (_definitionIdRef$curr2 = definitionIdRef.current) !== null && _definitionIdRef$curr2 !== void 0 ? _definitionIdRef$curr2 : null
109
- });
110
- } else {
111
- analyticsRef.current.ui.hoverCardDismissedEvent({
112
- previewDisplay: previewDisplay,
113
- previewInvokeMethod: previewInvokeMethod,
114
- hoverTime: hoverTime,
115
- status: statusRef.current
116
- });
117
- }
118
96
  };
119
97
  }, []);
120
98
  var onClick = useCallback(function (event) {
121
99
  var isModifierKeyPressed = isSpecialEvent(event);
122
- if (fg('platform_migrate-some-ui-events-smart-card')) {
123
- fireEvent('ui.smartLink.clicked.titleGoToLink', {
124
- id: id,
125
- display: CardDisplay.HoverCardPreview,
126
- isModifierKeyPressed: isModifierKeyPressed,
127
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
128
- });
129
- } else {
130
- analytics.ui.cardClickedEvent({
131
- id: id,
132
- display: CardDisplay.HoverCardPreview,
133
- status: cardState.status,
134
- isModifierKeyPressed: isModifierKeyPressed,
135
- actionSubjectId: 'titleGoToLink'
136
- });
137
- }
100
+ fireEvent('ui.smartLink.clicked.titleGoToLink', {
101
+ id: id,
102
+ display: CardDisplay.HoverCardPreview,
103
+ isModifierKeyPressed: isModifierKeyPressed,
104
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
105
+ });
138
106
  fireLinkClickedEvent(createAnalyticsEvent)(event);
139
- }, [createAnalyticsEvent, cardState.status, analytics.ui, id, fireEvent, definitionId]);
107
+ }, [createAnalyticsEvent, id, fireEvent, definitionId]);
140
108
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
141
109
  var _getMetadata = getMetadata(extensionKey, data),
142
110
  subtitle = _getMetadata.subtitle;
@@ -42,7 +42,6 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
42
42
  display: CardDisplay.HoverCardPreview
43
43
  });
44
44
  fireEvent('ui.smartLink.renderSuccess', {
45
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
46
45
  display: CardDisplay.HoverCardPreview
47
46
  });
48
47
  } else {
@@ -1,3 +1,6 @@
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; }
1
4
  /**
2
5
  * @jsxRuntime classic
3
6
  * @jsx jsx
@@ -15,7 +18,8 @@ import { CardDisplay } from '../../constants';
15
18
  import { useSmartLinkAnalytics } from '../../state';
16
19
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
17
20
  import { SmartLinkModalProvider } from '../../state/modal';
18
- import { HoverCardComponent } from './components/HoverCardComponent';
21
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
22
+ import { HOVER_CARD_SOURCE, HoverCardComponent } from './components/HoverCardComponent';
19
23
  var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
20
24
  var _useAnalyticsEvents = useAnalyticsEvents(),
21
25
  fireEvent = _useAnalyticsEvents.fireEvent;
@@ -23,17 +27,23 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
23
27
  id = props.id,
24
28
  children = props.children;
25
29
  var analytics = useSmartLinkAnalytics(url, id);
30
+ var analyticsContext = useSmartLinkAnalyticsContext({
31
+ display: CardDisplay.HoverCardPreview,
32
+ id: id,
33
+ source: HOVER_CARD_SOURCE,
34
+ url: url
35
+ });
26
36
  var onError = useCallback(function (error, info) {
27
37
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
28
38
  startUfoExperience('smart-link-rendered', id || 'NULL');
29
39
  failUfoExperience('smart-link-rendered', id || 'NULL');
30
40
  failUfoExperience('smart-link-authenticated', id || 'NULL');
31
- fireEvent('ui.smartLink.renderFailed', {
41
+ fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
32
42
  display: CardDisplay.HoverCardPreview,
33
43
  id: id !== null && id !== void 0 ? id : null,
34
44
  error: error,
35
45
  errorInfo: info
36
- });
46
+ }));
37
47
  } else {
38
48
  analytics.ui.renderFailedEvent({
39
49
  display: CardDisplay.HoverCardPreview,
@@ -42,7 +52,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
42
52
  errorInfo: info
43
53
  });
44
54
  }
45
- }, [analytics.ui, id, fireEvent]);
55
+ }, [analytics.ui, analyticsContext, id, fireEvent]);
46
56
  return jsx(ErrorBoundary, {
47
57
  fallback: children,
48
58
  onError: onError
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "32.7.7",
16
+ packageVersion: "32.7.9",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
6
5
  import { CONTENT_URL_3P_ACCOUNT_AUTH, CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
7
6
  import { messages } from '../../messages';
@@ -13,17 +12,12 @@ var UnauthorisedViewContent = function UnauthorisedViewContent(_ref) {
13
12
  var providerName = _ref.providerName,
14
13
  isProductIntegrationSupported = _ref.isProductIntegrationSupported,
15
14
  _ref$testId = _ref.testId,
16
- testId = _ref$testId === void 0 ? 'unauthorised-view-content' : _ref$testId,
17
- analytics = _ref.analytics;
15
+ testId = _ref$testId === void 0 ? 'unauthorised-view-content' : _ref$testId;
18
16
  var _useAnalyticsEvents = useAnalyticsEvents(),
19
17
  fireEvent = _useAnalyticsEvents.fireEvent;
20
18
  var handleLearnMoreClick = useCallback(function () {
21
- if (fg('platform_migrate-some-ui-events-smart-card')) {
22
- fireEvent('ui.button.clicked.learnMore', {});
23
- } else {
24
- analytics === null || analytics === void 0 || analytics.ui.learnMoreClickedEvent();
25
- }
26
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent]);
19
+ fireEvent('ui.button.clicked.learnMore', {});
20
+ }, [fireEvent]);
27
21
  var learnMoreMessage = isProductIntegrationSupported ? messages.learn_more_about_connecting_account : messages.learn_more_about_smart_links;
28
22
  return /*#__PURE__*/React.createElement(React.Fragment, null, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_description, {
29
23
  values: {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::1e6835b50307a44a077c38d864a2c66e>>
6
+ * @codegen <<SignedSource::84c7074821df29c52dd13557dab19219>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
8
8
  */
9
9
  export type PackageMetaDataContextType = {
@@ -126,6 +126,10 @@ export type SmartLinkQuickActionFailedAttributesType = {
126
126
  export type ConsentModalViewedAttributesType = {
127
127
  definitionId: string | null;
128
128
  };
129
+ export type EmbedPreviewModalViewedAttributesType = {
130
+ origin: 'smartLinkCard' | 'smartLinkEmbed' | 'smartLinkInline' | 'smartLinkPreviewHoverCard' | null;
131
+ size: 'large' | 'small' | null;
132
+ };
129
133
  export type SmartLinkConnectSucceededAttributesType = {
130
134
  definitionId: string | null;
131
135
  };
@@ -200,6 +204,11 @@ export type ConsentModalClosedAttributesType = {
200
204
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
201
205
  definitionId: string | null;
202
206
  };
207
+ export type ModalClosedEmbedPreviewAttributesType = {
208
+ origin: 'smartLinkCard' | 'smartLinkEmbed' | 'smartLinkInline' | 'smartLinkPreviewHoverCard' | null;
209
+ previewTime: number | null;
210
+ size: 'large' | 'small' | null;
211
+ };
203
212
  export type ButtonClickedLearnMoreAttributesType = {};
204
213
  export type ButtonClickedSmartLinkStatusLozengeAttributesType = {};
205
214
  export type ButtonClickedSmartLinkStatusListItemAttributesType = {};
@@ -214,7 +223,6 @@ export type ButtonClickedEmbedPreviewResizeAttributesType = {
214
223
  };
215
224
  export type SmartLinkRenderSuccessAttributesType = {
216
225
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
217
- definitionId: string | null;
218
226
  };
219
227
  export type SmartLinkRenderFailedAttributesType = {
220
228
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
@@ -301,6 +309,9 @@ export type AnalyticsEventAttributes = {
301
309
  /**
302
310
  * fires an event which represents the connect account page being opened. */
303
311
  'screen.consentModal.viewed': ConsentModalViewedAttributesType;
312
+ /**
313
+ * Fires an event that represents when a user view a modal. */
314
+ 'screen.embedPreviewModal.viewed': EmbedPreviewModalViewedAttributesType;
304
315
  /**
305
316
  * fires an event that represents an account successfully being connected via a Smart Link. */
306
317
  'operational.smartLink.connectSucceeded': SmartLinkConnectSucceededAttributesType;
@@ -343,6 +354,9 @@ export type AnalyticsEventAttributes = {
343
354
  /**
344
355
  * fires an event that represents when a user closed the authentication window without authenticating after opening it. */
345
356
  'ui.consentModal.closed': ConsentModalClosedAttributesType;
357
+ /**
358
+ * Fires an event that represents when a user close a modal. */
359
+ 'ui.modal.closed.embedPreview': ModalClosedEmbedPreviewAttributesType;
346
360
  /**
347
361
  * fires an event that signifies that a "Learn More" link was clicked on an unauthenticated card */
348
362
  'ui.button.clicked.learnMore': ButtonClickedLearnMoreAttributesType;
@@ -1,4 +1,4 @@
1
- import { type InvokeFailedEventProps, type InvokeSucceededEventProps, type UiActionClickedEventProps, type UiAuthAlternateAccountEventProps, type UiAuthEventProps, type UiCardClickedEventProps, type UiClosedAuthEventProps, type UiHoverCardDismissedEventProps, type UiHoverCardOpenLinkClickedEventProps, type UiHoverCardViewedEventProps, type UiRenderFailedEventProps, type UiRenderSuccessEventProps, type UiServerActionClickedEventProps } from '../../utils/analytics/types';
1
+ import { type InvokeFailedEventProps, type InvokeSucceededEventProps, type UiActionClickedEventProps, type UiRenderFailedEventProps, type UiRenderSuccessEventProps } from '../../utils/analytics/types';
2
2
  import { type AnalyticsName, type AnalyticsPayload } from '../../utils/types';
3
3
  /**
4
4
  * This hook provides usage of Smart Link analytics outside of the Card component.
@@ -11,48 +11,15 @@ import { type AnalyticsName, type AnalyticsPayload } from '../../utils/types';
11
11
  */
12
12
  export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLocation?: string) => {
13
13
  ui: {
14
- /**
15
- * This fires an event that represents when a user clicks on the authentication
16
- * call to action with no current authenticated account. (i.e. Connect to Preview).
17
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
18
- * @param definitionId The definitionId of the Smart Link resolver invoked.
19
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
20
- * @returns
21
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
22
- */
23
- authEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiAuthEventProps) => void;
24
- /**
25
- * This fires an event that represents when a user clicks on the authentication
26
- * call to action with a forbidden authenticated account. (i.e. Try another account).
27
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
28
- * @param definitionId The definitionId of the Smart Link resolver invoked.
29
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
30
- * @returns
31
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
32
- */
33
- authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiAuthAlternateAccountEventProps) => void;
34
14
  /**
35
15
  * This fires an event that represents when a user
36
16
  * click a button.
37
17
  * @param data A partial analytics event payload
18
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
38
19
  */
39
20
  buttonClickedEvent: (data: Partial<AnalyticsPayload> & {
40
21
  actionSubjectId: Required<string>;
41
22
  }) => void;
42
- /**
43
- * This fires an event that represents when a user clicks on a Smart Link.
44
- * @param id The unique ID for this Smart Link.
45
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
46
- * @param status What status the Smart Link is currently in (e.g. resolved, unresolved)
47
- * @param definitionId The definitionId of the Smart Link resolver invoked.
48
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
49
- * @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
50
- * @param location Where the Smart Link is currently rendered.
51
- * @param destinationProduct The product the Smart Link is linked to.
52
- * @returns
53
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
54
- */
55
- cardClickedEvent: ({ id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId, }: UiCardClickedEventProps) => void;
56
23
  /**
57
24
  * This fires an event that represents when a user clicks on a Smart Link action.
58
25
  * Note: This also starts the UFO smart-link-action-invocation experience.
@@ -63,28 +30,10 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
63
30
  * @returns
64
31
  */
65
32
  actionClickedEvent: ({ id, actionType, display, extensionKey: overrideExtensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiActionClickedEventProps) => void;
66
- /**
67
- * This fires an event that represents when a user clicks on a hover preview's "navigate to link" button.
68
- * https://product-fabric.atlassian.net/wiki/spaces/EM/pages/3206743323/Analytics+Metrics+-+Hover+Previews
69
- * @param previewDisplay What format the preview is in.
70
- * @param definitionId The definitionId of the Smart Link resolver invoked.
71
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
72
- * @param previewInvokeMethod How the preview was triggered.
73
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
74
- */
75
- hoverCardOpenLinkClickedEvent: ({ previewDisplay, definitionId, extensionKey, destinationProduct, destinationSubproduct, location, previewInvokeMethod, }: UiHoverCardOpenLinkClickedEventProps) => void;
76
- /**
77
- * This fires an event that represents when a user closed the authentication window without authenticating after opening it.
78
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
79
- * @param definitionId The definitionId of the Smart Link resolver invoked.
80
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
81
- * @returns
82
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
83
- */
84
- closedAuthEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiClosedAuthEventProps) => void;
85
33
  /**
86
34
  * This fires an event that represents when a user close a modal.
87
35
  * @param data A partial analytics event payload
36
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
88
37
  */
89
38
  modalClosedEvent: (data: Partial<AnalyticsPayload> & {
90
39
  actionSubjectId: Required<string>;
@@ -97,6 +46,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
97
46
  * @param definitionId The definitionId of the Smart Link resolver invoked.
98
47
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
99
48
  * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
49
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
100
50
  */
101
51
  renderSuccessEvent: ({ display, status, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, canBeDatasource, }: UiRenderSuccessEventProps) => void;
102
52
  /**
@@ -105,55 +55,9 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
105
55
  * @param id The unique ID for this Smart Link.
106
56
  * @param error: An error representing why the Smart Link render failed.
107
57
  * @param errorInfo: Additional details about the error including the stack trace.
58
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
108
59
  */
109
60
  renderFailedEvent: ({ display, id, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiRenderFailedEventProps) => void;
110
- /**
111
- * This fires an event that represents a hover preview being opened.
112
- * @param hoverDisplay Whether the hover preview was displayed as a card or embed.
113
- * @param definitionId The definitionId of the Smart Link resolver invoked.
114
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
115
- * @param previewInvokeMethod How the preview was triggered.
116
- * @returns
117
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
118
- */
119
- hoverCardViewedEvent: ({ previewDisplay, previewInvokeMethod, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, status, }: UiHoverCardViewedEventProps) => void;
120
- /**
121
- * This fires an event that represents a hover preview being dismissed.
122
- * @param hoverDisplay Whether the hover preview was displayed as a card or embed.
123
- * @param hoverTime The duration that the user hovered over a Smart Link before the preview was dismissed.
124
- * @param definitionId The definitionId of the Smart Link resolver invoked.
125
- * @param extensionKey The extensionKey of the Smart Link resolver invoked.
126
- * @param previewInvokeMethod How the preview was triggered.
127
- * @returns
128
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
129
- */
130
- hoverCardDismissedEvent: ({ id, previewDisplay, hoverTime, previewInvokeMethod, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, status, }: UiHoverCardDismissedEventProps) => void;
131
- /**
132
- * Fires an event that signifies that a "Learn More" link was clicked on an unauthenticated card
133
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
134
- * @param location The location where a link is displayed (jiraWebLinks, confluencePages etc)
135
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
136
- */
137
- learnMoreClickedEvent: () => void;
138
- /**
139
- * Fires an event that represent a click was performed on a Status Lozenge
140
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
141
- */
142
- smartLinkLozengeActionClickedEvent: () => void;
143
- /**
144
- * Fires an event that represent a click was performed on a Status Lozenge's dropdown item
145
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
146
- */
147
- smartLinkLozengeActionListItemClickedEvent: () => void;
148
- /**
149
- * Fires an event that represent a click was performed on a Status Lozenge open preview button
150
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
151
- */
152
- smartLinkLozengeActionErrorOpenPreviewClickedEvent: () => void;
153
- /**
154
- * @deprecated consider removing when cleaning up FF platform_migrate-some-ui-events-smart-card
155
- */
156
- smartLinkServerActionClickedEvent: (props: UiServerActionClickedEventProps) => void;
157
61
  };
158
62
  operational: {
159
63
  /**
@@ -177,7 +81,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
177
81
  screen: {
178
82
  /**
179
83
  * This fires an event that represents when a user view a modal.
180
- * @param data A partial analytics event payload
84
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
181
85
  */
182
86
  modalViewedEvent: (data: Partial<AnalyticsPayload> & {
183
87
  name: Extract<AnalyticsName, 'embedPreviewModal'>;
@@ -10,27 +10,15 @@ export declare function useSmartLink(id: string, url: string): {
10
10
  config: (import("@atlaskit/link-provider").CardProviderCacheOpts & import("@atlaskit/link-provider").CardAuthFlowOpts) | undefined;
11
11
  analytics: {
12
12
  ui: {
13
- authEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiAuthEventProps) => void;
14
- authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiAuthAlternateAccountEventProps) => void;
15
13
  buttonClickedEvent: (data: Partial<import("../..").AnalyticsPayload> & {
16
14
  actionSubjectId: string;
17
15
  }) => void;
18
- cardClickedEvent: ({ id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId, }: import("../../utils/analytics/types").UiCardClickedEventProps) => void;
19
16
  actionClickedEvent: ({ id, actionType, display, extensionKey: overrideExtensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiActionClickedEventProps) => void;
20
- hoverCardOpenLinkClickedEvent: ({ previewDisplay, definitionId, extensionKey, destinationProduct, destinationSubproduct, location, previewInvokeMethod, }: import("../../utils/analytics/types").UiHoverCardOpenLinkClickedEventProps) => void;
21
- closedAuthEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiClosedAuthEventProps) => void;
22
17
  modalClosedEvent: (data: Partial<import("../..").AnalyticsPayload> & {
23
18
  actionSubjectId: string;
24
19
  }) => void;
25
20
  renderSuccessEvent: ({ display, status, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, canBeDatasource, }: import("../../utils/analytics/types").UiRenderSuccessEventProps) => void;
26
21
  renderFailedEvent: ({ display, id, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiRenderFailedEventProps) => void;
27
- hoverCardViewedEvent: ({ previewDisplay, previewInvokeMethod, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, status, }: import("../../utils/analytics/types").UiHoverCardViewedEventProps) => void;
28
- hoverCardDismissedEvent: ({ id, previewDisplay, hoverTime, previewInvokeMethod, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, status, }: import("../../utils/analytics/types").UiHoverCardDismissedEventProps) => void;
29
- learnMoreClickedEvent: () => void;
30
- smartLinkLozengeActionClickedEvent: () => void;
31
- smartLinkLozengeActionListItemClickedEvent: () => void;
32
- smartLinkLozengeActionErrorOpenPreviewClickedEvent: () => void;
33
- smartLinkServerActionClickedEvent: (props: import("../../utils/analytics/types").UiServerActionClickedEventProps) => void;
34
22
  };
35
23
  operational: {
36
24
  invokeSucceededEvent: ({ id, actionType, display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").InvokeSucceededEventProps) => void;
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
3
+ import { context } from './analytics';
2
4
  type SmartLinkAnalyticsContextProps = {
3
5
  url: string;
4
6
  display?: string;
@@ -6,6 +8,18 @@ type SmartLinkAnalyticsContextProps = {
6
8
  source?: string;
7
9
  children?: React.ReactNode;
8
10
  };
11
+ type SmartLinkAnalyticsContextType = {
12
+ source?: string;
13
+ attributes?: typeof context & ReturnType<typeof getResolvedAttributes> & {
14
+ display?: string;
15
+ id?: string;
16
+ };
17
+ };
18
+ /**
19
+ * Provides an analytics context data to supply attributes to events based on a URL
20
+ * and the link state in the store
21
+ */
22
+ export declare const useSmartLinkAnalyticsContext: ({ display, id, source, url, }: Exclude<SmartLinkAnalyticsContextProps, 'children'>) => SmartLinkAnalyticsContextType | undefined;
9
23
  /**
10
24
  * Provides an analytics context to supply attributes to events based on a URL
11
25
  * and the link state in the store