@atlaskit/smart-card 32.5.1 → 32.7.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 +30 -0
- package/analytics.spec.yaml +163 -0
- package/dist/cjs/state/actions/index.js +53 -49
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +14 -128
- package/dist/cjs/utils/analytics/analytics.js +150 -234
- package/dist/cjs/utils/analytics/index.js +1 -89
- package/dist/cjs/view/CardWithUrl/component.js +37 -40
- package/dist/cjs/view/CardWithUrl/loader.js +7 -16
- package/dist/cjs/view/EmbedCard/index.js +19 -44
- package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +12 -3
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +11 -2
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +10 -2
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +64 -20
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/common/Metadata.js +1 -1
- package/dist/cjs/view/common/UnauthorisedViewContent.js +10 -2
- package/dist/es2019/state/actions/index.js +53 -49
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +15 -136
- package/dist/es2019/utils/analytics/analytics.js +43 -133
- package/dist/es2019/utils/analytics/index.js +1 -61
- package/dist/es2019/view/CardWithUrl/component.js +37 -40
- package/dist/es2019/view/CardWithUrl/loader.js +7 -16
- package/dist/es2019/view/EmbedCard/index.js +20 -45
- package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +12 -3
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +11 -2
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +11 -2
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +63 -20
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/common/Metadata.js +1 -1
- package/dist/es2019/view/common/UnauthorisedViewContent.js +11 -2
- package/dist/esm/state/actions/index.js +53 -49
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +15 -129
- package/dist/esm/utils/analytics/analytics.js +149 -233
- package/dist/esm/utils/analytics/index.js +1 -59
- package/dist/esm/view/CardWithUrl/component.js +37 -40
- package/dist/esm/view/CardWithUrl/loader.js +7 -16
- package/dist/esm/view/EmbedCard/index.js +19 -44
- package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +12 -3
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +11 -2
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +10 -2
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +65 -21
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/common/Metadata.js +1 -1
- package/dist/esm/view/common/UnauthorisedViewContent.js +10 -2
- package/dist/types/common/analytics/generated/analytics.types.d.ts +83 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +15 -38
- package/dist/types/state/hooks/useSmartLink.d.ts +0 -4
- package/dist/types/utils/analytics/analytics.d.ts +32 -16
- package/dist/types/utils/analytics/index.d.ts +1 -7
- package/dist/types/utils/analytics/types.d.ts +22 -22
- package/dist/types/utils/mocks.d.ts +0 -4
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +83 -1
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +15 -38
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +0 -4
- package/dist/types-ts4.5/utils/analytics/analytics.d.ts +32 -16
- package/dist/types-ts4.5/utils/analytics/index.d.ts +1 -7
- package/dist/types-ts4.5/utils/analytics/types.d.ts +22 -22
- package/dist/types-ts4.5/utils/mocks.d.ts +0 -4
- package/package.json +14 -17
|
@@ -76,16 +76,25 @@ function Component({
|
|
|
76
76
|
// Setup UI handlers.
|
|
77
77
|
const handleClickWrapper = useCallback(event => {
|
|
78
78
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
80
|
+
fireEvent('ui.smartLink.clicked', {
|
|
81
|
+
id,
|
|
82
|
+
display: isFlexibleUi ? CardDisplay.Flexible : appearance,
|
|
83
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
84
|
+
isModifierKeyPressed
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
analytics.ui.cardClickedEvent({
|
|
88
|
+
id,
|
|
89
|
+
display: isFlexibleUi ? CardDisplay.Flexible : appearance,
|
|
90
|
+
status: state.status,
|
|
91
|
+
definitionId,
|
|
92
|
+
extensionKey,
|
|
93
|
+
isModifierKeyPressed,
|
|
94
|
+
destinationProduct: product,
|
|
95
|
+
destinationSubproduct: subproduct
|
|
96
|
+
});
|
|
97
|
+
}
|
|
89
98
|
if (!onClick && !isFlexibleUi) {
|
|
90
99
|
const clickUrl = getClickUrl(url, state.details);
|
|
91
100
|
// Ctrl+left click on mac typically doesn't trigger onClick
|
|
@@ -105,7 +114,7 @@ function Component({
|
|
|
105
114
|
}
|
|
106
115
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
107
116
|
}
|
|
108
|
-
}, [id, url, state.details, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, isFlexibleUi, product, subproduct, createAnalyticsEvent]);
|
|
117
|
+
}, [id, url, state.details, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, isFlexibleUi, product, subproduct, createAnalyticsEvent, fireEvent]);
|
|
109
118
|
const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
|
|
110
119
|
const handleRetry = useCallback(() => {
|
|
111
120
|
actions.reload();
|
|
@@ -117,39 +126,27 @@ function Component({
|
|
|
117
126
|
useEffect(() => {
|
|
118
127
|
measure.mark(id, state.status);
|
|
119
128
|
if (state.status !== 'pending' && state.status !== 'resolving') {
|
|
129
|
+
var _state$error;
|
|
120
130
|
measure.create(id, state.status);
|
|
121
|
-
if (
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
type: state.error.type
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
var _state$error2;
|
|
142
|
-
analytics.operational.instrument({
|
|
143
|
-
id,
|
|
144
|
-
status: state.status,
|
|
145
|
-
definitionId,
|
|
146
|
-
extensionKey: extensionKey !== null && extensionKey !== void 0 ? extensionKey : (_state$error2 = state.error) === null || _state$error2 === void 0 ? void 0 : _state$error2.extensionKey,
|
|
147
|
-
resourceType,
|
|
148
|
-
error: state.error
|
|
131
|
+
if (state.status === 'resolved') {
|
|
132
|
+
var _measure$getMeasure$d, _measure$getMeasure;
|
|
133
|
+
fireEvent('operational.smartLink.resolved', {
|
|
134
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
135
|
+
duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(id, state.status)) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null
|
|
136
|
+
});
|
|
137
|
+
} else if (((_state$error = state.error) === null || _state$error === void 0 ? void 0 : _state$error.type) !== 'ResolveUnsupportedError') {
|
|
138
|
+
fireEvent('operational.smartLink.unresolved', {
|
|
139
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
140
|
+
reason: state.status,
|
|
141
|
+
error: state.error === undefined ? null : {
|
|
142
|
+
name: state.error.name,
|
|
143
|
+
kind: state.error.kind,
|
|
144
|
+
type: state.error.type
|
|
145
|
+
}
|
|
149
146
|
});
|
|
150
147
|
}
|
|
151
148
|
}
|
|
152
|
-
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType,
|
|
149
|
+
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, fireEvent]);
|
|
153
150
|
|
|
154
151
|
// NB: once the smart-card has rendered into an end state, we capture
|
|
155
152
|
// this as a successful render. These can be one of:
|
|
@@ -2,7 +2,6 @@ import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
3
|
import { di } from 'react-magnetic-di';
|
|
4
4
|
import uuid from 'uuid';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
7
6
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
8
7
|
import { importWithRetry } from '../../utils';
|
|
@@ -65,20 +64,12 @@ export function CardWithURLRenderer(props) {
|
|
|
65
64
|
// to the reliability of the smart-card front-end components.
|
|
66
65
|
// Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
|
|
67
66
|
if (error.name === 'ChunkLoadError') {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
analytics.operational.chunkloadFailedEvent({
|
|
77
|
-
display: appearance,
|
|
78
|
-
error,
|
|
79
|
-
errorInfo
|
|
80
|
-
});
|
|
81
|
-
}
|
|
67
|
+
fireEvent('operational.smartLink.chunkLoadFailed', {
|
|
68
|
+
display: appearance,
|
|
69
|
+
error: error,
|
|
70
|
+
errorInfo: errorInfo,
|
|
71
|
+
definitionId: null
|
|
72
|
+
});
|
|
82
73
|
} else if (error.name !== 'APIError') {
|
|
83
74
|
analytics.ui.renderFailedEvent({
|
|
84
75
|
display: isFlexibleUi ? 'flexible' : appearance,
|
|
@@ -92,7 +83,7 @@ export function CardWithURLRenderer(props) {
|
|
|
92
83
|
url: url !== null && url !== void 0 ? url : '',
|
|
93
84
|
err: error
|
|
94
85
|
});
|
|
95
|
-
}, [analytics.
|
|
86
|
+
}, [analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
|
|
96
87
|
if (!url) {
|
|
97
88
|
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
98
89
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import { extractBlockProps } from '../../extractors/block';
|
|
6
4
|
import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
|
|
7
5
|
import { extractEmbedProps } from '../../extractors/embed';
|
|
8
6
|
import { extractInlineProps } from '../../extractors/inline';
|
|
9
7
|
import { getExtensionKey, hasAuthScopeOverrides } from '../../state/helpers';
|
|
10
8
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
11
|
-
import { BlockCardResolvedView, BlockCardResolvingView } from '../BlockCard';
|
|
12
9
|
import FlexibleResolvedView from '../BlockCard/views/flexible/FlexibleResolvedView';
|
|
13
10
|
import { InlineCardResolvedView } from '../InlineCard/ResolvedView';
|
|
14
11
|
import { EmbedCardErroredView } from './views/ErroredView';
|
|
@@ -23,7 +20,6 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
23
20
|
handleErrorRetry,
|
|
24
21
|
handleFrameClick,
|
|
25
22
|
analytics,
|
|
26
|
-
handleInvoke,
|
|
27
23
|
isSelected,
|
|
28
24
|
frameStyle,
|
|
29
25
|
platform,
|
|
@@ -52,23 +48,16 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
52
48
|
switch (status) {
|
|
53
49
|
case 'pending':
|
|
54
50
|
case 'resolving':
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
testId: testId
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
|
|
69
|
-
testId: "embed-card-resolving-view",
|
|
70
|
-
inheritDimensions: inheritDimensions,
|
|
71
|
-
isSelected: isSelected
|
|
51
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
52
|
+
url: url,
|
|
53
|
+
cardState: cardState,
|
|
54
|
+
onClick: handleFrameClick,
|
|
55
|
+
onError: onError,
|
|
56
|
+
onResolve: onResolve,
|
|
57
|
+
renderers: renderers,
|
|
58
|
+
actionOptions: actionOptions,
|
|
59
|
+
analytics: analytics,
|
|
60
|
+
testId: testId ? `${testId}-resolving-view` : 'embed-card-resolving-view'
|
|
72
61
|
});
|
|
73
62
|
case 'resolved':
|
|
74
63
|
const resolvedViewProps = extractEmbedProps(data, meta, platform, iframeUrlType);
|
|
@@ -100,31 +89,17 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
100
89
|
onClick: handleFrameClick
|
|
101
90
|
}));
|
|
102
91
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
testId: testId
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
const resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
117
|
-
analytics,
|
|
118
|
-
origin: 'smartLinkEmbed',
|
|
119
|
-
handleInvoke,
|
|
120
|
-
extensionKey,
|
|
121
|
-
actionOptions
|
|
92
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
93
|
+
url: url,
|
|
94
|
+
cardState: cardState,
|
|
95
|
+
onClick: handleFrameClick,
|
|
96
|
+
onError: onError,
|
|
97
|
+
onResolve: onResolve,
|
|
98
|
+
renderers: renderers,
|
|
99
|
+
actionOptions: actionOptions,
|
|
100
|
+
analytics: analytics,
|
|
101
|
+
testId: testId
|
|
122
102
|
});
|
|
123
|
-
return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
|
|
124
|
-
isSelected: isSelected,
|
|
125
|
-
testId: testId,
|
|
126
|
-
onClick: handleFrameClick
|
|
127
|
-
}));
|
|
128
103
|
}
|
|
129
104
|
case 'unauthorized':
|
|
130
105
|
if (onError) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
|
|
4
5
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
6
|
import useInvoke from '../../../../../../state/hooks/use-invoke';
|
|
@@ -26,9 +27,17 @@ const ServerAction = ({
|
|
|
26
27
|
const smartLinkActionType = (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.actionType;
|
|
27
28
|
try {
|
|
28
29
|
setIsLoading(true);
|
|
29
|
-
|
|
30
|
-
smartLinkActionType
|
|
31
|
-
|
|
30
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
31
|
+
if (smartLinkActionType === 'FollowEntityAction' || smartLinkActionType === 'UnfollowEntityAction') {
|
|
32
|
+
fireEvent('ui.button.clicked.smartLinkFollowButton', {});
|
|
33
|
+
} else {
|
|
34
|
+
fireEvent(`ui.button.clicked.${smartLinkActionType}`, {});
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkServerActionClickedEvent({
|
|
38
|
+
smartLinkActionType
|
|
39
|
+
});
|
|
40
|
+
}
|
|
32
41
|
fireEvent('track.smartLinkQuickAction.started', {
|
|
33
42
|
smartLinkActionType
|
|
34
43
|
});
|
|
@@ -8,6 +8,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { jsx } from '@emotion/react';
|
|
10
10
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
|
|
12
13
|
import extractLozengeActionItems from '../../../../../../extractors/action/extract-lozenge-action-items';
|
|
13
14
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
@@ -63,7 +64,11 @@ const LozengeAction = ({
|
|
|
63
64
|
const handleOpenChange = useCallback(async args => {
|
|
64
65
|
setIsOpen(args.isOpen);
|
|
65
66
|
if (args.isOpen) {
|
|
66
|
-
|
|
67
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
68
|
+
fireEvent('ui.button.clicked.smartLinkStatusLozenge', {});
|
|
69
|
+
} else {
|
|
70
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionClickedEvent();
|
|
71
|
+
}
|
|
67
72
|
fireEvent('track.smartLinkQuickAction.started', {
|
|
68
73
|
smartLinkActionType: TrackQuickActionType.StatusUpdate
|
|
69
74
|
});
|
|
@@ -100,7 +105,11 @@ const LozengeAction = ({
|
|
|
100
105
|
})), [selected.appearance, selected.text, isOpen, testId]);
|
|
101
106
|
const handleItemClick = useCallback(async (id, text, appearance) => {
|
|
102
107
|
try {
|
|
103
|
-
|
|
108
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
109
|
+
fireEvent('ui.button.clicked.smartLinkStatusListItem', {});
|
|
110
|
+
} else {
|
|
111
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionListItemClickedEvent();
|
|
112
|
+
}
|
|
104
113
|
const updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
105
114
|
if (updateAction && id) {
|
|
106
115
|
setIsLoading(true);
|
|
@@ -9,7 +9,9 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
import { FormattedMessage } from 'react-intl-next';
|
|
10
10
|
import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
11
11
|
import ErrorIcon from '@atlaskit/icon/core/migration/error';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { R50, R500 } from '@atlaskit/theme/colors';
|
|
14
|
+
import { useAnalyticsEvents } from '../../../../../../../common/analytics/generated/use-analytics-events';
|
|
13
15
|
import { messages } from '../../../../../../../messages';
|
|
14
16
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../../state/flexible-ui-context';
|
|
15
17
|
import useResolve from '../../../../../../../state/hooks/use-resolve';
|
|
@@ -23,6 +25,9 @@ const LozengeActionError = ({
|
|
|
23
25
|
url,
|
|
24
26
|
previewData
|
|
25
27
|
}) => {
|
|
28
|
+
const {
|
|
29
|
+
fireEvent
|
|
30
|
+
} = useAnalyticsEvents();
|
|
26
31
|
const reload = useResolve();
|
|
27
32
|
const analytics = useFlexibleUiAnalyticsContext();
|
|
28
33
|
const isPreviewAvailable = previewData && previewData.src !== undefined;
|
|
@@ -33,14 +38,18 @@ const LozengeActionError = ({
|
|
|
33
38
|
}, [reload, url]);
|
|
34
39
|
const handlePreviewOpen = useCallback(() => {
|
|
35
40
|
if (isPreviewAvailable) {
|
|
36
|
-
|
|
41
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
42
|
+
fireEvent('ui.button.clicked.smartLinkStatusOpenPreview', {});
|
|
43
|
+
} else {
|
|
44
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionErrorOpenPreviewClickedEvent();
|
|
45
|
+
}
|
|
37
46
|
return openEmbedModalWithFlexibleUiIcon({
|
|
38
47
|
...previewData,
|
|
39
48
|
analytics,
|
|
40
49
|
onClose: handlePreviewClose
|
|
41
50
|
});
|
|
42
51
|
}
|
|
43
|
-
}, [analytics, handlePreviewClose, isPreviewAvailable, previewData]);
|
|
52
|
+
}, [analytics, handlePreviewClose, isPreviewAvailable, previewData, fireEvent]);
|
|
44
53
|
const content = useMemo(() => {
|
|
45
54
|
return jsx(Fragment, null, jsx("div", {
|
|
46
55
|
css: contentStyles
|
|
@@ -6,11 +6,13 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
|
-
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
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
|
+
import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
|
|
11
13
|
import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
12
14
|
import { useSmartLinkAnalytics } from '../../../state/analytics';
|
|
13
|
-
import { getExtensionKey, getServices } from '../../../state/helpers';
|
|
15
|
+
import { getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
14
16
|
import { useSmartCardState } from '../../../state/store';
|
|
15
17
|
import { isSpecialEvent } from '../../../utils';
|
|
16
18
|
import { getIsAISummaryEnabled } from '../../../utils/ai-summary';
|
|
@@ -38,12 +40,16 @@ const HoverCardContent = ({
|
|
|
38
40
|
var _linkState$status, _cardState$details;
|
|
39
41
|
const {
|
|
40
42
|
createAnalyticsEvent
|
|
43
|
+
} = useAnalyticsEventsNext();
|
|
44
|
+
const {
|
|
45
|
+
fireEvent
|
|
41
46
|
} = useAnalyticsEvents();
|
|
42
47
|
const defaultAnalytics = useSmartLinkAnalytics(url, id);
|
|
43
48
|
const analytics = _analytics !== null && _analytics !== void 0 ? _analytics : defaultAnalytics;
|
|
44
49
|
const extensionKey = useMemo(() => getExtensionKey(cardState.details), [cardState.details]);
|
|
45
50
|
const linkState = useSmartCardState(url);
|
|
46
51
|
const linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
52
|
+
const definitionId = useMemo(() => getDefinitionId(cardState.details), [cardState.details]);
|
|
47
53
|
const {
|
|
48
54
|
isAdminHubAIEnabled
|
|
49
55
|
} = useSmartLinkContext();
|
|
@@ -51,6 +57,8 @@ const HoverCardContent = ({
|
|
|
51
57
|
const services = getServices(linkState.details);
|
|
52
58
|
const statusRef = useRef(linkStatus);
|
|
53
59
|
const analyticsRef = useRef(analytics);
|
|
60
|
+
const fireEventRef = useRef(fireEvent);
|
|
61
|
+
const definitionIdRef = useRef(definitionId);
|
|
54
62
|
useEffect(() => {
|
|
55
63
|
/**
|
|
56
64
|
* Must access current analytics object value via ref because its not stable
|
|
@@ -62,37 +70,72 @@ const HoverCardContent = ({
|
|
|
62
70
|
if (statusRef.current !== linkStatus) {
|
|
63
71
|
statusRef.current = linkStatus;
|
|
64
72
|
}
|
|
65
|
-
|
|
73
|
+
if (fireEventRef.current !== fireEvent) {
|
|
74
|
+
fireEventRef.current = fireEvent;
|
|
75
|
+
}
|
|
76
|
+
if (definitionIdRef.current !== definitionId) {
|
|
77
|
+
definitionIdRef.current = definitionId;
|
|
78
|
+
}
|
|
79
|
+
}, [analytics, linkStatus, fireEvent, definitionId]);
|
|
66
80
|
useEffect(() => {
|
|
67
81
|
const previewDisplay = 'card';
|
|
68
82
|
const previewInvokeMethod = 'mouse_hover';
|
|
69
83
|
const cardOpenTime = Date.now();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
const fireEventCurrent = fireEventRef.current;
|
|
85
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
86
|
+
var _definitionIdRef$curr;
|
|
87
|
+
fireEventCurrent('ui.hoverCard.viewed', {
|
|
88
|
+
previewDisplay,
|
|
89
|
+
previewInvokeMethod,
|
|
90
|
+
definitionId: (_definitionIdRef$curr = definitionIdRef.current) !== null && _definitionIdRef$curr !== void 0 ? _definitionIdRef$curr : null
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
analyticsRef.current.ui.hoverCardViewedEvent({
|
|
78
94
|
previewDisplay,
|
|
79
95
|
previewInvokeMethod,
|
|
80
|
-
hoverTime,
|
|
81
96
|
status: statusRef.current
|
|
82
97
|
});
|
|
98
|
+
}
|
|
99
|
+
return () => {
|
|
100
|
+
const hoverTime = Date.now() - cardOpenTime;
|
|
101
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
102
|
+
var _definitionIdRef$curr2;
|
|
103
|
+
fireEventCurrent('ui.hoverCard.dismissed', {
|
|
104
|
+
previewDisplay,
|
|
105
|
+
previewInvokeMethod,
|
|
106
|
+
hoverTime,
|
|
107
|
+
definitionId: (_definitionIdRef$curr2 = definitionIdRef.current) !== null && _definitionIdRef$curr2 !== void 0 ? _definitionIdRef$curr2 : null
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
analyticsRef.current.ui.hoverCardDismissedEvent({
|
|
111
|
+
previewDisplay,
|
|
112
|
+
previewInvokeMethod,
|
|
113
|
+
hoverTime,
|
|
114
|
+
status: statusRef.current
|
|
115
|
+
});
|
|
116
|
+
}
|
|
83
117
|
};
|
|
84
118
|
}, []);
|
|
85
119
|
const onClick = useCallback(event => {
|
|
86
120
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
121
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
122
|
+
fireEvent('ui.smartLink.clicked.titleGoToLink', {
|
|
123
|
+
id,
|
|
124
|
+
display: CardDisplay.HoverCardPreview,
|
|
125
|
+
isModifierKeyPressed,
|
|
126
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
analytics.ui.cardClickedEvent({
|
|
130
|
+
id,
|
|
131
|
+
display: CardDisplay.HoverCardPreview,
|
|
132
|
+
status: cardState.status,
|
|
133
|
+
isModifierKeyPressed,
|
|
134
|
+
actionSubjectId: 'titleGoToLink'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
94
137
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
95
|
-
}, [createAnalyticsEvent, cardState.status, analytics.ui, id]);
|
|
138
|
+
}, [createAnalyticsEvent, cardState.status, analytics.ui, id, fireEvent, definitionId]);
|
|
96
139
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
97
140
|
const {
|
|
98
141
|
subtitle
|
|
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
10
10
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
11
11
|
const PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "32.
|
|
13
|
+
packageVersion: "32.7.0",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -16,7 +16,7 @@ const imgStyles = css({
|
|
|
16
16
|
height: "var(--ds-space-100, 8px)"
|
|
17
17
|
});
|
|
18
18
|
const textStyles = css({
|
|
19
|
-
|
|
19
|
+
font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
20
20
|
color: `${`var(--ds-text-subtlest, ${N300})`}`,
|
|
21
21
|
marginRight: "var(--ds-space-050, 4px)",
|
|
22
22
|
marginLeft: "var(--ds-space-025, 2px)"
|
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
4
6
|
import { CONTENT_URL_3P_ACCOUNT_AUTH, CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
|
|
5
7
|
import { messages } from '../../messages';
|
|
6
8
|
/**
|
|
@@ -13,9 +15,16 @@ const UnauthorisedViewContent = ({
|
|
|
13
15
|
testId = 'unauthorised-view-content',
|
|
14
16
|
analytics
|
|
15
17
|
}) => {
|
|
18
|
+
const {
|
|
19
|
+
fireEvent
|
|
20
|
+
} = useAnalyticsEvents();
|
|
16
21
|
const handleLearnMoreClick = useCallback(() => {
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
if (fg('platform_migrate-some-ui-events-smart-card')) {
|
|
23
|
+
fireEvent('ui.button.clicked.learnMore', {});
|
|
24
|
+
} else {
|
|
25
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.learnMoreClickedEvent();
|
|
26
|
+
}
|
|
27
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent]);
|
|
19
28
|
const learnMoreMessage = isProductIntegrationSupported ? messages.learn_more_about_connecting_account : messages.learn_more_about_smart_links;
|
|
20
29
|
return /*#__PURE__*/React.createElement(React.Fragment, null, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_description, {
|
|
21
30
|
values: {
|