@atlaskit/smart-card 22.0.0 → 22.1.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/extractors/block/index.js +6 -7
  3. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +16 -27
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +43 -0
  5. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +5 -3
  6. package/dist/cjs/utils/analytics/analytics.js +2 -2
  7. package/dist/cjs/utils/mocks.js +28 -2
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/cjs/view/BlockCard/actions/PreviewAction.js +2 -2
  10. package/dist/cjs/view/BlockCard/index.js +6 -5
  11. package/dist/cjs/view/CardWithUrl/component.js +2 -2
  12. package/dist/cjs/view/EmbedCard/index.js +3 -2
  13. package/dist/cjs/view/EmbedModal/components/analytics/index.js +100 -0
  14. package/dist/cjs/view/EmbedModal/components/analytics/types.js +5 -0
  15. package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +5 -10
  16. package/dist/cjs/view/EmbedModal/index.js +54 -15
  17. package/dist/cjs/view/EmbedModal/types.js +9 -1
  18. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -1
  19. package/dist/cjs/view/common/Modal.js +29 -4
  20. package/dist/cjs/view/common/ModalHeader.js +3 -2
  21. package/dist/es2019/extractors/block/index.js +6 -7
  22. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +16 -18
  23. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +46 -3
  24. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +5 -3
  25. package/dist/es2019/utils/analytics/analytics.js +1 -1
  26. package/dist/es2019/utils/mocks.js +26 -1
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/es2019/view/BlockCard/actions/PreviewAction.js +3 -3
  29. package/dist/es2019/view/BlockCard/index.js +5 -4
  30. package/dist/es2019/view/CardWithUrl/component.js +2 -2
  31. package/dist/es2019/view/EmbedCard/index.js +3 -2
  32. package/dist/es2019/view/EmbedModal/components/analytics/index.js +80 -0
  33. package/dist/es2019/view/EmbedModal/components/analytics/types.js +1 -0
  34. package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +5 -9
  35. package/dist/es2019/view/EmbedModal/index.js +46 -13
  36. package/dist/es2019/view/EmbedModal/types.js +6 -1
  37. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +2 -1
  38. package/dist/es2019/view/common/Modal.js +27 -6
  39. package/dist/es2019/view/common/ModalHeader.js +3 -2
  40. package/dist/esm/extractors/block/index.js +6 -7
  41. package/dist/esm/extractors/common/actions/extractPreviewAction.js +17 -27
  42. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +45 -2
  43. package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -3
  44. package/dist/esm/utils/analytics/analytics.js +2 -2
  45. package/dist/esm/utils/mocks.js +25 -0
  46. package/dist/esm/version.json +1 -1
  47. package/dist/esm/view/BlockCard/actions/PreviewAction.js +3 -3
  48. package/dist/esm/view/BlockCard/index.js +5 -4
  49. package/dist/esm/view/CardWithUrl/component.js +2 -2
  50. package/dist/esm/view/EmbedCard/index.js +3 -2
  51. package/dist/esm/view/EmbedModal/components/analytics/index.js +82 -0
  52. package/dist/esm/view/EmbedModal/components/analytics/types.js +1 -0
  53. package/dist/esm/view/EmbedModal/components/size-experiment/index.js +5 -10
  54. package/dist/esm/view/EmbedModal/index.js +52 -15
  55. package/dist/esm/view/EmbedModal/types.js +6 -1
  56. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +2 -1
  57. package/dist/esm/view/common/Modal.js +28 -6
  58. package/dist/esm/view/common/ModalHeader.js +3 -2
  59. package/dist/types/extractors/block/types.d.ts +4 -2
  60. package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +7 -5
  61. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +23 -1
  62. package/dist/types/state/hooks/useSmartLink.d.ts +9 -0
  63. package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +6 -2
  64. package/dist/types/utils/mocks.d.ts +48 -0
  65. package/dist/types/utils/types.d.ts +3 -1
  66. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +4 -0
  67. package/dist/types/view/BlockCard/index.d.ts +2 -2
  68. package/dist/types/view/BlockCard/types.d.ts +4 -4
  69. package/dist/types/view/Card/index.d.ts +1 -1
  70. package/dist/types/view/EmbedCard/types.d.ts +2 -2
  71. package/dist/types/view/EmbedModal/components/analytics/index.d.ts +5 -0
  72. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +6 -0
  73. package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +4 -3
  74. package/dist/types/view/EmbedModal/index.d.ts +3 -1
  75. package/dist/types/view/EmbedModal/types.d.ts +14 -4
  76. package/dist/types/view/common/Modal.d.ts +6 -8
  77. package/package.json +1 -1
  78. package/report.api.md +34 -2
@@ -1,11 +1,21 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useCallback, useState } from 'react';
2
+ import React, { useCallback, useRef, useState } from 'react';
3
3
  import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
4
4
  import LinkInfo from './components/link-info';
5
5
  import { MAX_MODAL_SIZE, MIN_MODAL_SIZE } from './constants';
6
6
  import EmbedContent from './components/embed-content';
7
+ import { EmbedModalSize } from './types';
7
8
  import withErrorBoundary from './components/error-boundary';
8
9
  import withSizeExperiment from './components/size-experiment';
10
+ import withAnalytics from './components/analytics';
11
+
12
+ var toSize = function toSize(width) {
13
+ return width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
14
+ };
15
+
16
+ var toWidth = function toWidth(size) {
17
+ return size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
18
+ };
9
19
 
10
20
  var EmbedModal = function EmbedModal(_ref) {
11
21
  var downloadUrl = _ref.download,
@@ -16,49 +26,76 @@ var EmbedModal = function EmbedModal(_ref) {
16
26
  onClose = _ref.onClose,
17
27
  onDownloadActionClick = _ref.onDownloadActionClick,
18
28
  onOpen = _ref.onOpen,
29
+ onResize = _ref.onResize,
19
30
  onViewActionClick = _ref.onViewActionClick,
20
31
  providerName = _ref.providerName,
21
32
  showModal = _ref.showModal,
22
33
  _ref$size = _ref.size,
23
- defaultSize = _ref$size === void 0 ? MIN_MODAL_SIZE : _ref$size,
34
+ size = _ref$size === void 0 ? EmbedModalSize.Small : _ref$size,
24
35
  src = _ref.src,
25
36
  _ref$testId = _ref.testId,
26
37
  testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
27
38
  title = _ref.title,
28
39
  url = _ref.url;
40
+ var defaultWidth = toWidth(size);
29
41
 
30
42
  var _useState = useState(showModal),
31
43
  _useState2 = _slicedToArray(_useState, 2),
32
44
  isOpen = _useState2[0],
33
45
  setIsOpen = _useState2[1];
34
46
 
35
- var _useState3 = useState(defaultSize),
47
+ var _useState3 = useState(defaultWidth),
36
48
  _useState4 = _slicedToArray(_useState3, 2),
37
- size = _useState4[0],
38
- setSize = _useState4[1];
49
+ width = _useState4[0],
50
+ setWidth = _useState4[1];
51
+
52
+ var openAt = useRef();
53
+ var handleOnOpenComplete = useCallback(function () {
54
+ openAt.current = Date.now();
39
55
 
56
+ if (onOpen) {
57
+ onOpen({
58
+ size: size
59
+ });
60
+ }
61
+ }, [onOpen, size]);
40
62
  var handleOnClose = useCallback(function () {
41
63
  return setIsOpen(false);
42
64
  }, []);
43
- var handleOnSizeClick = useCallback(function () {
44
- var newSize = size === MIN_MODAL_SIZE ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
45
- setSize(newSize);
46
- }, [size]);
65
+ var handleOnCloseComplete = useCallback(function () {
66
+ if (onClose) {
67
+ var duration = openAt.current ? Date.now() - openAt.current : undefined;
68
+ onClose({
69
+ duration: duration,
70
+ size: toSize(width)
71
+ });
72
+ }
73
+ }, [onClose, width]);
74
+ var handleOnResizeClick = useCallback(function () {
75
+ var newWidth = width === MIN_MODAL_SIZE ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
76
+ setWidth(newWidth);
77
+
78
+ if (onResize) {
79
+ onResize({
80
+ size: toSize(newWidth)
81
+ });
82
+ }
83
+ }, [onResize, width]);
47
84
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
48
85
  height: "100%",
49
86
  onClose: handleOnClose,
50
- onCloseComplete: onClose,
51
- onOpenComplete: onOpen,
87
+ onCloseComplete: handleOnCloseComplete,
88
+ onOpenComplete: handleOnOpenComplete,
52
89
  testId: testId,
53
- width: size
90
+ width: width
54
91
  }, /*#__PURE__*/React.createElement(LinkInfo, {
55
92
  downloadUrl: downloadUrl,
56
93
  icon: icon,
57
94
  providerName: providerName,
58
95
  onViewButtonClick: onViewActionClick,
59
96
  onDownloadButtonClick: onDownloadActionClick,
60
- onResizeButtonClick: handleOnSizeClick,
61
- size: size,
97
+ onResizeButtonClick: handleOnResizeClick,
98
+ size: width,
62
99
  title: title,
63
100
  testId: testId,
64
101
  url: url
@@ -70,4 +107,4 @@ var EmbedModal = function EmbedModal(_ref) {
70
107
  }))));
71
108
  };
72
109
 
73
- export default withSizeExperiment(withErrorBoundary(EmbedModal));
110
+ export default withSizeExperiment(withAnalytics(withErrorBoundary(EmbedModal)));
@@ -1 +1,6 @@
1
- export {};
1
+ export var EmbedModalSize;
2
+
3
+ (function (EmbedModalSize) {
4
+ EmbedModalSize["Large"] = "large";
5
+ EmbedModalSize["Small"] = "small";
6
+ })(EmbedModalSize || (EmbedModalSize = {}));
@@ -98,7 +98,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
98
98
  var linkActions = useSmartLinkActions({
99
99
  url: url,
100
100
  appearance: SMART_CARD_ANALYTICS_DISPLAY,
101
- analyticsHandler: analyticsHandler
101
+ analyticsHandler: analyticsHandler,
102
+ origin: 'smartLinkPreviewHoverCard'
102
103
  });
103
104
  var onActionClick = useCallback(function (actionId) {
104
105
  if (actionId === 'preview-content') {
@@ -25,10 +25,12 @@ manually passed to your custom components.
25
25
 
26
26
  For a complete guide on customization using the new compositional API, refer to the docs at
27
27
  https://atlassian.design/components/modal-dialog/examples#customizing-modal-dialog. */
28
- import React, { useState } from 'react';
29
- import ModalDialog, { ModalTransition, ModalBody } from '@atlaskit/modal-dialog';
28
+ import React, { useCallback, useRef, useState } from 'react';
29
+ import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
30
30
  import { Header } from './ModalHeader';
31
31
  import { getIframeSandboxAttribute } from '../../utils';
32
+ import withAnalytics from '../EmbedModal/components/analytics';
33
+ import { EmbedModalSize } from '../EmbedModal/types';
32
34
  var iframeStyles = {
33
35
  width: "100%",
34
36
  height: 'calc(100vh - 248px)'
@@ -72,7 +74,8 @@ var Modal = function Modal(_ref) {
72
74
  providerName = _ref.providerName,
73
75
  metadata = _ref.metadata,
74
76
  icon = _ref.icon,
75
- closeLabel = _ref.closeLabel,
77
+ _ref$closeLabel = _ref.closeLabel,
78
+ closeLabel = _ref$closeLabel === void 0 ? 'Close Preview' : _ref$closeLabel,
76
79
  iframeName = _ref.iframeName,
77
80
  title = _ref.title,
78
81
  url = _ref.url,
@@ -88,16 +91,35 @@ var Modal = function Modal(_ref) {
88
91
  isOpen = _useState2[0],
89
92
  setIsOpen = _useState2[1];
90
93
 
94
+ var openAt = useRef();
95
+ var handleOnOpenComplete = useCallback(function () {
96
+ openAt.current = Date.now();
97
+
98
+ if (onOpen) {
99
+ onOpen({
100
+ size: EmbedModalSize.Small
101
+ });
102
+ }
103
+ }, [onOpen]);
104
+ var handleOnCloseComplete = useCallback(function () {
105
+ if (onClose) {
106
+ var duration = openAt.current ? Date.now() - openAt.current : undefined;
107
+ onClose({
108
+ duration: duration,
109
+ size: EmbedModalSize.Small
110
+ });
111
+ }
112
+ }, [onClose]);
91
113
  var sandbox = getIframeSandboxAttribute(isTrusted);
92
114
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
93
115
  height: "100%",
94
116
  width: "large",
95
117
  testId: testId,
96
- onOpenComplete: onOpen,
118
+ onOpenComplete: handleOnOpenComplete,
97
119
  onClose: function onClose() {
98
120
  setIsOpen(false);
99
121
  },
100
- onCloseComplete: onClose
122
+ onCloseComplete: handleOnCloseComplete
101
123
  }, /*#__PURE__*/React.createElement(Header, {
102
124
  providerName: providerName,
103
125
  icon: icon,
@@ -123,4 +145,4 @@ var Modal = function Modal(_ref) {
123
145
  }))));
124
146
  };
125
147
 
126
- export default ModalWithErrorBoundary;
148
+ export default withAnalytics(ModalWithErrorBoundary);
@@ -75,7 +75,7 @@ export var Header = function Header(_ref) {
75
75
  testId: "preview-view-action",
76
76
  iconAfter: jsx(ShortcutIcon, {
77
77
  size: "small",
78
- label: "go to source"
78
+ label: ""
79
79
  }),
80
80
  onClick: onViewActionClick
81
81
  }, providerName ? jsx(F, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal)), jsx(Button, {
@@ -83,6 +83,7 @@ export var Header = function Header(_ref) {
83
83
  iconBefore: jsx(EditorCloseIcon, {
84
84
  label: label
85
85
  }),
86
- onClick: onClose
86
+ onClick: onClose,
87
+ testId: "preview-close-button"
87
88
  }))));
88
89
  };
@@ -1,10 +1,12 @@
1
1
  import { LinkingPlatformFeatureFlags } from '@atlaskit/linking-common';
2
2
  import { InvokeHandler } from '../../model/invoke-handler';
3
- import { AnalyticsHandler } from '../../utils/types';
3
+ import { AnalyticsFacade } from '../../state/analytics';
4
4
  import { CardInnerAppearance } from '../../view/Card/types';
5
+ import { AnalyticsOrigin } from '../../utils/types';
5
6
  export interface ExtractBlockOpts {
6
7
  handleInvoke: InvokeHandler;
7
- handleAnalytics: AnalyticsHandler;
8
+ analytics: AnalyticsFacade;
9
+ origin?: AnalyticsOrigin;
8
10
  extensionKey?: string;
9
11
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
10
12
  source?: CardInnerAppearance;
@@ -1,7 +1,9 @@
1
1
  import { JsonLd } from 'json-ld-types';
2
- import { LinkingPlatformFeatureFlags } from '@atlaskit/linking-common';
3
- import { InvokeHandler } from '../../../model/invoke-handler';
4
- import { CardInnerAppearance } from '../../../view/Card/types';
5
- import { AnalyticsHandler } from '../../../utils/types';
2
+ import { CardPlatform } from '../../../view/Card/types';
6
3
  import { BlockCardResolvedViewProps } from '../../../view/BlockCard';
7
- export declare const extractPreviewAction: (extensionKey: string | undefined, viewProps: BlockCardResolvedViewProps, jsonLd: JsonLd.Data.BaseData, handleInvoke: InvokeHandler, handleAnalytics: AnalyticsHandler, testId?: string | undefined, platform?: JsonLd.Primitives.Platforms | undefined, source?: CardInnerAppearance | undefined, featureFlags?: Partial<LinkingPlatformFeatureFlags> | undefined) => import("../../../view/BlockCard/components/Action").ActionProps | undefined;
4
+ import { ExtractBlockOpts } from '../../block/types';
5
+ export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, featureFlags, analytics, }: ExtractBlockOpts & {
6
+ viewProps: BlockCardResolvedViewProps;
7
+ jsonLd: JsonLd.Data.BaseData;
8
+ platform?: JsonLd.Primitives.Platforms | undefined;
9
+ }) => import("../../../view/BlockCard/components/Action").ActionProps | undefined;
@@ -1,4 +1,4 @@
1
- import { AnalyticsHandler } from '../../utils/types';
1
+ import { AnalyticsHandler, AnalyticsName, AnalyticsPayload } from '../../utils/types';
2
2
  import { ConnectFailedEventProps, ConnectSucceededEventProps, InstrumentEventProps, InvokeFailedEventProps, InvokeSucceededEventProps, ScreenAuthPopupEventProps, TrackAppAccountConnectedProps, UiActionClickedEventProps, UiAuthAlternateAccountEventProps, UiAuthEventProps, UiCardClickedEventProps, UiClosedAuthEventProps, UiHoverCardDismissedEventProps, UiHoverCardOpenLinkClickedEventProps, UiHoverCardViewedEventProps, UiRenderFailedEventProps, UiRenderSuccessEventProps } from '../../utils/analytics/types';
3
3
  /**
4
4
  * This hook provides usage of Smart Link analytics outside of the Card component.
@@ -29,6 +29,14 @@ export declare const useSmartLinkAnalytics: (url: string, dispatchAnalytics: Ana
29
29
  * @returns
30
30
  */
31
31
  authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiAuthAlternateAccountEventProps) => void;
32
+ /**
33
+ * This fires an event that represents when a user
34
+ * click a button.
35
+ * @param data A partial analytics event payload
36
+ */
37
+ buttonClickedEvent: (data: Partial<AnalyticsPayload> & {
38
+ actionSubjectId: Required<string>;
39
+ }) => void;
32
40
  /**
33
41
  * This fires an event that represents when a user clicks on a Smart Link.
34
42
  * @param id The unique ID for this Smart Link.
@@ -70,6 +78,13 @@ export declare const useSmartLinkAnalytics: (url: string, dispatchAnalytics: Ana
70
78
  * @returns
71
79
  */
72
80
  closedAuthEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiClosedAuthEventProps) => void;
81
+ /**
82
+ * This fires an event that represents when a user close a modal.
83
+ * @param data A partial analytics event payload
84
+ */
85
+ modalClosedEvent: (data: Partial<AnalyticsPayload> & {
86
+ actionSubjectId: Required<string>;
87
+ }) => void;
73
88
  /**
74
89
  * This fires an event that represents when a Smart Link was rendered successfully.
75
90
  * Note: this fires even if the Smart Link request errored out.
@@ -168,6 +183,13 @@ export declare const useSmartLinkAnalytics: (url: string, dispatchAnalytics: Ana
168
183
  * @returns
169
184
  */
170
185
  authPopupEvent: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: ScreenAuthPopupEventProps) => void;
186
+ /**
187
+ * This fires an event that represents when a user view a modal.
188
+ * @param data A partial analytics event payload
189
+ */
190
+ modalViewedEvent: (data: Partial<AnalyticsPayload> & {
191
+ name: Extract<AnalyticsName, 'embedPreviewModal'>;
192
+ }) => void;
171
193
  };
172
194
  };
173
195
  export declare type AnalyticsFacade = ReturnType<typeof useSmartLinkAnalytics>;
@@ -13,10 +13,16 @@ export declare function useSmartLink(id: string, url: string, dispatchAnalytics:
13
13
  ui: {
14
14
  authEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiAuthEventProps) => void;
15
15
  authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiAuthAlternateAccountEventProps) => void;
16
+ buttonClickedEvent: (data: Partial<import("../../utils/types").AnalyticsPayload> & {
17
+ actionSubjectId: string;
18
+ }) => void;
16
19
  cardClickedEvent: ({ id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId, }: import("../../utils/analytics/types").UiCardClickedEventProps) => void;
17
20
  actionClickedEvent: ({ id, actionType, display, invokeType, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiActionClickedEventProps) => void;
18
21
  hoverCardOpenLinkClickedEvent: ({ previewDisplay, definitionId, extensionKey, destinationProduct, destinationSubproduct, location, previewInvokeMethod, }: import("../../utils/analytics/types").UiHoverCardOpenLinkClickedEventProps) => void;
19
22
  closedAuthEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiClosedAuthEventProps) => void;
23
+ modalClosedEvent: (data: Partial<import("../../utils/types").AnalyticsPayload> & {
24
+ actionSubjectId: string;
25
+ }) => void;
20
26
  renderSuccessEvent: ({ display, status, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiRenderSuccessEventProps) => void;
21
27
  renderFailedEvent: ({ display, id, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiRenderFailedEventProps) => void;
22
28
  hoverCardViewedEvent: ({ previewDisplay, previewInvokeMethod, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiHoverCardViewedEventProps) => void;
@@ -34,6 +40,9 @@ export declare function useSmartLink(id: string, url: string, dispatchAnalytics:
34
40
  };
35
41
  screen: {
36
42
  authPopupEvent: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").CommonEventProps) => void;
43
+ modalViewedEvent: (data: Partial<import("../../utils/types").AnalyticsPayload> & {
44
+ name: "embedPreviewModal";
45
+ }) => void;
37
46
  };
38
47
  };
39
48
  renderers: import("@atlaskit/link-provider").CardProviderRenderers | undefined;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { JsonLd } from 'json-ld-types';
3
- import type { AnalyticsHandler } from '../../utils/types';
3
+ import type { AnalyticsHandler, AnalyticsOrigin } from '../../utils/types';
4
4
  import type { CardInnerAppearance } from '../../view/Card/types';
5
5
  export interface LinkAction {
6
6
  /**
@@ -41,5 +41,9 @@ export interface UseSmartLinkActionsOpts {
41
41
  * @default 'web'
42
42
  */
43
43
  platform?: JsonLd.Primitives.Platforms;
44
+ /**
45
+ * Smart link origin that the action being invoked from.
46
+ */
47
+ origin?: AnalyticsOrigin;
44
48
  }
45
- export declare function useSmartLinkActions({ url, appearance, analyticsHandler, platform, }: UseSmartLinkActionsOpts): LinkAction[];
49
+ export declare function useSmartLinkActions({ url, appearance, analyticsHandler, platform, origin, }: UseSmartLinkActionsOpts): LinkAction[];
@@ -20,7 +20,55 @@ export declare const mocks: {
20
20
  status: string;
21
21
  };
22
22
  };
23
+ analytics: {
24
+ status: string;
25
+ details: {
26
+ meta: {
27
+ definitionId: string;
28
+ key: string;
29
+ resourceType: string;
30
+ subproduct: string;
31
+ product: string;
32
+ };
33
+ };
34
+ };
23
35
  };
24
36
  export declare const fakeResponse: () => Promise<JsonLd.Response<JsonLd.Data.BaseData>>;
25
37
  export declare const fakeFactory: any;
26
38
  export declare const waitFor: (time?: number) => Promise<unknown>;
39
+ export declare const mockAnalytics: {
40
+ ui: {
41
+ authEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiAuthEventProps) => void;
42
+ authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiAuthAlternateAccountEventProps) => void;
43
+ buttonClickedEvent: (data: Partial<import("./types").AnalyticsPayload> & {
44
+ actionSubjectId: string;
45
+ }) => void;
46
+ cardClickedEvent: ({ id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId, }: import("./analytics/types").UiCardClickedEventProps) => void;
47
+ actionClickedEvent: ({ id, actionType, display, invokeType, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiActionClickedEventProps) => void;
48
+ hoverCardOpenLinkClickedEvent: ({ previewDisplay, definitionId, extensionKey, destinationProduct, destinationSubproduct, location, previewInvokeMethod, }: import("./analytics/types").UiHoverCardOpenLinkClickedEventProps) => void;
49
+ closedAuthEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiClosedAuthEventProps) => void;
50
+ modalClosedEvent: (data: Partial<import("./types").AnalyticsPayload> & {
51
+ actionSubjectId: string;
52
+ }) => void;
53
+ renderSuccessEvent: ({ display, status, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiRenderSuccessEventProps) => void;
54
+ renderFailedEvent: ({ display, id, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiRenderFailedEventProps) => void;
55
+ hoverCardViewedEvent: ({ previewDisplay, previewInvokeMethod, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiHoverCardViewedEventProps) => void;
56
+ hoverCardDismissedEvent: ({ id, previewDisplay, hoverTime, previewInvokeMethod, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").UiHoverCardDismissedEventProps) => void;
57
+ };
58
+ operational: {
59
+ invokeSucceededEvent: ({ id, actionType, display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").InvokeSucceededEventProps) => void;
60
+ invokeFailedEvent: ({ id, actionType, display, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").InvokeFailedEventProps) => void;
61
+ connectSucceededEvent: ({ id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").ConnectSucceededEventProps) => void;
62
+ connectFailedEvent: ({ id, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").ConnectFailedEventProps) => void;
63
+ instrument: ({ id, status, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, error, }: import("./analytics/types").InstrumentEventProps) => void;
64
+ };
65
+ track: {
66
+ appAccountConnected: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").CommonEventProps) => void;
67
+ };
68
+ screen: {
69
+ authPopupEvent: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("./analytics/types").CommonEventProps) => void;
70
+ modalViewedEvent: (data: Partial<import("./types").AnalyticsPayload> & {
71
+ name: "embedPreviewModal";
72
+ }) => void;
73
+ };
74
+ };
@@ -1,7 +1,9 @@
1
1
  import { GasPayload } from '@atlaskit/analytics-gas-types';
2
2
  import { CardInnerAppearance } from '../view/Card/types';
3
3
  export declare type AnalyticsAction = 'resolved' | 'unresolved' | 'connectSucceeded' | 'connectFailed' | 'connected' | 'clicked' | 'closed' | 'renderFailed' | 'renderWithStatus' | 'renderSuccess' | 'inserted' | 'viewed' | 'dismissed' | 'created';
4
- export declare type AnalyticsActionSubject = 'smartLink' | 'smartLinkAction' | 'applicationAccount' | 'button' | 'consentModal' | 'hoverCard';
4
+ export declare type AnalyticsActionSubject = 'smartLink' | 'smartLinkAction' | 'applicationAccount' | 'button' | 'consentModal' | 'hoverCard' | 'modal' | 'embedPreviewModal';
5
+ export declare type AnalyticsName = 'embedPreviewModal';
6
+ export declare type AnalyticsOrigin = 'smartLinkCard' | 'smartLinkEmbed' | 'smartLinkInline' | 'smartLinkPreviewHoverCard';
5
7
  export declare type AnalyticsPayload = GasPayload & {
6
8
  action?: AnalyticsAction;
7
9
  actionSubject: AnalyticsActionSubject;
@@ -1,9 +1,11 @@
1
1
  import React, { ErrorInfo } from 'react';
2
2
  import { LinkingPlatformFeatureFlags } from '@atlaskit/linking-common';
3
+ import { AnalyticsFacade } from '../../../state/analytics';
3
4
  import { EmbedModalWithExperimentProps } from '../../EmbedModal/types';
4
5
  import { ActionProps } from '../components/Action';
5
6
  import { IconProps } from '../../common/Icon';
6
7
  import { MetadataProps } from '../../common/Metadata';
8
+ import { AnalyticsOrigin } from '../../../utils/types';
7
9
  export interface PreviewFunctionArg extends EmbedModalWithExperimentProps {
8
10
  popupMountPointId: string;
9
11
  }
@@ -23,6 +25,8 @@ declare type PreviewInfo = {
23
25
  onOpen?: () => void;
24
26
  onOpenFailed?: (error: Error, errorInfo: ErrorInfo) => void;
25
27
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
28
+ analytics: AnalyticsFacade;
29
+ origin?: AnalyticsOrigin;
26
30
  };
27
31
  declare const _default: ({ details, ...rest }: PreviewInfo) => ActionProps;
28
32
  export default _default;
@@ -1,14 +1,14 @@
1
1
  import { FC } from 'react';
2
2
  import { BlockCardProps } from './types';
3
- export { default as PreviewAction } from './actions/PreviewAction';
4
3
  import { AuthorizeAction } from './actions/AuthorizeAction';
5
4
  import { ForbiddenAction } from './actions/ForbiddenAction';
6
5
  import { ResolvedView as BlockCardResolvedView } from './views/ResolvedView';
7
- export type { ResolvedViewProps as BlockCardResolvedViewProps } from './views/ResolvedView';
8
6
  import { NotFoundView as BlockCardNotFoundView } from './views/NotFoundView';
9
7
  import { ResolvingView as BlockCardResolvingView } from './views/ResolvingView';
10
8
  import { UnauthorizedView as BlockCardUnauthorisedView } from './views/UnauthorizedView';
11
9
  import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
12
10
  import { ErroredView as BlockCardErroredView } from './views/ErroredView';
11
+ export { default as PreviewAction } from './actions/PreviewAction';
12
+ export type { ResolvedViewProps as BlockCardResolvedViewProps } from './views/ResolvedView';
13
13
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView, };
14
14
  export declare const BlockCard: FC<BlockCardProps>;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { CardProviderRenderers, CardAuthFlowOpts } from '@atlaskit/link-provider';
2
+ import { CardAuthFlowOpts, CardProviderRenderers } from '@atlaskit/link-provider';
3
3
  import { CardState } from '../../state/types';
4
4
  import { InvokeHandler } from '../../model/invoke-handler';
5
- import { AnalyticsHandler } from '../../utils/types';
6
- import { OnResolveCallback, CardPlatform } from '../Card/types';
5
+ import { CardPlatform, OnResolveCallback } from '../Card/types';
7
6
  import { OnErrorCallback } from '../types';
7
+ import { AnalyticsFacade } from '../../state/analytics';
8
8
  export declare type BlockCardProps = {
9
9
  id: string;
10
10
  url: string;
@@ -12,7 +12,6 @@ export declare type BlockCardProps = {
12
12
  authFlow?: CardAuthFlowOpts['authFlow'];
13
13
  handleAuthorize: (() => void) | undefined;
14
14
  handleErrorRetry: () => void;
15
- handleAnalytics: AnalyticsHandler;
16
15
  handleInvoke: InvokeHandler;
17
16
  handleFrameClick: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
18
17
  isSelected?: boolean;
@@ -22,4 +21,5 @@ export declare type BlockCardProps = {
22
21
  showActions?: boolean;
23
22
  renderers?: CardProviderRenderers;
24
23
  platform?: CardPlatform;
24
+ analytics: AnalyticsFacade;
25
25
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "id" | "placeholder" | "onError" | "onClick" | "analyticsContext" | "key" | "url" | "ui" | "showHoverPreview" | "showActions" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "id" | "placeholder" | "onError" | "onClick" | "analyticsContext" | "key" | "url" | "ui" | "showActions" | "showHoverPreview" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -1,18 +1,18 @@
1
1
  import { CardState } from '../../state/types';
2
2
  import { InvokeHandler } from '../../model/invoke-handler';
3
- import { AnalyticsHandler } from '../../utils/types';
4
3
  import { CardPlatform, OnResolveCallback } from '../Card/types';
5
4
  import { ReactNode } from 'react';
6
5
  import { ActionProps } from '../BlockCard/components/Action';
7
6
  import { RequestAccessMessageKey } from '../../messages';
8
7
  import { OnErrorCallback } from '../types';
8
+ import { AnalyticsFacade } from '../../state/analytics';
9
9
  export declare type EmbedCardProps = {
10
10
  url: string;
11
11
  cardState: CardState;
12
12
  handleAuthorize: (() => void) | undefined;
13
13
  handleErrorRetry: () => void;
14
14
  handleFrameClick: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
15
- handleAnalytics: AnalyticsHandler;
15
+ analytics: AnalyticsFacade;
16
16
  handleInvoke: InvokeHandler;
17
17
  id?: string;
18
18
  isSelected?: boolean;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { EmbedModalProps } from '../../types';
3
+ import { WithAnalytics } from './types';
4
+ declare const withAnalytics: (Component: React.ComponentType<EmbedModalProps>) => React.FC<EmbedModalProps & WithAnalytics>;
5
+ export default withAnalytics;
@@ -0,0 +1,6 @@
1
+ import { AnalyticsFacade } from '../../../../state/analytics';
2
+ import { AnalyticsOrigin } from '../../../../utils/types';
3
+ export declare type WithAnalytics = {
4
+ analytics: AnalyticsFacade;
5
+ origin?: AnalyticsOrigin;
6
+ };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { ModalProps } from '../../../common/Modal';
3
- import { EmbedModalProps } from '../../types';
2
+ import Modal from '../../../common/Modal';
4
3
  import { WithSizeExperimentProps } from './types';
5
- declare const withSizeExperiment: (Component: React.ComponentType<EmbedModalProps>) => React.FC<(EmbedModalProps | ModalProps) & WithSizeExperimentProps>;
4
+ declare const withSizeExperiment: <Props, Component>(Component: React.ComponentType<Props>) => React.FC<Props & import("../../types").EmbedModalProps & import("../analytics/types").WithAnalytics & {
5
+ children?: React.ReactNode;
6
+ } & WithSizeExperimentProps>;
6
7
  export default withSizeExperiment;
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
2
  import { EmbedModalProps } from './types';
3
- declare const _default: React.FC<(import("../common/Modal").ModalProps | EmbedModalProps) & import("./components/size-experiment/types").WithSizeExperimentProps>;
3
+ declare const _default: React.FC<EmbedModalProps & import("./components/analytics/types").WithAnalytics & {
4
+ children?: React.ReactNode;
5
+ } & import("./components/size-experiment/types").WithSizeExperimentProps>;
4
6
  export default _default;
@@ -2,23 +2,33 @@ import { ErrorInfo } from 'react';
2
2
  import { IconProps } from '../common/Icon';
3
3
  import { WithSizeExperimentProps } from './components/size-experiment/types';
4
4
  import { ModalProps } from '../common/Modal';
5
+ import { WithAnalytics } from './components/analytics/types';
6
+ export declare enum EmbedModalSize {
7
+ Large = "large",
8
+ Small = "small"
9
+ }
10
+ export declare type EmbedModalContext = {
11
+ duration?: number;
12
+ size: EmbedModalSize;
13
+ };
5
14
  export declare type EmbedModalProps = {
6
15
  closeLabel?: string;
7
16
  download?: string;
8
17
  icon?: IconProps;
9
18
  iframeName: string;
10
19
  isTrusted?: boolean;
11
- onClose: () => any;
20
+ onClose: (context: EmbedModalContext) => void;
12
21
  onDownloadActionClick?: () => void;
13
- onOpen?: () => void;
22
+ onOpen?: (context: EmbedModalContext) => void;
14
23
  onOpenFailed?: (error: Error, errorInfo: ErrorInfo) => void;
24
+ onResize?: (context: EmbedModalContext) => void;
15
25
  onViewActionClick?: () => void;
16
26
  providerName?: string;
17
27
  showModal?: boolean;
18
- size?: string;
28
+ size?: EmbedModalSize;
19
29
  src?: string;
20
30
  testId?: string;
21
31
  title?: string;
22
32
  url?: string;
23
33
  };
24
- export declare type EmbedModalWithExperimentProps = EmbedModalProps & ModalProps & WithSizeExperimentProps;
34
+ export declare type EmbedModalWithExperimentProps = EmbedModalProps & ModalProps & WithSizeExperimentProps & WithAnalytics;
@@ -1,15 +1,16 @@
1
1
  import React, { ErrorInfo } from 'react';
2
2
  import { IconProps } from './Icon';
3
3
  import { MetadataListProps } from './MetadataList';
4
+ import { EmbedModalContext } from '../EmbedModal/types';
4
5
  export interface ModalProps {
5
- onClose: () => any;
6
- onOpen?: () => void;
6
+ onClose: (context: EmbedModalContext) => void;
7
+ onOpen?: (context: EmbedModalContext) => void;
7
8
  onOpenFailed?: (error: Error, errorInfo: ErrorInfo) => void;
8
9
  src?: string;
9
10
  showModal?: boolean;
10
11
  iframeName: string;
11
12
  providerName?: string;
12
- closeLabel: string;
13
+ closeLabel?: string;
13
14
  url?: string;
14
15
  title?: string;
15
16
  metadata?: MetadataListProps;
@@ -21,8 +22,5 @@ export interface ModalProps {
21
22
  onDownloadActionClick?: () => void;
22
23
  testId?: string;
23
24
  }
24
- declare class ModalWithErrorBoundary extends React.Component<ModalProps> {
25
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
26
- render(): JSX.Element;
27
- }
28
- export default ModalWithErrorBoundary;
25
+ declare const _default: React.FC<import("../EmbedModal/types").EmbedModalProps & import("../EmbedModal/components/analytics/types").WithAnalytics>;
26
+ export default _default;