@atlaskit/smart-card 44.10.0 → 44.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/analytics.spec.yaml +12 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/click-helpers.js +14 -0
- package/dist/cjs/view/LinkUrl/HyperlinkResolver/index.js +37 -7
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/SmartLinkEvents/useSmartLinkEvents.js +8 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/click-helpers.js +8 -0
- package/dist/es2019/view/LinkUrl/HyperlinkResolver/index.js +38 -8
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/SmartLinkEvents/useSmartLinkEvents.js +7 -2
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/click-helpers.js +8 -0
- package/dist/esm/view/LinkUrl/HyperlinkResolver/index.js +38 -8
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/SmartLinkEvents/useSmartLinkEvents.js +8 -1
- package/dist/types/common/analytics/generated/analytics.types.d.ts +2 -0
- package/dist/types/utils/click-helpers.d.ts +8 -0
- package/dist/types/view/SmartLinkEvents/useSmartLinkEvents.d.ts +7 -1
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +2 -0
- package/dist/types-ts4.5/utils/click-helpers.d.ts +8 -0
- package/dist/types-ts4.5/view/SmartLinkEvents/useSmartLinkEvents.d.ts +7 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 44.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`38ea17de1355a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38ea17de1355a) -
|
|
8
|
+
Track middle- and right-clicks on third-party Smart Links rendered by `HyperlinkResolver`. Adds
|
|
9
|
+
optional `isAuxClick` / `isContextMenu` attributes to the `smartlinkClickAnalyticsWorkflows`
|
|
10
|
+
event, gated by the `linking_platform_track_non_primary_3p_clicks` experiment.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 44.10.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/analytics.spec.yaml
CHANGED
|
@@ -906,3 +906,15 @@ events:
|
|
|
906
906
|
required: true
|
|
907
907
|
type: string
|
|
908
908
|
description: The timestamp when the event was clicked
|
|
909
|
+
isAuxClick:
|
|
910
|
+
required: false
|
|
911
|
+
type: boolean
|
|
912
|
+
description:
|
|
913
|
+
True when the click was a middle-click (button === 1) captured via `onAuxClick`.
|
|
914
|
+
Behaviour is gated by the `linking_platform_track_non_primary_3p_clicks` Statsig experiment.
|
|
915
|
+
isContextMenu:
|
|
916
|
+
required: false
|
|
917
|
+
type: boolean
|
|
918
|
+
description:
|
|
919
|
+
True when the event was a right-click captured via `onContextMenu`. Behaviour is gated
|
|
920
|
+
by the `linking_platform_track_non_primary_3p_clicks` Statsig experiment.
|
|
@@ -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.
|
|
14
|
+
packageVersion: "44.10.0" || ''
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAuxClick = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Returns true for genuine middle-clicks (button === 1).
|
|
9
|
+
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
10
|
+
* in addition to onContextMenu, to prevent double-counting.
|
|
11
|
+
*/
|
|
12
|
+
var isAuxClick = exports.isAuxClick = function isAuxClick(e) {
|
|
13
|
+
return e.button === 1;
|
|
14
|
+
};
|
|
@@ -12,15 +12,19 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
13
13
|
var _reactIntl = require("react-intl");
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
15
17
|
var _helpers = require("../../../state/helpers");
|
|
16
18
|
var _useResolveHyperlink2 = _interopRequireDefault(require("../../../state/hooks/use-resolve-hyperlink"));
|
|
17
19
|
var _useResolveHyperlinkValidator = _interopRequireDefault(require("../../../state/hooks/use-resolve-hyperlink/useResolveHyperlinkValidator"));
|
|
18
20
|
var _SmartLinkAnalyticsContext = require("../../../utils/analytics/SmartLinkAnalyticsContext");
|
|
21
|
+
var _clickHelpers = require("../../../utils/click-helpers");
|
|
19
22
|
var _intlProvider = _interopRequireDefault(require("../../common/intl-provider"));
|
|
20
23
|
var _useSmartLinkEvents = require("../../SmartLinkEvents/useSmartLinkEvents");
|
|
21
24
|
var _Hyperlink = _interopRequireDefault(require("../Hyperlink"));
|
|
22
25
|
var _excluded = ["onClick"];
|
|
23
26
|
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); }
|
|
27
|
+
var TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT = 'linking_platform_track_non_primary_3p_clicks';
|
|
24
28
|
var HyperlinkFallbackComponent = function HyperlinkFallbackComponent() {
|
|
25
29
|
return null;
|
|
26
30
|
};
|
|
@@ -45,17 +49,43 @@ var HyperlinkWithSmartLinkResolverInner = function HyperlinkWithSmartLinkResolve
|
|
|
45
49
|
var fire3PClickEvent = (0, _platformFeatureFlags.fg)('platform_smartlink_3pclick_analytics') ?
|
|
46
50
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
47
51
|
(0, _useSmartLinkEvents.useFire3PWorkflowsClickEvent)(firstPartyIdentifier, thirdPartyARI) : undefined;
|
|
52
|
+
|
|
53
|
+
// Shared scope guard for all 3P-click handlers.
|
|
54
|
+
var shouldFire3PClickEvent = (state === null || state === void 0 ? void 0 : state.status) === 'resolved' && fire3PClickEvent && (0, _platformFeatureFlags.fg)('platform_smartlink_3pclick_analytics');
|
|
48
55
|
var onClick = (0, _react.useCallback)(function (e) {
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fire3PClickEvent();
|
|
56
|
+
// button === 0 is left-click, see
|
|
57
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
58
|
+
if (shouldFire3PClickEvent && (e === null || e === void 0 ? void 0 : e.button) === 0) {
|
|
59
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent();
|
|
54
60
|
}
|
|
55
61
|
onClickCallback === null || onClickCallback === void 0 || onClickCallback(e);
|
|
56
|
-
}, [onClickCallback, fire3PClickEvent,
|
|
62
|
+
}, [onClickCallback, fire3PClickEvent, shouldFire3PClickEvent]);
|
|
63
|
+
|
|
64
|
+
// Fire experiment exposure once per surface mount, not on every re-render.
|
|
65
|
+
(0, _react.useEffect)(function () {
|
|
66
|
+
if (shouldFire3PClickEvent) {
|
|
67
|
+
(0, _expValEquals.expValEquals)(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true);
|
|
68
|
+
}
|
|
69
|
+
}, [shouldFire3PClickEvent]);
|
|
70
|
+
var onAuxClick = (0, _react.useCallback)(function (e) {
|
|
71
|
+
// isAuxClick guards against Windows right-clicks firing onAuxClick with button === 2.
|
|
72
|
+
if ((0, _clickHelpers.isAuxClick)(e) && shouldFire3PClickEvent && (0, _expValEqualsNoExposure.expValEqualsNoExposure)(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
73
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent({
|
|
74
|
+
isAuxClick: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
78
|
+
var onContextMenu = (0, _react.useCallback)(function (_e) {
|
|
79
|
+
if (shouldFire3PClickEvent && (0, _expValEqualsNoExposure.expValEqualsNoExposure)(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
80
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent({
|
|
81
|
+
isContextMenu: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
57
85
|
return /*#__PURE__*/_react.default.createElement(_Hyperlink.default, (0, _extends2.default)({}, props, {
|
|
58
|
-
onClick: onClick
|
|
86
|
+
onClick: onClick,
|
|
87
|
+
onAuxClick: onAuxClick,
|
|
88
|
+
onContextMenu: onContextMenu
|
|
59
89
|
}));
|
|
60
90
|
};
|
|
61
91
|
var HyperlinkWithSmartLinkResolver = exports.HyperlinkWithSmartLinkResolver = (0, _reactErrorBoundary.withErrorBoundary)(withValidator((0, _reactIntl.injectIntl)((0, _intlProvider.default)(HyperlinkWithSmartLinkResolverInner), {
|
|
@@ -22,7 +22,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
22
22
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
23
23
|
var PACKAGE_DATA = {
|
|
24
24
|
packageName: "@atlaskit/smart-card",
|
|
25
|
-
packageVersion: "44.
|
|
25
|
+
packageVersion: "44.10.0",
|
|
26
26
|
componentName: 'linkUrl'
|
|
27
27
|
};
|
|
28
28
|
var Anchor = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -22,6 +22,11 @@ function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI) {
|
|
|
22
22
|
var _useAnalyticsEventsNe = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
23
23
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
24
24
|
return function () {
|
|
25
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
26
|
+
_ref$isAuxClick = _ref.isAuxClick,
|
|
27
|
+
isAuxClick = _ref$isAuxClick === void 0 ? false : _ref$isAuxClick,
|
|
28
|
+
_ref$isContextMenu = _ref.isContextMenu,
|
|
29
|
+
isContextMenu = _ref$isContextMenu === void 0 ? false : _ref$isContextMenu;
|
|
25
30
|
var smartlinkClickAnalyticsEvent = createAnalyticsEvent({
|
|
26
31
|
action: 'clicked',
|
|
27
32
|
actionSubject: 'smartLink',
|
|
@@ -29,7 +34,9 @@ function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI) {
|
|
|
29
34
|
eventType: 'ui',
|
|
30
35
|
attributes: {
|
|
31
36
|
eventName: 'smartLinkClickAnalyticsThirdPartyWorkflows',
|
|
32
|
-
firstPartyIdentifier: firstPartyIdentifier
|
|
37
|
+
firstPartyIdentifier: firstPartyIdentifier,
|
|
38
|
+
isAuxClick: isAuxClick,
|
|
39
|
+
isContextMenu: isContextMenu
|
|
33
40
|
},
|
|
34
41
|
nonPrivacySafeAttributes: {
|
|
35
42
|
thirdPartyARI: thirdPartyARI
|
|
@@ -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.
|
|
5
|
+
packageVersion: "44.10.0" || ''
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true for genuine middle-clicks (button === 1).
|
|
3
|
+
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
4
|
+
* in addition to onContextMenu, to prevent double-counting.
|
|
5
|
+
*/
|
|
6
|
+
export const isAuxClick = e => {
|
|
7
|
+
return e.button === 1;
|
|
8
|
+
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect } from 'react';
|
|
3
3
|
import { withErrorBoundary as withReactErrorBoundary } from 'react-error-boundary';
|
|
4
4
|
import { injectIntl } from 'react-intl';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
6
8
|
import { getFirstPartyIdentifier, getThirdPartyARI } from '../../../state/helpers';
|
|
7
9
|
import useResolveHyperlink from '../../../state/hooks/use-resolve-hyperlink';
|
|
8
10
|
import useResolveHyperlinkValidator from '../../../state/hooks/use-resolve-hyperlink/useResolveHyperlinkValidator';
|
|
9
11
|
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
12
|
+
import { isAuxClick } from '../../../utils/click-helpers';
|
|
10
13
|
import withIntlProvider from '../../common/intl-provider';
|
|
11
14
|
import { useFire3PWorkflowsClickEvent } from '../../SmartLinkEvents/useSmartLinkEvents';
|
|
12
15
|
import Hyperlink from '../Hyperlink';
|
|
16
|
+
const TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT = 'linking_platform_track_non_primary_3p_clicks';
|
|
13
17
|
const HyperlinkFallbackComponent = () => null;
|
|
14
18
|
const withValidator = (Component, DefaultComponent) => props => {
|
|
15
19
|
const shouldResolveHyperlink = useResolveHyperlinkValidator(props === null || props === void 0 ? void 0 : props.href);
|
|
@@ -32,17 +36,43 @@ const HyperlinkWithSmartLinkResolverInner = ({
|
|
|
32
36
|
const fire3PClickEvent = fg('platform_smartlink_3pclick_analytics') ?
|
|
33
37
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
34
38
|
useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI) : undefined;
|
|
39
|
+
|
|
40
|
+
// Shared scope guard for all 3P-click handlers.
|
|
41
|
+
const shouldFire3PClickEvent = (state === null || state === void 0 ? void 0 : state.status) === 'resolved' && fire3PClickEvent && fg('platform_smartlink_3pclick_analytics');
|
|
35
42
|
const onClick = useCallback(e => {
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
fire3PClickEvent();
|
|
43
|
+
// button === 0 is left-click, see
|
|
44
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
45
|
+
if (shouldFire3PClickEvent && (e === null || e === void 0 ? void 0 : e.button) === 0) {
|
|
46
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 ? void 0 : fire3PClickEvent();
|
|
41
47
|
}
|
|
42
48
|
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(e);
|
|
43
|
-
}, [onClickCallback, fire3PClickEvent,
|
|
49
|
+
}, [onClickCallback, fire3PClickEvent, shouldFire3PClickEvent]);
|
|
50
|
+
|
|
51
|
+
// Fire experiment exposure once per surface mount, not on every re-render.
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (shouldFire3PClickEvent) {
|
|
54
|
+
expValEquals(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true);
|
|
55
|
+
}
|
|
56
|
+
}, [shouldFire3PClickEvent]);
|
|
57
|
+
const onAuxClick = useCallback(e => {
|
|
58
|
+
// isAuxClick guards against Windows right-clicks firing onAuxClick with button === 2.
|
|
59
|
+
if (isAuxClick(e) && shouldFire3PClickEvent && expValEqualsNoExposure(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
60
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 ? void 0 : fire3PClickEvent({
|
|
61
|
+
isAuxClick: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
65
|
+
const onContextMenu = useCallback(_e => {
|
|
66
|
+
if (shouldFire3PClickEvent && expValEqualsNoExposure(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
67
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 ? void 0 : fire3PClickEvent({
|
|
68
|
+
isContextMenu: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
44
72
|
return /*#__PURE__*/React.createElement(Hyperlink, _extends({}, props, {
|
|
45
|
-
onClick: onClick
|
|
73
|
+
onClick: onClick,
|
|
74
|
+
onAuxClick: onAuxClick,
|
|
75
|
+
onContextMenu: onContextMenu
|
|
46
76
|
}));
|
|
47
77
|
};
|
|
48
78
|
export const HyperlinkWithSmartLinkResolver = withReactErrorBoundary(withValidator(injectIntl(withIntlProvider(HyperlinkWithSmartLinkResolverInner), {
|
|
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
12
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
13
13
|
const PACKAGE_DATA = {
|
|
14
14
|
packageName: "@atlaskit/smart-card",
|
|
15
|
-
packageVersion: "44.
|
|
15
|
+
packageVersion: "44.10.0",
|
|
16
16
|
componentName: 'linkUrl'
|
|
17
17
|
};
|
|
18
18
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -13,7 +13,10 @@ export function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI
|
|
|
13
13
|
const {
|
|
14
14
|
createAnalyticsEvent
|
|
15
15
|
} = useAnalyticsEventsNext();
|
|
16
|
-
return (
|
|
16
|
+
return ({
|
|
17
|
+
isAuxClick = false,
|
|
18
|
+
isContextMenu = false
|
|
19
|
+
} = {}) => {
|
|
17
20
|
const smartlinkClickAnalyticsEvent = createAnalyticsEvent({
|
|
18
21
|
action: 'clicked',
|
|
19
22
|
actionSubject: 'smartLink',
|
|
@@ -21,7 +24,9 @@ export function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI
|
|
|
21
24
|
eventType: 'ui',
|
|
22
25
|
attributes: {
|
|
23
26
|
eventName: 'smartLinkClickAnalyticsThirdPartyWorkflows',
|
|
24
|
-
firstPartyIdentifier: firstPartyIdentifier
|
|
27
|
+
firstPartyIdentifier: firstPartyIdentifier,
|
|
28
|
+
isAuxClick,
|
|
29
|
+
isContextMenu
|
|
25
30
|
},
|
|
26
31
|
nonPrivacySafeAttributes: {
|
|
27
32
|
thirdPartyARI: thirdPartyARI
|
|
@@ -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.
|
|
7
|
+
packageVersion: "44.10.0" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true for genuine middle-clicks (button === 1).
|
|
3
|
+
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
4
|
+
* in addition to onContextMenu, to prevent double-counting.
|
|
5
|
+
*/
|
|
6
|
+
export var isAuxClick = function isAuxClick(e) {
|
|
7
|
+
return e.button === 1;
|
|
8
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["onClick"];
|
|
4
|
-
import React, { useCallback } from 'react';
|
|
4
|
+
import React, { useCallback, useEffect } from 'react';
|
|
5
5
|
import { withErrorBoundary as withReactErrorBoundary } from 'react-error-boundary';
|
|
6
6
|
import { injectIntl } from 'react-intl';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
10
|
import { getFirstPartyIdentifier, getThirdPartyARI } from '../../../state/helpers';
|
|
9
11
|
import useResolveHyperlink from '../../../state/hooks/use-resolve-hyperlink';
|
|
10
12
|
import useResolveHyperlinkValidator from '../../../state/hooks/use-resolve-hyperlink/useResolveHyperlinkValidator';
|
|
11
13
|
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
14
|
+
import { isAuxClick } from '../../../utils/click-helpers';
|
|
12
15
|
import withIntlProvider from '../../common/intl-provider';
|
|
13
16
|
import { useFire3PWorkflowsClickEvent } from '../../SmartLinkEvents/useSmartLinkEvents';
|
|
14
17
|
import Hyperlink from '../Hyperlink';
|
|
18
|
+
var TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT = 'linking_platform_track_non_primary_3p_clicks';
|
|
15
19
|
var HyperlinkFallbackComponent = function HyperlinkFallbackComponent() {
|
|
16
20
|
return null;
|
|
17
21
|
};
|
|
@@ -36,17 +40,43 @@ var HyperlinkWithSmartLinkResolverInner = function HyperlinkWithSmartLinkResolve
|
|
|
36
40
|
var fire3PClickEvent = fg('platform_smartlink_3pclick_analytics') ?
|
|
37
41
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
38
42
|
useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI) : undefined;
|
|
43
|
+
|
|
44
|
+
// Shared scope guard for all 3P-click handlers.
|
|
45
|
+
var shouldFire3PClickEvent = (state === null || state === void 0 ? void 0 : state.status) === 'resolved' && fire3PClickEvent && fg('platform_smartlink_3pclick_analytics');
|
|
39
46
|
var onClick = useCallback(function (e) {
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
fire3PClickEvent();
|
|
47
|
+
// button === 0 is left-click, see
|
|
48
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
49
|
+
if (shouldFire3PClickEvent && (e === null || e === void 0 ? void 0 : e.button) === 0) {
|
|
50
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent();
|
|
45
51
|
}
|
|
46
52
|
onClickCallback === null || onClickCallback === void 0 || onClickCallback(e);
|
|
47
|
-
}, [onClickCallback, fire3PClickEvent,
|
|
53
|
+
}, [onClickCallback, fire3PClickEvent, shouldFire3PClickEvent]);
|
|
54
|
+
|
|
55
|
+
// Fire experiment exposure once per surface mount, not on every re-render.
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (shouldFire3PClickEvent) {
|
|
58
|
+
expValEquals(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true);
|
|
59
|
+
}
|
|
60
|
+
}, [shouldFire3PClickEvent]);
|
|
61
|
+
var onAuxClick = useCallback(function (e) {
|
|
62
|
+
// isAuxClick guards against Windows right-clicks firing onAuxClick with button === 2.
|
|
63
|
+
if (isAuxClick(e) && shouldFire3PClickEvent && expValEqualsNoExposure(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
64
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent({
|
|
65
|
+
isAuxClick: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
69
|
+
var onContextMenu = useCallback(function (_e) {
|
|
70
|
+
if (shouldFire3PClickEvent && expValEqualsNoExposure(TRACK_NON_PRIMARY_3P_CLICKS_EXPERIMENT, 'isEnabled', true)) {
|
|
71
|
+
fire3PClickEvent === null || fire3PClickEvent === void 0 || fire3PClickEvent({
|
|
72
|
+
isContextMenu: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, [fire3PClickEvent, shouldFire3PClickEvent]);
|
|
48
76
|
return /*#__PURE__*/React.createElement(Hyperlink, _extends({}, props, {
|
|
49
|
-
onClick: onClick
|
|
77
|
+
onClick: onClick,
|
|
78
|
+
onAuxClick: onAuxClick,
|
|
79
|
+
onContextMenu: onContextMenu
|
|
50
80
|
}));
|
|
51
81
|
};
|
|
52
82
|
export var HyperlinkWithSmartLinkResolver = withReactErrorBoundary(withValidator(injectIntl(withIntlProvider(HyperlinkWithSmartLinkResolverInner), {
|
|
@@ -15,7 +15,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
15
15
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
16
16
|
var PACKAGE_DATA = {
|
|
17
17
|
packageName: "@atlaskit/smart-card",
|
|
18
|
-
packageVersion: "44.
|
|
18
|
+
packageVersion: "44.10.0",
|
|
19
19
|
componentName: 'linkUrl'
|
|
20
20
|
};
|
|
21
21
|
var Anchor = withLinkClickedEvent('a');
|
|
@@ -15,6 +15,11 @@ export function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI
|
|
|
15
15
|
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
16
16
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
17
17
|
return function () {
|
|
18
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
19
|
+
_ref$isAuxClick = _ref.isAuxClick,
|
|
20
|
+
isAuxClick = _ref$isAuxClick === void 0 ? false : _ref$isAuxClick,
|
|
21
|
+
_ref$isContextMenu = _ref.isContextMenu,
|
|
22
|
+
isContextMenu = _ref$isContextMenu === void 0 ? false : _ref$isContextMenu;
|
|
18
23
|
var smartlinkClickAnalyticsEvent = createAnalyticsEvent({
|
|
19
24
|
action: 'clicked',
|
|
20
25
|
actionSubject: 'smartLink',
|
|
@@ -22,7 +27,9 @@ export function useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI
|
|
|
22
27
|
eventType: 'ui',
|
|
23
28
|
attributes: {
|
|
24
29
|
eventName: 'smartLinkClickAnalyticsThirdPartyWorkflows',
|
|
25
|
-
firstPartyIdentifier: firstPartyIdentifier
|
|
30
|
+
firstPartyIdentifier: firstPartyIdentifier,
|
|
31
|
+
isAuxClick: isAuxClick,
|
|
32
|
+
isContextMenu: isContextMenu
|
|
26
33
|
},
|
|
27
34
|
nonPrivacySafeAttributes: {
|
|
28
35
|
thirdPartyARI: thirdPartyARI
|
|
@@ -276,6 +276,8 @@ export type SmartLinkClickedSmartlinkClickAnalyticsWorkflowsAttributesType = {
|
|
|
276
276
|
eventName: string;
|
|
277
277
|
firstPartyIdentifier?: string | null;
|
|
278
278
|
clickedAt: string;
|
|
279
|
+
isAuxClick?: boolean;
|
|
280
|
+
isContextMenu?: boolean;
|
|
279
281
|
};
|
|
280
282
|
export type AnalyticsEventAttributes = {
|
|
281
283
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true for genuine middle-clicks (button === 1).
|
|
3
|
+
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
4
|
+
* in addition to onContextMenu, to prevent double-counting.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isAuxClick: (e: {
|
|
7
|
+
button: number;
|
|
8
|
+
}) => boolean;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { SmartLinkEvents } from '../../utils/analytics/analytics';
|
|
2
2
|
export declare function useSmartLinkEvents(): SmartLinkEvents;
|
|
3
|
-
export
|
|
3
|
+
export type Fire3PWorkflowsClickEventOptions = {
|
|
4
|
+
/** True for middle-clicks (button === 1) captured via `onAuxClick`. */
|
|
5
|
+
isAuxClick?: boolean;
|
|
6
|
+
/** True for right-clicks captured via `onContextMenu`. */
|
|
7
|
+
isContextMenu?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function useFire3PWorkflowsClickEvent(firstPartyIdentifier: string | undefined, thirdPartyARI: string | undefined): ({ isAuxClick, isContextMenu, }?: Fire3PWorkflowsClickEventOptions) => void;
|
|
@@ -276,6 +276,8 @@ export type SmartLinkClickedSmartlinkClickAnalyticsWorkflowsAttributesType = {
|
|
|
276
276
|
eventName: string;
|
|
277
277
|
firstPartyIdentifier?: string | null;
|
|
278
278
|
clickedAt: string;
|
|
279
|
+
isAuxClick?: boolean;
|
|
280
|
+
isContextMenu?: boolean;
|
|
279
281
|
};
|
|
280
282
|
export type AnalyticsEventAttributes = {
|
|
281
283
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true for genuine middle-clicks (button === 1).
|
|
3
|
+
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
4
|
+
* in addition to onContextMenu, to prevent double-counting.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isAuxClick: (e: {
|
|
7
|
+
button: number;
|
|
8
|
+
}) => boolean;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { SmartLinkEvents } from '../../utils/analytics/analytics';
|
|
2
2
|
export declare function useSmartLinkEvents(): SmartLinkEvents;
|
|
3
|
-
export
|
|
3
|
+
export type Fire3PWorkflowsClickEventOptions = {
|
|
4
|
+
/** True for middle-clicks (button === 1) captured via `onAuxClick`. */
|
|
5
|
+
isAuxClick?: boolean;
|
|
6
|
+
/** True for right-clicks captured via `onContextMenu`. */
|
|
7
|
+
isContextMenu?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function useFire3PWorkflowsClickEvent(firstPartyIdentifier: string | undefined, thirdPartyARI: string | undefined): ({ isAuxClick, isContextMenu, }?: Fire3PWorkflowsClickEventOptions) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "44.
|
|
3
|
+
"version": "44.11.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@atlaskit/textfield": "^8.3.0",
|
|
87
87
|
"@atlaskit/theme": "^23.2.0",
|
|
88
88
|
"@atlaskit/tile": "^1.1.0",
|
|
89
|
-
"@atlaskit/tmp-editor-statsig": "^80.
|
|
89
|
+
"@atlaskit/tmp-editor-statsig": "^80.2.0",
|
|
90
90
|
"@atlaskit/tokens": "^13.0.0",
|
|
91
91
|
"@atlaskit/tooltip": "^22.2.0",
|
|
92
92
|
"@atlaskit/ufo": "^0.5.0",
|