@atlaskit/smart-card 16.1.1 → 16.2.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 +13 -0
- package/dist/cjs/client/utils/environments.js +1 -1
- package/dist/cjs/providers/editor/transformer.js +1 -1
- package/dist/cjs/state/actions/index.js +13 -6
- package/dist/cjs/state/analytics/index.js +32 -84
- package/dist/cjs/state/analytics/ufoExperiences.js +60 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +106 -0
- package/dist/cjs/state/hooks/useSmartLink.js +6 -6
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +8 -3
- package/dist/cjs/view/CardWithUrl/loader.js +110 -133
- package/dist/es2019/client/utils/environments.js +1 -1
- package/dist/es2019/providers/editor/transformer.js +1 -1
- package/dist/es2019/state/actions/index.js +9 -4
- package/dist/es2019/state/analytics/index.js +2 -40
- package/dist/es2019/state/analytics/ufoExperiences.js +40 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +62 -0
- package/dist/es2019/state/hooks/useSmartLink.js +4 -5
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +8 -3
- package/dist/es2019/view/CardWithUrl/loader.js +86 -88
- package/dist/esm/client/utils/environments.js +1 -1
- package/dist/esm/providers/editor/transformer.js +1 -1
- package/dist/esm/state/actions/index.js +12 -6
- package/dist/esm/state/analytics/index.js +2 -80
- package/dist/esm/state/analytics/ufoExperiences.js +40 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +94 -0
- package/dist/esm/state/hooks/useSmartLink.js +6 -6
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component-lazy/index.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +8 -3
- package/dist/esm/view/CardWithUrl/loader.js +103 -127
- package/dist/types/state/analytics/index.d.ts +3 -32
- package/dist/types/state/analytics/ufoExperiences.d.ts +7 -0
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +30 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +4 -5
- package/dist/types/view/CardWithUrl/component-lazy/index.d.ts +1 -1
- package/dist/types/view/CardWithUrl/loader.d.ts +1 -15
- package/package.json +6 -3
|
@@ -1,60 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import React, { lazy, useEffect, useState, Suspense } from 'react';
|
|
3
2
|
import uuid from 'uuid';
|
|
4
3
|
import { CardLinkView } from '@atlaskit/media-ui';
|
|
5
4
|
import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
|
|
6
5
|
import { clearMarks, clearMeasures } from '../../utils/performance';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
7
|
+
import { failUfoExperience, startUfoExperience } from '../../state/analytics/ufoExperiences';
|
|
8
|
+
const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => import(
|
|
9
|
+
/* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
|
|
10
|
+
'./component-lazy/index'));
|
|
11
|
+
export function CardWithURLRenderer(props) {
|
|
12
|
+
const [id] = useState(() => uuid()); // Equivalent to ComponentWillMount
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!analyticsPayload.attributes.display) {
|
|
21
|
-
analyticsPayload.attributes.display = appearance;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
this.state = {
|
|
29
|
-
id: uuid()
|
|
14
|
+
useState(() => {
|
|
15
|
+
// We want to start timing of render event only once and right at the start
|
|
16
|
+
startUfoExperience('smart-link-rendered', id);
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
// ComponentWillUnmount
|
|
20
|
+
return () => {
|
|
21
|
+
clearMarks(id);
|
|
22
|
+
clearMeasures(id);
|
|
30
23
|
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static moduleImporter(target) {
|
|
34
|
-
import(
|
|
35
|
-
/* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
|
|
36
|
-
'./component-lazy/index').then(module => {
|
|
37
|
-
CardWithURLRenderer.CardContent = module.LazyCardWithUrlContent;
|
|
38
|
-
target.forceUpdate();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
componentDidMount() {
|
|
43
|
-
if (CardWithURLRenderer.CardContent === null) {
|
|
44
|
-
(this.props.importer || CardWithURLRenderer.moduleImporter)(this);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
24
|
+
}, [id]);
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
const id = this.state.id;
|
|
50
|
-
clearMarks(id);
|
|
51
|
-
clearMeasures(id);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentDidCatch(error, errorInfo) {
|
|
26
|
+
const logError = (error, info) => {
|
|
55
27
|
const {
|
|
56
|
-
|
|
57
|
-
} =
|
|
28
|
+
componentStack
|
|
29
|
+
} = info; // NB: APIErrors are thrown in response to Object Resolver Service.
|
|
58
30
|
// In these cases, control is handed back to the Editor. We do not
|
|
59
31
|
// fire an event for these, as they do not cover failed UI render events.
|
|
60
32
|
|
|
@@ -64,54 +36,80 @@ export class CardWithURLRenderer extends React.PureComponent {
|
|
|
64
36
|
// to the reliability of the smart-card front-end components. We instrument
|
|
65
37
|
// these in order to measure our front-end reliability.
|
|
66
38
|
else {
|
|
67
|
-
|
|
39
|
+
const errorInfo = {
|
|
40
|
+
componentStack
|
|
41
|
+
};
|
|
42
|
+
failUfoExperience('smart-link-rendered', id);
|
|
43
|
+
failUfoExperience('smart-link-authenticated', id);
|
|
44
|
+
dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
|
|
68
45
|
}
|
|
69
|
-
} // Wrapper around analytics.
|
|
46
|
+
}; // Wrapper around analytics.
|
|
70
47
|
|
|
71
48
|
|
|
72
|
-
|
|
49
|
+
const dispatchAnalytics = analyticsPayload => {
|
|
73
50
|
const {
|
|
74
|
-
url,
|
|
75
51
|
appearance,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onClick,
|
|
79
|
-
container,
|
|
80
|
-
onResolve,
|
|
81
|
-
testId,
|
|
82
|
-
showActions,
|
|
83
|
-
inheritDimensions,
|
|
84
|
-
platform,
|
|
85
|
-
embedIframeRef,
|
|
86
|
-
inlinePreloaderStyle
|
|
87
|
-
} = this.props;
|
|
52
|
+
createAnalyticsEvent
|
|
53
|
+
} = props;
|
|
88
54
|
|
|
89
|
-
if (
|
|
90
|
-
|
|
55
|
+
if (analyticsPayload && analyticsPayload.attributes) {
|
|
56
|
+
// Update if we haven't already set the display - possible
|
|
57
|
+
// in the case of `preview` which is rendered differently.
|
|
58
|
+
if (!analyticsPayload.attributes.display) {
|
|
59
|
+
analyticsPayload.attributes.display = appearance;
|
|
60
|
+
}
|
|
91
61
|
}
|
|
92
62
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
63
|
+
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
url,
|
|
68
|
+
appearance,
|
|
69
|
+
isSelected,
|
|
70
|
+
isFrameVisible,
|
|
71
|
+
onClick,
|
|
72
|
+
container,
|
|
73
|
+
onResolve,
|
|
74
|
+
testId,
|
|
75
|
+
showActions,
|
|
76
|
+
inheritDimensions,
|
|
77
|
+
platform,
|
|
78
|
+
embedIframeRef,
|
|
79
|
+
inlinePreloaderStyle
|
|
80
|
+
} = props;
|
|
81
|
+
|
|
82
|
+
if (!url) {
|
|
83
|
+
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
113
84
|
}
|
|
114
85
|
|
|
86
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
87
|
+
FallbackComponent: ErrorFallback,
|
|
88
|
+
onError: logError
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Suspense, {
|
|
90
|
+
fallback: /*#__PURE__*/React.createElement(CardLinkView, {
|
|
91
|
+
key: 'chunk-placeholder',
|
|
92
|
+
link: url
|
|
93
|
+
})
|
|
94
|
+
}, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, {
|
|
95
|
+
id: id,
|
|
96
|
+
url: url,
|
|
97
|
+
appearance: appearance,
|
|
98
|
+
onClick: onClick,
|
|
99
|
+
isSelected: isSelected,
|
|
100
|
+
isFrameVisible: isFrameVisible,
|
|
101
|
+
dispatchAnalytics: dispatchAnalytics,
|
|
102
|
+
container: container,
|
|
103
|
+
onResolve: onResolve,
|
|
104
|
+
testId: testId,
|
|
105
|
+
showActions: showActions,
|
|
106
|
+
inheritDimensions: inheritDimensions,
|
|
107
|
+
platform: platform,
|
|
108
|
+
embedIframeRef: embedIframeRef,
|
|
109
|
+
inlinePreloaderStyle: inlinePreloaderStyle
|
|
110
|
+
})));
|
|
115
111
|
}
|
|
116
112
|
|
|
117
|
-
|
|
113
|
+
const ErrorFallback = () => {
|
|
114
|
+
return /*#__PURE__*/React.createElement("span", null);
|
|
115
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var devBaseUrl = 'https://api-private.dev.atlassian.com';
|
|
2
|
-
var stgBaseUrl = 'https://
|
|
2
|
+
var stgBaseUrl = 'https://commerce-components-preview.dev.atlassian.com/gateway/api';
|
|
3
3
|
var prodBaseUrl = 'https://api-private.atlassian.com';
|
|
4
4
|
export var BaseUrls = {
|
|
5
5
|
dev: devBaseUrl,
|
|
@@ -6,7 +6,7 @@ var isJiraRoadMap = function isJiraRoadMap(url) {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
var isPolarisView = function isPolarisView(url) {
|
|
9
|
-
return url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d
|
|
9
|
+
return url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d+$|^https:\/\/.*?\/secure\/JiraProductDiscoveryAnonymous\.jspa\?hash=\w+|^https:\/\/.*?\/jira\/polaris\/share\/\w+/);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
var isSlackMessage = function isSlackMessage(url) {
|
|
@@ -9,6 +9,7 @@ import { useSmartLinkContext } from '../context';
|
|
|
9
9
|
import * as measure from '../../utils/performance';
|
|
10
10
|
import { APIError } from '../../client/errors';
|
|
11
11
|
import { getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
12
|
+
import { addMetadataToExperience } from '../analytics';
|
|
12
13
|
export var useSmartCardActions = function useSmartCardActions(id, url, analytics) {
|
|
13
14
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
14
15
|
store = _useSmartLinkContext.store,
|
|
@@ -98,7 +99,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
98
99
|
isReloading = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
99
100
|
|
|
100
101
|
if (!(isReloading || !hasData)) {
|
|
101
|
-
_context.next =
|
|
102
|
+
_context.next = 6;
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -108,13 +109,18 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
108
109
|
return handleResolvedLinkError(resourceUrl, error);
|
|
109
110
|
}));
|
|
110
111
|
|
|
111
|
-
case
|
|
112
|
+
case 6:
|
|
113
|
+
addMetadataToExperience('smart-link-rendered', id, {
|
|
114
|
+
cached: true
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
case 7:
|
|
112
118
|
case "end":
|
|
113
119
|
return _context.stop();
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
}, _callee);
|
|
117
|
-
})), [url, hasData, connections.client, handleResolvedLinkResponse, handleResolvedLinkError]);
|
|
123
|
+
})), [url, hasData, connections.client, handleResolvedLinkResponse, handleResolvedLinkError, id]);
|
|
118
124
|
var register = useCallback(function () {
|
|
119
125
|
if (!details) {
|
|
120
126
|
dispatch(cardAction(ACTION_PENDING, {
|
|
@@ -152,10 +158,10 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
152
158
|
analytics.screen.authPopupEvent(definitionId, extensionKey);
|
|
153
159
|
auth(services[0].url).then(function () {
|
|
154
160
|
analytics.track.appAccountConnected(definitionId, extensionKey);
|
|
155
|
-
analytics.operational.connectSucceededEvent(definitionId, extensionKey);
|
|
161
|
+
analytics.operational.connectSucceededEvent(id, definitionId, extensionKey);
|
|
156
162
|
reload();
|
|
157
163
|
}, function (err) {
|
|
158
|
-
analytics.operational.connectFailedEvent(definitionId, extensionKey, err.type);
|
|
164
|
+
analytics.operational.connectFailedEvent(id, definitionId, extensionKey, err.type);
|
|
159
165
|
|
|
160
166
|
if (err.type === 'auth_window_closed') {
|
|
161
167
|
analytics.ui.closedAuthEvent(appearance, definitionId, extensionKey);
|
|
@@ -164,7 +170,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
164
170
|
reload();
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
|
-
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, reload, details, status]);
|
|
173
|
+
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload, details, status]);
|
|
168
174
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
169
175
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(opts, appearance) {
|
|
170
176
|
var key, action, source, markName, response;
|
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
4
|
-
var ui = useMemo(function () {
|
|
5
|
-
return {
|
|
6
|
-
authEvent: function authEvent(display, definitionId, extensionKey) {
|
|
7
|
-
return dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey));
|
|
8
|
-
},
|
|
9
|
-
authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
|
|
10
|
-
return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
|
|
11
|
-
},
|
|
12
|
-
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
13
|
-
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey));
|
|
14
|
-
},
|
|
15
|
-
actionClickedEvent: function actionClickedEvent(providerKey, actionType, display) {
|
|
16
|
-
return dispatchAnalytics(uiActionClickedEvent(providerKey, actionType, display));
|
|
17
|
-
},
|
|
18
|
-
closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
|
|
19
|
-
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
20
|
-
},
|
|
21
|
-
renderSuccessEvent: function renderSuccessEvent(display, definitionId, extensionKey) {
|
|
22
|
-
return dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
23
|
-
},
|
|
24
|
-
renderFailedEvent: function renderFailedEvent(display, error, errorInfo) {
|
|
25
|
-
return dispatchAnalytics(uiRenderFailedEvent(display, error, errorInfo));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}, [dispatchAnalytics]);
|
|
29
|
-
var operational = useMemo(function () {
|
|
30
|
-
return {
|
|
31
|
-
resolvedEvent: function resolvedEvent(id, definitionId, extensionKey, resourceType) {
|
|
32
|
-
return dispatchAnalytics(_resolvedEvent(id, definitionId, extensionKey, resourceType));
|
|
33
|
-
},
|
|
34
|
-
unresolvedEvent: function unresolvedEvent(id, status, definitionId, extensionKey, resourceType) {
|
|
35
|
-
return dispatchAnalytics(_unresolvedEvent(id, status, definitionId, extensionKey, resourceType));
|
|
36
|
-
},
|
|
37
|
-
invokeSucceededEvent: function invokeSucceededEvent(id, providerKey, actionType, display) {
|
|
38
|
-
return dispatchAnalytics(_invokeSucceededEvent(id, providerKey, actionType, display));
|
|
39
|
-
},
|
|
40
|
-
invokeFailedEvent: function invokeFailedEvent(id, providerKey, actionType, display, reason) {
|
|
41
|
-
return dispatchAnalytics(_invokeFailedEvent(id, providerKey, actionType, display, reason));
|
|
42
|
-
},
|
|
43
|
-
connectSucceededEvent: function connectSucceededEvent(definitionId, extensionKey) {
|
|
44
|
-
return dispatchAnalytics(_connectSucceededEvent(definitionId, extensionKey));
|
|
45
|
-
},
|
|
46
|
-
connectFailedEvent: function connectFailedEvent(definitionId, extensionKey, reason) {
|
|
47
|
-
return dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey, reason));
|
|
48
|
-
},
|
|
49
|
-
instrument: function instrument(id, status, definitionId, extensionKey, resourceType, error) {
|
|
50
|
-
var event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
|
|
51
|
-
|
|
52
|
-
if (event) {
|
|
53
|
-
dispatchAnalytics(event);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}, [dispatchAnalytics]);
|
|
58
|
-
var track = useMemo(function () {
|
|
59
|
-
return {
|
|
60
|
-
appAccountConnected: function appAccountConnected(definitionId, extensionKey) {
|
|
61
|
-
return dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}, [dispatchAnalytics]);
|
|
65
|
-
var screen = useMemo(function () {
|
|
66
|
-
return {
|
|
67
|
-
authPopupEvent: function authPopupEvent(definitionId, extensionKey) {
|
|
68
|
-
return dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey));
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}, [dispatchAnalytics]);
|
|
72
|
-
return useMemo(function () {
|
|
73
|
-
return {
|
|
74
|
-
ui: ui,
|
|
75
|
-
operational: operational,
|
|
76
|
-
track: track,
|
|
77
|
-
screen: screen
|
|
78
|
-
};
|
|
79
|
-
}, [ui, operational, track, screen]);
|
|
80
|
-
};
|
|
1
|
+
export { startUfoExperience, succeedUfoExperience, failUfoExperience, addMetadataToExperience } from './ufoExperiences';
|
|
2
|
+
export { useSmartLinkAnalytics } from './useSmartLinkAnalytics';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
|
+
var ufoExperiences = {
|
|
3
|
+
'smart-link-rendered': new ConcurrentExperience('smart-link-rendered', {
|
|
4
|
+
type: ExperienceTypes.Load,
|
|
5
|
+
performanceType: ExperiencePerformanceTypes.PageSegmentLoad,
|
|
6
|
+
platform: {
|
|
7
|
+
component: 'smart-links'
|
|
8
|
+
}
|
|
9
|
+
}),
|
|
10
|
+
'smart-link-authenticated': new ConcurrentExperience('smart-link-authenticated', {
|
|
11
|
+
type: ExperienceTypes.Load,
|
|
12
|
+
performanceType: ExperiencePerformanceTypes.PageSegmentLoad,
|
|
13
|
+
platform: {
|
|
14
|
+
component: 'smart-links'
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
export var startUfoExperience = function startUfoExperience(experienceName, id, properties) {
|
|
19
|
+
var experience = ufoExperiences[experienceName].getInstance(id);
|
|
20
|
+
experience.start();
|
|
21
|
+
|
|
22
|
+
if (properties) {
|
|
23
|
+
experience.addMetadata(properties);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export var succeedUfoExperience = function succeedUfoExperience(experienceName, id, properties) {
|
|
27
|
+
var experience = ufoExperiences[experienceName].getInstance(id);
|
|
28
|
+
experience.success({
|
|
29
|
+
metadata: properties
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export var failUfoExperience = function failUfoExperience(experienceName, id, properties) {
|
|
33
|
+
var experience = ufoExperiences[experienceName].getInstance(id);
|
|
34
|
+
experience.failure({
|
|
35
|
+
metadata: properties
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export var addMetadataToExperience = function addMetadataToExperience(experienceName, id, properties) {
|
|
39
|
+
ufoExperiences[experienceName].getInstance(id).addMetadata(properties);
|
|
40
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, resolvedEvent as _resolvedEvent, unresolvedEvent as _unresolvedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
|
+
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
5
|
+
var ui = useMemo(function () {
|
|
6
|
+
return {
|
|
7
|
+
authEvent: function authEvent(display, definitionId, extensionKey) {
|
|
8
|
+
return dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey));
|
|
9
|
+
},
|
|
10
|
+
authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
|
|
11
|
+
return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
|
|
12
|
+
},
|
|
13
|
+
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
14
|
+
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey));
|
|
15
|
+
},
|
|
16
|
+
actionClickedEvent: function actionClickedEvent(providerKey, actionType, display) {
|
|
17
|
+
return dispatchAnalytics(uiActionClickedEvent(providerKey, actionType, display));
|
|
18
|
+
},
|
|
19
|
+
closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
|
|
20
|
+
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
21
|
+
},
|
|
22
|
+
renderSuccessEvent: function renderSuccessEvent(display, id, definitionId, extensionKey) {
|
|
23
|
+
succeedUfoExperience('smart-link-rendered', id, {
|
|
24
|
+
extensionKey: extensionKey,
|
|
25
|
+
display: display
|
|
26
|
+
}); // UFO will disregard this if authentication experience has not yet been started
|
|
27
|
+
|
|
28
|
+
succeedUfoExperience('smart-link-authenticated', id, {
|
|
29
|
+
display: display
|
|
30
|
+
});
|
|
31
|
+
dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}, [dispatchAnalytics]);
|
|
35
|
+
var operational = useMemo(function () {
|
|
36
|
+
return {
|
|
37
|
+
resolvedEvent: function resolvedEvent(id, definitionId, extensionKey, resourceType) {
|
|
38
|
+
return dispatchAnalytics(_resolvedEvent(id, definitionId, extensionKey, resourceType));
|
|
39
|
+
},
|
|
40
|
+
unresolvedEvent: function unresolvedEvent(id, status, definitionId, extensionKey, resourceType) {
|
|
41
|
+
return dispatchAnalytics(_unresolvedEvent(id, status, definitionId, extensionKey, resourceType));
|
|
42
|
+
},
|
|
43
|
+
invokeSucceededEvent: function invokeSucceededEvent(id, providerKey, actionType, display) {
|
|
44
|
+
return dispatchAnalytics(_invokeSucceededEvent(id, providerKey, actionType, display));
|
|
45
|
+
},
|
|
46
|
+
invokeFailedEvent: function invokeFailedEvent(id, providerKey, actionType, display, reason) {
|
|
47
|
+
return dispatchAnalytics(_invokeFailedEvent(id, providerKey, actionType, display, reason));
|
|
48
|
+
},
|
|
49
|
+
connectSucceededEvent: function connectSucceededEvent(id, definitionId, extensionKey) {
|
|
50
|
+
startUfoExperience('smart-link-authenticated', id, {
|
|
51
|
+
extensionKey: extensionKey,
|
|
52
|
+
status: 'success'
|
|
53
|
+
});
|
|
54
|
+
dispatchAnalytics(_connectSucceededEvent(definitionId, extensionKey));
|
|
55
|
+
},
|
|
56
|
+
connectFailedEvent: function connectFailedEvent(id, definitionId, extensionKey, status) {
|
|
57
|
+
startUfoExperience('smart-link-authenticated', id, {
|
|
58
|
+
extensionKey: extensionKey,
|
|
59
|
+
status: status
|
|
60
|
+
});
|
|
61
|
+
dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey, status));
|
|
62
|
+
},
|
|
63
|
+
instrument: function instrument(id, status, definitionId, extensionKey, resourceType, error) {
|
|
64
|
+
var event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
|
|
65
|
+
|
|
66
|
+
if (event) {
|
|
67
|
+
dispatchAnalytics(event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [dispatchAnalytics]);
|
|
72
|
+
var track = useMemo(function () {
|
|
73
|
+
return {
|
|
74
|
+
appAccountConnected: function appAccountConnected(definitionId, extensionKey) {
|
|
75
|
+
return dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, [dispatchAnalytics]);
|
|
79
|
+
var screen = useMemo(function () {
|
|
80
|
+
return {
|
|
81
|
+
authPopupEvent: function authPopupEvent(definitionId, extensionKey) {
|
|
82
|
+
return dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}, [dispatchAnalytics]);
|
|
86
|
+
return useMemo(function () {
|
|
87
|
+
return {
|
|
88
|
+
ui: ui,
|
|
89
|
+
operational: operational,
|
|
90
|
+
track: track,
|
|
91
|
+
screen: screen
|
|
92
|
+
};
|
|
93
|
+
}, [ui, operational, track, screen]);
|
|
94
|
+
};
|
|
@@ -12,16 +12,15 @@ export function useSmartLink(id, url, dispatchAnalytics) {
|
|
|
12
12
|
var config = useSmartLinkConfig();
|
|
13
13
|
var renderers = useSmartLinkRenderers(); // NB: used to propagate errors from hooks to error boundaries.
|
|
14
14
|
|
|
15
|
-
var _useState = useState(),
|
|
15
|
+
var _useState = useState(null),
|
|
16
16
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
-
|
|
17
|
+
error = _useState2[0],
|
|
18
|
+
setError = _useState2[1]; // Register the current card.
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
var register = function register() {
|
|
21
22
|
actions.register().catch(function (err) {
|
|
22
|
-
return
|
|
23
|
-
throw err;
|
|
24
|
-
});
|
|
23
|
+
return setError(err);
|
|
25
24
|
});
|
|
26
25
|
}; // AFP-2511 TODO: Fix automatic suppressions below
|
|
27
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -34,6 +33,7 @@ export function useSmartLink(id, url, dispatchAnalytics) {
|
|
|
34
33
|
actions: actions,
|
|
35
34
|
config: config,
|
|
36
35
|
analytics: analytics,
|
|
37
|
-
renderers: renderers
|
|
36
|
+
renderers: renderers,
|
|
37
|
+
error: error
|
|
38
38
|
};
|
|
39
39
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { isIntersectionObserverSupported } from '@atlaskit/media-ui';
|
|
3
3
|
import { LazyLazilyRenderCard } from './LazyLazilyRenderCard';
|
|
4
4
|
import { LazyIntersectionObserverCard } from './LazyIntersectionObserverCard';
|
|
5
|
-
export function LazyCardWithUrlContent(props) {
|
|
5
|
+
export default function LazyCardWithUrlContent(props) {
|
|
6
6
|
if (isIntersectionObserverSupported()) {
|
|
7
7
|
return /*#__PURE__*/React.createElement(LazyIntersectionObserverCard, props);
|
|
8
8
|
} else {
|
|
@@ -28,7 +28,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
28
28
|
actions = _useSmartLink.actions,
|
|
29
29
|
config = _useSmartLink.config,
|
|
30
30
|
analytics = _useSmartLink.analytics,
|
|
31
|
-
renderers = _useSmartLink.renderers
|
|
31
|
+
renderers = _useSmartLink.renderers,
|
|
32
|
+
error = _useSmartLink.error;
|
|
32
33
|
|
|
33
34
|
var definitionId = getDefinitionId(state.details);
|
|
34
35
|
var extensionKey = getExtensionKey(state.details);
|
|
@@ -71,9 +72,13 @@ export function CardWithUrlContent(_ref) {
|
|
|
71
72
|
|
|
72
73
|
useEffect(function () {
|
|
73
74
|
if (isFinalState(state.status)) {
|
|
74
|
-
analytics.ui.renderSuccessEvent(appearance, definitionId, extensionKey);
|
|
75
|
+
analytics.ui.renderSuccessEvent(appearance, id, definitionId, extensionKey);
|
|
75
76
|
}
|
|
76
|
-
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui]);
|
|
77
|
+
}, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]); // We have to keep this last to prevent hook order from being violated
|
|
78
|
+
|
|
79
|
+
if (error) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
switch (appearance) {
|
|
79
84
|
case 'inline':
|