@atlaskit/smart-card 26.24.0 → 26.26.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 +16 -0
- package/dist/cjs/extractors/block/index.js +1 -1
- package/dist/cjs/extractors/common/actions/extractActions.js +3 -31
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +10 -15
- package/dist/cjs/state/hooks/use-invoke/utils.js +23 -0
- package/dist/cjs/state/hooks/use-invoke-client-action/index.js +20 -14
- package/dist/cjs/utils/analytics/analytics.js +28 -7
- package/dist/cjs/utils/mocks.js +7 -2
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -45
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
- package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +32 -15
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +2 -4
- package/dist/cjs/view/FlexibleCard/components/utils.js +9 -20
- package/dist/cjs/view/FlexibleCard/index.js +14 -1
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/block/index.js +2 -2
- package/dist/es2019/extractors/common/actions/extractActions.js +2 -23
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +10 -17
- package/dist/es2019/state/hooks/use-invoke/utils.js +13 -0
- package/dist/es2019/state/hooks/use-invoke-client-action/index.js +14 -8
- package/dist/es2019/utils/analytics/analytics.js +65 -32
- package/dist/es2019/utils/mocks.js +7 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -42
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +15 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +18 -7
- package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +19 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +15 -1
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/utils.js +3 -17
- package/dist/es2019/view/FlexibleCard/index.js +11 -1
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/block/index.js +2 -2
- package/dist/esm/extractors/common/actions/extractActions.js +2 -30
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +11 -16
- package/dist/esm/state/hooks/use-invoke/utils.js +15 -0
- package/dist/esm/state/hooks/use-invoke-client-action/index.js +20 -14
- package/dist/esm/utils/analytics/analytics.js +23 -5
- package/dist/esm/utils/mocks.js +7 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -46
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
- package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +32 -15
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +1 -3
- package/dist/esm/view/FlexibleCard/components/utils.js +9 -20
- package/dist/esm/view/FlexibleCard/index.js +14 -1
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +0 -1
- package/dist/types/extractors/common/actions/extractActions.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +6 -5
- package/dist/types/state/flexible-ui-context/index.d.ts +3 -119
- package/dist/types/state/flexible-ui-context/types.d.ts +6 -0
- package/dist/types/state/hooks/use-invoke/utils.d.ts +4 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +4 -3
- package/dist/types/utils/analytics/analytics.d.ts +4 -1
- package/dist/types/utils/analytics/types.d.ts +7 -3
- package/dist/types/utils/mocks.d.ts +4 -3
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -63
- package/dist/types/view/FlexibleCard/types.d.ts +2 -3
- package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +0 -1
- package/dist/types-ts4.5/extractors/common/actions/extractActions.d.ts +1 -1
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +6 -5
- package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +3 -119
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +6 -0
- package/dist/types-ts4.5/state/hooks/use-invoke/utils.d.ts +4 -0
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +4 -3
- package/dist/types-ts4.5/utils/analytics/analytics.d.ts +4 -1
- package/dist/types-ts4.5/utils/analytics/types.d.ts +7 -3
- package/dist/types-ts4.5/utils/mocks.d.ts +4 -3
- package/dist/types-ts4.5/view/Card/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +2 -63
- package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -3
- package/package.json +2 -2
- package/report.api.md +14 -6
- package/tmp/api-report-tmp.d.ts +12 -6
|
@@ -212,13 +212,18 @@ export const mockAnalytics = {
|
|
|
212
212
|
buttonClickedEvent: () => {},
|
|
213
213
|
modalClosedEvent: () => {},
|
|
214
214
|
renderSuccessEvent: () => {},
|
|
215
|
-
renderFailedEvent: () => {}
|
|
215
|
+
renderFailedEvent: () => {},
|
|
216
|
+
smartLinkServerActionClickedEvent: () => {}
|
|
216
217
|
},
|
|
217
218
|
operational: {
|
|
218
219
|
invokeSucceededEvent: () => {},
|
|
219
220
|
invokeFailedEvent: () => {}
|
|
220
221
|
},
|
|
221
|
-
track: {
|
|
222
|
+
track: {
|
|
223
|
+
smartLinkQuickActionFailed: () => {},
|
|
224
|
+
smartLinkQuickActionStarted: () => {},
|
|
225
|
+
smartLinkQuickActionSuccess: () => {}
|
|
226
|
+
},
|
|
222
227
|
screen: {
|
|
223
228
|
modalViewedEvent: () => {}
|
|
224
229
|
}
|
|
@@ -30,6 +30,7 @@ const FlexibleErroredView = ({
|
|
|
30
30
|
const status = cardState.status;
|
|
31
31
|
const actions = useMemo(() => onAuthorize ? [RetryAction(onAuthorize)] : [], [onAuthorize]);
|
|
32
32
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
33
|
+
appearance: "block",
|
|
33
34
|
cardState: cardState,
|
|
34
35
|
onAuthorize: onAuthorize,
|
|
35
36
|
onClick: onClick,
|
|
@@ -4,8 +4,7 @@ import FlexibleCard from '../../../FlexibleCard';
|
|
|
4
4
|
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
5
5
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
6
6
|
import { metadataBlockCss, footerBlockCss } from './styled';
|
|
7
|
-
import { ActionName,
|
|
8
|
-
import uuid from 'uuid';
|
|
7
|
+
import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
9
8
|
import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
|
|
10
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
|
|
@@ -32,7 +31,6 @@ const FlexibleResolvedView = ({
|
|
|
32
31
|
useEffect(() => {
|
|
33
32
|
setIsPreviewBlockErrored(false);
|
|
34
33
|
}, [url, cardState]);
|
|
35
|
-
const [analyticsId] = useState(() => id ? id : uuid());
|
|
36
34
|
const {
|
|
37
35
|
titleMetadata,
|
|
38
36
|
topMetadata,
|
|
@@ -80,49 +78,13 @@ const FlexibleResolvedView = ({
|
|
|
80
78
|
}, {
|
|
81
79
|
actions: [{
|
|
82
80
|
name: ActionName.PreviewAction,
|
|
83
|
-
hideIcon: true
|
|
84
|
-
onClick: () => {
|
|
85
|
-
analytics.ui.actionClickedEvent({
|
|
86
|
-
id: analyticsId,
|
|
87
|
-
actionType: 'PreviewAction',
|
|
88
|
-
display: CardDisplay.Block
|
|
89
|
-
});
|
|
90
|
-
analytics.operational.invokeSucceededEvent({
|
|
91
|
-
id: analyticsId,
|
|
92
|
-
actionType: 'PreviewAction',
|
|
93
|
-
display: CardDisplay.Block
|
|
94
|
-
});
|
|
95
|
-
}
|
|
81
|
+
hideIcon: true
|
|
96
82
|
}, {
|
|
97
83
|
name: ActionName.ViewAction,
|
|
98
|
-
hideIcon: true
|
|
99
|
-
onClick: () => {
|
|
100
|
-
analytics.ui.actionClickedEvent({
|
|
101
|
-
id: analyticsId,
|
|
102
|
-
actionType: 'ViewAction',
|
|
103
|
-
display: CardDisplay.Block
|
|
104
|
-
});
|
|
105
|
-
analytics.operational.invokeSucceededEvent({
|
|
106
|
-
id: analyticsId,
|
|
107
|
-
actionType: 'ViewAction',
|
|
108
|
-
display: CardDisplay.Block
|
|
109
|
-
});
|
|
110
|
-
}
|
|
84
|
+
hideIcon: true
|
|
111
85
|
}, {
|
|
112
86
|
name: ActionName.DownloadAction,
|
|
113
|
-
hideIcon: true
|
|
114
|
-
onClick: () => {
|
|
115
|
-
analytics.ui.actionClickedEvent({
|
|
116
|
-
id: analyticsId,
|
|
117
|
-
actionType: 'DownloadAction',
|
|
118
|
-
display: CardDisplay.Block
|
|
119
|
-
});
|
|
120
|
-
analytics.operational.invokeSucceededEvent({
|
|
121
|
-
id: analyticsId,
|
|
122
|
-
actionType: 'DownloadAction',
|
|
123
|
-
display: CardDisplay.Block
|
|
124
|
-
});
|
|
125
|
-
}
|
|
87
|
+
hideIcon: true
|
|
126
88
|
}]
|
|
127
89
|
})));
|
|
128
90
|
};
|
|
@@ -2,6 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { downloadUrl as download } from '../../../../../../utils';
|
|
5
|
+
import { ActionName } from '../../../../../../constants';
|
|
6
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
7
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
8
|
const DownloadAction = props => {
|
|
6
9
|
const {
|
|
7
10
|
appearance,
|
|
@@ -11,11 +14,22 @@ const DownloadAction = props => {
|
|
|
11
14
|
testId,
|
|
12
15
|
url
|
|
13
16
|
} = props;
|
|
17
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
+
const invoke = useInvokeClientAction({
|
|
19
|
+
analytics
|
|
20
|
+
});
|
|
14
21
|
if (downloadUrl && url) {
|
|
15
22
|
const action = {
|
|
16
23
|
...props,
|
|
17
24
|
onClick: () => {
|
|
18
|
-
|
|
25
|
+
invoke({
|
|
26
|
+
actionType: ActionName.DownloadAction,
|
|
27
|
+
actionFn: async () => download(downloadUrl),
|
|
28
|
+
// These values have already been set in analytics context.
|
|
29
|
+
// We only pass these here for ufo experience.
|
|
30
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
31
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
32
|
+
});
|
|
19
33
|
if (onClick) {
|
|
20
34
|
onClick();
|
|
21
35
|
}
|
|
@@ -2,10 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
|
-
import { useSmartLinkAnalytics } from '../../../../../../state';
|
|
6
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
6
|
import { messages } from '../../../../../../messages';
|
|
8
7
|
import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
|
|
8
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
9
|
+
import { ActionName } from '../../../../../../constants';
|
|
9
10
|
const PreviewAction = props => {
|
|
10
11
|
const {
|
|
11
12
|
appearance,
|
|
@@ -20,22 +21,32 @@ const PreviewAction = props => {
|
|
|
20
21
|
downloadUrl,
|
|
21
22
|
isSupportTheming
|
|
22
23
|
} = props;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
24
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
25
|
+
const invoke = useInvokeClientAction({
|
|
26
|
+
analytics
|
|
27
|
+
});
|
|
25
28
|
if (src && url) {
|
|
26
|
-
const
|
|
29
|
+
const actionFn = async () => openEmbedModalWithFlexibleUiIcon({
|
|
30
|
+
download: downloadUrl,
|
|
27
31
|
title,
|
|
28
32
|
providerName,
|
|
29
|
-
downloadUrl,
|
|
30
33
|
isSupportTheming,
|
|
31
34
|
analytics,
|
|
32
35
|
linkIcon,
|
|
33
|
-
src
|
|
36
|
+
src,
|
|
37
|
+
url
|
|
34
38
|
});
|
|
35
39
|
const action = {
|
|
36
40
|
...props,
|
|
37
41
|
onClick: () => {
|
|
38
|
-
|
|
42
|
+
invoke({
|
|
43
|
+
actionType: ActionName.PreviewAction,
|
|
44
|
+
actionFn,
|
|
45
|
+
// These values have already been set in analytics context.
|
|
46
|
+
// We only pass these here for ufo experience.
|
|
47
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
48
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
49
|
+
});
|
|
39
50
|
if (onClick) {
|
|
40
51
|
onClick();
|
|
41
52
|
}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import useInvoke from '../../../../../../state/hooks/use-invoke';
|
|
4
|
+
import { getInvokeFailureReason } from '../../../../../../state/hooks/use-invoke/utils';
|
|
4
5
|
import useResolve from '../../../../../../state/hooks/use-resolve';
|
|
5
6
|
import createInvokeRequest from '../../../../../../utils/actions/create-invoke-request';
|
|
6
7
|
import Action from '../index';
|
|
8
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
7
9
|
const ServerAction = ({
|
|
8
10
|
action,
|
|
9
11
|
onClick,
|
|
10
12
|
...props
|
|
11
13
|
}) => {
|
|
12
14
|
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
13
16
|
const invoke = useInvoke();
|
|
14
17
|
const reload = useResolve();
|
|
15
18
|
const handleClick = useCallback(async () => {
|
|
16
19
|
if (action) {
|
|
20
|
+
var _action$action;
|
|
21
|
+
const smartLinkActionType = (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.actionType;
|
|
17
22
|
try {
|
|
18
23
|
setIsLoading(true);
|
|
24
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkServerActionClickedEvent({
|
|
25
|
+
smartLinkActionType
|
|
26
|
+
});
|
|
27
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionStarted({
|
|
28
|
+
smartLinkActionType
|
|
29
|
+
});
|
|
19
30
|
const request = createInvokeRequest(action);
|
|
20
31
|
await invoke(request);
|
|
32
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionSuccess({
|
|
33
|
+
smartLinkActionType
|
|
34
|
+
});
|
|
21
35
|
if (action.reload && action.reload.url) {
|
|
22
36
|
await reload(action.reload.url, true, undefined, action.reload.id);
|
|
23
37
|
}
|
|
@@ -27,9 +41,13 @@ const ServerAction = ({
|
|
|
27
41
|
}
|
|
28
42
|
} catch (err) {
|
|
29
43
|
setIsLoading(false);
|
|
44
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.track.smartLinkQuickActionFailed({
|
|
45
|
+
smartLinkActionType,
|
|
46
|
+
reason: getInvokeFailureReason(err)
|
|
47
|
+
});
|
|
30
48
|
}
|
|
31
49
|
}
|
|
32
|
-
}, [action, invoke, onClick, reload]);
|
|
50
|
+
}, [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, reload]);
|
|
33
51
|
return /*#__PURE__*/React.createElement(Action, _extends({}, props, {
|
|
34
52
|
isLoading: isLoading,
|
|
35
53
|
onClick: handleClick
|
|
@@ -2,6 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { openUrl } from '../../../../../../utils';
|
|
5
|
+
import { ActionName } from '../../../../../../constants';
|
|
6
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
7
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
5
8
|
const ViewAction = props => {
|
|
6
9
|
const {
|
|
7
10
|
appearance,
|
|
@@ -11,11 +14,22 @@ const ViewAction = props => {
|
|
|
11
14
|
viewUrl,
|
|
12
15
|
url
|
|
13
16
|
} = props;
|
|
17
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
+
const invoke = useInvokeClientAction({
|
|
19
|
+
analytics
|
|
20
|
+
});
|
|
14
21
|
if (viewUrl && url) {
|
|
15
22
|
const action = {
|
|
16
23
|
...props,
|
|
17
24
|
onClick: () => {
|
|
18
|
-
|
|
25
|
+
invoke({
|
|
26
|
+
actionType: ActionName.ViewAction,
|
|
27
|
+
actionFn: async () => openUrl(viewUrl),
|
|
28
|
+
// These values have already been set in analytics context.
|
|
29
|
+
// We only pass these here for ufo experience.
|
|
30
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
31
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
32
|
+
});
|
|
19
33
|
if (onClick) {
|
|
20
34
|
onClick();
|
|
21
35
|
}
|
|
@@ -13,13 +13,13 @@ import extractLozengeActionItems from '../../../../../../extractors/action/extra
|
|
|
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 { isInvokeCustomError } from '../../../../../../state/hooks/use-invoke/utils';
|
|
16
17
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
17
18
|
import { TrackQuickActionType } from '../../../../../../utils/analytics/analytics';
|
|
18
19
|
import { permissionLoadErrorAnalyticsPayload, unknownLoadErrorAnalyticsPayload, unknownUpdateErrorAnalyticsPayload, validationUpdateErrorAnalyticsPayload } from './lozenge-action-analytics';
|
|
19
20
|
const validateItems = (items = [], text) => {
|
|
20
21
|
return items.filter(item => item.text !== text);
|
|
21
22
|
};
|
|
22
|
-
const isInvokeCustomError = err => err.message !== undefined && err.errorCode !== undefined;
|
|
23
23
|
const LozengeAction = ({
|
|
24
24
|
action,
|
|
25
25
|
appearance,
|
|
@@ -142,15 +142,8 @@ export const hasWhiteSpace = str => {
|
|
|
142
142
|
return str.search(/\s/) >= 0;
|
|
143
143
|
};
|
|
144
144
|
export const openEmbedModalWithFlexibleUiIcon = ({
|
|
145
|
-
analytics,
|
|
146
|
-
downloadUrl,
|
|
147
145
|
linkIcon,
|
|
148
|
-
|
|
149
|
-
providerName,
|
|
150
|
-
src,
|
|
151
|
-
title,
|
|
152
|
-
url,
|
|
153
|
-
isSupportTheming
|
|
146
|
+
...props
|
|
154
147
|
}) => {
|
|
155
148
|
const icon = {
|
|
156
149
|
icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
|
|
@@ -159,18 +152,11 @@ export const openEmbedModalWithFlexibleUiIcon = ({
|
|
|
159
152
|
isFlexibleUi: true
|
|
160
153
|
};
|
|
161
154
|
return openEmbedModal({
|
|
162
|
-
|
|
163
|
-
download: downloadUrl,
|
|
155
|
+
...props,
|
|
164
156
|
icon,
|
|
165
157
|
// Flex should not send origin as block card. It should be able to support
|
|
166
158
|
// its internal parent components like hover card, block card and
|
|
167
159
|
// itself as a standalone. To be investigated and fix in EDM-7520.
|
|
168
|
-
origin: 'smartLinkCard'
|
|
169
|
-
providerName,
|
|
170
|
-
onClose,
|
|
171
|
-
src,
|
|
172
|
-
title,
|
|
173
|
-
url,
|
|
174
|
-
isSupportTheming
|
|
160
|
+
origin: 'smartLinkCard'
|
|
175
161
|
});
|
|
176
162
|
};
|
|
@@ -13,6 +13,7 @@ import { getContextByStatus, getRetryOptions } from './utils';
|
|
|
13
13
|
*/
|
|
14
14
|
const FlexibleCard = ({
|
|
15
15
|
analytics,
|
|
16
|
+
appearance = 'flexible',
|
|
16
17
|
cardState,
|
|
17
18
|
children,
|
|
18
19
|
id,
|
|
@@ -28,6 +29,7 @@ const FlexibleCard = ({
|
|
|
28
29
|
ui,
|
|
29
30
|
url
|
|
30
31
|
}) => {
|
|
32
|
+
var _details$meta2;
|
|
31
33
|
const {
|
|
32
34
|
status: cardType,
|
|
33
35
|
details
|
|
@@ -45,6 +47,14 @@ const FlexibleCard = ({
|
|
|
45
47
|
const {
|
|
46
48
|
title
|
|
47
49
|
} = context || {};
|
|
50
|
+
const analyticsContext = useMemo(() => {
|
|
51
|
+
var _details$meta;
|
|
52
|
+
return analytics ? {
|
|
53
|
+
...analytics,
|
|
54
|
+
display: appearance,
|
|
55
|
+
extensionKey: details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.key
|
|
56
|
+
} : undefined;
|
|
57
|
+
}, [analytics, appearance, details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key]);
|
|
48
58
|
useEffect(() => {
|
|
49
59
|
switch (status) {
|
|
50
60
|
case SmartLinkStatus.Resolved:
|
|
@@ -70,7 +80,7 @@ const FlexibleCard = ({
|
|
|
70
80
|
}
|
|
71
81
|
}, [onError, onResolve, status, title, url]);
|
|
72
82
|
return /*#__PURE__*/React.createElement(FlexibleUiAnalyticsContext.Provider, {
|
|
73
|
-
value:
|
|
83
|
+
value: analyticsContext
|
|
74
84
|
}, /*#__PURE__*/React.createElement(FlexibleUiOptionContext.Provider, {
|
|
75
85
|
value: ui
|
|
76
86
|
}, /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
@@ -8,7 +8,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
const PACKAGE_DATA = {
|
|
10
10
|
packageName: "@atlaskit/smart-card",
|
|
11
|
-
packageVersion: "26.
|
|
11
|
+
packageVersion: "26.26.0",
|
|
12
12
|
componentName: 'linkUrl'
|
|
13
13
|
};
|
|
14
14
|
const Link = withLinkClickedEvent('a');
|
|
@@ -8,7 +8,7 @@ import { extractCommentCount, extractProgrammingLanguage, extractSubscriberCount
|
|
|
8
8
|
import { extractLink, extractTitle, extractProvider, extractMembers, extractPersonAssignedTo, extractPersonCreatedBy, extractPersonUpdatedBy, extractImage } from '@atlaskit/link-extractors';
|
|
9
9
|
import { extractByline } from '../common/byline/extractByline';
|
|
10
10
|
import { extractTitlePrefix } from '../common/title-prefix/extractTitlePrefix';
|
|
11
|
-
import {
|
|
11
|
+
import { extractClientActions } from '../common/actions/extractActions';
|
|
12
12
|
import { extractPreviewAction } from '../common/actions/extractPreviewAction';
|
|
13
13
|
import { extractIsTrusted } from '../common/meta/extractIsTrusted';
|
|
14
14
|
var extractBlockIcon = function extractBlockIcon(jsonLd) {
|
|
@@ -31,7 +31,7 @@ var extractBlockDetails = function extractBlockDetails(jsonLd) {
|
|
|
31
31
|
export var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform, meta) {
|
|
32
32
|
if (opts) {
|
|
33
33
|
var handleInvoke = opts.handleInvoke;
|
|
34
|
-
var actions =
|
|
34
|
+
var actions = extractClientActions(jsonLd, handleInvoke);
|
|
35
35
|
var previewAction = extractPreviewAction(_objectSpread(_objectSpread({}, opts), {}, {
|
|
36
36
|
viewProps: props,
|
|
37
37
|
jsonLd: jsonLd,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
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; }
|
|
4
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; }
|
|
@@ -37,27 +36,6 @@ var getClientActionProps = function getClientActionProps(jsonLd, action, handler
|
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
};
|
|
40
|
-
var getServerActionProps = function getServerActionProps(jsonLd, action, handler) {
|
|
41
|
-
var id = action['@id'] || action['@type'];
|
|
42
|
-
var data = {
|
|
43
|
-
type: 'server',
|
|
44
|
-
key: action.identifier,
|
|
45
|
-
action: {
|
|
46
|
-
type: action['@type'],
|
|
47
|
-
payload: {
|
|
48
|
-
id: id,
|
|
49
|
-
context: jsonLd.context
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
id: id,
|
|
55
|
-
text: action.name,
|
|
56
|
-
promise: function promise() {
|
|
57
|
-
return handler(data);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
39
|
export var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
62
40
|
var actions = jsonLd && jsonLd['schema:potentialAction'];
|
|
63
41
|
if (!actions) {
|
|
@@ -68,17 +46,11 @@ export var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
|
68
46
|
}
|
|
69
47
|
return actions;
|
|
70
48
|
};
|
|
71
|
-
export function
|
|
49
|
+
export function extractClientActions(jsonLd, handler) {
|
|
72
50
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
73
51
|
var clientActions = actions.filter(isClientAction);
|
|
74
|
-
var serverActions = actions.filter(function (action) {
|
|
75
|
-
return !isClientAction(action);
|
|
76
|
-
});
|
|
77
52
|
var clientActionImpls = clientActions.map(function (action) {
|
|
78
53
|
return getClientActionProps(jsonLd, action, handler);
|
|
79
54
|
});
|
|
80
|
-
|
|
81
|
-
return getServerActionProps(jsonLd, action, handler);
|
|
82
|
-
});
|
|
83
|
-
return [].concat(_toConsumableArray(clientActionImpls), _toConsumableArray(serverActionImpls));
|
|
55
|
+
return clientActionImpls;
|
|
84
56
|
}
|
|
@@ -8,7 +8,7 @@ import { chunkloadFailedEvent as _chunkloadFailedEvent, connectFailedEvent as _c
|
|
|
8
8
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
9
9
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getStatusDetails, getSubproduct } from '../helpers';
|
|
10
10
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
11
|
-
import { trackHoverCardResolutionStarted, trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
11
|
+
import { trackHoverCardResolutionStarted, trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent, uiServerActionClicked } from '../../utils/analytics/analytics';
|
|
12
12
|
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
13
13
|
var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
|
|
14
14
|
if (event && event.attributes) {
|
|
@@ -247,11 +247,11 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
247
247
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
248
248
|
* @param actionType The type of the action that was clicked, e.g. PreviewAction
|
|
249
249
|
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
250
|
-
* @param invokeType
|
|
250
|
+
* @param invokeType @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
|
|
251
251
|
* @returns
|
|
252
252
|
*/
|
|
253
253
|
actionClickedEvent: function actionClickedEvent(_ref6) {
|
|
254
|
-
var
|
|
254
|
+
var id = _ref6.id,
|
|
255
255
|
actionType = _ref6.actionType,
|
|
256
256
|
display = _ref6.display,
|
|
257
257
|
invokeType = _ref6.invokeType,
|
|
@@ -262,14 +262,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
262
262
|
destinationSubproduct = _ref6.destinationSubproduct,
|
|
263
263
|
location = _ref6.location;
|
|
264
264
|
var extensionKey = overrideExtensionKey !== null && overrideExtensionKey !== void 0 ? overrideExtensionKey : extractedExtensionKey;
|
|
265
|
-
startUfoExperience('smart-link-action-invocation', experienceId, {
|
|
266
|
-
actionType: actionType,
|
|
267
|
-
display: display,
|
|
268
|
-
extensionKey: extensionKey,
|
|
269
|
-
invokeType: invokeType
|
|
270
|
-
});
|
|
271
265
|
dispatchAnalytics(applyCommonAttributes(uiActionClickedEvent({
|
|
272
|
-
id: defaultId,
|
|
266
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
273
267
|
actionType: actionType,
|
|
274
268
|
display: display,
|
|
275
269
|
extensionKey: extensionKey,
|
|
@@ -512,6 +506,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
512
506
|
*/
|
|
513
507
|
smartLinkLozengeActionErrorOpenPreviewClickedEvent: function smartLinkLozengeActionErrorOpenPreviewClickedEvent() {
|
|
514
508
|
return dispatchAnalytics(applyCommonAttributes(uiSmartLinkStatusOpenPreviewButtonClicked(), commonAttributes));
|
|
509
|
+
},
|
|
510
|
+
smartLinkServerActionClickedEvent: function smartLinkServerActionClickedEvent(props) {
|
|
511
|
+
return dispatchAnalytics(applyCommonAttributes(uiServerActionClicked(props), commonAttributes));
|
|
515
512
|
}
|
|
516
513
|
};
|
|
517
514
|
}, [dispatchAnalytics, commonAttributes, defaultId, extractedExtensionKey]);
|
|
@@ -527,7 +524,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
527
524
|
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
528
525
|
*/
|
|
529
526
|
invokeSucceededEvent: function invokeSucceededEvent(_ref13) {
|
|
530
|
-
var
|
|
527
|
+
var id = _ref13.id,
|
|
531
528
|
actionType = _ref13.actionType,
|
|
532
529
|
display = _ref13.display,
|
|
533
530
|
extensionKey = _ref13.extensionKey,
|
|
@@ -536,9 +533,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
536
533
|
destinationProduct = _ref13.destinationProduct,
|
|
537
534
|
destinationSubproduct = _ref13.destinationSubproduct,
|
|
538
535
|
location = _ref13.location;
|
|
539
|
-
succeedUfoExperience('smart-link-action-invocation', experienceId);
|
|
540
536
|
dispatchAnalytics(applyCommonAttributes(_invokeSucceededEvent({
|
|
541
|
-
id: defaultId,
|
|
537
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
542
538
|
actionType: actionType,
|
|
543
539
|
display: display,
|
|
544
540
|
extensionKey: extensionKey,
|
|
@@ -558,7 +554,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
558
554
|
* @param reason The reason the invocation failed.
|
|
559
555
|
*/
|
|
560
556
|
invokeFailedEvent: function invokeFailedEvent(_ref14) {
|
|
561
|
-
var
|
|
557
|
+
var id = _ref14.id,
|
|
562
558
|
actionType = _ref14.actionType,
|
|
563
559
|
display = _ref14.display,
|
|
564
560
|
reason = _ref14.reason,
|
|
@@ -568,9 +564,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
568
564
|
destinationProduct = _ref14.destinationProduct,
|
|
569
565
|
destinationSubproduct = _ref14.destinationSubproduct,
|
|
570
566
|
location = _ref14.location;
|
|
571
|
-
failUfoExperience('smart-link-action-invocation', experienceId);
|
|
572
567
|
dispatchAnalytics(applyCommonAttributes(_invokeFailedEvent({
|
|
573
|
-
id: defaultId,
|
|
568
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
574
569
|
actionType: actionType,
|
|
575
570
|
display: display,
|
|
576
571
|
reason: reason,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TrackQuickActionFailureReason } from '../../../utils/analytics/analytics';
|
|
2
|
+
export var getInvokeFailureReason = function getInvokeFailureReason(err) {
|
|
3
|
+
if (!isInvokeCustomError(err)) {
|
|
4
|
+
return TrackQuickActionFailureReason.UnknownError;
|
|
5
|
+
}
|
|
6
|
+
switch (err === null || err === void 0 ? void 0 : err.errorCode) {
|
|
7
|
+
case 403:
|
|
8
|
+
return TrackQuickActionFailureReason.PermissionError;
|
|
9
|
+
default:
|
|
10
|
+
return TrackQuickActionFailureReason.UnknownError;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export var isInvokeCustomError = function isInvokeCustomError(err) {
|
|
14
|
+
return (err === null || err === void 0 ? void 0 : err.message) !== undefined && (err === null || err === void 0 ? void 0 : err.errorCode) !== undefined;
|
|
15
|
+
};
|
|
@@ -3,6 +3,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import uuid from 'uuid';
|
|
5
5
|
import * as measure from '../../../utils/performance';
|
|
6
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../analytics';
|
|
7
|
+
var ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Invoke client action such as preview, download and open link
|
|
8
11
|
*/
|
|
@@ -19,45 +22,48 @@ var useInvokeClientAction = function useInvokeClientAction(_ref) {
|
|
|
19
22
|
markName = "".concat(experienceId, "-").concat(actionType);
|
|
20
23
|
measure.mark(markName, 'pending');
|
|
21
24
|
_context.prev = 4;
|
|
22
|
-
// Begin
|
|
23
|
-
|
|
24
|
-
id: experienceId,
|
|
25
|
-
extensionKey: extensionKey,
|
|
25
|
+
// Begin UFO experience
|
|
26
|
+
startUfoExperience(ACTION_EXPERIENCE_NAME, experienceId, {
|
|
26
27
|
actionType: actionType,
|
|
27
28
|
display: display,
|
|
29
|
+
extensionKey: extensionKey,
|
|
28
30
|
invokeType: 'client'
|
|
29
31
|
});
|
|
30
32
|
|
|
33
|
+
// Begin analytics instrumentation.
|
|
34
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.actionClickedEvent({
|
|
35
|
+
actionType: actionType,
|
|
36
|
+
display: display
|
|
37
|
+
});
|
|
38
|
+
|
|
31
39
|
// Invoke action
|
|
32
|
-
_context.next =
|
|
40
|
+
_context.next = 9;
|
|
33
41
|
return actionFn();
|
|
34
|
-
case
|
|
42
|
+
case 9:
|
|
35
43
|
result = _context.sent;
|
|
36
44
|
measure.mark(markName, 'resolved');
|
|
45
|
+
succeedUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
37
46
|
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeSucceededEvent({
|
|
38
|
-
id: experienceId,
|
|
39
|
-
extensionKey: extensionKey,
|
|
40
47
|
actionType: actionType,
|
|
41
48
|
display: display
|
|
42
49
|
});
|
|
43
50
|
return _context.abrupt("return", result);
|
|
44
|
-
case
|
|
45
|
-
_context.prev =
|
|
51
|
+
case 16:
|
|
52
|
+
_context.prev = 16;
|
|
46
53
|
_context.t0 = _context["catch"](4);
|
|
47
54
|
measure.mark(markName, 'errored');
|
|
55
|
+
failUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
48
56
|
reason = typeof _context.t0 === 'string' ? _context.t0 : _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message;
|
|
49
57
|
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeFailedEvent({
|
|
50
|
-
id: experienceId,
|
|
51
|
-
extensionKey: extensionKey,
|
|
52
58
|
actionType: actionType,
|
|
53
59
|
display: display,
|
|
54
60
|
reason: reason
|
|
55
61
|
});
|
|
56
|
-
case
|
|
62
|
+
case 22:
|
|
57
63
|
case "end":
|
|
58
64
|
return _context.stop();
|
|
59
65
|
}
|
|
60
|
-
}, _callee, null, [[4,
|
|
66
|
+
}, _callee, null, [[4, 16]]);
|
|
61
67
|
}));
|
|
62
68
|
return function (_x) {
|
|
63
69
|
return _ref3.apply(this, arguments);
|