@atlaskit/smart-card 32.3.0 → 32.5.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 (41) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/analytics.spec.yaml +100 -0
  3. package/dist/cjs/state/actions/index.js +35 -11
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +5 -1
  5. package/dist/cjs/utils/analytics/analytics.js +21 -1
  6. package/dist/cjs/utils/analytics/index.js +3 -0
  7. package/dist/cjs/view/CardWithUrl/component.js +33 -10
  8. package/dist/cjs/view/CardWithUrl/loader.js +19 -6
  9. package/dist/cjs/view/EmbedCard/index.js +33 -4
  10. package/dist/cjs/view/LinkUrl/index.js +1 -1
  11. package/dist/es2019/state/actions/index.js +35 -11
  12. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -1
  13. package/dist/es2019/utils/analytics/analytics.js +21 -1
  14. package/dist/es2019/utils/analytics/index.js +4 -0
  15. package/dist/es2019/view/CardWithUrl/component.js +33 -10
  16. package/dist/es2019/view/CardWithUrl/loader.js +20 -6
  17. package/dist/es2019/view/EmbedCard/index.js +35 -5
  18. package/dist/es2019/view/LinkUrl/index.js +1 -1
  19. package/dist/esm/state/actions/index.js +35 -11
  20. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +5 -1
  21. package/dist/esm/utils/analytics/analytics.js +21 -1
  22. package/dist/esm/utils/analytics/index.js +4 -0
  23. package/dist/esm/view/CardWithUrl/component.js +33 -10
  24. package/dist/esm/view/CardWithUrl/loader.js +19 -6
  25. package/dist/esm/view/EmbedCard/index.js +33 -4
  26. package/dist/esm/view/LinkUrl/index.js +1 -1
  27. package/dist/types/common/analytics/generated/analytics.types.d.ts +38 -1
  28. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  29. package/dist/types/utils/analytics/analytics.d.ts +15 -0
  30. package/dist/types/utils/analytics/index.d.ts +3 -0
  31. package/dist/types/utils/analytics/types.d.ts +12 -0
  32. package/dist/types/view/EmbedCard/types.d.ts +2 -0
  33. package/dist/types/view/FlexibleCard/components/blocks/ai-footer-block/icons/info/index.d.ts +2 -2
  34. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +38 -1
  35. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  36. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +15 -0
  37. package/dist/types-ts4.5/utils/analytics/index.d.ts +3 -0
  38. package/dist/types-ts4.5/utils/analytics/types.d.ts +12 -0
  39. package/dist/types-ts4.5/view/EmbedCard/types.d.ts +2 -0
  40. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-footer-block/icons/info/index.d.ts +2 -2
  41. package/package.json +13 -7
@@ -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: "32.3.0"
7
+ packageVersion: "32.5.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -51,6 +51,10 @@ export const fireSmartLinkEvent = (payload, createAnalyticsEvent) => {
51
51
  createAnalyticsEvent(payload).fire(ANALYTICS_CHANNEL);
52
52
  }
53
53
  };
54
+
55
+ /**
56
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
57
+ */
54
58
  export const resolvedEvent = props => ({
55
59
  action: 'resolved',
56
60
  actionSubject: 'smartLink',
@@ -60,6 +64,10 @@ export const resolvedEvent = props => ({
60
64
  ...context
61
65
  }
62
66
  });
67
+
68
+ /**
69
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
70
+ */
63
71
  export const unresolvedEvent = ({
64
72
  id,
65
73
  definitionId,
@@ -163,6 +171,10 @@ export const invokeFailedEvent = ({
163
171
  }
164
172
  };
165
173
  };
174
+
175
+ /**
176
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
177
+ */
166
178
  export const connectSucceededEvent = ({
167
179
  definitionId,
168
180
  extensionKey,
@@ -182,6 +194,10 @@ export const connectSucceededEvent = ({
182
194
  location
183
195
  }
184
196
  });
197
+
198
+ /**
199
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
200
+ */
185
201
  export const connectFailedEvent = ({
186
202
  definitionId,
187
203
  extensionKey,
@@ -465,6 +481,10 @@ export const uiLearnMoreLinkClickedEvent = () => ({
465
481
  ...context
466
482
  }
467
483
  });
484
+
485
+ /**
486
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
487
+ */
468
488
  export const chunkloadFailedEvent = ({
469
489
  display,
470
490
  error,
@@ -1,6 +1,10 @@
1
1
  import { getMeasure } from '../performance';
2
2
  import { resolvedEvent, unresolvedEvent } from './analytics';
3
3
  export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, chunkloadFailedEvent, connectSucceededEvent, connectFailedEvent, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent, uiSmartLinkStatusLozengeButtonClicked, uiSmartLinkStatusListItemButtonClicked, uiSmartLinkStatusOpenPreviewButtonClicked } from './analytics';
4
+
5
+ /**
6
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
7
+ */
4
8
  export const instrumentEvent = ({
5
9
  id,
6
10
  status,
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
4
5
  import { CardDisplay } from '../../constants';
5
6
  import { useSmartLink } from '../../state';
@@ -116,18 +117,39 @@ function Component({
116
117
  useEffect(() => {
117
118
  measure.mark(id, state.status);
118
119
  if (state.status !== 'pending' && state.status !== 'resolving') {
119
- var _state$error;
120
120
  measure.create(id, state.status);
121
- analytics.operational.instrument({
122
- id,
123
- status: state.status,
124
- definitionId,
125
- extensionKey: extensionKey !== null && extensionKey !== void 0 ? extensionKey : (_state$error = state.error) === null || _state$error === void 0 ? void 0 : _state$error.extensionKey,
126
- resourceType,
127
- error: state.error
128
- });
121
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
122
+ var _state$error;
123
+ if (state.status === 'resolved') {
124
+ var _measure$getMeasure$d, _measure$getMeasure;
125
+ fireEvent('operational.smartLink.resolved', {
126
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
127
+ duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(id, state.status)) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null
128
+ });
129
+ } else if (((_state$error = state.error) === null || _state$error === void 0 ? void 0 : _state$error.type) !== 'ResolveUnsupportedError') {
130
+ fireEvent('operational.smartLink.unresolved', {
131
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
132
+ reason: state.status,
133
+ error: state.error === undefined ? null : {
134
+ name: state.error.name,
135
+ kind: state.error.kind,
136
+ type: state.error.type
137
+ }
138
+ });
139
+ }
140
+ } else {
141
+ var _state$error2;
142
+ analytics.operational.instrument({
143
+ id,
144
+ status: state.status,
145
+ definitionId,
146
+ extensionKey: extensionKey !== null && extensionKey !== void 0 ? extensionKey : (_state$error2 = state.error) === null || _state$error2 === void 0 ? void 0 : _state$error2.extensionKey,
147
+ resourceType,
148
+ error: state.error
149
+ });
150
+ }
129
151
  }
130
- }, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational]);
152
+ }, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational, fireEvent]);
131
153
 
132
154
  // NB: once the smart-card has rendered into an end state, we capture
133
155
  // this as a successful render. These can be one of:
@@ -243,6 +265,7 @@ function Component({
243
265
  return /*#__PURE__*/React.createElement(EmbedCard, {
244
266
  id: id,
245
267
  url: url,
268
+ renderers: renderers,
246
269
  cardState: state,
247
270
  iframeUrlType: embedIframeUrlType,
248
271
  handleAuthorize: services.length && handleAuthorize || undefined,
@@ -2,6 +2,8 @@ import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
2
2
  import { ErrorBoundary } from 'react-error-boundary';
3
3
  import { di } from 'react-magnetic-di';
4
4
  import uuid from 'uuid';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
5
7
  import { useSmartLinkAnalytics } from '../../state/analytics';
6
8
  import { importWithRetry } from '../../utils';
7
9
  import { isFlexibleUiCard } from '../../utils/flexible';
@@ -10,6 +12,9 @@ import { LoadingCardLink } from './component-lazy/LoadingCardLink';
10
12
  export const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => importWithRetry(() => import( /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */'./component-lazy/index')));
11
13
  export function CardWithURLRenderer(props) {
12
14
  const [id] = useState(() => props.id ? props.id : uuid());
15
+ const {
16
+ fireEvent
17
+ } = useAnalyticsEvents();
13
18
  useEffect(() => {
14
19
  // ComponentWillUnmount
15
20
  return () => {
@@ -60,11 +65,20 @@ export function CardWithURLRenderer(props) {
60
65
  // to the reliability of the smart-card front-end components.
61
66
  // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
62
67
  if (error.name === 'ChunkLoadError') {
63
- analytics.operational.chunkloadFailedEvent({
64
- display: appearance,
65
- error,
66
- errorInfo
67
- });
68
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
69
+ fireEvent('operational.smartLink.chunkLoadFailed', {
70
+ display: appearance,
71
+ error: error,
72
+ errorInfo: errorInfo,
73
+ definitionId: null
74
+ });
75
+ } else {
76
+ analytics.operational.chunkloadFailedEvent({
77
+ display: appearance,
78
+ error,
79
+ errorInfo
80
+ });
81
+ }
68
82
  } else if (error.name !== 'APIError') {
69
83
  analytics.ui.renderFailedEvent({
70
84
  display: isFlexibleUi ? 'flexible' : appearance,
@@ -78,7 +92,7 @@ export function CardWithURLRenderer(props) {
78
92
  url: url !== null && url !== void 0 ? url : '',
79
93
  err: error
80
94
  });
81
- }, [analytics.operational, analytics.ui, appearance, id, onError, url, isFlexibleUi]);
95
+ }, [analytics.operational, analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
82
96
  if (!url) {
83
97
  throw new Error('@atlaskit/smart-card: url property is missing.');
84
98
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { extractBlockProps } from '../../extractors/block';
5
6
  import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
6
7
  import { extractEmbedProps } from '../../extractors/embed';
@@ -8,6 +9,7 @@ import { extractInlineProps } from '../../extractors/inline';
8
9
  import { getExtensionKey, hasAuthScopeOverrides } from '../../state/helpers';
9
10
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
10
11
  import { BlockCardResolvedView, BlockCardResolvingView } from '../BlockCard';
12
+ import FlexibleResolvedView from '../BlockCard/views/flexible/FlexibleResolvedView';
11
13
  import { InlineCardResolvedView } from '../InlineCard/ResolvedView';
12
14
  import { EmbedCardErroredView } from './views/ErroredView';
13
15
  import ForbiddenView from './views/forbidden-view';
@@ -16,10 +18,7 @@ import { EmbedCardResolvedView } from './views/ResolvedView';
16
18
  import UnauthorizedView from './views/unauthorized-view';
17
19
  export const EmbedCard = /*#__PURE__*/React.forwardRef(({
18
20
  url,
19
- cardState: {
20
- status,
21
- details
22
- },
21
+ cardState,
23
22
  handleAuthorize,
24
23
  handleErrorRetry,
25
24
  handleFrameClick,
@@ -35,12 +34,17 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
35
34
  onIframeDwell,
36
35
  onIframeFocus,
37
36
  iframeUrlType,
38
- actionOptions
37
+ actionOptions,
38
+ renderers
39
39
  }, iframeRef) => {
40
40
  var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
41
41
  const {
42
42
  createAnalyticsEvent
43
43
  } = useAnalyticsEvents();
44
+ const {
45
+ status,
46
+ details
47
+ } = cardState;
44
48
  const data = details && details.data || getEmptyJsonLd();
45
49
  const meta = details && details.meta;
46
50
  const extensionKey = getExtensionKey(details);
@@ -48,6 +52,19 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
48
52
  switch (status) {
49
53
  case 'pending':
50
54
  case 'resolving':
55
+ if (fg('smart-card-remove-block-card-from-embed')) {
56
+ return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
57
+ url: url,
58
+ cardState: cardState,
59
+ onClick: handleFrameClick,
60
+ onError: onError,
61
+ onResolve: onResolve,
62
+ renderers: renderers,
63
+ actionOptions: actionOptions,
64
+ analytics: analytics,
65
+ testId: testId
66
+ });
67
+ }
51
68
  return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
52
69
  testId: "embed-card-resolving-view",
53
70
  inheritDimensions: inheritDimensions,
@@ -83,6 +100,19 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
83
100
  onClick: handleFrameClick
84
101
  }));
85
102
  }
103
+ if (fg('smart-card-remove-block-card-from-embed')) {
104
+ return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
105
+ url: url,
106
+ cardState: cardState,
107
+ onClick: handleFrameClick,
108
+ onError: onError,
109
+ onResolve: onResolve,
110
+ renderers: renderers,
111
+ actionOptions: actionOptions,
112
+ analytics: analytics,
113
+ testId: testId
114
+ });
115
+ }
86
116
  const resolvedBlockViewProps = extractBlockProps(data, meta, {
87
117
  analytics,
88
118
  origin: 'smartLinkEmbed',
@@ -7,7 +7,7 @@ import LinkWarningModal from './LinkWarningModal';
7
7
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "32.3.0",
10
+ packageVersion: "32.5.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -4,8 +4,10 @@ import { useCallback, useMemo } from 'react';
4
4
  import { useSmartLinkContext } from '@atlaskit/link-provider';
5
5
  import { ACTION_RESOLVING, ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
6
6
  import { auth } from '@atlaskit/outbound-auth-flow-client';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
8
9
  import { SmartLinkStatus } from '../../constants';
10
+ import { startUfoExperience } from '../analytics';
9
11
  import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
10
12
  import useInvokeClientAction from '../hooks/use-invoke-client-action';
11
13
  import useResolve from '../hooks/use-resolve';
@@ -119,19 +121,41 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
119
121
  fireEvent('track.applicationAccount.connected', {
120
122
  definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
121
123
  });
122
- analytics.operational.connectSucceededEvent({
123
- id: id,
124
- definitionId: definitionId,
125
- extensionKey: extensionKey
126
- });
124
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
125
+ startUfoExperience('smart-link-authenticated', id, {
126
+ extensionKey: extensionKey,
127
+ status: 'success'
128
+ });
129
+ fireEvent('operational.smartLink.connectSucceeded', {
130
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
131
+ });
132
+ } else {
133
+ analytics.operational.connectSucceededEvent({
134
+ id: id,
135
+ definitionId: definitionId,
136
+ extensionKey: extensionKey
137
+ });
138
+ }
127
139
  reload();
128
140
  }, function (err) {
129
- analytics.operational.connectFailedEvent({
130
- id: id,
131
- definitionId: definitionId,
132
- extensionKey: extensionKey,
133
- reason: err.type
134
- });
141
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
142
+ var _err$type;
143
+ startUfoExperience('smart-link-authenticated', id, {
144
+ extensionKey: extensionKey,
145
+ status: err.type
146
+ });
147
+ fireEvent('operational.smartLink.connectFailed', {
148
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
149
+ reason: (_err$type = err.type) !== null && _err$type !== void 0 ? _err$type : null
150
+ });
151
+ } else {
152
+ analytics.operational.connectFailedEvent({
153
+ id: id,
154
+ definitionId: definitionId,
155
+ extensionKey: extensionKey,
156
+ reason: err.type
157
+ });
158
+ }
135
159
  if (err.type === 'auth_window_closed') {
136
160
  analytics.ui.closedAuthEvent({
137
161
  display: appearance,
@@ -511,6 +511,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
511
511
  * @param id The unique ID for this Smart Link.
512
512
  * @param definitionId The definitionId of the Smart Link resolver invoked.
513
513
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
514
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
514
515
  */
515
516
  connectSucceededEvent: function connectSucceededEvent(_ref13) {
516
517
  var id = _ref13.id,
@@ -541,6 +542,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
541
542
  * @param definitionId The definitionId of the Smart Link resolver invoked.
542
543
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
543
544
  * @param reason The reason why the Smart Link connect account failed.
545
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
544
546
  */
545
547
  connectFailedEvent: function connectFailedEvent(_ref14) {
546
548
  var id = _ref14.id,
@@ -575,6 +577,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
575
577
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
576
578
  * @param resourceType The type of resource that was invoked. This is provider specific (e.g. File, PullRequest).
577
579
  * @param error An error representing why the Smart Link request failed.
580
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
578
581
  */
579
582
  instrument: function instrument(_ref15) {
580
583
  var id = _ref15.id,
@@ -602,11 +605,12 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
602
605
  }
603
606
  },
604
607
  /**
605
- * This fires an event that represents when a Smart Link renders unsuccessfuly.
608
+ * This fires an event that represents when a Smart Link renders unsuccessfully.
606
609
  * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
607
610
  * @param id The unique ID for this Smart Link.
608
611
  * @param error: An error representing why the Smart Link render failed.
609
612
  * @param errorInfo: Additional details about the error including the stack trace.
613
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
610
614
  */
611
615
  chunkloadFailedEvent: function chunkloadFailedEvent(_ref16) {
612
616
  var display = _ref16.display,
@@ -10,7 +10,7 @@ export var ANALYTICS_CHANNEL = 'media';
10
10
  export var context = {
11
11
  componentName: 'smart-cards',
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "32.3.0"
13
+ packageVersion: "32.5.0"
14
14
  };
15
15
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
16
16
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -57,6 +57,10 @@ export var fireSmartLinkEvent = function fireSmartLinkEvent(payload, createAnaly
57
57
  createAnalyticsEvent(payload).fire(ANALYTICS_CHANNEL);
58
58
  }
59
59
  };
60
+
61
+ /**
62
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
63
+ */
60
64
  export var resolvedEvent = function resolvedEvent(props) {
61
65
  return {
62
66
  action: 'resolved',
@@ -65,6 +69,10 @@ export var resolvedEvent = function resolvedEvent(props) {
65
69
  attributes: _objectSpread(_objectSpread({}, props), context)
66
70
  };
67
71
  };
72
+
73
+ /**
74
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
75
+ */
68
76
  export var unresolvedEvent = function unresolvedEvent(_ref) {
69
77
  var id = _ref.id,
70
78
  definitionId = _ref.definitionId,
@@ -159,6 +167,10 @@ export var invokeFailedEvent = function invokeFailedEvent(_ref3) {
159
167
  })
160
168
  };
161
169
  };
170
+
171
+ /**
172
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
173
+ */
162
174
  export var connectSucceededEvent = function connectSucceededEvent(_ref4) {
163
175
  var definitionId = _ref4.definitionId,
164
176
  extensionKey = _ref4.extensionKey,
@@ -178,6 +190,10 @@ export var connectSucceededEvent = function connectSucceededEvent(_ref4) {
178
190
  })
179
191
  };
180
192
  };
193
+
194
+ /**
195
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
196
+ */
181
197
  export var connectFailedEvent = function connectFailedEvent(_ref5) {
182
198
  var definitionId = _ref5.definitionId,
183
199
  extensionKey = _ref5.extensionKey,
@@ -461,6 +477,10 @@ export var uiLearnMoreLinkClickedEvent = function uiLearnMoreLinkClickedEvent()
461
477
  attributes: _objectSpread({}, context)
462
478
  };
463
479
  };
480
+
481
+ /**
482
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
483
+ */
464
484
  export var chunkloadFailedEvent = function chunkloadFailedEvent(_ref16) {
465
485
  var display = _ref16.display,
466
486
  error = _ref16.error,
@@ -4,6 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { getMeasure } from '../performance';
5
5
  import { resolvedEvent, unresolvedEvent } from './analytics';
6
6
  export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, chunkloadFailedEvent, connectSucceededEvent, connectFailedEvent, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent, uiSmartLinkStatusLozengeButtonClicked, uiSmartLinkStatusListItemButtonClicked, uiSmartLinkStatusOpenPreviewButtonClicked } from './analytics';
7
+
8
+ /**
9
+ * @deprecated remove with platform_smart-card-migrate-operational-analytics clean up
10
+ */
7
11
  export var instrumentEvent = function instrumentEvent(_ref) {
8
12
  var id = _ref.id,
9
13
  status = _ref.status,
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
4
5
  import { CardDisplay } from '../../constants';
5
6
  import { useSmartLink } from '../../state';
@@ -118,18 +119,39 @@ function Component(_ref) {
118
119
  useEffect(function () {
119
120
  measure.mark(id, state.status);
120
121
  if (state.status !== 'pending' && state.status !== 'resolving') {
121
- var _state$error;
122
122
  measure.create(id, state.status);
123
- analytics.operational.instrument({
124
- id: id,
125
- status: state.status,
126
- definitionId: definitionId,
127
- extensionKey: extensionKey !== null && extensionKey !== void 0 ? extensionKey : (_state$error = state.error) === null || _state$error === void 0 ? void 0 : _state$error.extensionKey,
128
- resourceType: resourceType,
129
- error: state.error
130
- });
123
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
124
+ var _state$error;
125
+ if (state.status === 'resolved') {
126
+ var _measure$getMeasure$d, _measure$getMeasure;
127
+ fireEvent('operational.smartLink.resolved', {
128
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
129
+ duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(id, state.status)) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null
130
+ });
131
+ } else if (((_state$error = state.error) === null || _state$error === void 0 ? void 0 : _state$error.type) !== 'ResolveUnsupportedError') {
132
+ fireEvent('operational.smartLink.unresolved', {
133
+ definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
134
+ reason: state.status,
135
+ error: state.error === undefined ? null : {
136
+ name: state.error.name,
137
+ kind: state.error.kind,
138
+ type: state.error.type
139
+ }
140
+ });
141
+ }
142
+ } else {
143
+ var _state$error2;
144
+ analytics.operational.instrument({
145
+ id: id,
146
+ status: state.status,
147
+ definitionId: definitionId,
148
+ extensionKey: extensionKey !== null && extensionKey !== void 0 ? extensionKey : (_state$error2 = state.error) === null || _state$error2 === void 0 ? void 0 : _state$error2.extensionKey,
149
+ resourceType: resourceType,
150
+ error: state.error
151
+ });
152
+ }
131
153
  }
132
- }, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational]);
154
+ }, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational, fireEvent]);
133
155
 
134
156
  // NB: once the smart-card has rendered into an end state, we capture
135
157
  // this as a successful render. These can be one of:
@@ -245,6 +267,7 @@ function Component(_ref) {
245
267
  return /*#__PURE__*/React.createElement(EmbedCard, {
246
268
  id: id,
247
269
  url: url,
270
+ renderers: renderers,
248
271
  cardState: state,
249
272
  iframeUrlType: embedIframeUrlType,
250
273
  handleAuthorize: services.length && handleAuthorize || undefined,
@@ -3,6 +3,8 @@ import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
3
3
  import { ErrorBoundary } from 'react-error-boundary';
4
4
  import { di } from 'react-magnetic-di';
5
5
  import uuid from 'uuid';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
6
8
  import { useSmartLinkAnalytics } from '../../state/analytics';
7
9
  import { importWithRetry } from '../../utils';
8
10
  import { isFlexibleUiCard } from '../../utils/flexible';
@@ -19,6 +21,8 @@ export function CardWithURLRenderer(props) {
19
21
  }),
20
22
  _useState2 = _slicedToArray(_useState, 1),
21
23
  id = _useState2[0];
24
+ var _useAnalyticsEvents = useAnalyticsEvents(),
25
+ fireEvent = _useAnalyticsEvents.fireEvent;
22
26
  useEffect(function () {
23
27
  // ComponentWillUnmount
24
28
  return function () {
@@ -65,11 +69,20 @@ export function CardWithURLRenderer(props) {
65
69
  // to the reliability of the smart-card front-end components.
66
70
  // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
67
71
  if (error.name === 'ChunkLoadError') {
68
- analytics.operational.chunkloadFailedEvent({
69
- display: appearance,
70
- error: error,
71
- errorInfo: errorInfo
72
- });
72
+ if (fg('platform_smart-card-migrate-operational-analytics')) {
73
+ fireEvent('operational.smartLink.chunkLoadFailed', {
74
+ display: appearance,
75
+ error: error,
76
+ errorInfo: errorInfo,
77
+ definitionId: null
78
+ });
79
+ } else {
80
+ analytics.operational.chunkloadFailedEvent({
81
+ display: appearance,
82
+ error: error,
83
+ errorInfo: errorInfo
84
+ });
85
+ }
73
86
  } else if (error.name !== 'APIError') {
74
87
  analytics.ui.renderFailedEvent({
75
88
  display: isFlexibleUi ? 'flexible' : appearance,
@@ -83,7 +96,7 @@ export function CardWithURLRenderer(props) {
83
96
  url: url !== null && url !== void 0 ? url : '',
84
97
  err: error
85
98
  });
86
- }, [analytics.operational, analytics.ui, appearance, id, onError, url, isFlexibleUi]);
99
+ }, [analytics.operational, analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
87
100
  if (!url) {
88
101
  throw new Error('@atlaskit/smart-card: url property is missing.');
89
102
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { extractBlockProps } from '../../extractors/block';
5
6
  import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
6
7
  import { extractEmbedProps } from '../../extractors/embed';
@@ -8,6 +9,7 @@ import { extractInlineProps } from '../../extractors/inline';
8
9
  import { getExtensionKey, hasAuthScopeOverrides } from '../../state/helpers';
9
10
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
10
11
  import { BlockCardResolvedView, BlockCardResolvingView } from '../BlockCard';
12
+ import FlexibleResolvedView from '../BlockCard/views/flexible/FlexibleResolvedView';
11
13
  import { InlineCardResolvedView } from '../InlineCard/ResolvedView';
12
14
  import { EmbedCardErroredView } from './views/ErroredView';
13
15
  import ForbiddenView from './views/forbidden-view';
@@ -17,9 +19,7 @@ import UnauthorizedView from './views/unauthorized-view';
17
19
  export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef) {
18
20
  var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
19
21
  var url = _ref.url,
20
- _ref$cardState = _ref.cardState,
21
- status = _ref$cardState.status,
22
- details = _ref$cardState.details,
22
+ cardState = _ref.cardState,
23
23
  handleAuthorize = _ref.handleAuthorize,
24
24
  handleErrorRetry = _ref.handleErrorRetry,
25
25
  handleFrameClick = _ref.handleFrameClick,
@@ -35,9 +35,12 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
35
35
  onIframeDwell = _ref.onIframeDwell,
36
36
  onIframeFocus = _ref.onIframeFocus,
37
37
  iframeUrlType = _ref.iframeUrlType,
38
- actionOptions = _ref.actionOptions;
38
+ actionOptions = _ref.actionOptions,
39
+ renderers = _ref.renderers;
39
40
  var _useAnalyticsEvents = useAnalyticsEvents(),
40
41
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
42
+ var status = cardState.status,
43
+ details = cardState.details;
41
44
  var data = details && details.data || getEmptyJsonLd();
42
45
  var meta = details && details.meta;
43
46
  var extensionKey = getExtensionKey(details);
@@ -45,6 +48,19 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
45
48
  switch (status) {
46
49
  case 'pending':
47
50
  case 'resolving':
51
+ if (fg('smart-card-remove-block-card-from-embed')) {
52
+ return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
53
+ url: url,
54
+ cardState: cardState,
55
+ onClick: handleFrameClick,
56
+ onError: onError,
57
+ onResolve: onResolve,
58
+ renderers: renderers,
59
+ actionOptions: actionOptions,
60
+ analytics: analytics,
61
+ testId: testId
62
+ });
63
+ }
48
64
  return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
49
65
  testId: "embed-card-resolving-view",
50
66
  inheritDimensions: inheritDimensions,
@@ -80,6 +96,19 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
80
96
  onClick: handleFrameClick
81
97
  }));
82
98
  }
99
+ if (fg('smart-card-remove-block-card-from-embed')) {
100
+ return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
101
+ url: url,
102
+ cardState: cardState,
103
+ onClick: handleFrameClick,
104
+ onError: onError,
105
+ onResolve: onResolve,
106
+ renderers: renderers,
107
+ actionOptions: actionOptions,
108
+ analytics: analytics,
109
+ testId: testId
110
+ });
111
+ }
83
112
  var resolvedBlockViewProps = extractBlockProps(data, meta, {
84
113
  analytics: analytics,
85
114
  origin: 'smartLinkEmbed',