@atlaskit/smart-card 22.0.0 → 22.1.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/__tests_external__/index.js +53 -0
  3. package/dist/cjs/__tests_external__/page-objects/BaseCard.js +115 -0
  4. package/dist/cjs/__tests_external__/page-objects/BlockCard.js +43 -0
  5. package/dist/cjs/__tests_external__/page-objects/EmbedCard.js +43 -0
  6. package/dist/cjs/__tests_external__/page-objects/InlineCard.js +43 -0
  7. package/dist/cjs/__tests_external__/test-cases/card.js +27 -0
  8. package/dist/cjs/__tests_external__/test-cases/embed.js +27 -0
  9. package/dist/cjs/__tests_external__/test-cases/inline.js +27 -0
  10. package/dist/cjs/__tests_external__/test-cases/types.js +5 -0
  11. package/dist/cjs/extractors/block/index.js +6 -7
  12. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +16 -27
  13. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +43 -0
  14. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +5 -3
  15. package/dist/cjs/utils/analytics/analytics.js +2 -2
  16. package/dist/cjs/utils/mocks.js +28 -2
  17. package/dist/cjs/version.json +1 -1
  18. package/dist/cjs/view/BlockCard/actions/PreviewAction.js +2 -2
  19. package/dist/cjs/view/BlockCard/index.js +6 -5
  20. package/dist/cjs/view/CardWithUrl/component.js +2 -2
  21. package/dist/cjs/view/EmbedCard/index.js +3 -2
  22. package/dist/cjs/view/EmbedModal/components/analytics/index.js +100 -0
  23. package/dist/cjs/view/EmbedModal/components/analytics/types.js +5 -0
  24. package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +5 -10
  25. package/dist/cjs/view/EmbedModal/index.js +54 -15
  26. package/dist/cjs/view/EmbedModal/types.js +9 -1
  27. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -1
  28. package/dist/cjs/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
  29. package/dist/cjs/view/common/Modal.js +29 -4
  30. package/dist/cjs/view/common/ModalHeader.js +3 -2
  31. package/dist/es2019/__tests_external__/index.js +6 -0
  32. package/dist/es2019/__tests_external__/page-objects/BaseCard.js +61 -0
  33. package/dist/es2019/__tests_external__/page-objects/BlockCard.js +8 -0
  34. package/dist/es2019/__tests_external__/page-objects/EmbedCard.js +8 -0
  35. package/dist/es2019/__tests_external__/page-objects/InlineCard.js +8 -0
  36. package/dist/es2019/__tests_external__/test-cases/card.js +14 -0
  37. package/dist/es2019/__tests_external__/test-cases/embed.js +14 -0
  38. package/dist/es2019/__tests_external__/test-cases/inline.js +14 -0
  39. package/dist/es2019/__tests_external__/test-cases/types.js +1 -0
  40. package/dist/es2019/extractors/block/index.js +6 -7
  41. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +16 -18
  42. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +46 -3
  43. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +5 -3
  44. package/dist/es2019/utils/analytics/analytics.js +1 -1
  45. package/dist/es2019/utils/mocks.js +26 -1
  46. package/dist/es2019/version.json +1 -1
  47. package/dist/es2019/view/BlockCard/actions/PreviewAction.js +3 -3
  48. package/dist/es2019/view/BlockCard/index.js +5 -4
  49. package/dist/es2019/view/CardWithUrl/component.js +2 -2
  50. package/dist/es2019/view/EmbedCard/index.js +3 -2
  51. package/dist/es2019/view/EmbedModal/components/analytics/index.js +80 -0
  52. package/dist/es2019/view/EmbedModal/components/analytics/types.js +1 -0
  53. package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +5 -9
  54. package/dist/es2019/view/EmbedModal/index.js +46 -13
  55. package/dist/es2019/view/EmbedModal/types.js +6 -1
  56. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +2 -1
  57. package/dist/es2019/view/InlineCard/IconAndTitleLayout/styled.js +0 -2
  58. package/dist/es2019/view/common/Modal.js +27 -6
  59. package/dist/es2019/view/common/ModalHeader.js +3 -2
  60. package/dist/esm/__tests_external__/index.js +6 -0
  61. package/dist/esm/__tests_external__/page-objects/BaseCard.js +101 -0
  62. package/dist/esm/__tests_external__/page-objects/BlockCard.js +28 -0
  63. package/dist/esm/__tests_external__/page-objects/EmbedCard.js +28 -0
  64. package/dist/esm/__tests_external__/page-objects/InlineCard.js +28 -0
  65. package/dist/esm/__tests_external__/test-cases/card.js +16 -0
  66. package/dist/esm/__tests_external__/test-cases/embed.js +16 -0
  67. package/dist/esm/__tests_external__/test-cases/inline.js +16 -0
  68. package/dist/esm/__tests_external__/test-cases/types.js +1 -0
  69. package/dist/esm/extractors/block/index.js +6 -7
  70. package/dist/esm/extractors/common/actions/extractPreviewAction.js +17 -27
  71. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +45 -2
  72. package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -3
  73. package/dist/esm/utils/analytics/analytics.js +2 -2
  74. package/dist/esm/utils/mocks.js +25 -0
  75. package/dist/esm/version.json +1 -1
  76. package/dist/esm/view/BlockCard/actions/PreviewAction.js +3 -3
  77. package/dist/esm/view/BlockCard/index.js +5 -4
  78. package/dist/esm/view/CardWithUrl/component.js +2 -2
  79. package/dist/esm/view/EmbedCard/index.js +3 -2
  80. package/dist/esm/view/EmbedModal/components/analytics/index.js +82 -0
  81. package/dist/esm/view/EmbedModal/components/analytics/types.js +1 -0
  82. package/dist/esm/view/EmbedModal/components/size-experiment/index.js +5 -10
  83. package/dist/esm/view/EmbedModal/index.js +52 -15
  84. package/dist/esm/view/EmbedModal/types.js +6 -1
  85. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +2 -1
  86. package/dist/esm/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
  87. package/dist/esm/view/common/Modal.js +28 -6
  88. package/dist/esm/view/common/ModalHeader.js +3 -2
  89. package/dist/types/extractors/block/types.d.ts +4 -2
  90. package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +7 -5
  91. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +23 -1
  92. package/dist/types/state/hooks/useSmartLink.d.ts +9 -0
  93. package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +6 -2
  94. package/dist/types/utils/mocks.d.ts +48 -0
  95. package/dist/types/utils/types.d.ts +3 -1
  96. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +4 -0
  97. package/dist/types/view/BlockCard/index.d.ts +2 -2
  98. package/dist/types/view/BlockCard/types.d.ts +4 -4
  99. package/dist/types/view/Card/index.d.ts +1 -1
  100. package/dist/types/view/EmbedCard/types.d.ts +2 -2
  101. package/dist/types/view/EmbedModal/components/analytics/index.d.ts +5 -0
  102. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +6 -0
  103. package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +4 -3
  104. package/dist/types/view/EmbedModal/index.d.ts +3 -1
  105. package/dist/types/view/EmbedModal/types.d.ts +14 -4
  106. package/dist/types/view/HoverCard/index.d.ts +1 -1
  107. package/dist/types/view/common/Modal.d.ts +6 -8
  108. package/package.json +22 -22
  109. package/report.api.md +35 -3
@@ -14,10 +14,12 @@ manually passed to your custom components.
14
14
 
15
15
  For a complete guide on customization using the new compositional API, refer to the docs at
16
16
  https://atlassian.design/components/modal-dialog/examples#customizing-modal-dialog. */
17
- import React, { useState } from 'react';
18
- import ModalDialog, { ModalTransition, ModalBody } from '@atlaskit/modal-dialog';
17
+ import React, { useCallback, useRef, useState } from 'react';
18
+ import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
19
19
  import { Header } from './ModalHeader';
20
20
  import { getIframeSandboxAttribute } from '../../utils';
21
+ import withAnalytics from '../EmbedModal/components/analytics';
22
+ import { EmbedModalSize } from '../EmbedModal/types';
21
23
  const iframeStyles = {
22
24
  width: `100%`,
23
25
  height: 'calc(100vh - 248px)'
@@ -45,7 +47,7 @@ const Modal = ({
45
47
  providerName,
46
48
  metadata,
47
49
  icon,
48
- closeLabel,
50
+ closeLabel = 'Close Preview',
49
51
  iframeName,
50
52
  title,
51
53
  url,
@@ -56,16 +58,35 @@ const Modal = ({
56
58
  onDownloadActionClick
57
59
  }) => {
58
60
  let [isOpen, setIsOpen] = useState(showModal);
61
+ const openAt = useRef();
62
+ const handleOnOpenComplete = useCallback(() => {
63
+ openAt.current = Date.now();
64
+
65
+ if (onOpen) {
66
+ onOpen({
67
+ size: EmbedModalSize.Small
68
+ });
69
+ }
70
+ }, [onOpen]);
71
+ const handleOnCloseComplete = useCallback(() => {
72
+ if (onClose) {
73
+ const duration = openAt.current ? Date.now() - openAt.current : undefined;
74
+ onClose({
75
+ duration,
76
+ size: EmbedModalSize.Small
77
+ });
78
+ }
79
+ }, [onClose]);
59
80
  const sandbox = getIframeSandboxAttribute(isTrusted);
60
81
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
61
82
  height: "100%",
62
83
  width: "large",
63
84
  testId: testId,
64
- onOpenComplete: onOpen,
85
+ onOpenComplete: handleOnOpenComplete,
65
86
  onClose: () => {
66
87
  setIsOpen(false);
67
88
  },
68
- onCloseComplete: onClose
89
+ onCloseComplete: handleOnCloseComplete
69
90
  }, /*#__PURE__*/React.createElement(Header, {
70
91
  providerName: providerName,
71
92
  icon: icon,
@@ -91,4 +112,4 @@ const Modal = ({
91
112
  }))));
92
113
  };
93
114
 
94
- export default ModalWithErrorBoundary;
115
+ export default withAnalytics(ModalWithErrorBoundary);
@@ -74,7 +74,7 @@ export const Header = ({
74
74
  testId: "preview-view-action",
75
75
  iconAfter: jsx(ShortcutIcon, {
76
76
  size: "small",
77
- label: "go to source"
77
+ label: ""
78
78
  }),
79
79
  onClick: onViewActionClick
80
80
  }, providerName ? jsx(F, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal)), jsx(Button, {
@@ -82,6 +82,7 @@ export const Header = ({
82
82
  iconBefore: jsx(EditorCloseIcon, {
83
83
  label: label
84
84
  }),
85
- onClick: onClose
85
+ onClick: onClose,
86
+ testId: "preview-close-button"
86
87
  }))));
87
88
  };
@@ -0,0 +1,6 @@
1
+ export { InlineCardPageObject } from './page-objects/InlineCard';
2
+ export { BlockCardPageObject } from './page-objects/BlockCard';
3
+ export { EmbedCardPageObject } from './page-objects/EmbedCard';
4
+ export { inlineSmartLinkRendersTestCase } from './test-cases/inline';
5
+ export { blockSmartLinkRendersTestCase } from './test-cases/card';
6
+ export { embedSmartLinkRendersTestCase } from './test-cases/embed';
@@ -0,0 +1,101 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
+
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+
12
+ import { InProductTestPageObject } from '@atlaskit/in-product-testing';
13
+ export var BaseCardPageObject = /*#__PURE__*/function (_InProductTestPageObj) {
14
+ _inherits(BaseCardPageObject, _InProductTestPageObj);
15
+
16
+ var _super = _createSuper(BaseCardPageObject);
17
+
18
+ function BaseCardPageObject(cy, appearance) {
19
+ var _this;
20
+
21
+ _classCallCheck(this, BaseCardPageObject);
22
+
23
+ _this = _super.call(this, cy);
24
+ _this.cy = cy;
25
+ _this.appearance = appearance;
26
+ return _this;
27
+ }
28
+
29
+ _createClass(BaseCardPageObject, [{
30
+ key: "_toSelector",
31
+ value: function _toSelector(appearance, status) {
32
+ var viewSelector = status.replace(/_/g, '-');
33
+ return this.toTestId("".concat(appearance, "-card-").concat(viewSelector, "-view"));
34
+ }
35
+ }, {
36
+ key: "expectCardReady",
37
+ value: function expectCardReady() {
38
+ var _this2 = this;
39
+
40
+ var numOfCards = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
41
+ var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'resolved';
42
+
43
+ var selector = this._toSelector(this.appearance, status);
44
+
45
+ return this.cy // NOTE: `timeout` used since Smart Links rely on a network response.
46
+ .get(selector, {
47
+ timeout: BaseCardPageObject.CARD_TIMEOUT
48
+ }).should('have.length', numOfCards).each(function (element) {
49
+ _this2.cy.wrap(element) // NOTE: `be.visible` is used to ensure the file is still visible
50
+ // whilst it is being uploaded.
51
+ .should('be.visible');
52
+ });
53
+ }
54
+ }, {
55
+ key: "expectCardNotExists",
56
+ value: function expectCardNotExists() {
57
+ var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'resolved';
58
+
59
+ var selector = this._toSelector(this.appearance, status);
60
+
61
+ return this.cy.get(selector).should('not.exist');
62
+ }
63
+ }, {
64
+ key: "findCardNth",
65
+ value: function findCardNth() {
66
+ var nth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
67
+ var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'resolved';
68
+
69
+ var selector = this._toSelector(this.appearance, status);
70
+
71
+ return this.cy // NOTE: `timeout` used since Smart Links rely on a network response.
72
+ .get(selector, {
73
+ timeout: BaseCardPageObject.CARD_TIMEOUT
74
+ }).should('have.length.at.least', nth).should('be.visible').eq(nth - 1);
75
+ }
76
+ }, {
77
+ key: "assertHrefRendered",
78
+ value: function assertHrefRendered(url) {
79
+ return this.cy.get("a[href=\"".concat(url, "\"]"), {
80
+ timeout: BaseCardPageObject.CARD_TIMEOUT
81
+ }).should('be.visible');
82
+ }
83
+ }, {
84
+ key: "assertHrefNotRendered",
85
+ value: function assertHrefNotRendered(url) {
86
+ return this.cy.get("a[href=\"".concat(url, "\"]"), {
87
+ timeout: BaseCardPageObject.CARD_TIMEOUT
88
+ }).should('not.exist');
89
+ }
90
+ }, {
91
+ key: "click",
92
+ value: function click() {
93
+ var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'resolved';
94
+ return this.findCardNth(1, status).click();
95
+ }
96
+ }]);
97
+
98
+ return BaseCardPageObject;
99
+ }(InProductTestPageObject);
100
+
101
+ _defineProperty(BaseCardPageObject, "CARD_TIMEOUT", 15000);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var BlockCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(BlockCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(BlockCardPageObject);
16
+
17
+ function BlockCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, BlockCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'block');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(BlockCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var EmbedCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(EmbedCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(EmbedCardPageObject);
16
+
17
+ function EmbedCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, EmbedCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'embed');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(EmbedCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var InlineCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(InlineCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(InlineCardPageObject);
16
+
17
+ function InlineCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, InlineCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'inline');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(InlineCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { BlockCardPageObject } from '../page-objects/BlockCard';
3
+ export var blockSmartLinkRendersTestCase = function blockSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Block Smart Link is visible in the resolved state',
9
+ id: 'block-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var blockCard = new BlockCardPageObject(cy);
12
+ blockCard.assertHrefRendered(url);
13
+ blockCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { EmbedCardPageObject } from '../page-objects/EmbedCard';
3
+ export var embedSmartLinkRendersTestCase = function embedSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Embed Smart Link is visible in the resolved state',
9
+ id: 'embed-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var embedCard = new EmbedCardPageObject(cy);
12
+ embedCard.assertHrefRendered(url);
13
+ embedCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { InlineCardPageObject } from '../page-objects/InlineCard';
3
+ export var inlineSmartLinkRendersTestCase = function inlineSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Inline Smart Link is visible in the resolved state',
9
+ id: 'inline-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var inlineCard = new InlineCardPageObject(cy);
12
+ inlineCard.assertHrefRendered(url);
13
+ inlineCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -37,14 +37,13 @@ var extractBlockDetails = function extractBlockDetails(jsonLd) {
37
37
 
38
38
  export var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform) {
39
39
  if (opts) {
40
- var featureFlags = opts.featureFlags,
41
- handleInvoke = opts.handleInvoke,
42
- handleAnalytics = opts.handleAnalytics,
43
- extensionKey = opts.extensionKey,
44
- source = opts.source,
45
- testId = opts.testId;
40
+ var handleInvoke = opts.handleInvoke;
46
41
  var actions = extractActions(jsonLd, handleInvoke);
47
- var previewAction = extractPreviewAction(extensionKey, props, jsonLd, handleInvoke, handleAnalytics, testId, platform, source, featureFlags); // The previewAction should always be the last action
42
+ var previewAction = extractPreviewAction(_objectSpread(_objectSpread({}, opts), {}, {
43
+ viewProps: props,
44
+ jsonLd: jsonLd,
45
+ platform: platform
46
+ })); // The previewAction should always be the last action
48
47
 
49
48
  if (previewAction) {
50
49
  actions.push(previewAction);
@@ -4,9 +4,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
- import { uiRenderSuccessEvent, uiRenderFailedEvent } from '../../../utils/analytics';
8
7
  import { extractDownloadUrl } from '../detail';
9
- import { extractProvider, extractPreview } from '@atlaskit/linking-common/extractors';
8
+ import { extractPreview, extractProvider } from '@atlaskit/linking-common/extractors';
10
9
  import { PreviewAction } from '../../../view/BlockCard';
11
10
 
12
11
  var getMetadataFromJsonLd = function getMetadataFromJsonLd(jsonLd, platform) {
@@ -51,16 +50,19 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
51
50
  };
52
51
  };
53
52
 
54
- export var extractPreviewAction = function extractPreviewAction() {
55
- var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'empty-object-provider';
56
- var viewProps = arguments.length > 1 ? arguments[1] : undefined;
57
- var jsonLd = arguments.length > 2 ? arguments[2] : undefined;
58
- var handleInvoke = arguments.length > 3 ? arguments[3] : undefined;
59
- var handleAnalytics = arguments.length > 4 ? arguments[4] : undefined;
60
- var testId = arguments.length > 5 ? arguments[5] : undefined;
61
- var platform = arguments.length > 6 ? arguments[6] : undefined;
62
- var source = arguments.length > 7 ? arguments[7] : undefined;
63
- var featureFlags = arguments.length > 8 ? arguments[8] : undefined;
53
+ export var extractPreviewAction = function extractPreviewAction(_ref) {
54
+ var _ref$extensionKey = _ref.extensionKey,
55
+ extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
56
+ viewProps = _ref.viewProps,
57
+ jsonLd = _ref.jsonLd,
58
+ handleInvoke = _ref.handleInvoke,
59
+ testId = _ref.testId,
60
+ platform = _ref.platform,
61
+ origin = _ref.origin,
62
+ _ref$source = _ref.source,
63
+ source = _ref$source === void 0 ? 'block' : _ref$source,
64
+ featureFlags = _ref.featureFlags,
65
+ analytics = _ref.analytics;
64
66
  // Extract metadata from view props & raw JSON-LD.
65
67
  var metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
66
68
  var metadataFromViewProps = getMetadataFromResolvedProps(viewProps);
@@ -72,22 +74,10 @@ export var extractPreviewAction = function extractPreviewAction() {
72
74
  // Build action using instrumentation hooks.
73
75
  var key = extensionKey;
74
76
  var previewAction = PreviewAction(_objectSpread(_objectSpread({}, metadata), {}, {
77
+ analytics: analytics,
78
+ origin: origin,
75
79
  featureFlags: featureFlags,
76
80
  testId: testId,
77
- onOpen: function onOpen() {
78
- handleAnalytics(uiRenderSuccessEvent({
79
- display: 'preview',
80
- status: 'resolved',
81
- extensionKey: key
82
- }));
83
- },
84
- onOpenFailed: function onOpenFailed(error, errorInfo) {
85
- handleAnalytics(uiRenderFailedEvent({
86
- display: 'preview',
87
- error: error,
88
- errorInfo: errorInfo
89
- }));
90
- },
91
81
  onDownloadActionClick: function onDownloadActionClick() {
92
82
  handleInvoke(getInvokeOpts(key, 'DownloadAction'));
93
83
  },
@@ -97,7 +87,7 @@ export var extractPreviewAction = function extractPreviewAction() {
97
87
  })); // Setup props to go through proper Redux 'invocation' flow
98
88
  // for analytics, further state management if required in future.
99
89
 
100
- var previewActionProps = getInvokeOpts(key, 'PreviewAction', source !== null && source !== void 0 ? source : 'block'); // - Promise invoked by the action invocation handler; open preview.
90
+ var previewActionProps = getInvokeOpts(key, 'PreviewAction', source); // - Promise invoked by the action invocation handler; open preview.
101
91
 
102
92
  previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
103
93
 
@@ -7,9 +7,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
 
8
8
  import { useMemo } from 'react';
9
9
  import { getUrl } from '@atlaskit/linking-common';
10
- import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
10
+ import { connectFailedEvent as _connectFailedEvent, connectSucceededEvent as _connectSucceededEvent, context, instrumentEvent, invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
11
11
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
12
- import { getDefinitionId, getExtensionKey, getResourceType, getSubproduct, getProduct } from '../helpers';
12
+ import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
13
13
  import { useSmartLinkContext } from '@atlaskit/link-provider';
14
14
 
15
15
  var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
@@ -120,6 +120,21 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
120
120
  }), commonAttributes));
121
121
  },
122
122
 
123
+ /**
124
+ * This fires an event that represents when a user
125
+ * click a button.
126
+ * @param data A partial analytics event payload
127
+ */
128
+ buttonClickedEvent: function buttonClickedEvent(data) {
129
+ return dispatchAnalytics(applyCommonAttributes({
130
+ action: 'clicked',
131
+ actionSubject: 'button',
132
+ actionSubjectId: data.actionSubjectId,
133
+ attributes: _objectSpread(_objectSpread({}, context), data.attributes),
134
+ eventType: 'ui'
135
+ }, commonAttributes));
136
+ },
137
+
123
138
  /**
124
139
  * This fires an event that represents when a user clicks on a Smart Link.
125
140
  * @param id The unique ID for this Smart Link.
@@ -251,6 +266,20 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
251
266
  }), commonAttributes));
252
267
  },
253
268
 
269
+ /**
270
+ * This fires an event that represents when a user close a modal.
271
+ * @param data A partial analytics event payload
272
+ */
273
+ modalClosedEvent: function modalClosedEvent(data) {
274
+ return dispatchAnalytics(applyCommonAttributes({
275
+ action: 'closed',
276
+ actionSubject: 'modal',
277
+ actionSubjectId: data.actionSubjectId,
278
+ attributes: _objectSpread(_objectSpread({}, context), data.attributes),
279
+ eventType: 'ui'
280
+ }, commonAttributes));
281
+ },
282
+
254
283
  /**
255
284
  * This fires an event that represents when a Smart Link was rendered successfully.
256
285
  * Note: this fires even if the Smart Link request errored out.
@@ -615,6 +644,20 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
615
644
  destinationSubproduct: destinationSubproduct,
616
645
  location: location
617
646
  })), commonAttributes));
647
+ },
648
+
649
+ /**
650
+ * This fires an event that represents when a user view a modal.
651
+ * @param data A partial analytics event payload
652
+ */
653
+ modalViewedEvent: function modalViewedEvent(data) {
654
+ return dispatchAnalytics(applyCommonAttributes({
655
+ action: 'viewed',
656
+ actionSubject: data.name,
657
+ attributes: _objectSpread(_objectSpread({}, context), data.attributes),
658
+ eventType: 'screen',
659
+ name: data.name
660
+ }, commonAttributes));
618
661
  }
619
662
  };
620
663
  }, [commonAttributes, dispatchAnalytics]);
@@ -12,7 +12,8 @@ export function useSmartLinkActions(_ref) {
12
12
  appearance = _ref.appearance,
13
13
  analyticsHandler = _ref.analyticsHandler,
14
14
  _ref$platform = _ref.platform,
15
- platform = _ref$platform === void 0 ? 'web' : _ref$platform;
15
+ platform = _ref$platform === void 0 ? 'web' : _ref$platform,
16
+ origin = _ref.origin;
16
17
  var id = useMemo(function () {
17
18
  return uuid();
18
19
  }, []);
@@ -42,7 +43,8 @@ export function useSmartLinkActions(_ref) {
42
43
  handleInvoke: function handleInvoke(opts) {
43
44
  return linkActions.invoke(opts, appearance);
44
45
  },
45
- handleAnalytics: analyticsHandler,
46
+ analytics: linkAnalytics,
47
+ origin: origin,
46
48
  extensionKey: getExtensionKey(linkState.details),
47
49
  source: appearance
48
50
  }, undefined, platform);
@@ -59,6 +61,6 @@ export function useSmartLinkActions(_ref) {
59
61
  };
60
62
  });
61
63
  setActions(cardActions);
62
- }, [linkState, linkActions, analyticsHandler, appearance, platform, embedModalSize]);
64
+ }, [linkState, linkActions, linkAnalytics, appearance, platform, embedModalSize, origin]);
63
65
  return actions;
64
66
  }
@@ -388,7 +388,7 @@ export var uiRenderFailedEvent = function uiRenderFailedEvent(_ref14) {
388
388
  actionSubject: 'smartLink',
389
389
  action: 'renderFailed',
390
390
  eventType: 'ui',
391
- attributes: {
391
+ attributes: _objectSpread(_objectSpread({}, context), {}, {
392
392
  error: error,
393
393
  errorInfo: errorInfo,
394
394
  display: display,
@@ -397,7 +397,7 @@ export var uiRenderFailedEvent = function uiRenderFailedEvent(_ref14) {
397
397
  destinationProduct: destinationProduct,
398
398
  destinationSubproduct: destinationSubproduct,
399
399
  location: location
400
- }
400
+ })
401
401
  };
402
402
  };
403
403
  export var uiHoverCardViewedEvent = function uiHoverCardViewedEvent(_ref15) {
@@ -121,6 +121,18 @@ export var mocks = {
121
121
  data: {
122
122
  status: 'CompletedStatus'
123
123
  }
124
+ },
125
+ analytics: {
126
+ status: 'resolved',
127
+ details: {
128
+ meta: {
129
+ definitionId: 'spaghetti-id',
130
+ key: 'spaghetti-key',
131
+ resourceType: 'spaghetti-resource',
132
+ subproduct: 'spaghetti-subproduct',
133
+ product: 'spaghetti-product'
134
+ }
135
+ }
124
136
  }
125
137
  };
126
138
  export var fakeResponse = function fakeResponse() {
@@ -232,4 +244,17 @@ export var waitFor = function waitFor() {
232
244
  return new Promise(function (res) {
233
245
  return setTimeout(res, time);
234
246
  });
247
+ };
248
+ export var mockAnalytics = {
249
+ ui: {
250
+ buttonClickedEvent: function buttonClickedEvent() {},
251
+ modalClosedEvent: function modalClosedEvent() {},
252
+ renderSuccessEvent: function renderSuccessEvent() {},
253
+ renderFailedEvent: function renderFailedEvent() {}
254
+ },
255
+ operational: {},
256
+ track: {},
257
+ screen: {
258
+ modalViewedEvent: function modalViewedEvent() {}
259
+ }
235
260
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "22.0.0",
3
+ "version": "22.1.2",
4
4
  "sideEffects": false
5
5
  }
@@ -12,7 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
 
13
13
  import React from 'react';
14
14
  import ReactDOM from 'react-dom';
15
- import { IntlProvider, FormattedMessage } from 'react-intl-next';
15
+ import { FormattedMessage, IntlProvider } from 'react-intl-next';
16
16
  import { messages } from '../../../messages';
17
17
 
18
18
  /*
@@ -62,9 +62,9 @@ function _previewFunction() {
62
62
  ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
63
63
  locale: "en"
64
64
  }, /*#__PURE__*/React.createElement(Modal.default, _extends({}, rest, {
65
- onClose: function onClose() {
65
+ onClose: function onClose(context) {
66
66
  if (popupMountPoint) {
67
- _onClose();
67
+ _onClose(context);
68
68
 
69
69
  ReactDOM.unmountComponentAtNode(popupMountPoint);
70
70
  }