@atlaskit/smart-card 44.28.1 → 44.28.2
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/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/click-helpers.js +7 -1
- package/dist/cjs/view/CardWithUrl/component.js +7 -16
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +33 -11
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/click-helpers.js +6 -0
- package/dist/es2019/view/CardWithUrl/component.js +5 -14
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +29 -9
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/click-helpers.js +6 -0
- package/dist/esm/view/CardWithUrl/component.js +5 -14
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +35 -13
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/utils/click-helpers.d.ts +1 -0
- package/dist/types-ts4.5/utils/click-helpers.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 44.28.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`85a6df19d005b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/85a6df19d005b) -
|
|
8
|
+
Update anchor href with cross-product analytics params on middle-click and context menu for
|
|
9
|
+
HoverCard.
|
|
10
|
+
|
|
3
11
|
## 44.28.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
11
11
|
var context = exports.context = {
|
|
12
12
|
componentName: 'smart-cards',
|
|
13
13
|
packageName: "@atlaskit/smart-card" || '',
|
|
14
|
-
packageVersion: "44.28.
|
|
14
|
+
packageVersion: "44.28.1" || ''
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isAuxClick = exports.getAnchorAttributesFromEvent = void 0;
|
|
6
|
+
exports.updateAnchorHref = exports.isAuxClick = exports.getAnchorAttributesFromEvent = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Returns true for genuine middle-clicks (button === 1).
|
|
9
9
|
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
@@ -40,4 +40,10 @@ var getAnchorAttributesFromEvent = exports.getAnchorAttributesFromEvent = functi
|
|
|
40
40
|
href: currentTarget.href,
|
|
41
41
|
target: currentTarget.target || '_self'
|
|
42
42
|
};
|
|
43
|
+
};
|
|
44
|
+
var updateAnchorHref = exports.updateAnchorHref = function updateAnchorHref(event, href) {
|
|
45
|
+
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
event.currentTarget.href = href;
|
|
43
49
|
};
|
|
@@ -114,19 +114,10 @@ function Component(_ref) {
|
|
|
114
114
|
var shouldFire3PClickEvent = thirdPartyARI && thirdPartyARI.startsWith(thirdPartyARIPrefix) && (0, _helpers.getClickUrl)(url, state.details) === url && fire3PClickEvent && (0, _platformFeatureFlags.fg)('platform_smartlink_3pclick_analytics');
|
|
115
115
|
var getDestinationUrl = (0, _react.useCallback)(function () {
|
|
116
116
|
var _getClickUrl, _appendCrossProductAn;
|
|
117
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
117
118
|
var preferredUrl = (_getClickUrl = (0, _helpers.getClickUrl)(url, state.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
118
119
|
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
119
120
|
}, [appendCrossProductAnalyticsParams, state.details, url]);
|
|
120
|
-
var updateAnchorHref = (0, _react.useCallback)(function (event, destinationUrl) {
|
|
121
|
-
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
126
|
-
// href is only defined when currentTarget is an anchor element.
|
|
127
|
-
// Update the anchor href so the browser context menu uses the decorated URL.
|
|
128
|
-
event.currentTarget.href = destinationUrl;
|
|
129
|
-
}, []);
|
|
130
121
|
|
|
131
122
|
// Setup UI handlers.
|
|
132
123
|
var handleClickWrapper = (0, _react.useCallback)(function (event) {
|
|
@@ -178,7 +169,7 @@ function Component(_ref) {
|
|
|
178
169
|
return;
|
|
179
170
|
}
|
|
180
171
|
var destinationUrl = getDestinationUrl();
|
|
181
|
-
updateAnchorHref(event, destinationUrl);
|
|
172
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
182
173
|
|
|
183
174
|
// For FlexibleCard, read target from the clicked anchor element (e.g. _blank for links
|
|
184
175
|
// rendered with explicit target). For classic cards, default to _self
|
|
@@ -256,7 +247,7 @@ function Component(_ref) {
|
|
|
256
247
|
(0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
|
|
257
248
|
}
|
|
258
249
|
}
|
|
259
|
-
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url,
|
|
250
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
|
|
260
251
|
|
|
261
252
|
// Exposure fires once per eligible mount; click-time reads use no-exposure variant.
|
|
262
253
|
(0, _react.useEffect)(function () {
|
|
@@ -270,7 +261,7 @@ function Component(_ref) {
|
|
|
270
261
|
var handleFrameAuxClick = (0, _react.useCallback)(function (event) {
|
|
271
262
|
if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
|
|
272
263
|
var destinationUrl = getDestinationUrl();
|
|
273
|
-
updateAnchorHref(event, destinationUrl);
|
|
264
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
274
265
|
}
|
|
275
266
|
|
|
276
267
|
// isAuxClick filters Windows right-clicks (button === 2) that also fire onAuxClick.
|
|
@@ -279,21 +270,21 @@ function Component(_ref) {
|
|
|
279
270
|
isAuxClick: true
|
|
280
271
|
});
|
|
281
272
|
}
|
|
282
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
273
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
283
274
|
|
|
284
275
|
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
285
276
|
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
286
277
|
var handleFrameContextMenu = (0, _react.useCallback)(function (event) {
|
|
287
278
|
if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
|
|
288
279
|
var destinationUrl = getDestinationUrl();
|
|
289
|
-
updateAnchorHref(event, destinationUrl);
|
|
280
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
290
281
|
}
|
|
291
282
|
if (shouldFire3PClickEvent && (0, _expValEqualsNoExposure.expValEqualsNoExposure)(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
292
283
|
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent({
|
|
293
284
|
isContextMenu: true
|
|
294
285
|
});
|
|
295
286
|
}
|
|
296
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
287
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
297
288
|
var reload = actions.reload;
|
|
298
289
|
var handleAuthorize = (0, _react.useCallback)(function () {
|
|
299
290
|
return actions.authorize(appearance);
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.hoverCardClassName = exports.default = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
12
13
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
@@ -34,6 +35,8 @@ var _resolving = _interopRequireDefault(require("./views/resolving"));
|
|
|
34
35
|
var _unauthorised = _interopRequireDefault(require("./views/unauthorised"));
|
|
35
36
|
var _RovoUnauthorisedView = _interopRequireDefault(require("./views/unauthorised/RovoUnauthorisedView"));
|
|
36
37
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
38
|
+
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; }
|
|
39
|
+
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; }
|
|
37
40
|
var hoverCardClassName = exports.hoverCardClassName = 'smart-links-hover-preview';
|
|
38
41
|
var useIsResolvedView = function useIsResolvedView(_ref) {
|
|
39
42
|
var _hoverPreviewOptions$;
|
|
@@ -137,23 +140,38 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
137
140
|
});
|
|
138
141
|
};
|
|
139
142
|
}, []);
|
|
143
|
+
var getDestinationUrl = (0, _react.useCallback)(function () {
|
|
144
|
+
var _getClickUrl, _appendCrossProductAn;
|
|
145
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
146
|
+
var preferredUrl = (_getClickUrl = (0, _helpers.getClickUrl)(url, linkState.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
147
|
+
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
148
|
+
}, [appendCrossProductAnalyticsParams, linkState.details, url]);
|
|
149
|
+
|
|
150
|
+
// Middle-click handler to trigger fire3PClickEvent on middle-clicks.
|
|
151
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
152
|
+
var onAuxClick = (0, _react.useCallback)(function (event) {
|
|
153
|
+
var destinationUrl = getDestinationUrl();
|
|
154
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
155
|
+
}, [getDestinationUrl]);
|
|
156
|
+
|
|
157
|
+
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
158
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
159
|
+
var onContextMenu = (0, _react.useCallback)(function (event) {
|
|
160
|
+
var destinationUrl = getDestinationUrl();
|
|
161
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
162
|
+
}, [getDestinationUrl]);
|
|
140
163
|
var onClick = (0, _react.useCallback)(function (event) {
|
|
141
164
|
if ((0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping')) {
|
|
142
165
|
// Prevent the anchor's native navigation so we can open the destination URL
|
|
143
166
|
// with cross-product analytics query parameters appended.
|
|
144
|
-
// The href is read from the anchor element at click time rather than at render
|
|
145
|
-
// time because the URL for the anchor may be different from original URL.
|
|
146
|
-
// The component may use the URL from the resolved response which can be a redirect URL
|
|
147
|
-
// or other preferred URL based on link extractor.
|
|
148
167
|
// The cross-product params are client-only and cannot be rendered
|
|
149
168
|
// server-side. Falls back to the original `url` prop if the event target is
|
|
150
169
|
// not an anchor element.
|
|
151
170
|
event.preventDefault();
|
|
152
171
|
var _getAnchorAttributesF = (0, _clickHelpers.getAnchorAttributesFromEvent)(event),
|
|
153
|
-
_getAnchorAttributesF2 = _getAnchorAttributesF.href,
|
|
154
|
-
href = _getAnchorAttributesF2 === void 0 ? url : _getAnchorAttributesF2,
|
|
155
172
|
target = _getAnchorAttributesF.target;
|
|
156
|
-
var destinationUrl =
|
|
173
|
+
var destinationUrl = getDestinationUrl();
|
|
174
|
+
(0, _clickHelpers.updateAnchorHref)(event, destinationUrl);
|
|
157
175
|
window.open(destinationUrl, target);
|
|
158
176
|
}
|
|
159
177
|
var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
|
|
@@ -164,7 +182,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
164
182
|
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
|
|
165
183
|
});
|
|
166
184
|
(0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
|
|
167
|
-
}, [createAnalyticsEvent,
|
|
185
|
+
}, [createAnalyticsEvent, getDestinationUrl, id, fireEvent, definitionId]);
|
|
168
186
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
169
187
|
var _getMetadata = (0, _utils2.getMetadata)(extensionKey, data),
|
|
170
188
|
subtitle = _getMetadata.subtitle;
|
|
@@ -178,10 +196,14 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
178
196
|
};
|
|
179
197
|
var uiOptions = _styled.flexibleUiOptions;
|
|
180
198
|
uiOptions.enableSnippetRenderer = true;
|
|
181
|
-
var flexibleCardProps = {
|
|
199
|
+
var flexibleCardProps = _objectSpread(_objectSpread({
|
|
182
200
|
appearance: _constants.CardDisplay.HoverCardPreview,
|
|
183
201
|
cardState: cardState,
|
|
184
|
-
onClick: onClick
|
|
202
|
+
onClick: onClick
|
|
203
|
+
}, (0, _platformFeatureFlags.fg)('platform_smartlink_xpc_url_wrapping') ? {
|
|
204
|
+
onAuxClick: onAuxClick,
|
|
205
|
+
onContextMenu: onContextMenu
|
|
206
|
+
} : undefined), {}, {
|
|
185
207
|
onResolve: onResolve,
|
|
186
208
|
origin: 'smartLinkPreviewHoverCard',
|
|
187
209
|
renderers: renderers,
|
|
@@ -189,7 +211,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
189
211
|
ui: uiOptions,
|
|
190
212
|
url: url,
|
|
191
213
|
children: null
|
|
192
|
-
};
|
|
214
|
+
});
|
|
193
215
|
var onClickStopPropagation = (0, _react.useCallback)(function (e) {
|
|
194
216
|
return e.stopPropagation();
|
|
195
217
|
}, []);
|
|
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
19
19
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
20
20
|
var PACKAGE_DATA = {
|
|
21
21
|
packageName: "@atlaskit/smart-card",
|
|
22
|
-
packageVersion: "44.28.
|
|
22
|
+
packageVersion: "44.28.1",
|
|
23
23
|
componentName: 'linkUrl'
|
|
24
24
|
};
|
|
25
25
|
var LinkUrl = function LinkUrl(_ref) {
|
|
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
2
2
|
export const context = {
|
|
3
3
|
componentName: 'smart-cards',
|
|
4
4
|
packageName: "@atlaskit/smart-card" || '',
|
|
5
|
-
packageVersion: "44.28.
|
|
5
|
+
packageVersion: "44.28.1" || ''
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -34,4 +34,10 @@ export const getAnchorAttributesFromEvent = event => {
|
|
|
34
34
|
href: currentTarget.href,
|
|
35
35
|
target: currentTarget.target || '_self'
|
|
36
36
|
};
|
|
37
|
+
};
|
|
38
|
+
export const updateAnchorHref = (event, href) => {
|
|
39
|
+
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
event.currentTarget.href = href;
|
|
37
43
|
};
|
|
@@ -16,7 +16,7 @@ import { isSpecialClick, isSpecialEvent, isSpecialKey } from '../../utils';
|
|
|
16
16
|
import { combineActionOptions } from '../../utils/actions/combine-action-options';
|
|
17
17
|
import { fireLinkClickedEvent } from '../../utils/analytics/click';
|
|
18
18
|
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
19
|
-
import { getAnchorAttributesFromEvent, isAuxClick } from '../../utils/click-helpers';
|
|
19
|
+
import { getAnchorAttributesFromEvent, isAuxClick, updateAnchorHref } from '../../utils/click-helpers';
|
|
20
20
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
21
21
|
import * as measure from '../../utils/performance';
|
|
22
22
|
import { BlockCard } from '../BlockCard';
|
|
@@ -104,19 +104,10 @@ function Component({
|
|
|
104
104
|
const shouldFire3PClickEvent = thirdPartyARI && thirdPartyARI.startsWith(thirdPartyARIPrefix) && getClickUrl(url, state.details) === url && fire3PClickEvent && fg('platform_smartlink_3pclick_analytics');
|
|
105
105
|
const getDestinationUrl = useCallback(() => {
|
|
106
106
|
var _getClickUrl, _appendCrossProductAn;
|
|
107
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
107
108
|
const preferredUrl = (_getClickUrl = getClickUrl(url, state.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
108
109
|
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
109
110
|
}, [appendCrossProductAnalyticsParams, state.details, url]);
|
|
110
|
-
const updateAnchorHref = useCallback((event, destinationUrl) => {
|
|
111
|
-
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
116
|
-
// href is only defined when currentTarget is an anchor element.
|
|
117
|
-
// Update the anchor href so the browser context menu uses the decorated URL.
|
|
118
|
-
event.currentTarget.href = destinationUrl;
|
|
119
|
-
}, []);
|
|
120
111
|
|
|
121
112
|
// Setup UI handlers.
|
|
122
113
|
const handleClickWrapper = useCallback(event => {
|
|
@@ -247,7 +238,7 @@ function Component({
|
|
|
247
238
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
248
239
|
}
|
|
249
240
|
}
|
|
250
|
-
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url,
|
|
241
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
|
|
251
242
|
|
|
252
243
|
// Exposure fires once per eligible mount; click-time reads use no-exposure variant.
|
|
253
244
|
useEffect(() => {
|
|
@@ -270,7 +261,7 @@ function Component({
|
|
|
270
261
|
isAuxClick: true
|
|
271
262
|
});
|
|
272
263
|
}
|
|
273
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
264
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
274
265
|
|
|
275
266
|
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
276
267
|
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
@@ -284,7 +275,7 @@ function Component({
|
|
|
284
275
|
isContextMenu: true
|
|
285
276
|
});
|
|
286
277
|
}
|
|
287
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
278
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
288
279
|
const {
|
|
289
280
|
reload
|
|
290
281
|
} = actions;
|
|
@@ -9,14 +9,14 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
9
9
|
import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
|
|
10
10
|
import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
11
11
|
import extractRovoChatAction from '../../../extractors/flexible/actions/extract-rovo-chat-action';
|
|
12
|
-
import { getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
12
|
+
import { getClickUrl, getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
13
13
|
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
14
14
|
import { useSmartLinkCrossProductUrlWrapperGated } from '../../../state/hooks/use-smart-link-cross-product-url-wrapper';
|
|
15
15
|
import { useSmartCardState } from '../../../state/store';
|
|
16
16
|
import { isSpecialEvent } from '../../../utils';
|
|
17
17
|
import { getIsAISummaryEnabled } from '../../../utils/ai-summary';
|
|
18
18
|
import { fireLinkClickedEvent } from '../../../utils/analytics/click';
|
|
19
|
-
import { getAnchorAttributesFromEvent } from '../../../utils/click-helpers';
|
|
19
|
+
import { getAnchorAttributesFromEvent, updateAnchorHref } from '../../../utils/click-helpers';
|
|
20
20
|
import { flexibleUiOptions } from '../styled';
|
|
21
21
|
import { getMetadata } from '../utils';
|
|
22
22
|
import ContentContainer from './ContentContainer';
|
|
@@ -131,23 +131,39 @@ const HoverCardContent = ({
|
|
|
131
131
|
});
|
|
132
132
|
};
|
|
133
133
|
}, []);
|
|
134
|
+
const getDestinationUrl = useCallback(() => {
|
|
135
|
+
var _getClickUrl, _appendCrossProductAn;
|
|
136
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
137
|
+
const preferredUrl = (_getClickUrl = getClickUrl(url, linkState.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
138
|
+
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
139
|
+
}, [appendCrossProductAnalyticsParams, linkState.details, url]);
|
|
140
|
+
|
|
141
|
+
// Middle-click handler to trigger fire3PClickEvent on middle-clicks.
|
|
142
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
143
|
+
const onAuxClick = useCallback(event => {
|
|
144
|
+
const destinationUrl = getDestinationUrl();
|
|
145
|
+
updateAnchorHref(event, destinationUrl);
|
|
146
|
+
}, [getDestinationUrl]);
|
|
147
|
+
|
|
148
|
+
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
149
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
150
|
+
const onContextMenu = useCallback(event => {
|
|
151
|
+
const destinationUrl = getDestinationUrl();
|
|
152
|
+
updateAnchorHref(event, destinationUrl);
|
|
153
|
+
}, [getDestinationUrl]);
|
|
134
154
|
const onClick = useCallback(event => {
|
|
135
155
|
if (fg('platform_smartlink_xpc_url_wrapping')) {
|
|
136
156
|
// Prevent the anchor's native navigation so we can open the destination URL
|
|
137
157
|
// with cross-product analytics query parameters appended.
|
|
138
|
-
// The href is read from the anchor element at click time rather than at render
|
|
139
|
-
// time because the URL for the anchor may be different from original URL.
|
|
140
|
-
// The component may use the URL from the resolved response which can be a redirect URL
|
|
141
|
-
// or other preferred URL based on link extractor.
|
|
142
158
|
// The cross-product params are client-only and cannot be rendered
|
|
143
159
|
// server-side. Falls back to the original `url` prop if the event target is
|
|
144
160
|
// not an anchor element.
|
|
145
161
|
event.preventDefault();
|
|
146
162
|
const {
|
|
147
|
-
href = url,
|
|
148
163
|
target
|
|
149
164
|
} = getAnchorAttributesFromEvent(event);
|
|
150
|
-
const destinationUrl =
|
|
165
|
+
const destinationUrl = getDestinationUrl();
|
|
166
|
+
updateAnchorHref(event, destinationUrl);
|
|
151
167
|
window.open(destinationUrl, target);
|
|
152
168
|
}
|
|
153
169
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
@@ -158,7 +174,7 @@ const HoverCardContent = ({
|
|
|
158
174
|
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
|
|
159
175
|
});
|
|
160
176
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
161
|
-
}, [createAnalyticsEvent,
|
|
177
|
+
}, [createAnalyticsEvent, getDestinationUrl, id, fireEvent, definitionId]);
|
|
162
178
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
163
179
|
const {
|
|
164
180
|
subtitle
|
|
@@ -177,6 +193,10 @@ const HoverCardContent = ({
|
|
|
177
193
|
appearance: CardDisplay.HoverCardPreview,
|
|
178
194
|
cardState: cardState,
|
|
179
195
|
onClick: onClick,
|
|
196
|
+
...(fg('platform_smartlink_xpc_url_wrapping') ? {
|
|
197
|
+
onAuxClick,
|
|
198
|
+
onContextMenu
|
|
199
|
+
} : undefined),
|
|
180
200
|
onResolve: onResolve,
|
|
181
201
|
origin: 'smartLinkPreviewHoverCard',
|
|
182
202
|
renderers: renderers,
|
|
@@ -9,7 +9,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
9
9
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
10
10
|
const PACKAGE_DATA = {
|
|
11
11
|
packageName: "@atlaskit/smart-card",
|
|
12
|
-
packageVersion: "44.28.
|
|
12
|
+
packageVersion: "44.28.1",
|
|
13
13
|
componentName: 'linkUrl'
|
|
14
14
|
};
|
|
15
15
|
const LinkUrl = ({
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card" || '',
|
|
7
|
-
packageVersion: "44.28.
|
|
7
|
+
packageVersion: "44.28.1" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -34,4 +34,10 @@ export var getAnchorAttributesFromEvent = function getAnchorAttributesFromEvent(
|
|
|
34
34
|
href: currentTarget.href,
|
|
35
35
|
target: currentTarget.target || '_self'
|
|
36
36
|
};
|
|
37
|
+
};
|
|
38
|
+
export var updateAnchorHref = function updateAnchorHref(event, href) {
|
|
39
|
+
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
event.currentTarget.href = href;
|
|
37
43
|
};
|
|
@@ -19,7 +19,7 @@ import { isSpecialClick, isSpecialEvent, isSpecialKey } from '../../utils';
|
|
|
19
19
|
import { combineActionOptions } from '../../utils/actions/combine-action-options';
|
|
20
20
|
import { fireLinkClickedEvent } from '../../utils/analytics/click';
|
|
21
21
|
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
22
|
-
import { getAnchorAttributesFromEvent, isAuxClick } from '../../utils/click-helpers';
|
|
22
|
+
import { getAnchorAttributesFromEvent, isAuxClick, updateAnchorHref } from '../../utils/click-helpers';
|
|
23
23
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
24
24
|
import * as measure from '../../utils/performance';
|
|
25
25
|
import { BlockCard } from '../BlockCard';
|
|
@@ -105,19 +105,10 @@ function Component(_ref) {
|
|
|
105
105
|
var shouldFire3PClickEvent = thirdPartyARI && thirdPartyARI.startsWith(thirdPartyARIPrefix) && getClickUrl(url, state.details) === url && fire3PClickEvent && fg('platform_smartlink_3pclick_analytics');
|
|
106
106
|
var getDestinationUrl = useCallback(function () {
|
|
107
107
|
var _getClickUrl, _appendCrossProductAn;
|
|
108
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
108
109
|
var preferredUrl = (_getClickUrl = getClickUrl(url, state.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
109
110
|
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
110
111
|
}, [appendCrossProductAnalyticsParams, state.details, url]);
|
|
111
|
-
var updateAnchorHref = useCallback(function (event, destinationUrl) {
|
|
112
|
-
if (!(event.currentTarget instanceof HTMLAnchorElement)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
117
|
-
// href is only defined when currentTarget is an anchor element.
|
|
118
|
-
// Update the anchor href so the browser context menu uses the decorated URL.
|
|
119
|
-
event.currentTarget.href = destinationUrl;
|
|
120
|
-
}, []);
|
|
121
112
|
|
|
122
113
|
// Setup UI handlers.
|
|
123
114
|
var handleClickWrapper = useCallback(function (event) {
|
|
@@ -247,7 +238,7 @@ function Component(_ref) {
|
|
|
247
238
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
248
239
|
}
|
|
249
240
|
}
|
|
250
|
-
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url,
|
|
241
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, getDestinationUrl, onClick, url, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
|
|
251
242
|
|
|
252
243
|
// Exposure fires once per eligible mount; click-time reads use no-exposure variant.
|
|
253
244
|
useEffect(function () {
|
|
@@ -270,7 +261,7 @@ function Component(_ref) {
|
|
|
270
261
|
isAuxClick: true
|
|
271
262
|
});
|
|
272
263
|
}
|
|
273
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
264
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
274
265
|
|
|
275
266
|
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
276
267
|
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
@@ -284,7 +275,7 @@ function Component(_ref) {
|
|
|
284
275
|
isContextMenu: true
|
|
285
276
|
});
|
|
286
277
|
}
|
|
287
|
-
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent
|
|
278
|
+
}, [fire3PClickEvent, getDestinationUrl, shouldFire3PClickEvent]);
|
|
288
279
|
var reload = actions.reload;
|
|
289
280
|
var handleAuthorize = useCallback(function () {
|
|
290
281
|
return actions.authorize(appearance);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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) { _defineProperty(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; }
|
|
2
5
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
6
|
import { AnalyticsContext, useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
|
|
4
7
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
@@ -9,14 +12,14 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
9
12
|
import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
|
|
10
13
|
import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
11
14
|
import extractRovoChatAction from '../../../extractors/flexible/actions/extract-rovo-chat-action';
|
|
12
|
-
import { getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
15
|
+
import { getClickUrl, getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
13
16
|
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
14
17
|
import { useSmartLinkCrossProductUrlWrapperGated } from '../../../state/hooks/use-smart-link-cross-product-url-wrapper';
|
|
15
18
|
import { useSmartCardState } from '../../../state/store';
|
|
16
19
|
import { isSpecialEvent } from '../../../utils';
|
|
17
20
|
import { getIsAISummaryEnabled } from '../../../utils/ai-summary';
|
|
18
21
|
import { fireLinkClickedEvent } from '../../../utils/analytics/click';
|
|
19
|
-
import { getAnchorAttributesFromEvent } from '../../../utils/click-helpers';
|
|
22
|
+
import { getAnchorAttributesFromEvent, updateAnchorHref } from '../../../utils/click-helpers';
|
|
20
23
|
import { flexibleUiOptions } from '../styled';
|
|
21
24
|
import { getMetadata } from '../utils';
|
|
22
25
|
import ContentContainer from './ContentContainer';
|
|
@@ -128,23 +131,38 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
128
131
|
});
|
|
129
132
|
};
|
|
130
133
|
}, []);
|
|
134
|
+
var getDestinationUrl = useCallback(function () {
|
|
135
|
+
var _getClickUrl, _appendCrossProductAn;
|
|
136
|
+
// FIXME: destinationUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
137
|
+
var preferredUrl = (_getClickUrl = getClickUrl(url, linkState.details)) !== null && _getClickUrl !== void 0 ? _getClickUrl : url;
|
|
138
|
+
return (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
139
|
+
}, [appendCrossProductAnalyticsParams, linkState.details, url]);
|
|
140
|
+
|
|
141
|
+
// Middle-click handler to trigger fire3PClickEvent on middle-clicks.
|
|
142
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
143
|
+
var onAuxClick = useCallback(function (event) {
|
|
144
|
+
var destinationUrl = getDestinationUrl();
|
|
145
|
+
updateAnchorHref(event, destinationUrl);
|
|
146
|
+
}, [getDestinationUrl]);
|
|
147
|
+
|
|
148
|
+
// Right-click handler to trigger fire3PClickEvent on right-clicks.
|
|
149
|
+
// Scope is limited to 3P click analytics to keep the experiment focused.
|
|
150
|
+
var onContextMenu = useCallback(function (event) {
|
|
151
|
+
var destinationUrl = getDestinationUrl();
|
|
152
|
+
updateAnchorHref(event, destinationUrl);
|
|
153
|
+
}, [getDestinationUrl]);
|
|
131
154
|
var onClick = useCallback(function (event) {
|
|
132
155
|
if (fg('platform_smartlink_xpc_url_wrapping')) {
|
|
133
156
|
// Prevent the anchor's native navigation so we can open the destination URL
|
|
134
157
|
// with cross-product analytics query parameters appended.
|
|
135
|
-
// The href is read from the anchor element at click time rather than at render
|
|
136
|
-
// time because the URL for the anchor may be different from original URL.
|
|
137
|
-
// The component may use the URL from the resolved response which can be a redirect URL
|
|
138
|
-
// or other preferred URL based on link extractor.
|
|
139
158
|
// The cross-product params are client-only and cannot be rendered
|
|
140
159
|
// server-side. Falls back to the original `url` prop if the event target is
|
|
141
160
|
// not an anchor element.
|
|
142
161
|
event.preventDefault();
|
|
143
162
|
var _getAnchorAttributesF = getAnchorAttributesFromEvent(event),
|
|
144
|
-
_getAnchorAttributesF2 = _getAnchorAttributesF.href,
|
|
145
|
-
href = _getAnchorAttributesF2 === void 0 ? url : _getAnchorAttributesF2,
|
|
146
163
|
target = _getAnchorAttributesF.target;
|
|
147
|
-
var destinationUrl =
|
|
164
|
+
var destinationUrl = getDestinationUrl();
|
|
165
|
+
updateAnchorHref(event, destinationUrl);
|
|
148
166
|
window.open(destinationUrl, target);
|
|
149
167
|
}
|
|
150
168
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
@@ -155,7 +173,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
155
173
|
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
|
|
156
174
|
});
|
|
157
175
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
158
|
-
}, [createAnalyticsEvent,
|
|
176
|
+
}, [createAnalyticsEvent, getDestinationUrl, id, fireEvent, definitionId]);
|
|
159
177
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
160
178
|
var _getMetadata = getMetadata(extensionKey, data),
|
|
161
179
|
subtitle = _getMetadata.subtitle;
|
|
@@ -169,10 +187,14 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
169
187
|
};
|
|
170
188
|
var uiOptions = flexibleUiOptions;
|
|
171
189
|
uiOptions.enableSnippetRenderer = true;
|
|
172
|
-
var flexibleCardProps = {
|
|
190
|
+
var flexibleCardProps = _objectSpread(_objectSpread({
|
|
173
191
|
appearance: CardDisplay.HoverCardPreview,
|
|
174
192
|
cardState: cardState,
|
|
175
|
-
onClick: onClick
|
|
193
|
+
onClick: onClick
|
|
194
|
+
}, fg('platform_smartlink_xpc_url_wrapping') ? {
|
|
195
|
+
onAuxClick: onAuxClick,
|
|
196
|
+
onContextMenu: onContextMenu
|
|
197
|
+
} : undefined), {}, {
|
|
176
198
|
onResolve: onResolve,
|
|
177
199
|
origin: 'smartLinkPreviewHoverCard',
|
|
178
200
|
renderers: renderers,
|
|
@@ -180,7 +202,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
180
202
|
ui: uiOptions,
|
|
181
203
|
url: url,
|
|
182
204
|
children: null
|
|
183
|
-
};
|
|
205
|
+
});
|
|
184
206
|
var onClickStopPropagation = useCallback(function (e) {
|
|
185
207
|
return e.stopPropagation();
|
|
186
208
|
}, []);
|
|
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
12
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
13
13
|
var PACKAGE_DATA = {
|
|
14
14
|
packageName: "@atlaskit/smart-card",
|
|
15
|
-
packageVersion: "44.28.
|
|
15
|
+
packageVersion: "44.28.1",
|
|
16
16
|
componentName: 'linkUrl'
|
|
17
17
|
};
|
|
18
18
|
var LinkUrl = function LinkUrl(_ref) {
|