@atlaskit/smart-card 26.0.0 → 26.1.0
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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +37 -0
- package/dist/cjs/state/hooks/use-invoke/index.js +28 -8
- package/dist/cjs/utils/actions/create-status-update-request.js +3 -2
- package/dist/cjs/utils/analytics/analytics.js +198 -126
- package/dist/cjs/utils/analytics/index.js +18 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
- package/dist/cjs/view/CardWithUrl/component.js +2 -1
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/index.js +43 -30
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +2 -1
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +37 -3
- package/dist/es2019/state/hooks/use-invoke/index.js +23 -9
- package/dist/es2019/utils/actions/create-status-update-request.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +66 -0
- package/dist/es2019/utils/analytics/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
- package/dist/es2019/view/CardWithUrl/component.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/index.js +29 -18
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +2 -1
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +39 -2
- package/dist/esm/state/hooks/use-invoke/index.js +28 -8
- package/dist/esm/utils/actions/create-status-update-request.js +3 -2
- package/dist/esm/utils/analytics/analytics.js +190 -124
- package/dist/esm/utils/analytics/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
- package/dist/esm/view/CardWithUrl/component.js +2 -1
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/index.js +43 -30
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +2 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +31 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +24 -0
- package/dist/types/state/hooks/use-invoke/index.d.ts +7 -1
- package/dist/types/state/hooks/useSmartLink.d.ts +12 -0
- package/dist/types/utils/analytics/analytics.d.ts +13 -0
- package/dist/types/utils/analytics/index.d.ts +1 -1
- package/dist/types/utils/analytics/types.d.ts +1 -0
- package/dist/types/utils/mocks.d.ts +12 -0
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/types.d.ts +1 -1
- package/package.json +1 -1
- package/report.api.md +20 -1
- package/tmp/api-report-tmp.d.ts +909 -0
|
@@ -23,6 +23,7 @@ var _extractLozengeActionItems = _interopRequireDefault(require("../../../../../
|
|
|
23
23
|
var _createStatusUpdateRequest = _interopRequireDefault(require("../../../../../utils/actions/create-status-update-request"));
|
|
24
24
|
var _useResolve = _interopRequireDefault(require("../../../../../state/hooks/use-resolve"));
|
|
25
25
|
var _types = require("./lozenge-action-error/types");
|
|
26
|
+
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
|
|
26
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
29
|
/** @jsx jsx */
|
|
@@ -72,14 +73,20 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
72
73
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
73
74
|
errorMessage = _useState12[0],
|
|
74
75
|
setErrorMessage = _useState12[1];
|
|
76
|
+
var reload = (0, _useResolve.default)();
|
|
77
|
+
//TODO EDM-6583 Replace usage of useFlexibleUiAnalyticsContext with linking platform analytics context from find team.
|
|
78
|
+
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)();
|
|
79
|
+
var invoke = (0, _useInvoke.default)({
|
|
80
|
+
started: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionStarted,
|
|
81
|
+
success: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionSuccess,
|
|
82
|
+
failed: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionFailed
|
|
83
|
+
});
|
|
75
84
|
(0, _react2.useEffect)(function () {
|
|
76
85
|
setSelected({
|
|
77
86
|
text: text,
|
|
78
87
|
appearance: appearance
|
|
79
88
|
});
|
|
80
89
|
}, [text, appearance]);
|
|
81
|
-
var invoke = (0, _useInvoke.default)();
|
|
82
|
-
var reload = (0, _useResolve.default)();
|
|
83
90
|
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
84
91
|
url = _ref2.url,
|
|
85
92
|
linkId = _ref2.id,
|
|
@@ -91,15 +98,20 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
91
98
|
while (1) switch (_context.prev = _context.next) {
|
|
92
99
|
case 0:
|
|
93
100
|
setIsOpen(args.isOpen);
|
|
94
|
-
if (!
|
|
95
|
-
_context.next =
|
|
101
|
+
if (!args.isOpen) {
|
|
102
|
+
_context.next = 22;
|
|
96
103
|
break;
|
|
97
104
|
}
|
|
98
|
-
|
|
105
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionClickedEvent();
|
|
106
|
+
if (!(!isLoaded && action !== null && action !== void 0 && action.read)) {
|
|
107
|
+
_context.next = 22;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
_context.prev = 4;
|
|
99
111
|
setIsLoading(true);
|
|
100
|
-
_context.next =
|
|
112
|
+
_context.next = 8;
|
|
101
113
|
return invoke(action.read, _extractLozengeActionItems.default);
|
|
102
|
-
case
|
|
114
|
+
case 8:
|
|
103
115
|
responseItems = _context.sent;
|
|
104
116
|
validItems = typeof text === 'string' ? validateItems(responseItems, text) : responseItems;
|
|
105
117
|
setItems(validItems);
|
|
@@ -108,31 +120,31 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
108
120
|
setErrorMessage(_types.LozengeActionErrorMessages.noData);
|
|
109
121
|
setIsLoaded(false);
|
|
110
122
|
}
|
|
111
|
-
_context.next =
|
|
123
|
+
_context.next = 19;
|
|
112
124
|
break;
|
|
113
|
-
case
|
|
114
|
-
_context.prev =
|
|
115
|
-
_context.t0 = _context["catch"](
|
|
125
|
+
case 15:
|
|
126
|
+
_context.prev = 15;
|
|
127
|
+
_context.t0 = _context["catch"](4);
|
|
116
128
|
setErrorMessage(_types.LozengeActionErrorMessages.unknown);
|
|
117
129
|
setIsLoaded(false);
|
|
118
|
-
case
|
|
119
|
-
_context.prev =
|
|
130
|
+
case 19:
|
|
131
|
+
_context.prev = 19;
|
|
120
132
|
setIsLoading(false);
|
|
121
|
-
return _context.finish(
|
|
122
|
-
case
|
|
133
|
+
return _context.finish(19);
|
|
134
|
+
case 22:
|
|
123
135
|
if (!args.isOpen) {
|
|
124
136
|
setErrorMessage(undefined);
|
|
125
137
|
}
|
|
126
|
-
case
|
|
138
|
+
case 23:
|
|
127
139
|
case "end":
|
|
128
140
|
return _context.stop();
|
|
129
141
|
}
|
|
130
|
-
}, _callee, null, [[
|
|
142
|
+
}, _callee, null, [[4, 15, 19, 22]]);
|
|
131
143
|
}));
|
|
132
144
|
return function (_x) {
|
|
133
145
|
return _ref3.apply(this, arguments);
|
|
134
146
|
};
|
|
135
|
-
}(), [action
|
|
147
|
+
}(), [action.read, analytics, invoke, isLoaded, text]);
|
|
136
148
|
var trigger = (0, _react2.useCallback)(function (props) {
|
|
137
149
|
return (0, _react.jsx)(_lozengeActionTrigger.default, (0, _extends2.default)({}, props, {
|
|
138
150
|
appearance: selected.appearance,
|
|
@@ -147,16 +159,17 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
147
159
|
while (1) switch (_context2.prev = _context2.next) {
|
|
148
160
|
case 0:
|
|
149
161
|
_context2.prev = 0;
|
|
162
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionListItemClickedEvent();
|
|
150
163
|
updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
151
164
|
if (!(updateAction && id)) {
|
|
152
|
-
_context2.next =
|
|
165
|
+
_context2.next = 16;
|
|
153
166
|
break;
|
|
154
167
|
}
|
|
155
168
|
setIsLoading(true);
|
|
156
169
|
request = (0, _createStatusUpdateRequest.default)(updateAction, id);
|
|
157
|
-
_context2.next =
|
|
170
|
+
_context2.next = 8;
|
|
158
171
|
return invoke(request);
|
|
159
|
-
case
|
|
172
|
+
case 8:
|
|
160
173
|
setSelected({
|
|
161
174
|
appearance: appearance,
|
|
162
175
|
text: text
|
|
@@ -166,16 +179,16 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
166
179
|
setIsOpen(false);
|
|
167
180
|
setItems([]);
|
|
168
181
|
if (!url) {
|
|
169
|
-
_context2.next =
|
|
182
|
+
_context2.next = 16;
|
|
170
183
|
break;
|
|
171
184
|
}
|
|
172
|
-
_context2.next =
|
|
185
|
+
_context2.next = 16;
|
|
173
186
|
return reload(url, true, undefined, linkId);
|
|
174
|
-
case
|
|
175
|
-
_context2.next =
|
|
187
|
+
case 16:
|
|
188
|
+
_context2.next = 22;
|
|
176
189
|
break;
|
|
177
|
-
case
|
|
178
|
-
_context2.prev =
|
|
190
|
+
case 18:
|
|
191
|
+
_context2.prev = 18;
|
|
179
192
|
_context2.t0 = _context2["catch"](0);
|
|
180
193
|
setIsLoading(false);
|
|
181
194
|
if (isInvokeCustomError(_context2.t0)) {
|
|
@@ -183,16 +196,16 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
183
196
|
} else {
|
|
184
197
|
setErrorMessage(_types.LozengeActionErrorMessages.updateFailed);
|
|
185
198
|
}
|
|
186
|
-
case
|
|
199
|
+
case 22:
|
|
187
200
|
case "end":
|
|
188
201
|
return _context2.stop();
|
|
189
202
|
}
|
|
190
|
-
}, _callee2, null, [[0,
|
|
203
|
+
}, _callee2, null, [[0, 18]]);
|
|
191
204
|
}));
|
|
192
205
|
return function (_x2, _x3, _x4) {
|
|
193
206
|
return _ref4.apply(this, arguments);
|
|
194
207
|
};
|
|
195
|
-
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
|
208
|
+
}(), [action === null || action === void 0 ? void 0 : action.update, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, linkId, reload, url]);
|
|
196
209
|
var dropdownItemGroup = (0, _react2.useMemo)(function () {
|
|
197
210
|
if (errorMessage) {
|
|
198
211
|
return (0, _react.jsx)(_lozengeActionError.default, {
|
|
@@ -145,7 +145,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
145
145
|
showServerActions: showServerActions,
|
|
146
146
|
ui: _styled.flexibleUiOptions,
|
|
147
147
|
url: url,
|
|
148
|
-
children: {}
|
|
148
|
+
children: {},
|
|
149
|
+
analytics: analytics
|
|
149
150
|
};
|
|
150
151
|
var onClickStopPropagation = (0, _react2.useCallback)(function (e) {
|
|
151
152
|
return e.stopPropagation();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { getUrl } from '@atlaskit/linking-common';
|
|
3
|
-
import { chunkloadFailedEvent, connectFailedEvent, connectSucceededEvent, context, instrumentEvent, invokeFailedEvent, invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
|
|
3
|
+
import { chunkloadFailedEvent, connectFailedEvent, connectSucceededEvent, context, instrumentEvent, invokeFailedEvent, invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent, uiSmartLinkStatusLozengeButtonClicked, uiSmartLinkStatusListItemButtonClicked, uiSmartLinkStatusOpenPreviewButtonClicked } from '../../utils/analytics';
|
|
4
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
5
5
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
|
-
import { trackLinkUpdated, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
7
|
+
import { trackLinkUpdated, trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
8
8
|
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
9
9
|
const applyCommonAttributes = (event, commonAttributes) => {
|
|
10
10
|
if (event && event.attributes) {
|
|
@@ -52,6 +52,7 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
52
52
|
definitionId: extractedDefinitionId,
|
|
53
53
|
extensionKey: extractedExtensionKey,
|
|
54
54
|
resourceType: extractedResourceType,
|
|
55
|
+
destinationObjectType: extractedResourceType,
|
|
55
56
|
destinationSubproduct: extractedSubproduct,
|
|
56
57
|
destinationProduct: extractedProduct,
|
|
57
58
|
location: defaultLocation
|
|
@@ -478,7 +479,19 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
478
479
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
479
480
|
* @param location The location where a link is displayed (jiraWebLinks, confluencePages etc)
|
|
480
481
|
*/
|
|
481
|
-
learnMoreClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiLearnMoreLinkClickedEvent(), commonAttributes))
|
|
482
|
+
learnMoreClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiLearnMoreLinkClickedEvent(), commonAttributes)),
|
|
483
|
+
/**
|
|
484
|
+
* Fires an event that represent a click was performed on a Status Lozenge
|
|
485
|
+
*/
|
|
486
|
+
smartLinkLozengeActionClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusLozengeButtonClicked(), commonAttributes)),
|
|
487
|
+
/**
|
|
488
|
+
* Fires an event that represent a click was performed on a Status Lozenge's dropdown item
|
|
489
|
+
*/
|
|
490
|
+
smartLinkLozengeActionListItemClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusListItemButtonClicked(), commonAttributes)),
|
|
491
|
+
/**
|
|
492
|
+
* Fires an event that represent a click was performed on a Status Lozenge open preview button
|
|
493
|
+
*/
|
|
494
|
+
smartLinkLozengeActionErrorOpenPreviewClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusOpenPreviewButtonClicked(), commonAttributes))
|
|
482
495
|
}), [defaultId, commonAttributes, dispatchAnalytics]);
|
|
483
496
|
|
|
484
497
|
/** Contains all operational analytics events */
|
|
@@ -725,6 +738,27 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
725
738
|
linkUpdated: props => dispatchAnalytics(applyCommonAttributes(trackLinkUpdated({
|
|
726
739
|
...commonAttributes,
|
|
727
740
|
...props
|
|
741
|
+
}), commonAttributes)),
|
|
742
|
+
/**
|
|
743
|
+
* This fires a tracking event before an action invoke api call is made
|
|
744
|
+
*/
|
|
745
|
+
smartLinkQuickActionStarted: props => dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionStarted({
|
|
746
|
+
...commonAttributes,
|
|
747
|
+
...props
|
|
748
|
+
}), commonAttributes)),
|
|
749
|
+
/**
|
|
750
|
+
* This fires a tracking event after an action invoke api call is successful
|
|
751
|
+
*/
|
|
752
|
+
smartLinkQuickActionSuccess: props => dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionSuccess({
|
|
753
|
+
...commonAttributes,
|
|
754
|
+
...props
|
|
755
|
+
}), commonAttributes)),
|
|
756
|
+
/**
|
|
757
|
+
* This fires a tracking event after an action invoke api call has failed
|
|
758
|
+
*/
|
|
759
|
+
smartLinkQuickActionFailed: props => dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionFailed({
|
|
760
|
+
...commonAttributes,
|
|
761
|
+
...props
|
|
728
762
|
}), commonAttributes))
|
|
729
763
|
}), [commonAttributes, dispatchAnalytics]);
|
|
730
764
|
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useSmartLinkClientExtension } from '@atlaskit/link-client-extension';
|
|
3
3
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
4
|
-
const useInvoke = (
|
|
4
|
+
const useInvoke = ({
|
|
5
|
+
failed,
|
|
6
|
+
started,
|
|
7
|
+
success
|
|
8
|
+
} = {}) => {
|
|
5
9
|
const {
|
|
6
10
|
connections
|
|
7
11
|
} = useSmartLinkContext();
|
|
8
12
|
const clientExt = useSmartLinkClientExtension(connections.client);
|
|
9
13
|
return useCallback(async (req, cb) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
var _req$action;
|
|
15
|
+
const smartLinkActionType = req === null || req === void 0 ? void 0 : (_req$action = req.action) === null || _req$action === void 0 ? void 0 : _req$action.actionType;
|
|
16
|
+
try {
|
|
17
|
+
started && started({
|
|
18
|
+
smartLinkActionType
|
|
19
|
+
});
|
|
20
|
+
const response = await clientExt.invoke(req);
|
|
21
|
+
success && success({
|
|
22
|
+
smartLinkActionType
|
|
23
|
+
});
|
|
24
|
+
return cb ? cb(response) : response;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
failed && failed({
|
|
27
|
+
smartLinkActionType
|
|
28
|
+
});
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
}, [clientExt, failed, started, success]);
|
|
18
32
|
};
|
|
19
33
|
export default useInvoke;
|
|
@@ -234,6 +234,45 @@ export const trackLinkUpdated = ({
|
|
|
234
234
|
...attributes
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
|
+
export const trackSmartLinkQuickActionStarted = ({
|
|
238
|
+
smartLinkActionType,
|
|
239
|
+
...attributes
|
|
240
|
+
}) => ({
|
|
241
|
+
action: 'started',
|
|
242
|
+
actionSubject: 'smartLinkQuickAction',
|
|
243
|
+
eventType: 'track',
|
|
244
|
+
attributes: {
|
|
245
|
+
...context,
|
|
246
|
+
...attributes,
|
|
247
|
+
smartLinkActionType
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
export const trackSmartLinkQuickActionSuccess = ({
|
|
251
|
+
smartLinkActionType,
|
|
252
|
+
...attributes
|
|
253
|
+
}) => ({
|
|
254
|
+
action: 'success',
|
|
255
|
+
actionSubject: 'smartLinkQuickAction',
|
|
256
|
+
eventType: 'track',
|
|
257
|
+
attributes: {
|
|
258
|
+
...context,
|
|
259
|
+
...attributes,
|
|
260
|
+
smartLinkActionType
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
export const trackSmartLinkQuickActionFailed = ({
|
|
264
|
+
smartLinkActionType,
|
|
265
|
+
...attributes
|
|
266
|
+
}) => ({
|
|
267
|
+
action: 'failed',
|
|
268
|
+
actionSubject: 'smartLinkQuickAction',
|
|
269
|
+
eventType: 'track',
|
|
270
|
+
attributes: {
|
|
271
|
+
...context,
|
|
272
|
+
...attributes,
|
|
273
|
+
smartLinkActionType
|
|
274
|
+
}
|
|
275
|
+
});
|
|
237
276
|
export const uiAuthEvent = ({
|
|
238
277
|
definitionId,
|
|
239
278
|
extensionKey,
|
|
@@ -589,4 +628,31 @@ export const chunkloadFailedEvent = ({
|
|
|
589
628
|
destinationSubproduct,
|
|
590
629
|
location
|
|
591
630
|
}
|
|
631
|
+
});
|
|
632
|
+
export const uiSmartLinkStatusLozengeButtonClicked = () => ({
|
|
633
|
+
action: 'clicked',
|
|
634
|
+
actionSubject: 'button',
|
|
635
|
+
actionSubjectId: 'smartLinkStatusLozenge',
|
|
636
|
+
eventType: 'ui',
|
|
637
|
+
attributes: {
|
|
638
|
+
...context
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
export const uiSmartLinkStatusListItemButtonClicked = () => ({
|
|
642
|
+
action: 'clicked',
|
|
643
|
+
actionSubject: 'button',
|
|
644
|
+
actionSubjectId: 'smartLinkStatusListItem',
|
|
645
|
+
eventType: 'ui',
|
|
646
|
+
attributes: {
|
|
647
|
+
...context
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
export const uiSmartLinkStatusOpenPreviewButtonClicked = () => ({
|
|
651
|
+
action: 'clicked',
|
|
652
|
+
actionSubject: 'button',
|
|
653
|
+
actionSubjectId: 'smartLinkStatusOpenPreview',
|
|
654
|
+
eventType: 'ui',
|
|
655
|
+
attributes: {
|
|
656
|
+
...context
|
|
657
|
+
}
|
|
592
658
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMeasure } from '../performance';
|
|
2
2
|
import { resolvedEvent, unresolvedEvent } from './analytics';
|
|
3
|
-
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, chunkloadFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent, uiIframeDwelledEvent } from './analytics';
|
|
3
|
+
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, chunkloadFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent, uiIframeDwelledEvent, uiSmartLinkStatusLozengeButtonClicked, uiSmartLinkStatusListItemButtonClicked, uiSmartLinkStatusOpenPreviewButtonClicked } from './analytics';
|
|
4
4
|
export const instrumentEvent = ({
|
|
5
5
|
id,
|
|
6
6
|
status,
|
package/dist/es2019/version.json
CHANGED
|
@@ -13,6 +13,7 @@ import extractLozengeActionItems from '../../../../../extractors/action/extract-
|
|
|
13
13
|
import createStatusUpdateRequest from '../../../../../utils/actions/create-status-update-request';
|
|
14
14
|
import useResolve from '../../../../../state/hooks/use-resolve';
|
|
15
15
|
import { LozengeActionErrorMessages } from './lozenge-action-error/types';
|
|
16
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../state/flexible-ui-context';
|
|
16
17
|
const validateItems = (items = [], text) => {
|
|
17
18
|
return items.filter(item => item.text !== text);
|
|
18
19
|
};
|
|
@@ -34,14 +35,20 @@ const LozengeAction = ({
|
|
|
34
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
36
|
const [items, setItems] = useState();
|
|
36
37
|
const [errorMessage, setErrorMessage] = useState();
|
|
38
|
+
const reload = useResolve();
|
|
39
|
+
//TODO EDM-6583 Replace usage of useFlexibleUiAnalyticsContext with linking platform analytics context from find team.
|
|
40
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
41
|
+
const invoke = useInvoke({
|
|
42
|
+
started: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionStarted,
|
|
43
|
+
success: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionSuccess,
|
|
44
|
+
failed: analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionFailed
|
|
45
|
+
});
|
|
37
46
|
useEffect(() => {
|
|
38
47
|
setSelected({
|
|
39
48
|
text,
|
|
40
49
|
appearance
|
|
41
50
|
});
|
|
42
51
|
}, [text, appearance]);
|
|
43
|
-
const invoke = useInvoke();
|
|
44
|
-
const reload = useResolve();
|
|
45
52
|
const {
|
|
46
53
|
url,
|
|
47
54
|
id: linkId,
|
|
@@ -49,28 +56,31 @@ const LozengeAction = ({
|
|
|
49
56
|
} = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {};
|
|
50
57
|
const handleOpenChange = useCallback(async args => {
|
|
51
58
|
setIsOpen(args.isOpen);
|
|
52
|
-
if (args.isOpen
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (args.isOpen) {
|
|
60
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionClickedEvent();
|
|
61
|
+
if (!isLoaded && action !== null && action !== void 0 && action.read) {
|
|
62
|
+
try {
|
|
63
|
+
setIsLoading(true);
|
|
64
|
+
const responseItems = await invoke(action.read, extractLozengeActionItems);
|
|
65
|
+
const validItems = typeof text === 'string' ? validateItems(responseItems, text) : responseItems;
|
|
66
|
+
setItems(validItems);
|
|
67
|
+
setIsLoaded(true);
|
|
68
|
+
if ((validItems === null || validItems === void 0 ? void 0 : validItems.length) === 0) {
|
|
69
|
+
setErrorMessage(LozengeActionErrorMessages.noData);
|
|
70
|
+
setIsLoaded(false);
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
setErrorMessage(LozengeActionErrorMessages.unknown);
|
|
61
74
|
setIsLoaded(false);
|
|
75
|
+
} finally {
|
|
76
|
+
setIsLoading(false);
|
|
62
77
|
}
|
|
63
|
-
} catch (err) {
|
|
64
|
-
setErrorMessage(LozengeActionErrorMessages.unknown);
|
|
65
|
-
setIsLoaded(false);
|
|
66
|
-
} finally {
|
|
67
|
-
setIsLoading(false);
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
if (!args.isOpen) {
|
|
71
81
|
setErrorMessage(undefined);
|
|
72
82
|
}
|
|
73
|
-
}, [action
|
|
83
|
+
}, [action.read, analytics, invoke, isLoaded, text]);
|
|
74
84
|
const trigger = useCallback(props => jsx(LozengeActionTrigger, _extends({}, props, {
|
|
75
85
|
appearance: selected.appearance,
|
|
76
86
|
testId: testId,
|
|
@@ -78,6 +88,7 @@ const LozengeAction = ({
|
|
|
78
88
|
})), [testId, selected]);
|
|
79
89
|
const handleItemClick = useCallback(async (id, text, appearance) => {
|
|
80
90
|
try {
|
|
91
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionListItemClickedEvent();
|
|
81
92
|
const updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
82
93
|
if (updateAction && id) {
|
|
83
94
|
setIsLoading(true);
|
|
@@ -103,7 +114,7 @@ const LozengeAction = ({
|
|
|
103
114
|
setErrorMessage(LozengeActionErrorMessages.updateFailed);
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
|
-
}, [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
|
117
|
+
}, [action === null || action === void 0 ? void 0 : action.update, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, linkId, reload, url]);
|
|
107
118
|
const dropdownItemGroup = useMemo(() => {
|
|
108
119
|
if (errorMessage) {
|
|
109
120
|
return jsx(LozengeActionError, {
|
|
@@ -103,7 +103,8 @@ const HoverCardContent = ({
|
|
|
103
103
|
showServerActions,
|
|
104
104
|
ui: flexibleUiOptions,
|
|
105
105
|
url: url,
|
|
106
|
-
children: {}
|
|
106
|
+
children: {},
|
|
107
|
+
analytics
|
|
107
108
|
};
|
|
108
109
|
const onClickStopPropagation = useCallback(e => e.stopPropagation(), []);
|
|
109
110
|
const getCardView = cardState => {
|
|
@@ -4,11 +4,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { getUrl } from '@atlaskit/linking-common';
|
|
7
|
-
import { chunkloadFailedEvent as _chunkloadFailedEvent, connectFailedEvent as _connectFailedEvent, connectSucceededEvent as _connectSucceededEvent, context, instrumentEvent, invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
|
|
7
|
+
import { chunkloadFailedEvent as _chunkloadFailedEvent, connectFailedEvent as _connectFailedEvent, connectSucceededEvent as _connectSucceededEvent, context, instrumentEvent, invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent, uiSmartLinkStatusLozengeButtonClicked, uiSmartLinkStatusListItemButtonClicked, uiSmartLinkStatusOpenPreviewButtonClicked } from '../../utils/analytics';
|
|
8
8
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
9
9
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
|
|
10
10
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
11
|
-
import { trackLinkUpdated, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
11
|
+
import { trackLinkUpdated, trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
12
12
|
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
13
13
|
var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
|
|
14
14
|
if (event && event.attributes) {
|
|
@@ -58,6 +58,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
58
58
|
definitionId: extractedDefinitionId,
|
|
59
59
|
extensionKey: extractedExtensionKey,
|
|
60
60
|
resourceType: extractedResourceType,
|
|
61
|
+
destinationObjectType: extractedResourceType,
|
|
61
62
|
destinationSubproduct: extractedSubproduct,
|
|
62
63
|
destinationProduct: extractedProduct,
|
|
63
64
|
location: defaultLocation
|
|
@@ -490,6 +491,24 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
490
491
|
*/
|
|
491
492
|
learnMoreClickedEvent: function learnMoreClickedEvent() {
|
|
492
493
|
return dispatchAnalytics(applyCommonAttributes(uiLearnMoreLinkClickedEvent(), commonAttributes));
|
|
494
|
+
},
|
|
495
|
+
/**
|
|
496
|
+
* Fires an event that represent a click was performed on a Status Lozenge
|
|
497
|
+
*/
|
|
498
|
+
smartLinkLozengeActionClickedEvent: function smartLinkLozengeActionClickedEvent() {
|
|
499
|
+
return dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusLozengeButtonClicked(), commonAttributes));
|
|
500
|
+
},
|
|
501
|
+
/**
|
|
502
|
+
* Fires an event that represent a click was performed on a Status Lozenge's dropdown item
|
|
503
|
+
*/
|
|
504
|
+
smartLinkLozengeActionListItemClickedEvent: function smartLinkLozengeActionListItemClickedEvent() {
|
|
505
|
+
return dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusListItemButtonClicked(), commonAttributes));
|
|
506
|
+
},
|
|
507
|
+
/**
|
|
508
|
+
* Fires an event that represent a click was performed on a Status Lozenge open preview button
|
|
509
|
+
*/
|
|
510
|
+
smartLinkLozengeActionErrorOpenPreviewClickedEvent: function smartLinkLozengeActionErrorOpenPreviewClickedEvent() {
|
|
511
|
+
return dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusOpenPreviewButtonClicked(), commonAttributes));
|
|
493
512
|
}
|
|
494
513
|
};
|
|
495
514
|
}, [defaultId, commonAttributes, dispatchAnalytics]);
|
|
@@ -731,6 +750,24 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
731
750
|
*/
|
|
732
751
|
linkUpdated: function linkUpdated(props) {
|
|
733
752
|
return dispatchAnalytics(applyCommonAttributes(trackLinkUpdated(_objectSpread(_objectSpread({}, commonAttributes), props)), commonAttributes));
|
|
753
|
+
},
|
|
754
|
+
/**
|
|
755
|
+
* This fires a tracking event before an action invoke api call is made
|
|
756
|
+
*/
|
|
757
|
+
smartLinkQuickActionStarted: function smartLinkQuickActionStarted(props) {
|
|
758
|
+
return dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionStarted(_objectSpread(_objectSpread({}, commonAttributes), props)), commonAttributes));
|
|
759
|
+
},
|
|
760
|
+
/**
|
|
761
|
+
* This fires a tracking event after an action invoke api call is successful
|
|
762
|
+
*/
|
|
763
|
+
smartLinkQuickActionSuccess: function smartLinkQuickActionSuccess(props) {
|
|
764
|
+
return dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionSuccess(_objectSpread(_objectSpread({}, commonAttributes), props)), commonAttributes));
|
|
765
|
+
},
|
|
766
|
+
/**
|
|
767
|
+
* This fires a tracking event after an action invoke api call has failed
|
|
768
|
+
*/
|
|
769
|
+
smartLinkQuickActionFailed: function smartLinkQuickActionFailed(props) {
|
|
770
|
+
return dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionFailed(_objectSpread(_objectSpread({}, commonAttributes), props)), commonAttributes));
|
|
734
771
|
}
|
|
735
772
|
};
|
|
736
773
|
}, [commonAttributes, dispatchAnalytics]);
|
|
@@ -4,29 +4,49 @@ import { useCallback } from 'react';
|
|
|
4
4
|
import { useSmartLinkClientExtension } from '@atlaskit/link-client-extension';
|
|
5
5
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
6
6
|
var useInvoke = function useInvoke() {
|
|
7
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
8
|
+
failed = _ref.failed,
|
|
9
|
+
started = _ref.started,
|
|
10
|
+
success = _ref.success;
|
|
7
11
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
8
12
|
connections = _useSmartLinkContext.connections;
|
|
9
13
|
var clientExt = useSmartLinkClientExtension(connections.client);
|
|
10
14
|
return useCallback( /*#__PURE__*/function () {
|
|
11
|
-
var
|
|
12
|
-
var
|
|
15
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(req, cb) {
|
|
16
|
+
var _req$action;
|
|
17
|
+
var smartLinkActionType, response;
|
|
13
18
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
19
|
while (1) switch (_context.prev = _context.next) {
|
|
15
20
|
case 0:
|
|
16
|
-
|
|
21
|
+
smartLinkActionType = req === null || req === void 0 ? void 0 : (_req$action = req.action) === null || _req$action === void 0 ? void 0 : _req$action.actionType;
|
|
22
|
+
_context.prev = 1;
|
|
23
|
+
started && started({
|
|
24
|
+
smartLinkActionType: smartLinkActionType
|
|
25
|
+
});
|
|
26
|
+
_context.next = 5;
|
|
17
27
|
return clientExt.invoke(req);
|
|
18
|
-
case
|
|
28
|
+
case 5:
|
|
19
29
|
response = _context.sent;
|
|
30
|
+
success && success({
|
|
31
|
+
smartLinkActionType: smartLinkActionType
|
|
32
|
+
});
|
|
20
33
|
return _context.abrupt("return", cb ? cb(response) : response);
|
|
21
|
-
case
|
|
34
|
+
case 10:
|
|
35
|
+
_context.prev = 10;
|
|
36
|
+
_context.t0 = _context["catch"](1);
|
|
37
|
+
failed && failed({
|
|
38
|
+
smartLinkActionType: smartLinkActionType
|
|
39
|
+
});
|
|
40
|
+
throw _context.t0;
|
|
41
|
+
case 14:
|
|
22
42
|
case "end":
|
|
23
43
|
return _context.stop();
|
|
24
44
|
}
|
|
25
|
-
}, _callee);
|
|
45
|
+
}, _callee, null, [[1, 10]]);
|
|
26
46
|
}));
|
|
27
47
|
return function (_x, _x2) {
|
|
28
|
-
return
|
|
48
|
+
return _ref2.apply(this, arguments);
|
|
29
49
|
};
|
|
30
|
-
}(), [clientExt]);
|
|
50
|
+
}(), [clientExt, failed, started, success]);
|
|
31
51
|
};
|
|
32
52
|
export default useInvoke;
|