@atlaskit/smart-card 19.1.13 → 19.1.14
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 +55 -0
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +255 -34
- package/dist/cjs/state/hooks/useSmartLink.js +1 -1
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +1 -1
- package/dist/cjs/state/hooks-external/useSmartLinkReload.js +1 -1
- package/dist/cjs/state/index.js +9 -1
- package/dist/cjs/utils/analytics/analytics.js +14 -9
- package/dist/cjs/utils/analytics/types.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithData/loader.js +2 -0
- package/dist/cjs/view/CardWithUrl/component.js +12 -8
- package/dist/cjs/view/CardWithUrl/loader.js +5 -3
- package/dist/cjs/view/HoverCard/index.js +3 -1
- package/dist/cjs/view/HoverCard/utils.js +3 -1
- package/dist/cjs/view/InlineCard/ResolvedView/index.js +2 -0
- package/dist/cjs/view/InlineCard/index.js +3 -1
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +196 -30
- package/dist/es2019/state/hooks/useSmartLink.js +1 -1
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +1 -1
- package/dist/es2019/state/hooks-external/useSmartLinkReload.js +1 -1
- package/dist/es2019/state/index.js +2 -1
- package/dist/es2019/utils/analytics/analytics.js +14 -9
- package/dist/es2019/utils/analytics/types.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithData/loader.js +2 -0
- package/dist/es2019/view/CardWithUrl/component.js +12 -8
- package/dist/es2019/view/CardWithUrl/loader.js +5 -3
- package/dist/es2019/view/HoverCard/index.js +3 -1
- package/dist/es2019/view/HoverCard/utils.js +1 -1
- package/dist/es2019/view/InlineCard/ResolvedView/index.js +2 -0
- package/dist/es2019/view/InlineCard/index.js +2 -0
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +254 -35
- package/dist/esm/state/hooks/useSmartLink.js +1 -1
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +1 -1
- package/dist/esm/state/hooks-external/useSmartLinkReload.js +1 -1
- package/dist/esm/state/index.js +2 -1
- package/dist/esm/utils/analytics/analytics.js +14 -9
- package/dist/esm/utils/analytics/types.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithData/loader.js +2 -0
- package/dist/esm/view/CardWithUrl/component.js +12 -8
- package/dist/esm/view/CardWithUrl/loader.js +5 -3
- package/dist/esm/view/HoverCard/index.js +3 -1
- package/dist/esm/view/HoverCard/utils.js +3 -1
- package/dist/esm/view/InlineCard/ResolvedView/index.js +2 -0
- package/dist/esm/view/InlineCard/index.js +3 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +144 -11
- package/dist/types/state/helpers.d.ts +2 -2
- package/dist/types/state/hooks/useSmartLink.d.ts +8 -10
- package/dist/types/state/index.d.ts +1 -0
- package/dist/types/utils/analytics/analytics.d.ts +6 -6
- package/dist/types/utils/analytics/types.d.ts +1 -0
- package/dist/types/utils/performance.d.ts +1 -1
- package/dist/types/utils/types.d.ts +1 -1
- package/dist/types/view/BlockCard/types.d.ts +1 -0
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +3 -0
- package/dist/types/view/CardWithData/types.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -1
- package/dist/types/view/CardWithUrl/types.d.ts +2 -0
- package/dist/types/view/EmbedCard/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/types.d.ts +4 -0
- package/dist/types/view/HoverCard/index.d.ts +1 -1
- package/dist/types/view/HoverCard/types.d.ts +1 -0
- package/dist/types/view/HoverCard/utils.d.ts +1 -1
- package/dist/types/view/InlineCard/ResolvedView/index.d.ts +2 -0
- package/dist/types/view/InlineCard/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -26,17 +26,19 @@ export function CardWithUrlContent({
|
|
|
26
26
|
inlinePreloaderStyle,
|
|
27
27
|
ui,
|
|
28
28
|
children,
|
|
29
|
-
showHoverPreview
|
|
29
|
+
showHoverPreview,
|
|
30
|
+
analyticsEvents
|
|
30
31
|
}) {
|
|
31
32
|
// Get state, actions for this card.
|
|
32
33
|
const {
|
|
33
34
|
state,
|
|
34
35
|
actions,
|
|
36
|
+
analytics: defaultAnalytics,
|
|
35
37
|
config,
|
|
36
|
-
analytics,
|
|
37
38
|
renderers,
|
|
38
39
|
error
|
|
39
40
|
} = useSmartLink(id, url, dispatchAnalytics);
|
|
41
|
+
const analytics = analyticsEvents || defaultAnalytics;
|
|
40
42
|
const definitionId = getDefinitionId(state.details);
|
|
41
43
|
const extensionKey = getExtensionKey(state.details);
|
|
42
44
|
const resourceType = getResourceType(state.details);
|
|
@@ -48,17 +50,15 @@ export function CardWithUrlContent({
|
|
|
48
50
|
isSpecialEvent(event) ? window.open(clickUrl, '_blank') : window.open(clickUrl, '_self');
|
|
49
51
|
}, [state.details, url]);
|
|
50
52
|
const handleClickWrapper = useCallback(event => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
|
|
54
|
-
}
|
|
53
|
+
const isModifierKeyPressed = isSpecialEvent(event);
|
|
54
|
+
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed);
|
|
55
55
|
|
|
56
56
|
if (onClick) {
|
|
57
57
|
onClick(event);
|
|
58
58
|
} else if (!isFlexibleUi) {
|
|
59
59
|
handleClick(event);
|
|
60
60
|
}
|
|
61
|
-
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
61
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
62
62
|
const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
|
|
63
63
|
const handleRetry = useCallback(() => {
|
|
64
64
|
actions.reload();
|
|
@@ -80,7 +80,7 @@ export function CardWithUrlContent({
|
|
|
80
80
|
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
if (isFinalState(state.status)) {
|
|
83
|
-
analytics.ui.renderSuccessEvent(appearance, id, definitionId, extensionKey);
|
|
83
|
+
analytics.ui.renderSuccessEvent(appearance, state.status, id, definitionId, extensionKey);
|
|
84
84
|
}
|
|
85
85
|
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
|
|
86
86
|
|
|
@@ -98,6 +98,7 @@ export function CardWithUrlContent({
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
101
|
+
id: id,
|
|
101
102
|
cardState: cardState,
|
|
102
103
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
103
104
|
onClick: handleClickWrapper,
|
|
@@ -117,6 +118,7 @@ export function CardWithUrlContent({
|
|
|
117
118
|
switch (appearance) {
|
|
118
119
|
case 'inline':
|
|
119
120
|
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
121
|
+
id: id,
|
|
120
122
|
url: url,
|
|
121
123
|
renderers: renderers,
|
|
122
124
|
cardState: state,
|
|
@@ -131,6 +133,7 @@ export function CardWithUrlContent({
|
|
|
131
133
|
|
|
132
134
|
case 'block':
|
|
133
135
|
return /*#__PURE__*/React.createElement(BlockCard, {
|
|
136
|
+
id: id,
|
|
134
137
|
url: url,
|
|
135
138
|
renderers: renderers,
|
|
136
139
|
authFlow: config && config.authFlow,
|
|
@@ -149,6 +152,7 @@ export function CardWithUrlContent({
|
|
|
149
152
|
|
|
150
153
|
case 'embed':
|
|
151
154
|
return /*#__PURE__*/React.createElement(EmbedCard, {
|
|
155
|
+
id: id,
|
|
152
156
|
url: url,
|
|
153
157
|
cardState: state,
|
|
154
158
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -9,7 +9,7 @@ const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => import(
|
|
|
9
9
|
/* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
|
|
10
10
|
'./component-lazy/index'));
|
|
11
11
|
export function CardWithURLRenderer(props) {
|
|
12
|
-
const [id] = useState(() => uuid());
|
|
12
|
+
const [id] = useState(() => props.id ? props.id : uuid());
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
// ComponentWillUnmount
|
|
15
15
|
return () => {
|
|
@@ -34,7 +34,8 @@ export function CardWithURLRenderer(props) {
|
|
|
34
34
|
createAnalyticsEvent,
|
|
35
35
|
children,
|
|
36
36
|
ui,
|
|
37
|
-
showHoverPreview
|
|
37
|
+
showHoverPreview,
|
|
38
|
+
analyticsEvents
|
|
38
39
|
} = props; // Wrapper around analytics.
|
|
39
40
|
|
|
40
41
|
const dispatchAnalytics = useCallback(analyticsPayload => {
|
|
@@ -94,7 +95,8 @@ export function CardWithURLRenderer(props) {
|
|
|
94
95
|
embedIframeRef,
|
|
95
96
|
inlinePreloaderStyle,
|
|
96
97
|
ui,
|
|
97
|
-
showHoverPreview
|
|
98
|
+
showHoverPreview,
|
|
99
|
+
analyticsEvents
|
|
98
100
|
};
|
|
99
101
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
100
102
|
FallbackComponent: ErrorFallback,
|
|
@@ -20,6 +20,7 @@ import { getSimulatedMetadata } from './utils';
|
|
|
20
20
|
import extractPreview from '../../extractors/flexible/extract-preview';
|
|
21
21
|
export const HoverCardComponent = ({
|
|
22
22
|
children,
|
|
23
|
+
id,
|
|
23
24
|
url,
|
|
24
25
|
createAnalyticsEvent
|
|
25
26
|
}) => {
|
|
@@ -32,7 +33,7 @@ export const HoverCardComponent = ({
|
|
|
32
33
|
const fadeInTimeoutId = useRef();
|
|
33
34
|
const cardOpenTime = useRef();
|
|
34
35
|
const linkState = useLinkState(url);
|
|
35
|
-
const analytics = useSmartLinkAnalytics(analyticsHandler);
|
|
36
|
+
const analytics = useSmartLinkAnalytics(url, analyticsHandler, id);
|
|
36
37
|
const extensionKey = useMemo(() => getExtensionKey(linkState.details), [linkState]);
|
|
37
38
|
const definitionId = useMemo(() => getDefinitionId(linkState.details), [linkState]);
|
|
38
39
|
const initHideCard = useCallback(() => {
|
|
@@ -106,6 +107,7 @@ export const HoverCardComponent = ({
|
|
|
106
107
|
onMouseLeave: initHideCard,
|
|
107
108
|
css: HoverCardContainer
|
|
108
109
|
}, jsx(Card, {
|
|
110
|
+
id: id,
|
|
109
111
|
appearance: "block",
|
|
110
112
|
url: url,
|
|
111
113
|
ui: {
|
|
@@ -22,6 +22,7 @@ export class InlineCardResolvedView extends React.Component {
|
|
|
22
22
|
|
|
23
23
|
render() {
|
|
24
24
|
const {
|
|
25
|
+
id,
|
|
25
26
|
title = '',
|
|
26
27
|
isSelected,
|
|
27
28
|
onClick,
|
|
@@ -46,6 +47,7 @@ export class InlineCardResolvedView extends React.Component {
|
|
|
46
47
|
|
|
47
48
|
if (showHoverPreview && link) {
|
|
48
49
|
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
50
|
+
id: id,
|
|
49
51
|
url: link
|
|
50
52
|
}, inlineCardResolvedView);
|
|
51
53
|
}
|
|
@@ -11,6 +11,7 @@ import { InlineCardResolvingView } from './ResolvingView';
|
|
|
11
11
|
import { InlineCardUnauthorizedView } from './UnauthorisedView';
|
|
12
12
|
export { InlineCardResolvedView, InlineCardResolvingView, InlineCardErroredView, InlineCardForbiddenView, InlineCardUnauthorizedView };
|
|
13
13
|
export const InlineCard = ({
|
|
14
|
+
id,
|
|
14
15
|
url,
|
|
15
16
|
cardState,
|
|
16
17
|
handleAuthorize,
|
|
@@ -53,6 +54,7 @@ export const InlineCard = ({
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedProps, {
|
|
57
|
+
id: id,
|
|
56
58
|
showHoverPreview: showHoverPreview,
|
|
57
59
|
link: url,
|
|
58
60
|
isSelected: isSelected,
|
|
@@ -73,7 +73,7 @@ export var extractPreviewAction = function extractPreviewAction() {
|
|
|
73
73
|
var previewAction = PreviewAction(_objectSpread(_objectSpread({}, metadata), {}, {
|
|
74
74
|
testId: testId,
|
|
75
75
|
onOpen: function onOpen() {
|
|
76
|
-
handleAnalytics(uiRenderSuccessEvent('preview', key));
|
|
76
|
+
handleAnalytics(uiRenderSuccessEvent('preview', 'resolved', key));
|
|
77
77
|
},
|
|
78
78
|
onOpenFailed: function onOpenFailed(error, errorInfo) {
|
|
79
79
|
handleAnalytics(uiRenderFailedEvent('preview', error, errorInfo));
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SmartCardProvider as Provider, SmartCardContext } from './state';
|
|
1
|
+
export { SmartCardProvider as Provider, SmartCardContext, useSmartLinkAnalytics } from './state';
|
|
2
2
|
export { EditorCardProvider, editorCardProvider } from '@atlaskit/link-provider';
|
|
3
3
|
export { APIError } from '@atlaskit/linking-common';
|
|
4
4
|
export { CardClient as Client } from '@atlaskit/link-provider';
|
|
@@ -1,34 +1,149 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getUrl } from '@atlaskit/linking-common';
|
|
3
|
+
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
3
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
|
-
|
|
5
|
+
import { getDefinitionId, getExtensionKey, getResourceType } from '../helpers';
|
|
6
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
|
+
/**
|
|
8
|
+
* This hook provides usage of Smart Link analytics outside of the Card component.
|
|
9
|
+
* Can be provided to Card via the analyticsEvents prop to change the analytics events.
|
|
10
|
+
* @param url URL of the link
|
|
11
|
+
* @param dispatchAnalytics dispatchAnalytics function
|
|
12
|
+
* @param id fallback id of the events sent if no id is available
|
|
13
|
+
* @param defaultLocation location attribute to be used
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchAnalytics, id, defaultLocation) {
|
|
18
|
+
var defaultId = id || 'NULL'; // We don't want to trigger a re-render by using useSmartCardState
|
|
19
|
+
|
|
20
|
+
var _useSmartLinkContext = useSmartLinkContext(),
|
|
21
|
+
store = _useSmartLinkContext.store;
|
|
22
|
+
|
|
23
|
+
var state = getUrl(store, url);
|
|
24
|
+
var extractedDefinitionId = getDefinitionId(state.details);
|
|
25
|
+
var extractedExtensionKey = getExtensionKey(state.details);
|
|
26
|
+
var extractedResourceType = getResourceType(state.details);
|
|
27
|
+
/** Contains all ui analytics events */
|
|
28
|
+
|
|
5
29
|
var ui = useMemo(function () {
|
|
6
30
|
return {
|
|
7
|
-
|
|
31
|
+
/**
|
|
32
|
+
* This fires an event that represents when a user clicks on the authentication
|
|
33
|
+
* call to action with no current authenticated account. (i.e. Connect to Preview).
|
|
34
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
35
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
36
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
authEvent: function authEvent(display) {
|
|
40
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
41
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
8
42
|
return dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey));
|
|
9
43
|
},
|
|
10
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This fires an event that represents when a user clicks on the authentication
|
|
47
|
+
* call to action with a forbidden authenticated account. (i.e. Try another account).
|
|
48
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
49
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
50
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
authAlternateAccountEvent: function authAlternateAccountEvent(display) {
|
|
54
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
55
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
11
56
|
return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
|
|
12
57
|
},
|
|
13
|
-
|
|
14
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This fires an event that represents when a user clicks on a Smart Link.
|
|
61
|
+
* @param id The unique ID for this Smart Link.
|
|
62
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
63
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
64
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
65
|
+
* @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
|
|
66
|
+
* @param location Where the Smart Link is currently rendered.
|
|
67
|
+
* @param destinationProduct The product the Smart Link is linked to.
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
cardClickedEvent: function cardClickedEvent() {
|
|
71
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
72
|
+
var display = arguments.length > 1 ? arguments[1] : undefined;
|
|
73
|
+
var status = arguments.length > 2 ? arguments[2] : undefined;
|
|
74
|
+
var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
|
|
75
|
+
var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
|
|
76
|
+
var isModifierKeyPressed = arguments.length > 5 ? arguments[5] : undefined;
|
|
77
|
+
var location = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultLocation;
|
|
78
|
+
var destinationProduct = arguments.length > 7 ? arguments[7] : undefined;
|
|
79
|
+
return dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct));
|
|
15
80
|
},
|
|
16
|
-
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* This fires an event that represents when a user clicks on a Smart Link action.
|
|
84
|
+
* Note: This also starts the UFO smart-link-action-invocation experience.
|
|
85
|
+
* @param id The unique ID for this Smart Link.
|
|
86
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
87
|
+
* @param actionType The type of the action that was clicked, e.g. PreviewAction
|
|
88
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
89
|
+
* @param invokeType Whether the action invoked made a call to a server.
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
actionClickedEvent: function actionClickedEvent() {
|
|
93
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
94
|
+
var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
|
|
95
|
+
var actionType = arguments.length > 2 ? arguments[2] : undefined;
|
|
96
|
+
var display = arguments.length > 3 ? arguments[3] : undefined;
|
|
97
|
+
var invokeType = arguments.length > 4 ? arguments[4] : undefined;
|
|
17
98
|
startUfoExperience('smart-link-action-invocation', id, {
|
|
18
99
|
actionType: actionType,
|
|
19
100
|
display: display,
|
|
20
101
|
extensionKey: extensionKey,
|
|
21
102
|
invokeType: invokeType
|
|
22
103
|
});
|
|
23
|
-
dispatchAnalytics(uiActionClickedEvent(
|
|
104
|
+
dispatchAnalytics(uiActionClickedEvent(actionType, extensionKey, display));
|
|
24
105
|
},
|
|
25
|
-
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* This fires an event that represents when a user clicks on a hover preview's "navigate to link" button.
|
|
109
|
+
* https://product-fabric.atlassian.net/wiki/spaces/EM/pages/3206743323/Analytics+Metrics+-+Hover+Previews
|
|
110
|
+
* @param previewDisplay What format the preview is in.
|
|
111
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
112
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
113
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
114
|
+
*/
|
|
115
|
+
hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(previewDisplay) {
|
|
116
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
117
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
118
|
+
var previewInvokeMethod = arguments.length > 3 ? arguments[3] : undefined;
|
|
26
119
|
dispatchAnalytics(uiHoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod));
|
|
27
120
|
},
|
|
28
|
-
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* This fires an event that represents when a user closed the authentication window without authenticating after opening it.
|
|
124
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
125
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
126
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
closedAuthEvent: function closedAuthEvent(display) {
|
|
130
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
131
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
29
132
|
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
30
133
|
},
|
|
31
|
-
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* This fires an event that represents when a Smart Link was rendered successfully.
|
|
137
|
+
* Note: this fires even if the Smart Link request errored out.
|
|
138
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
139
|
+
* @param id The unique ID for this Smart Link.
|
|
140
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
141
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
142
|
+
*/
|
|
143
|
+
renderSuccessEvent: function renderSuccessEvent(display, status) {
|
|
144
|
+
var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultId;
|
|
145
|
+
var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
|
|
146
|
+
var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
|
|
32
147
|
succeedUfoExperience('smart-link-rendered', id, {
|
|
33
148
|
extensionKey: extensionKey,
|
|
34
149
|
display: display
|
|
@@ -37,47 +152,131 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
37
152
|
succeedUfoExperience('smart-link-authenticated', id, {
|
|
38
153
|
display: display
|
|
39
154
|
});
|
|
40
|
-
dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
155
|
+
dispatchAnalytics(uiRenderSuccessEvent(display, status, definitionId, extensionKey));
|
|
41
156
|
},
|
|
42
|
-
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* This fires an event that represents a hover preview being opened.
|
|
160
|
+
* @param hoverDisplay Whether the hover preview was displayed as a card or embed.
|
|
161
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
162
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
163
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
hoverCardViewedEvent: function hoverCardViewedEvent(hoverDisplay) {
|
|
167
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
168
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
169
|
+
var previewInvokeMethod = arguments.length > 3 ? arguments[3] : undefined;
|
|
43
170
|
return dispatchAnalytics(uiHoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod));
|
|
44
171
|
},
|
|
45
|
-
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* This fires an event that represents a hover preview being dismissed.
|
|
175
|
+
* @param hoverDisplay Whether the hover preview was displayed as a card or embed.
|
|
176
|
+
* @param hoverTime The duration that the user hovered over a Smart Link before the preview was dismissed.
|
|
177
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
178
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
179
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
180
|
+
* @returns
|
|
181
|
+
*/
|
|
182
|
+
hoverCardDismissedEvent: function hoverCardDismissedEvent(hoverDisplay, hoverTime) {
|
|
183
|
+
var definitionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedDefinitionId;
|
|
184
|
+
var extensionKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedExtensionKey;
|
|
185
|
+
var previewInvokeMethod = arguments.length > 4 ? arguments[4] : undefined;
|
|
46
186
|
return dispatchAnalytics(uiHoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
|
|
47
187
|
}
|
|
48
188
|
};
|
|
49
|
-
}, [dispatchAnalytics]);
|
|
189
|
+
}, [defaultId, defaultLocation, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
190
|
+
/** Contains all operational analytics events */
|
|
191
|
+
|
|
50
192
|
var operational = useMemo(function () {
|
|
51
193
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
194
|
+
/**
|
|
195
|
+
* This fires an event that represents an action being successfully invoked.
|
|
196
|
+
* @param id The unique ID for this Smart Link.
|
|
197
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
198
|
+
* @param actionType The type of action invoked, e.g. PreviewAction
|
|
199
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
200
|
+
*/
|
|
201
|
+
invokeSucceededEvent: function invokeSucceededEvent() {
|
|
202
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
203
|
+
var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
|
|
204
|
+
var actionType = arguments.length > 2 ? arguments[2] : undefined;
|
|
205
|
+
var display = arguments.length > 3 ? arguments[3] : undefined;
|
|
59
206
|
succeedUfoExperience('smart-link-action-invocation', id);
|
|
60
|
-
dispatchAnalytics(_invokeSucceededEvent(id,
|
|
207
|
+
dispatchAnalytics(_invokeSucceededEvent(id, actionType, display, extensionKey));
|
|
61
208
|
},
|
|
62
|
-
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* This fires an event that represents an action being unsuccessfully invoked.
|
|
212
|
+
* @param id The unique ID for this Smart Link.
|
|
213
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
214
|
+
* @param actionType The type of action invoked, e.g. PreviewAction
|
|
215
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
216
|
+
* @param reason The reason the invocation failed.
|
|
217
|
+
*/
|
|
218
|
+
invokeFailedEvent: function invokeFailedEvent() {
|
|
219
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
220
|
+
var providerKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
|
|
221
|
+
var actionType = arguments.length > 2 ? arguments[2] : undefined;
|
|
222
|
+
var display = arguments.length > 3 ? arguments[3] : undefined;
|
|
223
|
+
var reason = arguments.length > 4 ? arguments[4] : undefined;
|
|
63
224
|
failUfoExperience('smart-link-action-invocation', id);
|
|
64
|
-
dispatchAnalytics(_invokeFailedEvent(id,
|
|
225
|
+
dispatchAnalytics(_invokeFailedEvent(id, actionType, display, reason, providerKey));
|
|
65
226
|
},
|
|
66
|
-
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* This fires an event that represents an account successfully being connected via a Smart Link.
|
|
230
|
+
* @param id The unique ID for this Smart Link.
|
|
231
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
232
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
233
|
+
*/
|
|
234
|
+
connectSucceededEvent: function connectSucceededEvent() {
|
|
235
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
236
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
237
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
67
238
|
startUfoExperience('smart-link-authenticated', id, {
|
|
68
239
|
extensionKey: extensionKey,
|
|
69
240
|
status: 'success'
|
|
70
241
|
});
|
|
71
242
|
dispatchAnalytics(_connectSucceededEvent(definitionId, extensionKey));
|
|
72
243
|
},
|
|
73
|
-
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* This fires an event that represents an account unsuccessfully being connected.
|
|
247
|
+
* @param id The unique ID for this Smart Link.
|
|
248
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
249
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
250
|
+
* @param reason The reason why the Smart Link connect account failed.
|
|
251
|
+
*/
|
|
252
|
+
connectFailedEvent: function connectFailedEvent() {
|
|
253
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
254
|
+
var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
|
|
255
|
+
var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
|
|
256
|
+
var reason = arguments.length > 3 ? arguments[3] : undefined;
|
|
74
257
|
startUfoExperience('smart-link-authenticated', id, {
|
|
75
258
|
extensionKey: extensionKey,
|
|
76
|
-
status:
|
|
259
|
+
status: reason
|
|
77
260
|
});
|
|
78
|
-
dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey,
|
|
261
|
+
dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey, reason));
|
|
79
262
|
},
|
|
80
|
-
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* This fires an event which represents a Smart Link request succeeding or failing based on the status.
|
|
266
|
+
* @param id The unique ID for this Smart Link.
|
|
267
|
+
* @param status The status of the Smart Link.
|
|
268
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
269
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
270
|
+
* @param resourceType The type of resource that was invoked. This is provider specific (e.g. File, PullRequest).
|
|
271
|
+
* @param error An error representing why the Smart Link request failed.
|
|
272
|
+
*/
|
|
273
|
+
instrument: function instrument() {
|
|
274
|
+
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
275
|
+
var status = arguments.length > 1 ? arguments[1] : undefined;
|
|
276
|
+
var definitionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedDefinitionId;
|
|
277
|
+
var extensionKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedExtensionKey;
|
|
278
|
+
var resourceType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedResourceType;
|
|
279
|
+
var error = arguments.length > 5 ? arguments[5] : undefined;
|
|
81
280
|
var event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
|
|
82
281
|
|
|
83
282
|
if (event) {
|
|
@@ -85,21 +284,41 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
85
284
|
}
|
|
86
285
|
}
|
|
87
286
|
};
|
|
88
|
-
}, [dispatchAnalytics]);
|
|
287
|
+
}, [defaultId, extractedResourceType, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
288
|
+
/** Contains all track analytics events */
|
|
289
|
+
|
|
89
290
|
var track = useMemo(function () {
|
|
90
291
|
return {
|
|
91
|
-
|
|
292
|
+
/**
|
|
293
|
+
* This fires an event which represents a user starting the Smart Link connect account process.
|
|
294
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
295
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
296
|
+
* @returns
|
|
297
|
+
*/
|
|
298
|
+
appAccountConnected: function appAccountConnected() {
|
|
299
|
+
var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
|
|
300
|
+
var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
|
|
92
301
|
return dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey));
|
|
93
302
|
}
|
|
94
303
|
};
|
|
95
|
-
}, [dispatchAnalytics]);
|
|
304
|
+
}, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
305
|
+
/** Contains all screen analytics events */
|
|
306
|
+
|
|
96
307
|
var screen = useMemo(function () {
|
|
97
308
|
return {
|
|
98
|
-
|
|
309
|
+
/**
|
|
310
|
+
* This fires an event which represents the connect account page being opened.
|
|
311
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
312
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
313
|
+
* @returns
|
|
314
|
+
*/
|
|
315
|
+
authPopupEvent: function authPopupEvent() {
|
|
316
|
+
var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
|
|
317
|
+
var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
|
|
99
318
|
return dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey));
|
|
100
319
|
}
|
|
101
320
|
};
|
|
102
|
-
}, [dispatchAnalytics]);
|
|
321
|
+
}, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
103
322
|
return useMemo(function () {
|
|
104
323
|
return {
|
|
105
324
|
ui: ui,
|
|
@@ -7,7 +7,7 @@ import { useSmartLinkAnalytics } from '../analytics';
|
|
|
7
7
|
import { useSmartLinkRenderers } from '../renderers';
|
|
8
8
|
export function useSmartLink(id, url, dispatchAnalytics) {
|
|
9
9
|
var state = useSmartLinkState(url);
|
|
10
|
-
var analytics = useSmartLinkAnalytics(dispatchAnalytics);
|
|
10
|
+
var analytics = useSmartLinkAnalytics(url, dispatchAnalytics, id);
|
|
11
11
|
var actions = useSmartLinkActions(id, url, analytics);
|
|
12
12
|
var config = useSmartLinkConfig();
|
|
13
13
|
var renderers = useSmartLinkRenderers(); // NB: used to propagate errors from hooks to error boundaries.
|
|
@@ -22,7 +22,7 @@ export function useSmartLinkActions(_ref) {
|
|
|
22
22
|
setActions = _useState2[1];
|
|
23
23
|
|
|
24
24
|
var linkState = useLinkState(url);
|
|
25
|
-
var linkAnalytics = useLinkAnalytics(analyticsHandler);
|
|
25
|
+
var linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
26
26
|
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
27
27
|
useEffect(function () {
|
|
28
28
|
if (!linkState.details) {
|
|
@@ -14,7 +14,7 @@ export function useSmartLinkReload(_ref) {
|
|
|
14
14
|
var id = useMemo(function () {
|
|
15
15
|
return uuid();
|
|
16
16
|
}, []);
|
|
17
|
-
var linkAnalytics = useLinkAnalytics(analyticsHandler);
|
|
17
|
+
var linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
18
18
|
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
19
19
|
return linkActions.reload;
|
|
20
20
|
}
|
package/dist/esm/state/index.js
CHANGED