@atlaskit/smart-card 26.12.1 → 26.13.1
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/messages.js +21 -1
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +8 -0
- package/dist/cjs/utils/analytics/analytics.js +139 -125
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -5
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +31 -18
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +6 -1
- package/dist/es2019/messages.js +21 -1
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +8 -1
- package/dist/es2019/utils/analytics/analytics.js +13 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +13 -5
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +33 -20
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +6 -1
- package/dist/esm/messages.js +21 -1
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +9 -1
- package/dist/esm/utils/analytics/analytics.js +130 -117
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -5
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +33 -20
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +6 -1
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +4 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +2 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -0
- package/dist/types/utils/analytics/analytics.d.ts +1 -0
- package/dist/types/utils/mocks.d.ts +1 -0
- package/dist/types-ts4.5/messages.d.ts +1 -1
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +4 -0
- package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +2 -0
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +1 -0
- package/dist/types-ts4.5/utils/analytics/analytics.d.ts +1 -0
- package/dist/types-ts4.5/utils/mocks.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +1 -0
- package/tmp/api-report-tmp.d.ts +1 -0
|
@@ -4,7 +4,7 @@ import { chunkloadFailedEvent, connectFailedEvent, connectSucceededEvent, contex
|
|
|
4
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
5
5
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getStatusDetails, getSubproduct } from '../helpers';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
|
-
import { trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
7
|
+
import { trackHoverCardResolutionStarted, 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) {
|
|
@@ -759,6 +759,13 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
759
759
|
smartLinkQuickActionFailed: props => dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionFailed({
|
|
760
760
|
...commonAttributes,
|
|
761
761
|
...props
|
|
762
|
+
}), commonAttributes)),
|
|
763
|
+
/**
|
|
764
|
+
* Fires a track event when we call loadMetadata() to get information for a hover card
|
|
765
|
+
*/
|
|
766
|
+
hoverCardResolutionStarted: () => dispatchAnalytics(applyCommonAttributes(trackHoverCardResolutionStarted({
|
|
767
|
+
display: 'hoverCardPreview',
|
|
768
|
+
...commonAttributes
|
|
762
769
|
}), commonAttributes))
|
|
763
770
|
}), [commonAttributes, dispatchAnalytics]);
|
|
764
771
|
|
|
@@ -270,6 +270,19 @@ export const trackSmartLinkQuickActionFailed = ({
|
|
|
270
270
|
smartLinkActionType
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
|
+
export const trackHoverCardResolutionStarted = ({
|
|
274
|
+
display,
|
|
275
|
+
...attributes
|
|
276
|
+
}) => ({
|
|
277
|
+
action: 'resolved',
|
|
278
|
+
actionSubject: 'hoverCard',
|
|
279
|
+
eventType: 'track',
|
|
280
|
+
attributes: {
|
|
281
|
+
...context,
|
|
282
|
+
...attributes,
|
|
283
|
+
display
|
|
284
|
+
}
|
|
285
|
+
});
|
|
273
286
|
export const uiAuthEvent = ({
|
|
274
287
|
definitionId,
|
|
275
288
|
extensionKey,
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
2
4
|
import FlexibleCard from '../../../FlexibleCard';
|
|
3
5
|
import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
|
|
4
6
|
import BlockCardFooter from '../../components/flexible/footer';
|
|
@@ -8,6 +10,7 @@ import { extractProvider } from '@atlaskit/link-extractors';
|
|
|
8
10
|
import UnauthorisedViewContent from '../../../common/UnauthorisedViewContent';
|
|
9
11
|
import { css } from '@emotion/react';
|
|
10
12
|
import { tokens } from '../../../../utils/token';
|
|
13
|
+
import { messages } from '../../../../messages';
|
|
11
14
|
const contentStyles = css`
|
|
12
15
|
color: ${tokens.text};
|
|
13
16
|
margin-top: 0.5rem;
|
|
@@ -44,6 +47,15 @@ const FlexibleUnauthorisedView = ({
|
|
|
44
47
|
onAuthorize();
|
|
45
48
|
}
|
|
46
49
|
}, [onAuthorize, extensionKey, analytics.track]);
|
|
50
|
+
const content = useMemo(() => onAuthorize ? /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
51
|
+
providerName: providerName,
|
|
52
|
+
analytics: analytics,
|
|
53
|
+
testId: testId
|
|
54
|
+
}) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[providerName ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider'], {
|
|
55
|
+
values: {
|
|
56
|
+
context: providerName
|
|
57
|
+
}
|
|
58
|
+
})), [analytics, onAuthorize, providerName, testId]);
|
|
47
59
|
const actions = useMemo(() => onAuthorize ? [AuthorizeAction(handleAuthorize, providerName)] : [], [handleAuthorize, onAuthorize, providerName]);
|
|
48
60
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
49
61
|
appearance: "block",
|
|
@@ -60,11 +72,7 @@ const FlexibleUnauthorisedView = ({
|
|
|
60
72
|
}), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
61
73
|
overrideCss: contentStyles,
|
|
62
74
|
testId: `${testId}-content`
|
|
63
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(
|
|
64
|
-
providerName: providerName,
|
|
65
|
-
analytics: analytics,
|
|
66
|
-
testId: testId
|
|
67
|
-
}))), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
75
|
+
}, /*#__PURE__*/React.createElement("div", null, content)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
68
76
|
actions: actions,
|
|
69
77
|
status: SmartLinkStatus.Unauthorized,
|
|
70
78
|
actionGroupAppearance: "primary"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { EmbedCardUnresolvedView } from './UnresolvedView';
|
|
3
|
-
import { UnauthorisedImage } from '../constants';
|
|
3
|
+
import { LockImage, UnauthorisedImage } from '../constants';
|
|
4
4
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
5
5
|
import { ImageIcon } from '../components/ImageIcon';
|
|
6
6
|
import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
|
|
@@ -15,7 +15,6 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
15
15
|
onClick,
|
|
16
16
|
extensionKey
|
|
17
17
|
}) => {
|
|
18
|
-
var _context$image;
|
|
19
18
|
const icon = context && context.icon && /*#__PURE__*/React.createElement(ImageIcon, {
|
|
20
19
|
src: typeof context.icon === 'string' ? context.icon : undefined
|
|
21
20
|
});
|
|
@@ -27,6 +26,36 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
27
26
|
onAuthorise();
|
|
28
27
|
}
|
|
29
28
|
}, [onAuthorise, analytics.track, extensionKey]);
|
|
29
|
+
const view = useMemo(() => {
|
|
30
|
+
var _context$image2;
|
|
31
|
+
if (onAuthorise) {
|
|
32
|
+
var _context$image;
|
|
33
|
+
return /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
|
|
34
|
+
button: {
|
|
35
|
+
appearance: 'primary',
|
|
36
|
+
text: 'connect_unauthorised_account_action',
|
|
37
|
+
testId: 'connect-account'
|
|
38
|
+
},
|
|
39
|
+
context: context && context.text,
|
|
40
|
+
description: "connect_unauthorised_account_description",
|
|
41
|
+
image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : UnauthorisedImage,
|
|
42
|
+
onClick: handleOnAuthorizeClick,
|
|
43
|
+
testId: testId,
|
|
44
|
+
title: "connect_link_account_card_name"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
46
|
+
analytics: analytics,
|
|
47
|
+
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
48
|
+
testId: testId
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
|
|
52
|
+
description: context !== null && context !== void 0 && context.text ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider',
|
|
53
|
+
image: (_context$image2 = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image2 !== void 0 ? _context$image2 : LockImage,
|
|
54
|
+
context: context === null || context === void 0 ? void 0 : context.text,
|
|
55
|
+
testId: testId,
|
|
56
|
+
title: context !== null && context !== void 0 && context.text ? 'unauthorised_account_name' : 'unauthorised_account_name_no_provider'
|
|
57
|
+
});
|
|
58
|
+
}, [analytics, context, handleOnAuthorizeClick, onAuthorise, testId]);
|
|
30
59
|
return /*#__PURE__*/React.createElement(ExpandedFrame, {
|
|
31
60
|
href: link,
|
|
32
61
|
icon: icon,
|
|
@@ -37,21 +66,5 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
37
66
|
onClick: onClick,
|
|
38
67
|
testId: testId,
|
|
39
68
|
allowScrollBar: true
|
|
40
|
-
},
|
|
41
|
-
image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : UnauthorisedImage,
|
|
42
|
-
title: "connect_link_account_card_name",
|
|
43
|
-
description: "connect_unauthorised_account_description",
|
|
44
|
-
context: context && context.text,
|
|
45
|
-
button: onAuthorise ? {
|
|
46
|
-
appearance: 'primary',
|
|
47
|
-
text: 'connect_unauthorised_account_action',
|
|
48
|
-
testId: 'connect-account'
|
|
49
|
-
} : undefined,
|
|
50
|
-
onClick: onAuthorise ? handleOnAuthorizeClick : undefined,
|
|
51
|
-
testId: testId
|
|
52
|
-
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
53
|
-
analytics: analytics,
|
|
54
|
-
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
55
|
-
testId: testId
|
|
56
|
-
})));
|
|
69
|
+
}, view);
|
|
57
70
|
};
|
|
@@ -12,6 +12,7 @@ import { CardDisplay } from '../../../constants';
|
|
|
12
12
|
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
13
13
|
import { useSmartCardActions } from '../../../state/actions';
|
|
14
14
|
import { useSmartLinkAnalytics } from '../../../state/analytics';
|
|
15
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
15
16
|
const HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
|
|
16
17
|
const FADE_IN_DELAY = 500;
|
|
17
18
|
const FADE_OUT_DELAY = 300;
|
|
@@ -41,6 +42,7 @@ export const HoverCardComponent = ({
|
|
|
41
42
|
const {
|
|
42
43
|
loadMetadata
|
|
43
44
|
} = useSmartCardActions(id, url, analytics);
|
|
45
|
+
const enableHoverCardResolutionTracking = useFeatureFlag('enableHoverCardResolutionTracking');
|
|
44
46
|
const setMousePosition = useCallback(event => {
|
|
45
47
|
if (isOpen && canOpen) {
|
|
46
48
|
return;
|
|
@@ -108,9 +110,12 @@ export const HoverCardComponent = ({
|
|
|
108
110
|
if (!resolveTimeOutId.current && isLinkUnresolved) {
|
|
109
111
|
resolveTimeOutId.current = setTimeout(() => {
|
|
110
112
|
loadMetadata();
|
|
113
|
+
if (enableHoverCardResolutionTracking) {
|
|
114
|
+
analytics.track.hoverCardResolutionStarted();
|
|
115
|
+
}
|
|
111
116
|
}, RESOLVE_DELAY);
|
|
112
117
|
}
|
|
113
|
-
}, [linkState, loadMetadata]);
|
|
118
|
+
}, [analytics.track, enableHoverCardResolutionTracking, linkState.metadataStatus, linkState.status, loadMetadata]);
|
|
114
119
|
const initShowCard = useCallback(event => {
|
|
115
120
|
// clearing out fadeOutTimeoutId in case it's already counting down to hide the card
|
|
116
121
|
if (fadeOutTimeoutId.current) {
|
package/dist/esm/messages.js
CHANGED
|
@@ -86,7 +86,7 @@ export var messages = defineMessages({
|
|
|
86
86
|
description: 'Shown when a user does not have access to a link, but can connect their external account to view the link on card view.'
|
|
87
87
|
},
|
|
88
88
|
connect_unauthorised_account_description_no_provider: {
|
|
89
|
-
id: 'fabric.linking.
|
|
89
|
+
id: 'fabric.linking.connect_unauthorised_account_description_no_provider',
|
|
90
90
|
defaultMessage: 'Connect to Atlassian to view more details of your work and collaborate from one place.',
|
|
91
91
|
description: 'Shown when a user does not have access to a link, but can connect their external account to view the link on card view and we do not have the providers name.'
|
|
92
92
|
},
|
|
@@ -386,6 +386,26 @@ export var messages = defineMessages({
|
|
|
386
386
|
defaultMessage: 'The link {unsafeLinkText} is taking you to a different site, <a>actual link here</a>',
|
|
387
387
|
description: 'Link safety check warning message'
|
|
388
388
|
},
|
|
389
|
+
unauthorised_account_description: {
|
|
390
|
+
id: 'fabric.linking.unauthorised_account_description',
|
|
391
|
+
defaultMessage: "You're trying to preview a link to a private {context} page. We recommend you review the URL or contact the page owner.",
|
|
392
|
+
description: 'Explains that user does not have access to a link.'
|
|
393
|
+
},
|
|
394
|
+
unauthorised_account_description_no_provider: {
|
|
395
|
+
id: 'fabric.linking.unauthorised_account_description_no_provider',
|
|
396
|
+
defaultMessage: "You're trying to preview a link to a private page. We recommend you review the URL or contact the page owner.",
|
|
397
|
+
description: 'Explains that user does not have access to a link.'
|
|
398
|
+
},
|
|
399
|
+
unauthorised_account_name: {
|
|
400
|
+
id: 'fabric.linking.unauthorised_account_name',
|
|
401
|
+
defaultMessage: "We can't display private pages from {context}",
|
|
402
|
+
description: 'Shown when a user does not have access to a link.'
|
|
403
|
+
},
|
|
404
|
+
unauthorised_account_name_no_provider: {
|
|
405
|
+
id: 'fabric.linking.unauthorised_account_name_no_provider',
|
|
406
|
+
defaultMessage: "We can't display private pages",
|
|
407
|
+
description: 'Shown when a user does not have access to a link.'
|
|
408
|
+
},
|
|
389
409
|
unlink_account: {
|
|
390
410
|
id: 'fabric.linking.unlink_account',
|
|
391
411
|
defaultMessage: 'Unlink Account',
|
|
@@ -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 { trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
11
|
+
import { trackHoverCardResolutionStarted, 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) {
|
|
@@ -769,6 +769,14 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
|
|
|
769
769
|
*/
|
|
770
770
|
smartLinkQuickActionFailed: function smartLinkQuickActionFailed(props) {
|
|
771
771
|
return dispatchAnalytics(applyCommonAttributes(trackSmartLinkQuickActionFailed(_objectSpread(_objectSpread({}, commonAttributes), props)), commonAttributes));
|
|
772
|
+
},
|
|
773
|
+
/**
|
|
774
|
+
* Fires a track event when we call loadMetadata() to get information for a hover card
|
|
775
|
+
*/
|
|
776
|
+
hoverCardResolutionStarted: function hoverCardResolutionStarted() {
|
|
777
|
+
return dispatchAnalytics(applyCommonAttributes(trackHoverCardResolutionStarted(_objectSpread({
|
|
778
|
+
display: 'hoverCardPreview'
|
|
779
|
+
}, commonAttributes)), commonAttributes));
|
|
772
780
|
}
|
|
773
781
|
};
|
|
774
782
|
}, [commonAttributes, dispatchAnalytics]);
|