@atlaskit/smart-card 29.0.1 → 29.0.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 29.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#147818](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147818)
8
+ [`56e97352c27dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/56e97352c27dc) -
9
+ Send smart-link-rendered UFO event only half of the time
10
+
3
11
  ## 29.0.1
4
12
 
5
13
  ### Patch Changes
@@ -20,7 +20,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
20
20
  var extractActions = function extractActions(response, url, actionOptions, id, aiSummaryConfig) {
21
21
  var _objectSpread2;
22
22
  var data = response.data;
23
- var action = _objectSpread((_objectSpread2 = {}, (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.CopyLinkAction, (0, _extractCopyLinkAction.extractCopyLinkAction)(data, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.DownloadAction, (0, _extractDownloadAction.extractDownloadAction)(data, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewAction)(response, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.AutomationAction, (0, _extractAutomationAction.extractAutomationAction)(response)), (0, _defineProperty2.default)(_objectSpread2, _constants.InternalActionName.AISummaryAction, (0, _extractAiSummaryAction.extractAISummaryAction)(response, url, actionOptions, aiSummaryConfig)), _objectSpread2), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-view-related-urls-action') ? (0, _defineProperty2.default)({}, _constants.InternalActionName.ViewRelatedLinksAction, (0, _extractViewRelatedLinksAction.extractViewRelatedLinksAction)(response)) : {});
23
+ var action = _objectSpread((_objectSpread2 = {}, (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.CopyLinkAction, (0, _extractCopyLinkAction.extractCopyLinkAction)(data, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.DownloadAction, (0, _extractDownloadAction.extractDownloadAction)(data, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewAction)(response, actionOptions)), (0, _defineProperty2.default)(_objectSpread2, _constants.ActionName.AutomationAction, (0, _extractAutomationAction.extractAutomationAction)(response)), (0, _defineProperty2.default)(_objectSpread2, _constants.InternalActionName.AISummaryAction, (0, _extractAiSummaryAction.extractAISummaryAction)(response, url, actionOptions, aiSummaryConfig)), _objectSpread2), (0, _platformFeatureFlags.fg)('platform-smart-card-view-related-urls-action') ? (0, _defineProperty2.default)({}, _constants.InternalActionName.ViewRelatedLinksAction, (0, _extractViewRelatedLinksAction.extractViewRelatedLinksAction)(response)) : {});
24
24
  return Object.values(action).some(function (value) {
25
25
  return Boolean(value);
26
26
  }) ? action : undefined;
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "29.0.1"
25
+ packageVersion: "29.0.2"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shouldSample = void 0;
7
+ var shouldSample = exports.shouldSample = function shouldSample() {
8
+ var threshold = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
9
+ return Math.random() > threshold;
10
+ };
@@ -12,6 +12,8 @@ var _state = require("../../../state");
12
12
  var _component = require("../component");
13
13
  var _LoadingCardLink = require("./LoadingCardLink");
14
14
  var _ufoExperiences = require("../../../state/analytics/ufoExperiences");
15
+ var _shouldSample = require("../../../utils/shouldSample");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
19
  // This property enables the intersection observer to be run once the
@@ -25,6 +27,9 @@ function LazyIntersectionObserverCard(props) {
25
27
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
26
28
  isIntersecting = _useState2[0],
27
29
  setIsIntersecting = _useState2[1];
30
+ var _useState3 = (0, _react.useState)((0, _shouldSample.shouldSample)()),
31
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 1),
32
+ shouldSendRenderedUFOEvent = _useState4[0];
28
33
  var appearance = props.appearance,
29
34
  url = props.url,
30
35
  id = props.id;
@@ -36,13 +41,19 @@ function LazyIntersectionObserverCard(props) {
36
41
  return entry.isIntersecting;
37
42
  });
38
43
  if (isVisible) {
39
- (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
44
+ if ((0, _platformFeatureFlags.fg)('send-smart-link-rendered-ufo-event-half-time')) {
45
+ if (shouldSendRenderedUFOEvent) {
46
+ (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
47
+ }
48
+ } else {
49
+ (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
50
+ }
40
51
  setIsIntersecting(true);
41
52
  observer.disconnect();
42
53
  } else {
43
54
  prefetch();
44
55
  }
45
- }, [prefetch, id]);
56
+ }, [id, prefetch, shouldSendRenderedUFOEvent]);
46
57
  (0, _react.useEffect)(function () {
47
58
  if (!ref.current) {
48
59
  return;
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "29.0.1",
20
+ packageVersion: "29.0.2",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -1,4 +1,4 @@
1
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { ActionName, InternalActionName } from '../../../constants';
3
3
  import { extractDownloadAction } from './extract-download-action';
4
4
  import { extractPreviewAction } from './extract-preview-action';
@@ -16,7 +16,7 @@ const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
16
16
  [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
17
17
  [ActionName.AutomationAction]: extractAutomationAction(response),
18
18
  [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig),
19
- ...(getBooleanFF('platform.linking-platform.smart-card.enable-view-related-urls-action') ? {
19
+ ...(fg('platform-smart-card-view-related-urls-action') ? {
20
20
  [InternalActionName.ViewRelatedLinksAction]: extractViewRelatedLinksAction(response)
21
21
  } : {})
22
22
  };
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "29.0.1"
7
+ packageVersion: "29.0.2"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1 @@
1
+ export const shouldSample = (threshold = 0.5) => Math.random() > threshold;
@@ -3,6 +3,8 @@ import { usePrefetch } from '../../../state';
3
3
  import { CardWithUrlContent } from '../component';
4
4
  import { LoadingCardLink } from './LoadingCardLink';
5
5
  import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
6
+ import { shouldSample } from '../../../utils/shouldSample';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
6
8
 
7
9
  // This property enables the intersection observer to be run once the
8
10
  // HTML element being observed is within `X` px of the target container it is
@@ -12,6 +14,7 @@ const ROOT_MARGIN_VERTICAL = '360px';
12
14
  export function LazyIntersectionObserverCard(props) {
13
15
  const ref = useRef(null);
14
16
  const [isIntersecting, setIsIntersecting] = useState(false);
17
+ const [shouldSendRenderedUFOEvent] = useState(shouldSample());
15
18
  const {
16
19
  appearance,
17
20
  url,
@@ -23,13 +26,19 @@ export function LazyIntersectionObserverCard(props) {
23
26
  const onIntersection = useCallback((entries, observer) => {
24
27
  const isVisible = entries.some(entry => entry.isIntersecting);
25
28
  if (isVisible) {
26
- startUfoExperience('smart-link-rendered', id);
29
+ if (fg('send-smart-link-rendered-ufo-event-half-time')) {
30
+ if (shouldSendRenderedUFOEvent) {
31
+ startUfoExperience('smart-link-rendered', id);
32
+ }
33
+ } else {
34
+ startUfoExperience('smart-link-rendered', id);
35
+ }
27
36
  setIsIntersecting(true);
28
37
  observer.disconnect();
29
38
  } else {
30
39
  prefetch();
31
40
  }
32
- }, [prefetch, id]);
41
+ }, [id, prefetch, shouldSendRenderedUFOEvent]);
33
42
  useEffect(() => {
34
43
  if (!ref.current) {
35
44
  return;
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "29.0.1",
10
+ packageVersion: "29.0.2",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { ActionName, InternalActionName } from '../../../constants';
6
6
  import { extractDownloadAction } from './extract-download-action';
7
7
  import { extractPreviewAction } from './extract-preview-action';
@@ -13,7 +13,7 @@ import { extractViewRelatedLinksAction } from './extract-view-related-links-acti
13
13
  var extractActions = function extractActions(response, url, actionOptions, id, aiSummaryConfig) {
14
14
  var _objectSpread2;
15
15
  var data = response.data;
16
- var action = _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, ActionName.CopyLinkAction, extractCopyLinkAction(data, actionOptions)), _defineProperty(_objectSpread2, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_objectSpread2, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _defineProperty(_objectSpread2, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_objectSpread2, ActionName.AutomationAction, extractAutomationAction(response)), _defineProperty(_objectSpread2, InternalActionName.AISummaryAction, extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)), _objectSpread2), getBooleanFF('platform.linking-platform.smart-card.enable-view-related-urls-action') ? _defineProperty({}, InternalActionName.ViewRelatedLinksAction, extractViewRelatedLinksAction(response)) : {});
16
+ var action = _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, ActionName.CopyLinkAction, extractCopyLinkAction(data, actionOptions)), _defineProperty(_objectSpread2, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_objectSpread2, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _defineProperty(_objectSpread2, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_objectSpread2, ActionName.AutomationAction, extractAutomationAction(response)), _defineProperty(_objectSpread2, InternalActionName.AISummaryAction, extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)), _objectSpread2), fg('platform-smart-card-view-related-urls-action') ? _defineProperty({}, InternalActionName.ViewRelatedLinksAction, extractViewRelatedLinksAction(response)) : {});
17
17
  return Object.values(action).some(function (value) {
18
18
  return Boolean(value);
19
19
  }) ? action : undefined;
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "29.0.1"
18
+ packageVersion: "29.0.2"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,4 @@
1
+ export var shouldSample = function shouldSample() {
2
+ var threshold = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
3
+ return Math.random() > threshold;
4
+ };
@@ -4,6 +4,8 @@ import { usePrefetch } from '../../../state';
4
4
  import { CardWithUrlContent } from '../component';
5
5
  import { LoadingCardLink } from './LoadingCardLink';
6
6
  import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
7
+ import { shouldSample } from '../../../utils/shouldSample';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
7
9
 
8
10
  // This property enables the intersection observer to be run once the
9
11
  // HTML element being observed is within `X` px of the target container it is
@@ -16,6 +18,9 @@ export function LazyIntersectionObserverCard(props) {
16
18
  _useState2 = _slicedToArray(_useState, 2),
17
19
  isIntersecting = _useState2[0],
18
20
  setIsIntersecting = _useState2[1];
21
+ var _useState3 = useState(shouldSample()),
22
+ _useState4 = _slicedToArray(_useState3, 1),
23
+ shouldSendRenderedUFOEvent = _useState4[0];
19
24
  var appearance = props.appearance,
20
25
  url = props.url,
21
26
  id = props.id;
@@ -27,13 +32,19 @@ export function LazyIntersectionObserverCard(props) {
27
32
  return entry.isIntersecting;
28
33
  });
29
34
  if (isVisible) {
30
- startUfoExperience('smart-link-rendered', id);
35
+ if (fg('send-smart-link-rendered-ufo-event-half-time')) {
36
+ if (shouldSendRenderedUFOEvent) {
37
+ startUfoExperience('smart-link-rendered', id);
38
+ }
39
+ } else {
40
+ startUfoExperience('smart-link-rendered', id);
41
+ }
31
42
  setIsIntersecting(true);
32
43
  observer.disconnect();
33
44
  } else {
34
45
  prefetch();
35
46
  }
36
- }, [prefetch, id]);
47
+ }, [id, prefetch, shouldSendRenderedUFOEvent]);
37
48
  useEffect(function () {
38
49
  if (!ref.current) {
39
50
  return;
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "29.0.1",
13
+ packageVersion: "29.0.2",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -0,0 +1,2 @@
1
+ /// <reference types="jest" />
2
+ export declare const shouldSample: jest.Mock<any, any, any>;
@@ -0,0 +1 @@
1
+ export declare const shouldSample: (threshold?: number) => boolean;
@@ -0,0 +1,2 @@
1
+ /// <reference types="jest" />
2
+ export declare const shouldSample: jest.Mock<any, any, any>;
@@ -0,0 +1 @@
1
+ export declare const shouldSample: (threshold?: number) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "29.0.1",
3
+ "version": "29.0.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -60,7 +60,7 @@
60
60
  "@atlaskit/textfield": "^6.5.0",
61
61
  "@atlaskit/theme": "^13.0.0",
62
62
  "@atlaskit/tokens": "^2.0.0",
63
- "@atlaskit/tooltip": "^18.7.0",
63
+ "@atlaskit/tooltip": "^18.8.0",
64
64
  "@atlaskit/ufo": "^0.3.0",
65
65
  "@babel/runtime": "^7.0.0",
66
66
  "@emotion/react": "^11.7.1",
@@ -150,7 +150,10 @@
150
150
  ".": "./src/index.ts"
151
151
  },
152
152
  "platform-feature-flags": {
153
- "platform.linking-platform.smart-card.enable-view-related-urls-action": {
153
+ "platform-smart-card-view-related-urls-action": {
154
+ "type": "boolean"
155
+ },
156
+ "send-smart-link-rendered-ufo-event-half-time": {
154
157
  "type": "boolean"
155
158
  }
156
159
  }