@atlaskit/smart-card 19.0.1 → 19.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,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 19.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f3026520fc6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f3026520fc6) - Fix long tti times for UFO smart-link-rendered experience
8
+
3
9
  ## 19.0.1
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -21,6 +21,8 @@ var _component = require("../component");
21
21
 
22
22
  var _LazyFallback = require("./LazyFallback");
23
23
 
24
+ var _ufoExperiences = require("../../../state/analytics/ufoExperiences");
25
+
24
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
27
 
26
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -39,7 +41,8 @@ function LazyIntersectionObserverCard(props) {
39
41
 
40
42
  var showActions = props.showActions,
41
43
  appearance = props.appearance,
42
- url = props.url;
44
+ url = props.url,
45
+ id = props.id;
43
46
  var prefetch = (0, _state.usePrefetch)(url);
44
47
  var Component = appearance === 'inline' ? 'span' : 'div';
45
48
  var ComponentObserver = Component;
@@ -49,12 +52,13 @@ function LazyIntersectionObserverCard(props) {
49
52
  });
50
53
 
51
54
  if (isVisible) {
55
+ (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
52
56
  setIsIntersecting(true);
53
57
  observer.disconnect();
54
58
  } else {
55
59
  prefetch();
56
60
  }
57
- }, [prefetch]);
61
+ }, [prefetch, id]);
58
62
  var onRef = (0, _react.useCallback)(function (element) {
59
63
  if (!element) {
60
64
  return;
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -9,7 +11,7 @@ exports.LazyLazilyRenderCard = LazyLazilyRenderCard;
9
11
 
10
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
13
 
12
- var _react = _interopRequireDefault(require("react"));
14
+ var _react = _interopRequireWildcard(require("react"));
13
15
 
14
16
  var _reactLazilyRender = _interopRequireDefault(require("react-lazily-render"));
15
17
 
@@ -17,11 +19,22 @@ var _component = require("../component");
17
19
 
18
20
  var _LazyFallback = require("./LazyFallback");
19
21
 
22
+ var _ufoExperiences = require("../../../state/analytics/ufoExperiences");
23
+
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+
26
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+
20
28
  function LazyLazilyRenderCard(props) {
21
29
  var appearance = props.appearance,
22
30
  container = props.container,
23
- showActions = props.showActions;
31
+ showActions = props.showActions,
32
+ id = props.id;
24
33
  var offset = Math.ceil(window.innerHeight / 4);
34
+ (0, _react.useState)(function () {
35
+ // Start of experience when intersectionObserver is not supported.
36
+ (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
37
+ });
25
38
  return /*#__PURE__*/_react.default.createElement(_reactLazilyRender.default, {
26
39
  offset: offset,
27
40
  component: appearance === 'inline' ? 'span' : 'div',
@@ -40,13 +40,8 @@ function CardWithURLRenderer(props) {
40
40
  return (0, _uuid.default)();
41
41
  }),
42
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 1),
43
- id = _useState2[0]; // Equivalent to ComponentWillMount
43
+ id = _useState2[0];
44
44
 
45
-
46
- (0, _react.useState)(function () {
47
- // We want to start timing of render event only once and right at the start
48
- (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
49
- });
50
45
  (0, _react.useEffect)(function () {
51
46
  // ComponentWillUnmount
52
47
  return function () {
@@ -96,7 +91,10 @@ function CardWithURLRenderer(props) {
96
91
  else {
97
92
  var errorInfo = {
98
93
  componentStack: componentStack
99
- };
94
+ }; // Start and fail the smart-link-rendered experience. If it has already
95
+ // been started nothing happens.
96
+
97
+ (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
100
98
  (0, _ufoExperiences.failUfoExperience)('smart-link-rendered', id);
101
99
  (0, _ufoExperiences.failUfoExperience)('smart-link-authenticated', id);
102
100
  dispatchAnalytics((0, _analytics.uiRenderFailedEvent)(appearance, error, errorInfo));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -2,7 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useState } from 'react';
3
3
  import { usePrefetch } from '../../../state';
4
4
  import { CardWithUrlContent } from '../component';
5
- import { LoadingCardLink } from './LazyFallback'; // This property enables the intersection observer to be run once the
5
+ import { LoadingCardLink } from './LazyFallback';
6
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences'; // This property enables the intersection observer to be run once the
6
7
  // HTML element being observed is within `X` px of the target container it is
7
8
  // being compared to. Since the default container is the `document`, we set this
8
9
  // up to check once a Smart Link is within `X` px from the bottom of the viewport.
@@ -13,7 +14,8 @@ export function LazyIntersectionObserverCard(props) {
13
14
  const {
14
15
  showActions,
15
16
  appearance,
16
- url
17
+ url,
18
+ id
17
19
  } = props;
18
20
  const prefetch = usePrefetch(url);
19
21
  const Component = appearance === 'inline' ? 'span' : 'div';
@@ -22,12 +24,13 @@ export function LazyIntersectionObserverCard(props) {
22
24
  const isVisible = entries.some(entry => entry.isIntersecting);
23
25
 
24
26
  if (isVisible) {
27
+ startUfoExperience('smart-link-rendered', id);
25
28
  setIsIntersecting(true);
26
29
  observer.disconnect();
27
30
  } else {
28
31
  prefetch();
29
32
  }
30
- }, [prefetch]);
33
+ }, [prefetch, id]);
31
34
  const onRef = useCallback(element => {
32
35
  if (!element) {
33
36
  return;
@@ -1,15 +1,21 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useState } from 'react';
3
3
  import LazilyRender from 'react-lazily-render';
4
4
  import { CardWithUrlContent } from '../component';
5
5
  import { LoadingCardLink } from './LazyFallback';
6
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
6
7
  export function LazyLazilyRenderCard(props) {
7
8
  const {
8
9
  appearance,
9
10
  container,
10
- showActions
11
+ showActions,
12
+ id
11
13
  } = props;
12
14
  const offset = Math.ceil(window.innerHeight / 4);
15
+ useState(() => {
16
+ // Start of experience when intersectionObserver is not supported.
17
+ startUfoExperience('smart-link-rendered', id);
18
+ });
13
19
  return /*#__PURE__*/React.createElement(LazilyRender, {
14
20
  offset: offset,
15
21
  component: appearance === 'inline' ? 'span' : 'div',
@@ -9,12 +9,7 @@ const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => import(
9
9
  /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
10
10
  './component-lazy/index'));
11
11
  export function CardWithURLRenderer(props) {
12
- const [id] = useState(() => uuid()); // Equivalent to ComponentWillMount
13
-
14
- useState(() => {
15
- // We want to start timing of render event only once and right at the start
16
- startUfoExperience('smart-link-rendered', id);
17
- });
12
+ const [id] = useState(() => uuid());
18
13
  useEffect(() => {
19
14
  // ComponentWillUnmount
20
15
  return () => {
@@ -68,7 +63,10 @@ export function CardWithURLRenderer(props) {
68
63
  else {
69
64
  const errorInfo = {
70
65
  componentStack
71
- };
66
+ }; // Start and fail the smart-link-rendered experience. If it has already
67
+ // been started nothing happens.
68
+
69
+ startUfoExperience('smart-link-rendered', id);
72
70
  failUfoExperience('smart-link-rendered', id);
73
71
  failUfoExperience('smart-link-authenticated', id);
74
72
  dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import React, { useCallback, useState } from 'react';
4
4
  import { usePrefetch } from '../../../state';
5
5
  import { CardWithUrlContent } from '../component';
6
- import { LoadingCardLink } from './LazyFallback'; // This property enables the intersection observer to be run once the
6
+ import { LoadingCardLink } from './LazyFallback';
7
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences'; // This property enables the intersection observer to be run once the
7
8
  // HTML element being observed is within `X` px of the target container it is
8
9
  // being compared to. Since the default container is the `document`, we set this
9
10
  // up to check once a Smart Link is within `X` px from the bottom of the viewport.
@@ -17,7 +18,8 @@ export function LazyIntersectionObserverCard(props) {
17
18
 
18
19
  var showActions = props.showActions,
19
20
  appearance = props.appearance,
20
- url = props.url;
21
+ url = props.url,
22
+ id = props.id;
21
23
  var prefetch = usePrefetch(url);
22
24
  var Component = appearance === 'inline' ? 'span' : 'div';
23
25
  var ComponentObserver = Component;
@@ -27,12 +29,13 @@ export function LazyIntersectionObserverCard(props) {
27
29
  });
28
30
 
29
31
  if (isVisible) {
32
+ startUfoExperience('smart-link-rendered', id);
30
33
  setIsIntersecting(true);
31
34
  observer.disconnect();
32
35
  } else {
33
36
  prefetch();
34
37
  }
35
- }, [prefetch]);
38
+ }, [prefetch, id]);
36
39
  var onRef = useCallback(function (element) {
37
40
  if (!element) {
38
41
  return;
@@ -1,13 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useState } from 'react';
3
3
  import LazilyRender from 'react-lazily-render';
4
4
  import { CardWithUrlContent } from '../component';
5
5
  import { LoadingCardLink } from './LazyFallback';
6
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
6
7
  export function LazyLazilyRenderCard(props) {
7
8
  var appearance = props.appearance,
8
9
  container = props.container,
9
- showActions = props.showActions;
10
+ showActions = props.showActions,
11
+ id = props.id;
10
12
  var offset = Math.ceil(window.innerHeight / 4);
13
+ useState(function () {
14
+ // Start of experience when intersectionObserver is not supported.
15
+ startUfoExperience('smart-link-rendered', id);
16
+ });
11
17
  return /*#__PURE__*/React.createElement(LazilyRender, {
12
18
  offset: offset,
13
19
  component: appearance === 'inline' ? 'span' : 'div',
@@ -16,13 +16,8 @@ export function CardWithURLRenderer(props) {
16
16
  return uuid();
17
17
  }),
18
18
  _useState2 = _slicedToArray(_useState, 1),
19
- id = _useState2[0]; // Equivalent to ComponentWillMount
19
+ id = _useState2[0];
20
20
 
21
-
22
- useState(function () {
23
- // We want to start timing of render event only once and right at the start
24
- startUfoExperience('smart-link-rendered', id);
25
- });
26
21
  useEffect(function () {
27
22
  // ComponentWillUnmount
28
23
  return function () {
@@ -72,7 +67,10 @@ export function CardWithURLRenderer(props) {
72
67
  else {
73
68
  var errorInfo = {
74
69
  componentStack: componentStack
75
- };
70
+ }; // Start and fail the smart-link-rendered experience. If it has already
71
+ // been started nothing happens.
72
+
73
+ startUfoExperience('smart-link-rendered', id);
76
74
  failUfoExperience('smart-link-rendered', id);
77
75
  failUfoExperience('smart-link-authenticated', id);
78
76
  dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
@@ -13,8 +13,11 @@ export declare const MockIntersectionObserverFactory: (mockIntersectionObserverO
13
13
  readonly root: Element | null;
14
14
  readonly rootMargin: string;
15
15
  readonly thresholds: ReadonlyArray<number>;
16
+ previousMockEntries: MockEntry[];
16
17
  callback: IntersectionObserverCallback;
17
18
  observe(_element: HTMLElement): void;
19
+ callIntersectionObserverCallback: () => void;
20
+ checkIntersection: () => void;
18
21
  disconnect: jest.Mock<any, any>;
19
22
  takeRecords: jest.Mock<any, any>;
20
23
  unobserve: jest.Mock<any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"