@atlaskit/smart-card 32.7.8 → 32.7.9
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/analytics.spec.yaml +31 -5
- package/dist/cjs/extractors/action/extract-invoke-preview-action.js +7 -6
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +5 -1
- package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +2 -7
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +99 -6
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +0 -1
- package/dist/cjs/view/CardWithUrl/loader.js +14 -5
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +88 -32
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -2
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +0 -1
- package/dist/cjs/view/HoverCard/index.js +15 -8
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/action/extract-invoke-preview-action.js +8 -7
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -1
- package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +0 -3
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +97 -2
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +0 -1
- package/dist/es2019/view/CardWithUrl/loader.js +9 -1
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +88 -32
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -1
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +0 -1
- package/dist/es2019/view/HoverCard/index.js +10 -2
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/action/extract-invoke-preview-action.js +8 -7
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +5 -1
- package/dist/esm/utils/analytics/LinkAnalyticsContext.js +2 -7
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +95 -5
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +0 -1
- package/dist/esm/view/CardWithUrl/loader.js +14 -5
- package/dist/esm/view/EmbedModal/components/analytics/index.js +88 -32
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -1
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +0 -1
- package/dist/esm/view/HoverCard/index.js +14 -4
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/common/analytics/generated/analytics.types.d.ts +16 -2
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -0
- package/dist/types/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +16 -2
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
- package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
- package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +1 -0
- package/dist/types-ts4.5/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.StandaloneHoverCard = exports.HoverCard = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _react2 = require("@emotion/react");
|
|
9
11
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
@@ -15,14 +17,13 @@ var _constants = require("../../constants");
|
|
|
15
17
|
var _state = require("../../state");
|
|
16
18
|
var _analytics = require("../../state/analytics");
|
|
17
19
|
var _modal = require("../../state/modal");
|
|
20
|
+
var _SmartLinkAnalyticsContext = require("../../utils/analytics/SmartLinkAnalyticsContext");
|
|
18
21
|
var _HoverCardComponent = require("./components/HoverCardComponent");
|
|
19
|
-
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
20
24
|
* @jsxRuntime classic
|
|
21
25
|
* @jsx jsx
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
|
-
|
|
26
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
27
|
var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
27
28
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
|
|
28
29
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
@@ -30,17 +31,23 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
|
30
31
|
id = props.id,
|
|
31
32
|
children = props.children;
|
|
32
33
|
var analytics = (0, _state.useSmartLinkAnalytics)(url, id);
|
|
34
|
+
var analyticsContext = (0, _SmartLinkAnalyticsContext.useSmartLinkAnalyticsContext)({
|
|
35
|
+
display: _constants.CardDisplay.HoverCardPreview,
|
|
36
|
+
id: id,
|
|
37
|
+
source: _HoverCardComponent.HOVER_CARD_SOURCE,
|
|
38
|
+
url: url
|
|
39
|
+
});
|
|
33
40
|
var onError = (0, _react.useCallback)(function (error, info) {
|
|
34
41
|
if ((0, _platformFeatureFlags.fg)('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
35
42
|
(0, _analytics.startUfoExperience)('smart-link-rendered', id || 'NULL');
|
|
36
43
|
(0, _analytics.failUfoExperience)('smart-link-rendered', id || 'NULL');
|
|
37
44
|
(0, _analytics.failUfoExperience)('smart-link-authenticated', id || 'NULL');
|
|
38
|
-
fireEvent('ui.smartLink.renderFailed', {
|
|
45
|
+
fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
|
|
39
46
|
display: _constants.CardDisplay.HoverCardPreview,
|
|
40
47
|
id: id !== null && id !== void 0 ? id : null,
|
|
41
48
|
error: error,
|
|
42
49
|
errorInfo: info
|
|
43
|
-
});
|
|
50
|
+
}));
|
|
44
51
|
} else {
|
|
45
52
|
analytics.ui.renderFailedEvent({
|
|
46
53
|
display: _constants.CardDisplay.HoverCardPreview,
|
|
@@ -49,7 +56,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
|
49
56
|
errorInfo: info
|
|
50
57
|
});
|
|
51
58
|
}
|
|
52
|
-
}, [analytics.ui, id, fireEvent]);
|
|
59
|
+
}, [analytics.ui, analyticsContext, id, fireEvent]);
|
|
53
60
|
return (0, _react2.jsx)(_reactErrorBoundary.ErrorBoundary, {
|
|
54
61
|
fallback: children,
|
|
55
62
|
onError: onError
|
|
@@ -20,7 +20,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
20
20
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
21
21
|
var PACKAGE_DATA = {
|
|
22
22
|
packageName: "@atlaskit/smart-card",
|
|
23
|
-
packageVersion: "32.7.
|
|
23
|
+
packageVersion: "32.7.9",
|
|
24
24
|
componentName: 'linkUrl'
|
|
25
25
|
};
|
|
26
26
|
var Anchor = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extractLink, extractPreview as extractPreviewData, extractProvider, extractTitle } from '@atlaskit/link-extractors';
|
|
2
2
|
import { ActionName, CardAction } from '../../index';
|
|
3
|
-
import {
|
|
3
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
4
4
|
import { canShowAction } from '../../utils/actions/can-show-action';
|
|
5
5
|
import { openEmbedModal } from '../../view/EmbedModal/utils';
|
|
6
6
|
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
@@ -27,12 +27,16 @@ export const extractInvokePreviewAction = param => {
|
|
|
27
27
|
const src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
28
28
|
if (src) {
|
|
29
29
|
const url = extractLink(data);
|
|
30
|
+
const extensionKey = getExtensionKey(response);
|
|
30
31
|
return {
|
|
31
32
|
actionFn: async () => {
|
|
32
33
|
var _extractProvider;
|
|
33
34
|
return openEmbedModal({
|
|
34
35
|
fireEvent,
|
|
36
|
+
extensionKey,
|
|
37
|
+
id,
|
|
35
38
|
invokeDownloadAction: extractInvokeDownloadAction(param),
|
|
39
|
+
invokeViewAction: extractInvokeViewAction(param, true),
|
|
36
40
|
isSupportTheming: extractIsSupportTheming(meta),
|
|
37
41
|
isTrusted: extractIsTrusted(meta),
|
|
38
42
|
linkIcon: extractLinkIcon(response),
|
|
@@ -41,17 +45,14 @@ export const extractInvokePreviewAction = param => {
|
|
|
41
45
|
origin,
|
|
42
46
|
src,
|
|
43
47
|
title: extractTitle(data),
|
|
44
|
-
url
|
|
45
|
-
invokeViewAction: extractInvokeViewAction(param, true)
|
|
48
|
+
url
|
|
46
49
|
});
|
|
47
50
|
},
|
|
48
51
|
actionSubjectId: 'invokePreviewScreen',
|
|
49
52
|
actionType: ActionName.PreviewAction,
|
|
50
|
-
definitionId: getDefinitionId(response),
|
|
51
53
|
display,
|
|
52
|
-
extensionKey
|
|
53
|
-
id
|
|
54
|
-
resourceType: getResourceType(response)
|
|
54
|
+
extensionKey,
|
|
55
|
+
id
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
};
|
|
@@ -60,6 +60,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
60
60
|
* This fires an event that represents when a user
|
|
61
61
|
* click a button.
|
|
62
62
|
* @param data A partial analytics event payload
|
|
63
|
+
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
63
64
|
*/
|
|
64
65
|
buttonClickedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
65
66
|
action: 'clicked',
|
|
@@ -107,6 +108,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
107
108
|
/**
|
|
108
109
|
* This fires an event that represents when a user close a modal.
|
|
109
110
|
* @param data A partial analytics event payload
|
|
111
|
+
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
110
112
|
*/
|
|
111
113
|
modalClosedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
112
114
|
action: 'closed',
|
|
@@ -126,6 +128,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
126
128
|
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
127
129
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
128
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
|
|
129
132
|
*/
|
|
130
133
|
renderSuccessEvent: ({
|
|
131
134
|
display,
|
|
@@ -167,6 +170,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
167
170
|
* @param id The unique ID for this Smart Link.
|
|
168
171
|
* @param error: An error representing why the Smart Link render failed.
|
|
169
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
|
|
170
174
|
*/
|
|
171
175
|
renderFailedEvent: ({
|
|
172
176
|
display,
|
|
@@ -271,7 +275,7 @@ export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
|
|
|
271
275
|
const screen = useMemo(() => ({
|
|
272
276
|
/**
|
|
273
277
|
* This fires an event that represents when a user view a modal.
|
|
274
|
-
* @
|
|
278
|
+
* @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
|
|
275
279
|
*/
|
|
276
280
|
modalViewedEvent: data => dispatchAnalytics(applyCommonAttributes({
|
|
277
281
|
action: 'viewed',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { context } from './analytics';
|
|
5
3
|
/**
|
|
6
4
|
* Provides an analytics context to supply attributes to events based on a URL
|
|
7
5
|
*/
|
|
@@ -16,7 +14,6 @@ export const LinkAnalyticsContext = ({
|
|
|
16
14
|
data: {
|
|
17
15
|
source,
|
|
18
16
|
attributes: {
|
|
19
|
-
...(fg('platform-smart-card-migrate-embed-modal-analytics') ? context : {}),
|
|
20
17
|
displayCategory,
|
|
21
18
|
display,
|
|
22
19
|
id
|
|
@@ -1,14 +1,101 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
4
4
|
import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
|
|
5
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
6
|
+
import { getUrl } from '@atlaskit/linking-common';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
8
|
import { useSmartCardState as useSmartLinkState } from '../../state/store';
|
|
9
|
+
import { context } from './analytics';
|
|
6
10
|
import { LinkAnalyticsContext } from './LinkAnalyticsContext';
|
|
11
|
+
const getExtendedResolvedAttributes = (linkDetails, details, linkStatus) => {
|
|
12
|
+
var _details$meta$definit, _details$meta, _details$meta$resourc, _details$meta2;
|
|
13
|
+
return {
|
|
14
|
+
definitionId: (_details$meta$definit = details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId) !== null && _details$meta$definit !== void 0 ? _details$meta$definit : null,
|
|
15
|
+
resourceType: (_details$meta$resourc = details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.resourceType) !== null && _details$meta$resourc !== void 0 ? _details$meta$resourc : null,
|
|
16
|
+
...getResolvedAttributes(linkDetails, details, linkStatus)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const getSmartLinkAnalyticsContext = ({
|
|
20
|
+
display,
|
|
21
|
+
id,
|
|
22
|
+
response,
|
|
23
|
+
source,
|
|
24
|
+
status,
|
|
25
|
+
url
|
|
26
|
+
}) => {
|
|
27
|
+
const resolvedAttributes = getExtendedResolvedAttributes({
|
|
28
|
+
url
|
|
29
|
+
}, response, status);
|
|
30
|
+
return {
|
|
31
|
+
source,
|
|
32
|
+
attributes: {
|
|
33
|
+
...context,
|
|
34
|
+
display,
|
|
35
|
+
id,
|
|
36
|
+
...resolvedAttributes
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Provides an analytics context data to supply attributes to events based on a URL
|
|
42
|
+
* and the link state in the store
|
|
43
|
+
*/
|
|
44
|
+
export const useSmartLinkAnalyticsContext = ({
|
|
45
|
+
display,
|
|
46
|
+
id,
|
|
47
|
+
source,
|
|
48
|
+
url
|
|
49
|
+
}) => {
|
|
50
|
+
const {
|
|
51
|
+
store
|
|
52
|
+
} = useSmartLinkContext();
|
|
53
|
+
const state = store ? getUrl(store, url) : undefined;
|
|
54
|
+
return useMemo(() => {
|
|
55
|
+
return fg('platform-smart-card-migrate-embed-modal-analytics') ? getSmartLinkAnalyticsContext({
|
|
56
|
+
display,
|
|
57
|
+
id,
|
|
58
|
+
response: state === null || state === void 0 ? void 0 : state.details,
|
|
59
|
+
source,
|
|
60
|
+
status: state === null || state === void 0 ? void 0 : state.status,
|
|
61
|
+
url
|
|
62
|
+
}) : {};
|
|
63
|
+
}, [display, id, source, state === null || state === void 0 ? void 0 : state.details, state === null || state === void 0 ? void 0 : state.status, url]);
|
|
64
|
+
};
|
|
65
|
+
|
|
7
66
|
/**
|
|
8
67
|
* Provides an analytics context to supply attributes to events based on a URL
|
|
9
68
|
* and the link state in the store
|
|
10
69
|
*/
|
|
11
|
-
|
|
70
|
+
const ExtendedSmartLinkAnalyticsContext = ({
|
|
71
|
+
children,
|
|
72
|
+
display,
|
|
73
|
+
id,
|
|
74
|
+
source,
|
|
75
|
+
url
|
|
76
|
+
}) => {
|
|
77
|
+
const {
|
|
78
|
+
details,
|
|
79
|
+
status
|
|
80
|
+
} = useSmartLinkState(url);
|
|
81
|
+
const data = getSmartLinkAnalyticsContext({
|
|
82
|
+
display,
|
|
83
|
+
id,
|
|
84
|
+
response: details,
|
|
85
|
+
source,
|
|
86
|
+
status,
|
|
87
|
+
url
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
90
|
+
data: data
|
|
91
|
+
}, 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 => {
|
|
12
99
|
const {
|
|
13
100
|
children,
|
|
14
101
|
url,
|
|
@@ -28,4 +115,12 @@ export const SmartLinkAnalyticsContext = props => {
|
|
|
28
115
|
attributes
|
|
29
116
|
}
|
|
30
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);
|
|
31
126
|
};
|
|
@@ -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: "32.7.
|
|
6
|
+
packageVersion: "32.7.9"
|
|
7
7
|
};
|
|
8
8
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
9
9
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -151,7 +151,6 @@ function Component({
|
|
|
151
151
|
display: isFlexibleUi ? 'flexible' : appearance
|
|
152
152
|
});
|
|
153
153
|
fireEvent('ui.smartLink.renderSuccess', {
|
|
154
|
-
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
155
154
|
display: isFlexibleUi ? 'flexible' : appearance
|
|
156
155
|
});
|
|
157
156
|
} else {
|
|
@@ -7,6 +7,7 @@ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analyti
|
|
|
7
7
|
import { useSmartLinkAnalytics } from '../../state';
|
|
8
8
|
import { failUfoExperience, startUfoExperience } from '../../state/analytics';
|
|
9
9
|
import { importWithRetry } from '../../utils';
|
|
10
|
+
import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
10
11
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
11
12
|
import { clearMarks, clearMeasures } from '../../utils/performance';
|
|
12
13
|
import { LoadingCardLink } from './component-lazy/LoadingCardLink';
|
|
@@ -53,6 +54,11 @@ export function CardWithURLRenderer(props) {
|
|
|
53
54
|
} = props;
|
|
54
55
|
const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
|
|
55
56
|
const isFlexibleUi = isFlexibleUiCard(children);
|
|
57
|
+
const analyticsContext = useSmartLinkAnalyticsContext({
|
|
58
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
59
|
+
id,
|
|
60
|
+
url: url !== null && url !== void 0 ? url : ''
|
|
61
|
+
});
|
|
56
62
|
const errorHandler = useCallback((error, info) => {
|
|
57
63
|
const {
|
|
58
64
|
componentStack
|
|
@@ -67,6 +73,7 @@ export function CardWithURLRenderer(props) {
|
|
|
67
73
|
// Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
|
|
68
74
|
if (error.name === 'ChunkLoadError') {
|
|
69
75
|
fireEvent('operational.smartLink.chunkLoadFailed', {
|
|
76
|
+
...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
|
|
70
77
|
display: appearance,
|
|
71
78
|
error: error,
|
|
72
79
|
errorInfo: errorInfo,
|
|
@@ -78,6 +85,7 @@ export function CardWithURLRenderer(props) {
|
|
|
78
85
|
failUfoExperience('smart-link-rendered', id || 'NULL');
|
|
79
86
|
failUfoExperience('smart-link-authenticated', id || 'NULL');
|
|
80
87
|
fireEvent('ui.smartLink.renderFailed', {
|
|
88
|
+
...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
|
|
81
89
|
display: isFlexibleUi ? 'flexible' : appearance,
|
|
82
90
|
id: id !== null && id !== void 0 ? id : null,
|
|
83
91
|
error: error,
|
|
@@ -97,7 +105,7 @@ export function CardWithURLRenderer(props) {
|
|
|
97
105
|
url: url !== null && url !== void 0 ? url : '',
|
|
98
106
|
err: error
|
|
99
107
|
});
|
|
100
|
-
}, [analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
|
|
108
|
+
}, [analytics.ui, analyticsContext, appearance, id, onError, url, isFlexibleUi, fireEvent]);
|
|
101
109
|
if (!url) {
|
|
102
110
|
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
103
111
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { CardDisplay } from '../../../../constants';
|
|
5
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../../../state/analytics';
|
|
4
6
|
import { EmbedModalSize } from '../../types';
|
|
5
7
|
const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
6
8
|
const withAnalytics = Component => props => {
|
|
7
9
|
const {
|
|
8
10
|
analytics,
|
|
11
|
+
fireEvent,
|
|
12
|
+
extensionKey,
|
|
13
|
+
id,
|
|
9
14
|
onClose,
|
|
10
15
|
onOpen,
|
|
11
16
|
onOpenFailed,
|
|
@@ -13,57 +18,108 @@ const withAnalytics = Component => props => {
|
|
|
13
18
|
origin
|
|
14
19
|
} = props;
|
|
15
20
|
const handleOnOpen = useCallback(context => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
origin,
|
|
21
|
+
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
22
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('screen.embedPreviewModal.viewed', {
|
|
23
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
20
24
|
size: context.size
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.screen.modalViewedEvent({
|
|
28
|
+
name: 'embedPreviewModal',
|
|
29
|
+
attributes: {
|
|
30
|
+
origin,
|
|
31
|
+
size: context.size
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
36
|
+
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
37
|
+
extensionKey,
|
|
38
|
+
display: CardDisplay.EmbedPreview
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
42
|
+
succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
|
|
43
|
+
display: CardDisplay.EmbedPreview
|
|
44
|
+
});
|
|
45
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderSuccess', {
|
|
46
|
+
display: CardDisplay.EmbedPreview
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
|
|
50
|
+
status: 'resolved',
|
|
51
|
+
display: CardDisplay.EmbedPreview
|
|
52
|
+
});
|
|
53
|
+
}
|
|
27
54
|
if (onOpen) {
|
|
28
55
|
onOpen(context);
|
|
29
56
|
}
|
|
30
|
-
}, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpen, origin]);
|
|
57
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, extensionKey, id, onOpen, origin]);
|
|
31
58
|
const handleOnOpenFailed = useCallback((error, errorInfo) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
59
|
+
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
60
|
+
startUfoExperience('smart-link-rendered', id || 'NULL');
|
|
61
|
+
failUfoExperience('smart-link-rendered', id || 'NULL');
|
|
62
|
+
failUfoExperience('smart-link-authenticated', id || 'NULL');
|
|
63
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderFailed', {
|
|
64
|
+
display: CardDisplay.EmbedPreview,
|
|
65
|
+
error: error,
|
|
66
|
+
errorInfo: errorInfo,
|
|
67
|
+
id: id !== null && id !== void 0 ? id : null
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
|
|
71
|
+
display: CardDisplay.EmbedPreview,
|
|
72
|
+
error,
|
|
73
|
+
errorInfo
|
|
74
|
+
});
|
|
75
|
+
}
|
|
37
76
|
if (onOpenFailed) {
|
|
38
77
|
onOpenFailed(error, errorInfo);
|
|
39
78
|
}
|
|
40
|
-
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpenFailed]);
|
|
79
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, id, onOpenFailed]);
|
|
41
80
|
const handleOnClose = useCallback(context => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
origin,
|
|
46
|
-
previewTime: context.duration,
|
|
81
|
+
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
82
|
+
var _context$duration;
|
|
83
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.modal.closed.embedPreview', {
|
|
84
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
85
|
+
previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
|
|
47
86
|
size: context.size
|
|
48
|
-
}
|
|
49
|
-
}
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
|
|
90
|
+
actionSubjectId: 'embedPreview',
|
|
91
|
+
attributes: {
|
|
92
|
+
origin,
|
|
93
|
+
previewTime: context.duration,
|
|
94
|
+
size: context.size
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
50
98
|
if (onClose) {
|
|
51
99
|
onClose(context);
|
|
52
100
|
}
|
|
53
|
-
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onClose, origin]);
|
|
101
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onClose, origin]);
|
|
54
102
|
const handleOnResize = useCallback(context => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
attributes: {
|
|
103
|
+
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
104
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.button.clicked.embedPreviewResize', {
|
|
58
105
|
newSize: context.size,
|
|
59
|
-
origin,
|
|
106
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
60
107
|
previousSize: getResizeFrom(context.size)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
|
|
111
|
+
actionSubjectId: 'embedPreviewResize',
|
|
112
|
+
attributes: {
|
|
113
|
+
newSize: context.size,
|
|
114
|
+
origin,
|
|
115
|
+
previousSize: getResizeFrom(context.size)
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
63
119
|
if (onResize) {
|
|
64
120
|
onResize(context);
|
|
65
121
|
}
|
|
66
|
-
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onResize, origin]);
|
|
122
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onResize, origin]);
|
|
67
123
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
68
124
|
onClose: handleOnClose,
|
|
69
125
|
onOpen: handleOnOpen,
|
|
@@ -17,7 +17,7 @@ import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAna
|
|
|
17
17
|
import CustomPopupContainer from '../components/CustomPopupContainer';
|
|
18
18
|
import HoverCardContent from '../components/HoverCardContent';
|
|
19
19
|
import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
|
|
20
|
-
const HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
|
|
20
|
+
export const HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
|
|
21
21
|
const FADE_IN_DELAY = 500;
|
|
22
22
|
const FADE_OUT_DELAY = 300;
|
|
23
23
|
const RESOLVE_DELAY = 100;
|
|
@@ -40,7 +40,6 @@ const HoverCardResolvedView = ({
|
|
|
40
40
|
display: CardDisplay.HoverCardPreview
|
|
41
41
|
});
|
|
42
42
|
fireEvent('ui.smartLink.renderSuccess', {
|
|
43
|
-
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
44
43
|
display: CardDisplay.HoverCardPreview
|
|
45
44
|
});
|
|
46
45
|
} else {
|
|
@@ -15,7 +15,8 @@ import { CardDisplay } from '../../constants';
|
|
|
15
15
|
import { useSmartLinkAnalytics } from '../../state';
|
|
16
16
|
import { failUfoExperience, startUfoExperience } from '../../state/analytics';
|
|
17
17
|
import { SmartLinkModalProvider } from '../../state/modal';
|
|
18
|
-
import {
|
|
18
|
+
import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
19
|
+
import { HOVER_CARD_SOURCE, HoverCardComponent } from './components/HoverCardComponent';
|
|
19
20
|
const HoverCardWithErrorBoundary = props => {
|
|
20
21
|
const {
|
|
21
22
|
fireEvent
|
|
@@ -26,12 +27,19 @@ const HoverCardWithErrorBoundary = props => {
|
|
|
26
27
|
children
|
|
27
28
|
} = props;
|
|
28
29
|
const analytics = useSmartLinkAnalytics(url, id);
|
|
30
|
+
const analyticsContext = useSmartLinkAnalyticsContext({
|
|
31
|
+
display: CardDisplay.HoverCardPreview,
|
|
32
|
+
id,
|
|
33
|
+
source: HOVER_CARD_SOURCE,
|
|
34
|
+
url
|
|
35
|
+
});
|
|
29
36
|
const onError = useCallback((error, info) => {
|
|
30
37
|
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
31
38
|
startUfoExperience('smart-link-rendered', id || 'NULL');
|
|
32
39
|
failUfoExperience('smart-link-rendered', id || 'NULL');
|
|
33
40
|
failUfoExperience('smart-link-authenticated', id || 'NULL');
|
|
34
41
|
fireEvent('ui.smartLink.renderFailed', {
|
|
42
|
+
...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
|
|
35
43
|
display: CardDisplay.HoverCardPreview,
|
|
36
44
|
id: id !== null && id !== void 0 ? id : null,
|
|
37
45
|
error: error,
|
|
@@ -45,7 +53,7 @@ const HoverCardWithErrorBoundary = props => {
|
|
|
45
53
|
errorInfo: info
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
|
-
}, [analytics.ui, id, fireEvent]);
|
|
56
|
+
}, [analytics.ui, analyticsContext, id, fireEvent]);
|
|
49
57
|
return jsx(ErrorBoundary, {
|
|
50
58
|
fallback: children,
|
|
51
59
|
onError: onError
|
|
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
10
10
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
11
11
|
const PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "32.7.
|
|
13
|
+
packageVersion: "32.7.9",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { extractLink, extractPreview as extractPreviewData, extractProvider, extractTitle } from '@atlaskit/link-extractors';
|
|
4
4
|
import { ActionName, CardAction } from '../../index';
|
|
5
|
-
import {
|
|
5
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
6
6
|
import { canShowAction } from '../../utils/actions/can-show-action';
|
|
7
7
|
import { openEmbedModal } from '../../view/EmbedModal/utils';
|
|
8
8
|
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
@@ -27,6 +27,7 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
|
|
|
27
27
|
var src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
28
28
|
if (src) {
|
|
29
29
|
var url = extractLink(data);
|
|
30
|
+
var extensionKey = getExtensionKey(response);
|
|
30
31
|
return {
|
|
31
32
|
actionFn: function () {
|
|
32
33
|
var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -36,7 +37,10 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
|
|
|
36
37
|
case 0:
|
|
37
38
|
return _context.abrupt("return", openEmbedModal({
|
|
38
39
|
fireEvent: fireEvent,
|
|
40
|
+
extensionKey: extensionKey,
|
|
41
|
+
id: id,
|
|
39
42
|
invokeDownloadAction: extractInvokeDownloadAction(param),
|
|
43
|
+
invokeViewAction: extractInvokeViewAction(param, true),
|
|
40
44
|
isSupportTheming: extractIsSupportTheming(meta),
|
|
41
45
|
isTrusted: extractIsTrusted(meta),
|
|
42
46
|
linkIcon: extractLinkIcon(response),
|
|
@@ -45,8 +49,7 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
|
|
|
45
49
|
origin: origin,
|
|
46
50
|
src: src,
|
|
47
51
|
title: extractTitle(data),
|
|
48
|
-
url: url
|
|
49
|
-
invokeViewAction: extractInvokeViewAction(param, true)
|
|
52
|
+
url: url
|
|
50
53
|
}));
|
|
51
54
|
case 1:
|
|
52
55
|
case "end":
|
|
@@ -61,11 +64,9 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
|
|
|
61
64
|
}(),
|
|
62
65
|
actionSubjectId: 'invokePreviewScreen',
|
|
63
66
|
actionType: ActionName.PreviewAction,
|
|
64
|
-
definitionId: getDefinitionId(response),
|
|
65
67
|
display: display,
|
|
66
|
-
extensionKey:
|
|
67
|
-
id: id
|
|
68
|
-
resourceType: getResourceType(response)
|
|
68
|
+
extensionKey: extensionKey,
|
|
69
|
+
id: id
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
};
|