@atlaskit/smart-card 33.1.0 → 33.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 +8 -0
- package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +1 -20
- package/dist/cjs/extractors/flexible/actions/extract-download-action.js +1 -23
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +1 -34
- package/dist/cjs/extractors/flexible/actions/index.js +2 -15
- package/dist/cjs/extractors/flexible/extract-state.js +1 -5
- package/dist/cjs/extractors/flexible/index.js +3 -7
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +18 -190
- package/dist/cjs/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +4 -18
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +12 -25
- package/dist/cjs/view/CardWithUrl/loader.js +10 -22
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +40 -89
- package/dist/cjs/view/EmbedModal/index.js +8 -65
- package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +26 -63
- package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +4 -40
- package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +4 -47
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +10 -26
- package/dist/cjs/view/FlexibleCard/components/utils.js +1 -28
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +13 -30
- package/dist/cjs/view/HoverCard/index.js +10 -22
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +0 -19
- package/dist/es2019/extractors/flexible/actions/extract-download-action.js +0 -21
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +0 -34
- package/dist/es2019/extractors/flexible/actions/index.js +4 -23
- package/dist/es2019/extractors/flexible/extract-state.js +1 -5
- package/dist/es2019/extractors/flexible/index.js +3 -4
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +2 -172
- package/dist/es2019/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +4 -18
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +3 -40
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +13 -26
- package/dist/es2019/view/CardWithUrl/loader.js +11 -23
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +39 -88
- package/dist/es2019/view/EmbedModal/index.js +10 -33
- package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +11 -32
- package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +4 -22
- package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +4 -27
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -24
- package/dist/es2019/view/FlexibleCard/components/utils.js +0 -25
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +12 -25
- package/dist/es2019/view/HoverCard/index.js +11 -23
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +0 -19
- package/dist/esm/extractors/flexible/actions/extract-download-action.js +0 -23
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +0 -34
- package/dist/esm/extractors/flexible/actions/index.js +4 -17
- package/dist/esm/extractors/flexible/extract-state.js +1 -5
- package/dist/esm/extractors/flexible/index.js +3 -4
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +19 -191
- package/dist/esm/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +4 -18
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +13 -26
- package/dist/esm/view/CardWithUrl/loader.js +10 -22
- package/dist/esm/view/EmbedModal/components/analytics/index.js +40 -89
- package/dist/esm/view/EmbedModal/index.js +10 -67
- package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +26 -63
- package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +4 -40
- package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +4 -47
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -26
- package/dist/esm/view/FlexibleCard/components/utils.js +0 -27
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +13 -30
- package/dist/esm/view/HoverCard/index.js +10 -22
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/index.d.ts +0 -6
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -60
- package/dist/types/state/flexible-ui-context/types.d.ts +4 -19
- package/dist/types/state/hooks/use-invoke/types.d.ts +0 -6
- package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +1 -1
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -16
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
- package/dist/types/utils/mocks.d.ts +1 -16
- package/dist/types/view/EmbedModal/index.d.ts +0 -2
- package/dist/types/view/EmbedModal/types.d.ts +0 -3
- package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
- package/dist/types/view/FlexibleCard/components/utils.d.ts +0 -6
- package/dist/types/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
- package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +1 -1
- package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +0 -6
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +2 -60
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +4 -19
- package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +0 -6
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +1 -1
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +1 -16
- package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
- package/dist/types-ts4.5/utils/mocks.d.ts +1 -16
- package/dist/types-ts4.5/view/EmbedModal/index.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedModal/types.d.ts +0 -3
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
- package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +0 -6
- package/dist/types-ts4.5/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/components/views/resolved/index.d.ts +1 -1
- package/package.json +1 -4
- package/dist/cjs/extractors/action/extractDownloadActionProps.js +0 -32
- package/dist/cjs/extractors/action/extractPreviewActionProps.js +0 -47
- package/dist/cjs/extractors/action/extractViewActionProps.js +0 -31
- package/dist/cjs/extractors/flexible/actions/extract-view-action.js +0 -27
- package/dist/es2019/extractors/action/extractDownloadActionProps.js +0 -24
- package/dist/es2019/extractors/action/extractPreviewActionProps.js +0 -36
- package/dist/es2019/extractors/action/extractViewActionProps.js +0 -23
- package/dist/es2019/extractors/flexible/actions/extract-view-action.js +0 -20
- package/dist/esm/extractors/action/extractDownloadActionProps.js +0 -27
- package/dist/esm/extractors/action/extractPreviewActionProps.js +0 -41
- package/dist/esm/extractors/action/extractViewActionProps.js +0 -26
- package/dist/esm/extractors/flexible/actions/extract-view-action.js +0 -22
- package/dist/types/extractors/action/extractDownloadActionProps.d.ts +0 -7
- package/dist/types/extractors/action/extractPreviewActionProps.d.ts +0 -7
- package/dist/types/extractors/action/extractViewActionProps.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +0 -7
- package/dist/types/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
- package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +0 -7
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ActionName, InternalActionName } from '../../../constants';
|
|
2
2
|
import { extractAISummaryAction } from './extract-ai-summary-action';
|
|
3
3
|
import { extractAutomationAction } from './extract-automation-action';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { extractCopyLinkClientAction } from './extract-copy-link-action';
|
|
5
|
+
import { extractDownloadClientAction } from './extract-download-action';
|
|
6
6
|
import extractFollowAction from './extract-follow-action';
|
|
7
|
-
import {
|
|
7
|
+
import { extractPreviewClientAction } from './extract-preview-action';
|
|
8
8
|
import { extractViewRelatedLinksAction } from './extract-view-related-links-action';
|
|
9
9
|
export const extractFlexibleCardActions = ({
|
|
10
10
|
actionOptions,
|
|
@@ -43,23 +43,4 @@ export const extractFlexibleCardActions = ({
|
|
|
43
43
|
[InternalActionName.ViewRelatedLinksAction]: extractViewRelatedLinksAction(response)
|
|
44
44
|
};
|
|
45
45
|
return Object.values(action).some(value => Boolean(value)) ? action : undefined;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
|
|
50
|
-
* Replaced with extractFlexibleCardActions()
|
|
51
|
-
*/
|
|
52
|
-
const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
|
|
53
|
-
const data = response.data;
|
|
54
|
-
const action = {
|
|
55
|
-
[ActionName.CopyLinkAction]: extractCopyLinkAction(data, actionOptions),
|
|
56
|
-
[ActionName.DownloadAction]: extractDownloadAction(data, actionOptions),
|
|
57
|
-
[ActionName.FollowAction]: extractFollowAction(response, actionOptions, id),
|
|
58
|
-
[ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
|
|
59
|
-
[ActionName.AutomationAction]: extractAutomationAction(response),
|
|
60
|
-
[InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig),
|
|
61
|
-
[InternalActionName.ViewRelatedLinksAction]: extractViewRelatedLinksAction(response)
|
|
62
|
-
};
|
|
63
|
-
return Object.values(action).some(value => Boolean(value)) ? action : undefined;
|
|
64
|
-
};
|
|
65
|
-
export default extractActions;
|
|
46
|
+
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { extractLink } from '@atlaskit/link-extractors';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { getExtensionKey } from '../../state/helpers';
|
|
4
3
|
import { canShowAction } from '../../utils/actions/can-show-action';
|
|
5
4
|
import { CardAction } from '../../view/Card/types';
|
|
6
5
|
import { extractInvokePreviewAction } from '../action/extract-invoke-preview-action';
|
|
7
6
|
import { extractLozenge } from '../common/lozenge';
|
|
8
|
-
import { extractPreviewAction } from './actions/extract-preview-action';
|
|
9
7
|
import extractServerAction from './extract-server-action';
|
|
10
8
|
const toInvokeRequest = (extensionKey, resourceIdentifiers, actionType, details) => {
|
|
11
9
|
if (!actionType) {
|
|
@@ -34,8 +32,7 @@ const extractAction = (response, id, actionOptions, appearance, origin, fireEven
|
|
|
34
32
|
}
|
|
35
33
|
const read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
36
34
|
const url = extractLink(data);
|
|
37
|
-
const
|
|
38
|
-
const invokePreviewAction = response && fg('platform-smart-card-migrate-embed-modal-analytics') ? extractInvokePreviewAction({
|
|
35
|
+
const invokePreviewAction = response ? extractInvokePreviewAction({
|
|
39
36
|
actionOptions,
|
|
40
37
|
appearance,
|
|
41
38
|
fireEvent,
|
|
@@ -47,7 +44,6 @@ const extractAction = (response, id, actionOptions, appearance, origin, fireEven
|
|
|
47
44
|
const details = {
|
|
48
45
|
id,
|
|
49
46
|
url,
|
|
50
|
-
previewData,
|
|
51
47
|
invokePreviewAction
|
|
52
48
|
};
|
|
53
49
|
const update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { extractAri, extractDateCreated, extractDateUpdated, extractLink, extractPersonCreatedBy, extractPersonOwnedBy, extractTitle } from '@atlaskit/link-extractors';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { extractSummary } from '../common/primitives';
|
|
4
|
-
import
|
|
3
|
+
import { extractFlexibleCardActions } from './actions';
|
|
5
4
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
6
5
|
import extractPreview from './extract-preview';
|
|
7
6
|
import extractPriority from './extract-priority';
|
|
@@ -28,7 +27,7 @@ const extractFlexibleUiContext = ({
|
|
|
28
27
|
const data = response.data;
|
|
29
28
|
const url = extractLink(data);
|
|
30
29
|
return {
|
|
31
|
-
actions:
|
|
30
|
+
actions: extractFlexibleCardActions({
|
|
32
31
|
actionOptions,
|
|
33
32
|
aiSummaryConfig,
|
|
34
33
|
appearance,
|
|
@@ -37,7 +36,7 @@ const extractFlexibleUiContext = ({
|
|
|
37
36
|
origin,
|
|
38
37
|
response,
|
|
39
38
|
url: props.url // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
|
|
40
|
-
})
|
|
39
|
+
}),
|
|
41
40
|
assignedToGroup: extractPersonAssignedToAsArray(data),
|
|
42
41
|
attachmentCount: extractAttachmentCount(data),
|
|
43
42
|
authorGroup: extractPersonCreatedBy(data),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
3
|
import { getUrl } from '@atlaskit/linking-common';
|
|
4
|
-
import {
|
|
4
|
+
import { invokeFailedEvent, invokeSucceededEvent } from '../../utils/analytics';
|
|
5
5
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getStatusDetails, getSubproduct } from '../helpers';
|
|
6
|
-
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
7
6
|
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
8
7
|
const applyCommonAttributes = (event, commonAttributes) => {
|
|
9
8
|
if (event && event.attributes) {
|
|
@@ -54,156 +53,6 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
54
53
|
statusDetails: extractedStatusDetails
|
|
55
54
|
}), [defaultId, extractedDefinitionId, extractedExtensionKey, extractedResourceType, extractedSubproduct, extractedProduct, defaultLocation, extractedStatusDetails]);
|
|
56
55
|
|
|
57
|
-
/** Contains all ui analytics events */
|
|
58
|
-
const ui = useMemo(() => ({
|
|
59
|
-
/**
|
|
60
|
-
* This fires an event that represents when a user
|
|
61
|
-
* click a button.
|
|
62
|
-
* @param data A partial analytics event payload
|
|
63
|
-
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
64
|
-
*/
|
|
65
|
-
buttonClickedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
66
|
-
action: 'clicked',
|
|
67
|
-
actionSubject: 'button',
|
|
68
|
-
actionSubjectId: data.actionSubjectId,
|
|
69
|
-
attributes: {
|
|
70
|
-
...context,
|
|
71
|
-
...data.attributes
|
|
72
|
-
},
|
|
73
|
-
eventType: 'ui'
|
|
74
|
-
}, commonAttributes)),
|
|
75
|
-
/**
|
|
76
|
-
* This fires an event that represents when a user clicks on a Smart Link action.
|
|
77
|
-
* Note: This also starts the UFO smart-link-action-invocation experience.
|
|
78
|
-
* @param id The unique ID for this Smart Link.
|
|
79
|
-
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
80
|
-
* @param actionType The type of the action that was clicked, e.g. PreviewAction
|
|
81
|
-
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
actionClickedEvent: ({
|
|
85
|
-
id,
|
|
86
|
-
actionType,
|
|
87
|
-
display,
|
|
88
|
-
extensionKey: overrideExtensionKey,
|
|
89
|
-
definitionId,
|
|
90
|
-
resourceType,
|
|
91
|
-
destinationProduct,
|
|
92
|
-
destinationSubproduct,
|
|
93
|
-
location
|
|
94
|
-
}) => {
|
|
95
|
-
const extensionKey = overrideExtensionKey !== null && overrideExtensionKey !== void 0 ? overrideExtensionKey : extractedExtensionKey;
|
|
96
|
-
dispatchAnalytics(applyCommonAttributes(uiActionClickedEvent({
|
|
97
|
-
id: id !== null && id !== void 0 ? id : defaultId,
|
|
98
|
-
actionType,
|
|
99
|
-
display,
|
|
100
|
-
extensionKey,
|
|
101
|
-
definitionId,
|
|
102
|
-
resourceType,
|
|
103
|
-
destinationProduct,
|
|
104
|
-
destinationSubproduct,
|
|
105
|
-
location
|
|
106
|
-
}), commonAttributes));
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* This fires an event that represents when a user close a modal.
|
|
110
|
-
* @param data A partial analytics event payload
|
|
111
|
-
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
112
|
-
*/
|
|
113
|
-
modalClosedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
114
|
-
action: 'closed',
|
|
115
|
-
actionSubject: 'modal',
|
|
116
|
-
actionSubjectId: data.actionSubjectId,
|
|
117
|
-
attributes: {
|
|
118
|
-
...context,
|
|
119
|
-
...data.attributes
|
|
120
|
-
},
|
|
121
|
-
eventType: 'ui'
|
|
122
|
-
}, commonAttributes)),
|
|
123
|
-
/**
|
|
124
|
-
* This fires an event that represents when a Smart Link was rendered successfully.
|
|
125
|
-
* Note: this fires even if the Smart Link request errored out.
|
|
126
|
-
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
127
|
-
* @param id The unique ID for this Smart Link.
|
|
128
|
-
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
129
|
-
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
130
|
-
* @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
|
|
131
|
-
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
132
|
-
*/
|
|
133
|
-
renderSuccessEvent: ({
|
|
134
|
-
display,
|
|
135
|
-
status,
|
|
136
|
-
id,
|
|
137
|
-
extensionKey,
|
|
138
|
-
definitionId,
|
|
139
|
-
resourceType,
|
|
140
|
-
destinationProduct,
|
|
141
|
-
destinationSubproduct,
|
|
142
|
-
location,
|
|
143
|
-
canBeDatasource = false
|
|
144
|
-
}) => {
|
|
145
|
-
const experienceId = id ? id : defaultId;
|
|
146
|
-
succeedUfoExperience('smart-link-rendered', experienceId, {
|
|
147
|
-
extensionKey,
|
|
148
|
-
display
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// UFO will disregard this if authentication experience has not yet been started
|
|
152
|
-
succeedUfoExperience('smart-link-authenticated', experienceId, {
|
|
153
|
-
display
|
|
154
|
-
});
|
|
155
|
-
dispatchAnalytics(applyCommonAttributes(uiRenderSuccessEvent({
|
|
156
|
-
display,
|
|
157
|
-
status,
|
|
158
|
-
extensionKey,
|
|
159
|
-
definitionId,
|
|
160
|
-
resourceType,
|
|
161
|
-
destinationProduct,
|
|
162
|
-
destinationSubproduct,
|
|
163
|
-
location,
|
|
164
|
-
canBeDatasource
|
|
165
|
-
}), commonAttributes));
|
|
166
|
-
},
|
|
167
|
-
/**
|
|
168
|
-
* This fires an event that represents when a Smart Link renders unsuccessfuly.
|
|
169
|
-
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
170
|
-
* @param id The unique ID for this Smart Link.
|
|
171
|
-
* @param error: An error representing why the Smart Link render failed.
|
|
172
|
-
* @param errorInfo: Additional details about the error including the stack trace.
|
|
173
|
-
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
174
|
-
*/
|
|
175
|
-
renderFailedEvent: ({
|
|
176
|
-
display,
|
|
177
|
-
id,
|
|
178
|
-
error,
|
|
179
|
-
errorInfo,
|
|
180
|
-
extensionKey,
|
|
181
|
-
definitionId,
|
|
182
|
-
resourceType,
|
|
183
|
-
destinationProduct,
|
|
184
|
-
destinationSubproduct,
|
|
185
|
-
location
|
|
186
|
-
}) => {
|
|
187
|
-
const experienceId = id ? id : defaultId;
|
|
188
|
-
// Start and fail the smart-link-rendered experience. If it has already
|
|
189
|
-
// been started nothing happens.
|
|
190
|
-
startUfoExperience('smart-link-rendered', experienceId);
|
|
191
|
-
failUfoExperience('smart-link-rendered', experienceId);
|
|
192
|
-
failUfoExperience('smart-link-authenticated', experienceId);
|
|
193
|
-
dispatchAnalytics(applyCommonAttributes(uiRenderFailedEvent({
|
|
194
|
-
display,
|
|
195
|
-
error,
|
|
196
|
-
errorInfo,
|
|
197
|
-
extensionKey,
|
|
198
|
-
definitionId,
|
|
199
|
-
resourceType,
|
|
200
|
-
destinationProduct,
|
|
201
|
-
destinationSubproduct,
|
|
202
|
-
location
|
|
203
|
-
}), commonAttributes));
|
|
204
|
-
}
|
|
205
|
-
}), [dispatchAnalytics, commonAttributes, defaultId, extractedExtensionKey]);
|
|
206
|
-
|
|
207
56
|
/** Contains all operational analytics events */
|
|
208
57
|
const operational = useMemo(() => ({
|
|
209
58
|
/**
|
|
@@ -270,27 +119,8 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
270
119
|
}), commonAttributes));
|
|
271
120
|
}
|
|
272
121
|
}), [defaultId, commonAttributes, dispatchAnalytics]);
|
|
273
|
-
|
|
274
|
-
/** Contains all screen analytics events */
|
|
275
|
-
const screen = useMemo(() => ({
|
|
276
|
-
/**
|
|
277
|
-
* This fires an event that represents when a user view a modal.
|
|
278
|
-
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
279
|
-
*/
|
|
280
|
-
modalViewedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
281
|
-
action: 'viewed',
|
|
282
|
-
actionSubject: data.name,
|
|
283
|
-
attributes: {
|
|
284
|
-
...context,
|
|
285
|
-
...data.attributes
|
|
286
|
-
},
|
|
287
|
-
eventType: 'screen',
|
|
288
|
-
name: data.name
|
|
289
|
-
}, commonAttributes))
|
|
290
|
-
}), [commonAttributes, dispatchAnalytics]);
|
|
291
122
|
return useMemo(() => ({
|
|
292
|
-
ui,
|
|
293
123
|
operational,
|
|
294
124
|
screen
|
|
295
|
-
}), [
|
|
125
|
+
}), [operational]);
|
|
296
126
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
|
|
5
4
|
import * as measure from '../../../utils/performance';
|
|
6
5
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../analytics';
|
|
@@ -10,7 +9,6 @@ const ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
|
|
|
10
9
|
* Invoke client action such as preview, download and open link
|
|
11
10
|
*/
|
|
12
11
|
const useInvokeClientAction = ({
|
|
13
|
-
analytics,
|
|
14
12
|
fireEvent: fireEventProp
|
|
15
13
|
}) => {
|
|
16
14
|
const {
|
|
@@ -33,6 +31,7 @@ const useInvokeClientAction = ({
|
|
|
33
31
|
const markName = `${experienceId}-${actionType}`;
|
|
34
32
|
measure.mark(markName, 'pending');
|
|
35
33
|
try {
|
|
34
|
+
var _measure$getMeasure$d, _measure$getMeasure;
|
|
36
35
|
// Begin UFO experience
|
|
37
36
|
startUfoExperience(ACTION_EXPERIENCE_NAME, experienceId, {
|
|
38
37
|
actionType,
|
|
@@ -42,7 +41,7 @@ const useInvokeClientAction = ({
|
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
// Begin analytics instrumentation.
|
|
45
|
-
if (actionSubjectId
|
|
44
|
+
if (actionSubjectId !== undefined) {
|
|
46
45
|
fireEvent(`ui.button.clicked.${actionSubjectId}`, {
|
|
47
46
|
actionType: actionType !== null && actionType !== void 0 ? actionType : null,
|
|
48
47
|
definitionId,
|
|
@@ -50,57 +49,35 @@ const useInvokeClientAction = ({
|
|
|
50
49
|
id: id !== null && id !== void 0 ? id : experienceId,
|
|
51
50
|
resourceType
|
|
52
51
|
});
|
|
53
|
-
} else {
|
|
54
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.ui.actionClickedEvent({
|
|
55
|
-
actionType,
|
|
56
|
-
display
|
|
57
|
-
});
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
// Invoke action
|
|
61
54
|
const result = await actionFn();
|
|
62
55
|
measure.mark(markName, 'resolved');
|
|
63
56
|
succeedUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
resourceType
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeSucceededEvent({
|
|
76
|
-
actionType,
|
|
77
|
-
display
|
|
78
|
-
});
|
|
79
|
-
}
|
|
57
|
+
fireEvent('operational.smartLinkAction.resolved', {
|
|
58
|
+
actionType: actionType !== null && actionType !== void 0 ? actionType : null,
|
|
59
|
+
definitionId,
|
|
60
|
+
display: display !== null && display !== void 0 ? display : null,
|
|
61
|
+
duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(markName, 'resolved')) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null,
|
|
62
|
+
id: id !== null && id !== void 0 ? id : experienceId,
|
|
63
|
+
resourceType
|
|
64
|
+
});
|
|
80
65
|
return result;
|
|
81
66
|
} catch (err) {
|
|
67
|
+
var _measure$getMeasure$d2, _measure$getMeasure2;
|
|
82
68
|
measure.mark(markName, 'errored');
|
|
83
69
|
failUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
84
70
|
const reason = typeof err === 'string' ? err : err === null || err === void 0 ? void 0 : err.message;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
resourceType
|
|
95
|
-
});
|
|
96
|
-
} else {
|
|
97
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeFailedEvent({
|
|
98
|
-
actionType,
|
|
99
|
-
display,
|
|
100
|
-
reason
|
|
101
|
-
});
|
|
102
|
-
}
|
|
71
|
+
fireEvent('operational.smartLinkAction.unresolved', {
|
|
72
|
+
actionType: actionType !== null && actionType !== void 0 ? actionType : null,
|
|
73
|
+
definitionId,
|
|
74
|
+
display: display !== null && display !== void 0 ? display : null,
|
|
75
|
+
duration: (_measure$getMeasure$d2 = (_measure$getMeasure2 = measure.getMeasure(markName, 'errored')) === null || _measure$getMeasure2 === void 0 ? void 0 : _measure$getMeasure2.duration) !== null && _measure$getMeasure$d2 !== void 0 ? _measure$getMeasure$d2 : null,
|
|
76
|
+
id: id !== null && id !== void 0 ? id : experienceId,
|
|
77
|
+
reason,
|
|
78
|
+
resourceType
|
|
79
|
+
});
|
|
103
80
|
}
|
|
104
|
-
}, [
|
|
81
|
+
}, [fireEvent]);
|
|
105
82
|
};
|
|
106
83
|
export default useInvokeClientAction;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
5
4
|
import { extractInvokeDownloadAction } from '../../extractors/action/extract-invoke-download-action';
|
|
6
5
|
import { extractInvokePreviewAction } from '../../extractors/action/extract-invoke-preview-action';
|
|
7
6
|
import { extractInvokeViewAction } from '../../extractors/action/extract-invoke-view-action';
|
|
8
|
-
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
9
|
-
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
10
|
-
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
11
7
|
import { messages } from '../../messages';
|
|
12
8
|
import { toAction } from '../../utils/actions/to-action';
|
|
13
9
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
14
|
-
import { getExtensionKey } from '../helpers';
|
|
15
10
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
16
11
|
import { useSmartCardState as useLinkState } from '../store';
|
|
17
12
|
export function useSmartLinkActions({
|
|
@@ -30,15 +25,6 @@ export function useSmartLinkActions({
|
|
|
30
25
|
analytics: linkAnalytics
|
|
31
26
|
});
|
|
32
27
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
33
|
-
const opts = {
|
|
34
|
-
response: linkState.details,
|
|
35
|
-
handleInvoke: invokeClientAction,
|
|
36
|
-
analytics: linkAnalytics,
|
|
37
|
-
origin,
|
|
38
|
-
extensionKey: getExtensionKey(linkState.details),
|
|
39
|
-
source: appearance,
|
|
40
|
-
actionOptions
|
|
41
|
-
};
|
|
42
28
|
const actions = [];
|
|
43
29
|
const invokeParam = {
|
|
44
30
|
actionOptions,
|
|
@@ -46,19 +32,19 @@ export function useSmartLinkActions({
|
|
|
46
32
|
id,
|
|
47
33
|
response: linkState.details
|
|
48
34
|
};
|
|
49
|
-
const downloadActionProps =
|
|
35
|
+
const downloadActionProps = extractInvokeDownloadAction(invokeParam);
|
|
50
36
|
if (downloadActionProps) {
|
|
51
37
|
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
52
38
|
}
|
|
53
|
-
const viewActionProps =
|
|
39
|
+
const viewActionProps = extractInvokeViewAction(invokeParam);
|
|
54
40
|
if (viewActionProps) {
|
|
55
41
|
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
56
42
|
}
|
|
57
|
-
const previewActionProps =
|
|
43
|
+
const previewActionProps = extractInvokePreviewAction({
|
|
58
44
|
...invokeParam,
|
|
59
45
|
fireEvent,
|
|
60
46
|
origin
|
|
61
|
-
})
|
|
47
|
+
});
|
|
62
48
|
if (previewActionProps) {
|
|
63
49
|
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
64
50
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
3
2
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
4
3
|
import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
|
|
5
4
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
6
5
|
import { getUrl } from '@atlaskit/linking-common';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
6
|
import { useSmartCardState as useSmartLinkState } from '../../state/store';
|
|
9
7
|
import { context } from './analytics';
|
|
10
|
-
import { LinkAnalyticsContext } from './LinkAnalyticsContext';
|
|
11
8
|
const getExtendedResolvedAttributes = (linkDetails, details, linkStatus) => {
|
|
12
9
|
var _details$meta$definit, _details$meta, _details$meta$resourc, _details$meta2;
|
|
13
10
|
return {
|
|
@@ -52,14 +49,14 @@ export const useSmartLinkAnalyticsContext = ({
|
|
|
52
49
|
} = useSmartLinkContext();
|
|
53
50
|
const state = store ? getUrl(store, url) : undefined;
|
|
54
51
|
return useMemo(() => {
|
|
55
|
-
return
|
|
52
|
+
return getSmartLinkAnalyticsContext({
|
|
56
53
|
display,
|
|
57
54
|
id,
|
|
58
55
|
response: state === null || state === void 0 ? void 0 : state.details,
|
|
59
56
|
source,
|
|
60
57
|
status: state === null || state === void 0 ? void 0 : state.status,
|
|
61
58
|
url
|
|
62
|
-
})
|
|
59
|
+
});
|
|
63
60
|
}, [display, id, source, state === null || state === void 0 ? void 0 : state.details, state === null || state === void 0 ? void 0 : state.status, url]);
|
|
64
61
|
};
|
|
65
62
|
|
|
@@ -67,7 +64,7 @@ export const useSmartLinkAnalyticsContext = ({
|
|
|
67
64
|
* Provides an analytics context to supply attributes to events based on a URL
|
|
68
65
|
* and the link state in the store
|
|
69
66
|
*/
|
|
70
|
-
const
|
|
67
|
+
export const SmartLinkAnalyticsContext = ({
|
|
71
68
|
children,
|
|
72
69
|
display,
|
|
73
70
|
id,
|
|
@@ -89,38 +86,4 @@ const ExtendedSmartLinkAnalyticsContext = ({
|
|
|
89
86
|
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
90
87
|
data: data
|
|
91
88
|
}, children);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Provides an analytics context to supply attributes to events based on a URL
|
|
96
|
-
* and the link state in the store
|
|
97
|
-
*/
|
|
98
|
-
const LegacySmartLinkAnalyticsContext = props => {
|
|
99
|
-
const {
|
|
100
|
-
children,
|
|
101
|
-
url,
|
|
102
|
-
display
|
|
103
|
-
} = props;
|
|
104
|
-
const {
|
|
105
|
-
details,
|
|
106
|
-
status
|
|
107
|
-
} = useSmartLinkState(url);
|
|
108
|
-
const attributes = getResolvedAttributes({
|
|
109
|
-
url
|
|
110
|
-
}, details, status);
|
|
111
|
-
return /*#__PURE__*/React.createElement(LinkAnalyticsContext, _extends({}, props, {
|
|
112
|
-
display: display
|
|
113
|
-
}), /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
114
|
-
data: {
|
|
115
|
-
attributes
|
|
116
|
-
}
|
|
117
|
-
}, children));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Provides an analytics context to supply attributes to events based on a URL
|
|
122
|
-
* and the link state in the store
|
|
123
|
-
*/
|
|
124
|
-
export const SmartLinkAnalyticsContext = props => {
|
|
125
|
-
return fg('platform-smart-card-migrate-embed-modal-analytics') ? /*#__PURE__*/React.createElement(ExtendedSmartLinkAnalyticsContext, props) : /*#__PURE__*/React.createElement(LegacySmartLinkAnalyticsContext, props);
|
|
126
89
|
};
|
|
@@ -3,7 +3,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
3
3
|
export const context = {
|
|
4
4
|
componentName: 'smart-cards',
|
|
5
5
|
packageName: "@atlaskit/smart-card",
|
|
6
|
-
packageVersion: "33.
|
|
6
|
+
packageVersion: "33.2.0"
|
|
7
7
|
};
|
|
8
8
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
9
9
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
5
4
|
import { CardDisplay } from '../../constants';
|
|
6
5
|
import { useSmartLink } from '../../state';
|
|
7
6
|
import { succeedUfoExperience } from '../../state/analytics';
|
|
8
|
-
import {
|
|
7
|
+
import { getClickUrl, getDefinitionId, getExtensionKey, getResourceType, getServices, isFinalState } from '../../state/helpers';
|
|
9
8
|
import { SmartLinkModalProvider } from '../../state/modal';
|
|
10
9
|
import { isSpecialEvent } from '../../utils';
|
|
11
10
|
import { combineActionOptions } from '../../utils/actions/combine-action-options';
|
|
@@ -64,7 +63,6 @@ function Component({
|
|
|
64
63
|
const extensionKey = getExtensionKey(state.details);
|
|
65
64
|
const resourceType = getResourceType(state.details);
|
|
66
65
|
const services = getServices(state.details);
|
|
67
|
-
const canBeDatasource = getCanBeDatasource(state.details);
|
|
68
66
|
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]);
|
|
69
67
|
const actionOptions = combineActionOptions({
|
|
70
68
|
actionOptions: actionOptionsProp,
|
|
@@ -139,31 +137,20 @@ function Component({
|
|
|
139
137
|
// - the unresolved states: viz. forbidden, not_found, unauthorized, errored.
|
|
140
138
|
useEffect(() => {
|
|
141
139
|
if (isFinalState(state.status)) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
140
|
+
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
141
|
+
extensionKey,
|
|
142
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
143
|
+
});
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else {
|
|
156
|
-
analytics.ui.renderSuccessEvent({
|
|
157
|
-
display: isFlexibleUi ? 'flexible' : appearance,
|
|
158
|
-
status: state.status,
|
|
159
|
-
id,
|
|
160
|
-
definitionId,
|
|
161
|
-
extensionKey,
|
|
162
|
-
canBeDatasource
|
|
163
|
-
});
|
|
164
|
-
}
|
|
145
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
146
|
+
succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
|
|
147
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
148
|
+
});
|
|
149
|
+
fireEvent('ui.smartLink.renderSuccess', {
|
|
150
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
151
|
+
});
|
|
165
152
|
}
|
|
166
|
-
}, [
|
|
153
|
+
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
167
154
|
const onIframeDwell = useCallback((dwellTime, dwellPercentVisible) => {
|
|
168
155
|
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
169
156
|
id,
|