@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
|
@@ -52,17 +52,19 @@ function CardWithUrlContent(_ref) {
|
|
|
52
52
|
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
53
53
|
ui = _ref.ui,
|
|
54
54
|
children = _ref.children,
|
|
55
|
-
showHoverPreview = _ref.showHoverPreview
|
|
55
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
56
|
+
analyticsEvents = _ref.analyticsEvents;
|
|
56
57
|
|
|
57
58
|
// Get state, actions for this card.
|
|
58
59
|
var _useSmartLink = (0, _state.useSmartLink)(id, url, dispatchAnalytics),
|
|
59
60
|
state = _useSmartLink.state,
|
|
60
61
|
actions = _useSmartLink.actions,
|
|
62
|
+
defaultAnalytics = _useSmartLink.analytics,
|
|
61
63
|
config = _useSmartLink.config,
|
|
62
|
-
analytics = _useSmartLink.analytics,
|
|
63
64
|
renderers = _useSmartLink.renderers,
|
|
64
65
|
error = _useSmartLink.error;
|
|
65
66
|
|
|
67
|
+
var analytics = analyticsEvents || defaultAnalytics;
|
|
66
68
|
var definitionId = (0, _helpers.getDefinitionId)(state.details);
|
|
67
69
|
var extensionKey = (0, _helpers.getExtensionKey)(state.details);
|
|
68
70
|
var resourceType = (0, _helpers.getResourceType)(state.details);
|
|
@@ -76,17 +78,15 @@ function CardWithUrlContent(_ref) {
|
|
|
76
78
|
(0, _utils.isSpecialEvent)(event) ? window.open(clickUrl, '_blank') : window.open(clickUrl, '_self');
|
|
77
79
|
}, [state.details, url]);
|
|
78
80
|
var handleClickWrapper = (0, _react.useCallback)(function (event) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
|
|
82
|
-
}
|
|
81
|
+
var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
|
|
82
|
+
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed);
|
|
83
83
|
|
|
84
84
|
if (onClick) {
|
|
85
85
|
onClick(event);
|
|
86
86
|
} else if (!isFlexibleUi) {
|
|
87
87
|
handleClick(event);
|
|
88
88
|
}
|
|
89
|
-
}, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
89
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
90
90
|
var handleAuthorize = (0, _react.useCallback)(function () {
|
|
91
91
|
return actions.authorize(appearance);
|
|
92
92
|
}, [actions, appearance]);
|
|
@@ -112,7 +112,7 @@ function CardWithUrlContent(_ref) {
|
|
|
112
112
|
|
|
113
113
|
(0, _react.useEffect)(function () {
|
|
114
114
|
if ((0, _helpers.isFinalState)(state.status)) {
|
|
115
|
-
analytics.ui.renderSuccessEvent(appearance, id, definitionId, extensionKey);
|
|
115
|
+
analytics.ui.renderSuccessEvent(appearance, state.status, id, definitionId, extensionKey);
|
|
116
116
|
}
|
|
117
117
|
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
|
|
118
118
|
|
|
@@ -130,6 +130,7 @@ function CardWithUrlContent(_ref) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
|
|
133
|
+
id: id,
|
|
133
134
|
cardState: cardState,
|
|
134
135
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
135
136
|
onClick: handleClickWrapper,
|
|
@@ -149,6 +150,7 @@ function CardWithUrlContent(_ref) {
|
|
|
149
150
|
switch (appearance) {
|
|
150
151
|
case 'inline':
|
|
151
152
|
return /*#__PURE__*/_react.default.createElement(_InlineCard.InlineCard, {
|
|
153
|
+
id: id,
|
|
152
154
|
url: url,
|
|
153
155
|
renderers: renderers,
|
|
154
156
|
cardState: state,
|
|
@@ -163,6 +165,7 @@ function CardWithUrlContent(_ref) {
|
|
|
163
165
|
|
|
164
166
|
case 'block':
|
|
165
167
|
return /*#__PURE__*/_react.default.createElement(_BlockCard.BlockCard, {
|
|
168
|
+
id: id,
|
|
166
169
|
url: url,
|
|
167
170
|
renderers: renderers,
|
|
168
171
|
authFlow: config && config.authFlow,
|
|
@@ -181,6 +184,7 @@ function CardWithUrlContent(_ref) {
|
|
|
181
184
|
|
|
182
185
|
case 'embed':
|
|
183
186
|
return /*#__PURE__*/_react.default.createElement(_EmbedCard.EmbedCard, {
|
|
187
|
+
id: id,
|
|
184
188
|
url: url,
|
|
185
189
|
cardState: state,
|
|
186
190
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -37,7 +37,7 @@ var LazyCardWithUrlContent = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
|
37
37
|
|
|
38
38
|
function CardWithURLRenderer(props) {
|
|
39
39
|
var _useState = (0, _react.useState)(function () {
|
|
40
|
-
return (0, _uuid.default)();
|
|
40
|
+
return props.id ? props.id : (0, _uuid.default)();
|
|
41
41
|
}),
|
|
42
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
43
43
|
id = _useState2[0];
|
|
@@ -65,7 +65,8 @@ function CardWithURLRenderer(props) {
|
|
|
65
65
|
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
66
66
|
children = props.children,
|
|
67
67
|
ui = props.ui,
|
|
68
|
-
showHoverPreview = props.showHoverPreview
|
|
68
|
+
showHoverPreview = props.showHoverPreview,
|
|
69
|
+
analyticsEvents = props.analyticsEvents; // Wrapper around analytics.
|
|
69
70
|
|
|
70
71
|
var dispatchAnalytics = (0, _react.useCallback)(function (analyticsPayload) {
|
|
71
72
|
if (analyticsPayload && analyticsPayload.attributes) {
|
|
@@ -122,7 +123,8 @@ function CardWithURLRenderer(props) {
|
|
|
122
123
|
embedIframeRef: embedIframeRef,
|
|
123
124
|
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
124
125
|
ui: ui,
|
|
125
|
-
showHoverPreview: showHoverPreview
|
|
126
|
+
showHoverPreview: showHoverPreview,
|
|
127
|
+
analyticsEvents: analyticsEvents
|
|
126
128
|
};
|
|
127
129
|
return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
128
130
|
FallbackComponent: ErrorFallback,
|
|
@@ -54,6 +54,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
54
54
|
/** @jsx jsx */
|
|
55
55
|
var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
56
56
|
var children = _ref.children,
|
|
57
|
+
id = _ref.id,
|
|
57
58
|
url = _ref.url,
|
|
58
59
|
createAnalyticsEvent = _ref.createAnalyticsEvent;
|
|
59
60
|
var analyticsHandler = (0, _react.useCallback)(function (analyticsPayload) {
|
|
@@ -70,7 +71,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
70
71
|
var fadeInTimeoutId = (0, _react.useRef)();
|
|
71
72
|
var cardOpenTime = (0, _react.useRef)();
|
|
72
73
|
var linkState = (0, _store.useSmartCardState)(url);
|
|
73
|
-
var analytics = (0, _analytics2.useSmartLinkAnalytics)(analyticsHandler);
|
|
74
|
+
var analytics = (0, _analytics2.useSmartLinkAnalytics)(url, analyticsHandler, id);
|
|
74
75
|
var extensionKey = (0, _react.useMemo)(function () {
|
|
75
76
|
return (0, _helpers.getExtensionKey)(linkState.details);
|
|
76
77
|
}, [linkState]);
|
|
@@ -153,6 +154,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
153
154
|
onMouseLeave: initHideCard,
|
|
154
155
|
css: _styled.HoverCardContainer
|
|
155
156
|
}, (0, _core.jsx)(_Card.Card, {
|
|
157
|
+
id: id,
|
|
156
158
|
appearance: "block",
|
|
157
159
|
url: url,
|
|
158
160
|
ui: {
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getSimulatedMetadata = void 0;
|
|
7
7
|
|
|
8
|
-
var getSimulatedMetadata = function getSimulatedMetadata(
|
|
8
|
+
var getSimulatedMetadata = function getSimulatedMetadata() {
|
|
9
|
+
var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
10
|
+
|
|
9
11
|
switch (extensionKey) {
|
|
10
12
|
case 'confluence-object-provider':
|
|
11
13
|
return {
|
|
@@ -61,6 +61,7 @@ var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
61
61
|
key: "render",
|
|
62
62
|
value: function render() {
|
|
63
63
|
var _this$props = this.props,
|
|
64
|
+
id = _this$props.id,
|
|
64
65
|
_this$props$title = _this$props.title,
|
|
65
66
|
title = _this$props$title === void 0 ? '' : _this$props$title,
|
|
66
67
|
isSelected = _this$props.isSelected,
|
|
@@ -88,6 +89,7 @@ var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
|
|
|
88
89
|
|
|
89
90
|
if (showHoverPreview && link) {
|
|
90
91
|
return /*#__PURE__*/_react.default.createElement(_index.HoverCard, {
|
|
92
|
+
id: id,
|
|
91
93
|
url: link
|
|
92
94
|
}, inlineCardResolvedView);
|
|
93
95
|
}
|
|
@@ -62,7 +62,8 @@ var _UnauthorisedView = require("./UnauthorisedView");
|
|
|
62
62
|
var InlineCard = function InlineCard(_ref) {
|
|
63
63
|
var _details$meta;
|
|
64
64
|
|
|
65
|
-
var
|
|
65
|
+
var id = _ref.id,
|
|
66
|
+
url = _ref.url,
|
|
66
67
|
cardState = _ref.cardState,
|
|
67
68
|
handleAuthorize = _ref.handleAuthorize,
|
|
68
69
|
handleFrameClick = _ref.handleFrameClick,
|
|
@@ -99,6 +100,7 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
return /*#__PURE__*/_react.default.createElement(_ResolvedView.InlineCardResolvedView, (0, _extends2.default)({}, resolvedProps, {
|
|
103
|
+
id: id,
|
|
102
104
|
showHoverPreview: showHoverPreview,
|
|
103
105
|
link: url,
|
|
104
106
|
isSelected: isSelected,
|
|
@@ -54,7 +54,7 @@ export const extractPreviewAction = (extensionKey = 'empty-object-provider', vie
|
|
|
54
54
|
const previewAction = PreviewAction({ ...metadata,
|
|
55
55
|
testId,
|
|
56
56
|
onOpen: () => {
|
|
57
|
-
handleAnalytics(uiRenderSuccessEvent('preview', key));
|
|
57
|
+
handleAnalytics(uiRenderSuccessEvent('preview', 'resolved', key));
|
|
58
58
|
},
|
|
59
59
|
onOpenFailed: (error, errorInfo) => {
|
|
60
60
|
handleAnalytics(uiRenderFailedEvent('preview', error, errorInfo));
|
package/dist/es2019/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,25 +1,115 @@
|
|
|
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, invokeFailedEvent, connectSucceededEvent, 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 const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocation) => {
|
|
18
|
+
const defaultId = id || 'NULL'; // We don't want to trigger a re-render by using useSmartCardState
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
store
|
|
22
|
+
} = useSmartLinkContext();
|
|
23
|
+
const state = getUrl(store, url);
|
|
24
|
+
const extractedDefinitionId = getDefinitionId(state.details);
|
|
25
|
+
const extractedExtensionKey = getExtensionKey(state.details);
|
|
26
|
+
const extractedResourceType = getResourceType(state.details);
|
|
27
|
+
/** Contains all ui analytics events */
|
|
28
|
+
|
|
5
29
|
const ui = useMemo(() => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
/**
|
|
31
|
+
* This fires an event that represents when a user clicks on the authentication
|
|
32
|
+
* call to action with no current authenticated account. (i.e. Connect to Preview).
|
|
33
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
34
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
35
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
authEvent: (display, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey)),
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This fires an event that represents when a user clicks on the authentication
|
|
42
|
+
* call to action with a forbidden authenticated account. (i.e. Try another account).
|
|
43
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
44
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
45
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
authAlternateAccountEvent: (display, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey)),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* This fires an event that represents when a user clicks on a Smart Link.
|
|
52
|
+
* @param id The unique ID for this Smart Link.
|
|
53
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
54
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
55
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
56
|
+
* @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
|
|
57
|
+
* @param location Where the Smart Link is currently rendered.
|
|
58
|
+
* @param destinationProduct The product the Smart Link is linked to.
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
cardClickedEvent: (id = defaultId, display, status, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, isModifierKeyPressed, location = defaultLocation, destinationProduct) => dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct)),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This fires an event that represents when a user clicks on a Smart Link action.
|
|
65
|
+
* Note: This also starts the UFO smart-link-action-invocation experience.
|
|
66
|
+
* @param id The unique ID for this Smart Link.
|
|
67
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
68
|
+
* @param actionType The type of the action that was clicked, e.g. PreviewAction
|
|
69
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
70
|
+
* @param invokeType Whether the action invoked made a call to a server.
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
actionClickedEvent: (id = defaultId, extensionKey = extractedExtensionKey, actionType, display, invokeType) => {
|
|
10
74
|
startUfoExperience('smart-link-action-invocation', id, {
|
|
11
75
|
actionType,
|
|
12
76
|
display,
|
|
13
77
|
extensionKey,
|
|
14
78
|
invokeType
|
|
15
79
|
});
|
|
16
|
-
dispatchAnalytics(uiActionClickedEvent(
|
|
80
|
+
dispatchAnalytics(uiActionClickedEvent(actionType, extensionKey, display));
|
|
17
81
|
},
|
|
18
|
-
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* This fires an event that represents when a user clicks on a hover preview's "navigate to link" button.
|
|
85
|
+
* https://product-fabric.atlassian.net/wiki/spaces/EM/pages/3206743323/Analytics+Metrics+-+Hover+Previews
|
|
86
|
+
* @param previewDisplay What format the preview is in.
|
|
87
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
88
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
89
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
90
|
+
*/
|
|
91
|
+
hoverCardOpenLinkClickedEvent: (previewDisplay, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, previewInvokeMethod) => {
|
|
19
92
|
dispatchAnalytics(uiHoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod));
|
|
20
93
|
},
|
|
21
|
-
|
|
22
|
-
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This fires an event that represents when a user closed the authentication window without authenticating after opening it.
|
|
97
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
98
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
99
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
closedAuthEvent: (display, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey)),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* This fires an event that represents when a Smart Link was rendered successfully.
|
|
106
|
+
* Note: this fires even if the Smart Link request errored out.
|
|
107
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
108
|
+
* @param id The unique ID for this Smart Link.
|
|
109
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
110
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
111
|
+
*/
|
|
112
|
+
renderSuccessEvent: (display, status, id = defaultId, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => {
|
|
23
113
|
succeedUfoExperience('smart-link-rendered', id, {
|
|
24
114
|
extensionKey,
|
|
25
115
|
display
|
|
@@ -28,50 +118,126 @@ export const useSmartLinkAnalytics = dispatchAnalytics => {
|
|
|
28
118
|
succeedUfoExperience('smart-link-authenticated', id, {
|
|
29
119
|
display
|
|
30
120
|
});
|
|
31
|
-
dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
121
|
+
dispatchAnalytics(uiRenderSuccessEvent(display, status, definitionId, extensionKey));
|
|
32
122
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This fires an event that represents a hover preview being opened.
|
|
126
|
+
* @param hoverDisplay Whether the hover preview was displayed as a card or embed.
|
|
127
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
128
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
129
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
hoverCardViewedEvent: (hoverDisplay, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, previewInvokeMethod) => dispatchAnalytics(uiHoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod)),
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* This fires an event that represents a hover preview being dismissed.
|
|
136
|
+
* @param hoverDisplay Whether the hover preview was displayed as a card or embed.
|
|
137
|
+
* @param hoverTime The duration that the user hovered over a Smart Link before the preview was dismissed.
|
|
138
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
139
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
140
|
+
* @param previewInvokeMethod How the preview was triggered.
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
hoverCardDismissedEvent: (hoverDisplay, hoverTime, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, previewInvokeMethod) => dispatchAnalytics(uiHoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod))
|
|
144
|
+
}), [defaultId, defaultLocation, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
145
|
+
/** Contains all operational analytics events */
|
|
146
|
+
|
|
36
147
|
const operational = useMemo(() => ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
148
|
+
/**
|
|
149
|
+
* This fires an event that represents an action being successfully invoked.
|
|
150
|
+
* @param id The unique ID for this Smart Link.
|
|
151
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
152
|
+
* @param actionType The type of action invoked, e.g. PreviewAction
|
|
153
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
154
|
+
*/
|
|
155
|
+
invokeSucceededEvent: (id = defaultId, extensionKey = extractedExtensionKey, actionType, display) => {
|
|
40
156
|
succeedUfoExperience('smart-link-action-invocation', id);
|
|
41
|
-
dispatchAnalytics(invokeSucceededEvent(id,
|
|
157
|
+
dispatchAnalytics(invokeSucceededEvent(id, actionType, display, extensionKey));
|
|
42
158
|
},
|
|
43
|
-
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* This fires an event that represents an action being unsuccessfully invoked.
|
|
162
|
+
* @param id The unique ID for this Smart Link.
|
|
163
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
164
|
+
* @param actionType The type of action invoked, e.g. PreviewAction
|
|
165
|
+
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
166
|
+
* @param reason The reason the invocation failed.
|
|
167
|
+
*/
|
|
168
|
+
invokeFailedEvent: (id = defaultId, providerKey = extractedExtensionKey, actionType, display, reason) => {
|
|
44
169
|
failUfoExperience('smart-link-action-invocation', id);
|
|
45
|
-
dispatchAnalytics(invokeFailedEvent(id,
|
|
170
|
+
dispatchAnalytics(invokeFailedEvent(id, actionType, display, reason, providerKey));
|
|
46
171
|
},
|
|
47
|
-
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* This fires an event that represents an account successfully being connected via a Smart Link.
|
|
175
|
+
* @param id The unique ID for this Smart Link.
|
|
176
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
177
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
178
|
+
*/
|
|
179
|
+
connectSucceededEvent: (id = defaultId, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => {
|
|
48
180
|
startUfoExperience('smart-link-authenticated', id, {
|
|
49
181
|
extensionKey,
|
|
50
182
|
status: 'success'
|
|
51
183
|
});
|
|
52
184
|
dispatchAnalytics(connectSucceededEvent(definitionId, extensionKey));
|
|
53
185
|
},
|
|
54
|
-
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* This fires an event that represents an account unsuccessfully being connected.
|
|
189
|
+
* @param id The unique ID for this Smart Link.
|
|
190
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
191
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
192
|
+
* @param reason The reason why the Smart Link connect account failed.
|
|
193
|
+
*/
|
|
194
|
+
connectFailedEvent: (id = defaultId, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, reason) => {
|
|
55
195
|
startUfoExperience('smart-link-authenticated', id, {
|
|
56
196
|
extensionKey,
|
|
57
|
-
status
|
|
197
|
+
status: reason
|
|
58
198
|
});
|
|
59
|
-
dispatchAnalytics(connectFailedEvent(definitionId, extensionKey,
|
|
199
|
+
dispatchAnalytics(connectFailedEvent(definitionId, extensionKey, reason));
|
|
60
200
|
},
|
|
61
|
-
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* This fires an event which represents a Smart Link request succeeding or failing based on the status.
|
|
204
|
+
* @param id The unique ID for this Smart Link.
|
|
205
|
+
* @param status The status of the Smart Link.
|
|
206
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
207
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
208
|
+
* @param resourceType The type of resource that was invoked. This is provider specific (e.g. File, PullRequest).
|
|
209
|
+
* @param error An error representing why the Smart Link request failed.
|
|
210
|
+
*/
|
|
211
|
+
instrument: (id = defaultId, status, definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey, resourceType = extractedResourceType, error) => {
|
|
62
212
|
const event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
|
|
63
213
|
|
|
64
214
|
if (event) {
|
|
65
215
|
dispatchAnalytics(event);
|
|
66
216
|
}
|
|
67
217
|
}
|
|
68
|
-
}), [dispatchAnalytics]);
|
|
218
|
+
}), [defaultId, extractedResourceType, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
219
|
+
/** Contains all track analytics events */
|
|
220
|
+
|
|
69
221
|
const track = useMemo(() => ({
|
|
70
|
-
|
|
71
|
-
|
|
222
|
+
/**
|
|
223
|
+
* This fires an event which represents a user starting the Smart Link connect account process.
|
|
224
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
225
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
appAccountConnected: (definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey))
|
|
229
|
+
}), [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
230
|
+
/** Contains all screen analytics events */
|
|
231
|
+
|
|
72
232
|
const screen = useMemo(() => ({
|
|
73
|
-
|
|
74
|
-
|
|
233
|
+
/**
|
|
234
|
+
* This fires an event which represents the connect account page being opened.
|
|
235
|
+
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
236
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
authPopupEvent: (definitionId = extractedDefinitionId, extensionKey = extractedExtensionKey) => dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey))
|
|
240
|
+
}), [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
|
|
75
241
|
return useMemo(() => ({
|
|
76
242
|
ui,
|
|
77
243
|
operational,
|
|
@@ -6,7 +6,7 @@ import { useSmartLinkAnalytics } from '../analytics';
|
|
|
6
6
|
import { useSmartLinkRenderers } from '../renderers';
|
|
7
7
|
export function useSmartLink(id, url, dispatchAnalytics) {
|
|
8
8
|
const state = useSmartLinkState(url);
|
|
9
|
-
const analytics = useSmartLinkAnalytics(dispatchAnalytics);
|
|
9
|
+
const analytics = useSmartLinkAnalytics(url, dispatchAnalytics, id);
|
|
10
10
|
const actions = useSmartLinkActions(id, url, analytics);
|
|
11
11
|
const config = useSmartLinkConfig();
|
|
12
12
|
const renderers = useSmartLinkRenderers(); // NB: used to propagate errors from hooks to error boundaries.
|
|
@@ -14,7 +14,7 @@ export function useSmartLinkActions({
|
|
|
14
14
|
const id = useMemo(() => uuid(), []);
|
|
15
15
|
const [actions, setActions] = useState([]);
|
|
16
16
|
const linkState = useLinkState(url);
|
|
17
|
-
const linkAnalytics = useLinkAnalytics(analyticsHandler);
|
|
17
|
+
const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
18
18
|
const linkActions = useLinkActions(id, url, linkAnalytics);
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
if (!linkState.details) {
|
|
@@ -13,7 +13,7 @@ export function useSmartLinkReload({
|
|
|
13
13
|
analyticsHandler
|
|
14
14
|
}) {
|
|
15
15
|
const id = useMemo(() => uuid(), []);
|
|
16
|
-
const linkAnalytics = useLinkAnalytics(analyticsHandler);
|
|
16
|
+
const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
17
17
|
const linkActions = useLinkActions(id, url, linkAnalytics);
|
|
18
18
|
return linkActions.reload;
|
|
19
19
|
}
|
|
@@ -69,7 +69,7 @@ export const unresolvedEvent = (id, status, definitionId, extensionKey, resource
|
|
|
69
69
|
} : undefined
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
export const invokeSucceededEvent = (id,
|
|
72
|
+
export const invokeSucceededEvent = (id, actionType, display, extensionKey) => {
|
|
73
73
|
const measure = getMeasure(id, 'resolved') || {
|
|
74
74
|
duration: undefined
|
|
75
75
|
};
|
|
@@ -81,12 +81,12 @@ export const invokeSucceededEvent = (id, extensionKey, actionType, display) => {
|
|
|
81
81
|
id,
|
|
82
82
|
actionType,
|
|
83
83
|
display,
|
|
84
|
-
extensionKey,
|
|
84
|
+
extensionKey: extensionKey || '',
|
|
85
85
|
duration: measure.duration
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
export const invokeFailedEvent = (id,
|
|
89
|
+
export const invokeFailedEvent = (id, actionType, display, reason, extensionKey) => {
|
|
90
90
|
const measure = getMeasure(id, 'errored') || {
|
|
91
91
|
duration: undefined
|
|
92
92
|
};
|
|
@@ -98,7 +98,7 @@ export const invokeFailedEvent = (id, extensionKey, actionType, display, reason)
|
|
|
98
98
|
id,
|
|
99
99
|
actionType,
|
|
100
100
|
display,
|
|
101
|
-
extensionKey,
|
|
101
|
+
extensionKey: extensionKey || '',
|
|
102
102
|
duration: measure.duration,
|
|
103
103
|
reason
|
|
104
104
|
}
|
|
@@ -169,24 +169,28 @@ export const uiAuthAlternateAccountEvent = (display, definitionId, extensionKey)
|
|
|
169
169
|
display
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
|
-
export const uiCardClickedEvent = (display, definitionId, extensionKey, isModifierKeyPressed) => ({
|
|
172
|
+
export const uiCardClickedEvent = (id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct) => ({
|
|
173
173
|
action: 'clicked',
|
|
174
174
|
actionSubject: 'smartLink',
|
|
175
175
|
eventType: 'ui',
|
|
176
176
|
attributes: { ...context,
|
|
177
|
+
id,
|
|
178
|
+
status,
|
|
177
179
|
definitionId: definitionId || '',
|
|
178
180
|
extensionKey: extensionKey || '',
|
|
179
181
|
display,
|
|
180
|
-
isModifierKeyPressed
|
|
182
|
+
isModifierKeyPressed,
|
|
183
|
+
location,
|
|
184
|
+
destinationProduct
|
|
181
185
|
}
|
|
182
186
|
});
|
|
183
|
-
export const uiActionClickedEvent = (
|
|
187
|
+
export const uiActionClickedEvent = (actionType, extensionKey, display) => ({
|
|
184
188
|
action: 'clicked',
|
|
185
189
|
actionSubject: 'smartLinkAction',
|
|
186
190
|
eventType: 'ui',
|
|
187
191
|
attributes: { ...context,
|
|
188
192
|
display,
|
|
189
|
-
extensionKey,
|
|
193
|
+
extensionKey: extensionKey || '',
|
|
190
194
|
actionType: actionType
|
|
191
195
|
}
|
|
192
196
|
});
|
|
@@ -208,11 +212,12 @@ export const screenAuthPopupEvent = (definitionId, extensionKey) => ({
|
|
|
208
212
|
extensionKey: extensionKey || ''
|
|
209
213
|
}
|
|
210
214
|
});
|
|
211
|
-
export const uiRenderSuccessEvent = (display, definitionId, extensionKey) => ({
|
|
215
|
+
export const uiRenderSuccessEvent = (display, status, definitionId, extensionKey) => ({
|
|
212
216
|
action: 'renderSuccess',
|
|
213
217
|
actionSubject: 'smartLink',
|
|
214
218
|
eventType: 'ui',
|
|
215
219
|
attributes: { ...context,
|
|
220
|
+
status,
|
|
216
221
|
definitionId: definitionId || '',
|
|
217
222
|
extensionKey: extensionKey || '',
|
|
218
223
|
display
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/version.json
CHANGED
|
@@ -18,6 +18,7 @@ export class CardWithDataRenderer extends React.PureComponent {
|
|
|
18
18
|
|
|
19
19
|
render() {
|
|
20
20
|
const {
|
|
21
|
+
id,
|
|
21
22
|
appearance,
|
|
22
23
|
data,
|
|
23
24
|
isSelected,
|
|
@@ -34,6 +35,7 @@ export class CardWithDataRenderer extends React.PureComponent {
|
|
|
34
35
|
|
|
35
36
|
if (CardWithDataRenderer.CardContent) {
|
|
36
37
|
return /*#__PURE__*/React.createElement(CardWithDataRenderer.CardContent, {
|
|
38
|
+
id: id,
|
|
37
39
|
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
38
40
|
appearance: appearance,
|
|
39
41
|
data: data,
|